weka.gui.visualize
Class MatrixPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byweka.gui.visualize.MatrixPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class MatrixPanel
extends javax.swing.JPanel

This panel displays a plot matrix of the user selected attributes of a given data set. The datapoints are coloured using a discrete colouring set if the user has selected a nominal attribute for colouring. If the user has selected a numeric attribute then the datapoints are coloured using a colour spectrum ranging from blue to red (low values to high). Datapoints missing a class value are displayed in black.

Version:
$Revision: 1.7 $
Author:
Ashraf M. Kibriya (amk14@cs.waikato.ac.nz)
See Also:
Serialized Form

Nested Class Summary
private  class MatrixPanel.Plot
          Internal class responsible for displaying the actual matrix Requires the internal data fields of the parent class to be properly initialized before being created
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  int datapointSize
          This stores the size of the datapoint
private  javax.swing.ButtonGroup distGroup
          Button group for subsampling radio buttons
private  java.awt.Font f
          font used in column and row names
private  java.awt.Color fontColor
          color for the font used in column and row names
private  int[][] jitterVals
          Array containing precalculated jitter values
protected  javax.swing.JSplitPane jp
          Split pane for splitting the matrix and the buttons and bars
protected  javax.swing.JList m_attribList
          The list for selecting the attributes to display the plot matrix
protected  javax.swing.JComboBox m_classAttrib
          The combo box to allow user to select the colouring attribute
private  int m_classIndex
          This contains the index of the currently selected colouring attribute
private  FastVector m_colorList
          Contains discrete colours for colouring for nominal attributes
protected  ClassPanel m_cp
          The panel that displays the legend of the colouring attribute
protected  Instances m_data
          The dataset for which this panel will display the plot matrix for
private static java.awt.Color[] m_defaultColors
          default colour list
protected  javax.swing.JSlider m_jitter
          The slider to add jitter to the plots
protected  javax.swing.JScrollPane m_js
          The scroll pane to scrolling the matrix
private  boolean[][] m_missing
          Contains true for each value that is missing, for each instance
private  java.awt.Dimension m_plotLBSizeD
          Stores the maximum size for PlotSize label to keep it's size constant
protected  javax.swing.JSlider m_plotSize
          The slider to adjust the size of the cells in the matrix
private  javax.swing.JLabel m_plotSizeLb
          Displays the current size beside the slider bar for cell size
private  MatrixPanel.Plot m_plotsPanel
          The that panel contains the actual matrix
private  int[] m_pointColors
          This is an array cache for the colour of each of the instances depending on the colouring attribute.
private  java.awt.Dimension m_pointLBSizeD
          Stores the maximum size for PointSize label to keep it's size constant
private  int[][] m_points
          This is a local array cache for all the instance values for faster rendering
protected  javax.swing.JSlider m_pointSize
          The slider to adjust the size of the datapoints
private  javax.swing.JLabel m_pointSizeLb
          Displays the current size beside the slider bar for point size
protected  javax.swing.JButton m_resampleBt
          The label for resample percentage
protected  javax.swing.JTextField m_resamplePercent
          The text area for percentage to resample data
protected  javax.swing.JTextField m_rseed
          Random seed for random subsample
protected  javax.swing.JButton m_selAttrib
          The button to display a window to select attributes
private  int[] m_selectedAttribs
          This array contains the indices of the attributes currently selected
private  int[][] m_type
          This array contains:
m_type[0][i] = [type of attribute, nominal, string or numeric]
m_type[1][i] = [number of discrete values of nominal or string attribute
or same as m_type[0][i] for numeric attribute]
protected  javax.swing.JButton m_updateBt
          The button that updates the display to reflect the changes made by the user.
protected  javax.swing.JPanel optionsPanel
          The panel that contains all the buttons and tools, i.e. resize, jitter bars and sub-sampling buttons etc on the bottom of the panel
protected  javax.swing.JRadioButton origDist
          For selecting same class distribution in the subsample as in the input
private  java.util.Random rnd
          For adding random jitter
protected  javax.swing.JRadioButton unifDist
          For selecting uniform class distribution in the subsample
 
Fields inherited from class javax.swing.JPanel
 
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.Container
 
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
MatrixPanel()
          Constructor
 
Method Summary
 void initInternalFields()
          Initializes internal data fields, i.e. data values, type, missing and color cache arrays
static void main(java.lang.String[] args)
          Main method for testing this class
 void setInstances(Instances newInst)
          This method changes the Instances object of this class to a new one.
 void setPercent()
          Calculates the percentage to resample
 void setupAttribLists()
          Sets up the UI's attributes lists
 
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, getVisibleRect, getWidth, 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_plotsPanel

private final MatrixPanel.Plot m_plotsPanel
The that panel contains the actual matrix


m_cp

protected final ClassPanel m_cp
The panel that displays the legend of the colouring attribute


optionsPanel

protected javax.swing.JPanel optionsPanel
The panel that contains all the buttons and tools, i.e. resize, jitter bars and sub-sampling buttons etc on the bottom of the panel


jp

protected javax.swing.JSplitPane jp
Split pane for splitting the matrix and the buttons and bars


m_updateBt

protected javax.swing.JButton m_updateBt
The button that updates the display to reflect the changes made by the user. E.g. changed attribute set for the matrix


m_selAttrib

protected javax.swing.JButton m_selAttrib
The button to display a window to select attributes


m_data

protected Instances m_data
The dataset for which this panel will display the plot matrix for


m_attribList

protected javax.swing.JList m_attribList
The list for selecting the attributes to display the plot matrix


m_js

protected final javax.swing.JScrollPane m_js
The scroll pane to scrolling the matrix


m_classAttrib

protected javax.swing.JComboBox m_classAttrib
The combo box to allow user to select the colouring attribute


m_plotSize

protected javax.swing.JSlider m_plotSize
The slider to adjust the size of the cells in the matrix


m_pointSize

protected javax.swing.JSlider m_pointSize
The slider to adjust the size of the datapoints


m_jitter

protected javax.swing.JSlider m_jitter
The slider to add jitter to the plots


rnd

private java.util.Random rnd
For adding random jitter


jitterVals

private int[][] jitterVals
Array containing precalculated jitter values


datapointSize

private int datapointSize
This stores the size of the datapoint


m_resamplePercent

protected javax.swing.JTextField m_resamplePercent
The text area for percentage to resample data


m_resampleBt

protected javax.swing.JButton m_resampleBt
The label for resample percentage


m_rseed

protected javax.swing.JTextField m_rseed
Random seed for random subsample


origDist

protected javax.swing.JRadioButton origDist
For selecting same class distribution in the subsample as in the input


unifDist

protected javax.swing.JRadioButton unifDist
For selecting uniform class distribution in the subsample


distGroup

private javax.swing.ButtonGroup distGroup
Button group for subsampling radio buttons


m_plotSizeLb

private final javax.swing.JLabel m_plotSizeLb
Displays the current size beside the slider bar for cell size


m_pointSizeLb

private final javax.swing.JLabel m_pointSizeLb
Displays the current size beside the slider bar for point size


m_selectedAttribs

private int[] m_selectedAttribs
This array contains the indices of the attributes currently selected


m_classIndex

private int m_classIndex
This contains the index of the currently selected colouring attribute


m_points

private int[][] m_points
This is a local array cache for all the instance values for faster rendering


m_pointColors

private int[] m_pointColors
This is an array cache for the colour of each of the instances depending on the colouring attribute. If the colouring attribute is nominal then it contains the index of the colour in our colour list. Otherwise, for numeric colouring attribute, it contains the precalculated red component for each instance's colour


m_missing

private boolean[][] m_missing
Contains true for each value that is missing, for each instance


m_type

private int[][] m_type
This array contains:
m_type[0][i] = [type of attribute, nominal, string or numeric]
m_type[1][i] = [number of discrete values of nominal or string attribute
or same as m_type[0][i] for numeric attribute]


m_plotLBSizeD

private java.awt.Dimension m_plotLBSizeD
Stores the maximum size for PlotSize label to keep it's size constant


m_pointLBSizeD

private java.awt.Dimension m_pointLBSizeD
Stores the maximum size for PointSize label to keep it's size constant


m_colorList

private FastVector m_colorList
Contains discrete colours for colouring for nominal attributes


m_defaultColors

private static final java.awt.Color[] m_defaultColors
default colour list


fontColor

private final java.awt.Color fontColor
color for the font used in column and row names


f

private final java.awt.Font f
font used in column and row names

Constructor Detail

MatrixPanel

public MatrixPanel()
Constructor

Method Detail

initInternalFields

public void initInternalFields()
Initializes internal data fields, i.e. data values, type, missing and color cache arrays


setupAttribLists

public void setupAttribLists()
Sets up the UI's attributes lists


setPercent

public void setPercent()
Calculates the percentage to resample


setInstances

public void setInstances(Instances newInst)
This method changes the Instances object of this class to a new one. It also does all the necessary initializations for displaying the panel. This must be called before trying to display the panel.

Parameters:
newInst - The new set of Instances

main

public static void main(java.lang.String[] args)
Main method for testing this class