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 forBlankCanvasfor systems that do not support OpenGL 3 throughorg.lwjgl.opengl.awt.AWTGLCanvas(e.g. macOS).This
JComponentuses a singleContourPlot.Rendererto draw its contents.- Author:
- hageldave
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ContourPlot.ImgdisplayBufferprotected booleanisRenderPDFAsImageprotected booleanisRenderSvgAsImageprotected ContourPlot.ImgmainRenderBufferprivate java.awt.image.ImageObserverobs_allbitsprotected ContourPlot.ImgpickingRenderBufferprotected ContourPlot.Rendererrendererprotected java.util.concurrent.atomic.AtomicBooleanrepaintIsSheduledprivate static longserialVersionUID-
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.BlankCanvasFallbackinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContourPlot.BlankCanvasFallbackasComponent()Implicit cast of this canvas to a class extendingComponent.voidenablePDFAsImageRendering(boolean enable)En/disables PDF rendering as image.voidenableSvgAsImageRendering(boolean enable)En/disables SVG rendering as image.intgetPixel(int x, int y, boolean picking, int areaSize)Reads the color value of the pixel at the specified location if areaSize == 1.ContourPlot.RenderergetRenderer()booleanisPDFAsImageRenderingEnabled()booleanisSvgAsImageRenderingEnabled()voidpaint(java.awt.Graphics g)protected voidrender()protected voidrender(java.awt.Graphics2D g, java.awt.Graphics2D p, int w, int h)voidrepaint()On AWT event dispatch thread:
Uses the setContourPlot.Rendererrender to render display contents, then calls super.repaint() to display rendered content.voidscheduleRepaint()Schedules a repaint call on the AWT event dispatch thread.ContourPlot.BlankCanvasFallbacksetRenderer(ContourPlot.Renderer renderer)Sets the renderer of this canvas.ContourPlot.ImgtoImg()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.BlankCanvasFallbackinstance.
-
-
Method Detail
-
setRenderer
public ContourPlot.BlankCanvasFallback setRenderer(ContourPlot.Renderer renderer)
Description copied from interface:ContourPlot.JPlotterCanvasSets the renderer of this canvas.- Specified by:
setRendererin interfaceContourPlot.JPlotterCanvas- Parameters:
renderer- to draw contents.- Returns:
- this for chaining
-
getRenderer
public ContourPlot.Renderer getRenderer()
- Specified by:
getRendererin interfaceContourPlot.JPlotterCanvas- Returns:
- the current renderer
-
scheduleRepaint
public void scheduleRepaint()
Description copied from interface:ContourPlot.JPlotterCanvasSchedules 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:
scheduleRepaintin interfaceContourPlot.JPlotterCanvas
-
repaint
public void repaint()
Description copied from interface:ContourPlot.JPlotterCanvasOn AWT event dispatch thread:
Uses the setContourPlot.Rendererrender 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 implementingComponentalready.- Specified by:
repaintin interfaceContourPlot.JPlotterCanvas- Overrides:
repaintin 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:
paintin classjavax.swing.JComponent
-
enableSvgAsImageRendering
public void enableSvgAsImageRendering(boolean enable)
Description copied from interface:ContourPlot.JPlotterCanvasEn/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:
enableSvgAsImageRenderingin 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:
isSvgAsImageRenderingEnabledin interfaceContourPlot.JPlotterCanvas- Returns:
- true when enabled
- See Also:
ContourPlot.JPlotterCanvas.enableSvgAsImageRendering(boolean)
-
enablePDFAsImageRendering
public void enablePDFAsImageRendering(boolean enable)
Description copied from interface:ContourPlot.JPlotterCanvasEn/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:
enablePDFAsImageRenderingin 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:
isPDFAsImageRenderingEnabledin interfaceContourPlot.JPlotterCanvas- Returns:
- true when enabled
- See Also:
(boolean)
-
toImg
public ContourPlot.Img toImg()
Description copied from interface:ContourPlot.JPlotterCanvasFetches the current contents of the framebuffer and returns them as anContourPlot.Img.- Specified by:
toImgin 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.JPlotterCanvasReads 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:
getPixelin 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.JPlotterCanvasImplicit cast of this canvas to a class extendingComponent. This implies that the implementing class is aComponent.- Specified by:
asComponentin interfaceContourPlot.JPlotterCanvas- Returns:
- this, but cast to
Component
-
-