pl.edu.agh.cast.model.visual.backward
Class Node

java.lang.Object
  extended by pl.edu.agh.cast.model.visual.backward.ModelElement
      extended by pl.edu.agh.cast.model.visual.backward.Node
All Implemented Interfaces:
PropertyChangeListener, Serializable, Cloneable, EventListener, IPropertyChangeProvider, AttributeValueContainer, IMoveable

public class Node
extends ModelElement
implements Cloneable, IMoveable

Class representing nodes of IDiagram.

Author:
AGH CAST Team
See Also:
Serialized Form

Field Summary
protected  List<ConnectionGroup> connectionGroups
          List of ConnectionGroups adjacent to the node.
static String CONNECTIONS
          Name of the Connections changed event.
static String DEFAULT_NODE_TYPE
          Default node type.
protected  org.eclipse.draw2d.geometry.Dimension dimensions
          Dimensions of the node.
protected  String imageId
          Node's image identifier - one from Images.
protected  org.eclipse.draw2d.geometry.Point location
          Location of the node.
static String LOCATION
          Name of the Location changed event.
static String SELECTED
          Name of the Selected event.
static String SELECTED_PRIMARY
          Name of the Selected primary event.
 
Fields inherited from class pl.edu.agh.cast.model.visual.backward.ModelElement
ATTRIBUTE_CHANGE, attributeValues
 
Constructor Summary
  Node(String id, boolean isMainNode, NodeAttributeManager attributeManager)
          Creates new Node instance.
protected Node(String id, boolean isMainNode, NodeAttributeManager attributeManager, org.eclipse.draw2d.geometry.Point location)
          Creates new Node instance in specified location.
 
Method Summary
 void addConnectionGroup(ConnectionGroup connectionGroup)
          Adds adjacent ConnectionGroup to this node.
 void copyTo(Node that)
          Copies all fields of this Node instance to that instance.
 boolean equals(Object obj)
          Two nodes are equal if their getId()s are equal.
 AttributeManager getAttributeManager()
          Returns attribute manager for this container.
 List<ConnectionGroup> getConnectionGroups()
          Returns the list of all ConnectionGroups adjacent to this node.
 org.eclipse.draw2d.geometry.Dimension getDimensions()
          Returns the dimension of this node.
 String getId()
          Returns the Id of this node.
 String getImageId()
          Returns the Id of an image that is used to display this node.
 String getLabel()
          Returns a label, composed of values of all ValueType.String attributes that have Attribute.isShowAsLabel() set.
 org.eclipse.draw2d.geometry.Point getLocation()
          Returns current location of movable element.
 int getTotalConnectionsCount()
          Returns the number of Connections this node is source or target for.
 int getTotalSourceConnectionsCount()
          Returns the number of Connections this node is source for.
 int getTotalTargetConnectionsCount()
          Returns the number of Connections this node is target for.
 String getType()
          Returns the type of this node.
 int hashCode()
          
 boolean isConnected(Node node)
          Checks if this node is directly connected to given node.
 boolean isMainNode()
          Returns main flag for this node.
static boolean isSuppressLocationChangeEvents()
           
protected  Object readResolve()
          Inits transient fields during deserialization.
 boolean removeConnectionGroup(ConnectionGroup connectionGroup)
          Removes adjacent ConnectionGroup to this node.
 void select(boolean primary)
          Selects this node.
 void setDimensions(org.eclipse.draw2d.geometry.Dimension dimensions)
          Sets dimensions of Node.
 void setImageId(String id)
           
 void setLocation(org.eclipse.draw2d.geometry.Point newLocation)
          Sets new location of movable element.
static void setSuppressLocationChangeEvents(boolean suppressLocationChangeEvents)
           
 void setType(String type)
          Sets the type of this node.
 String toString()
          
 
Methods inherited from class pl.edu.agh.cast.model.visual.backward.ModelElement
addPropertyChangeListener, bindToAttributeManager, copyAttributes, copyAttributeValues, firePropertyChange, getAllValues, getAttributeValue, getMid, isAttributeEditable, isAttributeSettable, isSaved, propertyChange, removePropertyChangeListener, removePropertyValue, setAttributeValue, setAttributeValue, setMid, setSaved
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCATION

public static final String LOCATION
Name of the Location changed event.

See Also:
Constant Field Values

CONNECTIONS

public static final String CONNECTIONS
Name of the Connections changed event.

See Also:
Constant Field Values

SELECTED

public static final String SELECTED
Name of the Selected event.

See Also:
Constant Field Values

SELECTED_PRIMARY

public static final String SELECTED_PRIMARY
Name of the Selected primary event.

See Also:
Constant Field Values

DEFAULT_NODE_TYPE

public static final String DEFAULT_NODE_TYPE
Default node type.

See Also:
Constant Field Values

location

protected org.eclipse.draw2d.geometry.Point location
Location of the node.


dimensions

protected org.eclipse.draw2d.geometry.Dimension dimensions
Dimensions of the node.


