dasher
Class CAlphabetManager

java.lang.Object
  extended by dasher.CNodeManager
      extended by dasher.CAlphabetManager
Direct Known Subclasses:
CRemoteAlphabetManager

public class CAlphabetManager
extends CNodeManager

AlphabetManager is a specialisation of NodeManager which knows about an Alphabet.

The AlphabetManager is used by the DasherModel to perform tasks which require the knowledge of which Alphabet is currently in use. This includes the handling of output of text when the user enters or leaves a given node and extending the Model's tree of DasherNodes, either forwards or backwards, whenever necessary.


Field Summary
protected  int ContSymbol
           
protected  int ConvertSymbol
           
protected  CAlphabet m_Alphabet
          Pointer to the current Alphabet, used to find out what a given character looks like typed (for the purposes of output) and displayed (if growing the DasherNode tree).
protected  java.util.ArrayList<java.lang.Integer> m_Colours
           
protected  java.util.ArrayList<java.lang.String> m_DisplayText
           
protected  CLanguageModel m_LanguageModel
          Pointer to the LanguageModel used in determining the relative probability assigned to new Nodes.
protected  CDasherModel m_Model
          Pointer to the DasherModel which performs some of the work in the course of producing probabilities.
protected  int SPSymbol
           
 
Fields inherited from class dasher.CNodeManager
m_iID
 
Constructor Summary
CAlphabetManager(CDasherModel Model, CLanguageModel LanguageModel)
          Sole constructor: produces an AlphabetManager linked to a given Model and LanguageModel.
 
Method Summary
 void ClearNode(CDasherNode Node)
          Stub; to be used if in future there is work to be done upon deleting a node.
 CDasherNode GetRoot(CDasherNode Parent, long iLower, long iUpper, int UserData)
          Creates a new root CDasherNode with the supplied parameters.
 void Output(CDasherNode Node, java.util.ArrayList<CSymbolProb> Added, int iNormalization)
          Generates an EditEvent announcing a new character has been entered, inferring the character from the Node supplied.
 void PopulateChildren(CDasherNode Node)
          Populates the children of a given DasherNode.
 void PopulateChildrenWithSymbol(CDasherNode Node, int iExistingSymbol, CDasherNode ExistingChild)
          Populates the children of a given Node.
 void PopulateChildrenWithSymbol(CDasherNode Node, int iExistingSymbol, CDasherNode ExistingChild, long[] cum)
          Creates the children of a given Node given a set of probabilities associated with said children and, perhaps, one child which already exists.
 CDasherNode RebuildParent(CDasherNode Node, int iGeneration)
          Reconstructs the parent of a given node, in the case that it had been deleted but the user has now backed off far enough that we need to restore.
 void Ref()
          Stub: AlphabetManager is not reference counted.
 void Undo(CDasherNode Node)
          Generates an EditEvent announcing that the character represented by this Node should be removed.
 void Unref()
          Stub: AlphabetManager is not reference counted.
 void WaitForChildren(CDasherNode node)
          Suspends the current thread until a given Node's children have been created.
 
Methods inherited from class dasher.CNodeManager
Enter, GetID, Leave
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_LanguageModel

protected CLanguageModel m_LanguageModel
Pointer to the LanguageModel used in determining the relative probability assigned to new Nodes.


m_Model

protected CDasherModel m_Model
Pointer to the DasherModel which performs some of the work in the course of producing probabilities.


SPSymbol

protected int SPSymbol

ConvertSymbol

protected int ConvertSymbol

ContSymbol

protected int ContSymbol

m_Alphabet

protected CAlphabet m_Alphabet
Pointer to the current Alphabet, used to find out what a given character looks like typed (for the purposes of output) and displayed (if growing the DasherNode tree).


m_Colours

protected java.util.ArrayList<java.lang.Integer> m_Colours

m_DisplayText

protected java.util.ArrayList<java.lang.String> m_DisplayText
Constructor Detail

CAlphabetManager

public CAlphabetManager(CDasherModel Model,
                        CLanguageModel LanguageModel)
Sole constructor: produces an AlphabetManager linked to a given Model and LanguageModel. These cannot be set after the Manager has been created; as such the Manager must be created last of these three.

Parameters:
Model - Linked DasherModel
LanguageModel - Linked LanguageModel
Method Detail

GetRoot

public CDasherNode GetRoot(CDasherNode Parent,
                           long iLower,
                           long iUpper,
                           int UserData)
