dasher
Class CAlphabet

java.lang.Object
  extended by dasher.CAlphabet

public class CAlphabet
extends java.lang.Object

Represents an Alphabet, including a list of its symbols, their appearance on screen and when typed, and their foreground and background colours.

Note that the colours specified here are mere ordinal numbers; the resolution of these into actual displayable colours is the responsibility of CCustomColours.

This class is also responsible for translating a tract of text into a sequence of logical symbol identifiers (see GetSymbols)


Field Summary
 SGroupInfo m_BaseGroup
          Root of the group tree.
protected  java.util.ArrayList<java.lang.String> m_Characters
          Symbols' representations when typed.
protected  java.util.ArrayList<java.lang.Integer> m_Colours
          Symbols' background colours, used by CDasherView to display their nodes.
protected  int m_ControlSymbol
          The symbol number of the control node.
protected  java.lang.String m_DefaultPalette
          Name of the colour scheme which this alphabet 'prefers' to use.
protected  java.util.ArrayList<java.lang.String> m_Display
          Symbols' representations on screen.
protected  int m_EndConversionSymbol
          The symbol number of the End Conversion symbol.
protected  java.util.ArrayList<java.lang.String> m_Foreground
          Stores the foreground colour of the symbols.
protected  java.lang.String m_GameModeFile
           
protected  int m_Orientation
          This alphabet's default orientation.
protected  int m_ParagraphSymbol
          The symbol number of the new-paragraph character.
protected  int m_SpaceSymbol
          The symbol number of the space character.
protected  int m_StartConversionSymbol
          The symbol number of the Start Conversion symbol.
protected  java.lang.String m_TrainingFile
          Path of a file containing training text relevant to this alphabet.
protected  CAlphabetMap TextMap
          Mapping from text to symbol numbers, for use in parsing training text.
 
Constructor Summary
CAlphabet()
          Default constructor; produces an alphabet containing no characters.
CAlphabet(CAlphIO.AlphInfo AlphabetInfo)
          Produces a ready-made Alphabet from an AlphInfo class which specifies the alphabet.
 
Method Summary
 void AddChar(java.lang.String NewCharacter, java.lang.String Display, int Colour, java.lang.String Foreground)
          Adds a new character to this alphabet.
 void AddControlSymbol(java.lang.String NewCharacter, java.lang.String Display, int Colour, java.lang.String Foreground)
          Adds a control symbol to the alphabet.
 void AddEndConversionSymbol(java.lang.String NewCharacter, java.lang.String Display, int Colour, java.lang.String Foreground)
          Adds an end-conversion symbol top the alphabet.
 void AddParagraphSymbol(java.lang.String NewCharacter, java.lang.String Display, int Colour, java.lang.String Foreground)
          Adds a paragraph symbol to the alphabet.
 void AddSpaceSymbol(java.lang.String NewCharacter, java.lang.String Display, int Colour, java.lang.String Foreground)
          Adds a space symbol to the alphabet.
 void AddStartConversionSymbol(java.lang.String NewCharacter, java.lang.String Display, int Colour, java.lang.String Foreground)
          Adds a start-conversion symbol top the alphabet.
 CAlphabetMap GetAlphabetMap()
          Gets the instance of CAlphabetMap which maps Strings to symbols in this Alphabet.
 int GetColour(int i)
          Retrieves the background colour for a given symbol.
 java.util.ArrayList<java.lang.Integer> GetColours()
          Gets a reference to the array of background colours used when drawing symbols.
 int GetControlSymbol()
          Gets the index of this alphabet's control symbol.
 java.lang.String GetDisplayText(int i)
          Retrieves the String which should be displayed to represent a given character.
 java.util.ArrayList<java.lang.String> GetDisplayTexts()
          Gets the array of display texts.
 int GetEndConversionSymbol()
          Gets the index of this alphabet's end-conversion symbol.
 java.lang.String GetForeground(int i)
          Retrieves the foreground (text) colour for a given symbol.
 java.lang.String GetGameModeFile()
           
 int GetNumberSymbols()
          Gets number of symbols in this alphabet, including special characters.
 int GetNumberTextSymbols()
          Gets the number of symbols in this alphabet which are not 'special symbols' (eg the Control symbol).
 int GetOrientation()
          Gets the orientation associated with this alphabet.
 java.lang.String GetPalette()
          Gets the name of the colour scheme preferred by this alphabet.
 int GetParagraphSymbol()
          Gets the index of this alphabet's paragraph symbol.
 int GetSpaceSymbol()
          Gets the index of this alphabet's space symbol.
 int GetStartConversionSymbol()
          Gets the index of this alphabet's start-conversion symbol.
 void GetSymbols(java.util.Collection<java.lang.Integer> Symbols, java.lang.String Input, boolean IsMore)
          Converts a string of text into a list of symbol indentifiers.
 java.lang.String GetText(int i)
          Retrieves the typed character representation of a given symbol.
 int GetTextColour(int Symbol)
          Retrieves the text colour to be used in drawing the specified symbol.
 java.lang.String GetTrainingFile()
          Gets the training file to be used training a language model which uses this alphabet.
 void SetGameModeFile(java.lang.String GameModeFile)
           
 void SetOrientation(int Orientation)
          Sets the preferred orientation for this alphabet.
 void SetPalette(java.lang.String Palette)
          Sets this alphabet's preferred colour scheme.
 void SetTrainingFile(java.lang.String TrainingFile)
          Sets the training file to be used training a language model which uses this alphabet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Orientation

protected int m_Orientation
This alphabet's default orientation. Valid values are specified by Opts.AlphabetTypes, and indicate left-to-right, right-to-left, top-to-bottom or bottom-to-top screen orientation.


m_ParagraphSymbol

protected int m_ParagraphSymbol
The symbol number of the new-paragraph character.


m_SpaceSymbol

protected int m_SpaceSymbol
The symbol number of the space character.


m_ControlSymbol

protected int m_ControlSymbol
The symbol number of the control node. Currently redundant as control mode is not implemented in Java.


m_StartConversionSymbol

protected int m_StartConversionSymbol
The symbol number of the Start Conversion symbol. Current redundant as kanji conversion is not yet implemented in Java.


m_EndConversionSymbol

protected int m_EndConversionSymbol
The symbol number of the End Conversion symbol. Current redundant as kanji conversion is not yet implemented in Java.


m_TrainingFile

protected java.lang.String m_TrainingFile
Path of a file containing training text relevant to this alphabet.


m_GameModeFile

protected java.lang.String m_GameModeFile

m_DefaultPalette

protected java.lang.String m_DefaultPalette
Name of the colour scheme which this alphabet 'prefers' to use. This class does not enforce its use.


m_Characters

protected java.util.ArrayList<java.lang.String> m_Characters
Symbols' representations when typed. These are Strings and not Characters because some alphabets may define multi-character symbols.


m_Display

protected java.util.ArrayList<java.lang.String> m_Display
Symbols' representations on screen. Usually this is the same as m_Characters, but some symbols are displayed with extra ornamentation on screen, such as the apostrophe in English, and most combining accent characters.


m_Colours

protected java.util.ArrayList<java.lang.Integer> m_Colours
Symbols' background colours, used by CDasherView to display their nodes. These colour identifiers must be looked up by an instance of CCustomColours to retrieve actual RGB colours.


m_Foreground

protected java.util.ArrayList<java.lang.String> m_Foreground
Stores the foreground colour of the symbols.


m_BaseGroup

public SGroupInfo m_BaseGroup
Root of the group tree. Contains all other groups.


TextMap

protected CAlphabetMap TextMap
Mapping from text to symbol numbers, for use in parsing training text.

Constructor Detail

CAlphabet

public CAlphabet()
Default constructor; produces an alphabet containing no characters. Characters may subsequently be added by calling AddChar. Special characters should be added by using AddParagraphSymbol, AddSpaceSymbol, and so forth.


CAlphabet

public CAlphabet(CAlphIO.AlphInfo AlphabetInfo)
Produces a ready-made Alphabet from an AlphInfo class which specifies the alphabet. These are typically produced by an instance of CAlphIO by reading alphabet.*.xml files but may be producd by other means.

The alphabet produced will have special characters (such as the start conversion character) only if AlphabetInfo specifies their text as having non-zero length.

Parameters:
AlphabetInfo - The AlphInfo class containing the alphabet specification.
See Also:
CAlphIO, CAlphIO.AlphInfo
Method Detail

GetSymbols

public void GetSymbols(java.util.Collection<java.lang.Integer> Symbols,
                       java.lang.String Input,
                       boolean IsMore)
Converts a string of text into a list of symbol indentifiers. Typically used in the course of training a language model, this fills the Symbols Collection with a seqeunce of integer symbol identifiers. Each character is individually used as a key into TextMap to determine its symbol number; as such their is no support for multi-character symbols at present.

Parameters:
Symbols - Collection to be filled with symbol identifiers.
Input - String to be converted.
IsMore - Redundant parameter; used to signal that the last input character may be an incomplete UTF-8 character, but redundant since UTF-16 is now used internally.

AddChar

public void AddChar(java.lang.String NewCharacter,
                    java.lang.String Display,
                    int Colour,
                    java.lang.String Foreground)
Adds a new character to this alphabet. The new character will be assigned the next free symbol index.

Parameters:
NewCharacter - Representation of this character as to be shown in textual output.
Display - Representation to be shown on screen.
Colour - Background colour index to be used in drawing nodes containing this character.
Foreground - Foreground colour to be used drawing the text..

AddParagraphSymbol

public void AddParagraphSymbol(java.lang.String NewCharacter,
                               java.lang.String Display,
                               int Colour,
                               java.lang.String Foreground)
Adds a paragraph symbol to the alphabet. Since there is only one identifier for the paragraph symbol, if multiple paragraph symbols are added all but the latest will lose their status and will become ordinary symbols.

Parameters:
NewCharacter - Representation of this character as to be shown in textual output.
Display - Representation to be shown on screen.
Colour - Background colour index to be used in drawing nodes containing this character.
Foreground - Foreground colour to be used drawing the text..

AddSpaceSymbol

public void AddSpaceSymbol(java.lang.String NewCharacter,
                           java.lang.String Display,
                           int Colour,
                           java.lang.String Foreground)
Adds a space symbol to the alphabet. Since there is only one identifier for the space symbol, if multiple space symbols are added all but the latest will lose their status and will become ordinary symbols.

Parameters:
NewCharacter - Representation of this character as to be shown in textual output.
Display - Representation to be shown on screen.
Colour - Background colour index to be used in drawing nodes containing this character.
Foreground - Foreground colour to be used drawing the text..

AddControlSymbol

public void AddControlSymbol(java.lang.String NewCharacter,
                             java.lang.String Display,
                             int Colour,
                             java.lang.String Foreground)
Adds a control symbol to the alphabet. Since there is only one identifier for the control symbol, if multiple control symbols are added all but the latest will lose their status and will become ordinary symbols.

Parameters:
NewCharacter - Redundant; the Control character is not typed.
Display - Representation to be shown on screen. (typically 'Control')
Colour - Background colour index to be used in drawing nodes containing this character.
Foreground - Foreground colour to be used drawing the text..

AddStartConversionSymbol

public void AddStartConversionSymbol(java.lang.String NewCharacter,
                                     java.lang.String Display,
                                     int Colour,
                                     java.lang.String Foreground)
Adds a start-conversion symbol top the alphabet. Since there is only one identifier for the symbol, if multiple start-conversion symbols are added all but the latest will lose their status and will become ordinary symbols.

Parameters:
NewCharacter - Redundant; the conversion symbol is not a typed character in the ordinary sense.
Display - Representation to be shown on screen.
Colour - Background colour index to be used in drawing nodes containing this character.
Foreground - Foreground colour to be used drawing the text..

AddEndConversionSymbol

public void AddEndConversionSymbol(java.lang.String NewCharacter,
                                   java.lang.String Display,
                                   int Colour,
                                   java.lang.String Foreground)
Adds an end-conversion symbol top the alphabet. Since there is only one identifier for the end-conversion symbol, if multiple end-conversion symbols are added all but the latest will lose their status and will become ordinary symbols.

Parameters:
NewCharacter - Redundant; the end-conversion symbol is not typed in the ordinary sense.
Display - Representation to be shown on screen.
Colour - Background colour index to be used in drawing nodes containing this character.
Foreground - Foreground colour to be used drawing the text..

GetTextColour

public int GetTextColour(int Symbol)
Retrieves the text colour to be used in drawing the specified symbol. In the case that a foreground colour was not specified (and so the m_Foreground list contains "" at this index) the default colour 4 is returned.

Parameters:
Symbol - Symbol whose colour is to be looked up.
Returns:
Colour identifier to be used drawing this text.

GetNumberSymbols

public int GetNumberSymbols()
Gets number of symbols in this alphabet, including special characters.

Returns:
Symbol count in this Alphabet.

GetNumberTextSymbols

public int GetNumberTextSymbols()
Gets the number of symbols in this alphabet which are not 'special symbols' (eg the Control symbol). In reality this is the same as GetNumberSymbols() - 1.

This method needs improving to correctly recognise the start conversion symbol.

Returns:
Textual symbol count in this alphabet.

GetOrientation

public int GetOrientation()
Gets the orientation associated with this alphabet. Allowable values are enumerated by Opts.ScreenOrientations.

Returns:
This Alphabet's preferred orientation.

GetTrainingFile

public java.lang.String GetTrainingFile()
Gets the training file to be used training a language model which uses this alphabet.

Returns:
Path to the specified training file.

GetGameModeFile

public java.lang.String GetGameModeFile()

GetPalette

public java.lang.String GetPalette()
Gets the name of the colour scheme preferred by this alphabet.

Returns:
Preferred colour scheme name.

GetDisplayTexts

public java.util.ArrayList<java.lang.String> GetDisplayTexts()
Gets the array of display texts. This should not be used to make changes to the alphabet.

Returns:
Reference to the array of characters' display texts.

GetDisplayText

public java.lang.String GetDisplayText(int i)
Retrieves the String which should be displayed to represent a given character.

Parameters:
i - Index of the character to be looked up.
Returns:
Display string for this character.

GetText

public java.lang.String GetText(int i)
Retrieves the typed character representation of a given symbol.

Parameters:
i - Symbol to look up
Returns:
Character which should be typed in the edit box (for example) to represent it.

GetColours

public java.util.ArrayList<java.lang.Integer> GetColours()
Gets a reference to the array of background colours used when drawing symbols. The returned array should not be modified, and GetColour(i) should be used where possible; this is for increased efficiency when iteration over the array is desired.

Returns:
Array of background colours.

GetColour

public int GetColour(int i)
Retrieves the background colour for a given symbol.

Parameters:
i - Symbol indentifier
Returns:
Background colour for this symbol.

GetForeground

public java.lang.String GetForeground(int i)
Retrieves the foreground (text) colour for a given symbol.

Parameters:
i - Symbol identifier.
Returns:
Foreground colour for this symbol.

SetOrientation

public void SetOrientation(int Orientation)
Sets the preferred orientation for this alphabet.

Parameters:
Orientation - New orientation.

SetTrainingFile

public void SetTrainingFile(java.lang.String TrainingFile)
Sets the training file to be used training a language model which uses this alphabet.

Parameters:
TrainingFile - New training file location.

SetGameModeFile

public void SetGameModeFile(java.lang.String GameModeFile)

SetPalette

public void SetPalette(java.lang.String Palette)
Sets this alphabet's preferred colour scheme.

Parameters:
Palette - Name of the new scheme.

GetAlphabetMap

public CAlphabetMap GetAlphabetMap()
Gets the instance of CAlphabetMap which maps Strings to symbols in this Alphabet.

Returns:
TextMap

GetParagraphSymbol

public int GetParagraphSymbol()
Gets the index of this alphabet's paragraph symbol.

Returns:
index of paragraph symbol.

GetSpaceSymbol

public int GetSpaceSymbol()
Gets the index of this alphabet's space symbol.

Returns:
index of space symbol.

GetControlSymbol

public int GetControlSymbol()
Gets the index of this alphabet's control symbol.

Returns:
index of control symbol, or -1 if there is none.

GetStartConversionSymbol

public int GetStartConversionSymbol()
Gets the index of this alphabet's start-conversion symbol.

Returns:
index of start-conversion symbol, or -1 if there is none.

GetEndConversionSymbol

public int GetEndConversionSymbol()
Gets the index of this alphabet's end-conversion symbol.

Returns:
index of end-conversion symbol, or -1 if there is none.