com.bbn.openmap
Class MapBean

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.bbn.openmap.MapBean
All Implemented Interfaces:
CenterListener, java.awt.event.ComponentListener, java.awt.event.ContainerListener, java.util.EventListener, java.awt.image.ImageObserver, LayerListener, java.awt.MenuContainer, PanListener, ProjectionListener, java.io.Serializable, SoloMapComponent, ZoomListener
Direct Known Subclasses:
BufferedMapBean

public class MapBean
extends javax.swing.JComponent
implements java.awt.event.ComponentListener, java.awt.event.ContainerListener, ProjectionListener, PanListener, ZoomListener, LayerListener, CenterListener, SoloMapComponent

The MapBean is the main component of the OpenMap Development Kit. It is a Java Bean that manages and displays a map. A map is comprised of a projection and a list of layers, and this class has methods that allow you to control the projection parameters and to add and remove layers. Layers that are part of the map receive dynamic notifications of changes to the underlying view and projection.

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.

See Also:
Layer, Serialized Form

Field Summary
protected  java.util.Vector addedLayers
          This vector is to let the layers know when they have been added to the map.
protected  java.awt.Paint background
          The background color for this particular MapBean.
static java.lang.String BackgroundProperty
           
protected  Layer[] currentLayers
           
static java.lang.String CursorProperty
           
static java.awt.Color DEFAULT_BACKGROUND_COLOR
           
static float DEFAULT_CENTER_LAT
           
static float DEFAULT_CENTER_LON
           
static int DEFAULT_HEIGHT
           
static float DEFAULT_SCALE
           
static int DEFAULT_WIDTH
           
protected  boolean doContainerChange
           
protected  boolean layerRemovalDelayed
          Some users may want the layers deleted immediately when they are removed from the map.
static java.lang.String LayersProperty
           
protected  int minHeight
           
protected  int minWidth
           
protected  PaintListenerSupport painters
          The PaintListeners want to know when the map has been repainted.
protected  Proj projection
           
static java.lang.String ProjectionProperty
           
protected  ProjectionSupport projectionSupport
           
protected  java.util.Vector removedLayers
          Layers that are removed from the MapBean are held until the next projection change.
protected  MapBeanRepaintPolicy repaintPolicy
          The MapBeanRepaintPolicy to use to handler/filter/pace layer repaint() requests.
static boolean suppressCopyright
          Suppress the copyright message on initialization.
static java.lang.String title
          OpenMap title.
static java.lang.String version
          OpenMap version.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MapBean()
          Construct a MapBean.
 
Method Summary
protected  void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
          Adds additional constraints on possible children components.
 void addPaintListener(PaintListener l)
          Add a PaintListener.
 void addProjectionListener(ProjectionListener l)
          Add a ProjectionListener to the MapBean.
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          In addition to adding the PropertyChangeListener as the JComponent method does, this method also provides the listener with the initial version of the Layer and Cursor properties.
 void center(CenterEvent evt)
          Handles incoming CenterEvents.
protected  void changeLayers(java.awt.event.ContainerEvent e)
          ContainerListener Interface method.
 void componentAdded(java.awt.event.ContainerEvent e)
          ContainerListener Interface method.
 void componentHidden(java.awt.event.ComponentEvent e)
          ComponentListener interface method.
 void componentMoved(java.awt.event.ComponentEvent e)
          ComponentListener interface method.
 void componentRemoved(java.awt.event.ContainerEvent e)
          ContainerListener Interface method.
 void componentResized(java.awt.event.ComponentEvent e)
          ComponentListener interface method.
 void componentShown(java.awt.event.ComponentEvent e)
          ComponentListener interface method.
protected  void debugmsg(java.lang.String msg)
           
protected  void drawProjectionBackground(java.awt.Graphics g)
          Convenience method to test if Graphics is Graphics2D object, and to try to do the right thing.
