org.eml.MMAX2.discourse
Class MMAX2Discourse

java.lang.Object
  extended by org.eml.MMAX2.discourse.MMAX2Discourse
All Implemented Interfaces:
DiscourseAPI

public class MMAX2Discourse
extends java.lang.Object
implements DiscourseAPI


Field Summary
static AlphabeticMarkableComparator ALPHACOMP
           
static DiscourseOrderMarkableComparator DISCOURSEORDERCOMP
           
static EndingMarkableComparator ENDCOMP
           
static MarkableIDComparator IDCOMP
           
static MarkableLevelPositionComparator LEVELCOMP
           
static StartingMarkableComparator STARTCOMP
           
 
Constructor Summary
MMAX2Discourse(boolean withGUI)
          Creates new Discourse
 
Method Summary
 MMAX2Discourse _buildDiscourse(java.lang.String infile, java.lang.String commonPathsFile)
          (API) Loads the .mmax file of name inFileName, using the common_paths.xml file specified in commonPathsFileName.
 void addWithID(java.lang.String id, org.w3c.dom.Element node)
           
 void applyStyleSheet(java.lang.String overrideStyleFileName)
          Apply the XSL style sheet in this.styleSheetFileName to this.structureDOM.
 void basedataTextAndAttributeSelected(org.w3c.dom.Node referenceNode, int mode, java.lang.String text, java.lang.String attribute)
           
static MMAX2Discourse buildDiscourse(java.lang.String infile)
           
static MMAX2Discourse buildDiscourse(java.lang.String infile, java.lang.String commonPathsFile)
           
 void destroyDependentComponents()
           
 java.lang.String[] getAllDiscourseElementIDs()
           
 java.lang.Integer[] getAllDisplayAssociations()
           
 java.lang.String getCommonBasedataPath()
           
 int getCurrentDocumentPosition()
          This method returns the current length of this.incrementalTransformationResult.
 MarkableChart getCurrentMarkableChart()
           
 java.lang.String getCurrentStyleSheet()
           
 MMAX2DiscourseElement getDiscourseElementAtDiscoursePosition(int discPos)
          (API) Returns the MMAX2DiscourseElement object (i.e.
 MMAX2DiscourseElement getDiscourseElementByID(java.lang.String id)
          (API) Returns the MMAX2DiscourseElement object (i.e.
 int getDiscourseElementCount()
          (API) Returns the number of MMAX2DiscourseElement objects in this discourse.
 java.lang.String getDiscourseElementIDAtDiscoursePosition(int pos)
           
 org.w3c.dom.Node getDiscourseElementNode(java.lang.String ID)
          Returns the Node representation of the discourse element with id ID.
 MMAX2DiscourseElement[] getDiscourseElements()
          (API) Returns an array containing all MMAX2DiscourseElement objects in the current discourse, ordered in discourse order.
 MMAX2DiscourseElement[] getDiscourseElements(Markable _markable)
          (API) Returns an array containing all MMAX2DiscourseElement objects in Markable markable, ordered in discourse order.
 int getDiscoursePositionAtDisplayPosition(int _displayPosition)
          This method returns the DiscoursePosition of the DiscourseElement currently displayed at display position displayPosition, or -1 if no DiscourseElement is displayed at this position.
 int getDiscoursePositionFromDiscourseElementID(java.lang.String id)
          This method receives the String id of a DiscourseElement (word_x) and returns the (0-based) discourse position, i.e.
 MMAX2Document getDisplayDocument()
           
 int getDisplayEndPositionFromDiscoursePosition(int discoursePosition)
          This method returns the display end position (i.e.
 int getDisplayStartPositionFromDiscoursePosition(int discoursePosition)
          This method returns the display start position (i.e.
 java.lang.String getFromHash(java.lang.String key)
           
 boolean getHasGUI()
           
 java.lang.String getHotSpotAtDisplayAssociation(int displayPosition)
           
 Markable getMarkableAtDisplayAssociation(int displayPosition)
           
 MarkableLevel getMarkableLevelByName(java.lang.String name, boolean interactive)
          (API) Returns the MarkableLevel object of name levelName, or null if no MarkableLevel of this name exists.
 MarkableLevel getMarkableLevelFromAbsoluteFileName(java.lang.String absFileName)
           
 MMAX2 getMMAX2()
           
 java.lang.String getNameSpace()
           
 MMAX2DiscourseElement getNextDiscourseElement(MMAX2DiscourseElement element)
          (API) Returns the MMAX2DiscourseElement object at discourse position currentElement.DiscourseElementAPI.getDiscoursePosition()+1, or null if none exists at this position.
 java.lang.String getNextDocumentChunk()
          This method returns the next chunk of the incremental transformation result that has not yet been processed.
 MMAX2DiscourseElement getPreviousDiscourseElement(MMAX2DiscourseElement element)
          (API) Returns the MMAX2DiscourseElement object at discourse position currentElement.DiscourseElementAPI.getDiscoursePosition()-1, or null if none exists at this position.
 java.lang.String[] getStyleSheetFileNames()
           
 java.lang.String getStyleSheetOutput()
           
 org.apache.xerces.dom.DocumentImpl getWordDOM()
           
 java.lang.String getWordFileName()
           
 boolean isCurrentlyLoaded(java.lang.String absoluteMarkableFileName)
           
 void performNonGUIInitializations()
           
 void putInHash(java.lang.String key, java.lang.String value)
           
 void reapplyStyleSheet()
          This method is called when the deep refresh button on the MarkableLevelControlPanel is pressed.
 void registerAllDiscourseElements()
           
 void registerDiscourseElement(java.lang.String id)
          This method receives a DiscourseElement id (word_x), assigns it a discourse position (0-based) and stores both values in the Hash DiscoursePositionOfDiscourseElement.
 java.lang.Integer[] removeDisplayAssociationsForMarkable(Markable removee)
           
 void requestAddBasedataElement(org.w3c.dom.Node referenceNode, int mode)
          This method is called by the MMAX2BasedataEditActionSelector upon selection of an 'add' action.
 void requestDeleteBasedataElement(org.w3c.dom.Node deletee)
           
 void resetForStyleSheetReapplication()
           
 void saveBasedata(java.lang.String newFileName)
           
 void setCommonBasedataPath(java.lang.String path)
           
 void setCurrentStyleSheet(java.lang.String name)
           
 void setMMAX2(MMAX2 _mmax2)
           
 void setNameSpace(java.lang.String _nameSpace)
           
 void setStyleSheetFileNames(java.lang.String[] names)
           
 void setWordFileName(java.lang.String name)
           
 void showEditBasedataElementWindow(java.util.ArrayList recentTexts, java.util.ArrayList recentAttributes, org.w3c.dom.Node referenceNode, int mode)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STARTCOMP

public static StartingMarkableComparator STARTCOMP

ENDCOMP

public static EndingMarkableComparator ENDCOMP

ALPHACOMP

public static AlphabeticMarkableComparator ALPHACOMP

DISCOURSEORDERCOMP

public static DiscourseOrderMarkableComparator DISCOURSEORDERCOMP

LEVELCOMP

public static MarkableLevelPositionComparator LEVELCOMP

IDCOMP

public static MarkableIDComparator IDCOMP
Constructor Detail

MMAX2Discourse

public MMAX2Discourse(boolean withGUI)
Creates new Discourse

Method Detail

_buildDiscourse

public MMAX2Discourse _buildDiscourse(java.lang.String infile,
                                      java.lang.String commonPathsFile)
Description copied from interface: DiscourseAPI
(API) Loads the .mmax file of name inFileName, using the common_paths.xml file specified in commonPathsFileName.
Note: This is a dummy implementation only. The actual method to use is the *static* method

public static MMAX2Discourse buildDiscourse(String inFileName, String commonPathsFileName);

Specified by:
_buildDiscourse in interface DiscourseAPI
Parameters:
infile - The name and path of the .mmax file to load.
commonPathsFile - The name (and possibly path) of the common_paths.xml file to use. If this parameter is an empty string, the file common_paths.xml in the current directory will be used.
Returns:
The MMAX2Discourse object containing the loaded .mmax file.

buildDiscourse

public static MMAX2Discourse buildDiscourse(java.lang.String infile,
                                            java.lang.String commonPathsFile)

buildDiscourse

public static MMAX2Discourse buildDiscourse(java.lang.String infile)

setNameSpace

public final void setNameSpace(java.lang.String _nameSpace)

getNameSpace

public final java.lang.String getNameSpace()

setWordFileName

public final void setWordFileName(java.lang.String name)

getWordFileName

public final java.lang.String getWordFileName()

addWithID

public final void addWithID(java.lang.String id,
                            org.w3c.dom.Element node)

destroyDependentComponents

public final void destroyDependentComponents()

getHasGUI

public final boolean getHasGUI()

getDisplayDocument

public final MMAX2Document getDisplayDocument()

setMMAX2

public final void setMMAX2(MMAX2 _mmax2)

getMMAX2

public final MMAX2 getMMAX2()

getAllDisplayAssociations

public final java.lang.Integer[] getAllDisplayAssociations()

getMarkableAtDisplayAssociation

public final Markable getMarkableAtDisplayAssociation(int displayPosition)

getHotSpotAtDisplayAssociation

public final java.lang.String getHotSpotAtDisplayAssociation(int displayPosition)

removeDisplayAssociationsForMarkable

public final java.lang.Integer[] removeDisplayAssociationsForMarkable(Markable removee)

getWordDOM

public final org.apache.xerces.dom.DocumentImpl getWordDOM()

getDisplayStartPositionFromDiscoursePosition

public final int getDisplayStartPositionFromDiscoursePosition(int discoursePosition)
This method returns the display start position (i.e. initial string position) for the Discourse Element at discourse position discoursePosition. It is called during display initialization from Markable.setDisplayPositions(), and during display selection / rendering.


getDisplayEndPositionFromDiscoursePosition

public final int getDisplayEndPositionFromDiscoursePosition(int discoursePosition)
This method returns the display end position (i.e. final string position) for the Discourse Element at discourse position discoursePosition. It is called during display initialization from Markable.setDisplayPositions(), and during display selection / rendering.


getDiscoursePositionAtDisplayPosition

public final int getDiscoursePositionAtDisplayPosition(int _displayPosition)
This method returns the DiscoursePosition of the DiscourseElement currently displayed at display position displayPosition, or -1 if no DiscourseElement is displayed at this position. This method is called by the CaretListener to determine which DiscourseElement has been clicked or is hovered over. Markable handles, literal text and empty space do not have discourse positions! This method uses the arrays DisplayStartPosition and DisplayEndPosition.


getDiscourseElementByID

public final MMAX2DiscourseElement getDiscourseElementByID(java.lang.String id)
Description copied from interface: DiscourseAPI
(API) Returns the MMAX2DiscourseElement object (i.e. base data element) associated with the ID discourseElementID (e.g. 'word_4'), or null if none exists.

Specified by:
getDiscourseElementByID in interface DiscourseAPI
Parameters:
id - The ID of the MMAX2DiscourseElement to return.
Returns:
The MMAX2DiscourseElement with ID discourseElementID.

getDiscoursePositionFromDiscourseElementID

public final int getDiscoursePositionFromDiscourseElementID(java.lang.String id)
This method receives the String id of a DiscourseElement (word_x) and returns the (0-based) discourse position, i.e. the running number of DiscourseElements that are registered in the current display. The discourse position is determined using the Hash DiscoursePositionOfDiscourseElement which has been filled by calls to this.registerDiscourseElement(String id) during style sheet execution. (DiscoursePositionOfDiscourseElement won't be filled until after stylesheet execution!!) This will be filled incrementally during style sheet execution, and is thus available during that.


getDiscourseElementIDAtDiscoursePosition

public final java.lang.String getDiscourseElementIDAtDiscoursePosition(int pos)

registerAllDiscourseElements

public final void registerAllDiscourseElements()

registerDiscourseElement

public final void registerDiscourseElement(java.lang.String id)
This method receives a DiscourseElement id (word_x), assigns it a discourse position (0-based) and stores both values in the Hash DiscoursePositionOfDiscourseElement. This Hash is later used by this.getDiscoursePositionFromDiscourseElementID(String id). This method also adds word_x to the list this.temporaryDiscourseElementAtPosition. This list's size is used as the discourse position determiner for the _NEXT_ element to be added. This method must be called for every de, incl. those that are suppressed from the display! Internal use only!


getDiscourseElements

public final MMAX2DiscourseElement[] getDiscourseElements()
Description copied from interface: DiscourseAPI
(API) Returns an array containing all MMAX2DiscourseElement objects in the current discourse, ordered in discourse order.

Specified by:
getDiscourseElements in interface DiscourseAPI
Returns:
An array of all MMAX2DiscourseElement objects in the current discourse.

getDiscourseElements

public final MMAX2DiscourseElement[] getDiscourseElements(Markable _markable)
Description copied from interface: DiscourseAPI
(API) Returns an array containing all MMAX2DiscourseElement objects in Markable markable, ordered in discourse order.

Specified by:
getDiscourseElements in interface DiscourseAPI
Parameters:
_markable - The Markable object whose MMAX2DiscourseElement objects are to be returned.
Returns:
An array of all MMAX2DiscourseElement objects in Markable markable.

getDiscourseElementAtDiscoursePosition

public final MMAX2DiscourseElement getDiscourseElementAtDiscoursePosition(int discPos)
Description copied from interface: DiscourseAPI
(API) Returns the MMAX2DiscourseElement object (i.e. base data element) associated with discourse position discoursePosition, or null if none exists at this position.

Specified by:
getDiscourseElementAtDiscoursePosition in interface DiscourseAPI
Parameters:
discPos - The numeric discourse position of the MMAX2DiscourseElement to return. This is normally the base data element's position in the base data file.
Returns:
The MMAX2DiscourseElement at discourse position discoursePosition.

getNextDiscourseElement

public final MMAX2DiscourseElement getNextDiscourseElement(MMAX2DiscourseElement element)
Description copied from interface: DiscourseAPI
(API) Returns the MMAX2DiscourseElement object at discourse position currentElement.DiscourseElementAPI.getDiscoursePosition()+1, or null if none exists at this position.

Specified by:
getNextDiscourseElement in interface DiscourseAPI
Parameters:
element - The MMAX2DiscourseElement object at the current position, or null.
Returns:
The MMAX2DiscourseElement object at discourse position currentElement.DiscourseElementAPI.getDiscoursePosition()+1, or null if none exists at this position. If currentElement is null, the first MMAX2DiscourseElement object in the current discourse is returned.

getPreviousDiscourseElement

public final MMAX2DiscourseElement getPreviousDiscourseElement(MMAX2DiscourseElement element)
Description copied from interface: DiscourseAPI
(API) Returns the MMAX2DiscourseElement object at discourse position currentElement.DiscourseElementAPI.getDiscoursePosition()-1, or null if none exists at this position.

Specified by:
getPreviousDiscourseElement in interface DiscourseAPI
Parameters:
element - The MMAX2DiscourseElement object at the current position, or null.
Returns:
The MMAX2DiscourseElement object at discourse position currentElement.DiscourseElementAPI.getDiscoursePosition()-1, or null if none exists at this position. If currentElement is null, the last MMAX2DiscourseElement object in the current discourse is returned.

getDiscourseElementNode

public final org.w3c.dom.Node getDiscourseElementNode(java.lang.String ID)
Returns the Node representation of the discourse element with id ID.


resetForStyleSheetReapplication

public final void resetForStyleSheetReapplication()

reapplyStyleSheet

public final void reapplyStyleSheet()
This method is called when the deep refresh button on the MarkableLevelControlPanel is pressed.


applyStyleSheet

public final void applyStyleSheet(java.lang.String overrideStyleFileName)
Apply the XSL style sheet in this.styleSheetFileName to this.structureDOM.


setCurrentStyleSheet

public final void setCurrentStyleSheet(java.lang.String name)

getCurrentStyleSheet

public final java.lang.String getCurrentStyleSheet()

setStyleSheetFileNames

public final void setStyleSheetFileNames(java.lang.String[] names)

getStyleSheetFileNames

public final java.lang.String[] getStyleSheetFileNames()

getCurrentDocumentPosition

public final int getCurrentDocumentPosition()
This method returns the current length of this.incrementalTransformationResult. It is used to associate Discourse Elements with display string positions during stylesheet execution.


getNextDocumentChunk

public final java.lang.String getNextDocumentChunk()
This method returns the next chunk of the incremental transformation result that has not yet been processed.


getMarkableLevelFromAbsoluteFileName

public final MarkableLevel getMarkableLevelFromAbsoluteFileName(java.lang.String absFileName)

isCurrentlyLoaded

public final boolean isCurrentlyLoaded(java.lang.String absoluteMarkableFileName)

getStyleSheetOutput

public final java.lang.String getStyleSheetOutput()

putInHash

public final void putInHash(java.lang.String key,
                            java.lang.String value)

getFromHash

public final java.lang.String getFromHash(java.lang.String key)

getMarkableLevelByName

public final MarkableLevel getMarkableLevelByName(java.lang.String name,
                                                  boolean interactive)
Description copied from interface: DiscourseAPI
(API) Returns the MarkableLevel object of name levelName, or null if no MarkableLevel of this name exists.

Specified by:
getMarkableLevelByName in interface DiscourseAPI
Parameters:
name - The name of the MarkableLevel to return.
interactive - If true, a message box will be displayed if no MarkableLevel of name levelName could be found.
Returns:
The MarkableLevel object of name levelName, or null.

getCurrentMarkableChart

public final MarkableChart getCurrentMarkableChart()

getAllDiscourseElementIDs

public final java.lang.String[] getAllDiscourseElementIDs()

getDiscourseElementCount

public final int getDiscourseElementCount()
Description copied from interface: DiscourseAPI
(API) Returns the number of MMAX2DiscourseElement objects in this discourse.

Specified by:
getDiscourseElementCount in interface DiscourseAPI
Returns:
The number of MMAX2DiscourseElement objects in this discourse.

performNonGUIInitializations

public final void performNonGUIInitializations()

setCommonBasedataPath

public final void setCommonBasedataPath(java.lang.String path)

getCommonBasedataPath

public final java.lang.String getCommonBasedataPath()

requestDeleteBasedataElement

public final void requestDeleteBasedataElement(org.w3c.dom.Node deletee)

showEditBasedataElementWindow

public final void showEditBasedataElementWindow(java.util.ArrayList recentTexts,
                                                java.util.ArrayList recentAttributes,
                                                org.w3c.dom.Node referenceNode,
                                                int mode)

basedataTextAndAttributeSelected

public final void basedataTextAndAttributeSelected(org.w3c.dom.Node referenceNode,
                                                   int mode,
                                                   java.lang.String text,
                                                   java.lang.String attribute)

requestAddBasedataElement

public final void requestAddBasedataElement(org.w3c.dom.Node referenceNode,
                                            int mode)
This method is called by the MMAX2BasedataEditActionSelector upon selection of an 'add' action.


saveBasedata

public final void saveBasedata(java.lang.String newFileName)