Most of the methods in the MapBean are called from the Java AWT and Swing code. These methods make the MapBean a good "Swing citizen" to its parent components, and you should not need to invoke them. In general there are only two reasons to call MapBean methods: controlling the projection, and adding or removing layers.
When controlling the MapBean projection, simply call the method that applies - setCenter, pan, zoom, etc. NOTE: If you are setting more than one parameter of the projection, it's more efficient to getProjection(), directly set the parameters of the projection object, and then call setProjection() with the modified projection. That way, each ProjectionListener of the MapBean (each layer) will only receive one projectionChanged() method call, as opposed to receiving one for each projection adjustment.
To add or remove layers, use the add() and remove() methods that the MapBean inherits from java.awt.Container. The add() method can be called with an integer that indicates its desired position in the layer list.
Changing the default clipping area may cause some Layers to not be drawn completely, depending on what the clipping area is set to and when the layer is trying to get itself painted. When manually adjusting clipping area, make sure that when restricted clipping is over that a full repaint occurs if there is a chance that another layer may be trying to paint itself.
PropertyChangeListeners and ProjectionListeners both receive notifications of the projection changes, but the PropertyChangeListeners receive them first. If you want to have a component that limits the MapBean's projection parameters, it should be a PropertyChangeListener on the MapBean, and throw a ProjectionChangeVetoException whenever a Projection setting falls outside of the limits. The ProjectionChangeVetoException should hold the alternate settings allowed by the listener. When a ProjectionChangeVetoException is thrown, all of the PropertyChangeListeners will receive another PropertyChangeEvent notification, under the MapBean.projectionVetoed property name. The old value for that property will be the rejected Projection object, and the new value will be the ProjectionChangeVetoException containing the new suggestions. The MapBean will then apply the suggestions and launch another round of projection change notifications. The ProjectionListeners only receive notification of Projections that have passed through the PropertyChangeListeners. @see Layer
|
|
|
|
|
|
|
|