JGraphpad Pro
v6.0.5.0


com.jgraph.pad.tool
Class JGraphpadVertexTool

java.lang.Object
  extended byorg.jgraph.graph.BasicMarqueeHandler
      extended bycom.jgraph.editor.JGraphEditorTool
          extended bycom.jgraph.pad.tool.JGraphpadVertexTool
Direct Known Subclasses:
JGraphpadEdgeTool

public class JGraphpadVertexTool
extends JGraphEditorTool

Tool that inserts vertices based on a prototype.


Field Summary
static String NAME_VERTEXTOOL
          Defines the default name for tools of this kind.
protected  boolean previewEnabled
          Specifies if the cellview should be previewed.
protected  org.jgraph.graph.CellView previewView
          Preview vertex view.
protected  Object prototype
          Holds the prototype to create new cells with.
protected  Dimension singleClickSize
          Defines the default size for vertices that are generated with a single click.
protected  int threshold
          Defines the threshhold (minimum size) for a drag to be used for an insert.
 
Fields inherited from class com.jgraph.editor.JGraphEditorTool
isAlwaysActive, name
 
Fields inherited from class org.jgraph.graph.BasicMarqueeHandler
currentPoint, marqueeBounds, previousCursor, startPoint
 
Constructor Summary
JGraphpadVertexTool(Object prototype)
          Constructs a new vertex tool for the specified prototype using NAME_VERTEXTOOL.
JGraphpadVertexTool(String name, Object prototype)
          Constructs a new vertex tool for the specified name and prototype.
 
Method Summary
protected  Object createCell(org.jgraph.graph.GraphModel model)
          Returns a deep clone of the cell prototype.
protected  void execute(org.jgraph.JGraph graph, Object cell)
          Provides a hook for subclassers to insert the specified cell into cache.
 Object getPrototype()
          Returns the prototype used to create new cells.
 Dimension getSingleClickSize()
          Returns the single click size which should be used to insert cells with a single click.
 int getThreshold()
          Returns the threshold for a drag to count as an insert.
protected  boolean isConstrainedSizeEvent(MouseEvent event)
          Hook for subclassers to define the key assignments for constrained inserts.
 boolean isPreviewEnabled()
          Sets if the cellview should be previewed.
 void mousePressed(MouseEvent event)
          Extends the parent's implementation to create a clone of the pototype using createCell(GraphModel) and a new view using the layout cache's factory.
 void mouseReleased(MouseEvent event)
          Overrides the parent's implementation to check if the event triggers an insert (checks threshold & singleClickSize) and inserts the cell stored in previewView using #execute(GraphLayoutCache, Object).
 void overlay(org.jgraph.JGraph graph, Graphics g, boolean clear)
          Extends the parent's implementation to draw the previewView.
protected  void processMouseDraggedEvent(MouseEvent event)
          Overrides the parent's implementation to update the preview bounds to the current BasicMarqueeHandler.marqueeBounds.
 void setPreviewEnabled(boolean previewEnabled)
          Returns if the cellview should be previewed.
 void setPrototype(Object prototype)
          Sets the prototype to be used to create new cells.
 void setSingleClickSize(Dimension singleClickSize)
          Sets the size of cells to be inserted with a single click.
 void setThreshold(int threshold)
          Sets the threshold for a drag to count as an insert.
 
Methods inherited from class com.jgraph.editor.JGraphEditorTool
getName, isAlwaysActive, setAlwaysActive, setName
 
Methods inherited from class org.jgraph.graph.BasicMarqueeHandler
getCurrentPoint, getGraphForEvent, getMarqueeBounds, getPreviousCursor, getStartPoint, handleMarqueeEvent, isForceMarqueeEvent, isMarqueeTriggerEvent, mouseDragged, mouseMoved, paint, setCurrentPoint, setMarqueeBounds, setPreviousCursor, setStartPoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_VERTEXTOOL

public static final String NAME_VERTEXTOOL
Defines the default name for tools of this kind.

See Also:
Constant Field Values

prototype

protected Object prototype
Holds the prototype to create new cells with.


threshold

protected int threshold
Defines the threshhold (minimum size) for a drag to be used for an insert. Default is 4.


singleClickSize

protected Dimension singleClickSize
Defines the default size for vertices that are generated with a single click. A value of null ignores single clicks. Default is null.


previewView

protected transient org.jgraph.graph.CellView previewView
Preview vertex view.


previewEnabled

protected transient boolean previewEnabled
Specifies if the cellview should be previewed. Default is true.

Constructor Detail

JGraphpadVertexTool

public JGraphpadVertexTool(Object prototype)
Constructs a new vertex tool for the specified prototype using NAME_VERTEXTOOL.

Parameters:
prototype - The prototype cell to create new vertices with.

JGraphpadVertexTool

public JGraphpadVertexTool(String name,
                           Object prototype)
Constructs a new vertex tool for the specified name and prototype.

Parameters:
name - The name of the tool to be created.
prototype - The prototype cell to create new vertices with.
Method Detail

getPrototype

public Object getPrototype()
Returns the prototype used to create new cells.

Returns:
Returns the prototype.

setPrototype

public void setPrototype(Object prototype)
Sets the prototype to be used to create new cells.

Parameters:
prototype - The prototype to set.

getSingleClickSize

public Dimension getSingleClickSize()
Returns the single click size which should be used to insert cells with a single click.

Returns:
Returns the singleClickSize.

setSingleClickSize

public void setSingleClickSize(Dimension singleClickSize)
Sets the size of cells to be inserted with a single click.

Parameters:
singleClickSize - The singleClickSize to set.

getThreshold

public int getThreshold()
Returns the threshold for a drag to count as an insert.

Returns:
Returns the threshold.

setThreshold

public void setThreshold(int threshold)
Sets the threshold for a drag to count as an insert.

Parameters:
threshold - The threshold to set.

isPreviewEnabled

public boolean isPreviewEnabled()
Sets if the cellview should be previewed.

Returns:
Returns the previewEnabled.

setPreviewEnabled

public void setPreviewEnabled(boolean previewEnabled)
Returns if the cellview should be previewed.

Parameters:
previewEnabled - The previewEnabled to set.

mousePressed

public void mousePressed(MouseEvent event)
Extends the parent's implementation to create a clone of the pototype using createCell(GraphModel) and a new view using the layout cache's factory. The view is then configured and stored in previewView.

Parameters:
event - The object that describes the event.

createCell

protected Object createCell(org.jgraph.graph.GraphModel model)
Returns a deep clone of the cell prototype.

Parameters:
model - The model to use for cloning the prototype.
Returns:
Returns a clone of prototype.

processMouseDraggedEvent

protected void processMouseDraggedEvent(MouseEvent event)
Overrides the parent's implementation to update the preview bounds to the current BasicMarqueeHandler.marqueeBounds.

Parameters:
event - The object that describes the event.

isConstrainedSizeEvent

protected boolean isConstrainedSizeEvent(MouseEvent event)
Hook for subclassers to define the key assignments for constrained inserts. This implementation redirects to BasicGraphUI.isConstrainedMoveEvent(MouseEvent).

Parameters:
event - The object that describes the event.

mouseReleased

public void mouseReleased(MouseEvent event)
Overrides the parent's implementation to check if the event triggers an insert (checks threshold & singleClickSize) and inserts the cell stored in previewView using #execute(GraphLayoutCache, Object).

Parameters:
event - The object that describes the event.

execute

protected void execute(org.jgraph.JGraph graph,
                       Object cell)
Provides a hook for subclassers to insert the specified cell into cache. This implementation passes the cell to the GraphLayoutCache.insert(Object).

Parameters:
cell - The cell to be inserted into cache.

overlay

public void overlay(org.jgraph.JGraph graph,
                    Graphics g,
                    boolean clear)
Extends the parent's implementation to draw the previewView.

Parameters:
graph - The graph to paint in.
g - The graphics to use for paiting.
clear - Wether to clear the display.

JGraphpad Pro
v6.0.5.0


Copyright (C) 2005 JGraph.com. All rights reserved.