FileDocCategorySizeDatePackage
GTKStyle.javaAPI DocJava SE 5 API65077Fri Aug 26 14:54:46 BST 2005com.sun.java.swing.plaf.gtk

GTKStyle

public class GTKStyle extends DefaultSynthStyle implements GTKConstants
SynthStyle implementation used in GTK. All painting is mapped to a GTKEngine.
version
1.116, 06/24/04
author
Scott Violet

Fields Summary
private static final String
ICON_PROPERTY_PREFIX
static final Color
BLACK_COLOR
static final Color
WHITE_COLOR
private static final Color[]
DEFAULT_COLORS
private static final int[]
DEFAULT_COLOR_MAP
State the color array at an particular index in DEFAULT_COLORS represents.
private static final Font
DEFAULT_FONT
private static final HashMap
DATA
Backing style properties that are used if the style does not defined the property.
private static final HashMap
CLASS_SPECIFIC_MAP
Maps from a key that is passed to Style.get to the equivalent class specific key.
private static final GTKGraphicsUtils
GTK_GRAPHICS
static final int
UNDEFINED_THICKNESS
Indicates the thickness has not been set.
private int
xThickness
private int
yThickness
private CircularIdentityList
classSpecificValues
Represents the values that are specific to a particular class. This is a CircularIdentityList of CircularIdentityLists, where the first level entries are gtk class names, and the second CircularIdentityLists contains the actual key/value pairs.
private GTKStockIconInfo[]
icons
Icons.
Constructors Summary
public GTKStyle(DefaultSynthStyle style)
Creates a new GTKStyle that is a copy of the passed in style.

        super(style);
        if (style instanceof GTKStyle) {
            GTKStyle gStyle = (GTKStyle)style;
            xThickness = gStyle.xThickness;
            yThickness = gStyle.yThickness;
            icons = gStyle.icons;
            classSpecificValues = cloneClassSpecificValues(
                                       gStyle.classSpecificValues);
        }
    
public GTKStyle()
Creates an empty GTKStyle.

        super(new Insets(-1, -1, -1, -1), true, null, null);
    
public GTKStyle(Font font)
Creates a GTKStyle with the specified font.

param
font Font to use in GTK.

        this();
        setFont(font);
    
GTKStyle(StateInfo[] states, CircularIdentityList classSpecificValues, Font font, int xThickness, int yThickness, GTKStockIconInfo[] icons)
Creates a GTKStyle with the specified parameters.

param
states StateInfo specifying the colors and fonts to use for a particular state.
param
classSpecificValues Values that are specific to a particular class
param
font to use.
param
xThickness X thickness
param
yThickness Y thickness
param
GTKStockIconInfo stock icons for this style.

        super(new Insets(-1, -1, -1, -1), true, states, null);
        setFont(font);
        this.xThickness = xThickness;
        this.yThickness = yThickness;
        this.icons = icons;
        this.classSpecificValues = classSpecificValues;
    
Methods Summary
static voidaddClassSpecificValues(CircularIdentityList from, CircularIdentityList to)
Adds the data from one set of class specific values into another.

param
from the list to grab data from (may be null)
param
to the list to add data to (may not be null)

        if (to == null) {
            throw new IllegalArgumentException("to may not be null");
        }
        
        if (from == null) {
            return;
        }

        synchronized(from) {
            Object firstKey = from.next();
            if (firstKey != null) {
                Object key = firstKey;
                do {
                    CircularIdentityList cList = ((CircularIdentityList)
                            from.get());
                    CircularIdentityList oSublist = (CircularIdentityList)
                                     to.get(key);
                    if (oSublist == null) {
                        to.set(key, cList.clone());
                    }
                    else {
                        Object cFirstKey = cList.next();

                        if (cFirstKey != null) {
                            Object cKey = cFirstKey;
                            do {
                                oSublist.set(cKey, cList.get());
                                cKey = cList.next();
                            } while (cKey != cFirstKey);
                        }
                    }
                    key = from.next();
                } while (key != firstKey);
            }
        }
    
