|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.layer.shape.areas.AreaHandler
public class AreaHandler
An object to organize graphics in a shapefile and their corresponding attributes in OpenMap. A properties object can determine how areas/graphics are to be colored, or you can grab the graphics directly and color them yourself. It's called AreaHandler because it was originally intended to be a management tool for political boundary areas, but it should work for all shapefiles, really. This object uses a CSV file created from the DBF file that usually accompanies the shapefile. Also, this class does inflict a startup burden on the map. Because all the organizational effort occurs in setProperties(), it occurs even if the handler isn't used in an active Layer.
Here is a sample of what this thing is looking for by way of properties:
layer.class=com.bbn.openmap.layer.shape.areas.AreaShapeLayer layer.prettyName=Layer Name layer.shapeFile=/usr/local/data/shape/shapefile.shp layer.spatialIndex=/usr/local/data/shape/shapefile.ssx # Now, provide a data file that says what the shapes in the .shp # file are. You can use the DBF file: layer.dbfFile=/usr/local/data/shape/shapefile.dbf # OR a csv file, created yourself or from the .dbf file. There # should be the same number of entries in the .csv file that are in # the .shp file. layer.csvFile=/usr/local/data/shape/shapefile.csv # An attribute to tell the AreaHandler to skip over the first row # of the csv file if it contains descriptive column header names. layer.csvFileHasHeader=true # Default DrawingAttributes properties for everything not defined # specifically: layer.lineColor=ff000000 layer.fillColor=ffff00ff # Now add any other attributes accepted by the DrawingAttributes # object, with the prefix as stated above, i.e. layer.lineColor) # # The first column index is 0, not 1. # # The key index specifies which column in the csv file contains # unique area names that are listed in the areas list here in the # properties. In this case, it's the column that contains MA in one # of its rows. layer.keyIndex=4 # The name index is the column in the csv file that contains what # should be displayed in the application when a shape is chosen - the # object's proper name. layer.nameIndex=4 layer.areas=MA RI layer.areas.MA.fillColor=ffff0000 layer.areas.MA.lineColor=ff00ff00 layer.areas.RI.fillColor=ffff0000 layer.areas.RI.lineColor=ff00ff00
Field Summary | |
---|---|
protected java.util.Vector |
areasItems
The list of areas that have special coloring needs. |
static java.lang.String |
areasProperty
The property that lists special colored areas. |
static java.lang.String |
CacheFileProperty
The resource name, URL or file name of the serialized graphics file. |
protected java.net.URL |
cacheURL
The URL location of the cached graphics file. |
protected GeoCoordTransformation |
coordTransform
|
static java.lang.String |
csvFileProperty
The name of the property that holds the name of the CSV file with the area attributes, like the name and the abbreviation (or search Key). |
protected boolean |
csvHasHeader
Flag that specifies that the first line consists of header information, and should not be mapped to a graphic. |
static java.lang.String |
csvHeaderProperty
Set if the CSVFile has a header record. |
static java.lang.String |
dbfFileProperty
The name of the property that holds the name of the DBF file with the area attributes, like the name and the abbreviation (or search Key). |
protected DbfTableModel |
dbfModel
The DBF attribute file table model. |
protected DrawingAttributes |
drawingAttributes
Default draw parameters of the graphics that don't have something specific set for it. |
protected CSVShapeInfoFile |
infoFile
The location of the CSV attribute file. |
protected int |
keyIndex
The index of the column that holds the search key of the area. |
static java.lang.String |
keyIndexProperty
The property that specifies an index location for the area search key for a shape graphic in the database file. |
protected int |
nameIndex
The index of the column that holds the name of the area. |
static java.lang.String |
nameIndexProperty
The property that specifies an index location for the area name for a shape graphic in the database file. |
protected OMGraphicList |
omgraphics
The graphics list |
protected java.lang.String |
originalPrefix
|
protected java.util.Properties |
originalProperties
|
static java.lang.String |
pointImageURLProperty
A property that sets an image URL to use for point objects. |
protected java.util.Hashtable |
politicalAreas
The known political areas, based on the list of OMGraphics each entry contains. |
protected SpatialIndex |
spatialIndex
|
Fields inherited from interface com.bbn.openmap.PropertyConsumer |
---|
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty |
Constructor Summary | |
---|---|
AreaHandler(SpatialIndex si,
DrawingAttributes da)
Construct an AreaHandler. |
Method Summary | |
---|---|
protected java.lang.String |
createStringFromKeyObject(java.lang.Object keyObj)
OK, we can't assume that we are assigning a string as a key, you might want to key in on a specific attribute that is a number, like the country coloring code that ESRI has in the country file. |
java.util.Hashtable |
determinePoliticalAreas(OMGraphicList graphicList)
DeterminePoliticalAreas goes over a list of omgraphics, and spits out a hashtable that holds PoliticalArea objects for every area key. |
java.util.Hashtable |
determinePoliticalAreas(OMGraphicList graphicList,
java.util.Hashtable poli_areas)
DeterminePoliticalAreas goes over a list of omgraphics, and spits out a hashtable that holds PoliticalArea objects for every area key. |
OMGeometryList |
findGraphics(java.lang.String area_key)
Find the graphics that are represented by an search key. |
PoliticalArea |
findPoliticalArea(java.lang.String area_key)
Find a PoliticalArea named by the search key. |
protected java.awt.Color |
getColor(java.lang.String colorString)
|
protected java.awt.Color |
GetColorFromString(java.lang.String token)
This function would return a Color object for string such as red, green,.. |
GeoCoordTransformation |
getCoordTransform()
|
DrawingAttributes |
getDrawingAttributes()
|
DrawingAttributes |
getDrawParams(int recordNumber)
Given the shapefile record number, find the drawing parameters that should be used for the shape. |
DrawingAttributes |
getDrawParamsFromCSV(int recordNumber)
Given the shapefile record number, find the drawing parameters that should be used for the shape. |
DrawingAttributes |
getDrawParamsFromDBF(int recordNumber)
Given the shapefile record number, find the drawing parameters from the DBF model that should be used for the shape. |
OMGraphicList |
getGraphics()
Get all the graphics from the shapefile, colored appropriately. |
OMGraphicList |
getGraphics(double ulLat,
double ulLon,
double lrLat,
double lrLon)
Get the graphics for a particular lat/lon area. |
OMGraphicList |
getGraphics(double ulLat,
double ulLon,
double lrLat,
double lrLon,
Projection proj)
Get the graphics for a particular lat/lon area. |
java.lang.String |
getName(java.lang.Integer integer)
Get the name of the object at the index of the list. |
java.lang.String |
getName(java.util.Vector vector)
Return the graphic name, given the infofile vector on the graphic. |
java.util.Hashtable |
getPoliticalAreas()
|
java.util.Properties |
getProperties(java.util.Properties props)
PropertyConsumer method. |
java.util.Properties |
getPropertyInfo(java.util.Properties props)
PropertyConsumer method. |
java.lang.String |
getPropertyPrefix()
PropertyConsumer method. |
SpatialIndex |
getSpatialIndex()
|
void |
initialize(java.lang.String prefix,
java.util.Properties props)
Go through the properties, loading the shapefile, information file and attributes files, and resolve how everything should be drawn. |
void |
loadDbfModelIntoGraphics(OMGraphicList list)
This function takes an OMGraphicList and loads each one with the array representing the records in the dbf file. |
static void |
main(java.lang.String[] argv)
This main function basically reads in the data sources (the shape file and the csv information file, and creates a serialized graphics file that will act like a cache later. |
static void |
printUsage()
|
OMGraphicList |
readCachedGraphics(java.net.URL url)
Read a cache of OMGraphics |
void |
setCoordTransform(GeoCoordTransformation dataTransform)
|
void |
setDrawingAttributes(DrawingAttributes da)
|
void |
setProperties(java.util.Properties props)
Method to set the properties in the PropertyConsumer. |
void |
setProperties(java.lang.String prefix,
java.util.Properties props)
Initializes this object from the given properties |
void |
setPropertyPrefix(java.lang.String pre)
PropertyConsumer method. |
void |
setSpatialIndex(SpatialIndex si)
|
protected void |
updateDrawingParameters(OMGraphicList omgl)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Hashtable politicalAreas
public static final java.lang.String areasProperty
public static final java.lang.String pointImageURLProperty
public static final java.lang.String keyIndexProperty
public static final java.lang.String nameIndexProperty
public static final java.lang.String CacheFileProperty
public static final java.lang.String csvFileProperty
public static final java.lang.String csvHeaderProperty
public static final java.lang.String dbfFileProperty
protected java.util.Vector areasItems
protected int nameIndex
protected int keyIndex
protected java.net.URL cacheURL
protected OMGraphicList omgraphics
protected DrawingAttributes drawingAttributes
protected CSVShapeInfoFile infoFile
protected DbfTableModel dbfModel
protected boolean csvHasHeader
protected java.util.Properties originalProperties
protected java.lang.String originalPrefix
protected SpatialIndex spatialIndex
protected GeoCoordTransformation coordTransform
Constructor Detail |
---|
public AreaHandler(SpatialIndex si, DrawingAttributes da)
Method Detail |
---|
public void setDrawingAttributes(DrawingAttributes da)
public DrawingAttributes getDrawingAttributes()
public void setSpatialIndex(SpatialIndex si)
public SpatialIndex getSpatialIndex()
public java.util.Hashtable getPoliticalAreas()
public void setProperties(java.util.Properties props)
PropertyConsumer
setProperties
in interface PropertyConsumer
props
- a properties object that the PropertyConsumer
can use to retrieve expected properties it can use for
configuration.public void setProperties(java.lang.String prefix, java.util.Properties props)
setProperties
in interface PropertyConsumer
props
- the Properties
holding settings for this objectprefix
- a String used by the PropertyConsumer to prepend
to each property value it wants to look up -
setList.getProperty(prefix.propertyKey). If the prefix
had already been set, then the prefix passed in should
replace that previous value.public java.util.Properties getProperties(java.util.Properties props)
getProperties
in interface PropertyConsumer
props
- a Properties object to load the PropertyConsumer
properties into. If getList equals null, then a new
Properties object should be created.
public java.util.Properties getPropertyInfo(java.util.Properties props)
getPropertyInfo
in interface PropertyConsumer
props
- a Properties object to load the PropertyConsumer
properties into. If getList equals null, then a new
Properties object should be created.
public void setPropertyPrefix(java.lang.String pre)
setPropertyPrefix
in interface PropertyConsumer
pre
- the prefix String.public java.lang.String getPropertyPrefix()
getPropertyPrefix
in interface PropertyConsumer
public void initialize(java.lang.String prefix, java.util.Properties props)
prefix
- property file entry header nameprops
- the properties to look through.public OMGraphicList readCachedGraphics(java.net.URL url) throws java.io.IOException
java.io.IOException
public OMGraphicList getGraphics()
protected void updateDrawingParameters(OMGraphicList omgl)
public OMGraphicList getGraphics(double ulLat, double ulLon, double lrLat, double lrLon)
ulLat
- upper left latitude, in decimal degrees.ulLon
- upper left longitude, in decimal degrees.lrLat
- lower right latitude, in decimal degrees.lrLon
- lower right longitude, in decimal degrees.
public OMGraphicList getGraphics(double ulLat, double ulLon, double lrLat, double lrLon, Projection proj)
ulLat
- upper left latitude, in decimal degrees.ulLon
- upper left longitude, in decimal degrees.lrLat
- lower right latitude, in decimal degrees.lrLon
- lower right longitude, in decimal degrees.proj
- the current map projection.
public java.lang.String getName(java.util.Vector vector)
public java.lang.String getName(java.lang.Integer integer)
integer
- a zero-based index.
public DrawingAttributes getDrawParamsFromCSV(int recordNumber)
recordNumber
- the zero-based record number from the OMGraphicList.public DrawingAttributes getDrawParamsFromDBF(int recordNumber)
recordNumber
- the zero-based record number from the OMGraphicListprotected java.lang.String createStringFromKeyObject(java.lang.Object keyObj)
public DrawingAttributes getDrawParams(int recordNumber)
recordNumber
- the zero-based record number from the OMGraphics.public void loadDbfModelIntoGraphics(OMGraphicList list)
public PoliticalArea findPoliticalArea(java.lang.String area_key)
area_key
- the lookup key, of which the index for the column was
designated in the properties file.public OMGeometryList findGraphics(java.lang.String area_key)
area_key
- the lookup key, of which the index for the column was
designated in the properties file.public java.util.Hashtable determinePoliticalAreas(OMGraphicList graphicList)
graphicList
- the list of graphics. The top level graphic entries on the
list represent areas.public java.util.Hashtable determinePoliticalAreas(OMGraphicList graphicList, java.util.Hashtable poli_areas)
graphicList
- the list of graphics. The top level graphic entries on the
list represent areas.protected java.awt.Color getColor(java.lang.String colorString)
protected java.awt.Color GetColorFromString(java.lang.String token)
public GeoCoordTransformation getCoordTransform()
public void setCoordTransform(GeoCoordTransformation dataTransform)
public static void main(java.lang.String[] argv)
public static void printUsage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |