unbbayes.prs
Class Node

java.lang.Object
  extended by unbbayes.prs.Node
All Implemented Interfaces:
Serializable, Comparable<Node>, INode
Direct Known Subclasses:
TreeVariable, UtilityNode

public abstract class Node
extends Object
implements Serializable, Comparable<Node>, INode

A class representing a generic node containing graphical/visual information.

Version:
04/18/2009
Author:
Michael, Rommel Carvalho (rommel.caralho@gmail.com), Shou Matsumoto Refactor: interface extraction -> INode
See Also:
Serialized Form

Nested Class Summary
 class Node.NodeNameChangedEvent
          NAME CHANGE LISTENER
static interface Node.NodeNameChangedListener
           
 class Node.SetList<E>
          This is just an ArrayList which does not allow duplicate elements
 
Field Summary
protected  Color backColor
           
static int CONTINUOUS_NODE_TYPE
           
static int DECISION_NODE_TYPE
           
static Point DEFAULT_SIZE
           
static int DESCRIPTION_TYPE
           
static String DISPLAY_MODE_BAR
           
static String DISPLAY_MODE_ELLIPSE
           
static int EXPLANATION_TYPE
           
 int[] infoestados
           
protected  String label
           
protected  double[] mean
          Holds the mean of the values for each class if this is a numeric attribute node
protected  String name
           
protected  List<Node.NodeNameChangedListener> nodeNameChangedListenerList
           
protected  ArrayList<Node> parents
           
protected  SerializablePoint2D position
           
static int PROBABILISTIC_NODE_TYPE
           
protected  SerializablePoint2D size
           
protected  boolean sizeIsVariable
           
protected  SerializablePoint2D sizeVariable
           
protected  double[] standardDeviation
          Holds the standard deviation of the values for each class if this is a numeric attribute node.
protected  List<String> states
           
static int UTILITY_NODE_TYPE
           
 
Constructor Summary
Node()
          Builds a new node and makes the expected initializations.
 
Method Summary
 void addChild(Node child)
           
 void addChildNode(INode child)
          Adds a child to this node
 void addExplanationPhrase(ExplanationPhrase explanationPhrase)
           
 void addNodeNameChangedListener(Node.NodeNameChangedListener listener)
           
 void addParent(Node parent)
           
 void addParentNode(INode parent)
          Add a parent to this node
 void appendState(String state)
          Inserts a state with the specified name at the end of the list.
 void atualizatamanhoinfoestados()
          Used within dalgo2
 void clearAdjacents()
          Clears the list of adjacent nodes.
 int compareTo(Node arg0)
           
 boolean equals(Object obj)
           
 List<INode> getAdjacentNodes()
          Obtains a list of adjacent nodes.
 ArrayList<Node> getAdjacents()
          Obtains a list of adjacents.
 List<INode> getChildNodes()
          Obtains a list of children.
 ArrayList<Node> getChildren()
          Obtains a list of children.
 Color getColor()
           
static int getDefaultHeight()
          Get the node's height.
static Point getDefaultSize()
           
static int getDefaultWidth()
          Get the node's width.
 String getDescription()
          Obtains the name of this node.
 String getDisplayMode()
           
 String getExplanationDescription()
          Obtains the description of the explanation of the node.
 ExplanationPhrase getExplanationPhrase(String node)
           
 int getHeight()
          Get the node's height.
 int getInformationType()
          Returns the type of information of this node.
 String getLabel()
          Return the node's label (text of the node).
 double[] getMean()
          Get the mean of the values if this is a numeric attribute node.
 String getName()
          Returns the node's literal symbol.
 List<INode> getParentNodes()
          Obtains a list of parents.
 ArrayList<Node> getParents()
          Obtains a list of parents.
 ArrayMap<String,ExplanationPhrase> getPhrasesMap()
          Obtains the ArrayMap with the phrases.
 Point2D.Double getPosition()
           
 Point2D.Double getSize()
          Returns the node's size (x,y) where x = width and y = height.
 double[] getStandardDeviation()
          Get the mean of the values if this is a numeric attribute node.
 String getStateAt(int index)
          Returns the state of the position given by index
 int getStatesSize()
          It returns the node's quantity of states.
 int getWidth()
          Get the node's width.
 boolean hasState(String state)
          Verifies if the node has a given state.
 boolean isChildOf(Node parent)
           
 boolean isParentOf(Node child)
           
 boolean isPointInDrawableArea(int x, int y)
           
 boolean isSelected()
           
 void makeAdjacents()
          Builds the list of adjacent nodes.
