com.metsci.glimpse.canvas
Class SwingGlimpseCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.metsci.glimpse.canvas.SwingGlimpseCanvas
All Implemented Interfaces:
GlimpseCanvas, GlimpseTarget, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class SwingGlimpseCanvas
extends javax.swing.JPanel
implements GlimpseCanvas

A JPanel onto which Glimpse rendering can take place. This class represents the interface between Swing and OpenGL/Glimpse.

Author:
ulman
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.Component
java.awt.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
SwingGlimpseCanvas()
           
SwingGlimpseCanvas(boolean setNoEraseBackgroundProperty)
           
SwingGlimpseCanvas(boolean setNoEraseBackgroundProperty, javax.media.opengl.GLContext _context)
           
SwingGlimpseCanvas(javax.media.opengl.GLContext _context)
           
 
Method Summary
 void addKeyListener(java.awt.event.KeyListener listener)
           
 void addLayout(GlimpseLayout layout)
          Adds a sub-layout to this GlimpseTarget which will only paint in a region of this GlimpseTarget based on its layout constraints.
 void addMouseListener(java.awt.event.MouseListener listener)
           
 void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
           
 void addMouseWheelListener(java.awt.event.MouseWheelListener listener)
           
 void dispose()
          Disposes of any native resources associated with the GlimpseCanvas.
 java.awt.Dimension getDimension()
           
 javax.media.opengl.GLContext getGLContext()
           
 GlimpseContext getGlimpseContext()
           
 GlimpseBounds getTargetBounds()
           
 GlimpseBounds getTargetBounds(GlimpseTargetStack stack)
          Returns the cached or calculated bounds of this GlimpseTarget for a particular context.
 java.util.List<GlimpseTarget> getTargetChildren()
           
 boolean isDisposed()
           
 boolean isEventConsumer()
          Sets whether this GlimpseTarget hides events from GlimpseTargets under it.
 boolean isEventGenerator()
          Sets whether this GlimpseTarget generates GlimpseMouseEvents.
 void paint()
          Lays out any GlimpseLayout instances attached to the GlimpseCanvas and paints all GlimpsePainter instances attached to the GlimpseLayouts.
 void removeKeyListener(java.awt.event.KeyListener listener)
           
 void removeLayout(GlimpseLayout layout)
          Removes a previously added layout from this GlimpseTarget.
 void removeMouseListener(java.awt.event.MouseListener listener)
           
 void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
           
 void removeMouseWheelListener(java.awt.event.MouseWheelListener listener)
           
 void removeNotify()
          This implementation of removeNotify is to get around an inconvenience where this canvas is removed from one component hierarchy and added to another.
 void setEventConsumer(boolean consume)
          Set whether or not this GlimpseTarget will consume or pass through mouse events.
 void setEventGenerator(boolean generate)
          Set whether or not this GlimpseTarget will generate GlimpseMouseEvents.
 void setLookAndFeel(LookAndFeel laf)
           
 java.lang.String toString()
           
 
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SwingGlimpseCanvas

public SwingGlimpseCanvas()

SwingGlimpseCanvas

public SwingGlimpseCanvas(javax.media.opengl.GLContext _context)

SwingGlimpseCanvas

public SwingGlimpseCanvas(boolean setNoEraseBackgroundProperty)

SwingGlimpseCanvas

public SwingGlimpseCanvas(boolean setNoEraseBackgroundProperty,
                          javax.media.opengl.GLContext _context)
Method Detail

getGlimpseContext

public GlimpseContext getGlimpseContext()
Specified by:
getGlimpseContext in interface GlimpseCanvas

setLookAndFeel

public void setLookAndFeel(LookAndFeel laf)
Specified by:
setLookAndFeel in interface GlimpseTarget

addLayout

public void addLayout(GlimpseLayout layout)
Description copied from interface: GlimpseTarget
Adds 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:
addLayout in interface GlimpseTarget

removeLayout

public void removeLayout(GlimpseLayout layout)
Description copied from interface: GlimpseTarget
Removes a previously added layout from this GlimpseTarget.

Specified by:
removeLayout in interface GlimpseTarget

getTargetChildren

public java.util.List<GlimpseTarget> getTargetChildren()
Specified by:
getTargetChildren in interface GlimpseTarget
Returns:
the list of children added through addLayout( GlimpseLayout ).

addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)
Overrides:
addMouseListener in class java.awt.Component

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
Overrides:
addMouseMotionListener in class java.awt.Component

addMouseWheelListener

public void addMouseWheelListener(java.awt.event.MouseWheelListener listener)
Overrides:
addMouseWheelListener in class java.awt.Component

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener listener)
Overrides:
removeMouseListener in class java.awt.Component

removeMouseMotionListener

public void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
Overrides:
removeMouseMotionListener in class java.awt.Component

removeMouseWheelListener

public void removeMouseWheelListener(java.awt.event.MouseWheelListener listener)
Overrides:
removeMouseWheelListener in class java.awt.Component

addKeyListener

public void addKeyListener(java.awt.event.KeyListener listener)
Overrides:
addKeyListener in class java.awt.Component

removeKeyListener

public void removeKeyListener(java.awt.event.KeyListener listener)
Overrides:
removeKeyListener in class java.awt.Component

getDimension

public java.awt.Dimension getDimension()

getTargetBounds

public GlimpseBounds getTargetBounds(GlimpseTargetStack stack)
Description copied from interface: GlimpseTarget
Returns the cached or calculated bounds of this GlimpseTarget for a particular context.

Specified by:
getTargetBounds in interface GlimpseTarget
Returns:
the bounds for the given stack

getTargetBounds

public GlimpseBounds getTargetBounds()
Specified by:
getTargetBounds in interface GlimpseCanvas

paint

public void paint()
Description copied from interface: GlimpseCanvas
Lays out any GlimpseLayout instances attached to the GlimpseCanvas and paints all GlimpsePainter instances attached to the GlimpseLayouts.

Specified by:
paint in interface GlimpseCanvas

getGLContext

public javax.media.opengl.GLContext getGLContext()
Specified by:
getGLContext in interface GlimpseCanvas

dispose

public void dispose()
Description copied from interface: GlimpseCanvas
Disposes of any native resources associated with the GlimpseCanvas.

Specified by:
dispose in interface GlimpseCanvas

isDisposed

public boolean isDisposed()
Specified by:
isDisposed in interface GlimpseCanvas
Returns:
whether or not dispose() has been successfully called. Once true, this GlimpseCanvas is no longer valid for rendering.

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component

isEventConsumer

public boolean isEventConsumer()
Description copied from interface: GlimpseTarget
Sets 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:
isEventConsumer in interface GlimpseTarget
Returns:
whether this target hides events from targets under it

setEventConsumer

public void setEventConsumer(boolean consume)
Description copied from interface: GlimpseTarget
Set whether or not this GlimpseTarget will consume or pass through mouse events.

Specified by:
setEventConsumer in interface GlimpseTarget

isEventGenerator

public boolean isEventGenerator()
Description copied from interface: GlimpseTarget
Sets whether this GlimpseTarget generates GlimpseMouseEvents. This value does not determine whether or not GlimpseTargets underneath this GlimpseTarget will also generate GlimpseMouseEvents (see GlimpseTarget.isEventConsumer()).

Specified by:
isEventGenerator in interface GlimpseTarget
Returns:
whether this target will generate GlimpseMouseEvents

setEventGenerator

public void setEventGenerator(boolean generate)
Description copied from interface: GlimpseTarget
Set whether or not this GlimpseTarget will generate GlimpseMouseEvents.

Specified by:
setEventGenerator in interface GlimpseTarget

removeNotify

public void removeNotify()
This implementation of removeNotify is to get around an inconvenience where this canvas is removed from one component hierarchy and added to another. Technically, this will destroy the context. But since Glimpse makes significant use of buffers and textures, this data needs to come along. Therefore, we force shared contexts to preserve the information as we transition to another canvas. This helps for docking frameworks and moving the canvas seamlessly.

We could override the removeNotify method of the enclosed GLCanvas, but then we'd have to take care of removing it from drawing into the screen. We could create a new GLCanvas directly shared with the old, instead of a pbuffer, but you have to draw into a new context at least once to share all the information, and you can't draw into a GLCanvas until it's physically displayed.

Overrides:
removeNotify in class javax.swing.JComponent


Copyright © 2012 Metron, Inc.. All Rights Reserved.