org.knime.base.node.viz.plotter.scatter
Class ScatterPlotter

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 org.knime.base.node.viz.plotter.AbstractPlotter
                      extended by org.knime.base.node.viz.plotter.basic.BasicPlotter
                          extended by org.knime.base.node.viz.plotter.columns.TwoColumnPlotter
                              extended by org.knime.base.node.viz.plotter.scatter.ScatterPlotter
All Implemented Interfaces:
ComponentListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, HiLiteListener
Direct Known Subclasses:
DendrogramPlotter, LinePlotter, LinRegLinePlotter, PolyRegLineScatterPlotter, ScatterMatrixPlotter

public class ScatterPlotter
extends TwoColumnPlotter

Maps the two selected columns to the screen coordinates. The resulting points in 2-dimensional space are represented by DotInfos, which are stored in a DotInfoArray which is then passed to the ScatterPlotterDrawingPane. For nominal values it is typically that many points are on the same coordinate which leads to overplotting. One possible solution is to jitter the points around the original point, to visualize that many points are on the same coordinate. The jittering for nominal values is done here.

Author:
Fabian Dill, University of Konstanz
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.knime.base.node.viz.plotter.AbstractPlotter
AbstractPlotter.MovingMouseListener, AbstractPlotter.SelectionMouseListener, AbstractPlotter.ZoomMouseListener
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.knime.base.node.viz.plotter.AbstractPlotter
DEFAULT_ZOOM_FACTOR, FADE_UNHILITED, HIDE_UNHILITED, SHOW_ALL, SHOW_HIDE
 
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
ScatterPlotter()
          Default constructor with ScatterPlotterDrawingPane and ScatterPlotterProperties.
ScatterPlotter(AbstractDrawingPane panel, AbstractPlotterProperties properties)
          Construction kit constructor to construct a customized plotter, registeres all necessary listeners.
 
Method Summary
protected  void calculateCoordinates(DotInfoArray dotsArray)
          Given the actual size of the drawing pane, the actual zoom factor, and min/max values it calculates the screen coordinates for each dot info in the array passed in.
 void clearSelection()
          Clears current selection.
 void dispose()
          Notifies the plotter that it is not needed any more and can clean up all data and references it holds.
 void fillPopupMenu(JPopupMenu popupMenu)
          The inherited hilite menu from the AbstractPlotter and the show all, fade or hide unhilited menu.
 int getDotSize()
           
 Action getFadeAction()
          The ScatterPlotter adds the posssibility to show, fade or hide unhilited dots and this is the fade unhilited action.
 Action getHideAction()
          The ScatterPlotter adds the posssibility to show, fade or hide unhilited dots and this is the hide unhilited action.
protected  int getJitterRate()
           
protected  int getMappedXValue(DataCell x)
          
protected  int getMappedYValue(DataCell y)
          
 Action getShowAllAction()
          The ScatterPlotter adds the posssibility to show, fade or hide unhilited dots and this is the show all action.
 JMenu getShowHideMenu()
          The ScatterPlotter adds the posssibility to show, fade or hide unhilited dots and this is the complete menu to hide, fade.
 void hiLite(KeyEvent event)
          Invoked when some item(s) were hilit.
 void hiLiteSelected()
          Is called from the menu entry hilite selected.
protected  boolean isHideMode()
           
protected  boolean isScatterPlotterDrawingPane()
           
protected  boolean isScatterPlotterProperties()
           
protected  void jitterDots(DotInfo[] dots, int xAxisJitterRange, int yAxisJitterRange)
          Jitters the dots according to the kind of axis and there values.
 void reset()
          Passes an empty DotInfoArray to the .ScatterPlotterDrawingPane.
 void selectClickedElement(Point p)
          Implementing classes mayxselect the elements depending on the clicked position.
 void selectElementsIn(Rectangle selectionRectangle)
          Implementing classes may select the elements in the selection rectangle obtained from the mouse dragging in selection mode.
 void setDotSize(int dotSize)
          Sets the size of the dots and sets a tick offset to both axes to ensure that the points are always completely visible.
 void setHideMode(boolean hide)
           
protected  void setJitterRate(int jitterRate)
           
 void unHiLite(KeyEvent event)
          Invoked when some item(s) were unhilit.
 void unHiLiteAll(KeyEvent event)
          Invoked, when everything (all rows) are unhilit.
 void unHiLiteSelected()
          Is called by the menu entry unhilite selected.
 void updatePaintModel()
          The data points of the data to visulaize are mapped to screen coordinates, represented by DotInfo and are passed in a DotInfoArray to the .ScatterPlotterDrawingPane.
 void updateSize()
          Updates the size by mapping the domain values of the BasicDrawingElements to the drawing pane's dimension.
 