protected  void nameChanged(Node.NodeNameChangedEvent event)
           
 void removeChild(Node child)
           
 void removeChildNode(INode child)
          Removes a child from this node
 void removeLastState()
          Deletes the node's last inserted state (i.e the last element inside the list of states).
 void removeNodeNameChangedListener(Node.NodeNameChangedListener listener)
           
 void removeParent(Node parent)
           
 void removeParentNode(INode parent)
          Removes a parent from this node
 void removeStateAt(int index)
          Used within dalgo2.
 void setAdjacents(ArrayList<Node> adjacents)
          Sets the adjacents.
 void setChildNodes(List<INode> children)
          Sets a new list of children.
 void setChildren(ArrayList<Node> children)
          Sets a new list of children.
 void setColor(Color c)
           
 void setDescription(String texto)
          Changes node's description.
 void setDisplayMode(String s)
           
 void setExplanationDescription(String text)
          Modifica a descriÔøΩÔøΩo da explanaÔøΩÔøΩo do nÔøΩ.
 void setInformationType(int informationType)
          Modify the node's type of information.
 void setLabel(String label)
          Set the node's label (text of the node).
 void setMean(double[] mean)
          Set the mean of the values if this is a numeric attribute node.
 void setName(String name)
          Set the node's name.
 void setParentNodes(List<INode> parents)
          Sets a new list of parents.
 void setParents(ArrayList<Node> parents)
          Sets a new list of parents.
 ArrayMap<String,ExplanationPhrase> setPhrasesMap(ArrayMap<String,ExplanationPhrase> phrasesMap)
          Modifies the ArrayMap with the phrases
 void setPosition(double x, double y)
           
 void setSelected(boolean b)
           
 void setSize(double width, double height)
          Set the node's size.
 void setSizeIsVariable(boolean is)
           
 void setSizeVariable(double width, double height)
           
 void setStandardDeviation(double[] standardDeviation)
          Set the mean of the values if this is a numeric attribute node.
 void setStateAt(String state, int index)
          Replaces a state at given position to the specified position.
 void setStates(List<String> states)
          Sets the states.
 String toString()
          Prints a description of the node using "description (name)" format (without the quotes).
 String updateLabel()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface unbbayes.prs.INode
getType
 

Field Detail

name

protected String name

label

protected String label

DEFAULT_SIZE

public static Point DEFAULT_SIZE

position

protected SerializablePoint2D position

backColor

protected Color backColor

size

protected SerializablePoint2D size

sizeVariable

protected SerializablePoint2D sizeVariable

sizeIsVariable

protected boolean sizeIsVariable

parents

protected ArrayList<Node> parents

states

protected List<String> states

infoestados

public int[] infoestados

DISPLAY_MODE_ELLIPSE

public static final String DISPLAY_MODE_ELLIPSE
See Also:
Constant Field Values

DISPLAY_MODE_BAR

public static final String DISPLAY_MODE_BAR
See Also:
Constant Field Values

PROBABILISTIC_NODE_TYPE

public static final int PROBABILISTIC_NODE_TYPE
See Also:
Constant Field Values

UTILITY_NODE_TYPE

public static final int UTILITY_NODE_TYPE
See Also:
Constant Field Values

DECISION_NODE_TYPE

public static final int DECISION_NODE_TYPE
See Also:
Constant Field Values

DESCRIPTION_TYPE

public static final int DESCRIPTION_TYPE
See Also:
Constant Field Values

EXPLANATION_TYPE

public static final int EXPLANATION_TYPE
See Also:
Constant Field Values

CONTINUOUS_NODE_TYPE

public static final int CONTINUOUS_NODE_TYPE
See Also:
Constant Field Values

mean

protected double[] mean
Holds the mean of the values for each class if this is a numeric attribute node


standardDeviation

protected double[] standardDeviation
Holds the standard deviation of the values for each class if this is a numeric attribute node.


nodeNameChangedListenerList

protected List<Node.NodeNameChangedListener> nodeNameChangedListenerList
Constructor Detail

Node

public Node()
Builds a new node and makes the expected initializations.

Method Detail

getDefaultSize

public static Point getDefaultSize()

getInformationType

public int getInformationType()
Returns the type of information of this node.

Returns:
Type of the information.

setInformationType

public void setInformationType(int informationType)
Modify the node's type of information. The types can be: DESCRIPTION_TYPE: for description nodes. EXPLANATION_TYPE: for explanation nodes.

