/*
 * Copyright (c) 2009 Kathryn Huxtable and Kenneth Orr.
 *
 * This file is part of the SeaGlass Pluggable Look and Feel.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * $Id$
 */
package com.seaglasslookandfeel.painter;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.geom.Rectangle2D;

import javax.swing.JComponent;

import com.seaglasslookandfeel.painter.AbstractRegionPainter.PaintContext.CacheMode;

/**
 * PopupMenuSeparatorPainter implementation.
 * 
 * Based on Nimbus's PopupMenuSepatorPainter.
 */
public final class PopupMenuSeparatorPainter extends AbstractRegionPainter {
    public static enum Which {
        BACKGROUND_ENABLED
    }

    private Which                  state;
    private PaintContext           ctx;

    private Rectangle2D            rect      = new Rectangle2D.Float(0, 0, 0, 0);

    private Color                  color1    = decodeColor("nimbusBlueGrey", -0.008547008f, -0.03830409f, -0.039215684f, 0);

    // FIXME These are not assigned properly.
    private static final Insets    insets    = new Insets(7, 7, 7, 7);
    private static final Dimension dimension = new Dimension(86, 28);
    private static final CacheMode cacheMode = CacheMode.NINE_SQUARE_SCALE;
    private static final Double    maxH      = Double.POSITIVE_INFINITY;
    private static final Double    maxV      = Double.POSITIVE_INFINITY;

    public PopupMenuSeparatorPainter(Which state) {
        super();
        this.state = state;
        this.ctx = new PaintContext(insets, dimension, false, cacheMode, maxH, maxV);
    }

    @Override
    protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys) {
        switch (state) {
        case BACKGROUND_ENABLED:
            paintBackgroundEnabled(g);
            break;
        }
    }

    @Override
    protected final PaintContext getPaintContext() {
        return ctx;
    }

    private void paintBackgroundEnabled(Graphics2D g) {
        rect = decodeRect1();
        g.setPaint(color1);
        g.fill(rect);

    }

    private Rectangle2D decodeRect1() {
        rect.setRect(decodeX(0.0f), // x
            decodeY(1.0f), // y
            decodeX(3.0f) - decodeX(0.0f), // width
            decodeY(2.0f) - decodeY(1.0f)); // height
        return rect;
    }
}

@@ -1450,132 +1450,29 @@
   = 
-decodeColor(%22nimbusBlueGrey%22, -0.008547008f, -0.03830409f, -0.039215684f, 0);%0A%0A    // FIXME These are not assigned properly.
+new Color(0xdddddd);%0A
 %0A   
@@ -1530,18 +1530,18 @@
 ets(
-7, 7, 7, 7
+1, 1, 1, 1
 );%0A 
@@ -1604,14 +1604,12 @@
 ion(
-86, 28
+3, 3
 );%0A 
@@ -1669,24 +1669,17 @@
 de.N
-INE_SQUARE_SCALE
+O_CACHING
 ;%0A  
@@ -1727,32 +1727,11 @@
   = 
-Double.POSITIVE_INFINITY
+1.0
 ;%0A  
@@ -1779,32 +1779,11 @@
   = 
-Double.POSITIVE_INFINITY
+1.0
 ;%0A%0A 
@@ -1937,12 +1937,11 @@
 on, 
-fals
+tru
 e, c
@@ -2186,16 +2186,31 @@
 nabled(g
+, width, height
 );%0A     
@@ -2386,16 +2386,39 @@
 hics2D g
+, int width, int height
 ) %7B%0A    
@@ -2440,16 +2440,29 @@
 deRect1(
+width, height
 );%0A     
@@ -2550,16 +2550,37 @@
 deRect1(
+int width, int height
 ) %7B%0A    
@@ -2600,165 +2600,33 @@
 ect(
-decodeX(0.0f), // x%0A            decodeY(1.0f), // y%0A            decodeX(3.0f) - decodeX(0.0f), // width%0A            decodeY(2.0f) - decodeY(1.0f)); // height
+0, height / 2, width, 1);
 %0A   

Update to Sea Glass specification, that is, make the separator one pixel thick and make it the correct color.