protected  void fireProjectionChanged()
          Called from within the MapBean when its projection listeners need to know about a projection change.
 java.awt.Color getBackground()
          Get the background color of the map.
 java.awt.Paint getBckgrnd()
          Get the background of the map.
 LatLonPoint getCenter()
          Gets the center of the map in the form of a LatLonPoint.
 LatLonPoint getCoordinates(java.awt.event.MouseEvent event)
          Convenience function to get the LatLonPoint representing a screen location from a MouseEvent.
 LatLonPoint getCoordinates(java.awt.event.MouseEvent event, LatLonPoint llp)
          Convenience function to get the LatLonPoint representing a screen location from a MouseEvent.
static java.lang.String getCopyrightMessage()
          Return the OpenMap Copyright message.
 boolean getDoContainerChange()
          ContainerListener Interface method.
 java.awt.Insets getInsets()
          Get the Insets of the MapBean.
 MapBeanRepaintPolicy getMapBeanRepaintPolicy()
          Get the MapBeanRepaintPolicy used by the MapBean.
 java.awt.Dimension getMinimumSize()
          Return the minimum size of the MapBean window.
 Projection getProjection()
          Get the projection property.
 int getProjectionType()
          Deprecated. Projection Type integers are no longer really used. The ProjectionFactory should be consulted for which type are available, and the projection should be created there.
 float getScale()
          Gets the scale of the map.
 void hideLayerPalettes()
          Turn off all layer palettes.
 boolean isBufferDirty()
          Checks whether the image buffer should be repainted.
 boolean isBuffered()
          Interface-like method to query if the MapBean is buffered, so you can control behavior better.
 boolean isLayerRemovalDelayed()
          Return the flag for delayed layer removal.
 void paint(java.awt.Graphics g)
          Same as JComponent.paint(), except if there are no children (Layers), the projection still paints the background and the border is painted.
 void paintChildren(java.awt.Graphics g)
          Same as JComponent.paintChildren() except any PaintListeners are notified and the border is painted over the children.
 void paintChildren(java.awt.Graphics g, java.awt.Rectangle clip)
          Same as paintChildren, but allows you to set a clipping area to paint.
 void paintChildrenWithBorder(java.awt.Graphics g, boolean drawBorder)
          Method that provides an option of whether or not to draw the border when painting.
 void pan(PanEvent evt)
          Handles incoming PanEvents.
 void projectionChanged(ProjectionEvent e)
          ProjectionListener interface method.
 void purgeAndNotifyRemovedLayers()
          Clear the vector containing all of the removed layers, and let those layers know they have been removed from the map.
 void removePaintListener(PaintListener l)
          Remove a PaintListener.
 void removeProjectionListener(ProjectionListener l)
          Remove a ProjectionListener from the MapBean.
 void repaint(Layer layer)
          A call to try and get the MapBean to reduce flashing by controlling when repaints happen, waiting for lower layers to call for a repaint(), too.
 void setBackground(java.awt.Color color)
           
 void setBackgroundColor(java.awt.Color color)
          Set the background color of the map.
 void setBckgrnd(java.awt.Paint paint)
          Set the background of the map.
 void setBufferDirty(boolean value)
          Interface-like method to set a buffer dirty, if there is one.
 void setCenter(float lat, float lon)
          Sets the center of the map.
 void setCenter(LatLonPoint newCenter)
          Sets the center of the map.
 void setCursor(java.awt.Cursor newCursor)
          Set the Mouse cursor over the MapBean component.
 void setDoContainerChange(boolean value)
          ContainerListener Interface method.
 void setLayerRemovalDelayed(boolean set)
          If true (default) layers are held when they are removed, and then released and notified of removal when the projection changes.
 void setLayers(LayerEvent evt)
          LayerListener interface method.
 void setLayout(java.awt.LayoutManager mgr)
          Prevents changing the LayoutManager.
 void setMapBeanRepaintPolicy(MapBeanRepaintPolicy mbrp)
          Set the MapBeanRepaintPolicy used by the MapBean.
 void setMinimumSize(java.awt.Dimension dim)
          Set the minimum size of the MapBean window.
 void setProjection(Projection aProjection)
          Set the projection.
 void setProjectionType(int newType)
          Deprecated. Projection Type integers are no longer really used. The ProjectionFactory should be consulted for which type are available, and the projection should be created there.
 void setScale(float newScale)
          Sets the scale of the map.
 void showLayerPalettes()
          Go through the layers, and for all of them that have the autoPalette variable turned on, show their palettes.
 java.lang.String toString()
          Return a stringified representation of the MapBean.
 void zoom(ZoomEvent evt)
          Zoom the Map.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LayersProperty

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

