Class 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 for BlankCanvas for systems that do not support OpenGL 3 through org.lwjgl.opengl.awt.AWTGLCanvas (e.g. macOS).

    This JComponent uses a single ContourPlot.Renderer to draw its contents.

    Author:
    hageldave
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ContourPlot.BlankCanvasFallback asComponent()
      Implicit cast of this canvas to a class extending Component.
      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 set ContourPlot.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 an ContourPlot.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
    • Field Detail

      • obs_allbits

        private final java.awt.image.ImageObserver obs_allbits
      • repaintIsSheduled

        protected java.util.concurrent.atomic.AtomicBoolean repaintIsSheduled
      • isRenderSvgAsImage

        protected boolean isRenderSvgAsImage
      • isRenderPDFAsImage

        protected boolean isRenderPDFAsImage
    • Method Detail

      • 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 interface ContourPlot.JPlotterCanvas
      • repaint

        public void repaint()
        Description copied from interface: ContourPlot.JPlotterCanvas
        On AWT event dispatch thread:
        Uses the set ContourPlot.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 implementing Component already.

        Specified by:
        repaint in interface ContourPlot.JPlotterCanvas
        Overrides:
        repaint in class java.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 class javax.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 interface ContourPlot.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.
      • 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 interface ContourPlot.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.
      • 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 interface ContourPlot.JPlotterCanvas
        Parameters:
        x - coordinate of the pixels location
        y - coordinate of the pixels location
        picking - 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.