com.bbn.openmap.layer.location.csv
Class CSVLinkHandler

java.lang.Object
  extended bycom.bbn.openmap.layer.location.AbstractLocationHandler
      extended bycom.bbn.openmap.layer.location.csv.CSVLocationHandler
          extended bycom.bbn.openmap.layer.location.csv.CSVLinkHandler
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, LocationHandler, PropertyConsumer

public class CSVLinkHandler
extends CSVLocationHandler

The CSVLinkHandler is designed to let you put data on the map based on information from a Comma Separated Value(CSV) file. It's assumed that the each row in the file refers to two locations, and that a link is to be shown between the two locations.

The individual fields must not have leading whitespace.

The locationFile property should contain a URL referring to the file. This can take the form of file:/myfile.csv for a local file or http://somehost.org/myfile.csv for a remote file If there is a lat1/lon1 index, and a lat2/lon2 index, then the links' endpoints are in the link file.

The Link CSV file has to have certain fields, and the column number of those fields are set in the properties:

         
          # latitude and longitude indexes of the link end points
          linkMarkerName.lat1Index=column_number
          linkMarkerName.lon1Index=column_number
          linkMarkerName.lat2Index=column_number
          linkMarkerName.lon2Index=column_number
          # These are optional
          linkMarkerName.dashIndex=column_number for true/false (false is default)
          linkMarkerName.colorIndex=column_number for color notation
          linkMarkerName.thicknessIndex=column_number for pixel thickness of link
          linkMarkerName.geoStyleIndex=column_number for link rendertype (STRAIGHT, GC, RHUMB)
          
 

TODO: update the quadtree used to instead use a com.bbn.openmap.geo.ExtentIndex, so that lines that bisect the map will appear. Right now, one of the endpoints of the line has to be in the map window in order for the link to be displayed, and that's not quite right.


Nested Class Summary
 class CSVLinkHandler.LinkDecoder
           
 
Nested classes inherited from class com.bbn.openmap.layer.location.csv.CSVLocationHandler
CSVLocationHandler.DefaultLocationDecoder, CSVLocationHandler.TokenDecoder
 
Field Summary
protected  int colorIndex
           
static java.lang.String ColorIndexProperty
           
protected  int dashIndex
           
static java.lang.String DashIndexProperty
          Index in file for True/false property to indicate link should be dashed line.
protected  int geoStyleIndex
          Index of column in CSV to use as the line-type to draw a link in.
static java.lang.String GeoStyleIndexProperty
          Index in CSV file for rendertype of link - STRAIGHT, GC, RHUMB
protected  int lat1Index
          Index of column in CSV to use as latitude1 of link.
static java.lang.String Lat1IndexProperty
          Property to use to designate the column of the link file to use as the latitude of end "1".
protected  int lat2Index
          Index of column in CSV to use as latitude2 of link.
static java.lang.String Lat2IndexProperty
          Property to use to designate the column of the link file to use as the latitude of end "2".
static java.lang.String LinkTypeIndexProperty
          Not used.
protected  int lon1Index
          Index of column in CSV to use as longitude1 of link.
static java.lang.String Lon1IndexProperty
          Property to use to designate the column of the link file to use as the longitude of end "1".
protected  int lon2Index
          Index of column in CSV to use as longitude2 of link.
static java.lang.String Lon2IndexProperty
          Property to use to designate the column of the link file to use as the longitude of end "2".
protected  int thicknessIndex
           
static java.lang.String ThicknessIndexProperty
           
 
Fields inherited from class com.bbn.openmap.layer.location.csv.CSVLocationHandler
box, csvHasHeader, csvHeaderProperty, defaultIconURL, DefaultIconURLProperty, eastIsNeg, eastIsNegProperty, iconIndex, IconIndexProperty, latIndex, LatIndexProperty, locationFile, LocationFileProperty, lonIndex, LonIndexProperty, nameIndex, NameIndexProperty, quadtree
 
Fields inherited from class com.bbn.openmap.layer.location.AbstractLocationHandler
i18n, locationDrawingAttributes, nameDrawingAttributes, propertyPrefix, zLayer
 
Fields inherited from interface com.bbn.openmap.layer.location.LocationHandler
defaultLocationColorString, defaultNameColorString, forceGlobalCommand, ForceGlobalProperty, LocationColorProperty, LocationPropertyPrefix, NameColorProperty, NamePropertyPrefix, readDataCommand, showdetails, showLocationsCommand, ShowLocationsProperty, showname, showNamesCommand, ShowNamesProperty
 
Fields inherited from interface com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Constructor Summary
CSVLinkHandler()
          The default constructor for the Layer.
 
Method Summary
protected  boolean checkIndexSettings()
           
protected  java.awt.Color getColorFromToken(java.lang.Object token)
          This interprets a color value from a token.
 java.awt.Component getGUI()
          Provides the palette widgets to control the options of showing maps, or attribute text.
protected  int getLineTypeFromToken(java.lang.Object token)
          This gets a line-type from a token, and translates it into one of LINETYPE_STRAIGHT, LINETYPE_GREATCIRCLE, or LINETYPE_RHUMB.
 java.util.Properties getProperties(java.util.Properties props)
          PropertyConsumer method, to fill in a Properties object, reflecting the current values of the layer.
 java.util.Properties getPropertyInfo(java.util.Properties list)
          Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer.
protected  CSVLocationHandler.TokenDecoder getTokenDecoder()
           
 void setProperties(java.lang.String prefix, java.util.Properties properties)
          The properties and prefix are managed and decoded here, for the standard uses of the CSVLinkHandler.
 
Methods inherited from class com.bbn.openmap.layer.location.csv.CSVLocationHandler
actionPerformed, createData, createLocation, fillLocationPopUpMenu, get, readCSVLineFromFile, reloadData
 
Methods inherited from class com.bbn.openmap.layer.location.AbstractLocationHandler
getLayer, getLocationColor, getLocationDrawingAttributes, getNameColor, getNameDrawingAttributes, getPropertyPrefix, isForceGlobal, isShowLocations, isShowNames, removed, setForceGlobal, setLayer, setLocationColor, setLocationDrawingAttributes, setNameColor, setNameDrawingAttributes, setProperties, setPropertyPrefix, setShowLocations, setShowNames
 
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.layer.location.LocationHandler
getLayer, isForceGlobal, isShowLocations, isShowNames, removed, setForceGlobal, setLayer, setShowLocations, setShowNames
 
Methods inherited from interface com.bbn.openmap.PropertyConsumer
getPropertyPrefix, setProperties, setPropertyPrefix
 

Field Detail

Lat1IndexProperty

public static final java.lang.String Lat1IndexProperty
Property to use to designate the column of the link file to use as the latitude of end "1".

See Also:
Constant Field Values

Lon1IndexProperty

public static final java.lang.String Lon1IndexProperty
Property to use to designate the column of the link file to use as the longitude of end "1".

See Also:
Constant Field Values

Lat2IndexProperty

public static final java.lang.String Lat2IndexProperty
Property to use to designate the column of the link file to use as the latitude of end "2".

See Also:
Constant Field Values

Lon2IndexProperty

public static final java.lang.String Lon2IndexProperty
Property to use to designate the column of the link file to use as the longitude of end "2".

See Also:
Constant Field Values

LinkTypeIndexProperty

public static final java.lang.String LinkTypeIndexProperty
Not used.

See Also:
Constant Field Values

DashIndexProperty

public static final java.lang.String DashIndexProperty
Index in file for True/false property to indicate link should be dashed line.

See Also:
Constant Field Values

ColorIndexProperty

public static final java.lang.String ColorIndexProperty
See Also:
Constant Field Values

ThicknessIndexProperty

public static final java.lang.String ThicknessIndexProperty
See Also:
Constant Field Values

GeoStyleIndexProperty

public static final java.lang.String GeoStyleIndexProperty
Index in CSV file for rendertype of link - STRAIGHT, GC, RHUMB

See Also:
Constant Field Values

lat1Index

protected int lat1Index
Index of column in CSV to use as latitude1 of link.


lon1Index

protected int lon1Index
Index of column in CSV to use as longitude1 of link.


lat2Index

protected int lat2Index
Index of column in CSV to use as latitude2 of link.


lon2Index

protected int lon2Index
Index of column in CSV to use as longitude2 of link.


geoStyleIndex

protected int geoStyleIndex
Index of column in CSV to use as the line-type to draw a link in.


dashIndex

protected int dashIndex

colorIndex

protected int colorIndex

thicknessIndex

protected int thicknessIndex
Constructor Detail

CSVLinkHandler

public CSVLinkHandler()
The default constructor for the Layer. All of the attributes are set to their default values.

Method Detail

setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties properties)
The properties and prefix are managed and decoded here, for the standard uses of the CSVLinkHandler.

Specified by:
setProperties in interface PropertyConsumer
Overrides:
setProperties in class CSVLocationHandler
Parameters:
prefix - string prefix used in the properties file for this layer.
properties - the properties set in the properties file.

getProperties

public java.util.Properties getProperties(java.util.Properties props)
PropertyConsumer method, to fill in a Properties object, reflecting the current values of the layer. If the layer has a propertyPrefix set, the property keys should have that prefix plus a separating '.' prepended to each propery key it uses for configuration.

Specified by:
getProperties in interface PropertyConsumer
Overrides:
getProperties in class CSVLocationHandler
Parameters:
props - a Properties object to load the PropertyConsumer properties into.
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 list)
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.). This method takes care of the basic LocationHandler parameters, so any LocationHandlers that extend the AbstractLocationHandler should call this method, too, before adding any specific properties.

Specified by:
getPropertyInfo in interface PropertyConsumer
Overrides:
getPropertyInfo in class CSVLocationHandler
Parameters:
list - 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.

checkIndexSettings

protected boolean checkIndexSettings()
Overrides:
checkIndexSettings in class CSVLocationHandler

getTokenDecoder

protected CSVLocationHandler.TokenDecoder getTokenDecoder()
Overrides:
getTokenDecoder in class CSVLocationHandler

getGUI

public java.awt.Component getGUI()
Provides the palette widgets to control the options of showing maps, or attribute text.

In this case, the palette widget only contains one button, which reloads the data files for the layer.

Specified by:
getGUI in interface LocationHandler
Overrides:
getGUI in class CSVLocationHandler
Returns:
Component object representing the palette widgets.

getLineTypeFromToken

protected int getLineTypeFromToken(java.lang.Object token)
This gets a line-type from a token, and translates it into one of LINETYPE_STRAIGHT, LINETYPE_GREATCIRCLE, or LINETYPE_RHUMB.

Parameters:
token - the token read from the CSV file.
Returns:
one of LINETYPE_STRAIGHT, LINETYPE_GREATCIRCLE, or LINETYPE_RHUMB

getColorFromToken

protected java.awt.Color getColorFromToken(java.lang.Object token)
This interprets a color value from a token. The color can be one of the standard colors in the java.awt.Color class, or it can be a hexadecimal representation of any other displayable color.

Parameters:
token - the token read from the CSV file.

Returns:
the java.awt.Color described by that token, or Color.black (if the token cannot be translated into a proper color).


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