com.bbn.openmap.plugin.esri
Class EsriPlugIn

java.lang.Object
  extended by com.bbn.openmap.plugin.AbstractPlugIn
      extended by com.bbn.openmap.plugin.BeanContextAbstractPlugIn
          extended by com.bbn.openmap.plugin.esri.EsriPlugIn
All Implemented Interfaces:
ShapeConstants, MapMouseListener, PlugIn, PropertyConsumer, DataBoundsProvider, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.util.EventListener

public class EsriPlugIn
extends BeanContextAbstractPlugIn
implements ShapeConstants, DataBoundsProvider

EsriPlugIn loads Esri shape file sets from web servers or local file systems, and it enables the creation of shape file sets. It needs to be inserted into a PlugInLayer to use within OpenMap.

To create a file from a remote location:

 
 URL shp = new URL("http://www.webserver.com/file.shp");
 URL dbf = new URL("http://www.webserver.com/file.dbf");
 URL shx = new URL("http://www.webserver.com/file.shx");
 EsriPlugIn epi = new EsriPlugIn("name", dbf, shp, shx);
 PlugInLayer pil = new PlugInLayer();
 pil.setPlugIn(epi);
 
 
To open a shape file set from the local file system:
 
 File dbf = new File("c:/data/file.dbf");
 File shp = new File("c:/data/file.shp");
 File shx = new File("c:/data/file.shx");
 EsriPlugIn epi = new EsriPlugIn("name", dbf.toURI().toURL(), shp.toURI().toURL(), shx.toURI().toURL());
 PlugInLayer pil = new PlugInLayer();
 pil.setPlugIn(epi);
 
 
To create a zero content shape file set from which the user can add shapes at runtime:
 EsriPlugIn epi = new EsriPlugIn("name", EsriLayer.TYPE_POLYLINE);
 
 
To add features to an EsriLayer:
 
 OMGraphicList shapeData = new OMGraphicList();
 ArrayList tabularData = new ArrayList();
 float[] part0 = new float[] { 35.0f, -120.0f, -25.0f, -95.0f, 56.0f, -30.0f };
 float[] part1 = new float[] { -15.0f, -110.0f, 13.0f, -80.0f, -25.0f, 10.0f };
 OMPoly poly0 = new OMPoly(part0, OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_RHUMB);
 OMPoly poly1 = new OMPoly(part1, OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_RHUMB);
 shapeData.add(poly0); //part 1
 shapeData.add(poly1); //part 2
 shapeData.generate(_mapBean.getProjection());
 tabularData.add(0, "a value");
 plugin.addRecord(shapeData, tabularData);
 plugin.repaint(); // assumes that plugin added to PlugInLayer
 
 
To configure an EsriLayer through a properties file, specify file references in terms of URLs, full or relative file paths. To reference a file on Windows 2000:
    
    
       esri.class = com.bbn.openmap.plugin.esri.EsriPlugIn
       esri.prettyName = Esri Example
       esri.shp = file:///c:/data/shapefile.shp
     # -or-
       esri.shp = c:/data/shapefile.shp
    
       esri.dbf = file:///c:/data/shapefile.dbf
       esri.shx = file:///c:/data/shapefile.shx
    
     
 
To reference a file on RedHat Linux 6.2:
    
    
       esri.class = com.bbn.openmap.plugin.esri.EsriPlugIn
       esri.prettyName = Esri Example
       esri.shp = file:///home/dvanauke/resources/shapefile.shp
     # - or -
       esri.shp = /home/dvanauke/resources/shapefile.shp
    
       esri.dbf = file:///home/dvanauke/resources/shapefile.dbf
       esri.shx = file:///home/dvanauke/resources/shapefile.shx
    
     
 
To reference a file on a web server:
    
    
       esri.class = com.bbn.openmap.plugin.esri.EsriPlugIn
       esri.prettyName = Esri Example
       esri.shp = http://www.webserver.com/shapefile.shp
       esri.dbf = http://www.webserver.com/shapefile.dbf
       esri.shx = http://www.webserver.com/shapefile.shx
    
     
 
The PlugIn has been updated to use the properties from the DrawingAttributes object in order to specify how it's objects should be rendered:
    
    
       esri.class = com.bbn.openmap.plugin.esri.EsriPlugIn
       esri.prettyName = Esri Example
       esri.lineColor = AARRGGBB (hex ARGB color)
       esri.fillColor = AARRGGBB (hex ARGB color)
       esri.selectColor = AARRGGBB (hex ARGB color)
       esri.lineWidth = AARRGGBB (hex ARGB color)
    
     
 
See DrawingAttributes for more options. Also, as of OpenMap 4.5.4, you don't have to specify the location of the .dbf and .shx files. If you don't, the plugin assumes that those files are next to the .shp file.

Author:
Doug Van Auken, Don Dietrick, Lonnie Goad from OptiMetrics provided selection bug solution and GUI interaction.

Field Summary
protected  javax.swing.JPanel daGUI
           
protected  DrawingAttributes drawingAttributes
           
protected  int graphicIndex
          This marks the index of the OMGraphic that is "selected"
protected  javax.swing.ListSelectionModel lsm
           
protected  Layer parentLayer
           
protected  Projection proj
          The last projection.
protected  OMGraphicList selectedGraphics
          A simple list mechanism that will let selected OMGraphics to be drawn on top of all the others.
protected  javax.swing.JTable table
           
protected  javax.swing.JFrame tableFrame
           
 
Fields inherited from class com.bbn.openmap.plugin.BeanContextAbstractPlugIn
beanContextChildSupport
 
Fields inherited from class com.bbn.openmap.plugin.AbstractPlugIn
addToBeanContext, component, i18n, mml, name, prefix, removable, RemovableProperty
 
Fields inherited from interface com.bbn.openmap.dataAccess.shape.ShapeConstants
DBF_ATTRIBUTE, DBF_AUTOINCREMENT, DBF_BINARY, DBF_CHARACTER, DBF_DATE, DBF_DOUBLE, DBF_FLOAT, DBF_LOGICAL, DBF_LONG, DBF_MEMO, DBF_NUMERIC, DBF_OLE, DBF_TIMESTAMP, DBF_TYPE_AUTOINCREMENT, DBF_TYPE_BINARY, DBF_TYPE_CHARACTER, DBF_TYPE_DATE, DBF_TYPE_DOUBLE, DBF_TYPE_FLOAT, DBF_TYPE_LOGICAL, DBF_TYPE_LONG, DBF_TYPE_MEMO, DBF_TYPE_NUMERIC, DBF_TYPE_OLE, DBF_TYPE_TIMESTAMP, PARAM_DBF, PARAM_SHP, PARAM_SHX, SHAPE_BOUNDS_ATTRIBUTE, SHAPE_DBF_DASHPATTERN, SHAPE_DBF_DASHPHASE, SHAPE_DBF_DESCRIPTION, SHAPE_DBF_FILLCOLOR, SHAPE_DBF_INFO_ATTRIBUTE, SHAPE_DBF_LINECOLOR, SHAPE_DBF_LINEWIDTH, SHAPE_DBF_SELECTCOLOR, SHAPE_FILE_HEADER_LENGTH, SHAPE_FILE_RECORD_HEADER_LENGTH, SHAPE_INDEX_ATTRIBUTE, SHAPE_MAX_MEASURE_ATTRIBUTE, SHAPE_MAX_Z_ATTRIBUTE, SHAPE_MEASURE_ATTRIBUTE, SHAPE_MIN_MEASURE_ATTRIBUTE, SHAPE_MIN_Z_ATTRIBUTE, SHAPE_TYPE_ARC, SHAPE_TYPE_MULTIPATCH, SHAPE_TYPE_MULTIPOINT, SHAPE_TYPE_MULTIPOINTM, SHAPE_TYPE_MULTIPOINTZ, SHAPE_TYPE_NULL, SHAPE_TYPE_POINT, SHAPE_TYPE_POINTM, SHAPE_TYPE_POINTZ, SHAPE_TYPE_POLYGON, SHAPE_TYPE_POLYGONM, SHAPE_TYPE_POLYGONZ, SHAPE_TYPE_POLYLINE, SHAPE_TYPE_POLYLINEM, SHAPE_TYPE_POLYLINEZ, SHAPE_Z_ATTRIBUTE
 
