org.tigris.gef.presentation
Class FigGroup

java.lang.Object
  extended by org.tigris.gef.presentation.Fig
      extended by org.tigris.gef.presentation.FigGroup
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, PopupGenerator
Direct Known Subclasses:
FigNode

public class FigGroup
extends Fig

A FigGroup is a collection of Figs to all be treated as a single item

Author:
Jason Robbins
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.tigris.gef.presentation.Fig
_allowsSaving, _context, _dashes, _dashPeriod, _dashStyle, _filled, _h, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, MIN_SIZE
 
Constructor Summary
FigGroup()
          Construct a new FigGroup that holds no Figs.
FigGroup(java.util.List figs)
          Construct a new FigGroup that holds the given Figs.
 
Method Summary
 void addFig(Fig fig)
          Add a Fig to the group.
 void addFigs(java.util.Collection figs)
          Add a collection of figs to the group.
 void calcBounds()
          Accumulate a bounding box for all the Figs in the group.
 java.lang.Object clone()
           
 boolean contains(int x, int y)
          Returns true if any Fig in the group contains the given point.
 Fig deepSelect(java.awt.Rectangle hitRect)
          Let the group decide if it should be selected itself or the hitten grouped fig instead.
 java.util.Enumeration elements()
          Deprecated. 0.11 use iterator()
 java.util.Collection getDisplayedFigs(java.util.Collection c)
          Returns a list of the displayable Figs enclosed.
 int getExtraFrameSpace()
          Returns the extra space that is added the frame surrounding the elements
 Fig getFigAt(int i)
          Get the fig within this group with the given index position
 java.util.List getFigs()
          Get the figs that make up this group
 java.awt.Font getFont()
           
 java.lang.String getFontFamily()
           
 int getFontSize()
           
 java.lang.String getPrivateData()
          TODO document Used in SVG.TEE
 java.awt.Dimension getSize()
          Returns the size of the group containing all entries.
protected  java.awt.Rectangle getSubFigBounds(Fig subFig)
          Returns the bounds of the given subfig.
 java.awt.Color getTextColor()
           
 java.awt.Color getTextFillColor()
           
 boolean getTextFilled()
           
 boolean hit(java.awt.Rectangle r)
          Returns true if any Fig in the group hits the given rect.
 Fig hitFig(java.awt.Rectangle r)
          Retrieve the top-most Fig containing the given point, or null.
 boolean isReshapable()
          Groups are resizable by default (see super class), but not reshapable, and not rotatable (for now).
 boolean isRotatable()
          Groups are resizable by default (see super class), but not reshapable, and not rotatable (for now).
 java.util.Iterator iterator()
          Reply an Iterator of the Figs contained in this FigGroup.
 void paint(java.awt.Graphics g)
          Paint all the Figs in this group.
 void parseDynObjects(java.lang.String dynStr)
          Empty method.
 void removeAll()
          Delete all Fig's from the group.
 void removeFig(Fig f)
          Remove a Fig from the group.
 void setBounds(int x, int y, int w, int h)
          Set the bounding box to the given rect.
 void setExtraFrameSpace(int extraSpace)
          Sets the extra spacing for the frame around the elements
 void setFigs(java.util.Collection figs)
          Sets a new collection of figs.
 void setFigs(java.util.List figs)
          Set the Figs in this group.
 void setFillColor(java.awt.Color col)
          Sets the color that will be used if the Fig is filled.
 void setFilled(boolean f)
          Sets a flag to either fill the Fig with its fillColor or not.
 void setFont(java.awt.Font f)
           
 void setFontFamily(java.lang.String s)
           
 void setFontSize(int s)
           
 void setLineColor(java.awt.Color col)
          Sets the color to be used if the lineWidth is > 0.
 void setLineWidth(int w)
          Set the line width.
 void setPrivateData(java.lang.String data)
          Derived classes should implement this method
 void setTextColor(java.awt.Color c)
           
 void setTextFillColor(java.awt.Color c)
           
 void setTextFilled(boolean b)
           
 void translate(int dx, int dy)
          Translate all the Fig in the list by the given offset.
 