CursorProperty

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

BackgroundProperty

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

ProjectionProperty

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

title

public static final java.lang.String title
OpenMap title.

See Also:
Constant Field Values

version

public static final java.lang.String version
OpenMap version.

See Also:
Constant Field Values

suppressCopyright

public static boolean suppressCopyright
Suppress the copyright message on initialization. But remember, the OpenMap License says you can't do this!


DEFAULT_CENTER_LAT

public static final float DEFAULT_CENTER_LAT
See Also:
Constant Field Values

DEFAULT_CENTER_LON

public static final float DEFAULT_CENTER_LON
See Also:
Constant Field Values

DEFAULT_SCALE

public static final float DEFAULT_SCALE
See Also:
Constant Field Values

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
See Also:
Constant Field Values

minHeight

protected int minHeight

minWidth

protected int minWidth

projection

protected Proj projection

projectionSupport

protected ProjectionSupport projectionSupport

removedLayers

protected java.util.Vector removedLayers
Layers that are removed from the MapBean are held until the next projection change. When the projection changes, they are notified that they have been removed from the map. This list is kept so that toggling a layer on and off won't cause them to get rid of their resources, in case the user is just creating different views of the map.


layerRemovalDelayed

protected boolean layerRemovalDelayed
Some users may want the layers deleted immediately when they are removed from the map. This flag controls that. The default behavior is to hold a reference to a layer and actually release it when the projection changes (default = true). Set to false if you want the MapBean to tell a Layer it has been removed immediately when it happens.


addedLayers

protected java.util.Vector addedLayers
This vector is to let the layers know when they have been added to the map.


painters

protected PaintListenerSupport painters
The PaintListeners want to know when the map has been repainted.


background

protected java.awt.Paint background
The background color for this particular MapBean. If null, the setting for the projection, which in turn is set in the Environment class, will be used.


repaintPolicy

protected MapBeanRepaintPolicy repaintPolicy
The MapBeanRepaintPolicy to use to handler/filter/pace layer repaint() requests. If not set, a StandardMapBeanRepaintPolicy will be used, which forwards repaint requests to Swing normally.


DEFAULT_BACKGROUND_COLOR

public static final java.awt.Color DEFAULT_BACKGROUND_COLOR

currentLayers

protected transient Layer[] currentLayers

doContainerChange

protected transient boolean doContainerChange
Constructor Detail

MapBean

public MapBean()
Construct a MapBean.

Method Detail

getCopyrightMessage

public static java.lang.String getCopyrightMessage()
Return the OpenMap Copyright message.

Returns:
String Copyright

toString

public java.lang.String toString()
Return a stringified representation of the MapBean.

Overrides:
toString in class java.awt.Component
Returns:
String

addImpl

protected final void addImpl(java.awt.Component comp,
                             java.lang.Object constraints,
                             int index)
Adds additional constraints on possible children components. The new component must be a Layer. This method included as a good container citizen, and should not be called directly. Use the add() methods inherited from java.awt.Container instead.

Overrides:
addImpl in class java.awt.Container
Parameters:
comp - Component
constraints - Object
index - int location

setLayout

public final void setLayout(java.awt.LayoutManager mgr)
Prevents changing the LayoutManager. Don't let anyone change the LayoutManager! This is called by the parent component and should not be called directly.

Overrides:
setLayout in class java.awt.Container

getMinimumSize

public java.awt.Dimension getMinimumSize()
Return the minimum size of the MapBean window. Included here to be a good citizen.

Overrides:
getMinimumSize in class javax.swing.JComponent

setMinimumSize

public void setMinimumSize(java.awt.Dimension dim)
Set the minimum size of the MapBean window. Included here to be a good citizen.