voidaddLabelProperties(com.sun.java.swing.plaf.gtk.GTKStyle style)
Adds the specific label based properties from style to this style.

        StateInfo[] states = getStateInfo();
        StateInfo[] oStates = style.getStateInfo();
        // Take the font
        setFont(style.getFontForState(null, null, 0));
        // And TEXT_FOREGROUND
        if (states == null) {
            if (oStates == null) {
                return;
            }
            states = new StateInfo[oStates.length];
            for (int counter = 0; counter < oStates.length; counter++) {
                Color color = oStates[counter].getColor(
                                     GTKColorType.FOREGROUND);

                states[counter] = createStateInfo(oStates[counter].
                     getComponentState(), GTKColorType.TEXT_FOREGROUND, color);
            }
        }
        else {
            // Reset the text foreground of all our states, this will ensure
            // the correct color is picked up if style doesn't specify a
            // text color.
            for (int counter = states.length - 1; counter >= 0; counter--) {
                ((GTKStateInfo)states[counter]).setColor(
                               GTKColorType.TEXT_FOREGROUND, null);
            }
            if (oStates != null) {
                for (int oCounter = oStates.length - 1; oCounter >= 0;
                         oCounter--) {
                    boolean matched = false;
                    StateInfo oState = oStates[oCounter];
                    int componentState = oState.getComponentState();
                    Color color = oState.getColor(GTKColorType.FOREGROUND);

                    for (int tCounter = states.length - 1; tCounter >= 0;
                             tCounter--) {
                        if (componentState == states[tCounter].
                                     getComponentState()) {
                            ((GTKStateInfo)states[tCounter]).setColor(
                                      GTKColorType.TEXT_FOREGROUND, color);
                            matched = true;
                            break;
                        }
                    }
                    if (!matched) {
                        StateInfo[] newStates = new StateInfo[states.length+1];
                        System.arraycopy(states, 0, newStates, 0,
                                         states.length);
                        newStates[states.length] = createStateInfo(
                                 componentState, GTKColorType.TEXT_FOREGROUND,
                                 color);
                        states = newStates;
                    }
                }
            }
        }
    
public sun.swing.plaf.synth.DefaultSynthStyleaddTo(sun.swing.plaf.synth.DefaultSynthStyle style)
Merges the contents of this Style with that of the passed in Style, returning the resulting merged syle. Properties of this GTKStyle will take precedence over those of the passed in DefaultSynthStyle. For example, if this style specifics a non-null font, the returned style will have its font so to that regardless of the style's font.

param
style Style to add our styles to
return
Merged style.

        if (!(style instanceof GTKStyle)) {
            style = new GTKStyle(style);
        }
        GTKStyle gtkStyle = (GTKStyle)super.addTo(style);
        if (xThickness != UNDEFINED_THICKNESS) {
            gtkStyle.xThickness = xThickness;
        }
        if (yThickness != UNDEFINED_THICKNESS) {
            gtkStyle.yThickness = yThickness;
        }
        if (gtkStyle.icons == null) {
            gtkStyle.icons = icons;
        }
        else if (icons != null) {
            GTKStockIconInfo[] mergedIcons =
                new GTKStockIconInfo[gtkStyle.icons.length + icons.length];
                
            System.arraycopy(icons, 0, mergedIcons, 0, icons.length);
            System.arraycopy(gtkStyle.icons, 0, mergedIcons, icons.length, gtkStyle.icons.length);
            
            gtkStyle.icons = mergedIcons;
        }
        
        if (gtkStyle.classSpecificValues == null) {
            gtkStyle.classSpecificValues =
                cloneClassSpecificValues(classSpecificValues);
        } else {
            addClassSpecificValues(classSpecificValues, gtkStyle.classSpecificValues);
        }
            
        return gtkStyle;
    
static java.awt.ColorcalculateDarkColor(java.awt.Color bg)
Calculates the DARK color from the background color.

        return GTKColorType.adjustColor(bg, 1.0f, .7f, .7f);
    
static java.awt.ColorcalculateLightColor(java.awt.Color bg)
Calculates the LIGHT color from the background color.


                 
        
        return GTKColorType.adjustColor(bg, 1.0f, 1.3f, 1.3f);
    
static java.awt.ColorcalculateMidColor(java.awt.Color lightColor, java.awt.Color darkColor)
Calculates the MID color from the light and dark colors.

        int light = lightColor.getRGB();
        int dark = darkColor.getRGB();
        int rLight = (light & 0xFF0000) >> 16;
        int rDark = (dark & 0xFF0000) >> 16;
        int gLight = (light & 0x00FF00) >> 8;
        int gDark = (dark & 0x00FF00) >> 8;
        int bLight = (light & 0xFF);
        int bDark = (dark & 0xFF);
        return new ColorUIResource((((rLight + rDark) / 2) << 16) |
                                   (((gLight + gDark) / 2) << 8) |
                                   ((bLight + bDark) / 2));
    
static java.awt.ColorcalculateMidColor(java.awt.Color bg)
Calculates the MID color from the background color.

        return calculateMidColor(calculateLightColor(bg),
                                 calculateDarkColor(bg));
    
private static java.lang.StringclassSpecValsToString(CircularIdentityList parent)

        StringBuffer buf = new StringBuffer();

        Object parentFirst = parent.next();
            
        if (parentFirst == null) {
            return "";
        }

        Object parentKey = parentFirst;

        do {
            buf.append(parentKey).append('\n");

            CircularIdentityList child = (CircularIdentityList)parent.get();

            Object childFirst = child.next();
                
            if (childFirst == null) {
                break;
            }
                    
            Object childKey = childFirst;
                    
            do {
                buf.append("    ").append(childKey).append('=").append(child.get()).append('\n");
                childKey = child.next();
            } while (childKey != childFirst);
            
            parentKey = parent.next();
        } while (parentKey != parentFirst);

        // remove last newline
        buf.deleteCharAt(buf.length() - 1);

        return buf.toString();
    
public java.lang.Objectclone()
Creates a clone of this GTKStyle.

return
Clone of this GTKStyle.

        GTKStyle style = (GTKStyle)super.clone();

        style.classSpecificValues = cloneClassSpecificValues(
                                         style.classSpecificValues);
        return style;
    
static CircularIdentityListcloneClassSpecificValues(CircularIdentityList list)
Clones the class specific values.

        if (list == null) {
            return null;
        }
        CircularIdentityList clone;
        synchronized(list) {
            Object firstKey = list.next();
            if (firstKey == null) {
                // Empty list
                return null;
            }
            clone = new CircularIdentityList();
            Object key = firstKey;
            do {
                clone.set(key, ((CircularIdentityList)list.get()).clone());
                key = list.next();
            } while (key != firstKey);
        }
        return clone;
    
com.sun.java.swing.plaf.gtk.GTKStyle$GTKStateInfocreateStateInfo(int state, javax.swing.plaf.synth.ColorType type, java.awt.Color color)
Creates a StateInfo with the specified component state, ColorType and color. Subclasses that create a custom GTKStateInfo will need to subclass and override this.

        Color[] colors = new Color[GTKColorType.MAX_COUNT];

        colors[type.getID()] = color;
        return new GTKStateInfo(state, null, colors, null);
    
booleanfillBackground(javax.swing.plaf.synth.SynthContext context, int state)
Returns true if the style should fill in the background of the specified context for the specified state.

        GTKStateInfo info = (GTKStateInfo)getStateInfo(state);

        if (info != null) {
            Object backgroundImage = info.getBackgroundImage();

            if (backgroundImage == "<none>" || backgroundImage == null) {
                return true;
            }
            return false;
        }
        return true;
    
java.awt.ImagegetBackgroundImage(javax.swing.plaf.synth.SynthContext context, int state)
Returns the Icon to fill the background in with for the specified context and state.

        GTKStateInfo info = (GTKStateInfo)getStateInfo(state);

        if (info != null) {
            Object backgroundImage = info.getBackgroundImage();

            if (backgroundImage instanceof Image) {
                return (Image)backgroundImage;
            }
        }
        return null;
    
public booleangetClassSpecificBoolValue(javax.swing.plaf.synth.SynthContext context, java.lang.String key, boolean defaultValue)
Convenience method to get a class specific Boolean value.

param
context SynthContext indentifying requestor
param
key Key identifying class specific value
param
defaultValue Returned if there is no value for the specified type
return
Value, or defaultValue if key is not defined

        Object value = getClassSpecificValue(context, key);

        if (value instanceof Boolean) {
            return ((Boolean)value).booleanValue();
        }
        return defaultValue;
    
public java.awt.InsetsgetClassSpecificInsetsValue(javax.swing.plaf.synth.SynthContext context, java.lang.String key, java.awt.Insets defaultValue)
Convenience method to get a class specific Insets value.

param
context SynthContext indentifying requestor
param
key Key identifying class specific value
param
defaultValue Returned if there is no value for the specified type
return
Value, or defaultValue if key is not defined

        Object value = getClassSpecificValue(context, key);

        if (value instanceof Insets) {
            return (Insets)value;
        }
        return defaultValue;
    
public intgetClassSpecificIntValue(javax.swing.plaf.synth.SynthContext context, java.lang.String key, int defaultValue)
Convenience method to get a class specific integer value.

param
context SynthContext indentifying requestor
param
key Key identifying class specific value
param
defaultValue Returned if there is no value for the specified type
return
Value, or defaultValue if key is not defined

        Object value = getClassSpecificValue(context, key);

        if (value instanceof Number) {
            return ((Number)value).intValue();
        }
        return defaultValue;
    
public java.lang.ObjectgetClassSpecificValue(javax.swing.plaf.synth.Region region, java.lang.String key)
Returns the value for a class specific property. A class specific value is a value that will be picked up based on class hierarchy. For example, a value specified for JComponent would be inherited on JButtons and JTrees, but not Button.

Note, the key used here should only contain the letters A-Z, a-z, the digits 0-9, and the '-' character. If you need to request a value for a key having characters outside this list, replace any other characters with '-'. (ie. "default_border" should be "default-border").

param
region Region requesting class specific value
param
key Key identifying class specific value
return
Value, or null if one has not been defined.

        if (classSpecificValues != null) {
            String gtkClass = GTKStyleFactory.gtkClassFor(region);

            while (gtkClass != null) {
                CircularIdentityList classValues = (CircularIdentityList)
                                classSpecificValues.get(gtkClass);

                if (classValues != null) {
                    Object value = classValues.get(key);

                    if (value != null) {
                        return value;
                    }
                }
                gtkClass = GTKStyleFactory.gtkSuperclass(gtkClass);
            }
        }
        return null;
    
public java.lang.ObjectgetClassSpecificValue(javax.swing.plaf.synth.SynthContext context, java.lang.String key)
Returns the value for a class specific property. A class specific value is a value that will be picked up based on class hierarchy. For example, a value specified for JComponent would be inherited on JButtons and JTrees, but not Button.

Note, the key used here should only contain the letters A-Z, a-z, the digits 0-9, and the '-' character. If you need to request a value for a key having characters outside this list, replace any other characters with '-'. (ie. "default_border" should be "default-border").

param
context SynthContext indentifying requestor
param
key Key identifying class specific value
return
Value, or null if one has not been defined.

        return getClassSpecificValue(context.getRegion(), key);
    
public java.awt.ColorgetColor(javax.swing.JComponent c, javax.swing.plaf.synth.Region id, int state, javax.swing.plaf.synth.ColorType type)
getColor is overriden to map the state from a Synth state to the GTK state, this should be not used when you have already mapped the state. Additionally this will map TEXT_FOREGROUND to the c.getForeground() if it is non-null and not a UIResource.

param
c JComponent the style is associated with
param
id Region identifier
param
state State of the region.
param
type Type of color being requested.
return
Color to render with

        if (id == Region.LABEL && type == ColorType.TEXT_FOREGROUND) {
            type = ColorType.FOREGROUND;
        }
        state = GTKLookAndFeel.synthStateToGTKState(id, state);
        if (!id.isSubregion() &&
                (state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
            if (type == ColorType.BACKGROUND) {
                return c.getBackground();
            }
            else if (type == ColorType.FOREGROUND) {
                return c.getForeground();
            }
            else if (type == ColorType.TEXT_FOREGROUND) {
                Color fg = c.getForeground();
                if (fg != null && !(fg instanceof UIResource)) {
                    // Only use the fg for text if specified.
                    return fg;
                }
            }
        }
        return getColorForState(c, id, state, type);
    
protected java.awt.ColorgetColorForState(javax.swing.JComponent c, javax.swing.plaf.synth.Region id, int state, javax.swing.plaf.synth.ColorType type)
Returns the color for the specified state. This redirects to the JComponent c as necessary. If this does not redirect to the JComponent getColorForState is invoked.

param
c JComponent the style is associated with
param
id Region identifier
param
state State of the region.
param
type Type of color being requested.
return
Color to render with

        Color color = super.getColorForState(c, id, state, type);

        if (color != null) {
            return color;
        }
        if (type == ColorType.FOCUS) {
            return BLACK_COLOR;
        }
        else if (type == GTKColorType.BLACK) {
            return BLACK_COLOR;
        }
        else if (type == GTKColorType.WHITE) {
            return WHITE_COLOR;
        }
        if (type == ColorType.TEXT_FOREGROUND && (GTKStyleFactory.
                    isLabelBearing(id) || id == Region.MENU_ITEM_ACCELERATOR ||
                    id == Region.TABBED_PANE_TAB)) {
            type = ColorType.FOREGROUND;
        }
        else if (id == Region.TABLE || id == Region.LIST ||
                 id == Region.TREE || id == Region.TREE_CELL){
            if (type == ColorType.FOREGROUND) {
                type = ColorType.TEXT_FOREGROUND;
                if (state == SynthConstants.PRESSED) {
                    state = SynthConstants.SELECTED;
                }
            }
            else if (type == ColorType.BACKGROUND) {
                type = ColorType.TEXT_BACKGROUND;
                if (state == SynthConstants.PRESSED) {
                    state = SynthConstants.SELECTED;
                }
            }
        }
        return getDefaultColor(c, id, state, type);
    
static java.awt.Color[]getColorsFrom(java.awt.Color bg, java.awt.Color fg)
Creates an array of colors populated based on the passed in the background color. Specifically this sets the BACKGROUND, LIGHT, DARK, MID, BLACK, WHITE and FOCUS colors from that of color, which is assumed to be the background.

        Color lightColor = calculateLightColor(bg);
        Color darkColor = calculateDarkColor(bg);
        Color midColor = calculateMidColor(lightColor, darkColor);
        Color[] colors = new Color[GTKColorType.MAX_COUNT];
        colors[GTKColorType.BACKGROUND.getID()] = bg;
        colors[GTKColorType.LIGHT.getID()] = lightColor;
        colors[GTKColorType.DARK.getID()] = darkColor;
        colors[GTKColorType.MID.getID()] = midColor;
        colors[GTKColorType.BLACK.getID()] = BLACK_COLOR;
        colors[GTKColorType.WHITE.getID()] = WHITE_COLOR;
        colors[GTKColorType.FOCUS.getID()] = BLACK_COLOR;
        colors[GTKColorType.FOREGROUND.getID()] = fg;
        colors[GTKColorType.TEXT_FOREGROUND.getID()] = fg;
        colors[GTKColorType.TEXT_BACKGROUND.getID()] = WHITE_COLOR;
        return colors;
    
java.awt.ColorgetDefaultColor(javax.swing.JComponent c, javax.swing.plaf.synth.Region id, int state, javax.swing.plaf.synth.ColorType type)
Returns the Color to use if the GTKStyle does not specify a color.

param
c JComponent the style is associated with
param
id Region identifier
param
state State of the region.
param
type Type of color being requested.
return
Color to render with

        if (type == ColorType.FOCUS) {
            return BLACK_COLOR;
        }
        else if (type == GTKColorType.BLACK) {
            return BLACK_COLOR;
        }
        else if (type == GTKColorType.WHITE) {
            return WHITE_COLOR;
        }
        for (int counter = DEFAULT_COLOR_MAP.length - 1;
                     counter >= 0; counter--) {
            if ((DEFAULT_COLOR_MAP[counter] & state) != 0) {
                if (type.getID() < DEFAULT_COLORS[counter].length) {
                    return DEFAULT_COLORS[counter][type.getID()];
                }
            }
        }
        if (type.getID() < DEFAULT_COLORS[2].length) {
            return DEFAULT_COLORS[2][type.getID()];
        }
        return null;
    
public java.lang.ObjectgetDefaultValue(javax.swing.plaf.synth.SynthContext context, java.lang.Object key)

        // See if this is a class specific value.
        Object classKey = CLASS_SPECIFIC_MAP.get(key);
        Object value = null;

        if (classKey != null) {
            value = getClassSpecificValue(context, (String)classKey);
            if (value != null) {
                return value;
            }
        }
            
        if (key == "ScrollPane.viewportBorderInsets") {
            return GTKPainter.INSTANCE.getScrollPaneInsets(context,
                                                     new Insets(0,0,0,0));
        } else if (key == "Slider.tickColor") {
            return getColor(context.getComponent(), context.getRegion(),
                            context.getComponentState(), ColorType.FOREGROUND);
        }
        synchronized (DATA) {
            value = DATA.get(key);
        }
        if (value instanceof StyleSpecificValue) {
            put(key, ((StyleSpecificValue)value).getValue(context));
        }
        if (value == null && key != "engine") {
            // For backward compatability we'll fallback to the UIManager.
            // We don't go to the UIManager for engine as the engine is GTK
            // specific.
            value = UIManager.get(key);
            if (key == "Table.rowHeight") {
                int focusLineWidth = getClassSpecificIntValue(
                         context, "focus-line-width", 0);
                if (value == null && focusLineWidth > 0) {
                    value = new Integer(16 + 2 * focusLineWidth);
                }
            }
        }
        // Don't call super, we don't want to pick up defaults from
        // SynthStyle.
        return value;
    
public com.sun.java.swing.plaf.gtk.GTKEnginegetEngine(javax.swing.plaf.synth.SynthContext context)
Returns the object used to renderer the look.

param
context SynthContext indentifying requestor
return
GTKEngine used to provide the look

        GTKEngine engine = (GTKEngine)get(context, "engine");

        if (engine == null) {
            return GTKEngine.INSTANCE;
        }
        return engine;
    
protected java.awt.FontgetFontForState(javax.swing.JComponent c, javax.swing.plaf.synth.Region id, int state)
Returns the font for the specified state. This should NOT callback to the JComponent.

param
c JComponent the style is associated with
param
id Region identifier
param
state State of the region.
return
Font to render with

        state = GTKLookAndFeel.synthStateToGTKState(id, state);

        Font f = super.getFontForState(c, id, state);

        if (f == null) {
            return DEFAULT_FONT;
        }
        return f;
    
java.awt.ColorgetGTKColor(int state, javax.swing.plaf.synth.ColorType type)

        return getGTKColor(null, null, state, type);
    
public java.awt.ColorgetGTKColor(javax.swing.JComponent c, javax.swing.plaf.synth.Region id, int state, javax.swing.plaf.synth.ColorType type)
This method is to be used from within GTK when do NOT want the component state to be mapped. It will NOT remap the state as the other various getters do.

param
c JComponent the style is associated with
param
id Region identifier
param
state State of the region.
param
type Type of color being requested.
return
Color to render with

        // NOTE: c and id are only ever null when this is called from
        // GTKLookAndFeel.loadSystemColorDefaults.
        if (c != null && id != null) {
            if (!id.isSubregion() &&
                (state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
                if (type == ColorType.BACKGROUND) {
                    Color bg = c.getBackground();
                    if (!(bg instanceof UIResource)) {
                        return bg;
                    }
                }
                else if (type == ColorType.FOREGROUND) {
                    Color fg = c.getForeground();
                    if (!(fg instanceof UIResource)) {
                        return fg;
                    }
                }
                else if (type == ColorType.TEXT_FOREGROUND) {
                    Color fg = c.getForeground();
                    if (!(fg instanceof UIResource)) {
                        return fg;
                    }
                }
                else if (type == ColorType.TEXT_BACKGROUND) {
                    Color bg = c.getBackground();
                    if (!(bg instanceof UIResource)) {
                        return bg;
                    }
                }
            }
        }
        Color color = super.getColorForState(c, id, state, type);
        if (color != null) {
            return color;
        }
        return getDefaultColor(c, id, state, type);
    
public javax.swing.plaf.synth.SynthGraphicsUtilsgetGraphicsUtils(javax.swing.plaf.synth.SynthContext context)

        return GTK_GRAPHICS;
    
private java.awt.ImagegetImageFromIcon(javax.swing.Icon icon, boolean requireBufferedImage)

        Image img = null;
        
        if (icon instanceof ImageIcon) { 
            img = ((ImageIcon)icon).getImage();
            if (requireBufferedImage && !(img instanceof BufferedImage)) {
                img = null;
            }
        }
        if (img == null) { 
            img = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
                                    BufferedImage.TYPE_INT_ARGB);                             
            Graphics g = img.getGraphics(); 
            icon.paintIcon(null, g, 0, 0); 
            g.dispose(); 
        } 
        return img;
    
public java.awt.InsetsgetInsets(javax.swing.plaf.synth.SynthContext state, java.awt.Insets insets)
Returns the Insets. If to is non-null the resulting insets will be placed in it, otherwise a new Insets object will be created and returned.

param
context SynthContext indentifying requestor
param
to Where to place Insets
return
Insets.

        insets = super.getInsets(state, insets);

        if (insets.top == -1) {
            insets.left = insets.right = insets.top = insets.bottom = 0;
            insets = GTKPainter.INSTANCE.getInsets(state, insets);
        }
        return insets;
    
public javax.swing.plaf.synth.SynthPaintergetPainter(javax.swing.plaf.synth.SynthContext state)
Returns a SynthPainter that will route the appropriate calls to a GTKEngine.

param
state SynthContext indentifying requestor
return
SynthPainter

        return GTKPainter.INSTANCE;
    
static java.lang.StringgetStateName(int state, java.lang.String undef)

        switch(state) {
            case SynthConstants.ENABLED: return "NORMAL";
            case SynthConstants.PRESSED: return "ACTIVE";
            case SynthConstants.SELECTED: return "SELECTED";
            case SynthConstants.MOUSE_OVER: return "PRELIGHT";
            case SynthConstants.DISABLED: return "INSENSITIVE";
            case UNDEFINED: return undef;
        }
        
        return "UNKNOWN";
    
private javax.swing.IcongetStockIcon(javax.swing.plaf.synth.SynthContext context, java.lang.String key, int type)

        Icon icon = null;
        GTKStockIconInfo iconInfo = null;
        GTKIconSource bestSource = null;
        int direction = LTR;
        
        if (context != null) {
            ComponentOrientation co = context.getComponent().
                                              getComponentOrientation();

            if (co == null || co.isLeftToRight()) {
                direction = LTR;
            }
            else {
                direction = RTL;
            }
        }
        // See if the style defines an icon
        if (icons != null) {
            for (int i = 0; i < icons.length; i++) {
                // find the first one that matches our key
                if (icons[i].getKey() == key) {
                    iconInfo = icons[i];
                    break;
                }
            }
            
            if (iconInfo != null) {
                // PENDING(shannonh) - pass in actual state
                bestSource = iconInfo.getBestIconSource(direction,
                                                        SynthConstants.ENABLED,
                                                        type);
            }
            
            if (bestSource != null) {
                icon = bestSource.toIcon();
            }
        }
        
        if (icon == null) {
            // Use a default icon
            String propName = ICON_PROPERTY_PREFIX + key + '." + type + '." +
                              (direction == RTL ? "rtl" : "ltr"); 
            Image img = (Image)Toolkit.getDefaultToolkit().
                                       getDesktopProperty(propName);
            if (img != null) {
                icon = new ImageIcon(img);
                return icon;
            } else {
                icon = (Icon)((UIDefaults.LazyValue)LookAndFeel.makeIcon(
                              GTKStyle.class, "resources/" + key + "-" + type +
                              ".png")).createValue(null);
            }
        }
        
        if (icon == null) {
            return null;
        }
        BufferedImage image = null; 

        // If the stock icon we found had a wildcard size, 
        // we force the size to match that requested 
        if (bestSource == null || bestSource.getSize() == UNDEFINED) { 
            Dimension iconSize = GTKStockIconInfo.getIconSize(type); 
            
            if (iconSize != null && (icon.getIconWidth() != iconSize.width || 
                    icon.getIconHeight() != iconSize.height)) { 
                image = new BufferedImage(iconSize.width, iconSize.height, 
                        BufferedImage.TYPE_INT_ARGB); 
                
                Graphics2D g2d = (Graphics2D)image.getGraphics(); 
                
                // for nicer scaling 
                g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 
                        RenderingHints.VALUE_INTERPOLATION_BILINEAR); 
                
                Image oldImage = getImageFromIcon(icon, false); 
                g2d.drawImage(oldImage, 0, 0, iconSize.width, iconSize.height, null); 
                g2d.dispose(); 
            }
        }
/* This is not done for now. We cache icons and use cached copies regardless
   of the component state, so we don't want to cache desaturated icons
   
        if (bestSource == null || bestSource.getState() == UNDEFINED) { 
            // We may need to change saturation for some states
            int state = context.getComponentState();
            if (state == SynthConstants.DISABLED ||
                state == SynthConstants.MOUSE_OVER) {
                
                if (image == null) {
                    image = (BufferedImage)getImageFromIcon(icon, true);
                }
                float rescaleFactor =
                        (state == SynthConstants.DISABLED ? 0.8f : 1.2f); 
                RescaleOp op = new RescaleOp(rescaleFactor, 0, null);
                // RescaleOp allows for in-place filtering
                op.filter(image, image);
            }
        }
*/        
        if (image != null) {
            icon = new ImageIcon(image);
        }
        return icon;
    
public intgetXThickness()
Returns the X thickness to use for this GTKStyle.

return
x thickness.

        return xThickness;
    
public intgetYThickness()
Returns the Y thickness to use for this GTKStyle.

return
x thickness.

        return yThickness;
    
public voidinstallDefaults(javax.swing.plaf.synth.SynthContext context)
{@inheritDoc}

        super.installDefaults(context);
        if (!context.getRegion().isSubregion()) {
            context.getComponent().putClientProperty(
                SwingUtilities2.AA_TEXT_PROPERTY_KEY,
                GTKLookAndFeel.aaText);
        }        
    
public booleanisOpaque(javax.swing.plaf.synth.SynthContext context)
Returns the value to initialize the opacity property of the Component to. A Style should NOT assume the opacity will remain this value, the developer may reset it or override it.

param
context SynthContext indentifying requestor
return
opaque Whether or not the JComponent is opaque.

        Region region = context.getRegion();
        if (region == Region.COMBO_BOX ||
              region == Region.DESKTOP_PANE ||
              region == Region.DESKTOP_ICON ||
              region == Region.EDITOR_PANE ||
              region == Region.FORMATTED_TEXT_FIELD ||
              region == Region.INTERNAL_FRAME ||
              region == Region.LIST ||
              region == Region.MENU_BAR ||
              region == Region.PASSWORD_FIELD || 
              region == Region.POPUP_MENU ||
              region == Region.PROGRESS_BAR ||
              region == Region.ROOT_PANE ||
              region == Region.SCROLL_PANE ||
              region == Region.SPINNER ||
              region == Region.TABLE ||
              region == Region.TEXT_AREA ||
              region == Region.TEXT_FIELD ||
              region == Region.TEXT_PANE ||
              region == Region.TOOL_BAR_DRAG_WINDOW ||
              region == Region.TOOL_TIP ||
              region == Region.TREE ||
              region == Region.VIEWPORT) {
            return true;
        }
        Component c = context.getComponent();
        String name = c.getName();
        if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") {
            return true;
        }
        return false;
    
voidput(java.lang.Object key, java.lang.Object value)
Adds a value specific to the style.

        Map data = getData();
        if (data== null) {
            data = new HashMap();
            setData(data);
        }
        data.put(key, value);
    
public java.lang.StringtoString()

        StringBuffer buf = new StringBuffer(super.toString());

        if (xThickness != UNDEFINED_THICKNESS) {
            buf.append("xt=").append(String.valueOf(xThickness)).append('\n");
        }

        if (yThickness != UNDEFINED_THICKNESS) {
            buf.append("yt=").append(String.valueOf(yThickness)).append('\n");
        }

        if (classSpecificValues != null) {
            buf.append("*** Properties ***\n");
            buf.append(classSpecValsToString(classSpecificValues)).append('\n");
        }

        if (icons != null) {
            buf.append("*** Stock Icons ***\n");
            for (int i = 0; i < icons.length; i++) {
                buf.append(icons[i].toString()).append('\n");
            }
        }

        // remove last newline
        buf.deleteCharAt(buf.length() - 1);

        return buf.toString();