org.graffiti.plugin.tool
Class AbstractTool

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by javax.swing.event.MouseInputAdapter
          extended by org.graffiti.plugin.tool.AbstractTool
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener, MouseInputListener, Tool, SelectionListener, SessionListener
Direct Known Subclasses:
AbstractUndoableTool

public abstract class AbstractTool
extends MouseInputAdapter
implements Tool, SessionListener, SelectionListener

Provides an abstract implementation of the Tool interface.

See Also:
Tool, MouseInputAdapter

Field Summary
protected  Graph graph
          The graph this tool works on.
protected  boolean isActive
          Flag set by activate and deactivate.
protected  Preferences prefs
          The preferences of this tool.
protected  Selection selection
          The current selection that this tool should work on / with.
protected  EditorSession session
          The current session that this tool should work on / with.
protected  AffineTransform zoom
          DOCUMENT ME!
 
Constructor Summary
AbstractTool()
           
 
Method Summary
 void activate()
          Classes that overwrite this method should call super.active first.
 void deactivate()
          Classes that overwrite this method should call super.deactive first.
 void displayAsMarked(EdgeComponentInterface comp)
          Show an edge component as marked.
 void displayAsMarked(GraphElementComponent comp)
          Show a graph element component as marked.
 void displayAsMarked(List<GraphElementComponent> comps)
          Display a list of graph element components
 void displayAsMarked(NodeComponentInterface comp)
          Show a node component as marked.
protected  List<GraphElementComponent> getAllMarkedComps()
          Returns a list of all GraphElementComponents contained in this selection.
protected  List<GraphElementComponent> getCompsForElem(GraphElement ge)
          Used method getComponentForElement from the views of the current session to get the GraphElementComponents for the provided GraphElement.
protected  List<GraphElementComponent> getCompsForElems(List<? extends GraphElement> elems)
          Used method getComponentForElement from the views of the current session to convert the provided list of GraphElement elements to a list of GraphElementComponents.
 void highlight(Component comp)
          Display a component in a special way distinguished from the way displayAsMarked does it.
 boolean isActive()
          Returns true if this tool has been activated and since then not been deactivated.
 boolean isSelectionListener()
          States whether this class wants to be registered as a SelectionListener.
 boolean isSessionListener()
          States whether this class wants to be registered as a SessionListener.
 boolean isViewListener()
          States whether this class wants to be registered as a ViewListener, i.e.
 void selectionChanged(SelectionEvent e)
          Called when the selection has changed.
 void selectionListChanged(SelectionEvent e)
          Is called, if a named selection is added or removed.
 void sessionChanged(Session s)
          This method is called when the session changes.
 void setGraph(Graph graph)
          Sets the graph of this tool.
 void setPrefs(Preferences p)
          Sets the preferences of this tool.
 void unDisplayAsMarked(EdgeComponentInterface comp)
          Remove anything that specifies an edge component as being marked.
 void unDisplayAsMarked(GraphElementComponent comp)
          Remove anything that specifies a graph element component as being marked.
 void unDisplayAsMarked(List<GraphElementComponent> comps)
          Call unDisplayAsMarked(GraphElementComponent geComp) on every element of the provided list.
 void unDisplayAsMarked(NodeComponentInterface comp)
          Remove anything that specifies a node component as being marked.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
 
Methods inherited from interface java.awt.event.MouseMotionListener
mouseDragged, mouseMoved
 
Methods inherited from interface org.graffiti.session.SessionListener
sessionDataChanged
 

Field Detail

zoom

protected AffineTransform zoom
DOCUMENT ME!


session

protected EditorSession session
The current session that this tool should work on / with.


graph

protected Graph graph
The graph this tool works on.


prefs

protected Preferences prefs
The preferences of this tool.


selection

protected Selection selection
The current selection that this tool should work on / with.


isActive

protected boolean isActive
Flag set by activate and deactivate.

Constructor Detail

AbstractTool

public AbstractTool()
Method Detail

isActive

public boolean isActive()
Returns true if this tool has been activated and since then not been deactivated.

Specified by:
isActive in interface Tool
Returns:
DOCUMENT ME!

setGraph

public void setGraph(Graph graph)
Sets the graph of this tool.

Specified by:
setGraph in interface Tool
Parameters:
graph - the graph of this tool.

setPrefs

public void setPrefs(Preferences p)
Sets the preferences of this tool.

