de.beamertool.viewer.gui.opengl.gl
Class CompositeGLJPanel

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 javax.media.opengl.GLJPanel
                      extended by de.beamertool.viewer.gui.opengl.gl.CompositeGLJPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ComponentEvents, GLAutoDrawable, GLDrawable, GLEventListener
Direct Known Subclasses:
Slideshow3D

public class CompositeGLJPanel
extends GLJPanel
implements GLEventListener

A simplified version of GLJPanel that allows for easy mixing of 2D and 3D elements in a Swing application. The intention of this class is to lower the barrier of entry for developers who are familiar with Java2D and Swing but less familiar with OpenGL and JOGL. This class handles much of the "dirty work" so that the developer can concentrate more on adding content than on (potentially confusing) OpenGL concepts.

This class has two modes:

In both modes, it is possible to mix Java2D, Swing, and JOGL elements. To simplify this process (and to help guide the developer), this class defines four protected methods that can be overridden by the developer, which are called in (approximately) the following order:

  1. render2DBackground()
  2. init3DResources()
  3. render3DScene()
  4. render2DForeground()

Most developers should only need to concern themselves with these four methods. Only advanced users should find it necessary to call or override the other public methods in this class.

Author:
Chris Campbell, Romain Guy
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
CompositeGLJPanel(boolean isOpaque, boolean hasDepth)
          Creates a new instance of CompositeGLJPanel.
 
Method Summary
 void display(GLAutoDrawable drawable)
           
 void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
           
 void init(GLAutoDrawable drawable)
           
 void paintComponent(Graphics g)
           
 void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
           
 
Methods inherited from class javax.media.opengl.GLJPanel
addGLEventListener, addNotify, createContext, display, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getGL, removeGLEventListener, removeNotify, reshape, setAutoSwapBufferMode, setGL, setOpaque, setRealized, shouldPreserveColorBufferIfTranslucent, swapBuffers
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, 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, 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, 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, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.media.opengl.GLAutoDrawable
repaint
 
Methods inherited from interface javax.media.opengl.GLDrawable
getHeight, getWidth, setSize
 
Methods inherited from interface javax.media.opengl.ComponentEvents
addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

CompositeGLJPanel

public CompositeGLJPanel(boolean isOpaque,
                         boolean hasDepth)
Creates a new instance of CompositeGLJPanel.

Parameters:
isOpaque - if true, the OpenGL drawable (and therefore the panel) will be completely opaque; if false, the OpenGL drawable will have an alpha channel and therefore will allow any components behind the panel to "show through"
hasDepth - if true, the OpenGL drawable will be created with a depth buffer and a perspective (3D) projection; if false, the OpenGL drawable will not have a depth buffer and will instead use an orthographic (2D) projection with a viewport originating in the upper-left corner of the window (just like Swing/Java2D)
Method Detail

display

public void display(GLAutoDrawable drawable)
Specified by:
display in interface GLEventListener

displayChanged

public void displayChanged(GLAutoDrawable drawable,
                           boolean modeChanged,
                           boolean deviceChanged)
Specified by:
displayChanged in interface GLEventListener

init

public void init(GLAutoDrawable drawable)
Specified by:
init in interface GLEventListener

paintComponent

public void paintComponent(Graphics g)
Overrides:
paintComponent in class GLJPanel

reshape

public void reshape(GLAutoDrawable drawable,
                    int x,
                    int y,
                    int width,
                    int height)
Specified by:
reshape in interface GLEventListener