com.jgraph.graph
Class EdgeView

java.lang.Object
  extended bycom.jgraph.graph.AbstractCellView
      extended bycom.jgraph.graph.EdgeView
All Implemented Interfaces:
CellView, java.io.Serializable

public class EdgeView
extends AbstractCellView

The default implementation of an edge view.

See Also:
Serialized Form

Nested Class Summary
 class EdgeView.EdgeHandle
           
 
Field Summary
protected  java.awt.Point labelPosition
          Cached label position of the edge.
protected  java.util.List points
          List of points of the edge.
static EdgeRenderer renderer
          Renderer for the class.
protected  PortView source
          Cached source and target portview of the edge.
protected  PortView target
          Cached source and target portview of the edge.
 
Fields inherited from class com.jgraph.graph.AbstractCellView
attributes, cell, cellEditor, childViews, graph, mapper, parent
 
Constructor Summary
EdgeView(java.lang.Object cell, JGraph graph, CellMapper mapper)
          Constructs an edge view for the specified model object.
 
Method Summary
 void addPoint(int index, java.awt.Point p)
          Adds p at position index.
 java.awt.Rectangle getBounds()
          Returns the location for this portview.
 EdgeRenderer getEdgeRenderer()
          Returns the local renderer.
 CellHandle getHandle(GraphContext context)
          Returns a cell handle for the view.
 java.awt.Point getLabelPosition()
          Returns a point that describes the position of the label.
 java.awt.Point getPoint(int index)
          Returns the cached points for this edge.
 int getPointCount()
          Returns the number of point for this edge.
 CellViewRenderer getRenderer()
          Returns a renderer for the class.
 PortView getSource()
          Returns the portview that represents the source of the edge.
 PortView getTarget()
          Returns the portview that represents the target of the edge.
 boolean intersects(java.awt.Graphics g, java.awt.Rectangle rect)
          Returns true if this view intersects the given rectangle.
 boolean isAddPointEvent(java.awt.event.MouseEvent event)
          Returning true signifies a mouse event adds a new point to an edge.
 boolean isRemovePointEvent(java.awt.event.MouseEvent event)
          Returning true signifies a mouse event removes a given point.
 void refresh(boolean createDependentViews)
          Overrides the parent method to udpate the cached points, source and target port.
 void removePoint(int index)
          Removes the point at position index.
 void setLabelPosition(java.awt.Point pos)
          Sets the description of the label position.
 void setPoint(int index, java.awt.Point p)
          Sets the point at index to p.
 void setSource(PortView sourceView)
          Sets the sourceView of the edge.
 void setTarget(PortView targetView)
          Sets the targetView of the edge.
 void update()
          Update attributes and recurse children.
 
Methods inherited from class com.jgraph.graph.AbstractCellView
getAttributes, getBounds, getCell, getChildViews, getDescendantViews, getEditor, getGraph, getMapper, getModel, getParentView, getRendererComponent, isControlAttribute, isLeaf, removeFromParent, scale, setAttributes, setBounds, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

renderer

public static EdgeRenderer renderer
Renderer for the class.


points

protected java.util.List points
List of points of the edge. May contain ports.


source

protected PortView source
Cached source and target portview of the edge.


target

protected PortView target
Cached source and target portview of the edge.


labelPosition

protected java.awt.Point labelPosition
Cached label position of the edge.

Constructor Detail

EdgeView

public EdgeView(java.lang.Object cell,
                JGraph graph,
                CellMapper mapper)
Constructs an edge view for the specified model object.

Parameters:
cell - reference to the model object
Method Detail

refresh

public void refresh(boolean createDependentViews)
Overrides the parent method to udpate the cached points, source and target port. If the source or target is removed, a point is inserted into the array of points.

Specified by:
refresh in interface CellView
Overrides:
refresh in class AbstractCellView

update

public void update()
Update attributes and recurse children.

Specified by:
update in interface CellView
Overrides:
update in class AbstractCellView

intersects

public boolean intersects(java.awt.Graphics g,
                          java.awt.Rectangle rect)
Returns true if this view intersects the given rectangle.

Specified by:
intersects in interface CellView
Overrides:
intersects in class AbstractCellView

getBounds

public java.awt.Rectangle getBounds()
Returns the location for this portview.

Specified by:
getBounds in interface CellView
Specified by:
getBounds in class AbstractCellView

getEdgeRenderer

public EdgeRenderer getEdgeRenderer()
Returns the local renderer. Do not access the renderer field directly. Use this method instead!


getRenderer

public CellViewRenderer getRenderer()
Returns a renderer for the class.

Specified by:
getRenderer in class AbstractCellView

getHandle

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

Specified by:
getHandle in interface CellView
Specified by:
getHandle in class AbstractCellView

getSource

public PortView getSource()
Returns the portview that represents the source of the edge.


setSource

public void setSource(PortView sourceView)
Sets the sourceView of the edge.


getTarget

public PortView getTarget()
Returns the portview that represents the target of the edge.


setTarget

public void setTarget(PortView targetView)
Sets the targetView of the edge.


getLabelPosition

public java.awt.Point getLabelPosition()
Returns a point that describes the position of the label.


setLabelPosition

public void setLabelPosition(java.awt.Point pos)
Sets the description of the label position.


getPointCount

public int getPointCount()
Returns the number of point for this edge.


getPoint

public java.awt.Point getPoint(int index)
Returns the cached points for this edge.


setPoint

public void setPoint(int index,
                     java.awt.Point p)
Sets the point at index to p.


addPoint

public void addPoint(int index,
                     java.awt.Point p)
Adds p at position index.


removePoint

public void removePoint(int index)
Removes the point at position index.


isAddPointEvent

public boolean isAddPointEvent(java.awt.event.MouseEvent event)
Returning true signifies a mouse event adds a new point to an edge.


isRemovePointEvent

public boolean isRemovePointEvent(java.awt.event.MouseEvent event)
Returning true signifies a mouse event removes a given point.