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, ImageObserver, MenuContainer, Serializable
Enclosing class:
ContourPlot

public class ContourPlot.BlankCanvasFallback extends JComponent implements ContourPlot.JPlotterCanvas
Fallback implementation for
invalid reference
BlankCanvas
for systems that do not support OpenGL 3 through
invalid reference
org.lwjgl.opengl.awt.AWTGLCanvas
(e.g. macOS).

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

Author:
hageldave
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • obs_allbits

      private final ImageObserver obs_allbits
    • repaintIsSheduled

      protected 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 Details

  • Method Details

    • setRenderer

      Description copied from interface: ContourPlot.JPlotterCanvas
      Sets the renderer of this canvas.
      Specified by:
      setRenderer in interface ContourPlot.JPlotterCanvas
      Parameters:
      renderer - to draw contents.
      Returns:
      this for chaining
    • getRenderer

      public ContourPlot.Renderer getRenderer()
      Specified by:
      getRenderer in interface ContourPlot.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 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 Component
    • render

      protected void render()
    • render

      protected void render(Graphics2D g, Graphics2D p, int w, int h)
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class 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.
    • isSvgAsImageRenderingEnabled

      public boolean isSvgAsImageRenderingEnabled()
      Specified by:
      isSvgAsImageRenderingEnabled in interface ContourPlot.JPlotterCanvas
      Returns:
      true when enabled
      See Also:
    • 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.
    • isPDFAsImageRenderingEnabled

      public boolean isPDFAsImageRenderingEnabled()
      Specified by:
      isPDFAsImageRenderingEnabled in interface ContourPlot.JPlotterCanvas
      Returns:
      true when enabled
      See Also:
    • toImg

      public ContourPlot.Img toImg()
      Description copied from interface: ContourPlot.JPlotterCanvas
      Fetches the current contents of the framebuffer and returns them as an ContourPlot.Img.
      Specified by:
      toImg in interface ContourPlot.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 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.
    • asComponent

      public ContourPlot.BlankCanvasFallback asComponent()
      Description copied from interface: ContourPlot.JPlotterCanvas
      Implicit cast of this canvas to a class extending Component. This implies that the implementing class is a Component.
      Specified by:
      asComponent in interface ContourPlot.JPlotterCanvas
      Returns:
      this, but cast to Component