Class ContourPlot.BlankCanvasFallback
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- gov.nih.mipav.model.algorithms.ContourPlot.BlankCanvasFallback
-
- All Implemented Interfaces:
ContourPlot.JPlotterCanvas
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
- Enclosing class:
- ContourPlot
public class ContourPlot.BlankCanvasFallback extends javax.swing.JComponent implements ContourPlot.JPlotterCanvas
Fallback implementation forBlankCanvas
for systems that do not support OpenGL 3 throughorg.lwjgl.opengl.awt.AWTGLCanvas
(e.g. macOS).This
JComponent
uses a singleContourPlot.Renderer
to draw its contents.- Author:
- hageldave
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ContourPlot.Img
displayBuffer
protected boolean
isRenderPDFAsImage
protected boolean
isRenderSvgAsImage
protected ContourPlot.Img
mainRenderBuffer
private java.awt.image.ImageObserver
obs_allbits
protected ContourPlot.Img
pickingRenderBuffer
protected ContourPlot.Renderer
renderer
protected java.util.concurrent.atomic.AtomicBoolean
repaintIsSheduled
private static long
serialVersionUID
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description BlankCanvasFallback()
Creates a newContourPlot.BlankCanvasFallback
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContourPlot.BlankCanvasFallback
asComponent()
Implicit cast of this canvas to a class extendingComponent
.void
enablePDFAsImageRendering(boolean enable)
En/disables PDF rendering as image.void
enableSvgAsImageRendering(boolean enable)
En/disables SVG rendering as image.int
getPixel(int x, int y, boolean picking, int areaSize)
Reads the color value of the pixel at the specified location if areaSize == 1.ContourPlot.Renderer
getRenderer()
boolean
isPDFAsImageRenderingEnabled()
boolean
isSvgAsImageRenderingEnabled()
void
paint(java.awt.Graphics g)
protected void
render()
protected void
render(java.awt.Graphics2D g, java.awt.Graphics2D p, int w, int h)
void
repaint()
On AWT event dispatch thread:
Uses the setContourPlot.Renderer
render to render display contents, then calls super.repaint() to display rendered content.void
scheduleRepaint()
Schedules a repaint call on the AWT event dispatch thread.ContourPlot.BlankCanvasFallback
setRenderer(ContourPlot.Renderer renderer)
Sets the renderer of this canvas.ContourPlot.Img
toImg()
Fetches the current contents of the framebuffer and returns them as anContourPlot.Img
.-
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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, updateUI
-
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, 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, getAccessibleContext, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gov.nih.mipav.model.algorithms.ContourPlot.JPlotterCanvas
addCleanupOnWindowClosingListener, paintToPDF
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
obs_allbits
private final java.awt.image.ImageObserver obs_allbits
-
repaintIsSheduled
protected java.util.concurrent.atomic.AtomicBoolean repaintIsSheduled
-
mainRenderBuffer
protected ContourPlot.Img mainRenderBuffer
-
pickingRenderBuffer
protected ContourPlot.Img pickingRenderBuffer
-
displayBuffer
protected ContourPlot.Img displayBuffer
-
renderer
protected ContourPlot.Renderer renderer
-
isRenderSvgAsImage
protected boolean isRenderSvgAsImage
-
isRenderPDFAsImage
protected boolean isRenderPDFAsImage
-
-
Constructor Detail
-
BlankCanvasFallback
public BlankCanvasFallback()
Creates a newContourPlot.BlankCanvasFallback
instance.
-
-
Method Detail
-
setRenderer
public ContourPlot.BlankCanvasFallback setRenderer(ContourPlot.Renderer renderer)
Description copied from interface:ContourPlot.JPlotterCanvas
Sets the renderer of this canvas.- Specified by:
setRenderer
in interfaceContourPlot.JPlotterCanvas
- Parameters:
renderer
- to draw contents.- Returns:
- this for chaining
-
getRenderer
public ContourPlot.Renderer getRenderer()
- Specified by:
getRenderer
in interfaceContourPlot.JPlotterCanvas
- Returns:
- the current renderer
-
scheduleRepaint
public void scheduleRepaint()
Description copied from interface:ContourPlot.JPlotterCanvas
Schedules a repaint call on the AWT event dispatch thread. If a repaint is already pending, this method will not schedule an additional call until the render method within repaint is about to be executed.- Specified by:
scheduleRepaint
in interfaceContourPlot.JPlotterCanvas
-
repaint
public void repaint()
Description copied from interface:ContourPlot.JPlotterCanvas
On AWT event dispatch thread:
Uses the setContourPlot.Renderer
render to render display contents, then calls super.repaint() to display rendered content.Schedules a repaint call call on the AWT event dispatch thread if not on it.
This method is only deprecated for calling directly, call
ContourPlot.JPlotterCanvas.scheduleRepaint()
instead.
Of course super.repaint() is implemented by the implementingComponent
already.- Specified by:
repaint
in interfaceContourPlot.JPlotterCanvas
- Overrides:
repaint
in classjava.awt.Component
-
render
protected void render()
-
render
protected void render(java.awt.Graphics2D g, java.awt.Graphics2D p, int w, int h)
-
paint
public void paint(java.awt.Graphics g)
- Overrides:
paint
in classjavax.swing.JComponent
-
enableSvgAsImageRendering
public void enableSvgAsImageRendering(boolean enable)
Description copied from interface:ContourPlot.JPlotterCanvas
En/disables SVG rendering as image. When rendering to SVG and this is enabled, instead of translating the contents of the renderers into SVG elements, the current framebuffer image is used and put into the dom.This can be useful for example when too many SVG elements would be created resulting in a huge dom and file size when exporting as SVG.
- Specified by:
enableSvgAsImageRendering
in interfaceContourPlot.JPlotterCanvas
- Parameters:
enable
- true when no SVG elements should be created from the content of this JPlotterCanvas but instead a simple image element with the framebuffer's content.
-
isSvgAsImageRenderingEnabled
public boolean isSvgAsImageRenderingEnabled()
- Specified by:
isSvgAsImageRenderingEnabled
in interfaceContourPlot.JPlotterCanvas
- Returns:
- true when enabled
- See Also:
ContourPlot.JPlotterCanvas.enableSvgAsImageRendering(boolean)
-
enablePDFAsImageRendering
public void enablePDFAsImageRendering(boolean enable)
Description copied from interface:ContourPlot.JPlotterCanvas
En/disables PDF rendering as image. When rendering to PDF and this is enabled, instead of translating the contents of the renderers into PDF elements, the current framebuffer image is used and put into the pdf document.This can be useful for example when too many PDF elements would be created resulting in a huge dom and file size when exporting as PDF.
- Specified by:
enablePDFAsImageRendering
in interfaceContourPlot.JPlotterCanvas
- Parameters:
enable
- true when no PDF elements should be created from the content of this JPlotterCanvas but instead a simple image element with the framebuffer's content.
-
isPDFAsImageRenderingEnabled
public boolean isPDFAsImageRenderingEnabled()
- Specified by:
isPDFAsImageRenderingEnabled
in interfaceContourPlot.JPlotterCanvas
- Returns:
- true when enabled
- See Also:
(boolean)
-
toImg
public ContourPlot.Img toImg()
Description copied from interface:ContourPlot.JPlotterCanvas
Fetches the current contents of the framebuffer and returns them as anContourPlot.Img
.- Specified by:
toImg
in interfaceContourPlot.JPlotterCanvas
- Returns:
- image of the current framebuffer.
-
getPixel
public int getPixel(int x, int y, boolean picking, int areaSize)
Description copied from interface:ContourPlot.JPlotterCanvas
Reads the color value of the pixel at the specified location if areaSize == 1. This can be used to get the color or picking color under the mouse cursor.Since the cursor placement may be inexact and thus miss the location the user was actually interested in, the areaSize parameter can be increased to create a window of pixels around the specified location. This window area will be examined and the most prominent non zero color value will be returned.
- Specified by:
getPixel
in interfaceContourPlot.JPlotterCanvas
- Parameters:
x
- coordinate of the pixels locationy
- coordinate of the pixels locationpicking
- whether the picking color or the visible color should be retrieved.areaSize
- width and height of the area around the specified location.- Returns:
- the most prominent color in the area as integer packed ARGB value.
If the returned value is to be used as an object id from picking color, then the
alpha value probably has to be discarded first using
0x00ffffff & returnValue
.
-
asComponent
public ContourPlot.BlankCanvasFallback asComponent()
Description copied from interface:ContourPlot.JPlotterCanvas
Implicit cast of this canvas to a class extendingComponent
. This implies that the implementing class is aComponent
.- Specified by:
asComponent
in interfaceContourPlot.JPlotterCanvas
- Returns:
- this, but cast to
Component
-
-