FileDocCategorySizeDatePackage
BlueprintStyle.javaAPI DocJava SE 5 API21308Fri Aug 26 14:54:44 BST 2005com.sun.java.swing.plaf.gtk

BlueprintStyle

public class BlueprintStyle extends GTKStyle implements GTKConstants
BlueprintStyle extends GTKStyle adding support for a set of Infos.
version
1.12 12/19/03
author
Scott Violet

Fields Summary
private static final GTKEngine
BLUEPRINT_ENGINE
There should only ever be one blueprint engine.
private static final BlueprintGraphicsUtils
BLUEPRINT_GRAPHICS
private Info[]
info
Set of Infos used to determine what to paint.
private boolean
iconColorize
Comes from the top level icon_colorize setting in rc files.
private String[]
iconAncestorTypes
Comes from the top level icon_colorize_ancestor_type setting in rec files. These Strings will all be interned by the parser.
private Color
colorizeColor
Comes from the top level colorize_color setting in rc files.
Constructors Summary
public BlueprintStyle(DefaultSynthStyle style)
Creates a duplicate of the passed in style.



                 
       
        super(style);
        if (style instanceof BlueprintStyle) {
            BlueprintStyle bpStyle = (BlueprintStyle)style;
            this.info = bpStyle.info;
            this.iconColorize = bpStyle.iconColorize;
            this.iconAncestorTypes = bpStyle.iconAncestorTypes;
            this.colorizeColor = bpStyle.colorizeColor;
        }
    
public BlueprintStyle(StateInfo[] states, CircularIdentityList classSpecificValues, Font font, int xThickness, int yThickness, GTKStockIconInfo[] icons, Info[] info, boolean iconColorize, String[] iconAncestorTypes, Color colorizeColor)
Creates a BlueprintStyle from the passed in arguments.

        super(states, classSpecificValues, font, xThickness, yThickness, icons);
        this.info = info;
        this.iconColorize = iconColorize;
        this.iconAncestorTypes = iconAncestorTypes;
        this.colorizeColor = colorizeColor;
    
Methods Summary
public sun.swing.plaf.synth.DefaultSynthStyleaddTo(sun.swing.plaf.synth.DefaultSynthStyle s)
Adds the state of this BlueprintStyle to that of s returning a combined SynthStyle.

        if (!(s instanceof BlueprintStyle)) {
            s = new BlueprintStyle(s);
        }
        BlueprintStyle style = (BlueprintStyle)super.addTo(s);
        if (info != null) {
            if (style.info == null) {
                style.info = info;
            }
            else {
                // Place the more specific first.
                Info[] merged = new Info[style.info.length + info.length];
                System.arraycopy(info, 0, merged, 0, info.length);
                System.arraycopy(style.info, 0, merged, info.length,
                                 style.info.length);
                style.info = merged;
            }
        }
        
        // like the real blueprint, we only overwrite when iconColorize is true

        if (iconColorize) {
            style.iconColorize = true;
            style.colorizeColor = colorizeColor;
        }

        // like the real blueprint, we always overwrite

        style.iconAncestorTypes = iconAncestorTypes;

        return style;
    
public java.lang.Objectclone()
Creates a copy of the reciever and returns it.

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

        // These fields are immutable, no need to clone them
        style.info = this.info;
        style.iconAncestorTypes = this.iconAncestorTypes;
        style.colorizeColor = this.colorizeColor;

        return style;
    
private static java.lang.StringgetColorStringWithAlpha(java.awt.Color c)

        if (c == null) {
            return "null";
        }

        StringBuffer buf = new StringBuffer();
        buf.append('{");
        buf.append(c.getRed()).append(", ");
        buf.append(c.getGreen()).append(", ");
        buf.append(c.getBlue()).append(", ");
        buf.append(c.getAlpha()).append("}");
        return buf.toString();
    
public com.sun.java.swing.plaf.gtk.GTKEnginegetEngine(javax.swing.plaf.synth.SynthContext context)
Returns a GTKEngine to use for rendering.

        return BLUEPRINT_ENGINE;
    
public javax.swing.plaf.synth.SynthGraphicsUtilsgetGraphicsUtils(javax.swing.plaf.synth.SynthContext context)

        return BLUEPRINT_GRAPHICS;
    
public com.sun.java.swing.plaf.gtk.BlueprintStyle$InfogetInfo(java.lang.String function, java.lang.String detail, int componentState, int shadow, int orientation, int gapSide, int arrowDirection, java.lang.String parentType)
Returns the first instance of Info that matches the past in args, may return null if nothing matches.

param
function String name for the painting method
param
detail Description of what is being painted
param
componentState State of the Component
param
shadow Shadow type
param
orientation Orientation of what is being painted
param
gapSide Side of the gap being drawn
param
arrowDirection direction of the arrow.
return
Best matching Info, or null if none match

        if (info != null) {
            for (int counter = 0, max = info.length; counter < max;counter++) {
                if (info[counter].getFunction() == function && info[counter].
                              getMatchCount(detail, componentState, shadow,
                              orientation, gapSide, arrowDirection,
                              parentType) != -1) {
                    return info[counter];
                }
            }
        }
        return null;
    
private intgetMaxMatchCount(int componentState, int shadow, int orientation, int gapSide, int arrowDirection, java.lang.String detail)
Returns the number of non-null arugments and arguments that are != UNDEFINED.

        int count = 0;

        if (detail != null) {
            count++;
        }
        if (componentState != UNDEFINED) {
            count++;
        }
        if (shadow != UNDEFINED) {
            count++;
        }
        if (orientation != UNDEFINED) {
            count++;
        }
        if (gapSide != UNDEFINED) {
            count++;
        }
        if (arrowDirection != UNDEFINED) {
            count++;
        }
        return count;
    
public java.lang.StringtoString()

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

        if (buf.length() > 0) {
            buf.append('\n");
        }

        buf.append("*** Blueprint Engine Info ***\n");

        buf.append("icon_colorize = " + iconColorize + '\n");
        buf.append("icon_colorize_ancestor_type = ");
        if (iconAncestorTypes == null) {
            buf.append("null\n");
        } else {
            buf.append('{");
            for (int i = 0; i < iconAncestorTypes.length; i++) {
                buf.append(iconAncestorTypes[i] + ", ");
            }

            buf.deleteCharAt(buf.length() - 1);
            buf.deleteCharAt(buf.length() - 1);

            buf.append("}\n");
        }

        buf.append("colorize_color = ");
        buf.append(getColorStringWithAlpha(colorizeColor));
        buf.append('\n");

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

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

        return buf.toString();