fi.paatti.research.paattiapplication.views.eventview.tools
Class NodeFactory.TreeNode

java.lang.Object
  extended by fi.paatti.research.paattiapplication.views.eventview.tools.Clickable
      extended by fi.paatti.research.paattiapplication.views.eventview.tools.NodeFactory.TreeNode
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
NodeFactory.MultiPathNode, NodeFactory.SinglePathNode
Enclosing class:
NodeFactory

public class NodeFactory.TreeNode
extends Clickable

TreeNode is the base class extended by all the nodes in an event tree. The base class contains the basic functionality for things like setting and getting the node's description, content, etc.

See Also:
Serialized Form
 

Field Summary
protected  Color baseColor
           
protected  LinkedList<NodeFactory.TreeNode> children
           
protected  LinkedList<NodeFactory.TreeNode> parents
           
 
Fields inherited from class fi.paatti.research.paattiapplication.views.eventview.tools.Clickable
height, width, x, y
 
Method Summary
 void addChild(NodeFactory.TreeNode child)
          Adds a node to this node's children list.
 void addParent(NodeFactory.TreeNode parent)
          Adds a node to this node's parents list.
 void detach()
          Removes all the connections between this node and the connected child and parent nodes.
 LinkedList<NodeFactory.TreeNode> getChildren()
          Returns the children list.
 String getContent()
          Returns the node's content.
 String getDescription()
          Returns the node's description.
 int getId()
          Returns the node's tree id.
 LinkedList<NodeFactory.TreeNode> getParents()
          Returns the parents list.
 com.vaadin.data.Property getProperty(String s)
          Returns property s using the BeanItem set in the constructor.
 int getRealId()
          Returns the node's real (db) id.
 int getType()
          Returns the node's type (db table TASKTYPE).
 int getX()
          Returns the node's x coordinate.
 int getY()
          Returns the node's y coordinate.
 void moveTo(int x, int y)
          Moves the node to the given coordinates, its center positioned in (x,y).
 void paint(Graphics g)
          Draws the node to the current graphics context.
 void removeChild(NodeFactory.TreeNode child)
          Removes a node from this node's children list, also removing this node from the given node's parents list.
 void removeParent(NodeFactory.TreeNode parent)
          Removes a node from this node's parents list.
 void setActive(boolean a)
          Sets the node's state.
 void setContent(String s)
          Sets the node's content.
 void setDescription(String s)
          Sets the node's description.
 void setRealId(int id)
          Sets the node's real (db) id.
 void setType(int i)
          Sets the node's type (db table TASKTYPE).
 void setX(int x)
          Sets the node's x coordinate.
 void setY(int y)
          Sets the node's y coordinate.
 String toString()
          Returns the node's string presentation.
 
Methods inherited from class fi.paatti.research.paattiapplication.views.eventview.tools.Clickable
contains
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parents

protected LinkedList<NodeFactory.TreeNode> parents

children

protected LinkedList<NodeFactory.TreeNode> children

baseColor

protected Color baseColor
Method Detail

getId

public int getId()
Returns the node's tree id.

Returns:
id

setRealId

public void setRealId(int id)
Sets the node's real (db) id. A node's real id is the node's db row id.

Parameters:
id - the node's db id

getRealId

public int getRealId()
Returns the node's real (db) id.

Returns:
the node's db id

getType

public int getType()
Returns the node's type (db table TASKTYPE).

Returns:
type

setType

public void setType(int i)
Sets the node's type (db table TASKTYPE).

Parameters:
i - new type

getDescription

public String getDescription()
Returns the node's description.

Returns:
description

setDescription

public void setDescription(String s)
Sets the node's description.

Parameters:
s - new description

getContent

public String getContent()
Returns the node's content.

Returns:
content

setContent

public void setContent(String s)
Sets the node's content.

Parameters:
s - new content

getProperty

public com.vaadin.data.Property getProperty(String s)
Returns property s using the BeanItem set in the constructor.

Parameters:
s - property to look for
Returns:
property found; otherwise null

setActive

public void setActive(boolean a)
Sets the node's state. State currently affects the node's border color only (true = red, false = black).

Parameters:
a - state

getX

public int getX()
Returns the node's x coordinate.

Returns:
the node's x coordinate

setX

public void setX(int x)
Sets the node's x coordinate.

Parameters:
x - the node's new x coordinate

getY

public int getY()
Returns the node's y coordinate.

Returns:
the node's y coordinate

setY

public void setY(int y)
Sets the node's y coordinate.

Parameters:
y - the node's y coordinate

addChild

public void addChild(NodeFactory.TreeNode child)
Adds a node to this node's children list. If the given node isn't null or the node hasn't been defined earlier as this node's parent or child, the node is added to the children list and this one is added to the node's parents list.

Parameters:
child - node to be added

removeChild

public void removeChild(NodeFactory.TreeNode child)
Removes a node from this node's children list, also removing this node from the given node's parents list.

Parameters:
child - node to be removed

addParent

public void addParent(NodeFactory.TreeNode parent)
Adds a node to this node's parents list.

Parameters:
parent - node to be added

removeParent

public void removeParent(NodeFactory.TreeNode parent)
Removes a node from this node's parents list.

Parameters:
parent - node to be removed

detach

public void detach()
Removes all the connections between this node and the connected child and parent nodes.


getChildren

public LinkedList<NodeFactory.TreeNode> getChildren()
Returns the children list.

Returns:
children list

getParents

public LinkedList<NodeFactory.TreeNode> getParents()
Returns the parents list.

Returns:
parents list

moveTo

public void moveTo(int x,
                   int y)
Moves the node to the given coordinates, its center positioned in (x,y).


paint

public void paint(Graphics g)
Draws the node to the current graphics context. The base of the node is a solid rectangle filled with the defined base color, framed with one pixel wide border (red if node active, black otherwise). Also, a set of connector lines are drawn between this node and its children.

Specified by:
paint in class Clickable
Parameters:
g - graphics context

toString

public String toString()
Returns the node's string presentation.

Overrides:
toString in class Object
Returns:
string presentation


Copyright © 2012. All Rights Reserved.