JGraph
v5.1


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.

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, groupBounds, 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
 Rectangle2D getBounds()
          Returns the bounds for the port view.
protected  Point2D getEdgePoint(EdgeView view, int index)
          Returns the point of edge at index index.
 CellHandle getHandle(GraphContext context)
          Returns null.
 Point2D getLocation(EdgeView edge)
          Returns the point that the port represents with respect to edge.
protected  Point2D 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.
protected  boolean shouldInvokePortMagic(EdgeView edge)
          Subclassers can override this to decide whether or not "port magic" should appear on a given edge.
 
Methods inherited from class org.jgraph.graph.AbstractCellView
childUpdated, createLocalAttributeMap, getAllAttributes, getAttributes, getBounds, getCell, getChildViews, getDescendantViews, getEditor, getGraph, getMapper, getModel, getRendererComponent, intersects, isLeaf, refresh, removeFromParent, scale, setAttributes, setBounds, translate, update, updateAllAttributes, updateGroupBounds
 
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
anchor - view of the parent
anchor - view of the anchor port
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 Rectangle2D getBounds()
Returns the bounds for the port view.

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

getHandle

public CellHandle getHandle(GraphContext context)
Returns null.

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

getLocation

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


shouldInvokePortMagic

protected boolean shouldInvokePortMagic(EdgeView edge)
Subclassers can override this to decide whether or not "port magic" should appear on a given edge. (Port magic means the port tries to make the edge horizontal or vertical if the closest control point lies within the bounds of the parent vertex.)


getNextPoint

protected Point2D 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 Point2D 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).


JGraph
v5.1


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