Fields inherited from interface com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Constructor Summary
EsriPlugIn()
          Creates an EsriPlugIn that will be configured through the setProperties() method
EsriPlugIn(java.lang.String name, int type, int columnCount)
          Creates an empty EsriPlugIn, usable for adding features at run-time.
EsriPlugIn(java.lang.String name, java.net.URL dbf, java.net.URL shp, java.net.URL shx)
          Creates an EsriPlugIn from a set of shape files
 
Method Summary
 void addRecord(OMGraphic graphic, java.util.ArrayList<java.lang.Object> record)
          Handles adding records to the geometry list and the DbfTableModel.
 DataBounds getDataBounds()
          DataBoundsInformer interface.
 java.lang.String getDescription(int index)
          Builds a description in HTML for a tool tip for the specified OMGraphic
 DrawingAttributes getDrawingAttributes()
          Get the drawing attributes for the graphics on the list.
 EsriGraphicList getEsriGraphicList()
          Returns the EsriGraphicList for this layer
 EsriGraphicList getGeometry(java.net.URL shp)
          Reads the contents of the SHP file.
 EsriGraphicList getGeometry(java.net.URL shp, java.net.URL shx)
          Deprecated. Use getGeometry(URL) instead, the shx file isn't used.
 java.awt.Component getGUI()
          Gives the PlugIn a chance to present components that control its attributes.
 DbfTableModel getModel()
          Returns the associated table model for this layer
 java.util.Properties getProperties(java.util.Properties props)
          Method to fill in a Properties object, reflecting the current values of the PropertyConsumer.
 java.util.Properties getPropertyInfo(java.util.Properties props)
          Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer.
 OMGraphicList getRectangle(Projection p)
          The getRectangle call is the main call into the PlugIn module.
 javax.swing.JTable getTable()
          Needs to be called before displaying the DbfTableModel.
 int getType()
          Returns whether this layer is of type 0 (point), 3 (polyline), or 5(polygon)
static void main(java.lang.String[] argv)
           
 boolean mouseClicked(java.awt.event.MouseEvent e)
          Handle a mouse click on the map.
 boolean mouseMoved(java.awt.event.MouseEvent e)
          Handle mouse moved events (Used for firing tool tip descriptions over graphics)
 void query(java.lang.String query)
          Filters the DbfTableModel given a SQL like string
 void selectEntry(OMGraphic graphic)
          Given a graphic, highlight its entry in the table.
 void selectGraphic(int index)
          Mark a graphic as selected on the map.
 void selectGraphic(OMGraphic graphic)
          Mark the graphic as selected, and generate if necessary.
 void setDrawingAttributes(DrawingAttributes da)
          Set the drawing attributes for the graphics on the list.
 void setDrawingAttributes(OMGraphic omg)
          Sets the drawing attributes to those of a particular OMGraphic.
 void setModel(DbfTableModel model)
          Sets the DbfTableModel
 void setProperties(java.lang.String prefix, java.util.Properties properties)
          Sets the properties for the Layer.
 void showTable()
          Show the table in its own frame.
 
Methods inherited from class com.bbn.openmap.plugin.BeanContextAbstractPlugIn
addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, findAndInit, findAndUndo, firePropertyChange, fireVetoableChange, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 
Methods inherited from class com.bbn.openmap.plugin.AbstractPlugIn
dispose, doPrepare, getAddToBeanContext, getComponent, getMapMouseListener, getMouseModeServiceList, getName, getPropertyPrefix, isRemovable, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, removed, repaint, setAddToBeanContext, setComponent, setMapMouseListener, setName, setProperties, setPropertyPrefix, setRemovable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bbn.openmap.util.DataBoundsProvider
getName
 

Field Detail

selectedGraphics

protected OMGraphicList selectedGraphics
A simple list mechanism that will let selected OMGraphics to be drawn on top of all the others. Using this list instead of changing the order of the esri graphic list maintains the order of that list. We clear out this and add to it as necessary.


proj

protected Projection proj
The last projection.


drawingAttributes

protected DrawingAttributes drawingAttributes

table

protected javax.swing.JTable table

lsm

protected javax.swing.ListSelectionModel lsm

parentLayer

protected Layer parentLayer

daGUI

protected javax.swing.JPanel daGUI

tableFrame

protected javax.swing.JFrame tableFrame

graphicIndex

protected int graphicIndex
This marks the index of the OMGraphic that is "selected"

Constructor Detail

EsriPlugIn

public EsriPlugIn()
Creates an EsriPlugIn that will be configured through the setProperties() method


EsriPlugIn

public EsriPlugIn(java.lang.String name,
                  int type,
                  int columnCount)
           throws java.lang.Exception
Creates an empty EsriPlugIn, usable for adding features at run-time.

Parameters:
name - The name of the layer
type - The type of layer
columnCount - The number of columns in the dbf model
Throws:
java.lang.Exception

EsriPlugIn

public EsriPlugIn(java.lang.String name,
                  java.net.URL dbf,
                  java.net.URL shp,
                  java.net.URL shx)
Creates an EsriPlugIn from a set of shape files

Parameters:
name - The name of the layer that may be used to reference the layer
dbf - The url referencing the dbf extension file
shp - The url referencing the shp extension file
shx - The url referencing the shx extension file
Method Detail

setDrawingAttributes

public void setDrawingAttributes(DrawingAttributes da)
Set the drawing attributes for the graphics on the list.


getDrawingAttributes

public DrawingAttributes getDrawingAttributes()
Get the drawing attributes for the graphics on the list.


addRecord

public void addRecord(OMGraphic graphic,
                      java.util.ArrayList<java.lang.Object> record)
Handles adding records to the geometry list and the DbfTableModel.

Parameters:
graphic - An OMGraphic to add the graphics list
record - A record to add to the DbfTableModel

getEsriGraphicList

public EsriGraphicList getEsriGraphicList()
Returns the EsriGraphicList for this layer

Returns:
The EsriGraphicList for this layer

main

public static void main(java.lang.String[] argv)

getRectangle

public OMGraphicList getRectangle(Projection p)
The getRectangle call is the main call into the PlugIn module. The module is expected to fill a graphics list with objects that are within the screen parameters passed. It's assumed that the PlugIn will call generate(projection) on the OMGraphics returned! If you don't call generate on the OMGraphics, they will not be displayed on the map.

Specified by:
getRectangle in interface PlugIn
Specified by:
getRectangle in class AbstractPlugIn
Parameters:
p - projection of the screen, holding scale, center coords, height, width. May be null if the parent component hasn't been given a projection.
Returns:
OMGraphicList.
See Also:
Projection, OMGraphicList

getGeometry

public EsriGraphicList getGeometry(java.net.URL shp,
                                   java.net.URL shx)
Deprecated. Use getGeometry(URL) instead, the shx file isn't used.

Reads the contents of the SHX and SHP files. The SHX file will be read first by utilizing the ShapeIndex.open method. This method will return a list of offsets, which the AbstractSupport.open method will use to iterate through the contents of the SHP file.

Parameters:
shp - The url of the SHP file
shx - The url of the SHX file (not used, OK if null).
Returns:
A new EsriGraphicList, null if something went badly.

getGeometry

public EsriGraphicList getGeometry(java.net.URL shp)
Reads the contents of the SHP file.

Parameters:
shp - The url of the SHP file
Returns:
A new EsriGraphicList, null if something went badly.

getModel

public DbfTableModel getModel()
Returns the associated table model for this layer

Returns:
The associated table model for this layer

getType

public int getType()
Returns whether this layer is of type 0 (point), 3 (polyline), or 5(polygon)

Returns:
An int representing the type of layer, as specified in Esri's shape file format specification

query

public void query(java.lang.String query)
Filters the DbfTableModel given a SQL like string

Parameters:
query - A SQL like string to filter the DbfTableModel

setModel

public void setModel(DbfTableModel model)
Sets the DbfTableModel

Parameters:
model - The DbfModel to set for this layer

setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties properties)
Sets the properties for the Layer.

Specified by:
setProperties in interface PropertyConsumer
Overrides:
setProperties in class AbstractPlugIn
Parameters:
prefix - the token to prefix the property names
properties - the Properties object

getProperties

public java.util.Properties getProperties(java.util.Properties props)
Description copied from class: AbstractPlugIn
Method to fill in a Properties object, reflecting the current values of the PropertyConsumer. If the PropertyConsumer has a prefix set, the property keys should have that prefix plus a separating '.' prepended to each property key it uses for configuration.

Specified by:
getProperties in interface PropertyConsumer
Overrides:
getProperties in class AbstractPlugIn
Parameters:
props - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

getPropertyInfo

public java.util.Properties getPropertyInfo(java.util.Properties props)
Description copied from class: AbstractPlugIn
Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer. The key for each property should be the raw property name (without a prefix) with a value that is a String that describes what the property key represents, along with any other information about the property that would be helpful (range, default value, etc.).

Specified by:
getPropertyInfo in interface PropertyConsumer
Overrides:
getPropertyInfo in class AbstractPlugIn
Parameters:
props - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

getGUI

public java.awt.Component getGUI()
Description copied from interface: PlugIn
Gives the PlugIn a chance to present components that control its attributes.

Specified by:
getGUI in interface PlugIn
Overrides:
getGUI in class AbstractPlugIn

setDrawingAttributes

public void setDrawingAttributes(OMGraphic omg)
Sets the drawing attributes to those of a particular OMGraphic.


getTable

public javax.swing.JTable getTable()
Needs to be called before displaying the DbfTableModel.


selectGraphic

public void selectGraphic(int index)
Mark a graphic as selected on the map.

Parameters:
index - the index, from 0, of the graphic on the list.

selectGraphic

public void selectGraphic(OMGraphic graphic)
Mark the graphic as selected, and generate if necessary.


selectEntry

public void selectEntry(OMGraphic graphic)
Given a graphic, highlight its entry in the table.


showTable

public void showTable()
Show the table in its own frame.


mouseClicked

public boolean mouseClicked(java.awt.event.MouseEvent e)
Handle a mouse click on the map.

Specified by:
mouseClicked in interface MapMouseListener
Overrides:
mouseClicked in class AbstractPlugIn
Parameters:
e - MouseEvent
Returns:
true if the listener was able to process the event.

mouseMoved

public boolean mouseMoved(java.awt.event.MouseEvent e)
Handle mouse moved events (Used for firing tool tip descriptions over graphics)

Specified by:
mouseMoved in interface MapMouseListener
Overrides:
mouseMoved in class AbstractPlugIn
Parameters:
e - MouseEvent
Returns:
true if the listener was able to process the event.

getDescription

public java.lang.String getDescription(int index)
Builds a description in HTML for a tool tip for the specified OMGraphic

Parameters:
index - the index of the graphic in the table

getDataBounds

public DataBounds getDataBounds()
DataBoundsInformer interface.

Specified by:
getDataBounds in interface DataBoundsProvider
Returns:
a DataBounds object describing the area of coverage, may be null if the data hasn't been evaluated yet.


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