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.


Variable Index

 o fCompartments
 o fInsets
The insets of the panel.

Constructor Index

 o CompartmentPanel()
Creation tools usually call this via clone();
 o CompartmentPanel(Point, Point)
Use this to set the display box of the CompartmentPanel at creation time.

Method Index

 o accept(Figure)
Does not accept subfigures.
 o acceptSubFigureChange(Point, Point)
Accept a change in the display box of a holder.
 o accommodate(Figure)
The default implementation calls grow after first getting the preferred size and the current location of the child-holder that has changed.
 o add(Figure)
Only connection figures can be added to CompartmentPanels.
 o addCompartment(FigureHolder)
Adds a new figure holder to this.
 o addCompartmentAfter(FigureHolder, FigureHolder)
Adds a new figure holder to this into the list of holders after the holder oldHolder.
 o addCompartmentAt(FigureHolder, FigureHolder)
Adds a new figure holder to this into the list of holders at the position of oldHolder.
 o basicDisplayBox(Point, Point)
Sets the display box of this.
 o createCompartmentAt(int, int, DrawingView)
Create a new compartment at the point x,y.
 o createCompartments()
Creates the compartments by using the origin and corner of the current display box and calling createCompartments(origin,corner).
 o createCompartments(Point, Point)
Creates the compartments (figure holders) of this within the area represented by origin and corner.
 o draw(Graphics)
Draws all the contained figures.
 o drawDividers(Graphics)
Draw dividers between containers or otherwise indicate their presence on the panel.
 o getCompartmentAt(int, int)
Returns the compartment that contains the point x,y.
 o getCompartments()
Returns the compartments (figure holders) of this.
 o getCompartments(Point, Point)
Returns the compartments (figure holders) of this.
 o getInsets()
Gets the current insets.
 o getLayout(Point, Point)
Computes and returns the layout of figure holders within the box defined by origin and corner.
 o getMinimumLayout()
Returns a vector of rectangles representing the minimum space required by the compartments arranged according to the current layout strategy.
 o getMinimumSize()
Returns a point representing the minimum size of this.
 o getUnion(Vector)
Returns the union of the rectangles.
 o grow(Rectangle, Point)
Grow the display box of this so that the childBox is contained within it.
 o removeChild(Figure)
Removes a child figure from the composite (A-PT).
 o removeCompartment(FigureHolder)
Removes a compartment from the composite (A-PT).
 o removeCompartmentAt(int, int)
Remove the compartment at the point x,y.
 o setHolderBoxes(Vector)
Sets the display boxes of the figure holders using the layout vector that contains the new boxes.
 o setInsets(Insets)
Set the insets of this.

Variables

 o fInsets
 protected Insets fInsets
The insets of the panel. Default values are (0,0,0,0).

 o fCompartments
 protected Vector fCompartments

Constructors

 o CompartmentPanel
 public CompartmentPanel()
Creation tools usually call this via clone();

 o CompartmentPanel
 public CompartmentPanel(Point origin,
                         Point corner)
Use this to set the display box of the CompartmentPanel at creation time.

Methods

 o setInsets
 public void setInsets(Insets padding)
Set the insets of this.

 o getInsets
 public Insets getInsets()
Gets the current insets.

 o createCompartments
 protected void createCompartments()
Creates the compartments by using the origin and corner of the current display box and calling createCompartments(origin,corner).

 o 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.

 o 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.

 o 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.

 o accept
 public boolean accept(Figure figure)
Does not accept subfigures. Figures should be dropped onto compartments.

Overrides:
accept in class PanelComposite
 o 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
 o 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.

 o 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.

 o 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.

 o setHolderBoxes
 protected void setHolderBoxes(Vector layout)
Sets the display boxes of the figure holders using the layout vector that contains the new boxes.

 o 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
 o 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
 o 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
 o removeChild
 public Figure removeChild(Figure figure)
Removes a child figure from the composite (A-PT).

Overrides:
removeChild in class CompositeFigure
 o removeCompartment
 public FigureHolder removeCompartment(FigureHolder figure)
Removes a compartment from the composite (A-PT). Merge compartments?? Check removal!

 o 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).

 o addCompartmentAfter
 public FigureHolder addCompartmentAfter(FigureHolder newHolder,
                                         FigureHolder oldHolder)
Adds a new figure holder to this into the list of holders after the holder oldHolder.

 o 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.

 o getCompartmentAt
 public FigureHolder getCompartmentAt(int x,
                                      int y)
Returns the compartment that contains the point x,y.

 o 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.

 o 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.

 o 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
 o 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
 o 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
 o 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