JGraph
v5.2.1


org.jgraph.graph
Class AbstractCellView

java.lang.Object
  extended byorg.jgraph.graph.AbstractCellView
All Implemented Interfaces:
CellView, Serializable
Direct Known Subclasses:
EdgeView, PortView, VertexView

public abstract class AbstractCellView
extends Object
implements CellView, Serializable

The abstract base class for all cell views.

See Also:
Serialized Form

Field Summary
protected  AttributeMap allAttributes
          Contains the complete set of attributes, ie.
protected  AttributeMap attributes
          Hashtable for attributes.
protected  Object cell
          Reference to the cell for this view
protected static GraphCellEditor cellEditor
          Editor for the cell.
protected  List childViews
          Cached child views.
protected  Rectangle2D groupBounds
          Cached bounds of all children if vertex is a group
protected  CellView parent
          Cached parent view
 
Constructor Summary
AbstractCellView()
          Constructs an empty abstract cell view.
AbstractCellView(Object cell)
          Constructs a view for the specified model object, and invokes update on the new instance.
 
Method Summary
 Map changeAttributes(Map change)
          Applies change to the attributes of the view and calls update.
 void childUpdated()
           
protected  AttributeMap createFallbackAttributeMap()
          Default implementation returns an AttributeMap
 AttributeMap getAllAttributes()
          Returns the attributes of the view combined with the attributes of the corresponding cell.
 AttributeMap getAttributes()
          Return the attributes of the view.
 Rectangle2D getBounds()
          Returns the cached bounds for the group if isleaf is false
static Rectangle2D getBounds(CellView[] views)
          Returns the bounding box for the specified views.
 Object getCell()
          Returns the model object that this view represents.
 CellView[] getChildViews()
          Returns the child views of this view.
static CellView[] getDescendantViews(CellView[] views)
          Returns all views, including descendants that have a parent in views without the PortViews.
 GraphCellEditor getEditor()
          Returns a cell editor for the view.
abstract  CellHandle getHandle(GraphContext context)
          Returns a cell handle for the view.
 CellView getParentView()
          Returns the parent view for this view.
abstract  CellViewRenderer getRenderer()
           
 Component getRendererComponent(JGraph graph, boolean selected, boolean focus, boolean preview)
          Returns a renderer component, configured for the view.
protected  boolean includeInGroupBounds(CellView view)
           
 boolean intersects(JGraph graph, Rectangle2D rect)
          Returns true if the view intersects the given rectangle.
 boolean isLeaf()
          Returns true if the view is a leaf.
 void refresh(GraphModel model, CellMapper mapper, boolean createDependentViews)
          Create child views and reload properties.
 void removeFromParent()
          Removes this view from the list of childs of the parent.
protected  void scale(double sx, double sy, Point2D origin)
          Scale view (group) by sx, sy.
 void setAttributes(AttributeMap attributes)
          Return the attributes of the view.
 void setBounds(Rectangle2D bounds)
          Sets the bounds of view.
 void setCell(Object cell)
          Returns the model object that this view represents.
protected  void translate(double dx, double dy)
          Translates view (group) by dx, dy.
 void update()
          Update attributes and recurse children.
protected  void updateAllAttributes()
          This method implements the merge between the cell's and the view's attributes.
protected  void updateGroupBounds()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cellEditor

protected static transient GraphCellEditor cellEditor
Editor for the cell.


cell

protected Object cell
Reference to the cell for this view


parent

protected transient CellView parent
Cached parent view


childViews

protected transient List childViews
Cached child views.


groupBounds

protected transient Rectangle2D groupBounds
Cached bounds of all children if vertex is a group


attributes

protected AttributeMap attributes
Hashtable for attributes. Initially created by calling createLocalAttributes. Value in this map override the values in allAttributes.


allAttributes

protected transient AttributeMap allAttributes
Contains the complete set of attributes, ie. including the cell's attributes. The values in this map are overriden by the corresponding values in attributes.

Constructor Detail

AbstractCellView

