OpenMap Development
OpenMap Development
TM
What is OpenMapTM?
Visualization of data, situational awareness Java-based programmers toolkit and application (JRE v1.4) User can develop map layers to display private data or standard data formats Runs on any machine with a JVM (Windows, Macintosh, Linux, Solaris, etc.) Compliant with Suns 100% Pure Java certication
Architecture
Application/Applet Embedded Components Image Generation Flexible Layer Congurations
Functionality/Setup
La ye rs
80/20
Application Components
OpenMaps History
1995: OpenMap developed as a web-based (Java) client-server tool 1998: BBN released Java version of OpenMap as open source under the OpenMap Software License Agreement 2009: Version 4.6.5 released March 5
Basic Goals
Section 1
Introduction to OpenMap
Architecture Management
Application Applet Web Server Image Support Custom integration
Component Communication
OpenMap components use the Java Event Model Events are objects that are sent from a source to a listener
Application view
Java components with layout concerns
Data view
Create map objects reecting data source Use Projection to determine which should be displayed
General Architecture
MapBean Component
Main Map Component, Java Container object Manages a projection object Layers are children that listen for projection changes Layer painting controlled by Java AWT thread.
MapHandler Component
Java BeanContext object Object holder for application components Membership Listeners get notied when objects are added and removed Conceptual map - knows that map has one version of some components (SoloMapComponent), handles duplicates
MapPanel holds everything you need JPanel with BeanContext, automatic connections Has MapBean, Menus (as list or MenuBar) Add other components to MapPanel for enhancements Jframe jFrame = new Jframe(Map); BasicMapPanel basicMapPanel = new BasicMapPanel(); // Add MapPanel as Swing Component jFrame.getContentPane().add(basicMapPanel); // If you want to set MenuBar for Map controls jFrame.setJMenuBar(basicMapPanel.getMapMenuBar()); jFrame.pack(); jFrame.show();
Exercise 1
Section 2
OpenMapTM Projections
Datums dene how coordinates are laid out on the projected grid (WGS 84) Projected coordinates are not handled by OpenMap
Projection type
Mercator Orthographic LLXY (EPSG 4236) Gnomonic Lambert Conformal Conic CADRG (Equal Arc for RPF data)
Latitude and longitude of window center Scale factor (zoom level) Pixel height and width of window
ProjectionFactory singleton class ProjectionLoader classes provide information about specic Projections Custom Projections can be added
ProjectionFactory.makeProjection( com.bbn.openmap.proj.Mercator.class, latitude, longitude, scale, windowWidth, windowHeight);
Layer Basics com.bbn.openmap.Layer class Layers are primarily responsible for displaying information on the MapBean Layers should mainly be concerned with rendering themselves properly for the latest projection received from the MapBean The MapBean doesnt care what the Layers are doing
Layers are PropertyConsumers, easily written to be congurable at startup Can provide a GUI palette to remain dynamically congurable Can be added to BeanContext to have access to other application components
Layer.paint(Graphics)
Layer extends JComponent The paint(java.awt.Graphics) method is where Layers draw the map objects Called from JVM AWT Thread Try to be a quick as possible Force paint() method calls with repaint()
Layers and Projection Events When added to the MapBean, a layer will start receiving ProjectionEvents Contains current Projection of map, layer should react accordingly Signicant work should be done in a separate thread (SwingWorker)
Projection changes/ Map resizes
Layer
projectionChanged() prepare() repaint() paint()
Gather data from data sources by any method allowed by JVM Decimal degree lat/lon data or x/y coordinates, WGS84 datum BinaryFile/BufferedBinaryFile used to read data les from any location
Resource datafile File /home/user/datafile URL http://localhost/datafile
OMGraphics are the main classes provided in OpenMap to display map objects Not mandatory, but convenient Contain rendering attributes - colors, stroke Map objects are maintained as objects, can contain more than display information if needed. OMGraphics know how to use the Projection to locate and render themselves
OMGraphics by Type
Many Types
Polygons, Splines Points Lines Arcs, Circles, Ellipses Rectangles Grids, Rasters, Bitmaps OMGeometryList, OMAreaList
The line type species how nodes between coordinates on the shape are connected. Straight lines are drawn in pixel space directly from one node to another (LINETYPE_STRAIGHT) Great circle lines are drawn to represent the shortest path from one point to another (LINETYPE_GREATCIRCLE) Rhumb lines are drawn with a constant directional bearing between nodes (LINETYPE_RHUMB)
OMPoint
Simple location marker Rendered as square or circle, centered over location Size is set for pixel space
OMRasterObjects
OMScalingRaster automatically scales and places images according to corner coordinates OMScalingIcon places image centered over a point, with scaling over that point OMBitmaps place XBM style images on map
2 bit image, not Windows bitmaps
OMPoly can be rendered as polyline (open) or polygon (closed). Polys with ll color are assumed to be closed polygons OMDistance objects are lat/lon rendertype OMPoly objects with labels marking ground distance between nodes OMSplines are polygons/polylines with natural cubic curved lines between nodes
OMLines are single connection between two nodes Can have arrow head at start, end or both, at different points on line Can be rendered with arc in x/y space between points
OMArcs can be chords, pies or open Specied with starting azimuth and angular extent and radius OMCircle can be specied by center location and constant distance radius OMEllipse can have different major and minor axis distance values
OMGrid
OMGrid contains two dimensional array of values, either integers or objects, with equal-arc spacing between values Uses OMGridGenerator to interpret values to create another OMGraphic to represent values on map
OMText
Add text labels to map Uses variety of font types/sized available to JVM Justication, baseline alignment
OMGeometryList contains OMGeometry objects that should be rendered the same way OMGeometry objects only contain location information OMAreaList combines all OMGraphics on list into one polygon
Customized OMGraphics
If OMLabeler added under OMGraphicConstants.LABEL key, OMGraphic will have label presented
Java List wrapper OMGraphicList contains OMGraphics, is an OMGraphic Order and membership can be controlled Can be vague or non-vague
OMGraphics know how to draw themselves on the map OMGraphics MUST be generated with the projection of the MapBean they will be rendered upon, to gure out where they go If OMGraphic parameters are changed, the OMGraphic will determine if it needs to be re-generated OMGraphics that need to be generated will not render themselves OMGraphic.generate(Projection) OMGraphic.render(java.awt.Graphics)
Exercise 2
Section 3
MouseEvent Handling
User mouse movements over the map are translated to MouseEvents, which are distributed to listeners MouseEvents describe location, keys, type of action OpenMap MouseEvent distribution is controlled for predictable application behavior
A MapMouseMode is a MouseEventListener that distributes MouseEvents for a particular purpose Limits distribution when event is consumed MouseDelegator manages MouseModes, determines which one is active MouseDelegator queries Layers for MapMouseListener that handles MouseEvents
Species which MapMouseModes should send events Can be Layer itself, or proxy object
OpenMap MapMouseModes
Abstract CoordMouseMode
Super class that handles display of coordinates with InformationDelegator
NavMouseMode/NavMouseMode2
Click to recenter Click and drag to create zoom box
SelectMouseMode
Interaction with map objects
PanMouseMode
Pan map to new location
If OMGraphics have been generated, they can respond to queries using x/y coordinates from MouseEvents
OMGraphic.contains(x, y) OMGraphic.distance(x, y)
OMGraphicList can provide OMGraphic closest to MouseEvent, providing mechanism to respond to user gestures on map
OMGraphicHandler interface is for any component that manages an OMGraphicList FilterSupport is a support component that manages queries on an OMGraphicList, both spatially and parametized
OMGraphicHandlerLayer New Layer super class, implements OMGraphicHandler Uses policy objects to set how it handles OMGraphics for projection changes and rendering Minimal modications needed to place data on map MouseEvents are Interpreted
On/Over OMGraphics or Map How to react? Uses MapMouseInterpreter
GestureResponsePolicy Guides interpreter on reacting to events over specic OMGraphics Provides information about OMGraphics
ToolTips InfoLine input Popup Menu options
Handles Highlight/Selection
Default: highlight, no selection
OMGraphicHandlerLayer Interpretation
OMGraphicHandlerLayer Interpretation
If over Map
getItemsForMapMenu(MapMouseEvent)
Map events
receivesMapEvents()
leftClick(MapMouseEvent) mouseOver(MapMouseEvent)
Exercise 3
Conversion of layer to OMGraphicHandlerLayer and Interaction with MouseEvents over the Map Objects
Section 4
Application Framework
Addition of layers and components through property le editing. No recompilation needed.
LayerHandler
Manages all layers, both on and off the map Uses layer visibility settings to determine which layers to provide to the MapBean Sends events detailing which layers are available to the application
InformationDelegator
Single interface to present information to User Can provide multiple information lines, pop-up windows, tooltips on map, additional information and browser content
ToolPanel
Main panel that displays Tools, widgets that provide application controls Can grab all available Tools from MapHandler, or can be limited to which tools to use or avoid Several ToolPanels can be used in an application, but coordination is needed to avoid duplicate parentage
Various Tools
OverviewMapHandler (Mini-map) ProjectionStackTool (back-forward) LayersPanel (control layers) OMDrawingToolLauncher (Create OMGraphics) MouseModeButtonPanel
OMDrawingTool
Tool to create or manipulate OMGraphics location, shape and rendering parameters Can be created programmatically or found in the MapHandler Uses EditToolLoaders dynamically to match EditableOMGraphics to requests
LightMapHandlerChild interface
Has findAndInit(Object) and findAndUndo(Object) MapHandlerMenuItem
Exercise 4
Section 5
Using Properties
Java Properties object, set of key value pairs Runtime application conguration with PropertyHandler
openmap.properties text le Can search CLASSPATH and user home directory
PropertyConsumer Interface for component that can be congured by Properties Provides methods for setting and getting properties Also provides methods for gathering information about what properties are available to be set (editors)
void setProperties(String, Properties); void setProperties(Properties); void setPropertyPrefix(String); String getPropertyPrefix(); Properties getProperties(Properties); Properties getPropertyInfo(Properties);
Property les loaded into PropertyHandler Marker Name list used for scoping
openmap.components= mn1 mn2 mn3 mn1.class=com.bbn.openmap.LayerHandler mn2.class=com.bbn.openmap.InformationDelegator mn3.class=classname mn3.firstProperty=value mn3.secondProperty=value
LayerHandler Example
Exercise 5
Run the OpenMap application with an openmap.properties le that reects your current application
Section 6
Animation Techniques
Dont do calculations in paint thread If updates are rapid and random, queue them up for scheduled repaint() occurring in regular intervals
GraphicLoaders
Create OMGraphics from data source and pushes them to OMGraphicHandler receiver Can run in own/external thread For creating dynamic input to layers Can be used with GraphicLoaderPlugIn GraphicLoaderConnector provides automatic hookup to layer using MapHandler
Exercise 6
Section 7
OpenMap has built-in support for various commercial and government data formats Layers congured via properties Three general types of data
Raster (images) Vector (object descriptions) Grid/Coverage
12m /36 ft
Location Data
Locations represent a place and a name Can be read from Comma-Separated Value (CSV) le or database LocationLayer deals with Locations, regardless of source LocationHandler handles coverting data source to Location map objects
For OpenMap 4.6.3, data must be in decimal degree lat/lons Several layer options for display
BufferedShapeLayer
All geometries rendered alike All geometries held in memory
MultiShapeLayer
Renders many shape layers in one layer Each shape le contents rendered independently
AreaShapeLayer
All geometries held in memory Individual geometries rendered with custom attributes set in properties
EsriPlugIn
All geometries held in memory DBF le contents displayed Gestures highlight table entries and map shapes
EsriLayer
Simple, generic All geometries held in memory
Raster Product Format Data created from scanned paper maps and digital imagery Contained in le hierarchy
RPF directory A.TOC le describes contents, sits right inside RPF
RPFLayer requires path to RPF directory RpfLayer can handle multiple RPF directories, but better to create new A.TOC le for many directories
Raster Product Format (continued) Requires CADRG projection for display RpfLayer can scale charts, likes to pick chart type most closely associated with projection scale Map has to be centered over map data and set to zoom level of data Coverage Tool in RpfLayer to assist in nding location of data on map All capital letters, ChangeCase class can modify Recently used images are cached
VPFLayer requires path to top-level directory that contains lat/.lat le Can display in any projection type 1:30,000,000 scale restriction to avoid long delays in gathering data VPFLayer gathers new OMGraphics every projection change
Data is represented by 2 dimensional array of elevation values Level denes spacing between posts:
Level 0: 30 arcsecond spacing (~300 meters) Level 1: 3 arcsecond spacing (~100 meters) Level 2: 1 arcsecond spacing (~30 meters)
Thinned data extracted from level 1 (where available), plus VMAP level 0s elevation data
Recently used frames are cached Mouse clicks create elevation location Map must be positioned over data 1:20,000,000 scale limit DTEDFrameCache can be added to MapHandler and used by other components for elevation retrieval
com.bbn.openmap.layer.terrain.TerrainLayer
Prole, LOS Generators
MapInfo
mif extension com.bbn.openmap.layer.mif.MIFLayer
Vector format Both contain rendering information Simply note data le path for layer to display
Client-Server Layers
OpenMap package includes several client-server components and packages to use for transfer of map data to MapBean over network Object transfer
Link package: BBN developed, simple socket, xml/binary protocol Specialist package: CORBA client layer and servers
Image transfer
WebImagePlugIn clients (SHIS and WMS) SimpleHttpImageServer/SHISPlugIn
PlugIns
Component that provides data access and OMGraphic creation Can be used by layer (PlugInLayer) or server Can respond to MouseEvents Can provide GUI
ScaleFilterLayer A parent layer that switches between child layers, depending on the map scale Need to have one less transition scale than layer count
scaledRoads.class=com.bbn.openmap.layer.ScaleFilterLayer scaledRoads.prettyName=Northeast Roads scaledRoads.layers=neroads neroadsDetailed scaledRoads.transitionScales=150000 neroads.class=com.bbn.openmap.layer.shape.ShapeLayer neroadsDetailed.class=com.bbn.openmap.layer.shape.ShapeLayer
DrawingToolLayer
Receives OMGraphics from OMDrawingTool added to application Save/Load OMGraphics stored as Serialized Objects saved in le Save OMGraphics to Shape le, with restrictions
EditorLayer
Generally used for specic data set representations (creation/editing) Extension of DrawingToolLayer Contains congurable OMDrawingTool
Gestures MapMouseMode acts as a proxy for editing DrawingAttributes access optional
Exporting OMGraphics
Serialized OMGraphics provide best duplicate representation Shape les dont contain rendering information
EsriShapeExport class OMGraphics -> Shape les Points, lines, poly les
Exercise 7
Section 8
OpenMap as an Applet
Applets
Runtime governed by Java sandbox, imposes operational restrictions No access to local system Network access restricted to original server Certicates can open access to local system
</EMBED>
Applet Classpath
CODEBASE parameter, usually parent directory of html le openmap.properties le loaded from there, conguring applet Data can be loaded from jar les or from directories in CODEBASE
More Info
OMAreaList, including uses for creating OMGraphics with holes Using OMScalingRaster for dynamic image scaling How to use the EarthImagePlugin - image created from pixel information from data source for lat, lon Specic DrawingAttributes examples, including ll pattern example, masks Why is there a 180 degree limit on the size of an OMGraphic?
OMAreaList
Used to connect OMGraphics to make a continuous shape. Works like OMGraphicList, add OMGraphics in the order they should be connected. DrawingAttributes set on the parts are ignored, the DrawingAttributes of OMAreaList are used.
OMRasterObject that is anchored at the upper left and lower right corners. Only scales, doesnt warp. Create java.awt.Image in Java, then hand to OMScalingRaster.
ImageIcon to read image le
EarthImagePlugIn
Displays images that are assumed cover the entire planet with Mercator projection. Assumption about image projection allows it to determine color for any lat/lon. Creates image in pixel space by using projection to get lat/lon value for each pixel of image. Performance directly related to size of image.
DrawingAttributes
Line paint (default edge color) Select paint (edge color when OMGraphic selected) Fill paint Fill pattern (from URL le) Matting paint Stroke (line width, dashes, end and caps)
DrawingAttributes Properties
DrawingAttributes (cont.)
PropertyConsumer, can be set from and provide Properties Can push and pull values from OMGraphics
drawingAttributes.setTo(OMGraphic); drawingAttributes.setFrom(OMGraphic);
Fill pattern is provided by image le. Needs path to image le, as resource, le path or URL. Pattern image will be repeated to ll shape. Pattern images with transparency will allow ll paint to show through.
PropUtils Class
Essential for dealing with Properties in code. Conversion methods with defaults File URL location
getResourceOrFileOrURL(String path);