Class Cairo

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JSplitPane
                          |
                          +--Cairo

public class Cairo
extends javax.swing.JSplitPane

The Cairo object lies at the heart of the package: it manages the top-level layout of the GUI and keeps track of all other objects. The main() method is implemented here so Cairo is executable as a standalone application; it creates and executes a CairoApp. In order to embed Cairo in a web page, embed a CairoApplet object instead.

Version:
0.95
Author:
Mike Jahr
See Also:
CairoApp, CairoApplet, CairoWrap, Serialized Form

Inner Class Summary
protected static class Cairo.AppCloser
          Trivial listener class which calls System.exit() when its window is closed.
 
Inner classes inherited from class javax.swing.JSplitPane
javax.swing.JSplitPane.AccessibleJSplitPane
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static java.lang.String ALIGN_SUFFIX
          Suffix for alignment files.
static java.lang.String BYLINE
          Author information.
static java.lang.String DEFAULT_ALIGN_DIR
          Default directory to search for alignment files.
static int DEFAULT_HEIGHT
          Default height of Cairo window; overridden in applet mode.
static int DEFAULT_SENTENCE_AXIS
          The default orientation of the sentences.
static int DEFAULT_WIDTH
          Default width of Cairo window; overridden in applet mode.
static java.lang.String INDEX_FILE_NAME
          Name of index file to use to list directory contents when running in applet mode.
static int MIN_HEIGHT
          Default height of Cairo window; overridden in applet mode.
static int MIN_WIDTH
          Default width of Cairo window; overridden in applet mode.
static java.lang.String VERSION
          Version information.
 
Fields inherited from class javax.swing.JSplitPane
BOTTOM, CONTINUOUS_LAYOUT_PROPERTY, continuousLayout, DIVIDER, DIVIDER_SIZE_PROPERTY, dividerSize, HORIZONTAL_SPLIT, LAST_DIVIDER_LOCATION_PROPERTY, lastDividerLocation, LEFT, leftComponent, ONE_TOUCH_EXPANDABLE_PROPERTY, oneTouchExpandable, orientation, ORIENTATION_PROPERTY, RIGHT, rightComponent, TOP, VERTICAL_SPLIT
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
Cairo(CairoWrap incw)
          Creates and initializes a Cairo using the given CairoWrap.
 
Method Summary
 javax.swing.JMenu createFileMenu(Cairo inc)
          Required by the CairoWrap interface; returns a FileMenuApp.
protected  javax.swing.JMenuBar createMenuBar()
          Creates the menu bar and add all menus.
 Cairo getCairo()
          Required by the CairoWrap interface; returns this.
 java.lang.Thread getLoadThread()
          Returns a thread which is currently loading an alignment file, if any is currently executing.
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
 Translation getTrans()
          Returns the current Translation object.
protected  void init()
          Initializes the Cairo object and all its helping objects.
static void main(java.lang.String[] args)
          Wrapper for CairoApp.main.
 void openFile(java.io.File infile)
          Attempts to load the given alignment file by spawning a loader thread.
 void openURL(java.lang.String inurl)
          Attempts to open an alignment file at the url specified by the given string.
 void openURL(java.net.URL url)
          Attempts to load the alignment file at the given url by spawning a loader thread.
 void openURL(java.net.URL base, java.lang.String inurl)
          Attempts to open an alignment file at the url specified by the given string, with the given url as the base directory.
 void ReportError(java.lang.String err)
          Displays an error dialog with the given string.
 void setLoadThread(java.lang.Thread inthread)
          Updates the currently loading thread to reflect the given value.
 void setStreamVisible(int s, boolean vis)
          Shows or hides the given stream by calling Translation.setStreamVisible.
 void showFourUp()
          Displays all four tables simultaneously.
 void showHoriz()
          Displays sentences horizontally at the top of the window, with the tables below.
 void showOneUp()
          Displays tables one at a time; users select which table to view via a tabbed interface.
 void showTwoUp()
          Displays two tables at a time.
 void showVert()
          Displays sentences vertically on the left side of the window, with the tables on the right.
 void stop()
          Interrupts any threads which are still alive and performs any necessary cleanup.
 void updateStreams(java.lang.String s)
          Updates the streams menu to reflect the given string of streams by calling OptionMenu.updateStreams.
 void updateTables(Word w)
          Updates the probability tables using the given word.
 
Methods inherited from class javax.swing.JSplitPane
addImpl, getAccessibleContext, getBottomComponent, getDividerLocation, getDividerSize, getLastDividerLocation, getLeftComponent, getMaximumDividerLocation, getMinimumDividerLocation, getOrientation, getRightComponent, getTopComponent, getUI, getUIClassID, isContinuousLayout, isOneTouchExpandable, paintChildren, paramString, remove, remove, removeAll, resetToPreferredSizes, setBottomComponent, setContinuousLayout, setDividerLocation, setDividerLocation, setDividerSize, setLastDividerLocation, setLeftComponent, setOneTouchExpandable, setOrientation, setRightComponent, setTopComponent, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
Version information.

BYLINE

public static final java.lang.String BYLINE
Author information.

DEFAULT_SENTENCE_AXIS

public static final int DEFAULT_SENTENCE_AXIS
The default orientation of the sentences. For horizontal alignment use BoxLayout.X_AXIS, for vertical alignment use BoxLayout.Y_AXIS.

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
Default width of Cairo window; overridden in applet mode.

MIN_HEIGHT

public static final int MIN_HEIGHT
Default height of Cairo window; overridden in applet mode.

MIN_WIDTH

public static final int MIN_WIDTH
Default width of Cairo window; overridden in applet mode.

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
Default height of Cairo window; overridden in applet mode.

DEFAULT_ALIGN_DIR

public static final java.lang.String DEFAULT_ALIGN_DIR
Default directory to search for alignment files.

ALIGN_SUFFIX

public static final java.lang.String ALIGN_SUFFIX
Suffix for alignment files.

INDEX_FILE_NAME

public static final java.lang.String INDEX_FILE_NAME
Name of index file to use to list directory contents when running in applet mode.
See Also:
FileMenuApplet
Constructor Detail

Cairo

public Cairo(CairoWrap incw)
Creates and initializes a Cairo using the given CairoWrap. Pass a CairoApplet to make an applet, or a CairoApp to make a standalone application.
See Also:
CairoApplet
Method Detail

main

public static void main(java.lang.String[] args)
Wrapper for CairoApp.main.

stop

public void stop()
Interrupts any threads which are still alive and performs any necessary cleanup.

init

protected void init()
Initializes the Cairo object and all its helping objects. Sets up the gui, creates menus, and initializes translation and sentence objects.
See Also:
Translation, Sentence, createMenuBar()

createMenuBar

protected javax.swing.JMenuBar createMenuBar()
Creates the menu bar and add all menus. Uses CairoWrap.createFileMenu to get the relevent FileMenu.
See Also:
FileMenuApp, FileMenuApplet, OptionMenu, HelpMenu

getTrans

public Translation getTrans()
Returns the current Translation object.

createFileMenu

public javax.swing.JMenu createFileMenu(Cairo inc)
Required by the CairoWrap interface; returns a FileMenuApp.

getCairo

public Cairo getCairo()
Required by the CairoWrap interface; returns this.

getLoadThread

public java.lang.Thread getLoadThread()
Returns a thread which is currently loading an alignment file, if any is currently executing.

setLoadThread

public void setLoadThread(java.lang.Thread inthread)
Updates the currently loading thread to reflect the given value.

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class javax.swing.JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

updateTables

public void updateTables(Word w)
Updates the probability tables using the given word. If w == null it clears the tables.
See Also:
ProbTable

updateStreams

public void updateStreams(java.lang.String s)
Updates the streams menu to reflect the given string of streams by calling OptionMenu.updateStreams.

setStreamVisible

public void setStreamVisible(int s,
                             boolean vis)
Shows or hides the given stream by calling Translation.setStreamVisible.

showFourUp

public void showFourUp()
Displays all four tables simultaneously.

showTwoUp

public void showTwoUp()
Displays two tables at a time. Users can tab between translations and distortions, and n-grams and fertilities.

showOneUp

public void showOneUp()
Displays tables one at a time; users select which table to view via a tabbed interface.

showVert

public void showVert()
Displays sentences vertically on the left side of the window, with the tables on the right.

showHoriz

public void showHoriz()
Displays sentences horizontally at the top of the window, with the tables below.

openURL

public void openURL(java.lang.String inurl)
Attempts to open an alignment file at the url specified by the given string. If the argument does not represent a valid absolute url, displays an error and does nothing. Otherwise, it spawns a loader thread.
See Also:
openURL(URL), openURL(URL, String), openFile(File)

openURL

public void openURL(java.net.URL base,
                    java.lang.String inurl)
Attempts to open an alignment file at the url specified by the given string, with the given url as the base directory. If the arguments do not represent a valid url, displays an error and does nothing. Otherwise, it spawns a loader thread.
See Also:
openURL(URL), openURL(String), openFile(File)

openURL

public void openURL(java.net.URL url)
Attempts to load the alignment file at the given url by spawning a loader thread. If the argument does not represent a valid url, displays an error and does nothing.
See Also:
openURL(URL), openURL(String), openURL(URL, String)

openFile

public void openFile(java.io.File infile)
Attempts to load the given alignment file by spawning a loader thread. If the argument does not represent a valid file, displays an error and does nothing.
See Also:
openURL(URL), openURL(String), openURL(URL, String)

ReportError

public void ReportError(java.lang.String err)
Displays an error dialog with the given string.