|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bbn.openmap.MapHandlerChild | +--com.bbn.openmap.OMComponent | +--com.bbn.openmap.LayerHandler
The LayerHandler is a component that keeps track of all Layers for the MapBean, whether or not they are currently part of the map or not. It is able to dynamically add and remove layers from the list of available layers. Whether a layer is added to the MapBean depends on the visibility setting of the layer. If Layer.isVisible() is true, the layer will be added to the MapBean. There are methods within the LayerHandler that let you change the visibility setting of a layer.
The LayerHandler is able to take a Properties object, and create layers that are defined within it. The key property is "layers", which may or may not have a prefix for it. If that property does have a prefix (prefix.layers, i.e. openmap.layers), then that prefix has to be known and passed in to the contructor or init method. This layers property should fit the general openmap marker list paradigm, where the marker names are listed in a space separated list, and then each marker name is used as a prefix for the properties for a particular layer. As a minimum, each layer needs to have the class and prettyName properties defined. The class property should define the class name to use for the layer, and the prettyName property needs to be a name for the layer to be used in the GUI. Any other property that the particular layer can use should be listed in the Properties, with the applicable marker name as a prefix. Each layer should have its available properties defined in its documentation. For example:
openmap.layers=marker1 marker2 (etc) marker1.class=com.bbn.openmap.layer.GraticuleLayer marker1.prettyName=Graticule Layer # false is default marker1.addToBeanContext=false marker2.class=com.bbn.openmap.layer.shape.ShapeLayer marker2.prettyName=Political Boundaries marker2.shapeFile=pathToShapeFile marker2.spatialIndex=pathToSpatialIndexFile marker2.lineColor=FFFFFFFF marker2.fillColor=FFFF0000
The LayerHandler is a SoloMapComponent, which means that for a particular map, there should only be one of them. When a LayerHandler is added to a BeanContext, it will look for a MapBean to connect to itself as a LayerListener so that the MapBean will receive LayerEvents - this is the mechanism that adds and removes layers on the map. If more than one MapBean is added to the BeanContext, then the last MapBean added will be added as a LayerListener, with any prior MapBeans added as a LayerListener removed from the LayerHandler. The MapHandler controls the behavior of multiple SoloMapComponent addition to the BeanContext.
Field Summary | |
protected Layer[] |
allLayers
The list of all layers, even the ones that are not part of the map. |
static java.lang.String |
layersProperty
Property for space separated layers. |
protected LayerSupport |
listeners
The object holding on to all LayerListeners interested in the layer arrangement and availability. |
protected PropertyHandler |
propertyHandler
This handle is only here to keep it appraised of layer prefix names. |
static java.lang.String |
startUpLayersProperty
Property for space separated layers to be displayed at startup. |
Fields inherited from class com.bbn.openmap.OMComponent |
i18n, propertyPrefix |
Fields inherited from class com.bbn.openmap.MapHandlerChild |
beanContextChildSupport |
Fields inherited from interface com.bbn.openmap.PropertyConsumer |
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty |
Constructor Summary | |
LayerHandler()
If you use this constructor, the LayerHandler expects that the layers will be created and added later, either by addLayer() or init(). |
|
LayerHandler(Layer[] layers)
Start the LayerHandler with configured layers. |
|
LayerHandler(java.util.Properties props)
Start the LayerHandler, and have it create all the layers as defined in a properties file. |
|
LayerHandler(java.lang.String prefix,
java.util.Properties props)
Start the LayerHandler, and have it create all the layers as defined in a properties file. |
Method Summary | |
void |
addLayer(Layer layer)
Add a layer to the bottom of the layer stack. |
void |
addLayer(Layer layer,
int position)
Add a layer to a certain position in the layer array. |
void |
addLayer(Layer layer,
int position,
boolean addedLayerTurnedOn)
Deprecated. the layer will be turned on if its visibility is true. |
void |
addLayerListener(LayerListener ll)
Add a LayerListener to the LayerHandler, in order to be told about layers that need to be added to the map. |
void |
addLayersToBeanContext(Layer[] layers)
Add layers to the BeanContext, if they want to be. |
void |
childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)
A BeanContextMembershipListener interface method, which is called when new objects are removed from the BeanContext. |
void |
findAndInit(java.util.Iterator it)
Called from childrenAdded(), when a new component is added to the BeanContext, and from setBeanContext() when the LayerHandler is initially added to the BeanContext. |
Layer[] |
getLayers()
Get a layer array, of potential layers that CAN be added to the map, not the ones that are active on the map. |
protected Layer[] |
getLayers(java.util.Properties p)
This is the method that gets used to parse the layer properties from an openmap.properties file, where the layer marker names are listed under a layers property, and each layer is then represented by a marker.class property, and a maker.prettyName property. |
protected Layer[] |
getLayers(java.lang.String prefix,
java.util.Properties p)
This is the method that gets used to parse the layer properties from an openmap.properties file, where the layer marker names are listed under a prefix.layers property, and each layer is then represented by a marker.class property, and a maker.prettyName property. |
static Layer[] |
getLayers(java.util.Vector layerList,
java.util.Vector visibleLayerList,
java.util.Properties p)
A static method that lets you pass in a Properties object, along with two Vectors of strings, each Vector representing marker names for layers contained in the Properties. |
protected LayerSupport |
getListeners()
Returns the object responsible for holding on to objects listening to layer changes. |
Layer[] |
getMapLayers()
Get the layers that are currently part of the Map - the ones that are visible. |
PropertyHandler |
getPropertyHandler()
|
boolean |
hasLayer(Layer l)
|
void |
init(Layer[] layers)
Initialize from an array of layers. |
void |
init(java.lang.String prefix,
java.util.Properties props)
Initialize the LayerHandler by having it construct it's layers from a properties object. |
void |
init(java.lang.String prefix,
java.net.URL url)
Initialize the LayerHandler by having it construct it's layers from a URL containing an openmap.properties file. |
void |
init(java.net.URL url)
Initialize the LayerHandler by having it construct it's layers from a URL containing an openmap.properties file. |
boolean |
moveLayer(Layer layer,
int toPosition)
Move a layer to a certain position. |
void |
removeAll()
Remove all the layers (that are marked as removeable). |
void |
removeLayer(int index)
Remove a layer from the list of potentials. |
void |
removeLayer(Layer layer)
Remove a layer from the list of potentials. |
protected void |
removeLayer(Layer[] currentLayers,
int index)
The version that does the work. |
void |
removeLayerListener(LayerListener ll)
Add a LayerListener to the LayerHandler, in order to be told about layers that need to be added to the map. |
void |
setBeanContext(java.beans.beancontext.BeanContext in_bc)
Called when the LayerHandler is added to a BeanContext. |
void |
setLayers()
If you are futzing with the layer visibility outside the perview of the LayerHandler (not using the turnLayerOn() methods) then you can call this to get all the listeners using the current set of visible layers. |
void |
setLayers(Layer[] layers)
Set all the layers held by the LayerHandler. |
void |
setProperties(java.lang.String prefix,
java.util.Properties props)
Extension of the OMComponent. |
void |
setPropertyHandler(PropertyHandler ph)
|
boolean |
turnLayerOn(boolean setting,
int index)
Take a layer that the LayersMenu knows about, that may or may not be a part of the map, and change its visibility by adding/removing it from the MapBean. |
boolean |
turnLayerOn(boolean setting,
Layer layer)
Take a layer that the LayersMenu knows about, that may or may not be a part of the map, and change its visibility by adding/removing it from the MapBean. |
void |
updateLayerLabels()
Deprecated. Replaced by setLayers(). |
Methods inherited from class com.bbn.openmap.OMComponent |
getProperties, getPropertyInfo, getPropertyPrefix, setProperties, setPropertyPrefix |
Methods inherited from class com.bbn.openmap.MapHandlerChild |
addPropertyChangeListener, addVetoableChangeListener, childrenAdded, findAndInit, findAndUndo, firePropertyChange, fireVetoableChange, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String layersProperty
public static final java.lang.String startUpLayersProperty
protected transient LayerSupport listeners
protected Layer[] allLayers
protected PropertyHandler propertyHandler
Constructor Detail |
public LayerHandler()
public LayerHandler(java.util.Properties props)
props
- properties as defined in an openmap.properties
file.public LayerHandler(java.lang.String prefix, java.util.Properties props)
prefix
- the prefix for the layers and startUpLayers
properties, as if they are listed as prefix.layers, and
prefix.startUpLayers.props
- properties as defined in an openmap.propertites
file.public LayerHandler(Layer[] layers)
Method Detail |
public void setProperties(java.lang.String prefix, java.util.Properties props)
setProperties
in interface PropertyConsumer
setProperties
in class OMComponent
prefix
- the token to prefix the property namesprops
- the Properties
objectpublic void init(java.lang.String prefix, java.util.Properties props)
prefix
- the prefix to use for the layers and
startUpLayers properties.props
- properties as defined in an openmap.properties
file.public void init(java.net.URL url)
url
- a url for a properties file.public void init(java.lang.String prefix, java.net.URL url)
prefix
- the prefix to use for the layers and
startUpLayers properties.url
- a url for a properties file.public void init(Layer[] layers)
layers
- the initial array of layers.public void setPropertyHandler(PropertyHandler ph)
public PropertyHandler getPropertyHandler()
protected Layer[] getLayers(java.util.Properties p)
p
- properties containing layers property, the
startupLayers property listing the layers to make
visible immediately, and the layer properties as well.
protected Layer[] getLayers(java.lang.String prefix, java.util.Properties p)
prefix
- the prefix to use to use for the layer list
(layers) property and the startUpLayers property. If it
is not null, this will cause the method to looke for
prefix.layers and prefix.startUpLayers.p
- the properties to build the layers from.
public static Layer[] getLayers(java.util.Vector layerList, java.util.Vector visibleLayerList, java.util.Properties p)
If a PlugIn is listed in the properties, the LayerHandler will create a PlugInLayer for it and set the PlugIn in that layer.
layerList
- Vector of marker names to use to inspect the
properties with.visibleLayerList
- Vector of marker names representing the
layers that should initially be set to visible when
created, so that those layers are initially added to the
map.p
- Properties object containing the layers properties.
public void addLayerListener(LayerListener ll)
ll
- LayerListener, usually the MapBean or other GUI
components interested in providing layer controls.public void removeLayerListener(LayerListener ll)
ll
- LayerListener, usually the MapBean or other GUI
components interested in providing layer controls.public void setLayers(Layer[] layers)
layers
- Layer array of all the layers to be held by the
LayerHandler.protected LayerSupport getListeners()
public void setLayers()
public void updateLayerLabels()
public Layer[] getLayers()
public Layer[] getMapLayers()
public boolean moveLayer(Layer layer, int toPosition)
layer
- the layer to move.toPosition
- the array index to place it, shifting the
other layers up or down, depending on where the layer is
originally.
public void addLayer(Layer layer)
layer
- the layer to add.public void addLayer(Layer layer, int position)
layer
- the layer to add.position
- the array index to place it.public void addLayer(Layer layer, int position, boolean addedLayerTurnedOn)
layer
- the layer to add.position
- the array index to place it.addedLayerTurnedOn
- turn the layer on.public void removeLayer(Layer layer)
layer
- to remove.public void removeLayer(int index)
index
- of layer in the layer array. Top-most is first.public boolean hasLayer(Layer l)
public void removeAll()
protected void removeLayer(Layer[] currentLayers, int index)
currentLayers
- the current layers handled in the
LayersMenu.index
- the validated index of the layer to remove.public boolean turnLayerOn(boolean setting, int index)
setting
- true to add layer to the map.index
- the index of the layer to turn on/off.
public boolean turnLayerOn(boolean setting, Layer layer)
setting
- true to add layer to the map.layer
- the layer to turn on.
public void findAndInit(java.util.Iterator it)
findAndInit
in class MapHandlerChild
it
- Iterator with objects to look through.public void childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)
childrenRemoved
in interface java.beans.beancontext.BeanContextMembershipListener
childrenRemoved
in class MapHandlerChild
bcme
- an event containing an Iterator containing removed
objects.public void addLayersToBeanContext(Layer[] layers)
layers
- layers to add, if they want to be.public void setBeanContext(java.beans.beancontext.BeanContext in_bc) throws java.beans.PropertyVetoException
setBeanContext
in interface java.beans.beancontext.BeanContextChild
setBeanContext
in class MapHandlerChild
in_bc
- BeanContext.
java.beans.PropertyVetoException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |