public class ViewerPanel extends JPanel implements OverlayRenderer, PainterThread.Paintable, ViewerStateChangeListener, RequestRepaint
Sources. The panel contains a
canvas and a time slider (if there
are multiple time-points). Maintains a render state, the
renderer, and basic navigation help overlays. It has it's own
PainterThread for painting, which is started on construction (use
to stop the PainterThread.| Modifier and Type | Class and Description |
|---|---|
static class |
ViewerPanel.AlignPlane
The planes which can be aligned with the viewer coordinate system: XY,
ZY, and XZ plane.
|
protected class |
ViewerPanel.MouseCoordinateListener |
protected static class |
ViewerPanel.RenderThreadFactory |
JPanel.AccessibleJPanelJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected AbstractTransformAnimator |
currentAnimator
Current animator for viewer transform, or null.
|
protected InteractiveDisplayCanvas |
display
Canvas used for displaying the rendered
image and
overlays. |
protected MultiResolutionRenderer |
imageRenderer
Renders the current state for the
display. |
protected CopyOnWriteArrayList<InterpolationModeListener> |
interpolationModeListeners |
protected ViewerPanel.MouseCoordinateListener |
mouseCoordinates
Keeps track of the current mouse coordinates, which are used to provide
the current global position (see
getGlobalMouseCoordinates(RealPositionable)). |
protected MessageOverlayAnimator |
msgOverlay
Fade-out overlay of recent messages.
|
protected MultiBoxOverlayRenderer |
multiBoxOverlayRenderer
Overlay navigation boxes.
|
protected ViewerOptions.Values |
options |
protected ArrayList<OverlayAnimator> |
overlayAnimators
A list of currently incomplete (see
OverlayAnimator.isComplete())
animators. |
protected PainterThread |
painterThread
Thread that triggers repainting of the display.
|
protected static AtomicInteger |
panelNumber |
protected ExecutorService |
renderingExecutorService
The
ExecutorService used for rendereing. |
protected BufferedImageOverlayRenderer |
renderTarget
TODO
|
protected ScaleBarOverlayRenderer |
scaleBarOverlayRenderer
TODO
|
protected JSlider |
sliderTime |
protected SourceInfoOverlayRenderer |
sourceInfoOverlayRenderer
Overlay current source name and current timepoint.
|
protected ViewerState |
state
Currently rendered state (visible sources, transformation, timepoint,
etc.) A copy can be obtained by
getState(). |
protected ThreadGroup |
threadGroup
A
ThreadGroup for (only) the threads used by this
ViewerPanel, that is, painterThread and
renderingExecutorService. |
protected CopyOnWriteArrayList<TimePointListener> |
timePointListeners
These listeners will be notified about changes to the current timepoint
ViewerState.getCurrentTimepoint(). |
protected CopyOnWriteArrayList<TransformListener<AffineTransform3D>> |
transformListeners
These listeners will be notified about changes to the
viewer-transform.
|
protected VisibilityAndGrouping |
visibilityAndGrouping
Manages visibility and currentness of sources and groups, as well as
grouping of sources, and display mode.
|
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| Constructor and Description |
|---|
ViewerPanel(List<SourceAndConverter<?>> sources,
int numTimePoints,
CacheControl cacheControl) |
ViewerPanel(List<SourceAndConverter<?>> sources,
int numTimepoints,
CacheControl cacheControl,
ViewerOptions optional) |
| Modifier and Type | Method and Description |
|---|---|
void |
addGroup(SourceGroup group)
Deprecated.
Modify
state() directly |
void |
addInterpolationModeListener(InterpolationModeListener listener)
Add a
InterpolationModeListener to notify when the interpolation
mode is changed. |
void |
addOverlayAnimator(OverlayAnimator animator)
Add a new
OverlayAnimator to the list of animators. |
void |
addRenderTransformListener(TransformListener<AffineTransform3D> listener)
Deprecated.
Use
renderTransformListeners().add( listener ). |
void |
addRenderTransformListener(TransformListener<AffineTransform3D> listener,
int index)
Deprecated.
Use
renderTransformListeners().add( index, listener ). |
void |
addSource(SourceAndConverter<?> sourceAndConverter)
Deprecated.
Modify
state() directly |
void |
addSources(Collection<SourceAndConverter<?>> sourceAndConverter)
Deprecated.
Modify
state() directly |
void |
addTimePointListener(TimePointListener listener)
Add a
TimePointListener to notify about time-point
changes. |
void |
addTimePointListener(TimePointListener listener,
int index)
Add a
TimePointListener to notify about time-point
changes. |
void |
addTransformListener(TransformListener<AffineTransform3D> listener)
Add a
TransformListener to notify about viewer transformation
changes. |
void |
addTransformListener(TransformListener<AffineTransform3D> listener,
int index)
Add a
TransformListener to notify about viewer transformation
changes. |
protected void |
align(ViewerPanel.AlignPlane plane)
Align the XY, ZY, or XZ plane of the local coordinate system of the
currently active source with the viewer coordinate system.
|
<P extends RealLocalizable & RealPositionable> |
displayToGlobalCoordinates(double[] gPos)
Set
gPos to the display coordinates at gPos transformed into the
global coordinate system. |
void |
displayToGlobalCoordinates(double x,
double y,
RealPositionable gPos)
Set
gPos to the display coordinates (x,y,0)T transformed into the
global coordinate system. |
<P extends RealLocalizable & RealPositionable> |
displayToGlobalCoordinates(P gPos)
Set
gPos to the display coordinates at gPos transformed into the
global coordinate system. |
void |
drawOverlays(Graphics g)
Render overlays.
|
InteractiveDisplayCanvas |
getDisplay()
Get the viewer canvas.
|
void |
getGlobalMouseCoordinates(RealPositionable gPos)
Set
gPos to the current mouse coordinates transformed into the
global coordinate system. |
void |
getMouseCoordinates(Positionable p)
TODO
|
ViewerOptions.Values |
getOptionValues() |
SourceInfoOverlayRenderer |
getSourceInfoOverlayRenderer() |
ViewerState |
getState()
Deprecated.
Use
state() instead.
Get a copy of the current ViewerState. |
TransformEventHandler |
getTransformEventHandler() |
VisibilityAndGrouping |
getVisibilityAndGrouping()
Deprecated.
Modify
state() directly
Returns the VisibilityAndGrouping that can be used to modify
visibility and currentness of sources and groups, as well as grouping of
sources, and display mode. |
void |
nextTimePoint()
Show the next time-point.
|
void |
paint()
This is called by the painter thread to repaint the display.
|
void |
previousTimePoint()
Show the previous time-point.
|
void |
removeAllSources()
Deprecated.
Modify
state() directly |
void |
removeGroup(SourceGroup group)
Deprecated.
Modify
state() directly |
void |
removeInterpolationModeListener(InterpolationModeListener listener)
Remove a
InterpolationModeListener. |
void |
removeSource(Source<?> source)
Deprecated.
Modify
state() directly |
void |
removeSources(Collection<Source<?>> sources)
Deprecated.
Modify
state() directly |
void |
removeTimePointListener(TimePointListener listener)
Remove a
TimePointListener. |
void |
removeTransformListener(TransformListener<AffineTransform3D> listener)
Remove a
TransformListener. |
org.scijava.listeners.Listeners<TransformListener<AffineTransform3D>> |
renderTransformListeners()
Add/remove
TransformListeners to notify about viewer transformation
changes. |
boolean |
requestFocusInWindow() |
void |
requestRepaint()
Repaint as soon as possible.
|
void |
requestRepaint(Interval screenInterval) |
void |
setCanvasSize(int width,
int height)
does nothing.
|
void |
setCurrentViewerTransform(AffineTransform3D viewerTransform)
Deprecated.
Modify
state() directly (state().setViewerTransform(t)) |
void |
setDisplayMode(DisplayMode displayMode)
Set the
DisplayMode. |
void |
setInterpolation(Interpolation mode)
Set the
Interpolation mode. |
void |
setNumTimepoints(int numTimepoints)
Set the number of available timepoints.
|
void |
setTimepoint(int timepoint)
Show the specified time-point.
|
void |
setTransformAnimator(AbstractTransformAnimator animator) |
void |
showMessage(String msg)
Display the specified message in a text overlay for a short time.
|
SynchronizedViewerState |
state()
Get the ViewerState.
|
void |
stateFromXml(org.jdom2.Element parent) |
org.jdom2.Element |
stateToXml() |
void |
stop()
Stop the
painterThread and shutdown rendering ExecutorService. |
void |
toggleInterpolation()
Switch to next interpolation mode.
|
void |
viewerStateChanged(ViewerStateChange change) |
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, 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, 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, updateadd, 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 final ViewerState state
getState().protected final MultiResolutionRenderer imageRenderer
display.protected final BufferedImageOverlayRenderer renderTarget
protected final MultiBoxOverlayRenderer multiBoxOverlayRenderer
protected final SourceInfoOverlayRenderer sourceInfoOverlayRenderer
protected final ScaleBarOverlayRenderer scaleBarOverlayRenderer
protected final InteractiveDisplayCanvas display
image and
overlays.protected final JSlider sliderTime
protected ThreadGroup threadGroup
ThreadGroup for (only) the threads used by this
ViewerPanel, that is, painterThread and
renderingExecutorService.protected final PainterThread painterThread
protected final ExecutorService renderingExecutorService
ExecutorService used for rendereing.protected final ViewerPanel.MouseCoordinateListener mouseCoordinates
getGlobalMouseCoordinates(RealPositionable)).protected final VisibilityAndGrouping visibilityAndGrouping
protected final CopyOnWriteArrayList<TransformListener<AffineTransform3D>> transformListeners
requestRepaint() so listeners have the chance to interfere.protected final CopyOnWriteArrayList<TimePointListener> timePointListeners
ViewerState.getCurrentTimepoint(). This is done before
calling requestRepaint() so listeners have the chance to
interfere.protected final CopyOnWriteArrayList<InterpolationModeListener> interpolationModeListeners
protected AbstractTransformAnimator currentAnimator
aligning to
orthogonal planes.protected final ArrayList<OverlayAnimator> overlayAnimators
OverlayAnimator.isComplete())
animators. Initially, this contains a TextOverlayAnimator showing
the "press F1 for help" message.protected final MessageOverlayAnimator msgOverlay
showMessage(String).protected final ViewerOptions.Values options
protected static final AtomicInteger panelNumber
public ViewerPanel(List<SourceAndConverter<?>> sources, int numTimePoints, CacheControl cacheControl)
public ViewerPanel(List<SourceAndConverter<?>> sources, int numTimepoints, CacheControl cacheControl, ViewerOptions optional)
sources - the sources to display.numTimepoints - number of available timepoints.cacheControl - to control IO budgeting and fetcher queue.optional - optional parameters. See ViewerOptions.options().@Deprecated public void addSource(SourceAndConverter<?> sourceAndConverter)
state() directly@Deprecated public void addSources(Collection<SourceAndConverter<?>> sourceAndConverter)
state() directly@Deprecated public void removeSource(Source<?> source)
state() directly@Deprecated public void removeSources(Collection<Source<?>> sources)
state() directly@Deprecated public void removeAllSources()
state() directly@Deprecated public void addGroup(SourceGroup group)
state() directly@Deprecated public void removeGroup(SourceGroup group)
state() directlypublic <P extends RealLocalizable & RealPositionable> void displayToGlobalCoordinates(double[] gPos)
gPos to the display coordinates at gPos transformed into the
global coordinate system.gPos - is set to the corresponding global coordinates.public <P extends RealLocalizable & RealPositionable> void displayToGlobalCoordinates(P gPos)
gPos to the display coordinates at gPos transformed into the
global coordinate system.gPos - is set to the corresponding global coordinates.public void displayToGlobalCoordinates(double x,
double y,
RealPositionable gPos)
gPos to the display coordinates (x,y,0)T transformed into the
global coordinate system.gPos - is set to the global coordinates at display (x,y,0)T.public void getGlobalMouseCoordinates(RealPositionable gPos)
gPos to the current mouse coordinates transformed into the
global coordinate system.gPos - is set to the current global coordinates.public void getMouseCoordinates(Positionable p)
p - public void paint()
PainterThread.Paintablepaint in interface PainterThread.Paintablepublic void requestRepaint()
requestRepaint in interface RequestRepaintpublic void requestRepaint(Interval screenInterval)
public void drawOverlays(Graphics g)
OverlayRendererdrawOverlays in interface OverlayRendererpublic void viewerStateChanged(ViewerStateChange change)
viewerStateChanged in interface ViewerStateChangeListenerprotected void align(ViewerPanel.AlignPlane plane)
plane - to which plane to align.public void setTransformAnimator(AbstractTransformAnimator animator)
public void toggleInterpolation()
public void setInterpolation(Interpolation mode)
Interpolation mode.public void setDisplayMode(DisplayMode displayMode)
DisplayMode.@Deprecated public void setCurrentViewerTransform(AffineTransform3D viewerTransform)
state() directly (state().setViewerTransform(t))public void setTimepoint(int timepoint)
timepoint - time-point index.public void nextTimePoint()
public void previousTimePoint()
public void setNumTimepoints(int numTimepoints)
numTimepoints == 1
this will hide the time slider, otherwise show it. If the currently
displayed timepoint would be out of range with the new number of
timepoints, the current timepoint is set to numTimepoints - 1.
This is equivalent to state().setNumTimepoints(numTimepoints}.
numTimepoints - number of available timepoints. Must be >= 1.@Deprecated public ViewerState getState()
state() instead.
Get a copy of the current ViewerState.ViewerState.public SynchronizedViewerState state()
SynchronizedViewerState for
thread-safety considerations.public InteractiveDisplayCanvas getDisplay()
public TransformEventHandler getTransformEventHandler()
public void showMessage(String msg)
msg - String to display. Should be just one line of text.public void addOverlayAnimator(OverlayAnimator animator)
OverlayAnimator to the list of animators. The animation
is immediately started. The new OverlayAnimator will remain in
the list of animators until it OverlayAnimator.isComplete().animator - animator to add.public void addInterpolationModeListener(InterpolationModeListener listener)
InterpolationModeListener to notify when the interpolation
mode is changed. Listeners will be notified before calling
requestRepaint() so they have the chance to interfere.listener - the interpolation mode listener to add.public void removeInterpolationModeListener(InterpolationModeListener listener)
InterpolationModeListener.listener - the interpolation mode listener to remove.public org.scijava.listeners.Listeners<TransformListener<AffineTransform3D>> renderTransformListeners()
TransformListeners to notify about viewer transformation
changes. Listeners will be notified when a new image has been painted
with the viewer transform used to render that image.
This happens immediately after that image is painted onto the screen, before any overlays are painted.
@Deprecated public void addRenderTransformListener(TransformListener<AffineTransform3D> listener)
renderTransformListeners().add( listener ).@Deprecated public void addRenderTransformListener(TransformListener<AffineTransform3D> listener, int index)
renderTransformListeners().add( index, listener ).public void addTransformListener(TransformListener<AffineTransform3D> listener)
TransformListener to notify about viewer transformation
changes. Listeners will be notified before calling
requestRepaint() so they have the chance to interfere.listener - the transform listener to add.public void addTransformListener(TransformListener<AffineTransform3D> listener, int index)
TransformListener to notify about viewer transformation
changes. Listeners will be notified before calling
requestRepaint() so they have the chance to interfere.listener - the transform listener to add.index - position in the list of listeners at which to insert this one.public void removeTransformListener(TransformListener<AffineTransform3D> listener)
TransformListener.listener - the transform listener to remove.public void addTimePointListener(TimePointListener listener)
TimePointListener to notify about time-point
changes. Listeners will be notified before calling
requestRepaint() so they have the chance to interfere.listener - the listener to add.public void addTimePointListener(TimePointListener listener, int index)
TimePointListener to notify about time-point
changes. Listeners will be notified before calling
requestRepaint() so they have the chance to interfere.listener - the listener to add.index - position in the list of listeners at which to insert this one.public void removeTimePointListener(TimePointListener listener)
TimePointListener.listener - the listener to remove.public org.jdom2.Element stateToXml()
public void stateFromXml(org.jdom2.Element parent)
public void setCanvasSize(int width,
int height)
setCanvasSize in interface OverlayRendererwidth - the new canvas width.height - the new canvas height.@Deprecated public VisibilityAndGrouping getVisibilityAndGrouping()
state() directly
Returns the VisibilityAndGrouping that can be used to modify
visibility and currentness of sources and groups, as well as grouping of
sources, and display mode.public ViewerOptions.Values getOptionValues()
public SourceInfoOverlayRenderer getSourceInfoOverlayRenderer()
public void stop()
painterThread and shutdown rendering ExecutorService.public boolean requestFocusInWindow()
requestFocusInWindow in class JComponentCopyright © 2015–2021 Fiji. All rights reserved.