Package com.metsci.glimpse.core.canvas
Class NewtSwingGlimpseCanvas
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.metsci.glimpse.core.canvas.NewtSwingGlimpseCanvas
-
- All Implemented Interfaces:
GlimpseCanvas,NewtGlimpseCanvas,GlimpseTarget,ImageObserver,MenuContainer,Serializable,Accessible
- Direct Known Subclasses:
NewtSwingEDTGlimpseCanvas
public class NewtSwingGlimpseCanvas extends JPanel implements NewtGlimpseCanvas
A GlimpseCanvas backed by the JOGLNewtCanvasAWT. This is the default GlimpseCanvas which should be used for most Swing applications. The underlyingNewtCanvasAWTis being actively developed, whereas the underlying canvas forSwingGlimpseCanvasis no longer supported and has fewer features.- Author:
- ulman
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description NewtSwingGlimpseCanvas()NewtSwingGlimpseCanvas(com.jogamp.opengl.GLContext context)NewtSwingGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile)NewtSwingGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile, com.jogamp.opengl.GLContext context)Deprecated.UseNewtSwingGlimpseCanvas(GLContext)instead.NewtSwingGlimpseCanvas(String profile)NewtSwingGlimpseCanvas(String glProfile, com.jogamp.opengl.GLContext context)Deprecated.UseNewtSwingGlimpseCanvas(GLContext)instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDisposeListener(com.jogamp.opengl.GLRunnable runnable)Called whenGLEventListener.dispose(GLAutoDrawable)event is fired by theGLAutoDrawableassociated with the GlimpseCanvas.voidaddLayout(GlimpseLayout layout)Adds a sub-layout to this GlimpseTarget which will only paint in a region of this GlimpseTarget based on its layout constraints.voidaddLayout(GlimpseLayout layout, int zOrder)voiddestroy()Destroys the native surface which this canvas draws to.voiddispose()A convenience method which is equivalent to:disposeAttached( ); destroy( );voiddisposeAttached()Disposes native resources of GlimpseLayouts and GlimpsePainters associated with the GlimpseCanvas.voiddisposePainter(GlimpsePainter painter)CallsGlimpsePainter.dispose(GlimpseContext)the next time the GLContext associated with this GlimpseCanvas is active.com.jogamp.newt.awt.NewtCanvasAWTgetCanvas()DimensiongetDimension()intgetDpi()Returns the ratio of pixels-per-inch for this canvas.com.jogamp.opengl.GLContextgetGLContext()com.jogamp.opengl.GLAutoDrawablegetGLDrawable()GlimpseContextgetGlimpseContext()com.jogamp.opengl.GLProfilegetGLProfile()com.jogamp.newt.opengl.GLWindowgetGLWindow()float[]getSurfaceScale()Returns the scale factors needed to convert the _native_ pixel coordinates to the _window_ pixel coordinates.GlimpseBoundsgetTargetBounds()GlimpseBoundsgetTargetBounds(GlimpseTargetStack stack)Returns the cached or calculated bounds of this GlimpseTarget for a particular context.List<GlimpseTarget>getTargetChildren()booleanisDestroyed()booleanisEventConsumer()Sets whether this GlimpseTarget hides events from GlimpseTargets under it.booleanisEventGenerator()Sets whether this GlimpseTarget generates GlimpseMouseEvents.voidpaint()Lays out anyGlimpseLayoutinstances attached to the GlimpseCanvas and paints allGlimpsePainterinstances attached to the GlimpseLayouts.voidremoveAllLayouts()Clears the canvas, removing all attached GlimpseLayouts.voidremoveLayout(GlimpseLayout layout)Removes a previously added layout from this GlimpseTarget.voidsetEventConsumer(boolean consume)Set whether or not this GlimpseTarget will consume or pass through mouse events.voidsetEventGenerator(boolean generate)Set whether or not this GlimpseTarget will generate GlimpseMouseEvents.voidsetLookAndFeel(LookAndFeel laf)Sets the LookAndFeel for this GlimpseTarget and all child GlimpseTargets.voidsetZOrder(GlimpseLayout layout, int zOrder)StringtoString()-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.metsci.glimpse.core.context.GlimpseTarget
isVisible
-
-
-
-
Constructor Detail
-
NewtSwingGlimpseCanvas
@Deprecated public NewtSwingGlimpseCanvas(String glProfile, com.jogamp.opengl.GLContext context)
Deprecated.UseNewtSwingGlimpseCanvas(GLContext)instead. The context implicitly provides a GLProfile.
-
NewtSwingGlimpseCanvas
@Deprecated public NewtSwingGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile, com.jogamp.opengl.GLContext context)
Deprecated.UseNewtSwingGlimpseCanvas(GLContext)instead. The context implicitly provides a GLProfile.
-
NewtSwingGlimpseCanvas
public NewtSwingGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile)
-
NewtSwingGlimpseCanvas
public NewtSwingGlimpseCanvas(String profile)
-
NewtSwingGlimpseCanvas
public NewtSwingGlimpseCanvas(com.jogamp.opengl.GLContext context)
-
NewtSwingGlimpseCanvas
public NewtSwingGlimpseCanvas()
-
-
Method Detail
-
getGLProfile
public com.jogamp.opengl.GLProfile getGLProfile()
- Specified by:
getGLProfilein interfaceGlimpseCanvas
-
getCanvas
public com.jogamp.newt.awt.NewtCanvasAWT getCanvas()
-
getGLDrawable
public com.jogamp.opengl.GLAutoDrawable getGLDrawable()
- Specified by:
getGLDrawablein interfaceGlimpseCanvas
-
getGLWindow
public com.jogamp.newt.opengl.GLWindow getGLWindow()
- Specified by:
getGLWindowin interfaceNewtGlimpseCanvas
-
getGlimpseContext
public GlimpseContext getGlimpseContext()
- Specified by:
getGlimpseContextin interfaceGlimpseCanvas
-
setLookAndFeel
public void setLookAndFeel(LookAndFeel laf)
Description copied from interface:GlimpseTargetSets the LookAndFeel for this GlimpseTarget and all child GlimpseTargets.- Specified by:
setLookAndFeelin interfaceGlimpseTarget
-
addLayout
public void addLayout(GlimpseLayout layout)
Description copied from interface:GlimpseTargetAdds a sub-layout to this GlimpseTarget which will only paint in a region of this GlimpseTarget based on its layout constraints. This same GlimpseLayout may be a child of any number of different GlimpseTargets.- Specified by:
addLayoutin interfaceGlimpseTarget
-
addLayout
public void addLayout(GlimpseLayout layout, int zOrder)
- Specified by:
addLayoutin interfaceGlimpseTarget
-
setZOrder
public void setZOrder(GlimpseLayout layout, int zOrder)
- Specified by:
setZOrderin interfaceGlimpseTarget
-
removeLayout
public void removeLayout(GlimpseLayout layout)
Description copied from interface:GlimpseTargetRemoves a previously added layout from this GlimpseTarget.- Specified by:
removeLayoutin interfaceGlimpseTarget
-
removeAllLayouts
public void removeAllLayouts()
Description copied from interface:GlimpseTargetClears the canvas, removing all attached GlimpseLayouts.- Specified by:
removeAllLayoutsin interfaceGlimpseTarget
-
getTargetChildren
public List<GlimpseTarget> getTargetChildren()
- Specified by:
getTargetChildrenin interfaceGlimpseTarget- Returns:
- the list of children added through addLayout( GlimpseLayout ).
-
getDimension
public Dimension getDimension()
-
getTargetBounds
public GlimpseBounds getTargetBounds(GlimpseTargetStack stack)
Description copied from interface:GlimpseTargetReturns the cached or calculated bounds of this GlimpseTarget for a particular context.- Specified by:
getTargetBoundsin interfaceGlimpseTarget- Returns:
- the bounds for the given stack
-
getTargetBounds
public GlimpseBounds getTargetBounds()
- Specified by:
getTargetBoundsin interfaceGlimpseCanvas
-
paint
public void paint()
Description copied from interface:GlimpseCanvasLays out anyGlimpseLayoutinstances attached to the GlimpseCanvas and paints allGlimpsePainterinstances attached to the GlimpseLayouts.- Specified by:
paintin interfaceGlimpseCanvas
-
getGLContext
public com.jogamp.opengl.GLContext getGLContext()
- Specified by:
getGLContextin interfaceGlimpseCanvas
-
isEventConsumer
public boolean isEventConsumer()
Description copied from interface:GlimpseTargetSets whether this GlimpseTarget hides events from GlimpseTargets under it. This value does not determine whether or not the GlimpseTarget will generate GlimpseMouseEvents (see {@link #isEventGenerator()).- Specified by:
isEventConsumerin interfaceGlimpseTarget- Returns:
- whether this target hides events from targets under it
-
setEventConsumer
public void setEventConsumer(boolean consume)
Description copied from interface:GlimpseTargetSet whether or not this GlimpseTarget will consume or pass through mouse events.- Specified by:
setEventConsumerin interfaceGlimpseTarget
-
isEventGenerator
public boolean isEventGenerator()
Description copied from interface:GlimpseTargetSets whether this GlimpseTarget generates GlimpseMouseEvents. This value does not determine whether or not GlimpseTargets underneath this GlimpseTarget will also generate GlimpseMouseEvents (seeGlimpseTarget.isEventConsumer()).- Specified by:
isEventGeneratorin interfaceGlimpseTarget- Returns:
- whether this target will generate GlimpseMouseEvents
-
setEventGenerator
public void setEventGenerator(boolean generate)
Description copied from interface:GlimpseTargetSet whether or not this GlimpseTarget will generate GlimpseMouseEvents.- Specified by:
setEventGeneratorin interfaceGlimpseTarget
-
destroy
public void destroy()
Description copied from interface:GlimpseCanvasDestroys the native surface which this canvas draws to. Does not dispose of GL resources associated with GlimpsePainters and GlimpseLayouts attached to the GlimpseCanvas (as these may be attached to other GlimpseCanvases as well). Disposing of Glimpse resources can be done via#disposeAttached().- Specified by:
destroyin interfaceGlimpseCanvas- See Also:
GlimpseCanvas.disposeAttached()
-
isDestroyed
public boolean isDestroyed()
- Specified by:
isDestroyedin interfaceGlimpseCanvas- Returns:
- whether or not
#dispose()has been successfully called. Once true, this GlimpseCanvas is no longer valid for rendering.
-
addDisposeListener
public void addDisposeListener(com.jogamp.opengl.GLRunnable runnable)
Description copied from interface:GlimpseCanvasCalled whenGLEventListener.dispose(GLAutoDrawable)event is fired by theGLAutoDrawableassociated with the GlimpseCanvas. This can happen for reasons other than the window containing the GlimpseCanvas being closed (for example, moving the window between physical monitors or moving the container between docks in a docking framework). Thus, GlimpsePainters and GlimpseLayouts attached to this GlimpseCanvas should generally not be disposed when this callback occurs.- Specified by:
addDisposeListenerin interfaceGlimpseCanvas
-
dispose
public void dispose()
Description copied from interface:GlimpseCanvasA convenience method which is equivalent to:disposeAttached( ); destroy( );- Specified by:
disposein interfaceGlimpseCanvas
-
disposeAttached
public void disposeAttached()
Description copied from interface:GlimpseCanvasDisposes native resources of GlimpseLayouts and GlimpsePainters associated with the GlimpseCanvas.- Specified by:
disposeAttachedin interfaceGlimpseCanvas- See Also:
GlimpseCanvas.destroy()
-
disposePainter
public void disposePainter(GlimpsePainter painter)
Description copied from interface:GlimpseCanvasCalls
GlimpsePainter.dispose(GlimpseContext)the next time the GLContext associated with this GlimpseCanvas is active. Generally this call is equivalent to:this.getGLDrawable( ).invoke( false, new GLRunnable( ) {- Specified by:
disposePainterin interfaceGlimpseCanvas
-
getSurfaceScale
public float[] getSurfaceScale()
Description copied from interface:GlimpseCanvasReturns the scale factors needed to convert the _native_ pixel coordinates to the _window_ pixel coordinates. This only really matters on displays like like Macbook Retina.- Specified by:
getSurfaceScalein interfaceGlimpseCanvas- Returns:
- the scale factors as {scaleX, scaleY}
-
getDpi
public int getDpi()
Description copied from interface:GlimpseCanvasReturns the ratio of pixels-per-inch for this canvas.- Specified by:
getDpiin interfaceGlimpseCanvas
-
-