Creates a new root CDasherNode with the supplied parameters.

Specified by:
GetRoot in class CNodeManager
Parameters:
Parent - Parent to which the new root will be a child
iLower - New node's lower probability bound with respect to its parent
iUpper - New node's upper probability bound with respect to its parent
UserData - Usage depends on the type of NodeManager
Returns:
new root CDasherNode

Ref

public void Ref()
Stub: AlphabetManager is not reference counted.

Specified by:
Ref in class CNodeManager

Unref

public void Unref()
Stub: AlphabetManager is not reference counted.

Specified by:
Unref in class CNodeManager

PopulateChildren

public void PopulateChildren(CDasherNode Node)
Populates the children of a given DasherNode.

This is exactly the same as calling PopulateChildrenWithSymbol(Node, -2, null);

Specified by:
PopulateChildren in class CNodeManager
Parameters:
Node - Node to be given children.

PopulateChildrenWithSymbol

public void PopulateChildrenWithSymbol(CDasherNode Node,
                                       int iExistingSymbol,
                                       CDasherNode ExistingChild)
Populates the children of a given Node. This function calls CLanguageModel.getProbs on the Context associated with this Node; its function is identical to the four-arg version of the function called upon the same probabilities.

Parameters:
Node - Node whose children we wish to populate.
iExistingSymbol - Symbol of child node which already exists, if any; -2 if none.
ExistingChild - Reference to the pre-existing child, if one exists.

PopulateChildrenWithSymbol

public void PopulateChildrenWithSymbol(CDasherNode Node,
                                       int iExistingSymbol,
                                       CDasherNode ExistingChild,
                                       long[] cum)
Creates the children of a given Node given a set of probabilities associated with said children and, perhaps, one child which already exists.

The probabilties supplied should not be cumulative, but should be normalised such that they add up to the value of LP_NORMALIZATION.

Parameters:
Node - Node whose children are to be populated.
iExistingSymbol - Symbol of its existing child, or -2 if there is none.
ExistingChild - Reference to its existing child, if any.
cum - Probabilities to be associated with the children, supplied in alphabet symbol order.

ClearNode

public void ClearNode(CDasherNode Node)
Stub; to be used if in future there is work to be done upon deleting a node.

Note that this method should NOT actually destroy the node, but should remove the Manager's references to it, if any exist.

Specified by:
ClearNode in class CNodeManager
Parameters:
Node - Node to be deleted

Output

public void Output(CDasherNode Node,
                   java.util.ArrayList<CSymbolProb> Added,
                   int iNormalization)
Generates an EditEvent announcing a new character has been entered, inferring the character from the Node supplied.

The second and third parameters are solely for logging purposes. Logging is not currently enabled in JDasher and so these can safely be set to null and 0 respectively.

In the case that logging is enabled, passing the second parameter as null will cause this addition not to be logged.

Overrides:
Output in class CNodeManager
Parameters:
Node - The node whose symbol we wish to look up and announce.
Added - An ArrayList to which the typed symbol, annotated with its probability, will be added for logging purposes.
iNormalization - The total to which probabilities should add (usually LP_NORMALIZATION) for the purposes of generating the logged probability.

Undo

public void Undo(CDasherNode Node)
Generates an EditEvent announcing that the character represented by this Node should be removed.

Overrides:
Undo in class CNodeManager
Parameters:
Node - Node whose symbol we wish to remove.

RebuildParent

public CDasherNode RebuildParent(CDasherNode Node,
                                 int iGeneration)
Reconstructs the parent of a given node, in the case that it had been deleted but the user has now backed off far enough that we need to restore.

This will generate an EditContextEvent to try to extend its knowledge of the current context; this is necessary because Dasher only buffers a small amount of context internally. Typically a UI component is expected to reply with the appropriate context.

In the event that context is not available internally and the dispatched EditContextEvent is not passed a new context, the root symbol is created and returned.

Overrides:
RebuildParent in class CNodeManager
Parameters:
Node - The node whose parent we wish to recreated.
iGeneration - The depth in the tree of this node.
Returns:
The newly created parent, which may be the root node.

WaitForChildren

public void WaitForChildren(CDasherNode node)
Suspends the current thread until a given Node's children have been created. This is for use with specialised AlphabetManagers which populate their child lists asynchronously such as RemoteAlphabetManager.

This simply polls the child-list every 50ms, and returns when it finds it is neither null nor empty.

Parameters:
node - Node whose children we wish to wait for.