Class CanvasAWT
- All Implemented Interfaces:
com.jogamp.nativewindow.awt.AWTPrintLifecycle, com.jogamp.nativewindow.NativeSurfaceHolder, com.jogamp.nativewindow.OffscreenLayerOption, com.jogamp.nativewindow.ScalableSurface, com.jogamp.nativewindow.WindowClosingProtocol, com.jogamp.opengl.awt.AWTGLAutoDrawable, com.jogamp.opengl.awt.ComponentEvents, com.jogamp.opengl.GLAutoDrawable, com.jogamp.opengl.GLDrawable, com.jogamp.opengl.GLSharedContextSetter, ImageObserver, MenuContainer, Serializable, Accessible, ICanvas, INativeCanvas, IScreenCanvas
CanvasAWT is a base implementation that primarily allows to integrate a Jzy3d chart in an
AWT application.
Relying on JOGL's
invalid reference
GLPanel
org.jzy3d.bridge.swt.Bridge.adapt(swt,awt).- Author:
- Martin Pernollet
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Canvas
Canvas.AccessibleAWTCanvasNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyNested classes/interfaces inherited from interface com.jogamp.nativewindow.awt.AWTPrintLifecycle
com.jogamp.nativewindow.awt.AWTPrintLifecycle.ContextNested classes/interfaces inherited from interface com.jogamp.nativewindow.WindowClosingProtocol
com.jogamp.nativewindow.WindowClosingProtocol.WindowClosingMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IAnimatorprotected List<ICanvasListener> protected ScheduledExecutorServiceprotected doubleprotected doubleprotected Renderer3dprotected ViewFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface com.jogamp.nativewindow.awt.AWTPrintLifecycle
DEFAULT_PRINT_TILE_SIZEFields inherited from interface com.jogamp.opengl.GLAutoDrawable
SCREEN_CHANGE_ACTION_ENABLEDFields inherited from interface ICanvas
ALLOW_WATCH_PIXEL_SCALE, LAST_RENDER_TIME_UNDEFINEDFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface com.jogamp.nativewindow.ScalableSurface
AUTOMAX_PIXELSCALE, IDENTITY_PIXELSCALE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCanvasListener(ICanvasListener listener) voidvoidprotected voidvoiddispose()protected voidfirePixelScaleChanged(double pixelScaleX, double pixelScaleY) voidcom.jogamp.opengl.GLAutoDrawabledoublePixel scale is used to model the pixel ratio thay may be introduced by HiDPI or Retina displays.doubledoubleintDeprecated.intDeprecated.getView()Provide a reference to the View that renders into this canvas.booleanisNative()protected float[]protected Renderer3dnewRenderer(IChartFactory factory) voidremoveCanvasListener(ICanvasListener listener) voidvoidprotected voidAWT may paint this canvas before JOGL realized its drawable, and then send no other paint event if nothing changes : the view of a chart opened empty was never initialized (JDK 8 on Linux).protected voidReset pixel scale to (1,1)com.jogamp.opengl.util.texture.TextureDatavoidscreenshot(File file) voidsetExporter(AWTImageExporter exporter) voidsetPixelScale(float[] scale) Requests a pixel scale on the underlying JOGL drawable.voidsetPixelScale(Coord2d scale) voidvoidvoidprotected voidMethods inherited from class com.jogamp.opengl.awt.GLCanvas
addGLEventListener, addGLEventListener, addNotify, areAllGLEventListenerInitialized, canSetSurfaceScale, createContext, destroy, destroyImpl, display, disposeGLEventListener, flushGLRunnables, getAnimator, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getContextCreationFlags, getCurrentSurfaceScale, getDefaultCloseOperation, getDelegatedDrawable, getExclusiveContextThread, getFactory, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, getGLProfile, getGraphicsConfiguration, getHandle, getMaximumSurfaceScale, getMinimumSurfaceScale, getNativeSurface, getRequestedGLCapabilities, getRequestedSurfaceScale, getShallUseOffscreenLayer, getSurfaceHeight, getSurfaceWidth, getThreadName, getUpstreamLock, getUpstreamWidget, invoke, invoke, isGLOriented, isOffscreenLayerSurfaceEnabled, isRealized, isThreadGLCapable, main, paint, print, releasePrint, removeGLEventListener, removeNotify, reshape, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setDefaultCloseOperation, setExclusiveContextThread, setGL, setGLEventListenerInitState, setRealized, setShallUseOffscreenLayer, setSharedAutoDrawable, setSharedContext, setSurfaceScale, setupPrint, swapBuffers, toString, updateMethods inherited from class Canvas
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategyMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, validateMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.jogamp.opengl.awt.AWTGLAutoDrawable
repaint, setSizeMethods inherited from interface com.jogamp.opengl.awt.ComponentEvents
addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface IScreenCanvas
display
-
Field Details
-
pixelScaleX
protected double pixelScaleX -
pixelScaleY
protected double pixelScaleY -
view
-
renderer
-
animator
-
canvasListeners
-
exec
-
-
Constructor Details
-
CanvasAWT
-
-
Method Details
-
renderOnceShown
protected void renderOnceShown()AWT may paint this canvas before JOGL realized its drawable, and then send no other paint event if nothing changes : the view of a chart opened empty was never initialized (JDK 8 on Linux). Render once the canvas is shown or resized, until the view is initialized. -
displayIfNotInitialized
protected void displayIfNotInitialized() -
watchPixelScale
protected void watchPixelScale() -
newPixelScaleIdentity
protected float[] newPixelScaleIdentity() -
newRenderer
-
getLastRenderingTimeMs
public double getLastRenderingTimeMs()- Specified by:
getLastRenderingTimeMsin interfaceICanvas
-
getAnimation
- Specified by:
getAnimationin interfaceIScreenCanvas
-
setPixelScale
public void setPixelScale(float[] scale) Requests a pixel scale on the underlying JOGL drawable.No longer effective on this canvas since JOGL 2.6.0. JOGL commit 900c35c6 (2023-05-15, "No setSurfaceScale(), have AWT toolkit define pixelScale only") made
GLCanvas.setSurfaceScale(float[])andGLCanvas.canSetSurfaceScale()return a hardcodedfalse, because, as its javadoc puts it, "pixelScale is dictated by AWT mechanisms". JOGL now reads the scale from the AWTGraphicsConfigurationinstead of imposing its own, so this call is silently ignored andgetPixelScale()keeps reporting the screen scale.Practical consequence:
Quality.setHiDPI(org.jzy3d.plot3d.rendering.view.HiDPI)withHiDPI.OFFhas no effect here. The chart always renders at the physical pixel density of the screen.The remaining way to get a 1:1 surface is to lower the scale AWT itself reports, with
-Dsun.java2d.uiScale=1. That property is JVM-global, must be set before AWT is initialized, and was verified to work on macOS from JDK 11 through JDK 26.Support of
HiDPI.OFFacross backends:- EmulGL (jGL) : supported
- JOGL AWT (CanvasAWT) and JOGL Swing (CanvasSwing) : not supported since JOGL 2.6.0
- JOGL NEWT :
canSetSurfaceScale()still returns true, but this was not verified end to end - PanamaGL : supported by the canvas, which renders to an FBO it sizes itself, but not
wired to
Qualityyet
- Specified by:
setPixelScalein interfaceICanvas- See Also:
-
setPixelScale
- Specified by:
setPixelScalein interfaceICanvas
-
getPixelScale
Pixel scale is used to model the pixel ratio thay may be introduced by HiDPI or Retina displays.- Specified by:
getPixelScalein interfaceICanvas
-
getPixelScaleJVM
- Specified by:
getPixelScaleJVMin interfaceICanvas
-
getPixelScaleX
public double getPixelScaleX() -
getPixelScaleY
public double getPixelScaleY() -
resetPixelScale
protected void resetPixelScale()Reset pixel scale to (1,1) -
addCanvasListener
- Specified by:
addCanvasListenerin interfaceICanvas
-
removeCanvasListener
- Specified by:
removeCanvasListenerin interfaceICanvas
-
getCanvasListeners
- Specified by:
getCanvasListenersin interfaceICanvas
-
firePixelScaleChanged
protected void firePixelScaleChanged(double pixelScaleX, double pixelScaleY) -
dispose
-
getDebugInfo
- Specified by:
getDebugInfoin interfaceICanvas
-
forceRepaint
public void forceRepaint()- Specified by:
forceRepaintin interfaceICanvas
-
screenshot
- Specified by:
screenshotin interfaceICanvas- Throws:
IOException
-
screenshot
public com.jogamp.opengl.util.texture.TextureData screenshot()- Specified by:
screenshotin interfaceICanvas- Specified by:
screenshotin interfaceINativeCanvas
-
triggerMouseEvent
-
triggerMouseMotionEvent
-
triggerMouseWheelEvent
-
addMouseController
- Specified by:
addMouseControllerin interfaceICanvas
-
addKeyController
- Specified by:
addKeyControllerin interfaceICanvas
-
removeMouseController
- Specified by:
removeMouseControllerin interfaceICanvas
-
removeKeyController
- Specified by:
removeKeyControllerin interfaceICanvas
-
getDrawable
public com.jogamp.opengl.GLAutoDrawable getDrawable()- Specified by:
getDrawablein interfaceINativeCanvas
-
getRenderer
- Specified by:
getRendererin interfaceINativeCanvas
-
getView
-
getRendererWidth
Deprecated.Provide the actual renderer width for the open gl camera settings, which is obtained after a resize event.- Specified by:
getRendererWidthin interfaceICanvas
-
getRendererHeight
Deprecated.Provide the actual renderer height for the open gl camera settings, which is obtained after a resize event.- Specified by:
getRendererHeightin interfaceICanvas
-
getDimension
- Specified by:
getDimensionin interfaceICanvas
-
isNative
-
getExporter
-
setExporter
-