jwo.landserf.gui
Class GraphicsArea

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--jwo.utils.JWCanvas
                    |
                    +--jwo.landserf.gui.GraphicsArea
All Implemented Interfaces:
Accessible, ComponentListener, EventListener, ImageObserver, MenuContainer, MouseListener, MouseMotionListener, Serializable

public class GraphicsArea
extends JWCanvas
implements MouseListener, MouseMotionListener

Class for creating a canvas to display possible raster and vector graphics.

Version:
1.8.0, 24th April, 2001.
Author:
Jo Wood
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Canvas
Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int BLEND
          Blend surface and drape.
static int CLEAR
          No raster display.
static int HUESAT
          Hue-Saturation map.
static int RASTER
          Interpolated k-colour raster.
static int SHADED
          Shaded relief blended with k-colour raster
 
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
GraphicsArea()
          Creates the canvas onto which graphics will be drawn.
 
Method Summary
 void addRubberbandListener(RubberbandListener rbListener)
          Adds a rubberband listener to the list of objects to be informed when a new rubberband is created.
 boolean displayRast(RastSurf surf, RastSurf drape)
          Displays raster object on screen, scaled to the maximum size allowed by the window while preserving aspect ratio.
 boolean displayVect(VectorMap vectorMap)
          Display vector in window, scaled to georegister with any raster objects.
 int getDisplay()
          Reports the currently selected raster display type.
 RastSurf getDrape()
          Gets the currently displayed drape.
 Image getImage()
          Returns the current image associated with the graphics area.
 int getImageHeight()
          Returns the current image height in pixels.
 int getImageWidth()
          Returns the current image width in pixels.
 Image getScaledImage()
          Returns the scaled image associated with the graphics area.
 JWRectangle getSubRegion()
          Reports the currently selected sub-region.
 RastSurf getSurf()
          Gets the currently displayed raster.
 void mouseClicked(MouseEvent mouseEvent)
          Checks for mouse clicks, but does nothing.
 void mouseDragged(MouseEvent mouseEvent)
          Checks for mouse dragging and draws a rubberband box in the appropriate location.
 void mouseEntered(MouseEvent mouseEvent)
          Checks for pointer entering event, but does nothing.
 void mouseExited(MouseEvent mouseEvent)
          Checks for pointer exiting event, but does nothing.
 void mouseMoved(MouseEvent mouseEvent)
          Checks for mouse movement, but does nothing.
 void mousePressed(MouseEvent mouseEvent)
          Checks for mouse button press, and reports on the (x,y,z) values at current mouse position.
 void mouseReleased(MouseEvent mouseEvent)
          Checks for mouse button release, and turns off mouse query.
 void paint(Graphics g)
          Plots the graphics onto the canvas.
 void removeProfileQueryBox()
          Removes the profile query box and turns off interactive profile query.
 void removeRastQueryBox()
          Removes the raster query box and turns off interactive raster query.
 void removeRubberbandListener(RubberbandListener rbListener)
          Removes a given listener from the list of objects to be informed when a new rubberband is created.
 void removeScaleQueryBox()
          Removes the multi-scale raster query box and turns off interactive raster query.
 void set3dBorder(boolean is3d)
          Sets the 3D border facility on or off.
 void setClear(boolean clear)
          Turns screen clearing on or off.
 void setDisplay(int displayType)
          Sets the raster display type.
 void setFullView()
          Resets view so all data are visible.
 void setOverlay(boolean draw)
          Determines if the overlay vector is drawn in the graphics window.
 void setOverlay(VectorMap vectMap, boolean draw)
          Sets the overlay vector map to be drawn in the graphics window.
 void setRubberbandType(int bandType)
          Sets the type of rubberband feature to be displayed.
 void setVectorDisplay(boolean isDisplayed)
          Sets the vector display to on or off.
 void startNetworkQuery()
          Establishes a link (if one does not already exist) between graphics area and mouse for feature queries.
 void startProfileQuery()
          Establishes a link (if one does not already exist) between graphics area and mouse for raster profile query.
 void startRastQuery()
          Establishes a link (if one does not already exist) between graphics area and mouse for raster query.
 void startScaleQuery(int paramType)
          Establishes a link (if one does not already exist) between graphics area and mouse for multi-scale raster query.
 void stopNetworkQuery()
          Breaks the link between graphics area and mouse for feature queries.
 void stopProfileQuery()
          Breaks the link between graphics area and mouse for raster profile query.
 void stopRastQuery()
          Breaks the link between graphics area and mouse for raster query.
 void stopScaleQuery()
          Breaks the link between graphics area and mouse for multi-scale raster query.
 double xToEasting(int x)
          Converts display pixel coordinate into its georeferenced equivalent.
 double yToNorthing(int y)
          Converts display pixel coordinate into its georeferenced equivalent.
 
Methods inherited from class jwo.utils.JWCanvas
componentHidden, componentMoved, componentResized, componentShown, update
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLEAR

public static final int CLEAR
No raster display.

See Also:
Constant Field Values

RASTER

public static final int RASTER
Interpolated k-colour raster.

See Also:
Constant Field Values

SHADED

public static final int SHADED
Shaded relief blended with k-colour raster

See Also:
Constant Field Values

BLEND

public static final int BLEND
Blend surface and drape.

See Also:
Constant Field Values

HUESAT

public static final int HUESAT
Hue-Saturation map.

See Also:
Constant Field Values
Constructor Detail

GraphicsArea

public GraphicsArea()
Creates the canvas onto which graphics will be drawn.

Method Detail

paint

public void paint(Graphics g)
Plots the graphics onto the canvas.

Overrides:
paint in class Canvas
Parameters:
g - The graphics context in which to paint.

displayRast

public boolean displayRast(RastSurf surf,
                           RastSurf drape)
Displays raster object on screen, scaled to the maximum size allowed by the window while preserving aspect ratio.

Parameters:
surf - Raster surface to display.
drape - Drape to display over surface.
Returns:
Boolean value depending on success.

displayVect

public boolean displayVect(VectorMap vectorMap)
Display vector in window, scaled to georegister with any raster objects.

Returns:
Boolean value depending on success.

getDisplay

public int getDisplay()
Reports the currently selected raster display type. Currently supports

Returns:
Raster display type.

setDisplay

public void setDisplay(int displayType)
Sets the raster display type. Currently supports

Parameters:
displayType - Raster display type.

getSurf

public RastSurf getSurf()
Gets the currently displayed raster.

Returns:
Raster currently being displayed.

getDrape

public RastSurf getDrape()
Gets the currently displayed drape.

Returns:
Raster currently being draped.

getImage

public Image getImage()
Returns the current image associated with the graphics area. The size of the image is dependent on the dimensions of the raster.

Returns:
Current image.

getScaledImage

public Image getScaledImage()
Returns the scaled image associated with the graphics area. The size of the image is dependent on the current window size.

Returns:
Current image.

getImageWidth

public int getImageWidth()
Returns the current image width in pixels. This depends on the aspect ratio of the image and the current window size.


getImageHeight

public int getImageHeight()
Returns the current image height in pixels. This depends on the aspect ratio of the image and the current window size.


setVectorDisplay

public void setVectorDisplay(boolean isDisplayed)
Sets the vector display to on or off.

Parameters:
isDisplayed - Determines if vector is displayed or not.

set3dBorder

public void set3dBorder(boolean is3d)
Sets the 3D border facility on or off.

Parameters:
is3d - Determines if border is 3D.

setClear

public void setClear(boolean clear)
Turns screen clearing on or off. Can be used to avoid flickering when performing rapid update. If set to false, screen will not behave well if resized.

Parameters:
clear - Will clear screen on redraw if set to true.

xToEasting

public double xToEasting(int x)
Converts display pixel coordinate into its georeferenced equivalent.

Parameters:
x - pixel x coordinate to convert.
Returns:
Easting represented by pixel coordinate.

yToNorthing

public double yToNorthing(int y)
Converts display pixel coordinate into its georeferenced equivalent.

Parameters:
y - pixel y coordinate to convert.
Returns:
Northing represented by pixel coordinate.

startRastQuery

public void startRastQuery()
Establishes a link (if one does not already exist) between graphics area and mouse for raster query.


startProfileQuery

public void startProfileQuery()
Establishes a link (if one does not already exist) between graphics area and mouse for raster profile query.


startNetworkQuery

public void startNetworkQuery()
Establishes a link (if one does not already exist) between graphics area and mouse for feature queries.


