|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.knime.base.node.viz.plotter.AbstractPlotter
public abstract class AbstractPlotter
Provides functionality for zooming, moving and selection and is designed to
be extended. For this purpose it provides means to support hiliting, creating
the x and y 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.
Nested Class Summary | |
---|---|
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. |
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 | |
---|---|
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. |
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 | |
---|---|
AbstractPlotter(AbstractDrawingPane drawingPane,
AbstractPlotterProperties properties)
Creates a new plotter with a drawing pane and a properties panel. |
Method Summary | |
---|---|
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. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.knime.core.node.property.hilite.HiLiteListener |
---|
unHiLiteAll |
Field Detail |
---|
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
Constructor Detail |
---|
public AbstractPlotter(AbstractDrawingPane drawingPane, AbstractPlotterProperties properties)
drawingPane
- the drawing paneproperties
- the properties panelMethod Detail |
---|
public 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 value
protected int getMappedYValue(DataCell y)
y
- domain value
public 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 value
public 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |