org.tigris.toolbar.layouts
Class DockBoundary

java.lang.Object
  |
  +--java.awt.geom.RectangularShape
        |
        +--java.awt.geom.Rectangle2D
              |
              +--java.awt.Rectangle
                    |
                    +--org.tigris.toolbar.layouts.DockBoundary
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, java.awt.Shape

public abstract class DockBoundary
extends java.awt.Rectangle

Abstract Rectangle class for representing the bounds of the docked toolbars at a given edge.

Author:
Christopher Bach
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Rectangle
height, width, x, y
 
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
 
Constructor Summary
DockBoundary(int edge)
          Creates a DockBoundary for the specified edge.
DockBoundary(int edge, int spacing)
          Creates a DockBoundary for the specified edge with the specified spacing.
 
Method Summary
 void addToolBar(javax.swing.JToolBar toolbar, int rowIndex, int index)
          Inserts the specified toolbar into this boundary at the provided indices.
 void addToolBar(javax.swing.JToolBar toolbar, java.awt.Point dropPoint)
          Adds the specified toolbar to this boundary calculating the insertion index based on the provided drop point.
 boolean containsToolBar(javax.swing.JToolBar toolbar)
          Returns a boolean indicating whether or not this boundary contains the provided toolbar.
 int getDepth()
          Returns the height or width of this boundary depending on orientation as determined by a previous call to validate.
abstract  int getDockIndex(javax.swing.JToolBar toolbar)
          Subclass implementation should return the index at which the specified toolbar is located within this boundary, or -1 if the toolbar is not present.
abstract  int getDockIndex(java.awt.Point p)
          Subclass implementations should return the index at which the toolbar should be added when dropped at this point.
 int getEdge()
          Gets the edge that this boundary represents.
 int getOrientation()
          Gets the orientation of this edge.
protected  int getPreferredToolBarDepth(javax.swing.JToolBar toolbar)
          Returns the "depth" (height or width) of the provided toolbar depending on this boundary's orientation.
protected  int getPreferredToolBarLength(javax.swing.JToolBar toolbar)
          Returns the "length" (width or height) of the provided toolbar depending on this boundary's orientation.
abstract  int getRowIndex(javax.swing.JToolBar toolbar)
          Subclass implementation should return the row index at which the specified toolbar is located within this boundary, or -1 if the toolbar is not present.
abstract  int getRowIndex(java.awt.Point p)
          Subclass implementations should return the row index at which the toolbar should be added when dropped at this point.
 int getSpacing()
          Gets the spacing between toolbars added to this edge.
 javax.swing.JToolBar[] getToolBars()
          Gets an array of the toolbars registered with this boundary.
 boolean isDockablePoint(java.awt.Point p)
          Determines if the provided point is within the dockable range for this edge.
 boolean isDraggablePoint(java.awt.Point p, javax.swing.JToolBar toolbar)
          Determines if a drag operation on the provided toolbar at the provided point may begin or continue.
protected  void mirrorBounds(java.awt.Rectangle r, int mirrorOffset)
          Reflects the provided rectangle about a line passing through the point at the provided offset distance depending on the orientation of this boundary.
 void removeComponent(java.awt.Component component)
          Removes the specified component from this boundary as long as the runtime type of the component is a JToolBar.
 void removeToolBar(javax.swing.JToolBar toolbar)
          Removes the specified toolbar from this boundary.
 void revalidate()
          Validates this boundary and recalculates its dockable range.
protected  void setDepth(int depth)
          Sets the height or width of this boundary depending on orientation.
 void setPosition(int newX, int newY, int length)
          Sets the location and length of this boundary, and calculates the bounds based on validating the toolbar layout.
 void setSpacing(int spacing)
          Sets the spacing between toolbars added to this edge.
protected  void toolBarAdded(javax.swing.JToolBar toolbar, int rowIndex, int index)
          Callback method called when a toolbar is added to the boundary in order to allow subclasses to provide additional handling.
protected  void toolBarRemoved(javax.swing.JToolBar toolbar)
          Callback method called when a toolbar is removed from the boundary in order to allow the subclass to provide additional handling.
abstract  void validate()
          Lays out the toolbars associated with this boundary and calculates the depth of the boundary based on the toolbar layout.
 
Methods inherited from class java.awt.Rectangle
add, add, add, contains, contains, contains, contains, createIntersection, createUnion, equals, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setBounds, setBounds, setLocation, setLocation, setRect, setSize, setSize, toString, translate, union
 
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
 
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getPathIterator, getPathIterator, intersects, intersects
 

Constructor Detail

DockBoundary

public DockBoundary(int edge)
Creates a DockBoundary for the specified edge.


DockBoundary

public DockBoundary(int edge,
                    int spacing)
Creates a DockBoundary for the specified edge with the specified spacing.

Method Detail

setSpacing

public void setSpacing(int spacing)
Sets the spacing between toolbars added to this edge.


getSpacing

public int getSpacing()
Gets the spacing between toolbars added to this edge.