Specified by:
setPrefs in interface Tool
Parameters:
p - the preferences of this tool.

isSelectionListener

public boolean isSelectionListener()
States whether this class wants to be registered as a SelectionListener.

Specified by:
isSelectionListener in interface Tool
Returns:
DOCUMENT ME!

isSessionListener

public boolean isSessionListener()
States whether this class wants to be registered as a SessionListener.

Specified by:
isSessionListener in interface Tool
Returns:
DOCUMENT ME!

isViewListener

public boolean isViewListener()
States whether this class wants to be registered as a ViewListener, i.e. if it wants to get informed when another view in the same session becomes active. This method is not called when another session is activated. Implement SessionListener if you are interested in session changed events.

Specified by:
isViewListener in interface Tool
Returns:
DOCUMENT ME!

activate

public void activate()
Classes that overwrite this method should call super.active first.

Specified by:
activate in interface Tool
See Also:
Tool.activate()

deactivate

public void deactivate()
Classes that overwrite this method should call super.deactive first.

Specified by:
deactivate in interface Tool
See Also:
Tool.deactivate()

displayAsMarked

public void displayAsMarked(GraphElementComponent comp)
Show a graph element component as marked.

Parameters:
comp - DOCUMENT ME!

displayAsMarked

public void displayAsMarked(NodeComponentInterface comp)
Show a node component as marked.

Parameters:
comp - DOCUMENT ME!

displayAsMarked

public void displayAsMarked(EdgeComponentInterface comp)
Show an edge component as marked.

Parameters:
comp - DOCUMENT ME!

displayAsMarked

public void displayAsMarked(List<GraphElementComponent> comps)
Display a list of graph element components

Parameters:
comps - DOCUMENT ME!

highlight

public void highlight(Component comp)
Display a component in a special way distinguished from the way displayAsMarked does it. Used for temporarily highlighting a component, e.g. for a mouseMoved action.

Parameters:
comp - DOCUMENT ME!

selectionChanged

public void selectionChanged(SelectionEvent e)
Called when the selection has changed.

Specified by:
selectionChanged in interface SelectionListener
Parameters:
e - DOCUMENT ME!

selectionListChanged

public void selectionListChanged(SelectionEvent e)
Description copied from interface: SelectionListener
Is called, if a named selection is added or removed.

Specified by:
selectionListChanged in interface SelectionListener
See Also:
SelectionListener.selectionListChanged(org.graffiti.selection.SelectionEvent)

sessionChanged

public void sessionChanged(Session s)
Description copied from interface: SessionListener
This method is called when the session changes.

Specified by:
sessionChanged in interface SessionListener
Parameters:
s - the new Session.
See Also:
SessionListener.sessionChanged(Session)

unDisplayAsMarked

public void unDisplayAsMarked(GraphElementComponent comp)
Remove anything that specifies a graph element component as being marked.

Parameters:
comp - DOCUMENT ME!

unDisplayAsMarked

public void unDisplayAsMarked(NodeComponentInterface comp)
Remove anything that specifies a node component as being marked.

Parameters:
comp - DOCUMENT ME!

unDisplayAsMarked

public void unDisplayAsMarked(EdgeComponentInterface comp)
Remove anything that specifies an edge component as being marked.

Parameters:
comp - DOCUMENT ME!

unDisplayAsMarked

public void unDisplayAsMarked(List<GraphElementComponent> comps)
Call unDisplayAsMarked(GraphElementComponent geComp) on every element of the provided list.

Parameters:
comps - DOCUMENT ME!

getAllMarkedComps

protected List<GraphElementComponent> getAllMarkedComps()
Returns a list of all GraphElementComponents contained in this selection.

Returns:
DOCUMENT ME!

getCompsForElem

protected List<GraphElementComponent> getCompsForElem(GraphElement ge)
Used method getComponentForElement from the views of the current session to get the GraphElementComponents for the provided GraphElement.

Parameters:
ge - DOCUMENT ME!
Returns:
DOCUMENT ME!

getCompsForElems

protected List<GraphElementComponent> getCompsForElems(List<? extends GraphElement> elems)
Used method getComponentForElement from the views of the current session to convert the provided list of GraphElement elements to a list of GraphElementComponents.

Parameters:
elems - DOCUMENT ME!
Returns:
DOCUMENT ME!


Generated at 2008-10-16 01:31:27 PM GMT+01:00