lemurproject.indri.ui
Class RetUI

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by lemurproject.indri.ui.RetUI
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class RetUI
extends javax.swing.JPanel
implements java.awt.event.ActionListener

User interface for indri retrieval.

Version:
1.0
Author:
David Fisher
See Also:
Serialized Form

Nested Class Summary
private  class RetUI.DocTableListener
          Listener on the retrieved documents table that enables populating the document text frame with the selection of a document.
private  class RetUI.QueryTreeListener
          Listener for the query tree to update highlighting when the query node selection changes.
private  class RetUI.UIQueryNode
          Adapter for QueryAnnotationNode for populating the query tree display.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.lang.String aboutText
          About the GUI.
(package private)  java.lang.String acroreadProg
          external viewers Acrobat.exe or AcroRd32.exe
(package private)  java.util.Map annotations
          Map containing query annotations for highlighting.
(package private)  javax.swing.JTable answerAll
          Retrieved documents table
private  boolean blinking
          Semaphore for the blinker thread
(package private)  int currentDoc
          Index into result holders for the current document
(package private)  int currentDocId
          Result holder for currently selected document id
(package private)  ParsedDocument currentParsedDoc
          Result holder for parsed documents
private static java.awt.Cursor def
          cursors
(package private)  javax.swing.JFrame docHtmlFrame
          Frame for showing document html document
(package private)  javax.swing.JTextPane docHtmlPane
          Document html pane.
(package private)  int[] docids
          Result holder for document internal ids
(package private)  javax.swing.JTree docQueryTree
          Query tree display
(package private)  javax.swing.JFrame docTextFrame
          Frame for showing document text and query tree.
(package private)  javax.swing.JTextPane docTextPane
          Document text pane.
private  javax.swing.JList documents
          Enable multiple indexes
private  javax.swing.DefaultListModel documentsModel
          hold the file names
(package private)  QueryEnvironment env
          Indri query environment for retrieval.
(package private)  boolean envInit
          Flag for whether or not the query environment has been initialized.
private  javax.swing.JFileChooser fc
          File chooser starting in current directory
(package private)  java.lang.Thread getDocHtmlThread
          getDocHtml Thread
(package private)  java.lang.Thread getDocTextThread
          getDocText Thread
(package private)  javax.swing.JButton go
          Search and Clear buttons
private static java.lang.String helpFile
          Help file for the application
private  javax.swing.JFrame helpFrame
          Frame for help window
private static java.lang.String iconFile
          Little lemur icon
private  javax.swing.JList indexes
          Enable multiple indexes
private  javax.swing.DefaultListModel indexesModel
          hold the file names
private static java.awt.Color lightYellow
          colors
private static java.awt.Color linen
          colors
(package private)  int maxDocs
          Maximum number of documents to retrieve for a query
(package private)  java.lang.String[] names
          Result holder for document external ids
private static java.awt.Color navyBlue
          colors
(package private)  javax.swing.JTextField numDocs
          Number of documents to retrieve input
(package private)  java.lang.String powerpointProg
          external viewers Powerpnt.exe
(package private)  javax.swing.JLabel progress
          Progress indicator output
(package private)  javax.swing.JTextField query
          Query input
(package private)  QueryAnnotation results
          Result holder for query retrieval.
(package private)  java.lang.Thread runQuestionThread
          runQuestion Thread
(package private)  ScoredExtentResult[] scored
          Result holder for document scored extents
(package private)  javax.swing.JButton scoreDisplay
          Search and Clear buttons
(package private)  boolean showScores
          Are we showing scores?
(package private)  javax.swing.JLabel status
          Status line output
(package private)  javax.swing.JButton stop
          Search and Clear buttons
(package private)  java.lang.String[] titles
          Result holder for document titles
private static java.awt.Cursor wait
          cursors
(package private)  java.lang.String wordProg
          external viewers Word.exe
 
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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RetUI()
          Initialize the query environment and indexes model.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void altgetDocText()
          Populate the document text frame with the selected document.
private  java.lang.Thread blinker(java.lang.String s1, java.lang.String s2)
          Blink a pair of messages on the status line
private  void clearAll()
          Clear everything
private  void clearHighlight(javax.swing.text.StyledDocument myDoc, javax.swing.text.MutableAttributeSet highlight)
          Clear all highlighting markup in a styled document.
private static void createAndShowGUI()
          Make the containing frame, menubar, and an instance of RetUI.
protected static javax.swing.ImageIcon createImageIcon(java.lang.String path)
          Returns an ImageIcon, or null if the path was invalid.
 void error(java.lang.String s)
          Display an error message in the progress label.
 void getDocHtml()
          Populate a document text frame with html -- no highlighting.
 void getDocText()
           
private  void highlight(javax.swing.tree.DefaultMutableTreeNode query)
          Insert highlighting markup into a styled document, starting from the given node of the query tree.
private  void highlight(RetUI.UIQueryNode q, javax.swing.text.StyledDocument myDoc, javax.swing.text.MutableAttributeSet highlight)
          Highlight the current document in the document text pane with respect to the given query node.
 void init()
          Create the gui elements, including the help frame.
static void main(java.lang.String[] args)
          Fire it up.
private  javax.swing.tree.DefaultMutableTreeNode makeChildNode(QueryAnnotationNode query)
          Make a DefaultMutableTreeNode out of a QueryAnnotationNode.
private  void makeDocHtmlFrame()
          Make the frame for displaying html documents
private  javax.swing.JTable makeDocsTable()
          Make a JTable and associated DocsTableModel for containing query result sets.
private  void makeDocTextFrame()
          Make the frame for displaying highlighted retrieved documents with both document text and the query tree.
private  void makeHelp()
          Create the frame that shows the help file and render the html.
private  javax.swing.JMenuItem makeMenuItem(java.lang.String label)
          Make a menu item with appropriate colors and this as its listener.
private  javax.swing.tree.DefaultTreeModel makeTreeModel(QueryAnnotationNode query)
          Create a TreeModel from a QueryAnnotationNode.
 void openIndex()
          Present a file chooser to select an index to open.
 void openServer()
          Present an input dialog to obtain a hostname and optional port number.
 void removeIndex()
          Remove the selected index from the list.
 void runQuestion()
          Run the given query in a separate thread.
private  void setPaths()
          Set the paths to the external viewer programs
private  void spawnViewer()
          Spawn an external viewer for pdf, doc, or ppt (Win only)
private  java.lang.String trim(java.lang.String s)
          Strip leading pathname, if any.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fc

private final javax.swing.JFileChooser fc
File chooser starting in current directory


aboutText

private static final java.lang.String aboutText
About the GUI.

See Also:
Constant Field Values

helpFile

private static final java.lang.String helpFile
Help file for the application

See Also:
Constant Field Values

iconFile

private static final java.lang.String iconFile
Little lemur icon

See Also:
Constant Field Values

helpFrame

private javax.swing.JFrame helpFrame
Frame for help window


go

javax.swing.JButton go
Search and Clear buttons


stop

javax.swing.JButton stop
Search and Clear buttons


scoreDisplay

javax.swing.JButton scoreDisplay
Search and Clear buttons


status

javax.swing.JLabel status
Status line output


progress

javax.swing.JLabel progress
Progress indicator output


query

javax.swing.JTextField query
Query input


numDocs

javax.swing.JTextField numDocs
Number of documents to retrieve input


answerAll

javax.swing.JTable answerAll
Retrieved documents table


docTextFrame

javax.swing.JFrame docTextFrame
Frame for showing document text and query tree.


docTextPane

javax.swing.JTextPane docTextPane
Document text pane.


docHtmlFrame

javax.swing.JFrame docHtmlFrame
Frame for showing document html document


docHtmlPane

javax.swing.JTextPane docHtmlPane
Document html pane.


docQueryTree

javax.swing.JTree docQueryTree
Query tree display


env

QueryEnvironment env
Indri query environment for retrieval.


annotations

java.util.Map annotations
Map containing query annotations for highlighting.


results

QueryAnnotation results
Result holder for query retrieval.


scored

ScoredExtentResult[] scored
Result holder for document scored extents


currentParsedDoc

ParsedDocument currentParsedDoc
Result holder for parsed documents


currentDocId

int currentDocId
Result holder for currently selected document id


names

java.lang.String[] names
Result holder for document external ids


titles

java.lang.String[] titles
Result holder for document titles


docids

int[] docids
Result holder for document internal ids


currentDoc

int currentDoc
Index into result holders for the current document


maxDocs

int maxDocs
Maximum number of documents to retrieve for a query


envInit

boolean envInit
Flag for whether or not the query environment has been initialized.


documents

private javax.swing.JList documents
Enable multiple indexes


documentsModel

private javax.swing.DefaultListModel documentsModel
hold the file names


indexes

private javax.swing.JList indexes
Enable multiple indexes


indexesModel

private javax.swing.DefaultListModel indexesModel
hold the file names


lightYellow

private static final java.awt.Color lightYellow
colors


navyBlue

private static final java.awt.Color navyBlue
colors


linen

private static final java.awt.Color linen
colors


wait

private static java.awt.Cursor wait
cursors


def

private static java.awt.Cursor def
cursors


wordProg

java.lang.String wordProg
external viewers Word.exe


powerpointProg

java.lang.String powerpointProg
external viewers Powerpnt.exe


acroreadProg

java.lang.String acroreadProg
external viewers Acrobat.exe or AcroRd32.exe


