All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class CH.ifa.draw.standard.FigureHolder

java.lang.Object
   |
   +----CH.ifa.draw.standard.AbstractFigure
           |
           +----CH.ifa.draw.standard.CompositeFigure
                   |
                   +----CH.ifa.draw.standard.FigureHolder

public class FigureHolder
extends CompositeFigure
A FigureHolder is a compartment like composite, that has a display box but no visible representation. The FigureHolder is the base class for compartments that have a special layout for subfigures.

A FigureHolder keeps a positioning of its subfigures that is relative to the origin of its display box. A FigureHolder has a preferred size, but the parent is responsible for actually setting the displayBox of the holder.


Variable Index

 o fArrangement
The current arrangement of subfigures.
 o fDisplayBox
The display box.
 o fHoldees
 o fMargins
 o fPreviousLoc
Remember the previous location of the display box.

Constructor Index

 o FigureHolder()
 o FigureHolder(Point, Point)
 o FigureHolder(Point, Point, Margins)

Method Index

 o accept(Figure)
Default is to accept all figures.
 o acceptChange(Point, Point)
Return true if the change in the display box is acceptable.
 o acceptSubFigureChange(Point, Point)
Allow subfigure changes only to the positive direction (down and right).
 o accommodate(Figure)
Moves the subfigure if necessary to keep the current origin of this.
 o add(Figure)
Adds a figure to the list of figures.
 o ancestorChanged()
Informs that the ancestry of this has changed.
 o arrange()
Fill the arrangement vector with Aligner objects for the subfigures according to the layout strategy and current display box.
 o basicDisplayBox(Point, Point)
Sets the display box of a figure.
 o basicMoveBy(int, int)
Moves all the given figures by x and y.
 o beginDrag(Figure)
Tell this that a child is about to be dragged.
 o broughtToFront()
Informs that a figure has been brought to front.
 o displayBox()
Gets the display box.
 o displayBox(Point, Point)
Changes the display box of a figure.
 o draw(Graphics)
Draws all the contained figures.
 o drop(Figure)
Add the dragged figure to this.
 o emptySize()
 o figureChanged(FigureChangeEvent)
Handle a subfigure change.
 o figureInvalidated(FigureChangeEvent)
Propagates the figureInvalidated event to my listener.
 o figureRemoved(FigureChangeEvent)
 o figureRequestRemove(FigureChangeEvent)
Propagates the removeFromDrawing request up to the container.
 o findConnectable(int, int, Figure)
Find the subfigure that can be connected at the given point or return this, if no subfigure is found.
 o findDropTarget(int, int, Figure)
Traverse the hieararchy of contained figures to find the subfigure at x,y that accepts the figure to be dropped on it.
 o findPos(Figure)
Find the position of figure among the subfigures according to the current layout strategy.
 o findSelectable(int, int)
Find the subfigure that can be selected at the given point or return this, if no subfigure is found.
 o getArrengement()
Gets the current arrengement of subfigures.
 o getDefaultMargins()
A hook; return default margins.
 o getFigures()
Return a copy of the vector of subfigures.
 o getMargins()
Return the Margins object representing the current insets.
 o getMinimumSize()
 o getPreferredSize()
Returns the desired size of this.
 o getPreviousLoc()
Return the previous location of the display box (the location before the display box was last set).
 o getStationaryFigures()
Return the holdees that are stationary.
 o handles()
Does not have any handles by default.
 o highlight(Graphics)
Draw this in a special way.
 o isFlat()
Returns true if this is a flat composite and returns false if this is a structured composite.
 o moveIn(Figure)
Move the subfigure inside of this if the subfigure extends either to the left or up (or both) of the origin of this.
 o orphan(Figure)
Removes a figure from the figure list, but doesn't release it.
 o pack()
Position the subfigures inside the current display box according to the current arrangement and the current layout policy.
 o read(StorableInput)
Reads the figures from StorableInput.
 o remove(Figure)
=> ?????
 o setChildAligner(Figure)
A hook.
 o setDisplayBox(Point, Point)
Sets the display box of this.
 o setDisplayBox(Rectangle)
A convenience method for calling setDisplayBox with a rectangle argument.
 o setHighlighted(boolean)
Highlights this.

Variables

 o fDisplayBox
 protected Rectangle fDisplayBox
The display box.

 o fPreviousLoc
 protected Point fPreviousLoc
Remember the previous location of the display box.

 o fArrangement
 protected transient Vector fArrangement
The current arrangement of subfigures. Adding and removing subfigures, and setting the display box of this invalidate the arrangement.

 o fHoldees
 protected transient Vector fHoldees
 o fMargins
 protected Margins fMargins

Constructors

 o FigureHolder
 public FigureHolder()
 o FigureHolder
 public FigureHolder(Point origin,
                     Point corner)
 o FigureHolder
 public FigureHolder(Point origin,
                     Point corner,
                     Margins margins)

Methods

 o getDefaultMargins
 protected Margins getDefaultMargins()
A hook; return default margins. The default is (3,3,3,3,2).

 o getMargins
 public Margins getMargins()
Return the Margins object representing the current insets.

 o setDisplayBox
 public void setDisplayBox(Point origin,
                           Point corner)
Sets the display box of this. Does NOT broadcast changes. use this to break the recursive figureChanged -cycle when the parent sets the display box of its child figure holder during layout. Packs the subfigures into the new box.

 o getPreviousLoc
 public Point getPreviousLoc()
Return the previous location of the display box (the location before the display box was last set).

 o setDisplayBox
 public void setDisplayBox(Rectangle r)
A convenience method for calling setDisplayBox with a rectangle argument.

 o accept
 public boolean accept(Figure figure)
Default is to accept all figures. Override this in subclasses to selectively accept subfigures.

Overrides:
accept in class AbstractFigure
 o acceptChange
 protected boolean acceptChange(Point origin,
                                Point corner)
Return true if the change in the display box is acceptable. The default implementation just checks the minimum size constraint (if a constraint is set). Override this in subclasses for more specific checking. => Is this really needed in this case?

 o acceptSubFigureChange
 public boolean acceptSubFigureChange(Point origin,
                                      Point corner)
Allow subfigure changes only to the positive direction (down and right).

Overrides:
acceptSubFigureChange in class CompositeFigure
 o moveIn
 protected void moveIn(Figure child)
Move the subfigure inside of this if the subfigure extends either to the left or up (or both) of the origin of this.

 o accommodate
 public void accommodate(Figure child)
Moves the subfigure if necessary to keep the current origin of this.

Overrides:
accommodate in class AbstractFigure
 o setChildAligner
 protected void setChildAligner(Figure child)
A hook. Set the aligner for the child. The default is to give the child a RelativeAligner.

 o getArrengement
 protected Vector getArrengement()
Gets the current arrengement of subfigures. Computes the arrengement if necessary.

 o getStationaryFigures
 protected Vector getStationaryFigures()
Return the holdees that are stationary. That is, include figures are selected to be dragged but not dragged yet

 o arrange
 protected void arrange()
Fill the arrangement vector with Aligner objects for the subfigures according to the layout strategy and current display box. The default layout strategy is to leave the subfigures where they are relative to the origin of the displaybox. Override in subclasses.

 o emptySize
 protected Dimension emptySize()
 o getFigures
 public Vector getFigures()
Return a copy of the vector of subfigures.

 o findPos
 protected int findPos(Figure figure)
Find the position of figure among the subfigures according to the current layout strategy. Return an index to the vector of subfigures. The default is to return the last+1 position. => make subfigure layout a REAL strategy??

 o getPreferredSize
 public Dimension getPreferredSize()
Returns the desired size of this.

Overrides:
getPreferredSize in class AbstractFigure
 o pack
 public void pack()
Position the subfigures inside the current display box according to the current arrangement and the current layout policy.

 o getMinimumSize
 protected Point getMinimumSize()
 o handles
 public Vector handles()
Does not have any handles by default. Return empty Vector.

Overrides:
handles in class AbstractFigure
 o setHighlighted
 public void setHighlighted(boolean isHighlighted)
Highlights this.

Overrides:
setHighlighted in class AbstractFigure
 o highlight
 protected void highlight(Graphics g)
Draw this in a special way. draw a red rectangle slightly smaller than the display box.

Overrides:
highlight in class AbstractFigure
 o isFlat
 public boolean isFlat()
Returns true if this is a flat composite and returns false if this is a structured composite.

