org.jgraph.graph
Class PortView

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

public class PortView
extends AbstractCellView

The default implementation of a port view.

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

Field Summary
protected  CellView lastParent
          Cache of the last valid parent.
static PortRenderer renderer
          Renderer for the class.
protected static int size
          Default size for all ports is 6.
 
Fields inherited from class org.jgraph.graph.AbstractCellView
allAttributes, attributes, cell, cellEditor, childViews, graph, mapper, parent
 
Constructor Summary
PortView(Object cell, JGraph graph, CellMapper mapper)
          Constructs a view that holds a reference to the specified cell, anchor and parent vertex.
 
Method Summary
 Rectangle getBounds()
          Returns the bounds for the port view.
protected  Point getEdgePoint(EdgeView view, int index)
          Returns the point of edge at index index.
 CellHandle getHandle(GraphContext context)
          Returns null.
 Point getLocation(EdgeView edge)
          Returns the point that the port represents with respect to edge.
protected  Point getNextPoint(EdgeView edge)
          Returns the point that is closest to the port view on edge.
 CellView getParentView()
          This method ensures a non-null value.
 CellViewRenderer getRenderer()
          Returns a renderer for the class.
 
Methods inherited from class org.jgraph.graph.AbstractCellView
childUpdated, getAllAttributes, getAttributes, getBounds, getCell, getChildViews, getDescendantViews, getEditor, getGraph, getMapper, getModel, getRendererComponent, intersects, isLeaf, refresh, removeFromParent, scale, setAttributes, setBounds, translate, update, updateAllAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

protected static int size
Default size for all ports is 6.


renderer

public static PortRenderer renderer
Renderer for the class.


lastParent

protected transient CellView lastParent
Cache of the last valid parent. //FIX: Better solution?

Constructor Detail

PortView

public PortView(Object cell,
                JGraph graph,
                CellMapper mapper)
Constructs a view that holds a reference to the specified cell, anchor and parent vertex.

Parameters:
cell - reference to the cell in the model
graph -
mapper -
Method Detail

getParentView

public CellView getParentView()
This method ensures a non-null value. If the super method returns null then the last valid parent is returned. Note: If a vertex is removed, all ports will be replaced in connected edges. The ports are replaced by the center point of the last valid vertex view.

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

getBounds

public Rectangle getBounds()
Returns the bounds for the port view.

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

getRenderer

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

Specified by:
getRenderer in class AbstractCellView

getHandle

public CellHandle getHandle(GraphContext context)
Returns null.

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

getLocation

public Point getLocation(EdgeView edge)
Returns the point that the port represents with respect to edge. edge may be null.


getNextPoint

protected Point getNextPoint(EdgeView edge)
Returns the point that is closest to the port view on edge. Returns null if edge has less than 2 points.


getEdgePoint

protected Point getEdgePoint(EdgeView view,
                             int index)
Returns the point of edge at index index. Avoids calling getLocation on the opposite port of edge (possible infinite recursion).