easik.sketch.util.graph
Class ExtendableCellViewFactory

java.lang.Object
  extended by org.jgraph.graph.DefaultCellViewFactory
      extended by easik.sketch.util.graph.ExtendableCellViewFactory
All Implemented Interfaces:
java.io.Serializable, org.jgraph.graph.CellViewFactory
Direct Known Subclasses:
EasikCellViewFactory

public abstract class ExtendableCellViewFactory
extends org.jgraph.graph.DefaultCellViewFactory

A class that can be extended in order to add new ways of rendering cells. A cell is the most basic form of data component in JGraph, it can be either an edge or a vertex. In order to create a new drawing form, a new view must be created, along with a renderer to be associated with it. The renderer must override the getPreferredSize and paint methods. It is recommended that you map new cell types to views, instead of mapping new views to existing cell types. It is unspecified what will happen if two views are mapped to the same cell type. Once the cell and view classes are created, just call addCellType to create a mapping between the cell and view classes.

Since:
2006-07-25 William Belanger
Version:
2006-07-25 William Belanger
Author:
William Belanger 2006
See Also:
Serialized Form

Nested Class Summary
private static class ExtendableCellViewFactory.CellViewMapping
          A mapping of cell classes to view classes.
 
Field Summary
private  java.util.Vector<ExtendableCellViewFactory.CellViewMapping> viewIndirections
          The list of mappings between cell types and view types
 
Constructor Summary
ExtendableCellViewFactory()
          Default constructor that adds no new cell to view mappings.
 
Method Summary
 void addCellType(java.lang.Class cell, java.lang.Class view)
          Adds a cell to view mapping to the list of mappings.
protected  org.jgraph.graph.EdgeView createEdgeView(java.lang.Object cell)
          Creates edge views
protected  org.jgraph.graph.VertexView createVertexView(java.lang.Object v)
          Reads through the list of registered mappings to see if this object is a cell of the specified type.
 java.util.Vector<ExtendableCellViewFactory.CellViewMapping> getViewIndirections()
           
 void setViewIndirections(java.util.Vector<ExtendableCellViewFactory.CellViewMapping> list)
           
 
Methods inherited from class org.jgraph.graph.DefaultCellViewFactory
createEdgeView, createPortView, createPortView, createView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewIndirections

private java.util.Vector<ExtendableCellViewFactory.CellViewMapping> viewIndirections
The list of mappings between cell types and view types

Constructor Detail

ExtendableCellViewFactory

public ExtendableCellViewFactory()
Default constructor that adds no new cell to view mappings.

Method Detail

addCellType

public void addCellType(java.lang.Class cell,
                        java.lang.Class view)
Adds a cell to view mapping to the list of mappings.

Parameters:
cell - The cell type.
view - The view type that should be used when creating a drawing of this cell type.

createVertexView

protected org.jgraph.graph.VertexView createVertexView(java.lang.Object v)
Reads through the list of registered mappings to see if this object is a cell of the specified type.

Overrides:
createVertexView in class org.jgraph.graph.DefaultCellViewFactory
Parameters:
v - The object to base creation on
Returns:
The view for the object to be rendered in

getViewIndirections

public java.util.Vector<ExtendableCellViewFactory.CellViewMapping> getViewIndirections()
Returns:
The list of mappings between cells and views.

setViewIndirections

public void setViewIndirections(java.util.Vector<ExtendableCellViewFactory.CellViewMapping> list)
Parameters:
list - The new list of mappings between cells and views.

createEdgeView

protected org.jgraph.graph.EdgeView createEdgeView(java.lang.Object cell)
Creates edge views

Overrides:
createEdgeView in class org.jgraph.graph.DefaultCellViewFactory
Parameters:
cell - The edge cell to base creation on
Returns:
The created edge view