Xj3D 2.0 VRML/X3D Code API

org.xj3d.ui.awt.widgets
Class SwingViewpointToolbar

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 org.xj3d.ui.awt.widgets.SwingViewpointToolbar
All Implemented Interfaces:
java.awt.event.ItemListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, NavigationStateListener, ViewpointStatusListener

public class SwingViewpointToolbar
extends javax.swing.JPanel
implements java.awt.event.ItemListener, ViewpointStatusListener, NavigationStateListener

A toolbar for all viewpoint manipulation commands that offers convenient and common code.

Creating an instance of this class will automatically register it as viewpoint and navigation state listeners with the browser core. The end user is not required to do this.

External Resources

This toolbar uses images for the button icons rather than text. These are the images used. The path is found relative to the classpath.

The toolbar always starts completely disabled. User code should not play with the enabled state as we will do that based on the feedback from the various status listeners... The actions returned are suitable for menu usage. Internally we have another set of actions that have a different style.

Version:
$Revision: 1.10 $
Author:
Justin Couch, Brad Vender
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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 org.web3d.browser.NavigationStateListener
EXAMINE_STATE, FLY_STATE, NO_STATE, PAN_STATE, TILT_STATE, WALK_STATE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SwingViewpointToolbar(BrowserCore core, ViewpointManager vpMgr, ErrorReporter reporter)
          Create a new horizontal viewpoint toolbar with an empty list of viewpoints.
SwingViewpointToolbar(BrowserCore core, ViewpointManager vpMgr, java.util.Properties skinProperties, ErrorReporter reporter)
          Create a new horizontal viewpoint toolbar with an empty list of viewpoints, but with non-default appearance.
 
Method Summary
 void clearViewpoints()
          Clear the viewpoint list and disable self
 javax.swing.AbstractAction getFitWorldAction()
          Get the FitWorld Action.
 javax.swing.AbstractAction getHomeViewpointAction()
          Get the Home Viewpoint Action.
 javax.swing.AbstractAction getLookatAction()
          Get the Lookat Action.
 javax.swing.AbstractAction getNextViewpointAction()
          Get the Next Viewpoint Action.
 javax.swing.AbstractAction getPreviousViewpointAction()
          Get the Previous Viewpoint Action.
 void itemStateChanged(java.awt.event.ItemEvent evt)
          Listen for item changing events in the comboBox selection
 void navigationListChanged(java.lang.String[] modes, int numModes)
          Notification that the list of valid navigation modes has changed.
 void navigationStateChanged(int idx)
          Notification that the navigation state has changed to the new state.
 void setEnabled(boolean enabled)
          Set the panel enabled or disabled.
 void viewpointAdded(VRMLViewpointNodeType node, int layerId, boolean isDefault)
          Invoked when a viewpoint has been added
 void viewpointBound(VRMLViewpointNodeType node, int layerId)
          Invoked when a viewpoint has been bound.
 void viewpointLayerActive(int layerId)
          The given layer is now made the active layer.
 void viewpointLayerAdded(int layerId)
          Notification of the addition of a valid layer ID to the current list.
 void viewpointLayerRemoved(int layerId)
          Notification that a Layer ID is no longer valid.
 void viewpointRemoved(VRMLViewpointNodeType node, int layerId)
          Invoked when a viewpoint has been removed
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
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, 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, 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
 

Constructor Detail

SwingViewpointToolbar

public SwingViewpointToolbar(BrowserCore core,
                             ViewpointManager vpMgr,
                             ErrorReporter reporter)
Create a new horizontal viewpoint toolbar with an empty list of viewpoints.

Parameters:
core - The browser core
vpMgr - The manager of viewpoint changes
reporter - The reporter instance to use or null

SwingViewpointToolbar

public SwingViewpointToolbar(BrowserCore core,
                             ViewpointManager vpMgr,
                             java.util.Properties skinProperties,
                             ErrorReporter reporter)
Create a new horizontal viewpoint toolbar with an empty list of viewpoints, but with non-default appearance.

Parameters:
core - The browser core
vpMgr - The manager of viewpoint changes
skinProperties - Properties object specifying image names
reporter - The reporter instance to use or null
Method Detail

navigationStateChanged

public void navigationStateChanged(int idx)
Notification that the navigation state has changed to the new state.

Specified by:
navigationStateChanged in interface NavigationStateListener
Parameters:
idx - The new state expressed as an index into the current navModes list.

navigationListChanged

public void navigationListChanged(java.lang.String[] modes,
                                  int numModes)
Notification that the list of valid navigation modes has changed.

Specified by:
navigationListChanged in interface NavigationStateListener
Parameters:
modes - The new modes
numModes - The number of modes in the list

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent evt)
Listen for item changing events in the comboBox selection

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
evt - The event that caused this method to be called

setEnabled

public void setEnabled(boolean enabled)
Set the panel enabled or disabled. Overridden to make sure the base components are properly handled.

Overrides:
setEnabled in class javax.swing.JComponent
Parameters:
enabled - true if this component is enabled

viewpointLayerAdded

public void viewpointLayerAdded(int layerId)
Notification of the addition of a valid layer ID to the current list. This layer is currently empty of viewpoints. Calls to viewpointAdded(org.web3d.vrml.nodes.VRMLViewpointNodeType, int, boolean) will subsequently follow with all the viewpoints listed in this layer. It can be assumed that the layer is not currently the active layer. A separate notificaion is available for that.

Specified by:
viewpointLayerAdded in interface ViewpointStatusListener
Parameters:
layerId - The ID of the layer to be added

viewpointLayerRemoved

public void viewpointLayerRemoved(int layerId)
Notification that a Layer ID is no longer valid. Any viewpoints that have been made available for that layer should now be removed from the layer.

Specified by:
viewpointLayerRemoved in interface ViewpointStatusListener
Parameters:
layerId - The ID of the layer to be added

viewpointLayerActive

public void viewpointLayerActive(int layerId)
The given layer is now made the active layer. If there is a viewpoint list being maintained per-layer then the UI can perform some sort of highlighting to indicate this. Viewpoints in other layers are still allowed to be bound by the user interface. If there was a previously active layer, ignore it.

The code will guarantee that if the active layer is removed, then this method will be called first to set a different valid layer, before removing that layer ID.

If a value of -1 is provided, that means no layers are active and that we currently have a completely clear browser with no world loaded. The UI should act appropriately.

Specified by:
viewpointLayerActive in interface ViewpointStatusListener
Parameters:
layerId - The ID of the layer to be made current or -1

viewpointAdded

public void viewpointAdded(VRMLViewpointNodeType node,
                           int layerId,
                           boolean isDefault)
Invoked when a viewpoint has been added

Specified by:
viewpointAdded in interface ViewpointStatusListener
Parameters:
node - The viewpoint
layerId - The ID of the layer the viewpoint is added to
isDefault - Is the node a default

viewpointRemoved

public void viewpointRemoved(VRMLViewpointNodeType node,
                             int layerId)
Invoked when a viewpoint has been removed

Specified by:
viewpointRemoved in interface ViewpointStatusListener
Parameters:
node - The viewpoint
layerId - The ID of the layer the viewpoint is removed from

viewpointBound

public void viewpointBound(VRMLViewpointNodeType node,
                           int layerId)
Invoked when a viewpoint has been bound.

Specified by:
viewpointBound in interface ViewpointStatusListener
Parameters:
node - The viewpoint
layerId - The ID of the layer the viewpoint is bound on

getNextViewpointAction

public javax.swing.AbstractAction getNextViewpointAction()
Get the Next Viewpoint Action. Suitable for use in a menu.

Returns:
Returns the action

getPreviousViewpointAction

public javax.swing.AbstractAction getPreviousViewpointAction()
Get the Previous Viewpoint Action.

Returns:
Returns the action

getHomeViewpointAction

public javax.swing.AbstractAction getHomeViewpointAction()
Get the Home Viewpoint Action.

Returns:
Returns the action

getLookatAction

public javax.swing.AbstractAction getLookatAction()
Get the Lookat Action.

Returns:
Returns the action

getFitWorldAction

public javax.swing.AbstractAction getFitWorldAction()
Get the FitWorld Action.

Returns:
Returns the action

clearViewpoints

public void clearViewpoints()
Clear the viewpoint list and disable self


Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium