Class MorphologyTool

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--ArborFrame
                                      |
                                      +--MorphologyTool
All Implemented Interfaces:
javax.accessibility.Accessible, org.xml.sax.ContentHandler, java.util.EventListener, java.awt.image.ImageObserver, org.xml.sax.ext.LexicalHandler, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class MorphologyTool
extends ArborFrame
implements javax.swing.event.ListSelectionListener, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler

The MorphologyTool is responsible for displaying morphological information in a top-level frame. Global searches for variants in the text can be performed by double-clicking an item from the right list. Dictionary lookup is accomplished by double-clicking on an item in the left list.

Version:
$2007-05-01 03:15:59 mdh$
Author:
Malcolm D. Hyman
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MorphologyTool(ContentOwner owner)
           
 
Method Summary
 void acquireFromDonatus()
          Acquires morphological data from Donatus.
 void addEntriesToDonatus()
          Adds new morphological entries to Donatus.
 boolean areFormsLoaded()
          Returns true if a morphology file has been loaded.
 org.w3c.dom.Document buildChangedMorphDOM()
          Builds a DOM of the user-modified morphological entries.
 org.w3c.dom.Document buildCompleteMorphDOM()
          Builds a DOM containing all morphological entries.
 void characters(char[] ch, int start, int length)
          This is part of the ContentHandler interface.
 void comment(char[] ch, int start, int length)
          These methods belong to the LexicalHandler interface.
 void dispose()
          Cleans up, when it's time for us to give up the ghost.
 void endCDATA()
           
 void endDocument()
           
 void endDTD()
           
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          This is part of the ContentHandler interface.
 void endEntity(java.lang.String name)
           
 void endPrefixMapping(java.lang.String prefix)
           
 void ensureFormsLoaded(java.lang.String lang)
          Tries to load the morphological data, if not already loaded.
 void extendMapping(java.lang.String formV, java.lang.String formB, java.lang.String formID, java.lang.String lang)
          Adds a new mapping of a basic and variant form.
 java.util.List getAllIdents(java.lang.String lang)
          Returns the the set of all used morphological identification labels.
 java.util.List getAllLemmata(java.lang.String lang)
          Returns a list of all known lemmata for a language.
 java.lang.String[] getBasicForms(java.lang.String form, java.lang.String lang)
          Returns the possible basic forms for a variant.
 java.lang.String getDecodedLemma(Language lang, PluggableFilter pf, java.lang.String s)
          If s is a transcoding via pf of a lemma, returns the lemma (in native encoding for the specified language).
 DonatusClient getDonatusClient()
          Obtains an interface for interacting with the Donatus morphology server.
 java.io.File getMorphSaveFile()
          Returns the local file to which modified morphology will by default be saved.
 java.lang.String[] getVariantForms(java.lang.String form, java.lang.String lang)
          Returns the known variant forms for a lemma.
 void ignorableWhitespace(char[] ch, int start, int length)
           
 boolean isDirty()
          Returns true if the morphology is "dirty" -- that is, if any items have been added since the last save.
 boolean isHidden()
          Returns true if the the morphology features for the content owner should be disabled.
 boolean isModified()
          Returns true if there are user-modified morphological data.
 void parseAcquired(java.io.ByteArrayInputStream bais)
          Parses XML acquired from Donatus.
 void popup(java.lang.String word, java.lang.String lang, org.w3c.dom.Node container, int count, ContentRenderPane content)
          Ensures that our frame is visible and initializes the JLists.
 void processingInstruction(java.lang.String target, java.lang.String data)
           
 void queryLoadUnparsed(java.net.URL url)
          Provides the user the option of loading unparsed items as a termlist.
 void serialize(org.w3c.dom.Document doc, java.io.File file)
          Serializes a DOM to a file sink.
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 void setHidden(boolean value)
          Sets the property that determines whether the morphology features for the content owner should be disabled.
 void showLog()
          Displays the log from Donatus.
 void skippedEntity(java.lang.String name)
           
 void startCDATA()
           
 void startDocument()
           
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
           
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          This is part of the ContentHandler interface.
 void startEntity(java.lang.String name)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String url)
           
 java.lang.String toString()
           
 void valueChanged(javax.swing.event.ListSelectionEvent evt)
          This method is required by ListSelectionListener.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

MorphologyTool

public MorphologyTool(ContentOwner owner)
Method Detail

getDecodedLemma

public java.lang.String getDecodedLemma(Language lang,
                                        PluggableFilter pf,
                                        java.lang.String s)
If s is a transcoding via pf of a lemma, returns the lemma (in native encoding for the specified language). Otherwise returns null.
Parameters:
lang - language
pf - a pluggable display filter
s - string to be tested

popup

public void popup(java.lang.String word,
                  java.lang.String lang,
                  org.w3c.dom.Node container,
                  int count,
                  ContentRenderPane content)
Ensures that our frame is visible and initializes the JLists.
Parameters:
word - word for which to display morphological information
lang - language code as per ISO 639
container - (outermost) container of word
count - token-type occurrence count for word
content - calling ContentRenderPane

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent evt)
This method is required by ListSelectionListener.
Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener

getBasicForms

public java.lang.String[] getBasicForms(java.lang.String form,
                                        java.lang.String lang)
Returns the possible basic forms for a variant. No attempt is made to load morphological data, if they are not already available. Returns an array consisting of a single item--the null string--if the form is not known.
Parameters:
form - variant form
lang - language code as per ISO 639
Returns:
array of basic forms
See Also:
getVariantForms(java.lang.String, java.lang.String)

getVariantForms

public java.lang.String[] getVariantForms(java.lang.String form,
                                          java.lang.String lang)
Returns the known variant forms for a lemma. No attempt is made to load morphological data, if they are not already available. Returns an empty array if the form is not known.
Parameters:
form - basic form
lang - language code as per ISO 639
Returns:
array of variant forms
See Also:
getBasicForms(java.lang.String, java.lang.String)

getAllLemmata

public java.util.List getAllLemmata(java.lang.String lang)
Returns a list of all known lemmata for a language.
Parameters:
lang - language code as per ISO 639
Returns:
list of lemmata

extendMapping

public void extendMapping(java.lang.String formV,
                          java.lang.String formB,
                          java.lang.String formID,
                          java.lang.String lang)
Adds a new mapping of a basic and variant form.
Parameters:
formV - variant form
formB - basic form
formID - morphological analysis
lang - language

ensureFormsLoaded

public void ensureFormsLoaded(java.lang.String lang)
Tries to load the morphological data, if not already loaded.
Parameters:
lang - language code as per ISO 639

areFormsLoaded

public boolean areFormsLoaded()
Returns true if a morphology file has been loaded.
Returns:
true if a morphology file has been loaded

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
This is part of the ContentHandler interface.
Specified by:
startElement in interface org.xml.sax.ContentHandler

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
This is part of the ContentHandler interface.
Specified by:
endElement in interface org.xml.sax.ContentHandler

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
This is part of the ContentHandler interface.
Specified by:
characters in interface org.xml.sax.ContentHandler

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

startDocument

public void startDocument()
Specified by:
startDocument in interface org.xml.sax.ContentHandler

endDocument

public void endDocument()
Specified by:
endDocument in interface org.xml.sax.ContentHandler

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String url)
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler

skippedEntity

public void skippedEntity(java.lang.String name)
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler

comment

public void comment(char[] ch,
                    int start,
                    int length)
These methods belong to the LexicalHandler interface.
Specified by:
comment in interface org.xml.sax.ext.LexicalHandler

endCDATA

public void endCDATA()
Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler

endDTD

public void endDTD()
Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler

endEntity

public void endEntity(java.lang.String name)
Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler

startCDATA

public void startCDATA()
Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler

startEntity

public void startEntity(java.lang.String name)
Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler

buildChangedMorphDOM

public org.w3c.dom.Document buildChangedMorphDOM()
Builds a DOM of the user-modified morphological entries.
Returns:
DOM (morphology doctype)

buildCompleteMorphDOM

public org.w3c.dom.Document buildCompleteMorphDOM()
Builds a DOM containing all morphological entries.
Returns:
DOM (morphology doctype)

serialize

public void serialize(org.w3c.dom.Document doc,
                      java.io.File file)
Serializes a DOM to a file sink.
Parameters:
doc - DOM
file - file to which XML is written

getMorphSaveFile

public java.io.File getMorphSaveFile()
Returns the local file to which modified morphology will by default be saved.
Returns:
default morphology file (null if not defined)

isDirty

public boolean isDirty()
Returns true if the morphology is "dirty" -- that is, if any items have been added since the last save.
Returns:
true if any unsaved items

getDonatusClient

public DonatusClient getDonatusClient()
Obtains an interface for interacting with the Donatus morphology server.
Returns:
Donatus client interface

addEntriesToDonatus

public void addEntriesToDonatus()
Adds new morphological entries to Donatus.

acquireFromDonatus

public void acquireFromDonatus()
Acquires morphological data from Donatus.

parseAcquired

public void parseAcquired(java.io.ByteArrayInputStream bais)
Parses XML acquired from Donatus.
Parameters:
bais - input stream for XML data

queryLoadUnparsed

public void queryLoadUnparsed(java.net.URL url)
Provides the user the option of loading unparsed items as a termlist.
Parameters:
url - URL to unparsed data (from Donatus server)

isHidden

public boolean isHidden()
Returns true if the the morphology features for the content owner should be disabled.
Returns:
true if morphology disabled

setHidden

public void setHidden(boolean value)
Sets the property that determines whether the morphology features for the content owner should be disabled.
Parameters:
value - true to disable morphology

isModified

public boolean isModified()
Returns true if there are user-modified morphological data.
Returns:
true if user added new morphological data

getAllIdents

public java.util.List getAllIdents(java.lang.String lang)
Returns the the set of all used morphological identification labels.
Parameters:
lang - language code as per ISO 639
Returns:
list of all morphological identifications

showLog

public void showLog()
Displays the log from Donatus.

dispose

public void dispose()
Cleans up, when it's time for us to give up the ghost.
Overrides:
dispose in class java.awt.Window

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component