Class PanamaGLSWTCanvas

java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.jzy3d.plot3d.rendering.canvas.PanamaGLSWTCanvas
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable, ICanvas, IPanamaGLCanvas, IScreenCanvas

public class PanamaGLSWTCanvas extends org.eclipse.swt.widgets.Composite implements IPanamaGLCanvas
An SWT Composite hosting a PanamaGL-backed GLCanvasSWT. Ships the very same PanamaGLCanvasSupport plumbing as the Swing and JavaFX panels, while exposing itself as a regular SWT Composite so it can be dropped into any SWT widget hierarchy.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    protected panamagl.canvas.swt.GLCanvasSWT
     
     

    Fields inherited from class org.eclipse.swt.widgets.Composite

    embeddedHandle

    Fields inherited from class org.eclipse.swt.widgets.Widget

    handle
  • Constructor Summary

    Constructors
    Constructor
    Description
    PanamaGLSWTCanvas(IChartFactory factory, org.jzy3d.plot3d.rendering.scene.Scene scene, Quality quality, org.eclipse.swt.widgets.Composite parent, panamagl.canvas.swt.GLCanvasSWT glCanvas)
    Advanced / test-friendly constructor: inject a pre-built GLCanvasSWT.
    PanamaGLSWTCanvas(IChartFactory factory, org.jzy3d.plot3d.rendering.scene.Scene scene, Quality quality, org.eclipse.swt.widgets.Composite parent, panamagl.factory.PanamaGLFactory panamaGLFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    void
    Register an SWT controller on the underlying GLCanvasSWT.
    void
     
    void
     
    protected void
    firePixelScaleChanged(double pixelScaleX, double pixelScaleY)
     
    void
     
     
     
     
    org.jzy3d.maths.Dimension
     
    panamagl.canvas.GLCanvas
    Methods that simply forward to glCanvas go through the field directly rather than through support.
    panamagl.GLEventListener
     
    double
     
    org.jzy3d.maths.Coord2d
     
    org.jzy3d.maths.Coord2d
     
    int
     
    int
    Renderer dimensions are reported in physical pixels, matching the FBO size that the underlying GLCanvasSWT allocates.
     
    boolean
     
    void
     
    void
     
    void
     
     
    void
     
    void
    setGLEventListener(panamagl.GLEventListener listener)
     
    void
    setPixelScale(float[] scale)
     

    Methods inherited from class org.eclipse.swt.widgets.Composite

    changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList

    Methods inherited from class org.eclipse.swt.widgets.Scrollable

    computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar

    Methods inherited from class org.eclipse.swt.widgets.Control

    addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isAutoScalable, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update

    Methods inherited from class org.eclipse.swt.widgets.Widget

    addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface ICanvas

    setPixelScale
  • Field Details

  • Constructor Details

    • PanamaGLSWTCanvas

      public PanamaGLSWTCanvas(IChartFactory factory, org.jzy3d.plot3d.rendering.scene.Scene scene, Quality quality, org.eclipse.swt.widgets.Composite parent, panamagl.factory.PanamaGLFactory panamaGLFactory)
    • PanamaGLSWTCanvas

      public PanamaGLSWTCanvas(IChartFactory factory, org.jzy3d.plot3d.rendering.scene.Scene scene, Quality quality, org.eclipse.swt.widgets.Composite parent, panamagl.canvas.swt.GLCanvasSWT glCanvas)
      Advanced / test-friendly constructor: inject a pre-built GLCanvasSWT. The supplied canvas is re-parented to this composite so that the FillLayout can drive its size. Use the main constructor in application code.
  • Method Details

    • firePixelScaleChanged

      protected void firePixelScaleChanged(double pixelScaleX, double pixelScaleY)
    • getGLCanvas

      public panamagl.canvas.GLCanvas getGLCanvas()
      Methods that simply forward to glCanvas go through the field directly rather than through support.

      SWT's ThreadRedirect_SWT runs the GL init synchronously when already on the display thread, which is exactly the case while PanamaGLCanvasSupport's constructor wires glCanvas.setGLEventListener(renderer). The init walks back through Renderer3D.init -> View.init into the canvas — first PanamaGLPainter.configureGL(Quality) calls getGLCanvas(), then View.initResources -> updateBounds -> shoot calls forceRepaint() — all before support has been assigned. Calling glCanvas keeps these paths NPE-free; the field and support.getGLCanvas() reference the same object.

      Specified by:
      getGLCanvas in interface IPanamaGLCanvas
    • getGLEventListener

      public panamagl.GLEventListener getGLEventListener()
      Specified by:
      getGLEventListener in interface IPanamaGLCanvas
    • setGLEventListener

      public void setGLEventListener(panamagl.GLEventListener listener)
      Specified by:
      setGLEventListener in interface IPanamaGLCanvas
    • isNative

      public boolean isNative()
      Specified by:
      isNative in interface ICanvas
    • getView

      public View getView()
      Specified by:
      getView in interface ICanvas
    • getRendererWidth

      public int getRendererWidth()
      Renderer dimensions are reported in physical pixels, matching the FBO size that the underlying GLCanvasSWT allocates. View uses these values to build the ViewportConfiguration that drives glViewport; on a Retina display the FBO is 2W x 2H so we must return 2W and 2H here, otherwise glViewport(0, 0, W, H) only fills the bottom-left quadrant of the FBO.

      When HiDPI is disabled (Jzy3D's Quality.preserveViewportSize=true), the FBO is already in logical pixels and getPhysicalWidth() returns the logical width.

      Specified by:
      getRendererWidth in interface ICanvas
    • getRendererHeight

      public int getRendererHeight()
      Specified by:
      getRendererHeight in interface ICanvas
    • screenshot

      public void screenshot(File file) throws IOException
      Specified by:
      screenshot in interface ICanvas
      Throws:
      IOException
    • screenshot

      public Object screenshot()
      Specified by:
      screenshot in interface ICanvas
    • display

      public void display()
      Specified by:
      display in interface IScreenCanvas
    • forceRepaint

      public void forceRepaint()
      Specified by:
      forceRepaint in interface ICanvas
    • dispose

      public void dispose()
      Specified by:
      dispose in interface ICanvas
      Overrides:
      dispose in class org.eclipse.swt.widgets.Widget
    • addMouseController

      public void addMouseController(Object o)
      Register an SWT controller on the underlying GLCanvasSWT.

      The controller is expected to implement one or more of SWT's mouse listener interfaces (MouseListener, MouseMoveListener, MouseWheelListener, MouseTrackListener). Each implemented interface is wired up to the canvas; missing ones are silently ignored — same lenient behavior as the AWT canvas's addMouseController(Object).

      Specified by:
      addMouseController in interface ICanvas
    • addKeyController

      public void addKeyController(Object o)
      Specified by:
      addKeyController in interface ICanvas
    • removeMouseController

      public void removeMouseController(Object o)
      Specified by:
      removeMouseController in interface ICanvas
    • removeKeyController

      public void removeKeyController(Object o)
      Specified by:
      removeKeyController in interface ICanvas
    • getDebugInfo

      public String getDebugInfo()
      Specified by:
      getDebugInfo in interface ICanvas
    • setPixelScale

      public void setPixelScale(float[] scale)
      Specified by:
      setPixelScale in interface ICanvas
      See Also:
      • invalid reference
        PanamaGLSwingCanvas#setPixelScale(float[])
    • getPixelScale

      public org.jzy3d.maths.Coord2d getPixelScale()
      Specified by:
      getPixelScale in interface ICanvas
    • getPixelScaleJVM

      public org.jzy3d.maths.Coord2d getPixelScaleJVM()
      Specified by:
      getPixelScaleJVM in interface ICanvas
    • getLastRenderingTimeMs

      public double getLastRenderingTimeMs()
      Specified by:
      getLastRenderingTimeMs in interface ICanvas
    • addCanvasListener

      public void addCanvasListener(ICanvasListener listener)
      Specified by:
      addCanvasListener in interface ICanvas
    • removeCanvasListener

      public void removeCanvasListener(ICanvasListener listener)
      Specified by:
      removeCanvasListener in interface ICanvas
    • getCanvasListeners

      public List<ICanvasListener> getCanvasListeners()
      Specified by:
      getCanvasListeners in interface ICanvas
    • getAnimation

      public IAnimator getAnimation()
      Specified by:
      getAnimation in interface IScreenCanvas
    • getDimension

      public org.jzy3d.maths.Dimension getDimension()
      Specified by:
      getDimension in interface ICanvas