org.argouml.swingext
Class Splitter

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byorg.argouml.swingext.Splitter
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class Splitter
extends javax.swing.JComponent

Acts as a seperator between components and will automatically resize those components when the splitter is moved by dragging the mouse across it.

See Also:
Serialized Form

Nested Class Summary
private  class Splitter.MyMouseListener
          The mouse listener to detect mouse interaction with this splitter
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  javax.swing.plaf.basic.BasicSplitPaneDivider _divider
          Component which knows how to paint the split divider.
(package private)  ArrowButton buttonNorth
          The quick hide buttons
(package private)  ArrowButton buttonSouth
           
private static int DIVIDER_PADDING
          Padding around the JSplitPane that is not included in the divider
private  boolean dynamicResize
          True if components are resized dymically when the plitter is dragged.
static int EAST
           
static Orientation HORIZONTAL_SPLIT
           
private  int lastLength
           
private  int lastPosition
           
private static int MIN_SPLITTER_SIZE
          Minimum size of the splitter in pixels.
static int NONE
           
static int NORTH
           
private  Orientation orientation
          The orientation of this splitter.
private  boolean panelHidden
          True if a component has been hidden by using the quick hide process of the Splitter
private  int quickHide
          Is quick hide available and if so which component ahould it hide
private  java.awt.Component[] sideComponent
          The 2 components which the splitter is designed to seperate
static int SOUTH
           
private  int splitterSize
          The standard width of a splitter
static Orientation VERTICAL_SPLIT
           
static int WEST
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Splitter(Orientation orientation)
          The constructor
 
Method Summary
 java.awt.Component getRegisteredComponent(int side)
          Get a registered component.
private  int moveSplitter(int movement)
           
 void paintComponent(java.awt.Graphics g)
          Delegates painting to the UI component responsible for the split pane divider.
 void registerComponent(int side, java.awt.Component comp)
          Register a component to be resized by this splitter.
private  void resizeComponents(int movement)
          Resize and reposition the components according to the movement of the splitter
private  int restrictMovement(java.awt.Component growingComponent, java.awt.Component shrinkingComponent, int movement, int sign)
          calculates any restriction of movement based on the min/max values of the registered components.
 void setQuickHide(int side)
          Change the quick hide action.
 void setSize(java.awt.Dimension d)
          Resizes the divider delegate when this component is resized.
 void setSize(int width, int height)
          Resizes the divider delegate when this component is resized.
private  void showButtons()
           
 void toggleHide()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HORIZONTAL_SPLIT

public static final Orientation HORIZONTAL_SPLIT

VERTICAL_SPLIT

public static final Orientation VERTICAL_SPLIT

NONE

public static final int NONE
See Also:
Constant Field Values

WEST

public static final int WEST
See Also:
Constant Field Values

EAST

public static final int EAST
See Also:
Constant Field Values

NORTH

public static final int NORTH
See Also:
Constant Field Values

SOUTH

public static final int SOUTH
See Also:
Constant Field Values

orientation

private Orientation orientation
The orientation of this splitter. Orientation does not represent the shape of the splitter but rather the layout of the objects being seperated by the splitter. In other words a horizontal splitter seperates components layed out in a horizontal row.


lastPosition

private int lastPosition

lastLength

private int lastLength

quickHide

private int quickHide
Is quick hide available and if so which component ahould it hide


panelHidden

private boolean panelHidden
True if a component has been hidden by using the quick hide process of the Splitter


dynamicResize

private boolean dynamicResize
True if components are resized dymically when the plitter is dragged. If false then components are only resized when the splitter is dropped by releasing the mouse.


sideComponent

private java.awt.Component[] sideComponent
The 2 components which the splitter is designed to seperate


splitterSize

private int splitterSize
The standard width of a splitter


buttonNorth

ArrowButton buttonNorth
The quick hide buttons


buttonSouth

ArrowButton buttonSouth

_divider

private javax.swing.plaf.basic.BasicSplitPaneDivider _divider
Component which knows how to paint the split divider.


DIVIDER_PADDING

private static final int DIVIDER_PADDING
Padding around the JSplitPane that is not included in the divider

See Also:
Constant Field Values

MIN_SPLITTER_SIZE

private static final int MIN_SPLITTER_SIZE
Minimum size of the splitter in pixels. Must be at least this size to properly display the toggle buttons.

See Also:
Constant Field Values
Constructor Detail

Splitter

public Splitter(Orientation orientation)
The constructor

Parameters:
orientation - A Horizontal or Vertical object to indicate whether this splitter is designed to seperate components laid out horizontally or vertically.
Method Detail

registerComponent

public void registerComponent(int side,
                              java.awt.Component comp)
Register a component to be resized by this splitter.

Parameters:
side - the side of the splitter to place the component being one of the constants NORTH, SOUTH, EAST or WEST

getRegisteredComponent

public java.awt.Component getRegisteredComponent(int side)
Get a registered component.

Parameters:
side - the side of the splitter of the component to return, being one of the constants NORTH, SOUTH, EAST or WEST
Returns:
the registered component

setQuickHide

public void setQuickHide(int side)
Change the quick hide action. If quick hide is turned on then an arrow button appears on the splitter to allow the user to instantly reposition the splitter to hide one of the components.

Parameters:
side - the side of the splitter of the component to be hidden on a quick hide action. This being one of the constants NORTH, SOUTH, EAST, WEST or NONE.

showButtons

private void showButtons()

toggleHide

public void toggleHide()

setSize

public void setSize(java.awt.Dimension d)
Resizes the divider delegate when this component is resized.


setSize

public void setSize(int width,
                    int height)
Resizes the divider delegate when this component is resized.


paintComponent

public void paintComponent(java.awt.Graphics g)
Delegates painting to the UI component responsible for the split pane divider.


moveSplitter

private int moveSplitter(int movement)

resizeComponents

private void resizeComponents(int movement)
Resize and reposition the components according to the movement of the splitter

Parameters:
movement - the distance the splitter has moved.

restrictMovement

private int restrictMovement(java.awt.Component growingComponent,
                             java.awt.Component shrinkingComponent,
                             int movement,
                             int sign)
calculates any restriction of movement based on the min/max values of the registered components.

Parameters:
growingComponent - The component that is expanding as the result of a splitter move.
shrinkingComponent - The component that is shrinking as the result of a splitter move.
movement - The number of pixels of the attempted move
sign - The direction of the move -ve or +ve (-1 or +1)


ArgoUML © 1996-2004 (20040316)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook