CubeTwister 2.0alpha141 2011-10-13

idx3d
Class idx3d_JCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by idx3d.idx3d_JCanvas
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.swing.event.ChangeListener

public class idx3d_JCanvas
extends javax.swing.JComponent
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.event.ChangeListener, java.awt.event.MouseWheelListener

idx3d_JCanvas.

Version:
5.8 2011-06-29 Adds methods setSwipeTimeout and getSwipeTimeout.
5.7 2010-08-18 Adds support for shared render pipelines.
5.6 2010-08-08 Adds scroll wheel support.
5.5 2010-06-01 Adds method setRasterizer.
5.4 2009-11-28 Adds method flush.
5.3 2009-04-11 Only process mouse events when enabled.
5.2.1 2009-01-19 Update cursor on mouse release.
5.2 2009-01-09 Cursor changes to hand cursor when over a triangle which has event listeners. Added workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6634290
5.1 2009-01-05 Added methods setUpdateCursor and isUpdateCursor.
5.0.1 2009-01-03 Don't start swiping when not in ROTATE_AND_SWIPE mode. Added method setMinFPS/getMinFPS.
5.0 2009-01-01 Added ROTATE_AND_SWIPE interaction mode.
4.2 2008-12-24 Added variable "quiet".
4.1 2008-09-12 Added support for border painting and insets.
4.0 2007-11-15 Upgraded to Java 1.4.
3.0.1 2007-09-10 Fixed some synchronization issues.
3.0 2007-09-09 Rewritten to match functionality of idx3d_CanvasAWT.
2.0 2006-02-20 Rewritten for asynchronous rendering of the scene.
1.0 January 5, 2006 Created.
Author:
Werner Randelshofer
See Also:
Serialized Form

Nested Class Summary
static class idx3d_JCanvas.Interaction
           
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String cameraName
           
protected  idx3d_RenderPipeline renderPipeline
          The 3d Render Pipeline.
protected  idx3d_Scene scene
          The 3d Scene.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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
idx3d_JCanvas()
          Creates a new instance.
 
Method Summary
protected  java.awt.geom.Point2D.Float canvasToTriangle(int x, int y, idx3d_Triangle triangle)
          Converts a location on the canvas to a location on the plane of the specified triangle.
 void dispose()
          Frees resources used by the canvas.
protected  void fireMouseDragged(java.awt.event.MouseEvent evt, idx3d_Triangle triangle)
           
protected  void fireMousePressed(java.awt.event.MouseEvent evt, idx3d_Triangle triangle)
           
 void flush()
           
 idx3d_JCanvas.Interaction getInteractionMode()
           
 java.lang.Object getLock()
           
 int getMinFPS()
          Returns the minimal number of frame seconds before the renderer switches antialising off.
 java.awt.Point getMousePosition()
           
 idx3d_Scene getScene()
           
 int getSwipeTimeout()
          Gets the timeout for swipe operations.
 boolean isUpdateCursor()
          Returns true, if the mouse cursor is updated by the canvas.
 void mouseClicked(java.awt.event.MouseEvent evt)
           
 void mouseDragged(java.awt.event.MouseEvent evt)
           
 void mouseEntered(java.awt.event.MouseEvent evt)
           
 void mouseExited(java.awt.event.MouseEvent evt)
           
 void mouseMoved(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
           
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent evt)
           
 void paintComponent(java.awt.Graphics gr)
           
 void reset()
           
 void setCamera(java.lang.String cameraName)
           
 void setInteractionMode(idx3d_JCanvas.Interaction newValue)
           
 void setLock(java.lang.Object lock)
           
 void setMinFPS(int newValue)
          Minimal Frame Per Seconds Rate.
 void setRasterizer(idx3d_Rasterizer r)
          Sets a different rasterizer.
 void setScene(idx3d_Scene scene)
           
 void setSharedRenderPipeline(idx3d_RenderPipeline newValue)
           
 void setSwipeTimeout(int newValue)
          Sets the timeout for swipe operations.
 void setUpdateCursor(boolean newValue)
          Sets whether the mouse cursor should be updated by the canvas.
 void stateChanged(javax.swing.event.ChangeEvent event)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scene

protected idx3d_Scene scene
The 3d Scene.


renderPipeline

protected idx3d_RenderPipeline renderPipeline
The 3d Render Pipeline.


cameraName

protected java.lang.String cameraName
Constructor Detail

idx3d_JCanvas

public idx3d_JCanvas()
Creates a new instance.

Method Detail

setInteractionMode

public void setInteractionMode(idx3d_JCanvas.Interaction newValue)

getInteractionMode

public idx3d_JCanvas.Interaction getInteractionMode()

setScene

public void setScene(idx3d_Scene scene)

getScene

public idx3d_Scene getScene()

setRasterizer

public void setRasterizer(idx3d_Rasterizer r)
Sets a different rasterizer.


setLock

public void setLock(java.lang.Object lock)

getLock

public java.lang.Object getLock()

setSharedRenderPipeline

public void setSharedRenderPipeline(idx3d_RenderPipeline newValue)

setCamera

public void setCamera(java.lang.String cameraName)

dispose

public void dispose()
Frees resources used by the canvas.


paintComponent

public void paintComponent(java.awt.Graphics gr)
Overrides:
paintComponent in class javax.swing.JComponent

getMinFPS

public int getMinFPS()
Returns the minimal number of frame seconds before the renderer switches antialising off.

Returns:
Number of Frames per second

setMinFPS

public void setMinFPS(int newValue)
Minimal Frame Per Seconds Rate. If the renderer drops below this rate, antialiasing is turned off.

Parameters:
newValue - Number of Frames per second.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent evt)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

setUpdateCursor

public void setUpdateCursor(boolean newValue)
Sets whether the mouse cursor should be updated by the canvas.


isUpdateCursor

public boolean isUpdateCursor()
Returns true, if the mouse cursor is updated by the canvas.


canvasToTriangle

protected java.awt.geom.Point2D.Float canvasToTriangle(int x,
                                                       int y,
                                                       idx3d_Triangle triangle)
Converts a location on the canvas to a location on the plane of the specified triangle.

Parameters:
x -
y -
triangle -
Returns:
Point on triangle.

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent event)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener

getMousePosition

public java.awt.Point getMousePosition()
Overrides:
getMousePosition in class java.awt.Component

fireMousePressed

protected void fireMousePressed(java.awt.event.MouseEvent evt,
                                idx3d_Triangle triangle)

fireMouseDragged

protected void fireMouseDragged(java.awt.event.MouseEvent evt,
                                idx3d_Triangle triangle)

reset

public void reset()

flush

public void flush()

getSwipeTimeout

public int getSwipeTimeout()
Gets the timeout for swipe operations. If the user presses the mouse key for a longer amount of milliseconds, the canvas performs a scene rotation rather than a swipe operation. Integer.MAX_VALUE indicates infinite timeout.


setSwipeTimeout

public void setSwipeTimeout(int newValue)
Sets the timeout for swipe operations. Integer.MAX_VALUE indicates infinite delay.


(c) Werner Randelshofer.
All rights reserved.