weka.gui.extensions
Class PreferenceStructurePanel

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

public class PreferenceStructurePanel
extends javax.swing.JPanel

PreferenceStructurePanel. A class to generate a visualization of a fuzzy preference structure. 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 PreferenceStructurePanel.PlotPanel
          small inner class for rendering the bitmap on to
protected  class PreferenceStructurePanel.PlotThread
           
 
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  weka.classifiers.Classifier m_classifier
          distribution classifier to use
protected  boolean m_classifierWasBuilt
          Flag marking that a classifier was built
protected  boolean m_Grayscale
          Switch between colored and grayscale output
protected  weka.core.Instance m_Instance
          The instance for which the preference structure shall be visualized
protected  java.lang.String m_latexCode
           
private  java.util.Vector m_listeners
          listeners to be notified when plot is complete
protected  weka.core.Instances m_LOOData
          The whole dataset without one instance which preference structure shall be visualized
protected  double m_maxX
           
protected  double m_maxY
           
protected  double m_minX
           
protected  double m_minY
           
protected  java.awt.Image m_osi
          used for offscreen drawing
protected  double m_pixHeight
           
protected  double m_pixWidth
           
private  PreferenceStructurePanel.PlotPanel m_plotPanel
          the actual plotting area
private  java.lang.Thread m_plotThread
          thread for running the plotting operation in
protected  boolean m_plotTrainingData
          plot the training data
protected  boolean m_stopPlotting
          Stop the plotting thread
protected  boolean m_stopReplotting
          Stop any replotting threads
protected  weka.core.Instances m_trainingData
          training data
protected  int m_xAttribute
           
protected  int m_yAttribute
           
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
PreferenceStructurePanel(int panelWidth, int panelHeight)
          Creates a new PreferenceStructurePanel instance.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener newListener)
          Register a listener to be notified when plotting completes
 void addMouseListener(java.awt.event.MouseListener l)
          Adds a mouse listener.
 boolean getPlotTrainingData()
          Returns true if training data is to be superimposed
protected  void initialize()
          Set up the off screen bitmap for rendering to
 void plotTrainingData()
          Render the training points on-screen.
 void removeActionListener(java.awt.event.ActionListener removeListener)
          Remove a listener
 void replot()
          Quickly replot the display using cached probability estimates
protected  void saveImage(java.lang.String fileName)
           
 void setClassifier(weka.classifiers.Classifier classifier)
          Set the classifier to use.
 void setPlotTrainingData(boolean pg)
          Set whether to superimpose the training data plot
 void setTrainingData(weka.core.Instances trainingData)
          Set the training data to use
 void setXAttribute(int xatt)
          Set the x attribute index
 void setYAttribute(int yatt)
          Set the y attribute index
 void start()
          Start the plotting thread
 void startPlotThread()
          Starts the plotting thread.
 void stopPlotting()
          Stop the plotting thread
private  void update()
          Update the rendered image.
 
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, 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_trainingData

protected weka.core.Instances m_trainingData
training data


m_LOOData

protected weka.core.Instances m_LOOData
The whole dataset without one instance which preference structure shall be visualized


m_Instance

protected weka.core.Instance m_Instance
The instance for which the preference structure shall be visualized


m_classifier

protected weka.classifiers.Classifier m_classifier
distribution classifier to use


m_classifierWasBuilt

protected boolean m_classifierWasBuilt
Flag marking that a classifier was built


m_Grayscale

protected boolean m_Grayscale
Switch between colored and grayscale output


m_xAttribute

protected int m_xAttribute

m_yAttribute

protected int m_yAttribute

m_minX

protected double m_minX

m_minY

protected double m_minY

m_maxX

protected double m_maxX

m_maxY

protected double m_maxY

m_latexCode

protected java.lang.String m_latexCode

m_pixHeight

protected double m_pixHeight

m_pixWidth

protected double m_pixWidth

m_osi

protected java.awt.Image m_osi
used for offscreen drawing


m_listeners

private java.util.Vector m_listeners
listeners to be notified when plot is complete


m_plotPanel

private PreferenceStructurePanel.PlotPanel m_plotPanel
the actual plotting area


m_plotThread

private java.lang.Thread m_plotThread
thread for running the plotting operation in


m_stopPlotting

protected boolean m_stopPlotting
Stop the plotting thread


m_stopReplotting

protected boolean m_stopReplotting
Stop any replotting threads


m_plotTrainingData

protected boolean m_plotTrainingData
plot the training data

Constructor Detail

PreferenceStructurePanel

public PreferenceStructurePanel(int panelWidth,
                                int panelHeight)
Creates a new PreferenceStructurePanel instance.

Parameters:
panelWidth - the width in pixels of the panel
panelHeight - the height in pixels of the panel
Method Detail

initialize

protected void initialize()
Set up the off screen bitmap for rendering to


stopPlotting

public void stopPlotting()
Stop the plotting thread


start

public void start()
           throws java.lang.Exception
Start the plotting thread

Throws:
java.lang.Exception - if an error occurs

plotTrainingData

public void plotTrainingData()
Render the training points on-screen.


update

private void update()
Update the rendered image.


setTrainingData

public void setTrainingData(weka.core.Instances trainingData)
                     throws java.lang.Exception
Set the training data to use

Parameters:
trainingData - the training data
Throws:
java.lang.Exception - if an error occurs

addActionListener

public void addActionListener(java.awt.event.ActionListener newListener)
Register a listener to be notified when plotting completes

Parameters:
newListener - the listener to add

removeActionListener

public void removeActionListener(java.awt.event.ActionListener removeListener)
Remove a listener

Parameters:
removeListener - the listener to remove

setClassifier

public void setClassifier(weka.classifiers.Classifier classifier)
Set the classifier to use.

Parameters:
classifier - the classifier to use

setXAttribute

public void setXAttribute(int xatt)
                   throws java.lang.Exception
Set the x attribute index

Parameters:
xatt - index of the attribute to use on the x axis
Throws:
java.lang.Exception - if an error occurs

setYAttribute

public void setYAttribute(int yatt)
                   throws java.lang.Exception
Set the y attribute index

Parameters:
yatt - index of the attribute to use on the y axis
Throws:
java.lang.Exception - if an error occurs

setPlotTrainingData

public void setPlotTrainingData(boolean pg)
Set whether to superimpose the training data plot

Parameters:
pg - a boolean value

getPlotTrainingData

public boolean getPlotTrainingData()
Returns true if training data is to be superimposed

Returns:
a boolean value

replot

public void replot()
Quickly replot the display using cached probability estimates


saveImage

protected void saveImage(java.lang.String fileName)

startPlotThread

public void startPlotThread()
Starts the plotting thread. Will also create it if necessary.


addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Adds a mouse listener.

Overrides:
addMouseListener in class java.awt.Component