org.jgraph.graph
Class EdgeView

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

public class EdgeView
extends AbstractCellView

The default implementation of an edge view.

Version:
1.0 1/1/02
Author:
Gaudenz Alder
See Also:
Serialized Form

Nested Class Summary
 class EdgeView.EdgeHandle
           
 
Field Summary
 Shape beginShape
          Drawing attributes that are created on the fly
 Shape endShape
          Drawing attributes that are created on the fly
protected  Point labelPosition
          Cached label position of the edge.
 Shape lineShape
          Drawing attributes that are created on the fly
protected  List points
          List of points of the edge.
static EdgeRenderer renderer
          Renderer for the class.
static long shapeHits
           
 GeneralPath sharedPath
          Shared-path tune-up.
protected  CellView source
          Cached source and target portview of the edge.
protected  CellView target
          Cached source and target portview of the edge.
 
Fields inherited from class org.jgraph.graph.AbstractCellView
allAttributes, attributes, cell, cellEditor, childViews, graph, mapper, parent
 
Constructor Summary
EdgeView(Object cell, JGraph graph, CellMapper mapper)
          Constructs an edge view for the specified model object.
 
Method Summary
 void addPoint(int index, Point p)
          Adds p at position index.
 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.
 Rectangle getLabelBounds()
          Returns the bounds of label according to the last rendering state
 Point getLabelPosition()
          Returns a point that describes the position of the label.
static double getLength(CellView view)
           
 Point getPoint(int index)
          Returns the cached points for this edge.
 int getPointCount()
          Returns the number of point for this edge.
 List getPoints()
          Returns the points.
 CellViewRenderer getRenderer()
          Returns a renderer for the class.
 Shape getShape()
          Returns the shape of the view according to the last rendering state
 CellView getSource()
          Returns the CellView that represents the source of the edge.
 CellView getTarget()
          Returns the CellView that represents the target of the edge.
 boolean intersects(Graphics g, Rectangle rect)
          Returns true if this view intersects the given rectangle.
 boolean isAddPointEvent(MouseEvent event)
          Returning true signifies a mouse event adds a new point to an edge.
 boolean isConstrainedMoveEvent(MouseEvent e)
           
 boolean isRemovePointEvent(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(Point pos)
          Sets the description of the label position.
 void setPoint(int index, Point p)
          Sets the point at index to p.
 void setSource(CellView sourceView)
          Sets the sourceView of the edge.
 void setTarget(CellView targetView)
          Sets the targetView of the edge.
 void update()
          Update attributes and recurse children.
 
Methods inherited from class org.jgraph.graph.AbstractCellView
childUpdated, getAllAttributes, getAttributes, getBounds, getCell, getChildViews, getDescendantViews, getEditor, getGraph, getMapper, getModel, getParentView, getRendererComponent, isLeaf, removeFromParent, scale, setAttributes, setBounds, translate, updateAllAttributes
 
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 List points
List of points of the edge. May contain ports.


source

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


target

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


labelPosition

protected Point labelPosition
Cached label position of the edge.


beginShape

public Shape beginShape
Drawing attributes that are created on the fly


endShape

public Shape endShape
Drawing attributes that are created on the fly


lineShape

public Shape lineShape
Drawing attributes that are created on the fly


sharedPath

public transient GeneralPath sharedPath
Shared-path tune-up.


shapeHits

public static long shapeHits
Constructor Detail

EdgeView

public EdgeView(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

getShape

public final Shape getShape()
Returns the shape of the view according to the last rendering state


getLabelBounds

public final Rectangle getLabelBounds()
Returns the bounds of label according to the last rendering state


intersects

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

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

getBounds

public 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 CellView getSource()
Returns the CellView that represents the source of the edge.


setSource

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


getTarget

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


setTarget

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


getLabelPosition

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


setLabelPosition

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


getPoints

public List getPoints()
Returns the points.

Returns:
java.util.List

getPointCount

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


getPoint

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


setPoint

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


addPoint

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


removePoint

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


isAddPointEvent

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


isRemovePointEvent

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


getLength

public static double getLength(CellView view)

isConstrainedMoveEvent

public boolean isConstrainedMoveEvent(MouseEvent e)