de.grogra.imp.edit
Class Tool

java.lang.Object
  extended by de.grogra.imp.edit.Tool
All Implemented Interfaces:
AttributeChangeListener, ChangeBoundaryListener, Disposable

public final class Tool
extends java.lang.Object
implements Disposable, AttributeChangeListener, ChangeBoundaryListener

A Tool represents a tool for interactive manipulation of objects in a 2D- or 3D-view. A tool is composed of a set of tool graphs, each represented by its root node of (a subclass of) class ToolRoot. Each tool graph is drawn as part of the 2D- or 3D-view.

A Tool operates on a single object, the tool target.

Author:
Ole Kniemeyer

Field Summary
 
Fields inherited from interface de.grogra.graph.ChangeBoundaryListener
ATTRIBUTE_PRIORITY, TOPOLOGY_PRIORITY, UPDATE_PRIORITY
 
Constructor Summary
Tool(java.lang.Object object, boolean asNode, ToolRoot[] roots)
          Creates a new Tool.
 
Method Summary
 void attributeChanged(AttributeChangeEvent e)
           
 void beginChange(GraphState gs)
           
static DisposableEventListener createToolListener(View view, UIProperty tool)
           
 void dispose()
           
 void endChange(GraphState gs)
           
 AttributeAccessor getAccessorOfObject(Attribute a)
           
 boolean getBooleanOfObject(BooleanAttribute a, boolean defaultValue)
           
 byte getByteOfObject(ByteAttribute a, byte defaultValue)
           
 char getCharOfObject(CharAttribute a, char defaultValue)
           
 double getDoubleOfObject(DoubleAttribute a, double defaultValue)
           
 float getFloatOfObject(FloatAttribute a, float defaultValue)
           
 GraphState getGraphState()
          Returns the GraphState of the workbench.
 int getIntOfObject(IntAttribute a, int defaultValue)
           
 long getLongOfObject(LongAttribute a, long defaultValue)
           
 java.lang.Object getObject()
          Returns this tool's target.
 java.lang.Object getObjectOfObject(ObjectAttribute a, java.lang.Object defaultValue)
           
 int getPriority()
           
 ToolRoot getRoot(int index)
          Returns the tool root at position index in the list of tool roots.
 short getShortOfObject(ShortAttribute a, short defaultValue)
           
 int getToolCount()
          Returns the number of tool roots.
 View getView()
          Returns the view in which this tool is displayed.
 void initialize(View view)
           
 boolean isNode()
          Determines whether the tool target is a node or an edge.
 boolean isWritable(Attribute a)
           
 void setBooleanOfObject(BooleanAttribute a, boolean value)
           
 void setByteOfObject(ByteAttribute a, byte value)
           
 void setCharOfObject(CharAttribute a, char value)
           
 void setDoubleOfObject(DoubleAttribute a, double value)
           
 void setFloatOfObject(FloatAttribute a, float value)
           
 void setIntOfObject(IntAttribute a, int value)
           
 void setLongOfObject(LongAttribute a, long value)
           
 void setObjectOfObject(ObjectAttribute a, java.lang.Object value)
           
 void setShortOfObject(ShortAttribute a, short value)
           
 void setSubfield(ObjectAttribute a, FieldChain field, int[] indices, java.lang.Object value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tool

public Tool(java.lang.Object object,
            boolean asNode,
            ToolRoot[] roots)
Creates a new Tool.

Parameters:
object - the tool target
asNode - true iff object is a node
roots - the set of tool roots
See Also:
Tool
Method Detail

attributeChanged

public void attributeChanged(AttributeChangeEvent e)
Specified by:
attributeChanged in interface AttributeChangeListener

beginChange

public void beginChange(GraphState gs)
Specified by:
beginChange in interface ChangeBoundaryListener

createToolListener

public static DisposableEventListener createToolListener(View view,
                                                         UIProperty tool)

dispose

public void dispose()
Specified by:
dispose in interface Disposable

endChange

public void endChange(GraphState gs)
Specified by:
endChange in interface ChangeBoundaryListener

getAccessorOfObject

public AttributeAccessor getAccessorOfObject(Attribute a)

getBooleanOfObject

public boolean getBooleanOfObject(BooleanAttribute a,
                                  boolean defaultValue)

getByteOfObject

public byte getByteOfObject(ByteAttribute a,
                            byte defaultValue)

getCharOfObject

public char getCharOfObject(CharAttribute a,
                            char defaultValue)

getDoubleOfObject

public double getDoubleOfObject(DoubleAttribute a,
                                double defaultValue)

getFloatOfObject

public float getFloatOfObject(FloatAttribute a,
                              float defaultValue)

getGraphState

public GraphState getGraphState()
Returns the GraphState of the workbench.

Returns:
the graph state of the workbench

getIntOfObject

public int getIntOfObject(IntAttribute a,
                          int defaultValue)

getLongOfObject

public long getLongOfObject(LongAttribute a,
                            long defaultValue)

getObject

public java.lang.Object getObject()
Returns this tool's target.

Returns:
the tool target

getObjectOfObject

public java.lang.Object getObjectOfObject(ObjectAttribute a,
                                          java.lang.Object defaultValue)

getPriority

public int getPriority()
Specified by:
getPriority in interface ChangeBoundaryListener

getRoot

public ToolRoot getRoot(int index)
Returns the tool root at position index in the list of tool roots.

Parameters:
index - the index into the list of tool roots
Returns:
the tool root number index

getShortOfObject

public short getShortOfObject(ShortAttribute a,
                              short defaultValue)

getToolCount

public int getToolCount()
Returns the number of tool roots. This number may be less than the length of the array used in the contructor of Tool, depending on the result of the initializations of each tool root.

Returns:
the number of tool roots

getView

public View getView()
Returns the view in which this tool is displayed.

Returns:
the view

initialize

public void initialize(View view)

isNode

public boolean isNode()
Determines whether the tool target is a node or an edge.

Returns:
true iff the tool target is a node

isWritable

public boolean isWritable(Attribute a)

setBooleanOfObject

public void setBooleanOfObject(BooleanAttribute a,
                               boolean value)

setByteOfObject

public void setByteOfObject(ByteAttribute a,
                            byte value)

setCharOfObject

public void setCharOfObject(CharAttribute a,
                            char value)

setDoubleOfObject

public void setDoubleOfObject(DoubleAttribute a,
                              double value)

setFloatOfObject

public void setFloatOfObject(FloatAttribute a,
                             float value)

setIntOfObject

public void setIntOfObject(IntAttribute a,
                           int value)

setLongOfObject

public void setLongOfObject(LongAttribute a,
                            long value)

setObjectOfObject

public void setObjectOfObject(ObjectAttribute a,
                              java.lang.Object value)

setShortOfObject

public void setShortOfObject(ShortAttribute a,
                             short value)

setSubfield

public void setSubfield(ObjectAttribute a,
                        FieldChain field,
                        int[] indices,
                        java.lang.Object value)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object