getOrientation

public int getOrientation()
Gets the orientation of this edge.


getEdge

public int getEdge()
Gets the edge that this boundary represents.


isDockablePoint

public boolean isDockablePoint(java.awt.Point p)
Determines if the provided point is within the dockable range for this edge.


isDraggablePoint

public boolean isDraggablePoint(java.awt.Point p,
                                javax.swing.JToolBar toolbar)
Determines if a drag operation on the provided toolbar at the provided point may begin or continue. The toolbar handler calls this method when a drag event occurs on the toolbar prior to displaying or positioning the dynamic dragging window. Subclasses may override this method to return false in order to internally process the drag gesture without the ToolBarHandler having to undock and redock the toolbar.


getDockIndex

public abstract int getDockIndex(java.awt.Point p)
Subclass implementations should return the index at which the toolbar should be added when dropped at this point.


getDockIndex

public abstract int getDockIndex(javax.swing.JToolBar toolbar)
Subclass implementation should return the index at which the specified toolbar is located within this boundary, or -1 if the toolbar is not present.


getRowIndex

public abstract int getRowIndex(java.awt.Point p)
Subclass implementations should return the row index at which the toolbar should be added when dropped at this point.


getRowIndex

public abstract int getRowIndex(javax.swing.JToolBar toolbar)
Subclass implementation should return the row index at which the specified toolbar is located within this boundary, or -1 if the toolbar is not present.


setPosition

public void setPosition(int newX,
                        int newY,
                        int length)
Sets the location and length of this boundary, and calculates the bounds based on validating the toolbar layout.


validate

public abstract void validate()
Lays out the toolbars associated with this boundary and calculates the depth of the boundary based on the toolbar layout. Subclass implementations should lay out the associated toolbars and determine the depth of this boundary. At the start of this mehtod, the depth of this boundary should be assumed to be 0 and should be determined by the time the validation completes, finishing with a call to setDepth(). This method usually will not be called directly. Instead, a call to setPosition() will call this method and will also subsequently verify the bounds of this boundary based on the new depth.


revalidate

public void revalidate()
Validates this boundary and recalculates its dockable range.


getDepth

public int getDepth()
Returns the height or width of this boundary depending on orientation as determined by a previous call to validate.


setDepth

protected void setDepth(int depth)
Sets the height or width of this boundary depending on orientation. This method should be called by the subclass implementation's validate method prior to returning.


addToolBar

public void addToolBar(javax.swing.JToolBar toolbar,
                       int rowIndex,
                       int index)
Inserts the specified toolbar into this boundary at the provided indices. Subclasses generally should not override this method, but may provide more detailed behavior by overriding the toolBarAdded() callback method instead.


addToolBar

public void addToolBar(javax.swing.JToolBar toolbar,
                       java.awt.Point dropPoint)
Adds the specified toolbar to this boundary calculating the insertion index based on the provided drop point. Subclasses generally should not override this method, but may provide more detailed behavior by overriding the toolBarAdded() callback method instead.


toolBarAdded

protected void toolBarAdded(javax.swing.JToolBar toolbar,
                            int rowIndex,
                            int index)
Callback method called when a toolbar is added to the boundary in order to allow subclasses to provide additional handling.


removeToolBar

public void removeToolBar(javax.swing.JToolBar toolbar)
Removes the specified toolbar from this boundary. Subclasses generally should not override this method, but may provide more detailed behavior by overriding the toolBarRemoved() callback method instead.


removeComponent

public void removeComponent(java.awt.Component component)
Removes the specified component from this boundary as long as the runtime type of the component is a JToolBar. Subclasses generally should not override this method, but may provide more detailed behavior by overriding the toolBarRemoved() callback method instead.


toolBarRemoved

protected void toolBarRemoved(javax.swing.JToolBar toolbar)
Callback method called when a toolbar is removed from the boundary in order to allow the subclass to provide additional handling.


getToolBars

public javax.swing.JToolBar[] getToolBars()
Gets an array of the toolbars registered with this boundary.


containsToolBar

public boolean containsToolBar(javax.swing.JToolBar toolbar)
Returns a boolean indicating whether or not this boundary contains the provided toolbar.


getPreferredToolBarLength

protected int getPreferredToolBarLength(javax.swing.JToolBar toolbar)
Returns the "length" (width or height) of the provided toolbar depending on this boundary's orientation.


getPreferredToolBarDepth

protected int getPreferredToolBarDepth(javax.swing.JToolBar toolbar)
Returns the "depth" (height or width) of the provided toolbar depending on this boundary's orientation.


mirrorBounds

protected void mirrorBounds(java.awt.Rectangle r,
                            int mirrorOffset)
Reflects the provided rectangle about a line passing through the point at the provided offset distance depending on the orientation of this boundary. This method may be used by subclasses (especially at the south and east edges) to lay out the toolbars relative to the boundary origin and then reflect them about the offset line to produce a reverse wrap of the toolbars.