Parameters:
informationType - type of information
Throws:
Exception - if the type of information is invalid

addExplanationPhrase

public void addExplanationPhrase(ExplanationPhrase explanationPhrase)

getExplanationPhrase

public ExplanationPhrase getExplanationPhrase(String node)
                                       throws Exception
Throws:
Exception

setDescription

public void setDescription(String texto)
Changes node's description.

Specified by:
setDescription in interface INode
Parameters:
texto - node's description.

setName

public void setName(String name)
Set the node's name. It also causes the nodeNameChanged event to be fired.

Specified by:
setName in interface INode
Parameters:
name - Node's name.

setLabel

public void setLabel(String label)
Set the node's label (text of the node).

Parameters:
label - Node's label.

getLabel

public String getLabel()
Return the node's label (text of the node).


updateLabel

public String updateLabel()

setChildren

public void setChildren(ArrayList<Node> children)
Sets a new list of children.

Parameters:
children - List of nodes representing the children.

setParents

public void setParents(ArrayList<Node> parents)
Sets a new list of parents.

Parameters:
parents - List of nodes representing the parents.

addChild

public void addChild(Node child)
              throws InvalidParentException
Throws:
InvalidParentException

removeChild

public void removeChild(Node child)

addParent

public void addParent(Node parent)
               throws InvalidParentException
Throws:
InvalidParentException

removeParent

public void removeParent(Node parent)

isParentOf

public boolean isParentOf(Node child)

isChildOf

public boolean isChildOf(Node parent)

setExplanationDescription

public void setExplanationDescription(String text)
Modifica a descriÔøΩÔøΩo da explanaÔøΩÔøΩo do nÔøΩ. Modifies the description of the explanation of the node.

Parameters:
texto - A text representing the node's explanation's description. descriÔøΩÔøΩo da explanaÔøΩÔøΩo do nÔøΩ.

setPhrasesMap

public ArrayMap<String,ExplanationPhrase> setPhrasesMap(ArrayMap<String,ExplanationPhrase> phrasesMap)
Modifies the ArrayMap with the phrases

Parameters:
phrasesMap - a new ArrayMap to be set
Returns:
the old phrasesMap.

getDescription

public String getDescription()
Obtains the name of this node.

Specified by:
getDescription in interface INode
Returns:
node's description.

getAdjacents

public ArrayList<Node> getAdjacents()
Obtains a list of adjacents.

Returns:
reference for this node's adjacents.

getName

public String getName()
Returns the node's literal symbol.

Specified by:
getName in interface INode
Returns:
node's literal abbreviation.

getChildren

public final ArrayList<Node> getChildren()
Obtains a list of children.

Returns:
list of children.

getParents

public final ArrayList<Node> getParents()
Obtains a list of parents.

Returns:
list of parents.

getExplanationDescription

public String getExplanationDescription()
Obtains the description of the explanation of the node.

Returns:
description of the explanation of the node

getPhrasesMap

public ArrayMap<String,ExplanationPhrase> getPhrasesMap()
Obtains the ArrayMap with the phrases.

Returns:
ArrayMap with the phrases.

atualizatamanhoinfoestados

public void atualizatamanhoinfoestados()
Used within dalgo2


hasState

public boolean hasState(String state)
Verifies if the node has a given state.

Parameters:
state - The state name to look for.
Returns:
true if the node has the given state, false otherwise.

appendState

public void appendState(String state)
Inserts a state with the specified name at the end of the list.

Specified by:
appendState in interface INode
Parameters:
state - Name of the state to be added.

removeLastState

public void removeLastState()
Deletes the node's last inserted state (i.e the last element inside the list of states).

Specified by:
removeLastState in interface INode

removeStateAt

public void removeStateAt(int index)
Used within dalgo2. It should not be used with nodes having potential table's informations.

Specified by:
removeStateAt in interface INode

setStateAt

public void setStateAt(String state,
                       int index)
Replaces a state at given position to the specified position.

Specified by:
setStateAt in interface INode
Parameters:
state - Name of the new state.
index - Position of the state being substituted. Starts with 0.

getStatesSize

public final int getStatesSize()
It returns the node's quantity of states.

Specified by:
getStatesSize in interface INode
Returns:
How many states the node has.

getStateAt

public final String getStateAt(int index)
Returns the state of the position given by index

Specified by:
getStateAt in interface INode
Parameters:
index - position of the state to be read.
Returns:
Name of the state at index

makeAdjacents

