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

PixmapStyle

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

Fields Summary
private static final GTKEngine
PIXMAP_ENGINE
There should only ever be one pixmap engine.
private Info[]
info
Set of Infos used to determine what to paint.
Constructors Summary
public PixmapStyle(DefaultSynthStyle style)
Creates a duplicate of the passed in style.



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

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

        if (!(s instanceof PixmapStyle)) {
            s = new PixmapStyle(s);
        }
        PixmapStyle style = (PixmapStyle)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;
            }
        }
        return style;
    
public java.lang.Objectclone()
Creates a copy of the reciever and returns it.

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

        // Info is immutable, no need to clone it.
        style.info = this.info;
        return style;
    
public com.sun.java.swing.plaf.gtk.GTKEnginegetEngine(javax.swing.plaf.synth.SynthContext context)
Returns a GTKEngine to use for rendering.

        return PIXMAP_ENGINE;
    
public com.sun.java.swing.plaf.gtk.PixmapStyle$InfogetInfo(java.lang.String function, java.lang.String detail, int componentState, int shadow, int orientation, int gapSide, int arrowDirection)
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) != -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()

        if (info == null) {
            return super.toString();
        } else {
            StringBuffer buf = new StringBuffer(super.toString());
            
            if (buf.length() > 0) {
                buf.append('\n");
            }

            buf.append("*** Pixmap Engine Info ***\n");
            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();
        }