JGraph
v5.5.3


org.jgraph.graph
Class EdgeView

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

public class EdgeView
extends AbstractCellView

The default implementation of an edge view. The getEdgeRenderer method assumes a renderer of type EdgeRenderer. If you provide a custom renderer to a subclass, you must also override the methods that call this method, namely: getShape, getLabelBounds, getExtraLabelBounds, intersects and getBounds.

See Also:
Serialized Form

Nested Class Summary
static class EdgeView.EdgeHandle
           
 
Field Summary
 Shape beginShape
          Drawing attributes that are created on the fly
protected  Rectangle2D cachedBounds
           
protected  Rectangle2D[] cachedExtraLabelBounds
           
protected  Rectangle2D cachedLabelBounds
           
 Shape endShape
          Drawing attributes that are created on the fly
protected  Point[] extraLabelPositions
           
protected  Point labelPosition
          Cached label position of the edge.
protected  Point2D labelVector
           
 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.
 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, groupBounds, parent
 
Constructor Summary
EdgeView()
          Constructs an empty edge view.
EdgeView(Object cell)
          Constructs an edge view for the specified model object.
 
Method Summary
 void addPoint(int index, Point2D p)
          Adds p at position index.
protected  void checkDefaultLabelPosition()
          Hook for subclassers to avoid default label positions.
 Rectangle2D getBounds()
          Returns the location for this edgeview.
 Rectangle2D getExtraLabelBounds(int index)
          Returns the bounds of label according to the last rendering state
 Point2D getExtraLabelPosition(int index)
          Returns a point that describes the position of the label.
 CellHandle getHandle(GraphContext context)
          Returns a cell handle for the view.
 Rectangle2D getLabelBounds()
          Returns the bounds of label according to the last rendering state
 Point2D getLabelPosition()
          Returns a point that describes the position of the label.
 Point2D getLabelVector()
          Hook to return the vector that is taken as the base vector to compute relative label positions.
static double getLength(CellView view)
           
protected  Point2D getNearestPoint(boolean source)
          Returns the nearest oint wrt to the source or target.
 Point2D getPoint(int index)
          Returns the cached points for this edge.
 int getPointCount()
          Returns the number of point for this edge.
protected  Point2D getPointLocation(int index)
          Returns the point of edge at index.
 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(JGraph graph, Rectangle2D rect)
          Returns true if this view intersects the given rectangle.
 void refresh(GraphModel model, CellMapper mapper, 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 setExtraLabelPosition(int index, Point2D pos)
          Sets the description of the label position.
 void setLabelPosition(Point2D pos)
          Sets the description of the label position.
 void setPoint(int index, Point2D 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
changeAttributes, childUpdated, createAttributeMap, getAllAttributes, getAttributes, getBounds, getCell, getCellAttributes, getChildViews, getDescendantViews, getEditor, getParentView, getRendererComponent, includeInGroupBounds, isLeaf, mergeAttributes, removeFromParent, scale, setAttributes, setBounds, setCell, translate, updateGroupBounds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

renderer

public static transient EdgeRenderer renderer
Renderer for the class.


points

protected transient List points
List of points of the edge. May contain ports.


source

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


target

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


labelPosition

protected transient Point labelPosition
Cached label position of the edge.


extraLabelPositions

protected transient Point[] extraLabelPositions

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.


cachedLabelBounds

protected transient Rectangle2D cachedLabelBounds

cachedExtraLabelBounds

protected transient Rectangle2D[] cachedExtraLabelBounds

cachedBounds

protected transient Rectangle2D cachedBounds

labelVector

protected transient Point2D labelVector
Constructor Detail

EdgeView

public EdgeView()
Constructs an empty edge view.


EdgeView

public EdgeView(Object cell)
Constructs an edge view for the specified model object.

Parameters:
cell - reference to the model object
Method Detail

refresh

public void refresh(GraphModel model,
                    CellMapper mapper,
                    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
Parameters:
model - the graph model to be used
mapper - the cell mapper to be used
createDependentViews - whether or not to create a view if one does not already exist

update

public void update()
Update attributes and recurse children.

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

checkDefaultLabelPosition

protected void checkDefaultLabelPosition()
Hook for subclassers to avoid default label positions.


getShape

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


getLabelBounds

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


getExtraLabelBounds

public Rectangle2D getExtraLabelBounds(int index)
Returns the bounds of label according to the last rendering state


intersects

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

Specified by:
intersects in interface CellView
Overrides:
intersects in class AbstractCellView
Parameters:
graph - the JGraph instance of the view
rect - the rectangle within which intersection is being checked for
Returns:
whether or not the rectangle specified intersects the view

getBounds

public Rectangle2D getBounds()
Returns the location for this edgeview.

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

getRenderer

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

Specified by:
getRenderer in class AbstractCellView
Returns:
the renderer instance for this view

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
Parameters:
context - the context of this cell view (cells indirectly affected by it)
Returns:
the cell handle for this view

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.


getExtraLabelPosition

public Point2D getExtraLabelPosition(int index)
Returns a point that describes the position of the label.


getLabelPosition

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


setLabelPosition

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


setExtraLabelPosition

public void setExtraLabelPosition(int index,
                                  Point2D 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 Point2D getPoint(int index)
Returns the cached points for this edge.


getNearestPoint

protected Point2D getNearestPoint(boolean source)
Returns the nearest oint wrt to the source or target. This method returns the next or previous point or port in the points list, eg. if source is true it returns the location of the point or port at index 1 without calling the getLocation method on any ports.
Likewise, the method returns the location at index getPointCount()-2 if source is false.


getPointLocation

protected Point2D getPointLocation(int index)
Returns the point of edge at index. Avoids calling getLocation on any ports of edge.
This is used from within getPoint to pass the nearest point to the portview to find it's location. This uses the center point of the parent view to determine the port view's location to avoid infinite recursion.


setPoint

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


addPoint

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


removePoint

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


getLabelVector

public Point2D getLabelVector()
Hook to return the vector that is taken as the base vector to compute relative label positions. Normally, the vector goes from the first to the last point on the edge, unless these points are equal, in which case the average distance of all points to the source point is used.


getLength

public static double getLength(CellView view)

JGraph
v5.5.3


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