Overrides:
isFlat in class AbstractFigure
 o basicMoveBy
 protected void basicMoveBy(int x,
                            int y)
Moves all the given figures by x and y. Doesn't announce any changes. Moves first the root figure and then the subfigures.

Overrides:
basicMoveBy in class CompositeFigure
 o displayBox
 public void displayBox(Point origin,
                        Point corner)
Changes the display box of a figure.

Overrides:
displayBox in class AbstractFigure
 o basicDisplayBox
 public void basicDisplayBox(Point origin,
                             Point corner)
Sets the display box of a figure.

Overrides:
basicDisplayBox in class AbstractFigure
 o drop
 public Figure drop(Figure dragTarget)
Add the dragged figure to this.

Overrides:
drop in class AbstractFigure
 o findDropTarget
 public Figure findDropTarget(int x,
                              int y,
                              Figure dragTarget)
Traverse the hieararchy of contained figures to find the subfigure at x,y that accepts the figure to be dropped on it. The protocol assumes that whoever calls findDropTarget tests first whether the called figure contains the point and is different from dragTarget.

Overrides:
findDropTarget in class AbstractFigure
 o displayBox
 public Rectangle displayBox()
Gets the display box. The display box is defined as the union of the contained figures.

Overrides:
displayBox in class AbstractFigure
 o broughtToFront
 public void broughtToFront()
Informs that a figure has been brought to front. Forwards the event to subfigures in case they need to inform there listeners (such as connections spanning figure hierarchies).

Overrides:
broughtToFront in class AbstractFigure
See Also:
broughtToFront
 o ancestorChanged
 public void ancestorChanged()
Informs that the ancestry of this has changed. Forwards the event to subfigures in case they need to inform there listeners (such as connections spanning figure hierarchies).

Overrides:
ancestorChanged in class AbstractFigure
See Also:
ancestorChanged
 o add
 public Figure add(Figure figure)
Adds a figure to the list of figures. Accommodates the figure. By default connections are not accommodated. Adding invalidates this via changed().

Overrides:
add in class CompositeFigure
 o remove
 public Figure remove(Figure figure)
=> ?????

Overrides:
remove in class CompositeFigure
 o orphan
 public Figure orphan(Figure figure)
Removes a figure from the figure list, but doesn't release it.

Overrides:
orphan in class CompositeFigure
 o beginDrag
 public void beginDrag(Figure child)
Tell this that a child is about to be dragged.

 o draw
 public void draw(Graphics g)
Draws all the contained figures. Sets the current clip to the displaybox of this - warning! assumes the clip shape to be a Rectangle. Descends to children and if a child is about to move adjusts the clip to the displaybox of the child to let it be drawn properly (i.e. outside the display box of the panel).

Overrides:
draw in class CompositeFigure
 o findSelectable
 public Figure findSelectable(int x,
                              int y)
Find the subfigure that can be selected at the given point or return this, if no subfigure is found.

Overrides:
findSelectable in class AbstractFigure
 o findConnectable
 public Figure findConnectable(int x,
                               int y,
                               Figure connection)
Find the subfigure that can be connected at the given point or return this, if no subfigure is found. If this is not connectable, return null.

Overrides:
findConnectable in class AbstractFigure
 o figureInvalidated
 public void figureInvalidated(FigureChangeEvent e)
Propagates the figureInvalidated event to my listener.

Overrides:
figureInvalidated in class CompositeFigure
See Also:
FigureChangeListener
 o figureRequestRemove
 public void figureRequestRemove(FigureChangeEvent e)
Propagates the removeFromDrawing request up to the container.

Overrides:
figureRequestRemove in class CompositeFigure
See Also:
FigureChangeListener
 o figureChanged
 public void figureChanged(FigureChangeEvent e)
Handle a subfigure change. Ignore subfigures in transit (being dragged), connection figures, subfigures brought to front, and event if itself in transit. Otherwise accommodate the changed subfigure.

Overrides:
figureChanged in class CompositeFigure
 o figureRemoved
 public void figureRemoved(FigureChangeEvent e)
Overrides:
figureRemoved in class CompositeFigure
 o read
 public void read(StorableInput dr) throws IOException
Reads the figures from StorableInput.

Overrides:
read in class CompositeFigure

All Packages  Class Hierarchy  This Package  Previous  Next  Index