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

java.lang.Object
  extended by com.bbn.openmap.MapHandlerChild
      extended by com.bbn.openmap.OMComponent
          extended by com.bbn.openmap.layer.location.AbstractLocationHandler
              extended by com.bbn.openmap.layer.location.csv.CSVLocationHandler
                  extended by com.bbn.openmap.layer.location.csv.CSVLinkHandler
All Implemented Interfaces:
LocationHandler, LightMapHandlerChild, PropertyConsumer, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.util.EventListener

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. It has the same basic properties as the CSVLocationHandler, with allowances for extra lat/lon per record to handle the other side of the link/line.

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 lat/lon 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.  The first two are the same as CSVLocationHandler.
          linkMarkerName.latIndex=column_number
          linkMarkerName.lonIndex=column_number
          linkMarkerName.lat2Index=column_number
          linkMarkerName.lon2Index=column_number
          
          #plus all the other optional properties. The marker parameters will work on the link OMGraphics.
 
 

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.


Field Summary
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".
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".
 
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, logger, RenderAttributesListProperty, zLayer
 
Fields inherited from class com.bbn.openmap.OMComponent
propertyPrefix
 
Fields inherited from class com.bbn.openmap.MapHandlerChild
beanContextChildSupport, isolated
 
Fields inherited from interface com.bbn.openmap.layer.location.LocationHandler
defaultLocationColorString, defaultNameColorString, forceGlobalCommand, ForceGlobalProperty, LocationPropertyPrefix, 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  void createLocation(java.util.List recordList, QuadTree<Location> qt)
          This is the method called by create data with a row's worth of information stuffed in the record List.
 java.awt.Component getGUI()
          Provides the palette widgets to control the options of showing maps, or attribute text.
 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.
 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
createData, createLocation, get, getItemsForPopupMenu, reloadData, tokenToDouble, tokenToDouble, tokenToString
 
Methods inherited from class com.bbn.openmap.layer.location.AbstractLocationHandler
getLayer, getLocationColor, getLocationDrawingAttributes, getNameColor, getNameDrawingAttributes, getPrettyName, getPropertyPrefix, isForceGlobal, isShowLocations, isShowNames, removed, setForceGlobal, setLayer, setLocationColor, setLocationDrawingAttributes, setNameColor, setNameDrawingAttributes, setPrettyName, setProperties, setPropertyPrefix, setShowLocations, setShowNames
 
Methods inherited from class com.bbn.openmap.MapHandlerChild
addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, findAndInit, findAndUndo, firePropertyChange, fireVetoableChange, getBeanContext, isIsolated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, setIsolated
 
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, getPrettyName, isForceGlobal, isShowLocations, isShowNames, removed, setForceGlobal, setLayer, setPrettyName, setShowLocations, setShowNames
 
Methods inherited from interface com.bbn.openmap.PropertyConsumer
getPropertyPrefix, setProperties, setPropertyPrefix
 

Field Detail

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

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.

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 property 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

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.

createLocation

protected void createLocation(java.util.List recordList,
                              QuadTree<Location> qt)
This is the method called by create data with a row's worth of information stuffed in the record List. The indexes set in the properties should describe what each entry is.

Overrides:
createLocation in class CSVLocationHandler
Parameters:
recordList - a record/row of data from the csv file.
qt - the Quadtree to add the Location object, created from the row contents.


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