Package org.jgraph.graph
Class AbstractCellView
java.lang.Object
org.jgraph.graph.AbstractCellView
- All Implemented Interfaces:
Serializable,CellView
- Direct Known Subclasses:
EdgeView,PortView,VertexView
The abstract base class for all cell views.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AttributeMapContains the complete set of attributes, including the cell's attributes.protected AttributeMapHashtable for attributes.protected ObjectReference to the cell for this viewstatic GraphCellEditorEditor for the cell.protected ListCached child views.protected Rectangle2DCached bounds of all children if vertex is a groupprotected CellViewCached parent view -
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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
Modifier and TypeMethodDescriptionchangeAttributes(GraphLayoutCache cache, Map change) Applieschangeto the attributes of the view and calls update.voidIndicates to parent, if any, that this child has been updated.protected AttributeMapHook for subclassers to avoid creating an empty AttributeMap during construction of the instance.Returns the attributes of the view combined with the attributes of the corresponding cell.Return the attributes of the view.Returns the cached bounds for the group if isleaf is falsestatic Rectangle2DReturns the bounding box for the specified views.getCell()Returns the model object that this view represents.protected AttributeMapgetCellAttributes(GraphModel model) Hook for subclassers to avoid cloning the cell's attributes.static Point2DgetCenterPoint(CellView vertex) CellView[]Returns the child views of this view.static CellView[]getDescendantViews(CellView[] views) Returns all views, including descendants that have a parent inviewswithout the PortViews.Returns a cell editor for the view.abstract CellHandlegetHandle(GraphContext context) Returns a cell handle for the view.Returns the parent view for this view.getPerimeterPoint(EdgeView edge, Point2D source, Point2D p) Returns the intersection of the bounding rectangle and the straight line between the source and the specified point p.abstract CellViewRendererObtains the renderer instance for this viewgetRendererComponent(JGraph graph, boolean selected, boolean focus, boolean preview) Returns a renderer component, configured for the view.protected booleanincludeInGroupBounds(CellView view) This is used to exclude certain cell views from the group bounds computation.booleanintersects(JGraph graph, Rectangle2D rect) Returns true if the view intersects the given rectangle.booleanisLeaf()Returnstrueif the view is a leaf.protected voidImplements the merging of the cell's attributes, initially stored in allAttributes, and the location attributes.voidrefresh(GraphLayoutCache cache, CellMapper mapper, boolean createDependentViews) Create child views and reload properties for this view.voidRemoves this view from the list of children of the parent.voidScaleview(group) bysx, sy.voidsetAttributes(AttributeMap attributes) Sets the attributes of this view to the specified valuevoidsetBounds(Rectangle2D bounds) Sets the bounds of thisview.voidSets the model object that this view represents to the specified cellvoidtranslate(double dx, double dy) Translatesview(group) bydx, dy.voidupdate(GraphLayoutCache cache) Update attributes for this view and indicate to the parent this child has been updatedprotected voidUpdates the bounds of this view and its children
-
Field Details
-
cellEditor
Editor for the cell. -
cell
Reference to the cell for this view -
parent
Cached parent view -
childViews
Cached child views. Default is a ArrayList with allocation size 0. -
allAttributes
Contains the complete set of attributes, including the cell's attributes. The values in this map are overriden by the corresponding values inattributes. -
attributes
Hashtable for attributes. Value in this map override the values inallAttributes. -
groupBounds
Cached bounds of all children if vertex is a group
-
-
Constructor Details
-
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
Constructs a view for the specified model object, and invokes update on the new instance.- Parameters:
cell- reference to the model object
-
-
Method Details
-
createAttributeMap
Hook for subclassers to avoid creating an empty AttributeMap during construction of the instance. Override this and return null if you want to avoid creation of an attribute map at construction time. -
getCell
Returns the model object that this view represents. -
setCell
Sets the model object that this view represents to the specified cell- Parameters:
cell- the model object this view will represent
-
refresh
Create child views and reload properties for this view. Invokes update first. -
getCellAttributes
Hook for subclassers to avoid cloning the cell's attributes. Return model.getAttributes(cell) to avoid cloning. -
update
Update attributes for this view and indicate to the parent this child has been updated -
mergeAttributes
protected void mergeAttributes()Implements the merging of the cell's attributes, initially stored in allAttributes, and the location attributes. The result should be stored in allAttributes. This hook is for subclassers to change the merging strategy. -
childUpdated
public void childUpdated()Indicates to parent, if any, that this child has been updated.- Specified by:
childUpdatedin interfaceCellView
-
getParentView
Returns the parent view for this view.- Specified by:
getParentViewin interfaceCellView- Returns:
- the parent view for this view
-
getChildViews
Returns the child views of this view.- Specified by:
getChildViewsin interfaceCellView- Returns:
- the child views of this view
-
getDescendantViews
Returns all views, including descendants that have a parent inviewswithout 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.- Parameters:
views- the cell views whose descendants are to be returned- Returns:
- the specified views and all their descendant views
-
removeFromParent
public void removeFromParent()Removes this view from the list of children of the parent.- Specified by:
removeFromParentin interfaceCellView
-
isLeaf
public boolean isLeaf()Returnstrueif the view is a leaf. -
getAttributes
Return the attributes of the view.- Specified by:
getAttributesin interfaceCellView- Returns:
- the
attributesof this view
-
setAttributes
Sets the attributes of this view to the specified value- Parameters:
attributes- the new attributes to set
-
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:
getAllAttributesin interfaceCellView
-
changeAttributes
Applieschangeto the attributes of the view and calls update.- Specified by:
changeAttributesin interfaceCellView- Parameters:
change- a map of attribute changes to apply- Returns:
- the undo map that reverses this change
-
getBounds
Returns the cached bounds for the group if isleaf is false -
getBounds
Returns the bounding box for the specified views.- Parameters:
views- the views for whom the bounding box is to be determined- Returns:
- the bounding box of the specified views
-
setBounds
Sets the bounds of thisview. Calls translateView and scaleView.- Parameters:
bounds- the new bounds for this cell view
-
updateGroupBounds
protected void updateGroupBounds()Updates the bounds of this view and its children -
includeInGroupBounds
This is used to exclude certain cell views from the group bounds computation. This implementation returns false for edges that connect to one of their ancestor groups (eg. parent).- Parameters:
view- the cell view to be included in the group bounds or not- Returns:
- whether or not to include the specified cell in the group bounds
-
translate
public void translate(double dx, double dy) Translatesview(group) bydx, dy.- Parameters:
dx- the x-coordinate amount to translate bydy- the y-coordinate amount to translate by
-
scale
Scaleview(group) bysx, sy.- Parameters:
sx- the multiple by which the x coordinate position of the cell view is to be scaledsy- the multiple by which the y coordinate position of the cell view is to be scaledorigin- the origin point from which the scaling will calculate
-
intersects
Returns true if the view intersects the given rectangle.- Specified by:
intersectsin interfaceCellView- Parameters:
graph- theJGraphinstance of the viewrect- the rectangle within which intersection is being checked for- Returns:
- whether or not the rectangle specified intersects the view
-
getRendererComponent
public Component getRendererComponent(JGraph graph, boolean selected, boolean focus, boolean preview) Returns a renderer component, configured for the view. The method used to obtain the renderer instance must install the necessary attributes from this view- Specified by:
getRendererComponentin interfaceCellView- Parameters:
graph- theJGraphinstance of the viewselected- whether or not this view is selectedfocus- whether or not this view is the focuspreview- whether or not it is a preview of the view- Returns:
- the renderer component for this view with this views attributes installed
-
getRenderer
Obtains the renderer instance for this view- Returns:
- the renderer instance for this view
-
getHandle
Returns a cell handle for the view. -
getEditor
Returns a cell editor for the view. -
getCenterPoint
-
getPerimeterPoint
Returns the intersection of the bounding rectangle and the straight line between the source and the specified point p. The specified point is expected not to intersect the bounds. Note: You must override this method if you use a different renderer. This is because this method relies on the VertexRenderer interface, which can not be safely assumed for subclassers.- Specified by:
getPerimeterPointin interfaceCellView
-