FileDocCategorySizeDatePackage
MotifSplitPaneDivider.javaAPI DocJava SE 5 API8798Fri Aug 26 14:54:48 BST 2005com.sun.java.swing.plaf.motif

MotifSplitPaneDivider

public class MotifSplitPaneDivider extends BasicSplitPaneDivider
Divider used for Motif split pane.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.

version
1.17 12/19/03
author
Jeff Dinkins

Fields Summary
private static final Cursor
defaultCursor
Default cursor, supers is package private, so we have to have one too.
public static final int
minimumThumbSize
public static final int
defaultDividerSize
protected static final int
pad
private int
hThumbOffset
private int
vThumbOffset
protected int
hThumbWidth
protected int
hThumbHeight
protected int
vThumbWidth
protected int
vThumbHeight
protected Color
highlightColor
protected Color
shadowColor
protected Color
focusedColor
Constructors Summary
public MotifSplitPaneDivider(BasicSplitPaneUI ui)
Creates a new Motif SplitPaneDivider


              
       
        super(ui);
        highlightColor = UIManager.getColor("SplitPane.highlight");
        shadowColor = UIManager.getColor("SplitPane.shadow");
        focusedColor = UIManager.getColor("SplitPane.activeThumb");
        setDividerSize(hThumbWidth + pad);
    
Methods Summary
private DragControllergetDragger()

	return dragger;
    
public java.awt.DimensiongetMinimumSize()
The minimums size is the same as the preferredSize

        return getPreferredSize();
    
private javax.swing.JSplitPanegetSplitPane()

	return splitPane;
    
private booleanisInThumb(int x, int y)
Returns true if the point at x, y is inside the thumb.

        Dimension           size = getSize();
	int                 thumbX;
	int                 thumbY;
	int                 thumbWidth;
	int                 thumbHeight;

	if (getBasicSplitPaneUI().getOrientation() ==
	    JSplitPane.HORIZONTAL_SPLIT) {
            int center = size.width/2;
            thumbX = center - hThumbWidth/2;
            thumbY = hThumbOffset;
	    thumbWidth = hThumbWidth;
	    thumbHeight = hThumbHeight;
	}
	else {
            int center = size.height/2;
            thumbX = size.width - vThumbOffset;
            thumbY = size.height/2 - vThumbHeight/2;
	    thumbWidth = vThumbWidth;
	    thumbHeight = vThumbHeight;
	}
	return (x >= thumbX && x < (thumbX + thumbWidth) &&
		y >= thumbY && y < (thumbY + thumbHeight));
    
public voidpaint(java.awt.Graphics g)
Paints the divider.

        Color               bgColor = getBackground();
        Dimension           size = getSize();

        // fill
        g.setColor(getBackground());
        g.fillRect(0, 0, size.width, size.height);

        if(getBasicSplitPaneUI().getOrientation() ==
           JSplitPane.HORIZONTAL_SPLIT) {
            int center = size.width/2;
            int x = center - hThumbWidth/2;
            int y = hThumbOffset;

            // split line
            g.setColor(shadowColor);
            g.drawLine(center-1, 0, center-1, size.height);

            g.setColor(highlightColor);
            g.drawLine(center, 0, center, size.height);

            // draw thumb
            g.setColor((splitPane.hasFocus()) ? focusedColor :
                                                getBackground());
            g.fillRect(x+1, y+1, hThumbWidth-2, hThumbHeight-1);

            g.setColor(highlightColor);
            g.drawLine(x, y, x+hThumbWidth-1, y);       // top
            g.drawLine(x, y+1, x, y+hThumbHeight-1);    // left

            g.setColor(shadowColor);
            g.drawLine(x+1, y+hThumbHeight-1,
                       x+hThumbWidth-1, y+hThumbHeight-1);      // bottom
            g.drawLine(x+hThumbWidth-1, y+1,
                       x+hThumbWidth-1, y+hThumbHeight-2);      // right

        } else {
            int center = size.height/2;
            int x = size.width - vThumbOffset;
            int y = size.height/2 - vThumbHeight/2;

            // split line
            g.setColor(shadowColor);
            g.drawLine(0, center-1, size.width, center-1);

            g.setColor(highlightColor);
            g.drawLine(0, center, size.width, center);

            // draw thumb
            g.setColor((splitPane.hasFocus()) ? focusedColor :
                                                getBackground());
            g.fillRect(x+1, y+1, vThumbWidth-1, vThumbHeight-1);

            g.setColor(highlightColor);
            g.drawLine(x, y, x+vThumbWidth, y);    // top
            g.drawLine(x, y+1, x, y+vThumbHeight); // left

            g.setColor(shadowColor);
            g.drawLine(x+1, y+vThumbHeight,
                       x+vThumbWidth, y+vThumbHeight);          // bottom
            g.drawLine(x+vThumbWidth, y+1,
                       x+vThumbWidth, y+vThumbHeight-1);        // right
        }
        super.paint(g);

    
public voidsetBasicSplitPaneUI(javax.swing.plaf.basic.BasicSplitPaneUI newUI)
Sets the SplitPaneUI that is using the receiver. This is completely overriden from super to create a different MouseHandler.

        if (splitPane != null) {
            splitPane.removePropertyChangeListener(this);
           if (mouseHandler != null) {
               splitPane.removeMouseListener(mouseHandler);
               splitPane.removeMouseMotionListener(mouseHandler);
	       removeMouseListener(mouseHandler);
	       removeMouseMotionListener(mouseHandler);
               mouseHandler = null;
           }
        }
        splitPaneUI = newUI;
        if (newUI != null) {
            splitPane = newUI.getSplitPane();
            if (splitPane != null) {
                if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
                splitPane.addMouseListener(mouseHandler);
                splitPane.addMouseMotionListener(mouseHandler);
		addMouseListener(mouseHandler);
		addMouseMotionListener(mouseHandler);
                splitPane.addPropertyChangeListener(this);
                if (splitPane.isOneTouchExpandable()) {
                    oneTouchExpandableChanged();
                }
            }
        }
        else {
            splitPane = null;
        }
    
public voidsetDividerSize(int newSize)
overrides to hardcode the size of the divider PENDING(jeff) - rewrite JSplitPane so that this ins't needed

	Insets          insets = getInsets();
	int             borderSize = 0;
	if (getBasicSplitPaneUI().getOrientation() ==
	    JSplitPane.HORIZONTAL_SPLIT) {
	    if (insets != null) {
		borderSize = insets.left + insets.right;
	    }
	}
	else if (insets != null) {
	    borderSize = insets.top + insets.bottom;
	}
        if (newSize < pad + minimumThumbSize + borderSize) {
            setDividerSize(pad + minimumThumbSize + borderSize);
        } else {
            vThumbHeight = hThumbWidth = newSize - pad - borderSize;
            super.setDividerSize(newSize);
        }