Methods inherited from class org.tigris.gef.presentation.Fig
addAnnotation, addPoint, addPropertyChangeListener, align, center, classNameAndBounds, cleanUp, connectionPoint, contains, contains, countCornersContained, createDrag, damage, deleteFromModel, drawDashedLine, drawDashedPerimeter, endTrans, firePropChange, firePropChange, firePropChange, getAnnotationOwner, getAnnotationStrategy, getBounds, getBounds, getClosestPoint, getContext, getDashed, getDashed01, getDashedString, getEnclosedFigs, getEnclosingFig, getFillColor, getFilled, getFilled01, getFirstPoint, getGravityPoints, getGroup, getHalfHeight, getHalfWidth, getHandleBox, getHeight, getId, getLastPoint, getLayer, getLineColor, getLineWidth, getLocation, getLocked, getMinimumSize, getNumPoints, getOwner, getPerimeterLength, getPoint, getPoints, getPopUpActions, getPreferredSize, getResource, getSingle, getTipString, getTrapRect, getUseTrapRect, getVisState, getWidth, getX, getXs, getY, getYs, hasFillColor, hasLineColor, initAnnotations, insertPoint, intersects, intersectsPerimeter, isAnnotation, isCopyable, isCutable, isLowerRightResizable, isMovable, isResizable, isSelected, isVisible, makeSelection, OK, pointAlongPerimeter, postLoad, postSave, preSave, print, propertyChange, redraw, removeAnnotation, removeAnnotation, removeFromDiagram, removePoint, removePropertyChangeListener, reorder, routingRect, savingAllowed, setAnnotationOwner, setAnnotationStatus, setAnnotationStrategy, setBounds, setCenter, setContext, setDashed, setDashedString, setEnclosingFig, setGroup, setHandleBox, setHeight, setLayer, setLocation, setLocation, setLocked, setMovable, setNumPoints, setOwner, setPoint, setPoint, setPoint, setPoint, setPoints, setResizable, setResource, setSavingAllowed, setSingle, setSize, setSize, setVisible, setVisState, setWidth, setX, setXs, setY, setYs, stuffBounds, stuffPointAlongPerimeter, translateAnnotations, unsetAnnotationOwner, updateAnnotationPositions, updateVisState, within
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FigGroup

public FigGroup()
Construct a new FigGroup that holds no Figs.


FigGroup

public FigGroup(java.util.List figs)
Construct a new FigGroup that holds the given Figs.

Method Detail

parseDynObjects

public void parseDynObjects(java.lang.String dynStr)
Empty method. Every FigGroup that generates new elements dynamically has to overwrite this method for loading this figure. TODO this needs further explanation. It has some connection with PGMLParser and SVGParser


addFig

public void addFig(Fig fig)
Add a Fig to the group. Takes no action if already part of the group. Removes from any other group it may have been in already. New Figs are added on the top.

Parameters:
fig - the Fig to add to this group

addFigs

public void addFigs(java.util.Collection figs)
Add a collection of figs to the group.

Parameters:
figs - Collection of figs to be added.

setFigs

public void setFigs(java.util.Collection figs)
Sets a new collection of figs. The old collection is removed.

Parameters:
figs - Collection of figs to be set.

calcBounds

public void calcBounds()
Accumulate a bounding box for all the Figs in the group. This method is called by many parts of the framework and may cause some performance problems. It is possible to suppress this mthod by calling suppressCalcBounds(true). Be sure to call calcBounds as soon as this suppression is turned off again.

Overrides:
calcBounds in class Fig
See Also:
FigText.calcBounds()

getSubFigBounds

protected java.awt.Rectangle getSubFigBounds(Fig subFig)
Returns the bounds of the given subfig. This method can be overwritten in order to use different strategies on determining the overall bounds of the FigGroup.

Parameters:
subFig - Subfig of this group to calculate the bounds for.
Returns:
Rectangle representing the bounds of the subfig.

clone

public java.lang.Object clone()
Overrides:
clone in class Fig

contains

public boolean contains(int x,
                        int y)
Returns true if any Fig in the group contains the given point.

Overrides:
contains in class Fig
See Also:
FigCircle, FigEdge

elements

public java.util.Enumeration elements()
Deprecated. 0.11 use iterator()

Reply an Enumeration of the Figs contained in this FigGroup.


iterator

public java.util.Iterator iterator()
Reply an Iterator of the Figs contained in this FigGroup.


getFigAt

public Fig getFigAt(int i)
Get the fig within this group with the given index position

Parameters:
i - position of fig within this group

getFigs

public java.util.List getFigs()
Get the figs that make up this group

Returns:
the figs of this group USED BY PGML.tee

getFont

public java.awt.Font getFont()

getFontFamily

public java.lang.String getFontFamily()

getFontSize

public int getFontSize()

getPrivateData

public java.lang.String getPrivateData()
TODO document Used in SVG.TEE

Overrides:
getPrivateData in class Fig

