flatscapex.openmap
Class MapLayer

java.lang.Object
  |
  +--flatscapex.openmap.MapLayer
All Implemented Interfaces:
Configurable, FMapLayer

public class MapLayer
extends java.lang.Object
implements FMapLayer, Configurable

Draws a background map in Flatscape from CADRG files listed in a Table of Contents File.

The following is an example of the MAPLAYER tag needed to initialize this class:

<MAPLAYER class="flatscapex.openmap.MapLayer"> <LATLON nwlat="22.5" nwlon="-160.0" selat="19.0" selon="-154.5"/> <TOCPATHS path="./map/RPF/"/> </MAPLAYER> This class assumes that the base scale is 250,000:1. NOTE: this has some drift after zooming in > 300


Field Summary
 float baseScale
           
 
Constructor Summary
MapLayer()
           
 
Method Summary
 java.lang.Object config(java.lang.Object parent, org.w3c.dom.Element config)
          Creates a cache to access the store the SubFrames needed to cover the current window.
 void drawMap(java.awt.Graphics2D g)
          This is called from the Flatscape paint method.
 java.awt.geom.Point2D inverse(double screenY, double screenX)
          Use the current flatscape information and the current projection to find the Lat/Lon of a point that was picked on the screen.
 void resetCenter(flatscape.FCanvas.Info info)
          Calculates the lat lon of the center of the screen after the user moves the map using the difference between the previous info and the current one.
 void setProj(flatscape.FCanvas.Info info)
          Calculates the offset for rotation creates as stores new CADRG projection to draw the map and compute the inverse function.
static java.lang.String truncate(java.lang.String numString, int places)
          Truncate a floating point number to have a given number of places after the decimal point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseScale

public final float baseScale
See Also:
Constant Field Values
Constructor Detail

MapLayer

public MapLayer()
Method Detail

config

public java.lang.Object config(java.lang.Object parent,
                               org.w3c.dom.Element config)
                        throws java.lang.Exception
Creates a cache to access the store the SubFrames needed to cover the current window.

Specified by:
config in interface Configurable
Parameters:
parent - the AbstractViewer object that uses this MapLayer to draw
config - The DOM element representing the XML element that loaded this class.
Returns:
The configured class, usually returns this.
Throws:
java.lang.Exception - Thrown if there is any problem configuring this class.

drawMap

public void drawMap(java.awt.Graphics2D g)
This is called from the Flatscape paint method.

Specified by:
drawMap in interface FMapLayer
Parameters:
g - Graphics to draw on the Flatscape window.

resetCenter

public void resetCenter(flatscape.FCanvas.Info info)
Calculates the lat lon of the center of the screen after the user moves the map using the difference between the previous info and the current one. Assumes that only one of rotation, scale or translation has changed since the last call.

Specified by:
resetCenter in interface FMapLayer
Parameters:
info - the new Info structure from FCanvas.

setProj

public void setProj(flatscape.FCanvas.Info info)
Description copied from interface: FMapLayer
Calculates the offset for rotation creates as stores new CADRG projection to draw the map and compute the inverse function. NOTE: this really should be the same calculation as in resetCenter!

Specified by:
setProj in interface FMapLayer
Parameters:
info - the new Info structure from FCanvas.

inverse

public java.awt.geom.Point2D inverse(double screenY,
                                     double screenX)
Use the current flatscape information and the current projection to find the Lat/Lon of a point that was picked on the screen.

Specified by:
inverse in interface FMapLayer
Parameters:
screenY - the vertical distance from the 0,0 point
screenX - the horizontal distance from the 0,0 point

truncate

public static java.lang.String truncate(java.lang.String numString,
                                        int places)
Truncate a floating point number to have a given number of places after the decimal point. Later can have padding for the start and a - sign if the whole string length must be constant.

Parameters:
numString - the original String
places - the number of places after the decimal point


Copyright (c) 2003 Rutgers, The State University of New Jersey