public abstract class AbstractPlotter extends JPanel implements HiLiteListener, ComponentListener
Axis
and get the mapped
values for a given DataCell
, whose values lies
within the domain used to create the axes.
The plotter consists of a drawing pane and a properties panel which can be
accessed. The size of each is adapted automatically. The plotter relies on an
object implementing the DataProvider
to access the data to visualize.
The two most important methods are
updatePaintModel()
and updateSize()
.
The former is called whenever the data to visualize might have changed, the
latter is called when the size of the plotter has changed. In some cases this
means no difference since the mapping of the data to the screen coordinates
has to be done anyway, but if there are other things specific to the data to
be visualized the
updatePaintModel()
is
the correct place to access and display it.
Modifier and Type | Class and Description |
---|---|
class |
AbstractPlotter.MovingMouseListener
When the drawing pane is larger then the viewport for it, this mouse
listener realizes the possibility to drag the drawing pane inside the
viewport.
|
class |
AbstractPlotter.SelectionMouseListener
The selection mouse listener checks the selection status, that is, if the
mouse was dragged, the CTRL key is pressed and so on and calls the
appropriate methods in the
AbstractPlotter . |
class |
AbstractPlotter.ZoomMouseListener
Realizes the zooming behaviour, when the mouse is clicked it calls the
zoomByClick(Point) , when the mouse is dragged
the zoomByWindow(Rectangle) is called. |
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_ZOOM_FACTOR
The default zoom factor.
|
static String |
FADE_UNHILITED
Constant for "Fade unhilited" menu entry.
|
static String |
HIDE_UNHILITED
Constant for "show hilited only" menu entry.
|
static String |
SHOW_ALL
Constant for the menu entry "show all".
|
static String |
SHOW_HIDE
Constant for the show/hide menu title.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
AbstractPlotter(AbstractDrawingPane drawingPane,
AbstractPlotterProperties properties)
Creates a new plotter with a drawing pane and a properties panel.
|
Modifier and Type | Method and Description |
---|---|
void |
addMouseListener(PlotterMouseListener listener)
If an additional mouse mode should be supported, extend the
PlotterMouseListener and add it. |
abstract void |
clearSelection()
Clears current selection.
|
void |
componentHidden(ComponentEvent e) |
void |
componentMoved(ComponentEvent e) |
void |
componentResized(ComponentEvent e)
Resizes the axes and calls
updateSize() , the drawing pane is
adapted to the new space only if the size is increased. |
void |
componentShown(ComponentEvent e) |
void |
createNominalXCoordinate(Set<DataCell> values)
Creates a nominal x axis.
|
void |
createNominalYCoordinate(Set<DataCell> values)
Creates a nominal y axis.
|
void |
createXCoordinate(double min,
double max)
Recalculates the domain of the x axis.
|
void |
createXCoordinate(int min,
int max)
Recalculates the domain of the x axis.
|
void |
createYCoordinate(double min,
double max)
Recalculates the domain of the y axis.
|
void |
delegateAddHiLiteListener(HiLiteListener listener)
Delegates the listener to the hilite handler.
|
Set<RowKey> |
delegateGetHiLitKeys()
Delegates to the hilite handler.
|
void |
delegateHiLite(RowKey... ids)
Delegates to the hilite handler.
|
void |
delegateHiLite(Set<RowKey> ids)
Delegates to the hilite handler.
|
boolean |
delegateIsHiLit(RowKey... ids)
delegates to the hilite handler.
|
boolean |
delegateIsHiLit(Set<RowKey> ids)
Delegates to the hilite handler.
|
void |
delegateRemoveAllHiLiteListeners()
Delegates to the hilite handler.
|
void |
delegateRemoveHiLiteListener(HiLiteListener listener) |
void |
delegateUnHiLite(RowKey... ids)
Delegates to the hilite handler.
|
void |
delegateUnHiLite(Set<RowKey> ids)
Delegates to the hilite handler.
|
void |
delegateUnHiLiteAll()
Delegates the unhilite all command to the hilite handler.
|
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)
Fills the popup menu with (additional) elements.
|
void |
fitToScreen()
Fits to screen, that is it resizes the drawing pane to fit into the
plotters dimension.
|
Action |
getClearHiliteAction()
This action calls
delegateUnHiLiteAll() , if it is overridden
take care to not return null since it might be called also
when the getHiLiteMenu() returns null. |
PlotterMouseListener |
getCurrentMouseListener() |
int |
getDataArrayIdx() |
DataProvider |
getDataProvider() |
AbstractDrawingPane |
getDrawingPane() |
Dimension |
getDrawingPaneDimension() |
Action |
getHiliteAction()
This action calls
hiLiteSelected() , if it is overridden take
care to not return null since it might be called also when
the getHiLiteMenu() returns null. |
JMenu |
getHiLiteMenu()
Returns the hilite menu displayed in the
NodeView 's menu bar. |
protected int |
getMappedXValue(DataCell x) |
protected int |
getMappedYValue(DataCell y) |
AbstractPlotterProperties |
getProperties() |
double |
getScreenYCoordinate(double y) |
Action |
getUnhiliteAction()
This action calls
unHiLiteSelected() , if it is overridden take
care to not return null since it might be called also when
the getHiLiteMenu() returns null. |
Axis |
getXAxis() |
Axis |
getYAxis() |
abstract void |
hiLite(KeyEvent event)
Invoked when some item(s) were hilit.
|
abstract void |
hiLiteSelected()
Is called from the menu entry hilite selected.
|
void |
removeMouseListener(Class<? extends PlotterMouseListener> listener)
If one of the default mouse modes (selection, zooming, moving) should not
be available, use this method to remove it.
|
abstract void |
reset()
Reset all local data which depends on the input data provided by the data
provider.
|
abstract void |
selectClickedElement(Point clicked)
Implementing classes mayxselect the elements depending on the clicked
position.
|
abstract void |
selectElementsIn(Rectangle selectionRectangle)
Implementing classes may select the elements in the selection rectangle
obtained from the mouse dragging in selection mode.
|
void |
setAntialiasing(boolean doAntialiasing)
Turns antialiasing on (true) or off (false).
|
void |
setDataArrayIdx(int dataArrayIdx) |
void |
setDataProvider(DataProvider provider) |
void |
setHeight(int height)
Sets the height for the drawing pane.
|
void |
setHiLiteHandler(HiLiteHandler handler) |
void |
setPreserve(boolean preserve) |
void |
setXAxis(Axis xAxis) |
void |
setYAxis(Axis yAxis) |
abstract void |
unHiLite(KeyEvent event)
Invoked when some item(s) were unhilit.
|
abstract void |
unHiLiteSelected()
Is called by the menu entry unhilite selected.
|
void |
updateAxisLength()
Sets the size of the axes to the dimension of the drawing pane.
|
abstract void |
updatePaintModel()
Do the mapping from the models data to screen coordinates here and pass
the visualization model to the drawing pane.
|
abstract void |
updateSize()
Whenever the size of the drawing pane is changed (zooming, resizing) this
method is called in order to update the painting.
|
protected void |
zoomByClick(Point clicked)
Zooms the content of the drawing pane with the point clicked in center.
|
protected void |
zoomByWindow(Rectangle draggedRectangle)
Zooms the content of the drawing pane to the dragged rectangle.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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
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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
unHiLiteAll
public static final double DEFAULT_ZOOM_FACTOR
public static final String HIDE_UNHILITED
public static final String SHOW_ALL
public static final String FADE_UNHILITED
public static final String SHOW_HIDE
public AbstractPlotter(AbstractDrawingPane drawingPane, AbstractPlotterProperties properties)
drawingPane
- the drawing paneproperties
- the properties panelpublic Dimension getDrawingPaneDimension()
protected void zoomByWindow(Rectangle draggedRectangle)
draggedRectangle
- the dragged rectangleprotected void zoomByClick(Point clicked)
clicked
- the point clicked becomes center.public final void fitToScreen()
public final void componentResized(ComponentEvent e)
updateSize()
, the drawing pane is
adapted to the new space only if the size is increased.componentResized
in interface ComponentListener
e
- the resize event
public void setHeight(int height)
height
- the height to set for the plotterpublic void updateAxisLength()
public void removeMouseListener(Class<? extends PlotterMouseListener> listener)
listener
- the class of the listener to be removed.public PlotterMouseListener getCurrentMouseListener()
public void addMouseListener(PlotterMouseListener listener)
PlotterMouseListener
and add it.
It will then appear in the mouse mode selection box displayed with the
value of the toString()
method.listener
- the listener to add.public void setAntialiasing(boolean doAntialiasing)
doAntialiasing
- true for antialiasing enabled, false otherwise.public Axis getXAxis()
public void setXAxis(Axis xAxis)
xAxis
- the x axis to set for the drawing panepublic Axis getYAxis()
public void setYAxis(Axis yAxis)
yAxis
- the y axis to set for the drawing panepublic void setDataProvider(DataProvider provider)
provider
- the data provider.public DataProvider getDataProvider()
public int getDataArrayIdx()
public void setDataArrayIdx(int dataArrayIdx)
dataArrayIdx
- the dataArrayIdx to setpublic AbstractDrawingPane getDrawingPane()
public AbstractPlotterProperties getProperties()
public Action getHiliteAction()
hiLiteSelected()
, if it is overridden take
care to not return null
since it might be called also when
the getHiLiteMenu()
returns null. If no hilite behavior should
be implemented either let the hiLiteSelected()
empty
(recommended) or override this method by returning an empty action.public Action getUnhiliteAction()
unHiLiteSelected()
, if it is overridden take
care to not return null
since it might be called also when
the getHiLiteMenu()
returns null. If no hilite behavior should
be implemented either let the unHiLiteSelected()
empty
(recommended) or override this method by returning an empty action.public Action getClearHiliteAction()
delegateUnHiLiteAll()
, if it is overridden
take care to not return null
since it might be called also
when the getHiLiteMenu()
returns null. If not hilite behavior
should be implemented override this method by returning an empty action
(not recommended).public void fillPopupMenu(JPopupMenu popupMenu)
popupMenu
- the popup menu to fill.public JMenu getHiLiteMenu()
NodeView
's menu bar. In this class the
hilite, unhilite and clear hilite actions are added. This method is
called in the
DefaultVisualizationNodeView
if it is not null
, i.e. if an extending plotter doesn't
support hiliting override this method by returning null
.NodeView
's
menu bar.public abstract void hiLite(KeyEvent event)
hiLite
in interface HiLiteListener
event
- contains a list of row keys that were hilitpublic abstract void unHiLite(KeyEvent event)
unHiLite
in interface HiLiteListener
event
- contains a list of row keys that were unhilitpublic abstract void unHiLiteSelected()
public abstract void hiLiteSelected()
public void delegateUnHiLiteAll()
public void setHiLiteHandler(HiLiteHandler handler)
handler
- a new hilite handlerpublic void delegateAddHiLiteListener(HiLiteListener listener)
listener
- the listenerpublic Set<RowKey> delegateGetHiLitKeys()
HiLiteHandler.getHiLitKeys()
public void delegateHiLite(RowKey... ids)
ids
- the keys to be hilited.HiLiteHandler.fireHiLiteEvent(
RowKey...)
public void delegateHiLite(Set<RowKey> ids)
ids
- the keys to be hilitedHiLiteHandler.fireHiLiteEvent(
java.util.Set)
public boolean delegateIsHiLit(RowKey... ids)
ids
- the ids to be checked.HiLiteHandler.isHiLit(
RowKey...)
public boolean delegateIsHiLit(Set<RowKey> ids)
ids
- the ids to be checked.HiLiteHandler.isHiLit(
RowKey...)
public void delegateRemoveAllHiLiteListeners()
#removeAllHiLiteListeners()
public void delegateRemoveHiLiteListener(HiLiteListener listener)
listener
- the listener to be removed.#removeHiLiteListener(org.knime.core.node.property.hilite.HiLiteListener)
public void delegateUnHiLite(RowKey... ids)
ids
- the ids to be unhilited.#fireUnHiLiteEvent(RowKey...)
public void delegateUnHiLite(Set<RowKey> ids)
ids
- the ids to be unhilited.HiLiteHandler.fireUnHiLiteEvent(
java.util.Set)
public abstract void selectElementsIn(Rectangle selectionRectangle)
selectionRectangle
- the selection rectangle from the dragged mouse
in selection modepublic abstract void selectClickedElement(Point clicked)
clicked
- the clicked pointpublic abstract void clearSelection()
public abstract void updateSize()
public abstract void updatePaintModel()
public abstract void reset()
public void dispose()
public void setPreserve(boolean preserve)
preserve
- true if old min max values of the axes should be
preserved, false otherwise.protected int getMappedXValue(DataCell x)
x
- domain valueprotected int getMappedYValue(DataCell y)
y
- domain valuepublic void createYCoordinate(double min, double max)
min
- the min valuemax
- the max value setPreserve(boolean)
public void createXCoordinate(double min, double max)
min
- the min valuemax
- the max value setPreserve(boolean)
public void createXCoordinate(int min, int max)
min
- the min valuemax
- the max value setPreserve(boolean)
public void createNominalXCoordinate(Set<DataCell> values)
values
- the possible values.public void createNominalYCoordinate(Set<DataCell> values)
values
- the possible values.public final double getScreenYCoordinate(double y)
y
- the mapped y valuepublic void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
public void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
public void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
KNIME GmbH, Konstanz, Germany
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.