public void makeAdjacents()
Builds the list of adjacent nodes. (the parents and children of this node)


clearAdjacents

public void clearAdjacents()
Clears the list of adjacent nodes.


setDisplayMode

public void setDisplayMode(String s)

getDisplayMode

public String getDisplayMode()

setAdjacents

public void setAdjacents(ArrayList<Node> adjacents)
Sets the adjacents.

Parameters:
adjacents - The adjacents to set

setStates

public void setStates(List<String> states)
Sets the states.

Specified by:
setStates in interface INode
Parameters:
states - The states to set

toString

public String toString()
Prints a description of the node using "description (name)" format (without the quotes). It is used by the Interface's JTree when net is compiled.

Overrides:
toString in class Object
Returns:
formatted node description.

equals

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

compareTo

public int compareTo(Node arg0)
Specified by:
compareTo in interface Comparable<Node>

isPointInDrawableArea

public boolean isPointInDrawableArea(int x,
                                     int y)

isSelected

public boolean isSelected()

setSelected

public void setSelected(boolean b)

getPosition

public Point2D.Double getPosition()

setPosition

public void setPosition(double x,
                        double y)

getColor

public Color getColor()

setColor

public void setColor(Color c)

getWidth

public int getWidth()
Get the node's width.

Returns:
Node's width.

getHeight

public int getHeight()
Get the node's height.

Returns:
The node's height.

getDefaultWidth

public static int getDefaultWidth()
Get the node's width.

Returns:
Node's width.

getDefaultHeight

public static int getDefaultHeight()
Get the node's height.

Returns:
The node's height.

getSize

public Point2D.Double getSize()
Returns the node's size (x,y) where x = width and y = height.

Returns:
The node's size.

setSize

public void setSize(double width,
                    double height)
Set the node's size.

Parameters:
width - The node's width.
height - The node's height.

setSizeVariable

public void setSizeVariable(double width,
                            double height)

setSizeIsVariable

public void setSizeIsVariable(boolean is)

setMean

public void setMean(double[] mean)
Set the mean of the values if this is a numeric attribute node.

Parameters:
mean -

setStandardDeviation

public void setStandardDeviation(double[] standardDeviation)
Set the mean of the values if this is a numeric attribute node.

Parameters:
mean -

getMean

public double[] getMean()
Get the mean of the values if this is a numeric attribute node.

Parameters:
mean -

getStandardDeviation

public double[] getStandardDeviation()
Get the mean of the values if this is a numeric attribute node.

Parameters:
mean -

addNodeNameChangedListener

public void addNodeNameChangedListener(Node.NodeNameChangedListener listener)

removeNodeNameChangedListener

public void removeNodeNameChangedListener(Node.NodeNameChangedListener listener)

nameChanged

protected void nameChanged(Node.NodeNameChangedEvent event)

addChildNode

public void addChildNode(INode child)
                  throws InvalidParentException
Description copied from interface: INode
Adds a child to this node

Specified by:
addChildNode in interface INode
Throws:
InvalidParentException

addParentNode

public void addParentNode(INode parent)
                   throws InvalidParentException
Description copied from interface: INode
Add a parent to this node

Specified by:
addParentNode in interface INode
Throws:
InvalidParentException

getAdjacentNodes

public List<INode> getAdjacentNodes()
Description copied from interface: INode
Obtains a list of adjacent nodes.

Specified by:
getAdjacentNodes in interface INode
Returns:
reference for this node's adjacents.

getChildNodes

public List<INode> getChildNodes()
Description copied from interface: INode
Obtains a list of children.

Specified by:
getChildNodes in interface INode
Returns:
list of children.

getParentNodes

public List<INode> getParentNodes()
Description copied from interface: INode
Obtains a list of parents.

Specified by:
getParentNodes in interface INode
Returns:
list of parents.

removeChildNode

public void removeChildNode(INode child)
Description copied from interface: INode
Removes a child from this node

Specified by:
removeChildNode in interface INode

removeParentNode

public void removeParentNode(INode parent)
Description copied from interface: INode
Removes a parent from this node

Specified by:
removeParentNode in interface INode

setChildNodes

public void setChildNodes(List<INode> children)
Description copied from interface: INode
Sets a new list of children.

Specified by:
setChildNodes in interface INode
Parameters:
children - List of nodes representing the children.

setParentNodes

public void setParentNodes(List<INode> parents)
Description copied from interface: INode
Sets a new list of parents.

Specified by:
setParentNodes in interface INode
Parameters:
parents - List of nodes representing the parents.


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.