org.problets.lib.conceptmap.model
Class NodeModel

java.lang.Object
  extended by org.problets.lib.conceptmap.model.NodeModel
Direct Known Subclasses:
UserBuiltNodeModel

public class NodeModel
extends java.lang.Object

The NodeModel is the model for a node in the tree. Nodes are painted by their NodeView objects (1 per node). Connections between objects are handled through a vector of link models (with each link model having a link view for painting it).

Author:
Eric Fernandes - v1, Adrian Maries - v2

Constructor Summary
NodeModel(NodeModel inParent, java.util.Vector contents)
          Creates a node model using the parent node and the data for the rest of the tree passed in a vector of strings as arguments.
 
Method Summary
 void addLink(LinkModel linkModel)
          Adds the specified link as a child link.
 void addNode(NodeModel nodeModel)
          Adds the specified node as a child node.
 void connect2StatusProvider(StatusProvider inStatusProvider)
          Given a node (NodeModel) in ForestModel and the corresponding node (KnowledgeUnit) in student's KnowledgeModel, makes a StatusProvider reference from the NodeModel to the KnowledgeUnit.
 boolean getAreChildrenAnd()
          Indicates if this node's children are AND or OR.
 NodeModel getChild(int index)
          Returns the child at the specified position in this node's vector of children.
 LinkModel getChildLink(int index)
          Returns the link at the specified position in this node's vector of child links.
 LinkModel getChildLinkTo(java.lang.String name)
          Returns the link to the node model with the specified name.
 java.lang.String getDescription()
          Returns this node's text description (to be displayed when the mouse is over it).
 int getIndex(java.lang.String childName)
          Returns the index of the child node whose name is passed as argument.
 void getModelVector(java.util.Vector modelVector, int depth)
          Returns the vector passed as argument plus the name of this node.
 java.lang.String getName()
          Returns this node's name.
 int getNumChildren()
          Returns this node's number of children.
 NodeModel getParent()
          Returns this node's parent.
 double getPercentCompletion()
          Asks status provider to return the percent completion.
static void main(java.lang.String[] args)
           
 void print()
          Outputs this node's name to the console and recursively outputs the names of all its descendants.
 void setAreChildernAndFlag(boolean inAreChildrenAnd)
          Sets the status of the areChildrenAnd flag.
 void setParent(NodeModel inParent)
          Sets the node model passed as argument as this node's parent.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeModel

public NodeModel(NodeModel inParent,
                 java.util.Vector contents)
Creates a node model using the parent node and the data for the rest of the tree passed in a vector of strings as arguments.

Parameters:
inParent - the parent node
contents - the vector holding the data for the rest of the tree
Method Detail

getPercentCompletion

public double getPercentCompletion()
Asks status provider to return the percent completion.

Returns:
the percent completion for this node

getChild

public NodeModel getChild(int index)
Returns the child at the specified position in this node's vector of children.

Parameters:
index - an index into the vector of children
Returns:
the node model at the specified position in this node's vector of children

getChildLink

public LinkModel getChildLink(int index)
Returns the link at the specified position in this node's vector of child links.

Parameters:
index - an index into the vector of child links
Returns:
the link model at the specified position in this node's vector of child links

getParent

public NodeModel getParent()
Returns this node's parent.

Returns:
this node's parent

getName

public java.lang.String getName()
Returns this node's name.

Returns:
this node's name

getDescription

public java.lang.String getDescription()
Returns this node's text description (to be displayed when the mouse is over it).

Returns:
this node's description

getAreChildrenAnd

public boolean getAreChildrenAnd()
Indicates if this node's children are AND or OR.

Returns:
true if the children are AND, false otherwise

getNumChildren

public int getNumChildren()
Returns this node's number of children.

Returns:
this node's number of children

getIndex

public int getIndex(java.lang.String childName)
Returns the index of the child node whose name is passed as argument.

Parameters:
the - name of the child node whose index is returned
Returns:
the index of the child node whose name is passed as argument

getChildLinkTo

public LinkModel getChildLinkTo(java.lang.String name)
Returns the link to the node model with the specified name.

Parameters:
the - name of the node model connected to its parent by the specified link
Returns:
the link model to the model with the name passed as argument

getModelVector

public void getModelVector(java.util.Vector modelVector,
                           int depth)
Returns the vector passed as argument plus the name of this node.

Parameters:
modelVector - the vector with the names of the nodes which appeared before this node in the tree.
this - node's depth (level of indentation)

addNode

public void addNode(NodeModel nodeModel)
Adds the specified node as a child node.

Parameters:
nodeModel - the node model to be added to the vector of children

addLink

public void addLink(LinkModel linkModel)
Adds the specified link as a child link.

Parameters:
linkModel - the link model to be added to the vector of child links

setParent

public void setParent(NodeModel inParent)
Sets the node model passed as argument as this node's parent.

Parameters:
inParent - this node's parent

setAreChildernAndFlag

public void setAreChildernAndFlag(boolean inAreChildrenAnd)
Sets the status of the areChildrenAnd flag.

Parameters:
true - if the children are AND (as opposed to OR), false otherwise

connect2StatusProvider

public void connect2StatusProvider(StatusProvider inStatusProvider)
Given a node (NodeModel) in ForestModel and the corresponding node (KnowledgeUnit) in student's KnowledgeModel, makes a StatusProvider reference from the NodeModel to the KnowledgeUnit. Furthermore, for each child of the NodeModel, finds its corresponding KnowledgeUnit in KnowledgeModel and recursively calls this function to connect them. For this operation, KnowledgeUnit is treated as an implementor of StatusProvider interface. In other words, any tree of StatusProvider implementors can be used with conceptmaps.


print

public void print()
Outputs this node's name to the console and recursively outputs the names of all its descendants.


main

public static void main(java.lang.String[] args)