public AbstractCellView()
Constructs an empty abstract cell view. You should set a cell on this view using setCell before doing anything. Optionally you can also set a different attribute map using setAttributeMap. Note: To change the attribute map you should now use the changeAttributes method.


AbstractCellView

public AbstractCellView(Object cell)
Constructs a view for the specified model object, and invokes update on the new instance.

Parameters:
cell - reference to the model object
Method Detail

getCell

public Object getCell()
Returns the model object that this view represents.

Specified by:
getCell in interface CellView

setCell

public void setCell(Object cell)
Returns the model object that this view represents.


refresh

public void refresh(GraphModel model,
                    CellMapper mapper,
                    boolean createDependentViews)
Create child views and reload properties. Invokes update first.

Specified by:
refresh in interface CellView

update

public void update()
Update attributes and recurse children.

Specified by:
update in interface CellView

updateAllAttributes

protected void updateAllAttributes()
This method implements the merge between the cell's and the view's attributes. The view's attributes override the cell's attributes.


createFallbackAttributeMap

protected AttributeMap createFallbackAttributeMap()
Default implementation returns an AttributeMap

Returns:
a new AttributeMap

childUpdated

public void childUpdated()
Specified by:
childUpdated in interface CellView

getParentView

public CellView getParentView()
Returns the parent view for this view.

Specified by:
getParentView in interface CellView

getChildViews

public CellView[] getChildViews()
Returns the child views of this view.

Specified by:
getChildViews in interface CellView

getDescendantViews

public static CellView[] getDescendantViews(CellView[] views)
Returns all views, including descendants that have a parent in views without the PortViews. Note: Iterative Implementation using view.getChildViews. This returns the array in inverse order, ie with the top most cell view at index 0.


removeFromParent

public void removeFromParent()
Removes this view from the list of childs of the parent.

Specified by:
removeFromParent in interface CellView

isLeaf

public boolean isLeaf()
Returns true if the view is a leaf.

Specified by:
isLeaf in interface CellView

getAttributes

public AttributeMap getAttributes()
Return the attributes of the view.

Specified by:
getAttributes in interface CellView

setAttributes

public void setAttributes(AttributeMap attributes)
Return the attributes of the view.


getAllAttributes

public AttributeMap getAllAttributes()
Returns the attributes of the view combined with the attributes of the corresponding cell. The view's attributes override the cell's attributes with the same key.

Specified by:
getAllAttributes in interface CellView

changeAttributes

public Map changeAttributes(Map change)
Applies change to the attributes of the view and calls update.

Specified by:
changeAttributes in interface CellView

getBounds

public Rectangle2D getBounds()
Returns the cached bounds for the group if isleaf is false

Specified by:
getBounds in interface CellView

getBounds

public static Rectangle2D getBounds(CellView[] views)
Returns the bounding box for the specified views.


setBounds

public void setBounds(Rectangle2D bounds)
Sets the bounds of view. Calls translateView and scaleView.


updateGroupBounds

protected void updateGroupBounds()

includeInGroupBounds

protected boolean includeInGroupBounds(CellView view)

translate

protected void translate(double dx,
                         double dy)
Translates view (group) by dx, dy.


scale

protected void scale(double sx,
                     double sy,
                     Point2D origin)
Scale view (group) by sx, sy.


intersects

public boolean intersects(JGraph graph,
                          Rectangle2D rect)
Returns true if the view intersects the given rectangle.

Specified by:
intersects in interface CellView

getRendererComponent

public Component getRendererComponent(JGraph graph,
                                      boolean selected,
                                      boolean focus,
                                      boolean preview)
Returns a renderer component, configured for the view.

Specified by:
getRendererComponent in interface CellView

getRenderer

public abstract CellViewRenderer getRenderer()

getHandle

public abstract CellHandle getHandle(GraphContext context)
Returns a cell handle for the view.

Specified by:
getHandle in interface CellView

getEditor

public GraphCellEditor getEditor()
Returns a cell editor for the view.

Specified by:
getEditor in interface CellView

JGraph
v5.2.1


Copyright (C) 2001-2004 Gaudenz Alder. All rights reserved.