Overrides:
setMinimumSize in class javax.swing.JComponent

getInsets

public final java.awt.Insets getInsets()
Get the Insets of the MapBean. This returns 0-length Insets.

This makes sure that there will be no +x,+y offset when drawing graphics. This is ok since any borders around the MapBean will get drawn afterwards on top.

Overrides:
getInsets in class javax.swing.JComponent
Returns:
Insets 0-length Insets

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
ComponentListener interface method. Should not be called directly. Invoked when component has been resized, and kicks off a projection change.

Specified by:
componentResized in interface java.awt.event.ComponentListener
Parameters:
e - ComponentEvent

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
ComponentListener interface method. Should not be called directly. Invoked when component has been moved.

Specified by:
componentMoved in interface java.awt.event.ComponentListener
Parameters:
e - ComponentEvent

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
ComponentListener interface method. Should not be called directly. Invoked when component has been shown.

Specified by:
componentShown in interface java.awt.event.ComponentListener
Parameters:
e - ComponentEvent

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
ComponentListener interface method. Should not be called directly. Invoked when component has been hidden.

Specified by:
componentHidden in interface java.awt.event.ComponentListener
Parameters:
e - ComponentEvent

addProjectionListener

public void addProjectionListener(ProjectionListener l)
Add a ProjectionListener to the MapBean. You do not need to call this method to add layers as ProjectionListeners. This method is called for the layer when it is added to the MapBean. Use this method for other objects that you want to know about the MapBean's projection.

Parameters:
l - ProjectionListener

removeProjectionListener

public void removeProjectionListener(ProjectionListener l)
Remove a ProjectionListener from the MapBean. You do not need to call this method to remove layers that are ProjectionListeners. This method is called for the layer when it is removed from the MapBean. Use this method for other objects that you want to remove from receiving projection events.

Parameters:
l - ProjectionListener

fireProjectionChanged

protected void fireProjectionChanged()
Called from within the MapBean when its projection listeners need to know about a projection change.


purgeAndNotifyRemovedLayers

public void purgeAndNotifyRemovedLayers()
Clear the vector containing all of the removed layers, and let those layers know they have been removed from the map.


getScale

public float getScale()
Gets the scale of the map.

Returns:
float the current scale of the map
See Also:
Projection.getScale()

setScale

public void setScale(float newScale)
Sets the scale of the map. The Projection may silently disregard this setting, setting it to a maxscale or minscale value.

Parameters:
newScale - the new scale
See Also:
Proj.setScale(float)

getCenter

public LatLonPoint getCenter()
Gets the center of the map in the form of a LatLonPoint.

Returns:
the center point of the map
See Also:
Projection.getCenter()

setCenter

public void setCenter(LatLonPoint newCenter)
Sets the center of the map.

Parameters:
newCenter - the center point of the map
See Also:
Proj.setCenter(LatLonPoint)

setCenter

public void setCenter(float lat,
                      float lon)
Sets the center of the map.

Parameters:
lat - the latitude of center point of the map in decimal degrees
lon - the longitude of center point of the map in decimal degrees
See Also:
Proj.setCenter(float, float)

getProjectionType

public int getProjectionType()
Deprecated. Projection Type integers are no longer really used. The ProjectionFactory should be consulted for which type are available, and the projection should be created there.

Get the type of the projection.

Returns:
int type
See Also:
Projection.getProjectionType()

setProjectionType

public void setProjectionType(int newType)
Deprecated. Projection Type integers are no longer really used. The ProjectionFactory should be consulted for which type are available, and the projection should be created there.

Set the type of the projection. If different from the current type, this installs a new projection with the same center, scale, width, and height of the previous one.

Parameters:
newType - the new projection type

setBackgroundColor

public void setBackgroundColor(java.awt.Color color)
Set the background color of the map. If the background for this MapBean is not null, the background of the projection will be used.

Parameters:
color - java.awt.Color.

setBackground

public void setBackground(java.awt.Color color)
Overrides:
setBackground in class javax.swing.JComponent

setBckgrnd

public void setBckgrnd(java.awt.Paint paint)
Set the background of the map. If the background for this MapBean is not null, the background of the projection will be used.

Parameters:
paint - java.awt.Paint.

getBackground

public java.awt.Color getBackground()
Get the background color of the map. If the background color for this MapBean has been explicitly set, that value will be returned. Otherwise, the background color of the projection will be returned. If the background is not a color (as opposed to Paint) this method will return null.

Overrides:
getBackground in class java.awt.Component
Returns:
color java.awt.Color.

getBckgrnd

public java.awt.Paint getBckgrnd()
Get the background of the map. If the background for this MapBean has been explicitly set, that value will be returned. Otherwise, the background of the projection will be returned.

Returns:
color java.awt.Color.

getProjection

public Projection getProjection()
Get the projection property.

Returns:
Projection

setProjection

public void setProjection(Projection aProjection)
Set the projection. Shouldn't be null, and won't do anything if it is.

Parameters:
aProjection - Projection

center

public void center(CenterEvent evt)
Handles incoming CenterEvents.

Specified by:
center in interface CenterListener
Parameters:
evt - the incoming center event

pan

public void pan(PanEvent evt)
Handles incoming PanEvents.

Specified by:
pan in interface PanListener
Parameters:
evt - the incoming pan event

zoom

public void zoom(ZoomEvent evt)
Zoom the Map. Part of the ZoomListener interface. Sets the scale of the MapBean projection, based on a relative or absolute amount.

Specified by:
zoom in interface ZoomListener
Parameters:
evt - the ZoomEvent describing the new scale.

setDoContainerChange

public void setDoContainerChange(boolean value)
ContainerListener Interface method. Should not be called directly. Part of the ContainerListener interface, and it's here to make the MapBean a good Container citizen.

Parameters:
value - boolean

getDoContainerChange

public boolean getDoContainerChange()
ContainerListener Interface method. Should not be called directly. Part of the ContainerListener interface, and it's here to make the MapBean a good Container citizen.

Returns:
boolean

componentAdded

public void componentAdded(java.awt.event.ContainerEvent e)
ContainerListener Interface method. Should not be called directly. Part of the ContainerListener interface, and it's here to make the MapBean a good Container citizen.

Specified by:
componentAdded in interface java.awt.event.ContainerListener
Parameters:
e - ContainerEvent

componentRemoved

public void componentRemoved(java.awt.event.ContainerEvent e)
ContainerListener Interface method. Should not be called directly. Part of the ContainerListener interface, and it's here to make the MapBean a good Container citizen. Layers that are removed are added to a list, which is cleared when the projection changes. If they are added to the MapBean again before the projection changes, they are taken off the list, added back to the MapBean, and are simply repainted. This prevents layers from doing unnecessary work if they are toggled on and off without projection changes.

Specified by:
componentRemoved in interface java.awt.event.ContainerListener
Parameters:
e - ContainerEvent
See Also:
purgeAndNotifyRemovedLayers()

changeLayers

protected void changeLayers(java.awt.event.ContainerEvent e)
ContainerListener Interface method. Should not be called directly. Part of the ContainerListener interface, and it's here to make the MapBean a good Container citizen.

Parameters:
e - ContainerEvent

projectionChanged

public void projectionChanged(ProjectionEvent e)
ProjectionListener interface method. Should not be called directly.

Specified by:
projectionChanged in interface ProjectionListener
Parameters:
e - ProjectionEvent

setCursor

public void setCursor(java.awt.Cursor newCursor)
Set the Mouse cursor over the MapBean component.

Overrides:
setCursor in class java.awt.Component
Parameters:
newCursor - Cursor

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
In addition to adding the PropertyChangeListener as the JComponent method does, this method also provides the listener with the initial version of the Layer and Cursor properties.

Overrides:
addPropertyChangeListener in class javax.swing.JComponent

debugmsg

protected final void debugmsg(java.lang.String msg)

paint

public void paint(java.awt.Graphics g)
Same as JComponent.paint(), except if there are no children (Layers), the projection still paints the background and the border is painted.

Overrides:
paint in class javax.swing.JComponent

drawProjectionBackground

