FileDocCategorySizeDatePackage
ParsedSynthStyle.javaAPI DocJava SE 6 API94173Tue Jun 10 00:26:54 BST 2008javax.swing.plaf.synth

ParsedSynthStyle

public class ParsedSynthStyle extends DefaultSynthStyle
ParsedSynthStyle are the SynthStyle's that SynthParser creates.
version
1.7, 11/17/05
author
Scott Violet

Fields Summary
private static SynthPainter
DELEGATING_PAINTER_INSTANCE
private PainterInfo[]
_painters
Constructors Summary
public ParsedSynthStyle()

    
public ParsedSynthStyle(DefaultSynthStyle style)

        super(style);
        if (style instanceof ParsedSynthStyle) {
            ParsedSynthStyle pStyle = (ParsedSynthStyle)style;

            if (pStyle._painters != null) {
                _painters = pStyle._painters;
            }
        }
    
Methods Summary
public sun.swing.plaf.synth.DefaultSynthStyleaddTo(sun.swing.plaf.synth.DefaultSynthStyle style)

        if (!(style instanceof ParsedSynthStyle)) {
            style = new ParsedSynthStyle(style);
        }
        ParsedSynthStyle pStyle = (ParsedSynthStyle)super.addTo(style);
        pStyle._painters = mergePainterInfo(pStyle._painters, _painters);
        return pStyle;
    
private javax.swing.plaf.synth.SynthPaintergetBestPainter(javax.swing.plaf.synth.SynthContext context, java.lang.String method, int direction)

        // Check the state info first
        StateInfo info = (StateInfo)getStateInfo(context.getComponentState());
        SynthPainter painter;
        if (info != null) {
            if ((painter = getBestPainter(info.getPainters(), method,
                                          direction)) != null) {
                return painter;
            }
        }
        if ((painter = getBestPainter(_painters, method, direction)) != null) {
            return painter;
        }
        return SynthPainter.NULL_PAINTER;
    
private javax.swing.plaf.synth.SynthPaintergetBestPainter(javax.swing.plaf.synth.ParsedSynthStyle$PainterInfo[] info, java.lang.String method, int direction)

        if (info != null) {
            // Painter specified with no method
            SynthPainter nullPainter = null;
            // Painter specified for this method
            SynthPainter methodPainter = null;

            for (int counter = info.length - 1; counter >= 0; counter--) {
                PainterInfo pi = info[counter];

                if (pi.getMethod() == method) {
                    if (pi.getDirection() == direction) {
                        return pi.getPainter();
                    }
                    else if (methodPainter == null &&pi.getDirection() == -1) {
                        methodPainter = pi.getPainter();
                    }
                }
                else if (nullPainter == null && pi.getMethod() == null) {
                    nullPainter = pi.getPainter();
                }
            }
            if (methodPainter != null) {
                return methodPainter;
            }
            return nullPainter;
        }
        return null;
    
public javax.swing.plaf.synth.SynthPaintergetPainter(javax.swing.plaf.synth.SynthContext ss)

        return DELEGATING_PAINTER_INSTANCE;
    
private static javax.swing.plaf.synth.ParsedSynthStyle$PainterInfo[]mergePainterInfo(javax.swing.plaf.synth.ParsedSynthStyle$PainterInfo[] old, javax.swing.plaf.synth.ParsedSynthStyle$PainterInfo[] newPI)


        
                                                    
        if (old == null) {
            return newPI;
        }
        if (newPI == null) {
            return old;
        }
        int oldLength = old.length;
        int newLength = newPI.length;
        int dups = 0;
        PainterInfo[] merged = new PainterInfo[oldLength + newLength];
        System.arraycopy(old, 0, merged, 0, oldLength);
        for (int newCounter = 0; newCounter < newLength; newCounter++) {
            boolean found = false;
            for (int oldCounter = 0; oldCounter < oldLength - dups;
                     oldCounter++) {
                if (newPI[newCounter].equalsPainter(old[oldCounter])) {
                    merged[oldCounter] = newPI[newCounter];
                    dups++;
                    found = true;
                    break;
                }
            }
            if (!found) {
                merged[oldLength + newCounter - dups] = newPI[newCounter];
            }
        }
        if (dups > 0) {
            PainterInfo[] tmp = merged;
            merged = new PainterInfo[merged.length - dups];
            System.arraycopy(tmp, 0, merged, 0, merged.length);
        }
        return merged;
    
public voidsetPainters(javax.swing.plaf.synth.ParsedSynthStyle$PainterInfo[] info)

        _painters = info;
    
public java.lang.StringtoString()

        StringBuffer text = new StringBuffer(super.toString());
        if (_painters != null) {
            text.append(",painters=[");
            for (int i = 0; i < +_painters.length; i++) {
                text.append(_painters[i].toString());
            }
            text.append("]");
        }
        return text.toString();