edu.northwestern.at.wordhoard.model.text
Class TranslatedText

java.lang.Object
  extended by edu.northwestern.at.wordhoard.model.text.Text
      extended by edu.northwestern.at.wordhoard.model.text.TranslatedText
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable

public class TranslatedText
extends Text

Text with translations.

This class takes primary text plus one or more text translations and merges them together into a text object which has the translated lines immediately following each primary text line. This is like a "perfect shuffle" of multiple decks of cards into one big deck of cards.

Each translation text object must have exactly the same number of lines as the primary text object, in one-to-one correspondence.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.northwestern.at.wordhoard.model.text.Text
serialVersionUID
 
Constructor Summary
TranslatedText(Text primaryText, Text[] translations)
          Creates new translated text.
 
Method Summary
 TextLocation baseToDerived(TextLocation loc)
          Converts a location from base to derived coordinates.
 TextLocation derivedToBase(TextLocation loc)
          Converts a location from derived to base coordinates.
 
Methods inherited from class edu.northwestern.at.wordhoard.model.text.Text
appendBlankLine, appendLine, appendLine, baseToDerived, clone, computeLineWidths, computeVerticalPositioningInformation, copyLine, copyLine, derivedToBase, draw, finalize, getLine, getLineLocation, getLineLocation, getLines, getNumLines, getText, getWordLocation, hasLineNumbers, hasMarginalia, initializeForDrawing, isMarked, readExternal, roundLocation, setCollapseBlankLines, setExtraIndentation, setLineNumberInterval, setMarkers, setSelection, viewToModel, writeExternal
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TranslatedText

public TranslatedText(Text primaryText,
                      Text[] translations)
               throws java.lang.Exception
Creates new translated text.

Parameters:
primaryText - Primary text.
translations - Translations.
Throws:
java.lang.Exception - Translation has wrong number of lines.
Method Detail

derivedToBase

public TextLocation derivedToBase(TextLocation loc)
Converts a location from derived to base coordinates.

If the location is in a translated line, the returned base location is at the end of the earliest preceding primary line.

See the package documentation for more details on derived and base coordinate systems.

Overrides:
derivedToBase in class Text
Parameters:
loc - Text location in derived coordinates.
Returns:
Text location in base coordinates.

baseToDerived

public TextLocation baseToDerived(TextLocation loc)
Converts a location from base to derived coordinates.

See the package documentation for more details on derived and base coordinate systems.

Overrides:
baseToDerived in class Text
Parameters:
loc - Text location in base cooordinates.
Returns:
Text location in derived coordinates.