org.jzy3d.plot3d.rendering.canvas
Class CanvasSwing

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 org.jzy3d.plot3d.rendering.canvas.CanvasSwing
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.media.opengl.ComponentEvents, javax.media.opengl.GLAutoDrawable, javax.media.opengl.GLDrawable, ICanvas, IScreenCanvas

public class CanvasSwing
extends javax.media.opengl.GLJPanel
implements IScreenCanvas

A Canvas3d embed an OpenGL Renderer3d for handling GL events, a mouse and keyboard controllers for setting the viewpoint (inheriting ViewPointController), and a Scene storing the actual Graph and Views.

The Canvas3d allows getting rid of GL and AWT events by offering a direct registration of a View from the referenced Scene. The View may be retrieved in order to attach it to a ViewController, either one of those held by the current canvas, or an other controller (autonomous, or held by another Canvas). The Canvas silently adds a Renderer3d as its GLEventListener and hide its management for the user.

The Canvas3d last provide an animator that is explicitely stopped when Canvas3d disposes. This offers the alternative of repaint-on-demand-model based on Controllers, and repaint-continuously model based on the Animator.

Author:
Martin Pernollet
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
CanvasSwing(Scene scene, Quality quality)
          Initialize a Canvas3d attached to a Scene, with a given rendering Quality.
 
Method Summary
 void dispose()
          Performs all required cleanup when destroying a Canvas.
 void forceRepaint()
          Force repaint and ensure that GL rendering will occur in the GUI thread, wherever the caller stands.
 int getRendererHeight()
          Provide the actual renderer height for the open gl camera settings, which is obtained after a resize event.
 int getRendererWidth()
          Provide the actual renderer width for the open gl camera settings, which is obtained after a resize event.
 View getView()
          Provide a reference to the View that renders into this canvas.
 java.awt.image.BufferedImage screenshot()
          Returns an image with the current renderer's size
 
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 org.jzy3d.plot3d.rendering.canvas.IScreenCanvas
display
 
Methods inherited from interface org.jzy3d.plot3d.rendering.canvas.ICanvas
addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener
 
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

CanvasSwing

public CanvasSwing(Scene scene,
                   Quality quality)
Initialize a Canvas3d attached to a Scene, with a given rendering Quality.

Method Detail

dispose

public void dispose()
Description copied from interface: ICanvas
Performs all required cleanup when destroying a Canvas.

Specified by:
dispose in interface ICanvas

forceRepaint

public void forceRepaint()
Force repaint and ensure that GL rendering will occur in the GUI thread, wherever the caller stands.

Specified by:
forceRepaint in interface ICanvas

screenshot

public java.awt.image.BufferedImage screenshot()
Description copied from interface: ICanvas
Returns an image with the current renderer's size

Specified by:
screenshot in interface ICanvas

getView

public View getView()
Provide a reference to the View that renders into this canvas.

Specified by:
getView in interface ICanvas

getRendererWidth

public int getRendererWidth()
Provide the actual renderer width for the open gl camera settings, which is obtained after a resize event.

Specified by:
getRendererWidth in interface ICanvas

getRendererHeight

public int getRendererHeight()
Provide the actual renderer height for the open gl camera settings, which is obtained after a resize event.

Specified by:
getRendererHeight in interface ICanvas