T - The type of the data to be visualisedpublic abstract class VisualisationImpl<T> extends JPanel implements ComponentListener, Visualisation<T>, AnimatedVisualisationListener
showWindow(String),
allows the visualisation to be displayed in a window.
This class is abstract - it does not know how to paint the data on which it
is typed. It is therefore necessary to subclass this class with specific
implementations of visualisations for specific types. To do this, override
the update() method in this class to draw the visualisation into
the visImage member. The implementation of the update()
method may call Component.repaint() if it so wishes to update any displays
of the data. This is called automatically when setData(Object) is
called to update the data object.
The class also allows for linking visualisations so that one visualisation can draw on top of another visualisation's output. However, the visualisations do not affect each other's visualisation images. If you call the constructor that takes a visualisation, this visualisation will become an overlay of the given visualisation. Each time the underlying visualisation is updated, a copy of the visualisation is stored in this visualisation for drawing as a background. This means that this visualisation can update more often than the underlying visualisation, however, it can be slow if the underlying visualisation updates often because it's making a copy of the image.
JPanel.AccessibleJPanelJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected boolean |
clearBeforeDraw
Whether to clear the image before redrawing
|
protected T |
data
The data to be visualised
|
protected MBFImage |
visImage
The visualisation image
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Modifier | Constructor and Description |
|---|---|
protected |
VisualisationImpl()
Default constructor
|
|
VisualisationImpl(int width,
int height)
Create a new visualisation with the given width and height
|
|
VisualisationImpl(VisualisationImpl<?> overlayOn)
Create a new visualisation using an existing image.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addOverlay(VisualisationImpl<?> v)
Add an overlay to this visualisation
|
void |
componentHidden(ComponentEvent e) |
void |
componentMoved(ComponentEvent e) |
void |
componentResized(ComponentEvent e) |
void |
componentShown(ComponentEvent e) |
Dimension |
getRequiredSize()
Get the current required size of the vis
|
MBFImage |
getVisualisationImage()
Returns the image to which the bars will be drawn.
|
boolean |
isAllowResize()
Whether this visualisation can be resized.
|
void |
newVisualisationAvailable(AnimatedVisualisationProvider avp)
Called by the
AnimatedVisualisationProvider when
a new visualisation is available to drawn (but hasn't been
drawn yet). |
void |
paint(Graphics g) |
void |
removeOverlay(VisualisationImpl<?> v)
Remove the given overlay from this visualisation
|
void |
setAllowResize(boolean allowResize)
Set whether this visualisation can be resized.
|
void |
setClearBeforeDraw(boolean tf)
Sets whether to clear the image before drawing.
|
void |
setData(T data)
Set the data to be visualised.
|
void |
setRequiredSize(Dimension d)
Set the required size of the vis
|
JFrame |
showWindow(String title)
Show a window containing this visualisation
|
abstract void |
update()
Called to update the visualisation.
|
void |
update(Graphics g) |
void |
updateVis()
Call to force and update of the visualisation
|
void |
updateVis(MBFImage overlay)
Update the visualisation using the given image as the base image
on which to overlay.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, 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, 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, unregisterKeyboardActionadd, 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, validateTreeaction, 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, transferFocusUpCycleprotected boolean clearBeforeDraw
protected VisualisationImpl()
public VisualisationImpl(int width, int height)
width - The widthheight - The heightpublic VisualisationImpl(VisualisationImpl<?> overlayOn)
overlayOn - The visualisation on which to overlaypublic void addOverlay(VisualisationImpl<?> v)
v - The visualisation to overlay on this visualisationpublic void removeOverlay(VisualisationImpl<?> v)
v - The visualisation to removepublic abstract void update()
visImage member to be available and of the correct size.
The method simply needs to draw the visualisation to this MBFImage.
You should wrap any drawing code in a synchronized block, synchronized on
the visImage - this stops the image being repainted to the screen half way
through drawing.
Update is called from the paint() method so should ideally not force a repaint() as this will call a continuous repaint loop.
public void updateVis()
updateVis in interface VisualisationImageProviderpublic void updateVis(MBFImage overlay)
overlay - The overlaypublic void setData(T data)
setData in interface Visualisation<T>data - The data to be visualisedpublic MBFImage getVisualisationImage()
getVisualisationImage in interface VisualisationImageProviderpublic void paint(Graphics g)
paint in class JComponentJComponent.paint(java.awt.Graphics)public void update(Graphics g)
update in class JComponentJComponent.update(java.awt.Graphics)public JFrame showWindow(String title)
title - The title of the windowpublic boolean isAllowResize()
public void setAllowResize(boolean allowResize)
allowResize - TRUE to allow the visualisation to be resizablepublic void setRequiredSize(Dimension d)
setRequiredSize in interface VisualisationImageProviderd - The required sizepublic Dimension getRequiredSize()
public void setClearBeforeDraw(boolean tf)
tf - TRUE to clear the imagepublic void componentHidden(ComponentEvent e)
componentHidden in interface ComponentListenerpublic void componentMoved(ComponentEvent e)
componentMoved in interface ComponentListenerpublic void componentShown(ComponentEvent e)
componentShown in interface ComponentListenerpublic void componentResized(ComponentEvent e)
componentResized in interface ComponentListenerpublic void newVisualisationAvailable(AnimatedVisualisationProvider avp)
AnimatedVisualisationProvider when
a new visualisation is available to drawn (but hasn't been
drawn yet).newVisualisationAvailable in interface AnimatedVisualisationListeneravp - The source of the eventAnimatedVisualisationListener.newVisualisationAvailable(org.openimaj.vis.AnimatedVisualisationProvider)