FileDocCategorySizeDatePackage
SynthSplitPaneUI.javaAPI DocJava SE 5 API9400Fri Aug 26 14:58:12 BST 2005javax.swing.plaf.synth

SynthSplitPaneUI

public class SynthSplitPaneUI extends BasicSplitPaneUI implements sun.swing.plaf.synth.SynthUI, PropertyChangeListener
Synth's SplitPaneUI.
version
1.15, 12/19/03
author
Scott Violet

Fields Summary
private static Set
managingFocusForwardTraversalKeys
Keys to use for forward focus traversal when the JComponent is managing focus.
private static Set
managingFocusBackwardTraversalKeys
Keys to use for backward focus traversal when the JComponent is managing focus.
private SynthStyle
style
Style for the JSplitPane.
private SynthStyle
dividerStyle
Style for the divider.
Constructors Summary
Methods Summary
public javax.swing.plaf.basic.BasicSplitPaneDividercreateDefaultDivider()
Creates the default divider.

        SynthSplitPaneDivider divider = new SynthSplitPaneDivider(this);

        divider.setDividerSize(splitPane.getDividerSize());
        return divider;
    
protected java.awt.ComponentcreateDefaultNonContinuousLayoutDivider()

        return new Canvas() {
            public void paint(Graphics g) {
                paintDragDivider(g, 0, 0, getWidth(), getHeight());
            }
        };
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent x)
Creates a new SynthSplitPaneUI instance

        return new SynthSplitPaneUI();
    
public voidfinishedPaintingChildren(javax.swing.JSplitPane jc, java.awt.Graphics g)

        if(jc == splitPane && getLastDragLocation() != -1 &&
                              !isContinuousLayout() && !draggingHW) {
            if(jc.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
                paintDragDivider(g, getLastDragLocation(), 0, dividerSize - 1,
                                 splitPane.getHeight() - 1);
            } else {
                paintDragDivider(g, 0, getLastDragLocation(),
                                 splitPane.getWidth() - 1, dividerSize - 1);
            }
        }
    
private intgetComponentState(javax.swing.JComponent c)

        return SynthLookAndFeel.getComponentState(c);
    
private intgetComponentState(javax.swing.JComponent c, javax.swing.plaf.synth.Region subregion)

        int state = SynthLookAndFeel.getComponentState(c);

        if (divider.isMouseOver()) {
            state |= MOUSE_OVER;
        }
        return state;
    
javax.swing.plaf.synth.SynthContextgetContext(javax.swing.JComponent c, javax.swing.plaf.synth.Region region)

        return getContext(c, region, getComponentState(c, region));
    
private javax.swing.plaf.synth.SynthContextgetContext(javax.swing.JComponent c, javax.swing.plaf.synth.Region region, int state)

        if (region == Region.SPLIT_PANE_DIVIDER) {
            return SynthContext.getContext(SynthContext.class, c, region,
                                           dividerStyle, state);
        }
        return SynthContext.getContext(SynthContext.class, c, region,
                                       style, state);
    
public javax.swing.plaf.synth.SynthContextgetContext(javax.swing.JComponent c)

        return getContext(c, getComponentState(c));
    
private javax.swing.plaf.synth.SynthContextgetContext(javax.swing.JComponent c, int state)

        return SynthContext.getContext(SynthContext.class, c,
                    SynthLookAndFeel.getRegion(c), style, state);
    
private javax.swing.plaf.synth.RegiongetRegion(javax.swing.JComponent c)

        return SynthLookAndFeel.getRegion(c);
    
protected voidinstallDefaults()
Installs the UI defaults.

        updateStyle(splitPane);

        setOrientation(splitPane.getOrientation());
        setContinuousLayout(splitPane.isContinuousLayout());

        resetLayoutManager();

        /* Install the nonContinuousLayoutDivider here to avoid having to
        add/remove everything later. */
        if(nonContinuousLayoutDivider == null) {
            setNonContinuousLayoutDivider(
                                createDefaultNonContinuousLayoutDivider(),
                                true);
        } else {
            setNonContinuousLayoutDivider(nonContinuousLayoutDivider, true);
        }

	// focus forward traversal key
	if (managingFocusForwardTraversalKeys==null) {
	    managingFocusForwardTraversalKeys = new TreeSet();
	    managingFocusForwardTraversalKeys.add(
		KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
	}
	splitPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
					managingFocusForwardTraversalKeys);
	// focus backward traversal key
	if (managingFocusBackwardTraversalKeys==null) {
	    managingFocusBackwardTraversalKeys = new TreeSet();
	    managingFocusBackwardTraversalKeys.add(
		KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
	}
	splitPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
					managingFocusBackwardTraversalKeys);
    
protected voidinstallListeners()
Installs the event listeners for the UI.

        super.installListeners();
        splitPane.addPropertyChangeListener(this);
    
public voidpaint(java.awt.Graphics g, javax.swing.JComponent c)

        SynthContext context = getContext(c);

        paint(context, g);
        context.dispose();
    
protected voidpaint(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g)

        // This is done to update package private variables in
        // BasicSplitPaneUI
        super.paint(g, splitPane);
    
public voidpaintBorder(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g, int x, int y, int w, int h)

        context.getPainter().paintSplitPaneBorder(context, g, x, y, w, h);
    
private voidpaintDragDivider(java.awt.Graphics g, int x, int y, int w, int h)

        SynthContext context = getContext(splitPane,Region.SPLIT_PANE_DIVIDER);
        context.setComponentState(((context.getComponentState() | MOUSE_OVER) ^
                                   MOUSE_OVER) | PRESSED);
        Shape oldClip = g.getClip();
        g.clipRect(x, y, w, h);
        context.getPainter().paintSplitPaneDragDivider(context, g, x, y, w, h,
                                           splitPane.getOrientation());
        g.setClip(oldClip);
        context.dispose();
    
public voidpropertyChange(java.beans.PropertyChangeEvent e)

        if (SynthLookAndFeel.shouldUpdateStyle(e)) {
            updateStyle((JSplitPane)e.getSource());
        }
    
protected voiduninstallDefaults()
Uninstalls the UI defaults.

        SynthContext context = getContext(splitPane, ENABLED);

        style.uninstallDefaults(context);
        context.dispose();
        style = null;

        context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER, ENABLED);
        dividerStyle.uninstallDefaults(context);
        context.dispose();
        dividerStyle = null;

        super.uninstallDefaults();
    
protected voiduninstallListeners()
Uninstalls the event listeners for the UI.

        super.uninstallListeners();
        splitPane.removePropertyChangeListener(this);
    
public voidupdate(java.awt.Graphics g, javax.swing.JComponent c)

        SynthContext context = getContext(c);

        SynthLookAndFeel.update(context, g);
        context.getPainter().paintSplitPaneBackground(context,
                          g, 0, 0, c.getWidth(), c.getHeight());
        paint(context, g);
        context.dispose();
    
private voidupdateStyle(javax.swing.JSplitPane splitPane)

        SynthContext context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER,
                                          ENABLED);
        SynthStyle oldDividerStyle = dividerStyle;
        dividerStyle = SynthLookAndFeel.updateStyle(context, this);
        context.dispose();

        context = getContext(splitPane, ENABLED);
        SynthStyle oldStyle = style;

        style = SynthLookAndFeel.updateStyle(context, this);

        if (style != oldStyle) {
            Object value = style.get(context, "SplitPane.size");
            if (value == null) {
                value = new Integer(6);
            }
            LookAndFeel.installProperty(splitPane, "dividerSize", value);

            value = style.get(context, "SplitPane.oneTouchExpandable");
            if (value != null) {
                LookAndFeel.installProperty(splitPane, "oneTouchExpandable", value);
            }

            if (divider != null) {
                splitPane.remove(divider);
                divider.setDividerSize(splitPane.getDividerSize());
            }
            if (oldStyle != null) {
                uninstallKeyboardActions();
                installKeyboardActions();
            }
        }
        if (style != oldStyle || dividerStyle != oldDividerStyle) {
            // Only way to force BasicSplitPaneDivider to reread the
            // necessary properties.
            if (divider != null) {
                splitPane.remove(divider);
            }
            divider = createDefaultDivider();
            divider.setBasicSplitPaneUI(this);
            splitPane.add(divider, JSplitPane.DIVIDER);
        }
        context.dispose();