dasher
Class CDasherNode

java.lang.Object
  extended by dasher.CDasherNode

public class CDasherNode
extends java.lang.Object

A DasherNode represents a node in the DasherModel's tree; it is has a probability, children and one parent, and is typically drawn as a box with a letter or symbol in it.

It is capable of finding a Node at a given Screen location and of performing certain tree modifications (such as deleting its children) but otherwise mainly acts as a data structure.


Field Summary
protected  boolean m_bAlive
          Indicates whether this node is currently drawable
 SGroupInfo m_BaseGroup
          Root of the tree of groups into which this Node's children are arranged.
protected  boolean m_bHasAllChildren
          Flag indicating whether all of this node's children are present
protected  boolean m_bSeen
          Indicates whether this node's symbol has been output already
 boolean m_bShove
          Whether this Node shoves or not (ie.
protected  EColorSchemes m_ColorScheme
          Colour scheme associated with this node
protected  CContextBase m_Context
          Language model context corresponding to this node's position in the tree.
protected  int m_iColour
          Colour number if this node is using a colour scheme defined by an instance of CCustomColours
protected  long m_iHbnd
          Upper cumulative probability bound relative to our parent
protected  long m_iLbnd
          Lower cumulative probability bound relative to our parent
protected  int m_iPhase
          Phase; this is related to colour cycling from one generation to the next.
protected  CLanguageModel m_LanguageModel
          LanguageModel which was responsible for generating this node's probability
protected  java.util.ArrayList<CDasherNode> m_mChildren
          List of this node's child Nodes
 CNodeManager m_NodeManager
          NodeManager responsible for populating this Node's children.
protected  CDasherNode m_Parent
          Parent Node
 java.lang.String m_strDisplayText
          This Node's display text
protected  int m_Symbol
          Symbol number represented by this node
 int m_UserData
          Stores arbitrary information; may be extended to hold more in the future.
 
Constructor Summary
CDasherNode(CDasherNode Parent, int Symbol, int iphase, EColorSchemes ColorScheme, long ilbnd, long ihbnd, CLanguageModel lm, int Colour)
          Creates a Node and sets its describing variables.
 
Method Summary
 boolean Alive()
          Determines if this node is currently drawable.
 void Alive(boolean b)
          Sets this node's Alive flag
 int ChildCount()
          Returns the size of our child list.
 java.util.ArrayList<CDasherNode> Children()
          Gets a reference to this Node's child list.
 EColorSchemes ColorScheme()
          Gets this Node's colour scheme
 int Colour()
          Gets this Node's colour index
 CContextBase Context()
          Retrives the LM context associated with this node.
 void Delete_children()
          Clears the Children list and sets our HasAllChildren flag to false; this will leave this section of tree unrefrenced and available for garbage collection.
 void DeleteNephews(CDasherNode pChild)
          Deletes the nephews of a given child; that is to say, deletes its siblings' children.
 void DeleteNode()
          At present, does nothing; Nodes will be "deleted" by virtue of their parents cutting them loose at the appropriate time, making them available for garbage collection.
 CDasherNode Get_node_under(long iNormalization, long miY1, long miY2, long miMousex, long miMousey)
          Finds the node under a given mouse location, given our boundaries in Dasher space.
 java.util.ArrayList<CDasherNode> GetChildren()
          Gets a reference to this Node's child list.
 double GetProb(int iNormalization)
          Gets this node's probability
 boolean HasAllChildren()
          Checks whether all of this Node's children exist at present
 long Hbnd()
          Gets m_iHbnd
 boolean isSeen()
          Gets this node's Seen flag
 void Kill()
          Sets this node's Alive flag to false
 long Lbnd()
          Gets m_iLbnd
 long MostProbableChild()
          Gets the probability associated with this node's most probable child.
 boolean NodeIsParent(CDasherNode oldnode)
          Determine if a given node is this one's parent.
 void OrphanChild(CDasherNode pChild)
          Delete our children except for a given one, the delete ourself.
 CDasherNode Parent()
          Gets this node's parent.
 int Phase()
          Gets this node's colour-cycling phase
 long Range()
          Gets the difference between m_iLbnd and m_iHbnd.
 void Seen(boolean seen)
          Sets this node's Seen flag
 void SetChildren(java.util.ArrayList<CDasherNode> in)
          Sets this Node's child list.
 void SetContext(CContextBase context)
          Sets the context associated with this node.
 void SetHasAllChildren(boolean val)
          Sets the HasAllChildren flag
 void SetParent(CDasherNode NewParent)
          Attaches this Node to a given Parent.
 void SetRange(long iLower, long iUpper)
          Sets this node's probabilities.
 int Symbol()
          Gets this node's symbol
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_ColorScheme

protected EColorSchemes m_ColorScheme
Colour scheme associated with this node


m_iPhase

protected int m_iPhase
Phase; this is related to colour cycling from one generation to the next.


m_iColour

protected int m_iColour
Colour number if this node is using a colour scheme defined by an instance of CCustomColours


m_iLbnd

protected long m_iLbnd
Lower cumulative probability bound relative to our parent


m_iHbnd

protected long m_iHbnd
Upper cumulative probability bound relative to our parent


m_bAlive

protected boolean m_bAlive
Indicates whether this node is currently drawable


m_bSeen

protected boolean m_bSeen
Indicates whether this node's symbol has been output already


m_mChildren

protected java.util.ArrayList<CDasherNode> m_mChildren
List of this node's child Nodes


m_bHasAllChildren

protected boolean m_bHasAllChildren
Flag indicating whether all of this node's children are present


m_Parent

protected CDasherNode m_Parent
Parent Node


m_LanguageModel

protected CLanguageModel m_LanguageModel
LanguageModel which was responsible for generating this node's probability


m_Context

protected CContextBase m_Context
Language model context corresponding to this node's position in the tree.


m_Symbol

protected int m_Symbol
Symbol number represented by this node


m_BaseGroup

public SGroupInfo m_BaseGroup
Root of the tree of groups into which this Node's children are arranged.


m_NodeManager

public CNodeManager m_NodeManager
NodeManager responsible for populating this Node's children.


m_UserData

public int m_UserData
Stores arbitrary information; may be extended to hold more in the future.


m_strDisplayText

public java.lang.String m_strDisplayText
This Node's display text


m_bShove

public boolean m_bShove
Whether this Node shoves or not (ie. whether the symbols of its children should be displaced to the right so as not to obscure this one)

Constructor Detail

CDasherNode

public CDasherNode(CDasherNode Parent,
                   int Symbol,
                   int iphase,
                   EColorSchemes ColorScheme,
                   long ilbnd,
                   long ihbnd,
                   CLanguageModel lm,
                   int Colour)
Creates a Node and sets its describing variables.

Parameters:
Parent - Parent Node
Symbol - Symbol number
iphase - Colour-cycling phase
ColorScheme - Colour scheme
ilbnd - Lower bound of cum. probability relative to parent
ihbnd - Upper bound of cum. probability relative to parent
lm - LanguageModel
Colour - Colour number
Method Detail

DeleteNode

public void DeleteNode()
At present, does nothing; Nodes will be "deleted" by virtue of their parents cutting them loose at the appropriate time, making them available for garbage collection.


SetContext

public void SetContext(CContextBase context)
Sets the context associated with this node.

Releases its existing context with the language model if one exists.

Parameters:
context - New context

Lbnd

public long Lbnd()
Gets m_iLbnd

Returns:
m_iLbnd

Hbnd

public long Hbnd()
Gets m_iHbnd

Returns:
m_iHbnd

Range

public long Range()
Gets the difference between m_iLbnd and m_iHbnd.

Returns:
Range

Children

public java.util.ArrayList<CDasherNode> Children()
Gets a reference to this Node's child list.

Returns:
m_mChildren

GetChildren

public java.util.ArrayList<CDasherNode> GetChildren()
Gets a reference to this Node's child list.

Returns:
m_mChildren

SetChildren

public void SetChildren(java.util.ArrayList<CDasherNode> in)
Sets this Node's child list.

Parameters:
in - The list of children to be attached to this node.

Context

public CContextBase Context()
Retrives the LM context associated with this node.

Returns:
Context

NodeIsParent

public boolean NodeIsParent(CDasherNode oldnode)
Determine if a given node is this one's parent.

Parameters:
oldnode - Potential parent
Returns:
True if parent

ChildCount

public int ChildCount()
Returns the size of our child list.

Returns:
Size of m_mChildren.

Parent

public CDasherNode Parent()
Gets this node's parent.

Returns:
Parent node.

SetParent

public void SetParent(CDasherNode NewParent)
Attaches this Node to a given Parent.

Parameters:
NewParent - Our new parent

SetRange

public void SetRange(long iLower,
                     long iUpper)
Sets this node's probabilities.

Parameters:
iLower - New Lbnd
iUpper - New Hbnd

Alive

public boolean Alive()
Determines if this node is currently drawable.

Returns:
m_bAlive

Alive

public void Alive(boolean b)
Sets this node's Alive flag

Parameters:
b - new value

Kill

public void Kill()
Sets this node's Alive flag to false


isSeen

public boolean isSeen()
Gets this node's Seen flag

Returns:
Seen

Seen

public void Seen(boolean seen)
Sets this node's Seen flag

Parameters:
seen - new value

Symbol

public int Symbol()
Gets this node's symbol

Returns:
symbol number

Phase

public int Phase()
Gets this node's colour-cycling phase

Returns:
Phase

ColorScheme

public EColorSchemes ColorScheme()
Gets this Node's colour scheme


Colour

public int Colour()
Gets this Node's colour index

Returns:
Colour index

HasAllChildren

public boolean HasAllChildren()
Checks whether all of this Node's children exist at present

Returns:
m_bHasAllChildren

SetHasAllChildren

public void SetHasAllChildren(boolean val)
Sets the HasAllChildren flag

Parameters:
val - new value

MostProbableChild

public long MostProbableChild()
Gets the probability associated with this node's most probable child.

Returns:
Probability

Get_node_under

public CDasherNode Get_node_under(long iNormalization,
                                  long miY1,
                                  long miY2,
                                  long miMousex,
                                  long miMousey)
Finds the node under a given mouse location, given our boundaries in Dasher space. Essentially this iterates through our children checking whether the point falls within each child, and if so recalls this method in the child. If no children match, we replace a reference to ourselves.

The "mouse position" may of course be replaced by any other point we want to find the node under.

Parameters:
iNormalization - Normalization value, usually LP_NORMALIZATION
miY1 - Our upper bound in Dasher co-ordinate space
miY2 - Our lower bound in Dasher co-ordiante space
miMousex - Current mouse position X
miMousey - Current mouse position Y
Returns:
Node under this mouse position.

OrphanChild

public void OrphanChild(CDasherNode pChild)
Delete our children except for a given one, the delete ourself.

Parameters:
pChild - Child to keep

DeleteNephews

public void DeleteNephews(CDasherNode pChild)
Deletes the nephews of a given child; that is to say, deletes its siblings' children.

Parameters:
pChild - Child whose children will NOT be deleted.

Delete_children

public void Delete_children()
Clears the Children list and sets our HasAllChildren flag to false; this will leave this section of tree unrefrenced and available for garbage collection.


GetProb

public double GetProb(int iNormalization)
Gets this node's probability

Parameters:
iNormalization - Norm value, usually LP_NORMALIZATION