Xj3D 2.0 VRML/X3D Code API

org.xj3d.ui.swt.widgets
Class ViewpointToolbar

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.xj3d.ui.swt.widgets.ViewpointToolbar
All Implemented Interfaces:
java.lang.Runnable, java.util.EventListener, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.graphics.Drawable, org.eclipse.swt.internal.SWTEventListener, NavigationStateListener, ViewpointStatusListener

public class ViewpointToolbar
extends org.eclipse.swt.widgets.Composite
implements org.eclipse.swt.events.SelectionListener, ViewpointStatusListener, NavigationStateListener, java.lang.Runnable

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...

Version:
$Revision: 1.8 $
Author:
Justin Couch, Brad Vender, Rex Melton

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Fields inherited from interface org.web3d.browser.NavigationStateListener
EXAMINE_STATE, FLY_STATE, NO_STATE, PAN_STATE, TILT_STATE, WALK_STATE
 
Constructor Summary
ViewpointToolbar(org.eclipse.swt.widgets.Composite parent, BrowserCore core, ViewpointManager vpMgr, ErrorReporter reporter)
          Create a new horizontal viewpoint toolbar with an empty list of viewpoints.
ViewpointToolbar(org.eclipse.swt.widgets.Composite parent, 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
 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 run()
          Process the enabling and disabling of the widgets on the display thread.
 void setEnabled(boolean enabled)
          Set the composite enabled or disabled.
 void setLayout(org.eclipse.swt.widgets.Layout layout)
          Do nothing, we do our own layout
 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
 void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent se)
          Process the default selection generated from the user interface.
 void widgetSelected(org.eclipse.swt.events.SelectionEvent se)
          Process the selection generated from the user interface.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ViewpointToolbar

public ViewpointToolbar(org.eclipse.swt.widgets.Composite parent,
                        BrowserCore core,
                        ViewpointManager vpMgr,
                        ErrorReporter reporter)
Create a new horizontal viewpoint toolbar with an empty list of viewpoints.

Parameters:
parent - the SWT Composite widget that this will be added to
core - The browser core
vpMgr - The manager of viewpoint changes
reporter - The reporter instance to use or null

ViewpointToolbar

public ViewpointToolbar(org.eclipse.swt.widgets.Composite parent,
                        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:
parent - - The SWT Composite widget that this will be added to
core - - The browser core
vpMgr - - The manager of viewpoint changes
skinProperties - - The properties object specifying image names
reporter - - The reporter instance to use or null
Method Detail

setLayout

public void setLayout(org.eclipse.swt.widgets.Layout layout)
Do nothing, we do our own layout

Overrides:
setLayout in class org.eclipse.swt.widgets.Composite

setEnabled

public void setEnabled(boolean enabled)
Set the composite enabled or disabled. Overridden to make sure the widgets are properly handled.

Overrides:
setEnabled in class org.eclipse.swt.widgets.Control
Parameters:
enabled - true if this composite is enabled

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

widgetSelected

public void widgetSelected(org.eclipse.swt.events.SelectionEvent se)
Process the selection generated from the user interface.

Specified by:
widgetSelected in interface org.eclipse.swt.events.SelectionListener
Parameters:
se - The event that caused this method to be called

widgetDefaultSelected

public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent se)
Process the default selection generated from the user interface. Selection from the viewpoint combo box.

Specified by:
widgetDefaultSelected in interface org.eclipse.swt.events.SelectionListener
Parameters:
se - - The event that caused this method to be called

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

run

public void run()
Process the enabling and disabling of the widgets on the display thread.

Specified by:
run in interface java.lang.Runnable

clearViewpoints

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


Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium