## com.bbn.openmap.layer.terrain
Class ProfileGenerator

    java.lang.Object
      com.bbn.openmap.layer.terrain.ProfileGenerator

All Implemented Interfaces:
  TerrainTool

public class ProfileGenerator
extends java.lang.Object
implements TerrainTool

This tool lets the user draw a line on the map, and then presents the profile of the path in a GIF picture. The line can be drawn in a series if clicks, or the mouse button can be held down as the mouse is dragged around. The lines are drawn as great circle lines, which represent the straight geographical line between clicks.

The profile tool uses the ProfileStateMachine, and the Profile States, to keep track of the proper actions and reactions of user input.

Field Summary
`java.util.Vector` `coords` Array of LatLonPoints.
`protected OMGraphicList` `graphics` The list of graphics to draw.
`protected TerrainLayer` `layer` The layer that the tool is serving.
`OMPoly` `profileLine` The line drawn on the screen representing the profile line path.
`protected com.bbn.openmap.layer.terrain.ProfileStateMachine` `stateMachine` The state machine for user gestures.
`java.util.Vector` `xypoints` These are the raw x-y points of the gestures, for the great circle line points, too.

Fields inherited from interface com.bbn.openmap.layer.terrain.TerrainTool
`MAX_SPACE_BETWEEN_PIXELS`

Constructor Summary
`ProfileGenerator(TerrainLayer tLayer)`

Method Summary
`protected void` `addGreatCirclePoints(java.awt.event.MouseEvent beginning, java.awt.event.MouseEvent ending)` Figure out the internal points to create a great circle line between two points on the screen.
`protected void` `addProfileEvent(java.awt.event.MouseEvent event)` Used to keep track of another point for the line, as determined by the state machine.
`protected void` `createGIFFile(int distance, int max, int[] post_dist, int[] post_height)` Create the image and write it the location.
`void` `createProfileImage()` Creates the line points for the path drawn on the screen, and collects the elevation values for those points.
`OMGraphicList` `getGraphics()` Get the current list of graphics from the tool.
`State` `getState()` Returns the current state of the state machine.
`void` `init()` Create the line object, the state machine, and the vectors used to keep track of the line being drawn.
`void` `reset()` Clears the line from the screen, and resets the state machine.
`float[]` `setLLPoints()` Returns a set of lat lon points that represent the line as it was drawn.
`void` `setScreenParameters(Projection p)` Let the tool know what the screen looks like.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### stateMachine

    protected com.bbn.openmap.layer.terrain.ProfileStateMachine stateMachine

  The state machine for user gestures.

### layer

    protected TerrainLayer layer

  The layer that the tool is serving.

### graphics

    protected OMGraphicList graphics

  The list of graphics to draw. Contains the drawn line.

### coords

    public java.util.Vector coords

  Array of LatLonPoints. The points are the clicked points, and the points in between, on a great circle. Have to figure these points out, and not rely only on the poly line points, because we need to get the elevations for all the points for the profile.

### xypoints

    public java.util.Vector xypoints

  These are the raw x-y points of the gestures, for the great circle line points, too. These are used to construct the profile image. An array of java.awt.Points.

### profileLine

    public OMPoly profileLine

  The line drawn on the screen representing the profile line path.

Constructor Detail

### ProfileGenerator

    public ProfileGenerator(TerrainLayer tLayer)

Method Detail

### getGraphics

    public OMGraphicList getGraphics()

  Description copied from interface: `TerrainTool`
  Get the current list of graphics from the tool.

  Specified by:
    `getGraphics` in interface `TerrainTool`

### init

    public void init()

  Create the line object, the state machine, and the vectors used to keep track of the line being drawn.

  Specified by:
    `init` in interface `TerrainTool`

### reset

    public void reset()

  Clears the line from the screen, and resets the state machine.

  Specified by:
    `reset` in interface `TerrainTool`

### setScreenParameters

    public void setScreenParameters(Projection p)

  Description copied from interface: `TerrainTool`
  Let the tool know what the screen looks like.

  Specified by:
    `setScreenParameters` in interface `TerrainTool`

### setLLPoints

    public float[] setLLPoints()

  Returns a set of lat lon points that represent the line as it was drawn. The lat lon points are in an array of floats, that alternate, lat, lon, etc.

### getState

    public State getState()

  Returns the current state of the state machine.

  Specified by:
    `getState` in interface `TerrainTool`

### createProfileImage

    public void createProfileImage()

  Creates the line points for the path drawn on the screen, and collects the elevation values for those points. Makes the call to write the new gif file to disk.

### createGIFFile

    protected void createGIFFile(int distance,
                                 int max,
                                 int[] post_dist,
                                 int[] post_height)

  Create the image and write it the location.

  Parameters:
    `distance` - total length of line, in pixels
    `max` - highest point, in meters of all the heights in the line.
    `post_dist` - array of pixel distances between the points
    `post_height` - the array of heights

### addProfileEvent

    protected void addProfileEvent(java.awt.event.MouseEvent event)

  Used to keep track of another point for the line, as determined by the state machine.

  Parameters:
    `event` - Mouse event that supplies the location

### addGreatCirclePoints

    protected void addGreatCirclePoints(java.awt.event.MouseEvent beginning,
                                        java.awt.event.MouseEvent ending)

  Figure out the internal points to create a great circle line between two points on the screen. The interior points are added to the coords array, but not to the xy points array.

  Parameters:
    `beginning` - the starting mouse event
    `ending` - the ending mouse event

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details