jwo.landserf.gui3d
Class GUI3d

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byjwo.utils.gui.JWFrame
                          extended byjwo.landserf.gui3d.GUI3d
All Implemented Interfaces:
Accessible, ActionListener, CameraListener, ChangeListener, EventListener, ImageObserver, JWColourListener, MenuContainer, MouseWheelListener, Printable, RootPaneContainer, Runnable, Serializable, SnapshotListener, WindowConstants

public class GUI3d
extends JWFrame
implements ActionListener, ChangeListener, CameraListener, JWColourListener, MouseWheelListener, Printable, SnapshotListener, Runnable

Creates GUI for viewing spatial objects in 3D.

Version:
2.2, 22nd September, 2004.
Author:
Jo Wood.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int HIGH
          High texture quality (512 x 512 pixels).
static int LOW
          Low texture quality (128 x 128 pixels).
static int MAXIMUM
          Maximum texture quality (2048 x 2048 pixels).
static int MEDIUM
          Medium texture quality (256 x 256 pixels).
static int VHIGH
          Very High texture quality (1024 x 1024 pixels).
static int VLOW
          Very low texture quality (64 x 64 pixels).
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GUI3d(GISFrame parent)
          Creates the GUI for 3d visualisation.
 
Method Summary
 void actionPerformed(ActionEvent event)
          Responds to a selection of menu item or button press.
 void cameraChanged(Camera camera)
          Displays the current camera position in response to a change in position.
protected  void closeDown()
          Closes the 3d window.
 Image getDetailImage()
          Reports the image used for detail texture.
 float getDetailSize()
          Reports the size of the detail texture relative to 1 grid cell.
 float getDetailTransparency()
          Reports the transparency value selected.
 int getDetailType()
          Reports the type of detail image used.
 GISFrame getGISFrame()
          Reports the GIS frame holding spatial objects.
 float getPointSize()
          Gets the size of the point feature representation.
 SurfaceRenderer getSurfaceRenderer()
          Returns the renderer used to display the 3d view.
 int getTextureSize()
          Reports the current selected texture quality.
 float getVectHeight()
          Reports height that vectors are drawn above the surface.
 float getVectWidth()
          Reports the width that vectors are drawn.
 boolean isDrawDetail()
          Reports if the detailed texture is drawn or not..
 boolean isFadeDetail()
          Reports if the detailed texture fades with distance.
 boolean isVectClipped()
          Reports whether vectors are to be depth clipped.
 boolean isVectSmoothed()
          Reports whether vectors displayed as smoothed.
 void loadImage(String fileName)
          Loads the given graphics file and updates the drape with it.
 void mouseWheelMoved(MouseWheelEvent event)
          Responds to a mouse wheel change event by changing the vertical position of the camera.
 int print(Graphics g, PageFormat pageFormat, int pageIndex)
          Creates a printable version of the 3d display.
 void routeFinished()
          Identifies when a route has finished naturally.
 void run()
          Starts the main animation thread for the 3d view.
 void setAnimRate(int animRate)
          Sets the maximum animation rate in frames per second.
 void setPointSize(float pointSize)
          Sets the size of the point feature representation.
 void setVectClipped(boolean clipVect)
          Sets whether vectors are drawn with (true) or without (false) depth clipping.
 void setVectHeight(float vectHeight)
          Sets the height that vectors are drawn above the surface.
 void setVectSmoothed(boolean smoothed)
          Sets whether vectors displayed as smoothed.
 void setVectWidth(float vectWidth)
          Sets the line width of vectors.
 void snapshotReceived(String fileName, ImageIcon snapshot)
          Receives an image containing the completed shapshot.
 void stateChanged(ChangeEvent e)
          Responds to a change in a slider by updating the relevent contol.
 void updateColour(Color newColour)
          Responds to a request to change one of the display colours (fog, sea, sky or walls.
 void updateTexture()
          Updates the current texture at the given level of detail.
 void updateTexture(int level)
          Updates the current texture at the given level of detail.
 void updateTextureMenu(int maxTextureSize)
          Updates the GUI to reflect current texture options.
 
Methods inherited from class jwo.utils.gui.JWFrame
addActionItem, addActionItem, addActionItem, addActionItem, addActionItem, addBinActionItem, addBinActionItem, addBinActionItem, addBinActionItem, addBinActionItem, addBinActionItem, addBinActionItem, addBinActionItem, addButtonSeparator, addInterruptionListener, addMenu, addMenu, addMenu, addMenuSeparator, getAction, initWindow, removeInterruptionListener, setMaxProgress, setMessage, setMinProgress, setProgress, showProgress
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

VLOW

public static final int VLOW
Very low texture quality (64 x 64 pixels).

See Also:
Constant Field Values

LOW

public static final int LOW
Low texture quality (128 x 128 pixels).

See Also:
Constant Field Values

MEDIUM

public static final int MEDIUM
Medium texture quality (256 x 256 pixels).

See Also:
Constant Field Values

HIGH

public static final int HIGH
High texture quality (512 x 512 pixels).

See Also:
Constant Field Values

VHIGH

public static final int VHIGH
Very High texture quality (1024 x 1024 pixels).

See Also:
Constant Field Values

MAXIMUM

public static final int MAXIMUM
Maximum texture quality (2048 x 2048 pixels).

See Also:
Constant Field Values
Constructor Detail

GUI3d

public GUI3d(GISFrame parent)
Creates the GUI for 3d visualisation.

Parameters:
parent - Holds spatial objects to display.
Method Detail

run

public void run()
Starts the main animation thread for the 3d view. This makes repeated calls to the surface renderer, which itself will update the view where necessary.

Specified by:
run in interface Runnable
Overrides:
run in class JWFrame

closeDown

protected void closeDown()
Closes the 3d window. Overrides the default method which would have asked the user whether they wish to quit and then closed entire program.

Overrides:
closeDown in class JWFrame

updateTextureMenu

public void updateTextureMenu(int maxTextureSize)
Updates the GUI to reflect current texture options.

Parameters:
maxTextureSize - Maxium stored texture size.

loadImage

public void loadImage(String fileName)
Loads the given graphics file and updates the drape with it.

Parameters:
fileName - Name of graphics file to load.

updateColour

public void updateColour(Color newColour)
Responds to a request to change one of the display colours (fog, sea, sky or walls.

Specified by:
updateColour in interface JWColourListener
Parameters:
newColour - New colour to display.

getGISFrame

public GISFrame getGISFrame()
Reports the GIS frame holding spatial objects.

Returns:
GISFrame holding spatial objects.

getVectHeight

public float getVectHeight()
Reports height that vectors are drawn above the surface.

Returns:
Height of vectors above surface.

getVectWidth

public float getVectWidth()
Reports the width that vectors are drawn.

Returns:
Vector width in pixels. This can be non-integer if anti-aliasing is turned on.

setVectHeight

public void setVectHeight(float vectHeight)
Sets the height that vectors are drawn above the surface.

Parameters:
vectHeight - Vector height in elevation units.

setPointSize

public void setPointSize(float pointSize)
Sets the size of the point feature representation.

Parameters:
pointSize - Size of point features represented on surface. Scaled between 0 and 10. If 0, no point features shown.

getPointSize

public float getPointSize()
Gets the size of the point feature representation.

Returns:
Size of point features represented on surface. Scaled between 0 and 10. If 0, no point features shown.

setVectWidth

public void setVectWidth(float vectWidth)
Sets the line width of vectors. This can be a non-integer, but will only have an effect if anti-aliasing is set.

Parameters:
vectWidth - Vector width in pixels (can be fractional).

isVectSmoothed

public boolean isVectSmoothed()
Reports whether vectors displayed as smoothed. If smoothed (via anti-aliasing) vector widths can be non-integers.

Returns:
True if vectors are smoothed.

setVectSmoothed

public void setVectSmoothed(boolean smoothed)
Sets whether vectors displayed as smoothed. If smoothed (via anti-aliasing) vector widths can be non-integers.

Parameters:
smoothed - True if vectors are to be smoothed.

isVectClipped

public boolean isVectClipped()
Reports whether vectors are to be depth clipped. Depth clipping will hide parts of the vector that are 'behind' part of the surface.

Returns:
True if vectors are depth clipped.

setVectClipped

public void setVectClipped(boolean clipVect)
Sets whether vectors are drawn with (true) or without (false) depth clipping.

Parameters:
clipVect - Determines whether vectors are depth clipped.

setAnimRate

public void setAnimRate(int animRate)
Sets the maximum animation rate in frames per second.

Parameters:
animRate - Maximum animation rate in fps.

getTextureSize

public int getTextureSize()
Reports the current selected texture quality.

Returns:
Current selected texture resolution (64-2048).

updateTexture

public void updateTexture()
Updates the current texture at the given level of detail.


updateTexture

public void updateTexture(int level)
Updates the current texture at the given level of detail.

Parameters:
level - Texture size level of detail to update (1-2048).

getDetailTransparency

public float getDetailTransparency()
Reports the transparency value selected.

Returns:
Transparency value.

getDetailImage

public Image getDetailImage()
Reports the image used for detail texture.

Returns:
Texture image.

getDetailType

public int getDetailType()
Reports the type of detail image used. For example, SurfaceDetailBox.USER_DEFINED SurfaceDetailBox.RIPPLES or one of the other preset types).

Returns:
surface detail type.
See Also:
SurfaceDetailBox

getDetailSize

public float getDetailSize()
Reports the size of the detail texture relative to 1 grid cell.

Returns:
Number of grid cells occupied by the detail texture.

isDrawDetail

public boolean isDrawDetail()
Reports if the detailed texture is drawn or not..

Returns:
True if detail is drawn.

isFadeDetail

public boolean isFadeDetail()
Reports if the detailed texture fades with distance.

Returns:
True if detail fades with distance.

actionPerformed

public void actionPerformed(ActionEvent event)
Responds to a selection of menu item or button press.

Specified by:
actionPerformed in interface ActionListener
Parameters:
event - Menu/button selection event.

stateChanged

public void stateChanged(ChangeEvent e)
Responds to a change in a slider by updating the relevent contol.

Specified by:
stateChanged in interface ChangeListener
Parameters:
e - Slider change event.

cameraChanged

public void cameraChanged(Camera camera)
Displays the current camera position in response to a change in position.

Specified by:
cameraChanged in interface CameraListener
Parameters:
camera - Camera containing changed properties.

routeFinished

public void routeFinished()
Identifies when a route has finished naturally. Updates the GUI to reflect the fact that the route has finished.

Specified by:
routeFinished in interface CameraListener

mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent event)
Responds to a mouse wheel change event by changing the vertical position of the camera.

Specified by:
mouseWheelMoved in interface MouseWheelListener
Parameters:
event - Mouse wheel event.

print

public int print(Graphics g,
                 PageFormat pageFormat,
                 int pageIndex)
Creates a printable version of the 3d display. Scales output to the given page format.

Specified by:
print in interface Printable
Parameters:
g - Graphics to print.
pageFormat - Format of page on which to print.
pageIndex - Page to print.

getSurfaceRenderer

public SurfaceRenderer getSurfaceRenderer()
Returns the renderer used to display the 3d view.

Returns:
3d renderer.

snapshotReceived

public void snapshotReceived(String fileName,
                             ImageIcon snapshot)
Receives an image containing the completed shapshot.

Specified by:
snapshotReceived in interface SnapshotListener
Parameters:
fileName - Name of file containing snapshot or null if not written to a file.
snapshot - Snapshot image.


Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005