|
||||||||||
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
public class 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 constructor 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:
<p/> openmap.layers=marker1 marker2 (etc) marker1.class=com.bbn.openmap.layer.GraticuleLayer marker1.prettyName=Graticule Layer # false is default marker1.addToBeanContext=false <p/> marker2.class=com.bbn.openmap.layer.shape.ShapeLayer marker2.prettyName=Political Boundaries marker2.shapeFile=pathToShapeFile marker2.spatialIndex=pathToSpatialIndexFile marker2.lineColor=FFFFFFFF marker2.fillColor=FFFF0000 <p/>
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 java.util.List<Layer> |
allLayers
The list of all layers, even the ones that are not part of the map. |
protected LayerConfigurationListenerSupport |
layerConfigListeners
LayerConfigurationListenerSupport for LayerConfigurationListeners. |
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. |
static java.util.logging.Logger |
logger
|
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. |
static java.lang.String |
SynchronousThreadingProperty
Flag to set synchronous threading on the LayerHandler, telling it to react to layer order changes and layer visibility requests within the calling thread. |
Fields inherited from class com.bbn.openmap.OMComponent |
---|
i18n, propertyPrefix |
Fields inherited from class com.bbn.openmap.MapHandlerChild |
---|
beanContextChildSupport, isolated |
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 |
addLayerConfigurationListener(LayerConfigurationListener lcl)
Add a LayerConfigurationListener, so a component can make adjustments to new layer configurations before they get sent to the map. |
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(java.util.List<Layer> layers)
Add layers to the BeanContext, if they want to be. |
void |
findAndInit(java.lang.Object someObj)
Called from childrenAdded(), when a new component is added to the BeanContext, and from setBeanContext() when the LayerHandler is initially added to the BeanContext. |
void |
findAndUndo(java.lang.Object someObj)
A BeanContextMembershipListener interface method, which is called when new objects are removed from the BeanContext. |
java.util.List<Layer> |
getLayerList()
Returns a copy of the List of all the available layers. |
protected java.lang.String |
getLayerNamesFromArray(java.util.List<Layer> lArray)
|
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<java.lang.String> layerList,
java.util.Vector<java.lang.String> 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. |
java.util.Properties |
getProperties(java.util.Properties props)
PropertyConsumer method, to fill in a Properties object, reflecting the current values of the OMComponent. |
PropertyHandler |
getPropertyHandler()
|
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. |
boolean |
hasLayer(Layer l)
|
void |
init(Layer[] layers)
Initialize from an array of layers. |
void |
init(java.util.List<Layer> 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. |
protected boolean |
isForegroundUnderBackgroundLayer(java.util.List<Layer> layers)
Checks to see if there are background layers on top of foreground layers. |
boolean |
isSynchronousThreading()
|
boolean |
moveLayer(Layer layer,
int toPosition)
Move a layer to a certain position. |
protected java.util.List<Layer> |
organizeBackgroundLayers(java.util.List<Layer> layers)
Does the check to see of foreground layers are below background layers, and then iterates through the Layer[] switching layers around until they are in the appropriate order. |
void |
removeAll()
Remove all the layers (that are marked as removable). |
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 |
removeLayerConfigurationListener(LayerConfigurationListener lcl)
Remove a LayerConfigurationListener. |
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 |
removeLayersFromBeanContext(java.util.List<Layer> layers)
Add layers to the BeanContext, if they want to be. |
void |
setBeanContext(java.beans.beancontext.BeanContext in_bc)
Called when the LayerHandler is added to a BeanContext. |
void |
setLayerList(java.util.List<Layer> layers)
|
void |
setLayers()
If you are futzing with the layer visibility outside the purview 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)
|
void |
setSynchronousThreading(boolean s)
|
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. |
Methods inherited from class com.bbn.openmap.OMComponent |
---|
getPropertyPrefix, setProperties, setPropertyPrefix |
Methods inherited from class com.bbn.openmap.MapHandlerChild |
---|
addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, firePropertyChange, fireVetoableChange, getBeanContext, isIsolated, removePropertyChangeListener, removeVetoableChangeListener, setIsolated |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.util.logging.Logger logger
public static final java.lang.String layersProperty
public static final java.lang.String startUpLayersProperty
public static final java.lang.String SynchronousThreadingProperty
protected transient LayerSupport listeners
protected transient LayerConfigurationListenerSupport layerConfigListeners
protected java.util.List<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.properties 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 init(java.util.List<Layer> 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 look for prefix.layers and
prefix.startUpLayers.p
- the properties to build the layers from.
public static Layer[] getLayers(java.util.Vector<java.lang.String> layerList, java.util.Vector<java.lang.String> visibleLayerList, java.util.Properties p)
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 addLayerConfigurationListener(LayerConfigurationListener lcl)
lcl
- LayerConfigurationListenerpublic void removeLayerListener(LayerListener ll)
ll
- LayerListener, usually the MapBean or other GUI components
interested in providing layer controls.public void removeLayerConfigurationListener(LayerConfigurationListener lcl)
lcl
- LayerConfigurationListenerpublic void setLayers(Layer[] layers)
layers
- Layer array of all the layers to be held by the
LayerHandler.public void setLayerList(java.util.List<Layer> layers)
protected java.lang.String getLayerNamesFromArray(java.util.List<Layer> lArray)
protected boolean isForegroundUnderBackgroundLayer(java.util.List<Layer> layers)
layers
-
protected java.util.List<Layer> organizeBackgroundLayers(java.util.List<Layer> layers)
layers
-
protected LayerSupport getListeners()
public void setLayers()
public Layer[] getLayers()
public java.util.List<Layer> getLayerList()
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 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.lang.Object someObj)
findAndInit
in interface LightMapHandlerChild
findAndInit
in class MapHandlerChild
someObj
- an Object being added to the MapHandler/BeanContext.public void findAndUndo(java.lang.Object someObj)
findAndUndo
in interface LightMapHandlerChild
findAndUndo
in class MapHandlerChild
someObj
- an Object being removed from the MapHandler/BeanContext.public void addLayersToBeanContext(java.util.List<Layer> layers)
layers
- layers to add, if they want to be.public void removeLayersFromBeanContext(java.util.List<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
public void setSynchronousThreading(boolean s)
public boolean isSynchronousThreading()
public java.util.Properties getProperties(java.util.Properties props)
OMComponent
getProperties
in interface PropertyConsumer
getProperties
in class OMComponent
props
- a Properties object to load the PropertyConsumer properties
into. If props equals null, then a new Properties object should be
created.
public java.util.Properties getPropertyInfo(java.util.Properties props)
OMComponent
getPropertyInfo
in interface PropertyConsumer
getPropertyInfo
in class OMComponent
props
- a Properties object to load the PropertyConsumer properties
into. If getList equals null, then a new Properties object should
be created.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |