Package 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:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible
public class ResultHistoryPanel extends javax.swing.JPanelA 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: 14497 $
- Author:
- Len Trigg (trigg@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceResultHistoryPanel.RDeleteListenerInterface for something to be notified when an entry in the list is deletedstatic classResultHistoryPanel.RKeyAdapterExtension of KeyAdapter that implements Serializable.static classResultHistoryPanel.RMouseAdapterExtension of MouseAdapter that implements Serializable.
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description ResultHistoryPanel(javax.swing.text.JTextComponent text)Create the result history object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObject(java.lang.String name, java.lang.Object o)Adds an object to the results list.voidaddOrOverwriteObject(java.lang.String name, java.lang.Object o)Adds an object to the result list.voidaddResult(java.lang.String name, java.lang.StringBuffer result)Adds a new result to the result list.voidclearResults()Removes all of the result buffers from the history.javax.swing.JListgetList()Gets the JList used by the results listjava.lang.StringgetNameAtIndex(int index)Gets the name of theitem in the list at the specified indexjava.lang.StringBuffergetNamedBuffer(java.lang.String name)Gets the named bufferjava.lang.ObjectgetNamedObject(java.lang.String name)Get the named object from the listjava.lang.StringBuffergetSelectedBuffer()Gets the buffer associated with the currently selected item in the list.java.lang.StringgetSelectedName()Get the name of the currently selected item in the listjava.lang.ObjectgetSelectedObject()Gets the object associated with the currently selected item in the list.javax.swing.ListSelectionModelgetSelectionModel()Gets the selection model used by the results list.static voidmain(java.lang.String[] args)Tests out the result history from the command line.voidopenFrame(java.lang.String name)Opens the named result in a separate frame.voidremoveResult(java.lang.String name)Removes one of the result buffers from the history.voidremoveResults(int[] selectedI)Remove the entries at the specified indices in the listvoidremoveResults(java.util.List<java.lang.String> entries)Remove the specified entries from the listvoidsetBackground(java.awt.Color c)Set the background color for this component and the listvoidsetDeleteListener(ResultHistoryPanel.RDeleteListener listener)Set a listener for deletions from the listvoidsetFont(java.awt.Font f)Set the font to use in the listvoidsetHandleRightClicks(boolean tf)Set whether the result history list should handle right clicks or whether the parent object will handle them.voidsetSelectedListValue(java.lang.String name)Set the selected list entry.voidsetSingle(java.lang.String name)Sets the single-click display to view the named result.voidupdateResult(java.lang.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, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Method Detail
-
setDeleteListener
public void setDeleteListener(ResultHistoryPanel.RDeleteListener listener)
Set a listener for deletions from the list- Parameters:
listener- the listener to set
-
addResult
public void addResult(java.lang.String name, java.lang.StringBuffer result)Adds a new result to the result list.- Parameters:
name- the name to associate with the resultresult- the StringBuffer that contains the result text
-
removeResults
public void removeResults(int[] selectedI)
Remove the entries at the specified indices in the list- Parameters:
selectedI- the entries to remove
-
removeResults
public void removeResults(java.util.List<java.lang.String> entries)
Remove the specified entries from the list- Parameters:
entries- the entries to remove
-
removeResult
public void removeResult(java.lang.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.
-
clearResults
public void clearResults()
Removes all of the result buffers from the history. Any windows currently displaying the contents of the buffer are not affected.
-
addObject
public void addObject(java.lang.String name, java.lang.Object o)Adds an object to the results list. If an object with the same name already exists, then a number is appended to the end of the name to make it unique.- Parameters:
name- the name to associate with the objecto- the object
-
addOrOverwriteObject
public void addOrOverwriteObject(java.lang.String name, java.lang.Object o)Adds an object to the result list. Overwrites any exsiting object with the same name- Parameters:
name- the name to associate with the objecto- the object
-
getNamedObject
public java.lang.Object getNamedObject(java.lang.String name)
Get the named object from the list- Parameters:
name- the name of the item to retrieve the stored object for- Returns:
- the object or null if there is no object at this index
-
getSelectedObject
public java.lang.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 java.lang.StringBuffer getNamedBuffer(java.lang.String name)
Gets the named buffer- Returns:
- the buffer or null if there are no items in the list
-
getSelectedBuffer
public java.lang.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 java.lang.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 java.lang.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(java.lang.String name)
Sets the single-click display to view the named result.- Parameters:
name- the name of the result to display.
-
setSelectedListValue
public void setSelectedListValue(java.lang.String name)
Set the selected list entry. Note, does not update the single click display to the corresponding named result - use setSingle() to set the selected list entry and view the corresponding result- Parameters:
name- the name of the list entry to be selected
-
openFrame
public void openFrame(java.lang.String name)
Opens the named result in a separate frame.- Parameters:
name- the name of the result to open.
-
updateResult
public void updateResult(java.lang.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 javax.swing.ListSelectionModel getSelectionModel()
Gets the selection model used by the results list.- Returns:
- a value of type 'ListSelectionModel'
-
getList
public javax.swing.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
-
setBackground
public void setBackground(java.awt.Color c)
Set the background color for this component and the list- Overrides:
setBackgroundin classjavax.swing.JComponent- Parameters:
c- the background color to use
-
setFont
public void setFont(java.awt.Font f)
Set the font to use in the list- Overrides:
setFontin classjavax.swing.JComponent- Parameters:
f- the font to use
-
main
public static void main(java.lang.String[] args)
Tests out the result history from the command line.- Parameters:
args- ignored
-
-