protected void drawProjectionBackground(java.awt.Graphics g)
Convenience method to test if Graphics is Graphics2D object, and to try to do the right thing.


paintChildren

public void paintChildren(java.awt.Graphics g)
Same as JComponent.paintChildren() except any PaintListeners are notified and the border is painted over the children.

Overrides:
paintChildren in class javax.swing.JComponent

paintChildren

public void paintChildren(java.awt.Graphics g,
                          java.awt.Rectangle clip)
Same as paintChildren, but allows you to set a clipping area to paint. Be careful with this, because if the clipping area is set while some layer decides to paint itself, that layer may not have all it's objects painted.


paintChildrenWithBorder

public void paintChildrenWithBorder(java.awt.Graphics g,
                                    boolean drawBorder)
Method that provides an option of whether or not to draw the border when painting. Usually called from another object trying to control the Map appearance when events are flying around.


addPaintListener

public void addPaintListener(PaintListener l)
Add a PaintListener.

Parameters:
l - PaintListener

removePaintListener

public void removePaintListener(PaintListener l)
Remove a PaintListener.

Parameters:
l - PaintListener

setLayers

public void setLayers(LayerEvent evt)
LayerListener interface method. A list of layers will be added, removed, or replaced based on on the type of LayerEvent.

Specified by:
setLayers in interface LayerListener
Parameters:
evt - a LayerEvent

repaint

public void repaint(Layer layer)
A call to try and get the MapBean to reduce flashing by controlling when repaints happen, waiting for lower layers to call for a repaint(), too. Calls shouldForwardRepaint(Layer), which acts as a policy for whether to forward the repaint up the Swing tree.


setMapBeanRepaintPolicy

public void setMapBeanRepaintPolicy(MapBeanRepaintPolicy mbrp)
Set the MapBeanRepaintPolicy used by the MapBean. This policy can be used to pace/filter layer repaint() requests.


getMapBeanRepaintPolicy

public MapBeanRepaintPolicy getMapBeanRepaintPolicy()
Get the MapBeanRepaintPolicy used by the MapBean. This policy can be used to pace/filter layer repaint() requests. If no policy has been set, a StandardMapBeanRepaintPolicy will be created, which simply forwards all requests.


getCoordinates

public LatLonPoint getCoordinates(java.awt.event.MouseEvent event)
Convenience function to get the LatLonPoint representing a screen location from a MouseEvent. Returns null if the event is null, or if the projection is not set in the MapBean. Allocates new LatLonPoint with coordinates.


getCoordinates

public LatLonPoint getCoordinates(java.awt.event.MouseEvent event,
                                  LatLonPoint llp)
Convenience function to get the LatLonPoint representing a screen location from a MouseEvent. Returns null if the event is null, or if the projection is not set in the MapBean. Save on memory allocation by sending in the LatLonPoint to fill.


isBuffered

public boolean isBuffered()
Interface-like method to query if the MapBean is buffered, so you can control behavior better. Allows the removal of specific instance-like quieries for, say, BufferedMapBean, when all you really want to know is if you have the data is buffered, and if so, should be buffer be cleared. For the MapBean, always false.


setBufferDirty

public void setBufferDirty(boolean value)
Interface-like method to set a buffer dirty, if there is one. In MapBean, there isn't.

Parameters:
value - boolean

isBufferDirty

public boolean isBufferDirty()
Checks whether the image buffer should be repainted.

Returns:
boolean whether the layer buffer is dirty. Always true for MapBean, because a paint is always gonna need to happen.

setLayerRemovalDelayed

public void setLayerRemovalDelayed(boolean set)
If true (default) layers are held when they are removed, and then released and notified of removal when the projection changes. This saves the layers from releasing resources if the layer is simply being toggled on/off for different map views.


isLayerRemovalDelayed

public boolean isLayerRemovalDelayed()
Return the flag for delayed layer removal.


showLayerPalettes

public void showLayerPalettes()
Go through the layers, and for all of them that have the autoPalette variable turned on, show their palettes.


hideLayerPalettes

public void hideLayerPalettes()
Turn off all layer palettes.



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