startScaleQuery

public void startScaleQuery(int paramType)
Establishes a link (if one does not already exist) between graphics area and mouse for multi-scale raster query. Initially asks for maximum scale and parameter to calculate.

Parameters:
paramType - Parameter type to calculate on query.

removeRastQueryBox

public void removeRastQueryBox()
Removes the raster query box and turns off interactive raster query.


removeProfileQueryBox

public void removeProfileQueryBox()
Removes the profile query box and turns off interactive profile query.


removeScaleQueryBox

public void removeScaleQueryBox()
Removes the multi-scale raster query box and turns off interactive raster query.


stopRastQuery

public void stopRastQuery()
Breaks the link between graphics area and mouse for raster query.


stopProfileQuery

public void stopProfileQuery()
Breaks the link between graphics area and mouse for raster profile query.


stopNetworkQuery

public void stopNetworkQuery()
Breaks the link between graphics area and mouse for feature queries.


stopScaleQuery

public void stopScaleQuery()
Breaks the link between graphics area and mouse for multi-scale raster query.


setFullView

public void setFullView()
Resets view so all data are visible.


addRubberbandListener

public void addRubberbandListener(RubberbandListener rbListener)
Adds a rubberband listener to the list of objects to be informed when a new rubberband is created.

Parameters:
rbListener - Object listening out for a rubberband event.

removeRubberbandListener

public void removeRubberbandListener(RubberbandListener rbListener)
Removes a given listener from the list of objects to be informed when a new rubberband is created.

Parameters:
rbListener - Object to be removed from listeners.

setRubberbandType

public void setRubberbandType(int bandType)
Sets the type of rubberband feature to be displayed. Can be either a box or line.

Parameters:
bandType - Type of rubberband to display. Can be JWRubberband.BOX or JWRubberband.LINE.
See Also:
JWRubberband

getSubRegion

public JWRectangle getSubRegion()
Reports the currently selected sub-region.

Returns:
Bounds of currently selected sub-region, or full raster/vector if not defined or null if no layers present.

setOverlay

public void setOverlay(VectorMap vectMap,
                       boolean draw)
Sets the overlay vector map to be drawn in the graphics window.

Parameters:
vectMap - The vector map to draw or remove.
draw - True if map is to be drawn, false if it is to be removed.

setOverlay

public void setOverlay(boolean draw)
Determines if the overlay vector is drawn in the graphics window.

Parameters:
draw - True if map is to be drawn, false if it is to be removed.

mouseClicked

public void mouseClicked(MouseEvent mouseEvent)
Checks for mouse clicks, but does nothing. Implements interface method.

Specified by:
mouseClicked in interface MouseListener
Parameters:
mouseEvent - Mouse click event.

mousePressed

public void mousePressed(MouseEvent mouseEvent)
Checks for mouse button press, and reports on the (x,y,z) values at current mouse position. Implements interface method.

Specified by:
mousePressed in interface MouseListener
Parameters:
mouseEvent - Mouse press event.

mouseReleased

public void mouseReleased(MouseEvent mouseEvent)
Checks for mouse button release, and turns off mouse query. Implements interface method.

Specified by:
mouseReleased in interface MouseListener
Parameters:
mouseEvent - Mouse release event.

mouseDragged

public void mouseDragged(MouseEvent mouseEvent)
Checks for mouse dragging and draws a rubberband box in the appropriate location. If profiling is selected, dymically updates it as the mouse is dragged.

Specified by:
mouseDragged in interface MouseMotionListener
Parameters:
mouseEvent - Mouse dragging event.

mouseMoved

public void mouseMoved(MouseEvent mouseEvent)
Checks for mouse movement, but does nothing.

Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
mouseEvent - Mouse movement event.

mouseEntered

public void mouseEntered(MouseEvent mouseEvent)
Checks for pointer entering event, but does nothing. Implements interface method.

Specified by:
mouseEntered in interface MouseListener
Parameters:
mouseEvent - Pointer entering event.

mouseExited

public void mouseExited(MouseEvent mouseEvent)
Checks for pointer exiting event, but does nothing. Implements interface method.

Specified by:
mouseExited in interface MouseListener
Parameters:
mouseEvent - Mouse exiting event.