Package org.xj3d.ui.awt.widgets
Class SwingViewpointToolbar
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.xj3d.ui.awt.widgets.SwingViewpointToolbar
- All Implemented Interfaces:
ItemListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,NavigationStateListener
,ViewpointStatusListener
public class SwingViewpointToolbar
extends JPanel
implements 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.
- Forward: images/navigation/ButtonForward.gif
- Back: images/navigation/ButtonBack.gif
- Home: images/navigation/ButtonHome.gif
- Fit: images/navigation/ButtonFit.gif
- Look At: images/navigation/ButtonLookat.gif
- Version:
- $Revision: 1.10 $
- Author:
- Justin Couch, Brad Vender
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Fields inherited from interface org.web3d.browser.NavigationStateListener
EXAMINE_STATE, FLY_STATE, NO_STATE, PAN_STATE, TILT_STATE, WALK_STATE
-
Constructor Summary
ConstructorsConstructorDescriptionSwingViewpointToolbar
(BrowserCore core, ViewpointManager vpMgr, Properties skinProperties, org.j3d.util.ErrorReporter reporter) Create a new horizontal viewpoint toolbar with an empty list of viewpoints, but with non-default appearance.SwingViewpointToolbar
(BrowserCore core, ViewpointManager vpMgr, org.j3d.util.ErrorReporter reporter) Create a new horizontal viewpoint toolbar with an empty list of viewpoints. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the viewpoint list and disable selfGet the FitWorld Action.Get the Home Viewpoint Action.Get the Lookat Action.Get the Next Viewpoint Action.Get the Previous Viewpoint Action.void
Listen for item changing events in the comboBox selectionvoid
navigationListChanged
(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 addedvoid
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 removedMethods 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, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
SwingViewpointToolbar
public SwingViewpointToolbar(BrowserCore core, ViewpointManager vpMgr, org.j3d.util.ErrorReporter reporter) Create a new horizontal viewpoint toolbar with an empty list of viewpoints.- Parameters:
core
- The browser corevpMgr
- The manager of viewpoint changesreporter
- The reporter instance to use or null
-
SwingViewpointToolbar
public SwingViewpointToolbar(BrowserCore core, ViewpointManager vpMgr, Properties skinProperties, org.j3d.util.ErrorReporter reporter) Create a new horizontal viewpoint toolbar with an empty list of viewpoints, but with non-default appearance.- Parameters:
core
- The browser corevpMgr
- The manager of viewpoint changesskinProperties
- Properties object specifying image namesreporter
- The reporter instance to use or null
-
-
Method Details
-
itemStateChanged
Listen for item changing events in the comboBox selection- Specified by:
itemStateChanged
in interfaceItemListener
- 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 classJComponent
- 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 toviewpointAdded(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 interfaceViewpointStatusListener
- 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 interfaceViewpointStatusListener
- 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 interfaceViewpointStatusListener
- Parameters:
layerId
- The ID of the layer to be made current or -1
-
viewpointAdded
Invoked when a viewpoint has been added- Specified by:
viewpointAdded
in interfaceViewpointStatusListener
- Parameters:
node
- The viewpointlayerId
- The ID of the layer the viewpoint is added toisDefault
- Is the node a default
-
viewpointRemoved
Invoked when a viewpoint has been removed- Specified by:
viewpointRemoved
in interfaceViewpointStatusListener
- Parameters:
node
- The viewpointlayerId
- The ID of the layer the viewpoint is removed from
-
viewpointBound
Invoked when a viewpoint has been bound.- Specified by:
viewpointBound
in interfaceViewpointStatusListener
- Parameters:
node
- The viewpointlayerId
- The ID of the layer the viewpoint is bound on
-
getNextViewpointAction
Get the Next Viewpoint Action. Suitable for use in a menu.- Returns:
- Returns the action
-
getPreviousViewpointAction
Get the Previous Viewpoint Action.- Returns:
- Returns the action
-
getHomeViewpointAction
Get the Home Viewpoint Action.- Returns:
- Returns the action
-
getLookatAction
-
getFitWorldAction
-
clearViewpoints
public void clearViewpoints()Clear the viewpoint list and disable self