showScores

boolean showScores
Are we showing scores?


getDocTextThread

volatile java.lang.Thread getDocTextThread
getDocText Thread


getDocHtmlThread

volatile java.lang.Thread getDocHtmlThread
getDocHtml Thread


runQuestionThread

volatile java.lang.Thread runQuestionThread
runQuestion Thread


blinking

private volatile boolean blinking
Semaphore for the blinker thread

Constructor Detail

RetUI

public RetUI()
Initialize the query environment and indexes model.

Method Detail

init

public void init()
Create the gui elements, including the help frame.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

clearAll

private void clearAll()
Clear everything


removeIndex

public void removeIndex()
Remove the selected index from the list.


openIndex

public void openIndex()
Present a file chooser to select an index to open. Open the index in the query environment.


openServer

public void openServer()
Present an input dialog to obtain a hostname and optional port number. Open the given server in the query environment.


runQuestion

public void runQuestion()
Run the given query in a separate thread.


setPaths

private void setPaths()
Set the paths to the external viewer programs


makeHelp

private void makeHelp()
Create the frame that shows the help file and render the html. Saves time when the user opens the help.


makeDocTextFrame

private void makeDocTextFrame()
Make the frame for displaying highlighted retrieved documents with both document text and the query tree.


makeDocHtmlFrame

private void makeDocHtmlFrame()
Make the frame for displaying html documents


spawnViewer

private void spawnViewer()
Spawn an external viewer for pdf, doc, or ppt (Win only)


altgetDocText

public void altgetDocText()
Populate the document text frame with the selected document. Highlight the document based on query matches.


getDocText

public void getDocText()

getDocHtml

public void getDocHtml()
Populate a document text frame with html -- no highlighting.


highlight

private void highlight(javax.swing.tree.DefaultMutableTreeNode query)
                throws java.lang.InterruptedException
Insert highlighting markup into a styled document, starting from the given node of the query tree. If the node is the root of the tree, recurse through the entire tree.

Parameters:
query - The query tree node to highlight
Throws:
java.lang.InterruptedException

clearHighlight

private void clearHighlight(javax.swing.text.StyledDocument myDoc,
                            javax.swing.text.MutableAttributeSet highlight)
Clear all highlighting markup in a styled document.

Parameters:
myDoc - The StyledDocument to highlight
highlight - The highlighting attributes

highlight

private void highlight(RetUI.UIQueryNode q,
                       javax.swing.text.StyledDocument myDoc,
                       javax.swing.text.MutableAttributeSet highlight)
                throws java.lang.InterruptedException
Highlight the current document in the document text pane with respect to the given query node.

Parameters:
q - The query node to highlight extents for
myDoc - The StyledDocument to highlight
highlight - The highlighting attributes
Throws:
java.lang.InterruptedException

makeTreeModel

private javax.swing.tree.DefaultTreeModel makeTreeModel(QueryAnnotationNode query)
Create a TreeModel from a QueryAnnotationNode.

Parameters:
query - The QueryAnnotationNode to use as the root of the tree
Returns:
A DefaultTreeModel rooted in query

makeChildNode

private javax.swing.tree.DefaultMutableTreeNode makeChildNode(QueryAnnotationNode query)
Make a DefaultMutableTreeNode out of a QueryAnnotationNode. Recursively insert all children of the query into the tree.

Parameters:
query - The QueryAnnotationNode to insert into the tree.
Returns:
a DefaultMutableTreeNode for this query.

blinker

private java.lang.Thread blinker(java.lang.String s1,
                                 java.lang.String s2)
Blink a pair of messages on the status line

Parameters:
s1 - The first message to display
s2 - The second message to display
Returns:
The Thread doing the blinking

error

public void error(java.lang.String s)
Display an error message in the progress label.

Parameters:
s - The error message to display.

trim

private java.lang.String trim(java.lang.String s)
Strip leading pathname, if any.


makeDocsTable

private javax.swing.JTable makeDocsTable()
Make a JTable and associated DocsTableModel for containing query result sets.

Returns:
The JTable with its model and listener initialized.

makeMenuItem

private javax.swing.JMenuItem makeMenuItem(java.lang.String label)
Make a menu item with appropriate colors and this as its listener.

Parameters:
label - The label for the menu item
Returns:
The menu item

createImageIcon

protected static javax.swing.ImageIcon createImageIcon(java.lang.String path)
Returns an ImageIcon, or null if the path was invalid.

Parameters:
path - the image file to load.
Returns:
an ImageIcon, or null if the path was invalid.

createAndShowGUI

private static void createAndShowGUI()
Make the containing frame, menubar, and an instance of RetUI. Initialize.


main

public static void main(java.lang.String[] args)
Fire it up.

Parameters:
args - ignored