fdda.graphics.java2d
Class Node

java.lang.Object
  |
  +--fdda.graphics.java2d.Component
        |
        +--fdda.graphics.java2d.Node
All Implemented Interfaces:
Cloneable, Component, Node, PropertyHolder, WorkingPart

public class Node
extends Component
implements Node

Implementation of the graphical representation of nodes for Java2D. A node is drawn as a filled circle, the label inside. Not working nodes are crossed out.

Author:
Jörg Rüdenauer

Field Summary
(package private) static double RADIUS
          default radius for nodes
static Color RED_CROSS_COLOR
          color of the cross that shows not working nodes
(package private) static double REPEATER_RADIUS
          radius for repeaters
 
Fields inherited from class fdda.graphics.java2d.Component
COLOR_NORMAL, COLOR_SELECTED, dirtyShape, selected, shape, x, y
 
Fields inherited from interface fdda.graphics.Component
SEL_ALL, SEL_EQUALS, SEL_MOVABLES, SEL_NOTHING
 
Constructor Summary
Node(double x, double y)
          Default connstructor.
Node(double x, double y, boolean selected)
          Constructor
 
Method Summary
 void addProperty(Property property)
          Adds a property to the holder.
 void addPropertyListener(PropertyListener pl)
          Adds a PropertyListener (Observer pattern).
protected  void calcShape()
          Recalculates the shape.
 void changeProperty(Property property)
          Changes a property of the holder - i.e., replaces the property with the name of the parameter property with the parameter.
 Object clone()
          Clones the component
 void draw(Graphics2D graphContext)
          Draws the component, using the given graphics.
 void firePropertyChanged(Property property)
          Informs the listeners that a property has been changed.
 double getLineStartX()
          Returns the x coordinate of the point where lines should start.
 double getLineStartY()
          Returns the y coordinate of the point where lines should start.
 Node getModelNode()
          Returns the model node which is symbolized by this node.
 Color getPrimaryColor()
          Returns the main color of the node.
 Iterator getProperties()
          Returns an Iterator over the properties of the holder.
 Property getProperty(String name)
          Returns a property of the holder.
 double getRadius()
          Returns the radius of the node
 Color getSecondaryColor()
          Returns the secondary color of the node.
 boolean isMovable()
          Returns true.
 boolean isWorking()
          Returns whether the component is working.
 void move(double x, double y)
          Move the component (or its most prominent point).
 void removeProperty(Property property)
          Removes a property from the holder.
 void removePropertyListener(PropertyListener listener)
          Removes a PropertyListener (Observer pattern).
 void repaint()
          Refreshes the graphics.
 int selectableWith()
          Returns SEL_MOVABLES
 void setModelNode(Node modelNode)
          Sets the model node which is symbolized by this node.
 void setPrimaryColor(Color color)
          Sets the main color of the node.
 void setSecondaryColor(Color color)
          Sets the secondary color of the node.
 void setWorking(boolean working)
          Sets whether the component is working.
 Object visit(ComponentVisitor visitor)
          Calls visitNode according to visitor pattern
 
Methods inherited from class fdda.graphics.java2d.Component
deselect, getGraphicalSystem, getShape, getX, getY, isSelected, recalculateShape, select, setGraphicalSystem, setXY
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fdda.graphics.Component
deselect, getGraphicalSystem, getShape, getX, getY, isSelected, recalculateShape, select, setGraphicalSystem, setXY
 

Field Detail

RADIUS

static final double RADIUS
default radius for nodes

See Also:
Constant Field Values

REPEATER_RADIUS

static final double REPEATER_RADIUS
radius for repeaters

See Also:
Constant Field Values

RED_CROSS_COLOR

public static final Color RED_CROSS_COLOR
color of the cross that shows not working nodes

Constructor Detail

Node

public Node(double x,
            double y)
Default connstructor. Node is not selected.

Parameters:
x - the x coordinate
y - the y coordinate

Node

public Node(double x,
            double y,
            boolean selected)
Constructor

Parameters:
x - the x coordinate
y - the y coordinate
selected - whether the node shall be selected
Method Detail

clone

public Object clone()
Description copied from interface: Component
Clones the component

Specified by:
clone in interface Component
Overrides:
clone in class Component
Returns:
the clone

isMovable

public boolean isMovable()
Returns true.

Specified by:
isMovable in interface Component
Returns:
true, iff the user can move the component
See Also:
Component.isMovable()

move

public void move(double x,
                 double y)
Description copied from interface: Component
Move the component (or its most prominent point).

Specified by:
move in interface Component
Parameters:
x - offset for move in x direction
y - offset for move in y direction

selectableWith

public int selectableWith()
Returns SEL_MOVABLES

Specified by:
selectableWith in interface Component
Returns:
constant indicating the selection class
See Also:
Component.selectableWith()

draw

public void draw(Graphics2D graphContext)
Description copied from class: Component
Draws the component, using the given graphics. The graphics should have the same attributes (color, pen, etc.) after the call as before the call.

Specified by:
draw in class Component
Parameters:
graphContext - the graphics

repaint

public void repaint()
Description copied from interface: Node
Refreshes the graphics.

Specified by:
repaint in interface Node

getLineStartX

public double getLineStartX()
Description copied from interface: Node
Returns the x coordinate of the point where lines should start.

Specified by:
getLineStartX in interface Node
Returns:
the x coordinate of the line start point

getLineStartY

public double getLineStartY()
Description copied from interface: Node
Returns the y coordinate of the point where lines should start.

Specified by:
getLineStartY in interface Node
Returns:
the y coordinate of the line start point

getRadius

public double getRadius()
Returns the radius of the node

Returns:
the radius

visit

public Object visit(ComponentVisitor visitor)
Calls visitNode according to visitor pattern

Specified by:
visit in interface Component
Parameters:
visitor - the visitor
Returns:
specific to subclass
See Also:
Component.visit(fdda.graphics.ComponentVisitor)

setModelNode

public void setModelNode(Node modelNode)
Description copied from interface: Node
Sets the model node which is symbolized by this node.

Specified by:
setModelNode in interface Node
Parameters:
modelNode - the model node

getModelNode

public Node getModelNode()
Description copied from interface: Node
Returns the model node which is symbolized by this node.

Specified by:
getModelNode in interface Node
Returns:
the model node

getPrimaryColor

public Color getPrimaryColor()
Description copied from interface: Node
Returns the main color of the node.

Specified by:
getPrimaryColor in interface Node
Returns:
the main color.

setPrimaryColor

public void setPrimaryColor(Color color)
Description copied from interface: Node
Sets the main color of the node. May be ignored by implementations.

Specified by:
setPrimaryColor in interface Node
Parameters:
color - the main color

getSecondaryColor

public Color getSecondaryColor()
Description copied from interface: Node
Returns the secondary color of the node.

Specified by:
getSecondaryColor in interface Node
Returns:
the secondary color

setSecondaryColor

public void setSecondaryColor(Color color)
Description copied from interface: Node
Sets the secondary color of the node. May be ignored by implementations.

Specified by:
setSecondaryColor in interface Node
Parameters:
color - the secondary color.

addProperty

public void addProperty(Property property)
Description copied from interface: PropertyHolder
Adds a property to the holder. If a property with the same name already exists, it is removed.

Specified by:
addProperty in interface PropertyHolder

removeProperty

public void removeProperty(Property property)
Description copied from interface: PropertyHolder
Removes a property from the holder. The key for removal is the name of the property; if no property with that name exists, nothing happens.

Specified by:
removeProperty in interface PropertyHolder
Parameters:
property - the property to be removed, must not be null

changeProperty

public void changeProperty(Property property)
Description copied from interface: PropertyHolder
Changes a property of the holder - i.e., replaces the property with the name of the parameter property with the parameter. If no such property exists, the property is simply added to the holder; in this case, a propertyAdded event instead of a propertyChanged event is fired.

Specified by:
changeProperty in interface PropertyHolder
Parameters:
property - the new property, must not be null

getProperty

public Property getProperty(String name)
Description copied from interface: PropertyHolder
Returns a property of the holder. If no property with the specified name exists, null is returned.

Specified by:
getProperty in interface PropertyHolder
Parameters:
name - the name of the property
Returns:
the property

getProperties

public Iterator getProperties()
Description copied from interface: PropertyHolder
Returns an Iterator over the properties of the holder.

Specified by:
getProperties in interface PropertyHolder
Returns:
an Iterator over the properties

addPropertyListener

public void addPropertyListener(PropertyListener pl)
Description copied from interface: PropertyHolder
Adds a PropertyListener (Observer pattern).

Specified by:
addPropertyListener in interface PropertyHolder
Parameters:
pl - the listener to be added
See Also:
EventListenerList

removePropertyListener

public void removePropertyListener(PropertyListener listener)
Description copied from interface: PropertyHolder
Removes a PropertyListener (Observer pattern).

Specified by:
removePropertyListener in interface PropertyHolder
Parameters:
listener - the listener to be removed
See Also:
EventListenerList

firePropertyChanged

public void firePropertyChanged(Property property)
Description copied from interface: PropertyHolder
Informs the listeners that a property has been changed. Note that the property holder can't determine by himself whether a property is changed internally; therefore, the property must inform its holder of any changes. This method must only be called by implementing classes of either PropertyHolder or Property.

Specified by:
firePropertyChanged in interface PropertyHolder
Parameters:
property - the property that was changed.

isWorking

public boolean isWorking()
Description copied from interface: WorkingPart
Returns whether the component is working.

Specified by:
isWorking in interface WorkingPart
Returns:
whether the component is working

setWorking

public void setWorking(boolean working)
Description copied from interface: WorkingPart
Sets whether the component is working.

Specified by:
setWorking in interface WorkingPart
Parameters:
working - whether the component is working

calcShape

protected void calcShape()
Description copied from class: Component
Recalculates the shape. Is called by getShape if the flag dirtyShape is set. Must unset the flag after calculation.

Specified by:
calcShape in class Component


API documentation for FDDA version 0.9. Generated on 17/02/2004 14:12.