getExtraFrameSpace

public int getExtraFrameSpace()
Returns the extra space that is added the frame surrounding the elements

Returns:
num of pixel used for extra spacing.

hit

public boolean hit(java.awt.Rectangle r)
Returns true if any Fig in the group hits the given rect.

Overrides:
hit in class Fig
Parameters:
r - the rectangular hit area
Returns:
true if the hit rectangle strikes this fig

hitFig

public Fig hitFig(java.awt.Rectangle r)
Retrieve the top-most Fig containing the given point, or null. Needs-More-Work: just do a linear search. Later, optimize this routine using Quad Trees (or other) techniques. Always returns false if this FigGroup is invisible.


isReshapable

public boolean isReshapable()
Groups are resizable by default (see super class), but not reshapable, and not rotatable (for now).

Overrides:
isReshapable in class Fig

isRotatable

public boolean isRotatable()
Groups are resizable by default (see super class), but not reshapable, and not rotatable (for now).

Overrides:
isRotatable in class Fig

paint

public void paint(java.awt.Graphics g)
Paint all the Figs in this group.

Overrides:
paint in class Fig

removeAll

public void removeAll()
Delete all Fig's from the group. Fires PropertyChange with "bounds".


removeFig

public void removeFig(Fig f)
Remove a Fig from the group. Fires PropertyChange with "bounds".


getDisplayedFigs

public java.util.Collection getDisplayedFigs(java.util.Collection c)
Returns a list of the displayable Figs enclosed. e.g. returns the list of enclosed Figs, without the Compartments that should not be displayed.


setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Set the bounding box to the given rect. Figs in the group are scaled to fit. Fires PropertyChange with "bounds"

Overrides:
setBounds in class Fig
Parameters:
x - new X co ordinate for fig
y - new Y co ordinate for fig
w - new width for fig
h - new height for fig

setFigs

public void setFigs(java.util.List figs)
Set the Figs in this group. Fires PropertyChange with "bounds".


setFillColor

public void setFillColor(java.awt.Color col)
Description copied from class: Fig
Sets the color that will be used if the Fig is filled. If col is null, turns off filling. Fires PropertyChangeEvent "fillColor", or "filled".

Overrides:
setFillColor in class Fig

setFilled

public void setFilled(boolean f)
Description copied from class: Fig
Sets a flag to either fill the Fig with its fillColor or not. Fires PropertyChangeEvent "filled".

Overrides:
setFilled in class Fig

setFont

public void setFont(java.awt.Font f)

setFontFamily

public void setFontFamily(java.lang.String s)

setFontSize

public void setFontSize(int s)

setLineColor

public void setLineColor(java.awt.Color col)
Description copied from class: Fig
Sets the color to be used if the lineWidth is > 0. If col is null, sets the lineWidth to 0. Fires PropertyChangeEvent "lineColor", or "lineWidth".

Overrides:
setLineColor in class Fig

setLineWidth

public void setLineWidth(int w)
Description copied from class: Fig
Set the line width. Zero means lines are not drawn. One draws them one pixel wide. Larger widths are in experimental support stadium (hendrik@freiheit.com, 2003-02-05). Fires PropertyChangeEvent "lineWidth".

Overrides:
setLineWidth in class Fig
Parameters:
w - The new lineWidth value

setPrivateData

public void setPrivateData(java.lang.String data)
Description copied from class: Fig
Derived classes should implement this method

Overrides:
setPrivateData in class Fig

setTextColor

public void setTextColor(java.awt.Color c)

setTextFillColor

public void setTextFillColor(java.awt.Color c)

setTextFilled

public void setTextFilled(boolean b)

getTextColor

public java.awt.Color getTextColor()

getTextFillColor

public java.awt.Color getTextFillColor()

getTextFilled

public boolean getTextFilled()

setExtraFrameSpace

public void setExtraFrameSpace(int extraSpace)
Sets the extra spacing for the frame around the elements

Parameters:
extraSpace - Num of pixels added as additional spacing

translate

public void translate(int dx,
                      int dy)
Translate all the Fig in the list by the given offset.

Overrides:
translate in class Fig

deepSelect

public Fig deepSelect(java.awt.Rectangle hitRect)
Let the group decide if it should be selected itself or the hitten grouped fig instead.

Parameters:
hitRect - Rectangle surrounding the current mouse position.
Returns:
The fig that should be selected.

getSize

public java.awt.Dimension getSize()
Returns the size of the group containing all entries.

Overrides:
getSize in class Fig
Returns:
Dimension representing the size of the group.