weka.gui
Class ResultHistoryPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--weka.gui.ResultHistoryPanel
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class ResultHistoryPanel
extends JPanel

A component that accepts named stringbuffers and displays the name in a list box. When a name is right-clicked, a frame is popped up that contains the string held by the stringbuffer. Optionally a text component may be provided that will have it's text set to the named result text on a left-click.

Version:
$Revision: 1.15 $
Author:
Len Trigg (trigg@cs.waikato.ac.nz)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Hashtable m_FramedOutput
          A Hashtable mapping names to output text components
protected  boolean m_HandleRightClicks
          Let the result history list handle right clicks in the default manner---ie, pop up a window displaying the buffer
protected  JList m_List
          The list component
protected  DefaultListModel m_Model
          The list model
protected  Hashtable m_Objs
          A hashtable mapping names to arbitrary objects
protected  Hashtable m_Results
          A Hashtable mapping names to result buffers
protected  String m_SingleName
          The named result being viewed in the single-click display
protected  JTextComponent m_SingleText
          An optional component for single-click display
 
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
ResultHistoryPanel(JTextComponent text)
          Create the result history object
 
Method Summary
 void addObject(String name, Object o)
          Adds an object to the results list
 void addResult(String name, StringBuffer result)
          Adds a new result to the result list.
 JList getList()
          Gets the JList used by the results list
 String getNameAtIndex(int index)
          Gets the name of theitem in the list at the specified index
 StringBuffer getNamedBuffer(String name)
          Gets the named buffer
 Object getNamedObject(String name)
          Get the named object from the list
 StringBuffer getSelectedBuffer()
          Gets the buffer associated with the currently selected item in the list.
 String getSelectedName()
          Get the name of the currently selected item in the list
 Object getSelectedObject()
          Gets the object associated with the currently selected item in the list.
 ListSelectionModel getSelectionModel()
          Gets the selection model used by the results list.
static void main(String[] args)
          Tests out the result history from the command line.
 void openFrame(String name)
          Opens the named result in a separate frame.
 void removeResult(String name)
          Removes one of the result buffers from the history.
 void setHandleRightClicks(boolean tf)
          Set whether the result history list should handle right clicks or whether the parent object will handle them.
 void setSingle(String name)
          Sets the single-click display to view the named result.
 void updateResult(String name)
          Tells any component currently displaying the named result that the contents of the result text in the StringBuffer have been updated.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

m_SingleText

protected JTextComponent m_SingleText
An optional component for single-click display


m_SingleName

protected String m_SingleName
The named result being viewed in the single-click display


m_Model

protected DefaultListModel m_Model
The list model


m_List

protected JList m_List
The list component


m_Results

protected Hashtable m_Results
A Hashtable mapping names to result buffers


m_FramedOutput

protected Hashtable m_FramedOutput
A Hashtable mapping names to output text components


m_Objs

protected Hashtable m_Objs
A hashtable mapping names to arbitrary objects


m_HandleRightClicks

protected boolean m_HandleRightClicks
Let the result history list handle right clicks in the default manner---ie, pop up a window displaying the buffer

Constructor Detail

ResultHistoryPanel

public ResultHistoryPanel(JTextComponent text)
Create the result history object

Parameters:
text - the optional text component for single-click display
Method Detail

addResult

public void addResult(String name,
                      StringBuffer result)
Adds a new result to the result list.

Parameters:
name - the name to associate with the result
result - the StringBuffer that contains the result text

removeResult

public void removeResult(String name)
Removes one of the result buffers from the history. Any windows currently displaying the contents of the buffer are not affected.

Parameters:
name - the name of the buffer to remove.

addObject

public void addObject(String name,
                      Object o)
Adds an object to the results list

Parameters:
name - the name to associate with the object
o - the object

getNamedObject

public Object getNamedObject(String name)
Get the named object from the list

Returns:
the object or null if there is no object at this index

getSelectedObject

public Object getSelectedObject()
Gets the object associated with the currently selected item in the list.

Returns:
the object or null if there is no object corresponding to the current selection in the list

getNamedBuffer

public StringBuffer getNamedBuffer(String name)
Gets the named buffer

Returns:
the buffer or null if there are no items in the list

getSelectedBuffer

public StringBuffer getSelectedBuffer()
Gets the buffer associated with the currently selected item in the list.

Returns:
the buffer or null if there are no items in the list

getSelectedName

public String getSelectedName()
Get the name of the currently selected item in the list

Returns:
the name of the currently selected item or null if no item selected

getNameAtIndex

public String getNameAtIndex(int index)
Gets the name of theitem in the list at the specified index

Returns:
the name of item or null if there is no item at that index

setSingle

public void setSingle(String name)
Sets the single-click display to view the named result.

Parameters:
name - the name of the result to display.

openFrame

public void openFrame(String name)
Opens the named result in a separate frame.

Parameters:
name - the name of the result to open.

updateResult

public void updateResult(String name)
Tells any component currently displaying the named result that the contents of the result text in the StringBuffer have been updated.

Parameters:
name - the name of the result that has been updated.

getSelectionModel

public ListSelectionModel getSelectionModel()
Gets the selection model used by the results list.

Returns:
a value of type 'ListSelectionModel'

getList

public JList getList()
Gets the JList used by the results list

Returns:
the JList

setHandleRightClicks

public void setHandleRightClicks(boolean tf)
Set whether the result history list should handle right clicks or whether the parent object will handle them.

Parameters:
tf - false if parent object will handle right clicks

main

public static void main(String[] args)
Tests out the result history from the command line.

Parameters:
args - ignored