All Packages Class Hierarchy This Package Previous Next Index
Class CH.ifa.draw.standard.CompartmentPanel
java.lang.Object
|
+----CH.ifa.draw.standard.AbstractFigure
|
+----CH.ifa.draw.standard.CompositeFigure
|
+----CH.ifa.draw.standard.PanelComposite
|
+----CH.ifa.draw.standard.CompartmentPanel
- public abstract class CompartmentPanel
- extends PanelComposite
CompartmentPanel is a PanelComposite that has a number of
tiled (non-overlapping) FigureHolders (compartments) that fill its whole
display box (frame). Clients can not add subfigures directly
to the Panel but only to the figure holdes (if they accept it).
It is the responsibility of the panel to set the sizes of the
figure holders when the display box of the panel changes (it is
resized or its figure holder announces a change). Also, it is
the resposibility of the panel to maintain the desired layout and
draw the dividers (if any) between holders.
The number of figure holders is dynamic. Holders are created on
demand and not upon the creation of the panel to ensure that the
panel has a proper display box. The subfigure list (fFigures)
is used to store the figure holders. However, there is no generic
functionality for computing the layout of the compartments. Concrete
subclasses must fully specify the layout algorithm.
-
fCompartments
-
-
fInsets
- The insets of the panel.
-
CompartmentPanel()
- Creation tools usually call this via clone();
-
CompartmentPanel(Point, Point)
- Use this to set the display box of the CompartmentPanel at
creation time.
-
accept(Figure)
- Does not accept subfigures.
-
acceptSubFigureChange(Point, Point)
- Accept a change in the display box of a holder.
-
accommodate(Figure)
- The default implementation
calls grow after first getting the preferred size and the current location
of the child-holder that has changed.
-
add(Figure)
- Only connection figures can be added to CompartmentPanels.
-
addCompartment(FigureHolder)
- Adds a new figure holder to this.
-
addCompartmentAfter(FigureHolder, FigureHolder)
- Adds a new figure holder to this into the list of holders after the
holder oldHolder.
-
addCompartmentAt(FigureHolder, FigureHolder)
- Adds a new figure holder to this into the list of holders at the
position of oldHolder.
-
basicDisplayBox(Point, Point)
- Sets the display box of this.
-
createCompartmentAt(int, int, DrawingView)
- Create a new compartment at the point x,y.
-
createCompartments()
- Creates the compartments by using the origin and corner of the
current display box and calling createCompartments(origin,corner).
-
createCompartments(Point, Point)
- Creates the compartments (figure holders) of this within the area represented by
origin and corner.
-
draw(Graphics)
- Draws all the contained figures.
-
drawDividers(Graphics)
- Draw dividers between containers or otherwise indicate their presence
on the panel.
-
getCompartmentAt(int, int)
- Returns the compartment that contains the point x,y.
-
getCompartments()
- Returns the compartments (figure holders) of this.
-
getCompartments(Point, Point)
- Returns the compartments (figure holders) of this.
-
getInsets()
- Gets the current insets.
-
getLayout(Point, Point)
- Computes and returns the layout of figure holders within the box defined
by origin and corner.
-
getMinimumLayout()
- Returns a vector of rectangles representing the minimum space required
by the compartments arranged according to the current layout strategy.
-
getMinimumSize()
- Returns a point representing the minimum size of this.
-
getUnion(Vector)
- Returns the union of the rectangles.
-
grow(Rectangle, Point)
- Grow the display box of this so that the childBox is contained within
it.
-
removeChild(Figure)
- Removes a child figure from the composite (A-PT).
-
removeCompartment(FigureHolder)
- Removes a compartment from the composite (A-PT).
-
removeCompartmentAt(int, int)
- Remove the compartment at the point x,y.
-
setHolderBoxes(Vector)
- Sets the display boxes of the figure holders using the layout vector
that contains the new boxes.
-
setInsets(Insets)
- Set the insets of this.
fInsets
protected Insets fInsets
- The insets of the panel. Default values are (0,0,0,0).
fCompartments
protected Vector fCompartments
CompartmentPanel
public CompartmentPanel()
- Creation tools usually call this via clone();
CompartmentPanel
public CompartmentPanel(Point origin,
Point corner)
- Use this to set the display box of the CompartmentPanel at
creation time.
setInsets
public void setInsets(Insets padding)
- Set the insets of this.
getInsets
public Insets getInsets()
- Gets the current insets.
createCompartments
protected void createCompartments()
- Creates the compartments by using the origin and corner of the
current display box and calling createCompartments(origin,corner).
createCompartments
protected abstract void createCompartments(Point origin,
Point corner)
- Creates the compartments (figure holders) of this within the area represented by
origin and corner. Override in concrete subclasses. Use add() to
actually add the figure holders to this.
getCompartments
protected Vector getCompartments()
- Returns the compartments (figure holders) of this. If there are no
holders, createCompartments() is called. This lazy creation ensures
that the panel has a proper display box when its holders are initialized.
getCompartments
protected Vector getCompartments(Point origin,
Point corner)
- Returns the compartments (figure holders) of this. If there are no
holders, createCompartments() is called. Origin and corner define
the box in which to create the holders.
accept
public boolean accept(Figure figure)
- Does not accept subfigures. Figures should be dropped onto
compartments.
- Overrides:
- accept in class PanelComposite
acceptSubFigureChange
public boolean acceptSubFigureChange(Point origin,
Point corner)
- Accept a change in the display box of a holder. The default is to
check that the origin remains to the right and down of the origin
of this' display box (plus the current left and top insets). Note:
setsthe x and/or y of the origin to displayBox().x+fInsets.left
(or y) if they don't satisfy the constraint.
- Overrides:
- acceptSubFigureChange in class CompositeFigure
getUnion
protected Rectangle getUnion(Vector rectangles)
- Returns the union of the rectangles. If rectangles is empty, the result
is an empty rectangle located at the origin of the current display box.
getMinimumLayout
protected abstract Vector getMinimumLayout()
- Returns a vector of rectangles representing the minimum space required
by the compartments arranged according to the current layout strategy.
The rectangles are not stretched to make them fill a rectangular area.
Concrete subclasses should implement this method.
getLayout
protected abstract Vector getLayout(Point origin,
Point corner)
- Computes and returns the layout of figure holders within the box defined
by origin and corner. The layout is returned as a vector of rectangles
that holds the new display boxes of the holders. The order of the
rectangles in the returned Vector must match the order of the holders
in the subfigure list (fFigures) of this. Concrete subclasses implement
this method.
setHolderBoxes
protected void setHolderBoxes(Vector layout)
- Sets the display boxes of the figure holders using the layout vector
that contains the new boxes.
basicDisplayBox
public void basicDisplayBox(Point origin,
Point corner)
- Sets the display box of this. Creates the compartments if necessary.
Checks whether the change is accepted, and if not, tries to constrain
the box to acceptable limits by getting the minimum size and calling
constrainDisplayBox. If change is ok, calls getLayout() and setHolderBoxes
to do the layout of holders. Sets also the display box of the frame
figure (root figure).
- Overrides:
- basicDisplayBox in class PanelComposite
getMinimumSize
public Point getMinimumSize()
- Returns a point representing the minimum size of this. Calls
getMinimumLayout and computes the union over it.
- Overrides:
- getMinimumSize in class PanelComposite
add
public Figure add(Figure figure)
- Only connection figures can be added to CompartmentPanels.
Use addCompartment to add figure holders.
- Overrides:
- add in class PanelComposite
removeChild
public Figure removeChild(Figure figure)
- Removes a child figure from the composite (A-PT).
- Overrides:
- removeChild in class CompositeFigure
removeCompartment
public FigureHolder removeCompartment(FigureHolder figure)
- Removes a compartment from the composite (A-PT). Merge compartments??
Check removal!
addCompartment
public FigureHolder addCompartment(FigureHolder figure)
- Adds a new figure holder to this. The holder is added to the
compartment list and to the subfigure display list (fFigures).
addCompartmentAfter
public FigureHolder addCompartmentAfter(FigureHolder newHolder,
FigureHolder oldHolder)
- Adds a new figure holder to this into the list of holders after the
holder oldHolder.
addCompartmentAt
public FigureHolder addCompartmentAt(FigureHolder newHolder,
FigureHolder oldHolder)
- Adds a new figure holder to this into the list of holders at the
position of oldHolder.
getCompartmentAt
public FigureHolder getCompartmentAt(int x,
int y)
- Returns the compartment that contains the point x,y.
createCompartmentAt
public void createCompartmentAt(int x,
int y,
DrawingView view)
- Create a new compartment at the point x,y. Implement this method
in concrete subclass according to the structure and layout policy
of the compartment panel. The default implementation does nothing.
removeCompartmentAt
public void removeCompartmentAt(int x,
int y)
- Remove the compartment at the point x,y. Implement this method
in concrete subclass according to the structure and layout policy
of the compartment panel. The default implementation does nothing.
grow
protected void grow(Rectangle childBox,
Point pad)
- Grow the display box of this so that the childBox is contained within
it. An optional padding argument can be used to leave some space around
the child. Reset the display box in order to set the display boxes
of figure holders (compartments). A figure holder relies on its container
to set its display box.
- Overrides:
- grow in class PanelComposite
accommodate
public void accommodate(Figure child)
- The default implementation
calls grow after first getting the preferred size and the current location
of the child-holder that has changed.
- Overrides:
- accommodate in class PanelComposite
draw
public void draw(Graphics g)
- Draws all the contained figures. Calls drawDividers() (this is a template
method).
- Overrides:
- draw in class PanelComposite
- See Also:
- draw
drawDividers
public void drawDividers(Graphics g)
- Draw dividers between containers or otherwise indicate their presence
on the panel. The default implementation does nothing.
All Packages Class Hierarchy This Package Previous Next Index