Methods inherited from class org.knime.base.node.viz.plotter.columns.TwoColumnPlotter
getSelectedXColumn, getSelectedXColumnIndex, getSelectedYColumn, getSelectedYColumnIndex, setDataProvider, setSelectableColumns
 
Methods inherited from class org.knime.base.node.viz.plotter.basic.BasicPlotter
addBasicDrawingElement, addEllipse, addLine, addLine, addLine, addLine, addRectangle, addText
 
Methods inherited from class org.knime.base.node.viz.plotter.AbstractPlotter
addMouseListener, componentHidden, componentMoved, componentResized, componentShown, createNominalXCoordinate, createNominalYCoordinate, createXCoordinate, createXCoordinate, createYCoordinate, delegateAddHiLiteListener, delegateGetHiLitKeys, delegateHiLite, delegateHiLite, delegateIsHiLit, delegateIsHiLit, delegateRemoveAllHiLiteListeners, delegateRemoveHiLiteListener, delegateUnHiLite, delegateUnHiLite, delegateUnHiLiteAll, fitToScreen, getClearHiliteAction, getCurrentMouseListener, getDataArrayIdx, getDataProvider, getDrawingPane, getDrawingPaneDimension, getHiliteAction, getHiLiteMenu, getProperties, getScreenYCoordinate, getUnhiliteAction, getXAxis, getYAxis, removeMouseListener, setAntialiasing, setDataArrayIdx, setHeight, setHiLiteHandler, setPreserve, setXAxis, setYAxis, updateAxisLength, zoomByClick, zoomByWindow
 
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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, 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
 

Constructor Detail

ScatterPlotter

public ScatterPlotter(AbstractDrawingPane panel,
                      AbstractPlotterProperties properties)
Construction kit constructor to construct a customized plotter, registeres all necessary listeners.

Parameters:
panel - the drawing pane
properties - the properties

ScatterPlotter

public ScatterPlotter()
Default constructor with ScatterPlotterDrawingPane and ScatterPlotterProperties.

Method Detail

reset

public void reset()
Passes an empty DotInfoArray to the .ScatterPlotterDrawingPane.

Overrides:
reset in class BasicPlotter
See Also:
AbstractPlotter.reset()

dispose

public void dispose()
Notifies the plotter that it is not needed any more and can clean up all data and references it holds.

Overrides:
dispose in class AbstractPlotter

setDotSize

public void setDotSize(int dotSize)
Sets the size of the dots and sets a tick offset to both axes to ensure that the points are always completely visible.

Parameters:
dotSize - the dot size.

getDotSize

public int getDotSize()
Returns:
the dot size.

setJitterRate

protected void setJitterRate(int jitterRate)
Parameters:
jitterRate - the jitter rate.

getJitterRate

protected int getJitterRate()
Returns:
the jitter rate (its 1/10 iof the value displayed in the slider).

getShowAllAction

public Action getShowAllAction()
The ScatterPlotter adds the posssibility to show, fade or hide unhilited dots and this is the show all action. The hide flag is administered in the ScatterPlotter, since hidden points are not passed to the .ScatterPlotterDrawingPane, the fade flag is administered in the .ScatterPlotterDrawingPane, since the dots are painted but with a different (faded) color.

Returns:
the menu item for show all.

getHideAction

public Action getHideAction()
The ScatterPlotter adds the posssibility to show, fade or hide unhilited dots and this is the hide unhilited action. The hide flag is administered in the ScatterPlotter, since hidden points are not passed to the .ScatterPlotterDrawingPane, the fade flag is administered in the .ScatterPlotterDrawingPane, since the dots are painted but with a different (faded) color.

Returns:
the menu item for hide unhilited.

isHideMode

protected boolean isHideMode()
Returns:
true if only hilited dots should be painted.

setHideMode

public void setHideMode(boolean hide)
Parameters:
hide - flag whether to hide unhilited dots.

getFadeAction

public Action getFadeAction()
The ScatterPlotter adds the posssibility to show, fade or hide unhilited dots and this is the fade unhilited action. The hide flag is administered in the ScatterPlotter, since hidden points are not passed to the .ScatterPlotterDrawingPane, the fade flag is administered in the .ScatterPlotterDrawingPane, since the dots are painted but with a different (faded) color.

Returns:
the menu item for fade unhilited.

getShowHideMenu

public JMenu getShowHideMenu()
The ScatterPlotter adds the posssibility to show, fade or hide unhilited dots and this is the complete menu to hide, fade. The hide flag is administered in the ScatterPlotter, since hidden points are not passed to the .ScatterPlotterDrawingPane, the fade flag is administered in the .ScatterPlotterDrawingPane, since the dots are painted but with a different (faded) color.

Returns:
an additional menu for the NodeView's menu bar containing the actions for show, fade and hide unhilited dots.

fillPopupMenu

public void fillPopupMenu(JPopupMenu popupMenu)
The inherited hilite menu from the AbstractPlotter and the show all, fade or hide unhilited menu. Fills the popup menu with (additional) elements. In this class the hilite, unhilite and clear hilite actions are added.

Overrides:
fillPopupMenu in class AbstractPlotter
Parameters:
popupMenu - the popup menu to fill.

updatePaintModel

public void updatePaintModel()
The data points of the data to visulaize are mapped to screen coordinates, represented by DotInfo and are passed in a DotInfoArray to the .ScatterPlotterDrawingPane. Repaint of the drawing pane is triggered. Jittering is also triggered from here.

Specified by:
updatePaintModel in class TwoColumnPlotter
See Also:
#updatePaintModel()

calculateCoordinates

protected void calculateCoordinates(DotInfoArray dotsArray)
Given the actual size of the drawing pane, the actual zoom factor, and min/max values it calculates the screen coordinates for each dot info in the array passed in. It accesses the model to retrieve the actual values of the rows. It changes the contents of the DotInfos passed in. It also triggers resorting of the sorted lists in the dot container.

Parameters:
dotsArray - the array containing the dots.

jitterDots

protected void jitterDots(DotInfo[] dots,
                          int xAxisJitterRange,
                          int yAxisJitterRange)
Jitters the dots according to the kind of axis and there values. The function sorts the dots first for the nominal value and second according the other coordinate (possibly also a nominal coordinate)

Parameters:
dots - the dots to jitter
xAxisJitterRange - the available range to jitter for the x axis
yAxisJitterRange - the available range ot jitter for the y axis

isScatterPlotterDrawingPane

protected boolean isScatterPlotterDrawingPane()
Returns:
true if the drawing pane is a scatterplotter drawing pane.

isScatterPlotterProperties

protected boolean isScatterPlotterProperties()
Returns:
true if the properties are scatter plotter properties.

updateSize

public void updateSize()
Updates the size by mapping the domain values of the BasicDrawingElements to the drawing pane's dimension.

Overrides:
updateSize in class BasicPlotter
See Also:
AbstractPlotter.updateSize()

getMappedXValue

protected int getMappedXValue(DataCell x)

Overrides:
getMappedXValue in class AbstractPlotter
Parameters:
x - domain value
Returns:
mapped value

getMappedYValue

protected int getMappedYValue(DataCell y)

Overrides:
getMappedYValue in class AbstractPlotter
Parameters:
y - domain value
Returns:
mapped value

selectElementsIn

public void selectElementsIn(Rectangle selectionRectangle)
Implementing classes may select the elements in the selection rectangle obtained from the mouse dragging in selection mode.

Specified by:
selectElementsIn in class AbstractPlotter
Parameters:
selectionRectangle - the selection rectangle from the dragged mouse in selection mode

selectClickedElement

public void selectClickedElement(Point p)
Implementing classes mayxselect the elements depending on the clicked position. This method is called only when the element should be selected, that is, it is already determined whether the CTRL key is pressed or not.

Specified by:
selectClickedElement in class AbstractPlotter
Parameters:
p - the clicked point

clearSelection

public void clearSelection()
Clears current selection.

Specified by:
clearSelection in class AbstractPlotter

hiLiteSelected

public void hiLiteSelected()
Is called from the menu entry hilite selected. Should hilite selected elements.

Specified by:
hiLiteSelected in class AbstractPlotter

unHiLiteSelected

public void unHiLiteSelected()
Is called by the menu entry unhilite selected. Should unhilite selected elements.

Specified by:
unHiLiteSelected in class AbstractPlotter

unHiLiteAll

public void unHiLiteAll(KeyEvent event)
Invoked, when everything (all rows) are unhilit.

Parameters:
event - contains a list of row key that were unhilit

hiLite

public void hiLite(KeyEvent event)
Invoked when some item(s) were hilit.

Specified by:
hiLite in interface HiLiteListener
Specified by:
hiLite in class AbstractPlotter
Parameters:
event - contains a list of row keys that were hilit

unHiLite

public void unHiLite(KeyEvent event)
Invoked when some item(s) were unhilit.

Specified by:
unHiLite in interface HiLiteListener
Specified by:
unHiLite in class AbstractPlotter
Parameters:
event - contains a list of row keys that were unhilit


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.