weka.gui.extensions
Class PreferenceStructureVisualizer

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 weka.gui.extensions.PreferenceStructureVisualizer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, weka.gui.MainMenuExtension

public class PreferenceStructureVisualizer
extends javax.swing.JPanel
implements weka.gui.MainMenuExtension

PreferenceStructureVisualizer. This class draws the preference structure given a classifier and a query instance.

Date created: 08/07/2008

Version:
$Revision: 1.0 $
Author:
Jens Christian Hühn (huehn@gmx.net)
See Also:
JPanel, Serialized Form

Nested Class Summary
private  class PreferenceStructureVisualizer.AxisPanel
          Inner class to handle rendering the axis Date created: 08/07/2008
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JButton chooseButton
           
protected  java.awt.Dimension COMBO_SIZE
           
protected  javax.swing.JLabel dataFileLabel
           
protected  weka.gui.ExtensionFileFilter m_arffFileFilter
           
protected  PreferenceStructurePanel m_boundaryPanel
          the plotting panel
protected  javax.swing.JComboBox m_classAttBox
           
private  weka.classifiers.Classifier m_classifier
          the classifier to use
protected  weka.gui.GenericObjectEditor m_classifierEditor
           
protected  weka.gui.PropertyPanel m_ClassifierPanel
           
protected  weka.gui.visualize.ClassPanel m_classPanel
           
protected  javax.swing.JPanel m_controlPanel
           
protected  javax.swing.JButton m_copyToClipboardBtn
           
protected static boolean m_ExitIfNoWindowsOpen
          whether the exit if there are no more windows open
protected  javax.swing.JFileChooser m_FileChooser
          The file chooser for selecting arff files
protected  javax.swing.JButton m_GrayscaleBtn
           
protected  javax.swing.JComboBox m_LooBox
           
protected  int m_plotAreaHeight
           
protected  int m_plotAreaWidth
           
protected  javax.swing.JButton m_startBut
           
private  weka.core.Instances m_trainingInstances
          the training instances
protected static int m_WindowCount
          the number of visualizer windows we have open.
private  PreferenceStructureVisualizer.AxisPanel m_xAxisPanel
           
private  PreferenceStructureVisualizer.AxisPanel m_yAxisPanel
           
private static long serialVersionUID
          for serialization
 
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
PreferenceStructureVisualizer()
          Creates a new PreferenceStructureVisualizer instance.
 
Method Summary
private  void computeBounds()
          Sets up the bounds on our x and y axes to fit the dataset.
private  void configureForClassAttribute()
          Set up the class values combo boxes
static void createNewVisualizerWindow(weka.classifiers.Classifier classifier, weka.core.Instances instances)
          Creates a new GUI window with all of the PreferenceStructureVisualizer trappings,
 void fillFrame(java.awt.Component frame)
          Fills the frame with life, like adding components, window listeners, setting size, location, etc.
 java.awt.event.ActionListener getActionListener(javax.swing.JFrame owner)
          If the extension has a custom ActionListener for the menu item, then it must be returned here.
static boolean getExitIfNoWindowsOpen()
          Gets whether System.exit gets called after the last window gets closed
 weka.core.Instances getInstances()
          Get the training instances
 java.lang.String getMenuTitle()
          Returns the name of the menu item.
 java.lang.String getSubmenuTitle()
          Returns the name of the submenu.
 void plotTrainingData()
          Plots the training data on-screen.
 void setClassifier(weka.classifiers.Classifier newClassifier)
          Set a classifier to use
private  void setControlEnabledStatus(boolean status)
          Set the enabled status of the controls
static void setExitIfNoWindowsOpen(boolean value)
          Sets whether System.exit gets called when no more windows are open.
 void setInstances(weka.core.Instances inst)
          Set the training instances
 void setInstancesFromFileQ()
          Queries the user for a file to load instances from, then loads the instances in a background process.
 int setUpBoundaryPanel()
          Sets up the BoundaryPanel object so that it is ready for plotting.
 void stopPlotting()
          Stops the plotting thread.
 
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, 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, 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

serialVersionUID

private static final long serialVersionUID
for serialization

See Also:
Constant Field Values

m_WindowCount

protected static int m_WindowCount
the number of visualizer windows we have open.


m_ExitIfNoWindowsOpen

protected static boolean m_ExitIfNoWindowsOpen
whether the exit if there are no more windows open


m_trainingInstances

private weka.core.Instances m_trainingInstances
the training instances


m_classifier

private weka.classifiers.Classifier m_classifier
the classifier to use


m_plotAreaWidth

protected int m_plotAreaWidth

m_plotAreaHeight

protected int m_plotAreaHeight

m_boundaryPanel

protected PreferenceStructurePanel m_boundaryPanel
the plotting panel


m_classAttBox

protected javax.swing.JComboBox m_classAttBox

m_LooBox

protected javax.swing.JComboBox m_LooBox

COMBO_SIZE

protected java.awt.Dimension COMBO_SIZE

m_startBut

protected javax.swing.JButton m_startBut

m_GrayscaleBtn

protected javax.swing.JButton m_GrayscaleBtn

m_copyToClipboardBtn

protected javax.swing.JButton m_copyToClipboardBtn

m_controlPanel

protected javax.swing.JPanel m_controlPanel

m_classPanel

protected weka.gui.visualize.ClassPanel m_classPanel

m_xAxisPanel

private PreferenceStructureVisualizer.AxisPanel m_xAxisPanel

m_yAxisPanel

private PreferenceStructureVisualizer.AxisPanel m_yAxisPanel

m_classifierEditor

protected weka.gui.GenericObjectEditor m_classifierEditor

m_ClassifierPanel

protected weka.gui.PropertyPanel m_ClassifierPanel

m_FileChooser

protected javax.swing.JFileChooser m_FileChooser
The file chooser for selecting arff files


m_arffFileFilter

protected weka.gui.ExtensionFileFilter m_arffFileFilter

dataFileLabel

protected javax.swing.JLabel dataFileLabel

chooseButton

protected javax.swing.JButton chooseButton
Constructor Detail

PreferenceStructureVisualizer

public PreferenceStructureVisualizer()
Creates a new PreferenceStructureVisualizer instance.

Method Detail

setControlEnabledStatus

private void setControlEnabledStatus(boolean status)
Set the enabled status of the controls

Parameters:
status - a boolean value

setClassifier

public void setClassifier(weka.classifiers.Classifier newClassifier)
                   throws java.lang.Exception
Set a classifier to use

Parameters:
newClassifier - the classifier to use
Throws:
java.lang.Exception - if an error occurs

computeBounds

private void computeBounds()
Sets up the bounds on our x and y axes to fit the dataset. Also repaints the x and y axes.


getInstances

public weka.core.Instances getInstances()
Get the training instances

Returns:
the training instances

setInstances

public void setInstances(weka.core.Instances inst)
                  throws java.lang.Exception
Set the training instances

Parameters:
inst - the instances to use
Throws:
java.lang.Exception

configureForClassAttribute

private void configureForClassAttribute()
Set up the class values combo boxes


setInstancesFromFileQ

public void setInstancesFromFileQ()
Queries the user for a file to load instances from, then loads the instances in a background process. This is done in the IO thread, and an error message is popped up if the IO thread is busy.


setUpBoundaryPanel

public int setUpBoundaryPanel()
                       throws java.lang.Exception
Sets up the BoundaryPanel object so that it is ready for plotting.

Returns:
an error code:
0 - SUCCESS
1 - ERROR - Kernel bandwidth < 0
2 - ERROR - Kernel bandwidth >= number of training instances.
Throws:
java.lang.Exception

plotTrainingData

public void plotTrainingData()
                      throws java.lang.Exception
Plots the training data on-screen. Also does all of the setup required for this to work.

Throws:
java.lang.Exception

stopPlotting

public void stopPlotting()
Stops the plotting thread.


setExitIfNoWindowsOpen

public static void setExitIfNoWindowsOpen(boolean value)
Sets whether System.exit gets called when no more windows are open.

Parameters:
value - if TRUE then a System.exit call is ossued after the last window gets closed.

getExitIfNoWindowsOpen

public static boolean getExitIfNoWindowsOpen()
Gets whether System.exit gets called after the last window gets closed

Returns:
TRUE if System.exit gets called after last window got closed.

createNewVisualizerWindow

public static void createNewVisualizerWindow(weka.classifiers.Classifier classifier,
                                             weka.core.Instances instances)
                                      throws java.lang.Exception
Creates a new GUI window with all of the PreferenceStructureVisualizer trappings,

Parameters:
classifier - The classifier to use in the new window. May be null.
instances - The dataset to visualize on in the new window. May be null.
Throws:
java.lang.Exception

fillFrame

public void fillFrame(java.awt.Component frame)
Description copied from interface: weka.gui.MainMenuExtension
Fills the frame with life, like adding components, window listeners, setting size, location, etc. The frame object can be either derived from JFrame or from JInternalFrame. This method is only called in case getActionListener() returns null.

Specified by:
fillFrame in interface weka.gui.MainMenuExtension
Parameters:
frame - the frame object to embed components, etc.
See Also:
MainMenuExtension.getActionListener(JFrame), JFrame, JInternalFrame

getActionListener

public java.awt.event.ActionListener getActionListener(javax.swing.JFrame owner)
Description copied from interface: weka.gui.MainMenuExtension
If the extension has a custom ActionListener for the menu item, then it must be returned here. Having a custom ActionListener also means that the component handles any frame by itself.

Specified by:
getActionListener in interface weka.gui.MainMenuExtension
Parameters:
owner - the owner of potential dialogs
Returns:
a custom ActionListener, can be null
See Also:
MainMenuExtension.fillFrame(Component)

getMenuTitle

public java.lang.String getMenuTitle()
Description copied from interface: weka.gui.MainMenuExtension
Returns the name of the menu item.

Specified by:
getMenuTitle in interface weka.gui.MainMenuExtension
Returns:
the name of the menu item.

getSubmenuTitle

public java.lang.String getSubmenuTitle()
Description copied from interface: weka.gui.MainMenuExtension
Returns the name of the submenu. If there is no submenu necessary then the return value is null.

Specified by:
getSubmenuTitle in interface weka.gui.MainMenuExtension
Returns:
the title of the submenu or null if no submenu