com.jjt.utbeg
Class SwathViewer

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--com.jjt.utbeg.SwathViewer

public final class SwathViewer
extends Panel
implements PropertyChangeListener

Component for drawing the swath image used in Applet1.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
Component.AWTTreeLock, Component.NativeInLightFixer
 
Field Summary
private  int backgroundImageIndex
           
private  Applet imageLoader
           
private  Image[] images
           
private  String[] imageURLs
           
private  double magnification
           
private  int numberOfReceiverLines
           
private  int numberOfSourceLines
           
private  Image offscreenImage
           
private  UserParameters parameters
           
private  Dimension preferredSize
           
private  Color receiverColor
           
private  int receiverLineSpacing
           
private  int receiverStationSpacing
           
private  Color referenceLineColor
           
private  int referenceLineLength
           
private  double scale
           
private  Dimension sizeAt1x
           
private  Color sourceColor
           
private  int sourceLineSpacing
           
private  int sourceStationSpacing
           
private  Point swathUpperLeft
           
 
Fields inherited from class java.awt.Panel
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
SwathViewer(Applet imageLoader, String[] imageURLs, UserParameters parameters)
          Creates a SwathViewer.
 
Method Summary
private  void drawReceiver(Graphics g, int x, int y)
          Draws a single receiver station at the specified point.
private  void drawReceivers(Graphics g)
          Draws all the lines of receivers onto the Graphics.
private  void drawReferenceLines(Graphics g)
          Paints the swath size reference lines on the Graphics.
private  void drawSource(Graphics g, int x, int y)
          Draws a single source station at the specified point.
private  void drawSources(Graphics g)
          Draws all the lines of sources onto the Graphics.
private  void drawSwath(Graphics g)
          Draws the swath onto the Graphics.
private  Point getCenterSwathPoint()
          Calculates the swath center point based on the upper left point and the swath size.
protected  Image getImage()
          Loads and returns the current background image.
 double getMagnification()
          Returns the current "zoom" magnification for this viewer.
 Dimension getMaximumSize()
          Over-ridden Component class method.
 Dimension getMinimumSize()
          Over-ridden Component class method.
 Dimension getPreferredSize()
          Over-ridden Component class method.
private  Point getUpperLeftSwathPoint()
          Returns the upper-left coordinate for the drawn swath.
 void paint(Graphics g)
          Over-ridden Component-class method for drawing this Component on the screen.
protected  void populateSwath()
          Fetches values for this viewer from the current values stored in the UserParameters Object.
 void propertyChange(PropertyChangeEvent event)
          This method is public as an implementation side-effect.
private  void reallyRepaint()
          Resets the offscreen image cache and repaint()s.
private  void rescale(Dimension componentSize)
          Sets the pixel-to-feet scale based on the given pixel size.
private  int scale(double lengthInFeet)
          Scales the given value (in feet) into a length in pixels.
 void setBackgroundImage(int index)
          Sets the currently displayed background image to the nth image in the image array.
 void setMagnification(double zoomX)
          Sets the "zoom" factor for this viewer.
private  void setNewSwathPosition(Point centerPoint)
          Sets a new position for the swath drawn within the viewer.
 
Methods inherited from class java.awt.Panel
addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
, add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMouseEventTarget, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, update, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

imageURLs

private String[] imageURLs

images

private Image[] images

backgroundImageIndex

private int backgroundImageIndex

imageLoader

private Applet imageLoader

parameters

private UserParameters parameters

preferredSize

private Dimension preferredSize

offscreenImage

private Image offscreenImage

magnification

private double magnification

scale

private double scale

sourceStationSpacing

private int sourceStationSpacing

receiverStationSpacing

private int receiverStationSpacing

sourceLineSpacing

private int sourceLineSpacing

receiverLineSpacing

private int receiverLineSpacing

numberOfSourceLines

private int numberOfSourceLines

numberOfReceiverLines

private int numberOfReceiverLines

swathUpperLeft

private Point swathUpperLeft

referenceLineLength

private int referenceLineLength

referenceLineColor

private Color referenceLineColor

sourceColor

private Color sourceColor

receiverColor

private Color receiverColor

sizeAt1x

private Dimension sizeAt1x
Constructor Detail

SwathViewer

public SwathViewer(Applet imageLoader,
                   String[] imageURLs,
                   UserParameters parameters)
Creates a SwathViewer.
Parameters:
imageLoader - the Applet to use for loading Image Objects from URL Strings. The Applet.getImage(URL) method is used for loading images.
imageURLs - the URL Strings for the 8 images to display for the various depths.
parameters - the UserParameters Object that will determine how the swath is drawn. Values in the Object will be modified real-time by the human.
Method Detail

setBackgroundImage

public void setBackgroundImage(int index)
Sets the currently displayed background image to the nth image in the image array.

The imageURLs array has 8 images, representing various depths. This method sets which one should be painted.

Parameters:
index - the 0-based index of the image to display.

paint

public void paint(Graphics g)
Over-ridden Component-class method for drawing this Component on the screen.
Overrides:
paint in class Container

drawSwath

private void drawSwath(Graphics g)
Draws the swath onto the Graphics.

This method calls drawReferenceLines(), drawSources(), and drawReceivers().

See Also:
#drawReferenceLines(), #drawSources(), #drawReceivers()

drawReferenceLines

private void drawReferenceLines(Graphics g)
Paints the swath size reference lines on the Graphics.

drawSources

private void drawSources(Graphics g)
Draws all the lines of sources onto the Graphics.

drawReceivers

private void drawReceivers(Graphics g)
Draws all the lines of receivers onto the Graphics.

reallyRepaint

private void reallyRepaint()
Resets the offscreen image cache and repaint()s.

getUpperLeftSwathPoint

private Point getUpperLeftSwathPoint()
Returns the upper-left coordinate for the drawn swath.
Returns:
the upper-left point, in pixel coordinates.

getCenterSwathPoint

private Point getCenterSwathPoint()
Calculates the swath center point based on the upper left point and the swath size.

setNewSwathPosition

private void setNewSwathPosition(Point centerPoint)
Sets a new position for the swath drawn within the viewer.

The swath position is actually remembered as the upper left corner, but the position given is the center point, where the human clicked. This method must calculate the upper left point relative to the given center point.


scale

private int scale(double lengthInFeet)
Scales the given value (in feet) into a length in pixels.
Parameters:
lengthInFeet - the number of feet to scale.
Returns:
the number of pixels that should represent the length in feet.

rescale

private void rescale(Dimension componentSize)
Sets the pixel-to-feet scale based on the given pixel size.

This component should be roughly 12000 feet in the y dimension by 6000 feet in the x.


drawSource

private void drawSource(Graphics g,
                        int x,
                        int y)
Draws a single source station at the specified point.

A source station is drawn as an O.


drawReceiver

private void drawReceiver(Graphics g,
                          int x,
                          int y)
Draws a single receiver station at the specified point.

A receiver station is drawn as an X.


populateSwath

protected void populateSwath()
Fetches values for this viewer from the current values stored in the UserParameters Object.

getImage

protected Image getImage()
Loads and returns the current background image.

propertyChange

public void propertyChange(PropertyChangeEvent event)
This method is public as an implementation side-effect.

Called when a user parameter is changed.

Specified by:
propertyChange in interface PropertyChangeListener

getPreferredSize

public Dimension getPreferredSize()
Over-ridden Component class method.

getPreferredSize(), getMinimumSize(), and getMaximumSize() are over-ridden to return the same fixed size.

Overrides:
getPreferredSize in class Container

getMinimumSize

public Dimension getMinimumSize()
Over-ridden Component class method.

getPreferredSize(), getMinimumSize(), and getMaximumSize() are over-ridden to return the same fixed size.

Overrides:
getMinimumSize in class Container

getMaximumSize

public Dimension getMaximumSize()
Over-ridden Component class method.

getPreferredSize(), getMinimumSize(), and getMaximumSize() are over-ridden to return the same fixed size.

Overrides:
getMaximumSize in class Container

setMagnification

public void setMagnification(double zoomX)
Sets the "zoom" factor for this viewer.
Parameters:
zoomX - the number of "times" normal size this viewer should appear. For example, a value of 3.0 would make the viewer 3 times its normal size.

getMagnification

public double getMagnification()
Returns the current "zoom" magnification for this viewer.
Returns:
the current magnification, where 1.0 is normal size, and, i.e., 4.0 is four times normal size.