imageId

@XStreamAsAttribute
protected String imageId
Node's image identifier - one from Images.


connectionGroups

protected List<ConnectionGroup> connectionGroups
List of ConnectionGroups adjacent to the node.

Constructor Detail

Node

public Node(String id,
            boolean isMainNode,
            NodeAttributeManager attributeManager)
Creates new Node instance.

Parameters:
id - id of the node; non-null
isMainNode - whether the node is a main node or not. Main nodes are highlighted on diagrams.
attributeManager - AttributeManager for the node
Throws:
IllegalArgumentException - if supplied node id is null

Node

protected Node(String id,
               boolean isMainNode,
               NodeAttributeManager attributeManager,
               org.eclipse.draw2d.geometry.Point location)
Creates new Node instance in specified location.

Parameters:
id - id of the node
isMainNode - whether the node is a main node or not. Main nodes are highlighted on diagrams.
attributeManager - AttributeManager for the node
location - the location of the node
Method Detail

readResolve

protected Object readResolve()
Inits transient fields during deserialization.

Overrides:
readResolve in class ModelElement
See Also:
ModelElement.readResolve()

addConnectionGroup

public void addConnectionGroup(ConnectionGroup connectionGroup)
Adds adjacent ConnectionGroup to this node.

Parameters:
connectionGroup - ConnectionGroup to add

removeConnectionGroup

public boolean removeConnectionGroup(ConnectionGroup connectionGroup)
Removes adjacent ConnectionGroup to this node.

Parameters:
connectionGroup - ConnectionGroup to remove
Returns:
status of the operation (see List.remove(Object) for details)

getConnectionGroups

public List<ConnectionGroup> getConnectionGroups()
Returns the list of all ConnectionGroups adjacent to this node.

Returns:
list of all adjacent ConnectionGroups

getId

public String getId()
Returns the Id of this node.

Returns:
Id of this node

getLabel

public String getLabel()
Returns a label, composed of values of all ValueType.String attributes that have Attribute.isShowAsLabel() set. Returns label of movable element.

Specified by:
getLabel in interface IMoveable
Returns:
element label
See Also:
IMoveable.getLabel()

isMainNode

public boolean isMainNode()
Returns main flag for this node.

Returns:
main node flag

setType

public void setType(String type)
Sets the type of this node.

Parameters:
type - type of the node

getType

public String getType()
Returns the type of this node.

Returns:
type of this node

getLocation

public org.eclipse.draw2d.geometry.Point getLocation()
Returns current location of movable element.

Specified by:
getLocation in interface IMoveable
Returns:
current element location
See Also:
IMoveable.getLocation()

setLocation

public void setLocation(org.eclipse.draw2d.geometry.Point newLocation)
Sets new location of movable element.

Specified by:
setLocation in interface IMoveable
Parameters:
newLocation - new location point
See Also:
IMoveable.setLocation(org.eclipse.draw2d.geometry.Point)

getDimensions

public org.eclipse.draw2d.geometry.Dimension getDimensions()
Returns the dimension of this node.

Returns:
dimension of this node

setDimensions

public void setDimensions(org.eclipse.draw2d.geometry.Dimension dimensions)
Sets dimensions of Node. SHOULD ONLY be called once, after corresponding figure's dimensions are calculated.

Parameters:
dimensions - new dimensions of this node

copyTo

public void copyTo(Node that)
Copies all fields of this Node instance to that instance.

Parameters:
that - instance of Node to copy this instance to

getImageId

public String getImageId()
Returns the Id of an image that is used to display this node.

Returns:
Id of this node's image

setImageId

public void setImageId(String id)

getTotalTargetConnectionsCount

public int getTotalTargetConnectionsCount()
Returns the number of Connections this node is target for.

Returns:
number of Connections this node is target for

getTotalSourceConnectionsCount

public int getTotalSourceConnectionsCount()
Returns the number of Connections this node is source for.

Returns:
number of Connections this node is source for

getTotalConnectionsCount

public int getTotalConnectionsCount()
Returns the number of Connections this node is source or target for.

Returns:
number of Connections this node is source or target for

isConnected

public boolean isConnected(Node node)
Checks if this node is directly connected to given node.

Parameters:
node - another node to check connection for
Returns:
true if there is a direct Connection between this node and given node

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

equals

public boolean equals(Object obj)
Two nodes are equal if their getId()s are equal.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

select

public void select(boolean primary)
Selects this node.

Parameters:
primary - whether the selection is primary

getAttributeManager

public AttributeManager getAttributeManager()
Returns attribute manager for this container.

Specified by:
getAttributeManager in interface AttributeValueContainer
Specified by:
getAttributeManager in class ModelElement
Returns:
attribute manager for this container
See Also:
ModelElement.getAttributeManager()

setSuppressLocationChangeEvents

public static void setSuppressLocationChangeEvents(boolean suppressLocationChangeEvents)

isSuppressLocationChangeEvents

public static boolean isSuppressLocationChangeEvents()


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.