com.bbn.openmap
Class MapBean

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.bbn.openmap.MapBean
All Implemented Interfaces:
CenterListener, LayerListener, PanListener, ProjectionListener, ZoomListener, SoloMapComponent, java.awt.event.ComponentListener, java.awt.event.ContainerListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
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.

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 Also:
Layer, Serialized Form

Nested Class Summary
protected  class MapBean.RotationHelper
           
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.util.Vector<Layer> 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
           
protected  ProjectionFactory projectionFactory
           
static java.lang.String ProjectionProperty
           
protected  ProjectionSupport projectionSupport
           
static java.lang.String ProjectionVetoedProperty
           
protected  java.util.Vector<Layer> 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.
protected  double rotationAngle
          The angle, in radians, to rotate the map.
protected  MapBean.RotationHelper rotHelper
           
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.
MapBean(boolean useThreadedNotification)
           
 
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)
           
 void dispose()
          Call when getting rid of the MapBean, it releases pointers to all listeners and kills the ProjectionSupport thread.
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.
 java.awt.geom.Point2D getCenter()
          Gets the center of the map in the form of a LatLonPoint.
 java.awt.geom.Point2D getCoordinates(java.awt.event.MouseEvent event)
          Convenience function to get the LatLonPoint representing a screen location from a MouseEvent.
<T extends java.awt.geom.Point2D>
T
getCoordinates(java.awt.event.MouseEvent event, T 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.Graphics getGraphics(boolean rotateIfSet)
           
 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.
 java.awt.geom.Point2D getNonRotatedLocation(java.awt.event.MouseEvent event)
          Convenience function to get the pixel Point2D representing a screen location from a MouseEvent in the projection space (as if there is no rotation set).
 java.awt.geom.Point2D getNonRotatedLocation(java.awt.event.MouseEvent event, java.awt.geom.Point2D pnt)
          Convenience function to get the pixel Point2D representing a screen location from a MouseEvent in the projection space (as if there is no rotation set).
 java.awt.Shape getNonRotatedShape(java.awt.Shape shape)
          If the map has been rotated, get a shape that has been transformed into the pixel space of the unrotated maps (the space the projected OMGraphics know about).
 Projection getProjection()
          Get the projection property, reflects the projection with no rotation.
 ProjectionFactory getProjectionFactory()
           
 Projection getRotatedProjection()
           
 double getRotationAngle()
          Get the rotation of the map in RADIANS.
protected  MapBean.RotationHelper getRotHelper()
          Get the RotationHelper that assists with rotated maps.
 float getScale()
          Gets the scale of the map.
protected  MapBean.RotationHelper getUpdatedRotHelper()
          Handles all of the updating of the RotationHelper if needed, based on the current rotation settings on the MapBean.
 void hideLayerPalettes()
          Turn off all layer palettes.
<T extends java.awt.geom.Point2D>
T
inverse(double x, double y, T ret)
          Checks the rotation set on the MapBean and accounts for it before calling inverse on the projection.
 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()
           
 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 paintBorder(java.awt.Graphics g)
          We override this to set the paint mode on the Graphics before the border is painted, otherwise we get an XOR effect in the border.
 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.
protected  void paintLayers(java.awt.Graphics g)
          A method that grabs the component list of the MapBean, and renders just the layers from back to front.
 void paintPainters(java.awt.Graphics g)
           
 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(double lat, double lon)
          Sets the center of the map.
 void setCenter(float lat, float lon)
          Sets the center of the map.
 void setCenter(java.awt.geom.Point2D 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 setProjectionFactory(ProjectionFactory projFactory)
           
 void setRotationAngle(double angle)
          Set the rotation of the map in RADIANS.
 void setRotationAngle(double angle, boolean fastRotation)
          Set the rotation of the map in RADIANS.
protected  void setRotHelper(MapBean.RotationHelper nRotHelper)
           
 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 string-ified representation of the MapBean.
 void zoom(ZoomEvent evt)
          Zoom the Map.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

ProjectionVetoedProperty

public static final java.lang.String ProjectionVetoedProperty
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.


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 final ProjectionSupport projectionSupport

removedLayers

protected final java.util.Vector<Layer> 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 final java.util.Vector<Layer> addedLayers
This vector is to let the layers know when they have been added to the map.


painters

protected final 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.


rotationAngle

protected double rotationAngle
The angle, in radians, to rotate the map. 0.0 is north-up, clockwise is positive.


DEFAULT_BACKGROUND_COLOR

public static final java.awt.Color DEFAULT_BACKGROUND_COLOR

currentLayers

protected transient Layer[] currentLayers

doContainerChange

protected transient boolean doContainerChange

projectionFactory

protected ProjectionFactory projectionFactory

rotHelper

protected MapBean.RotationHelper rotHelper
Constructor Detail

MapBean

public MapBean()
Construct a MapBean.


MapBean

public MapBean(boolean useThreadedNotification)
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 string-ified representation of the MapBean.

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

dispose

public void dispose()
Call when getting rid of the MapBean, it releases pointers to all listeners and kills the ProjectionSupport thread.


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 java.awt.geom.Point2D 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(java.awt.geom.Point2D newCenter)
Sets the center of the map.

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

setCenter

public void setCenter(double lat,
                      double 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(double, double)

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(double, double)

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

paintBorder

public void paintBorder(java.awt.Graphics g)
We override this to set the paint mode on the Graphics before the border is painted, otherwise we get an XOR effect in the border.

Overrides:
paintBorder 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, reflects the projection with no rotation.

Returns:
current Projection of map.

getRotatedProjection

public Projection getRotatedProjection()
Returns:
the expanded rotated projection if map rotated, normal projection if not rotated. The rotated projection is larger than the MapBean and has extra offsets.

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 java.awt.Container

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

paintPainters

public void paintPainters(java.awt.Graphics g)

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.


paintLayers

protected void paintLayers(java.awt.Graphics g)
A method that grabs the component list of the MapBean, and renders just the layers from back to front. No clipping is set, other than what is set on the Graphics object.

Parameters:
g - Graphics

getGraphics

public java.awt.Graphics getGraphics(boolean rotateIfSet)

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 java.awt.geom.Point2D 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. Takes rotation set on MapBean into account.


getCoordinates

public <T extends java.awt.geom.Point2D> T getCoordinates(java.awt.event.MouseEvent event,
                                                          T 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. Takes rotation set on MapBean into account.


getNonRotatedLocation

public java.awt.geom.Point2D getNonRotatedLocation(java.awt.event.MouseEvent event)
Convenience function to get the pixel Point2D representing a screen location from a MouseEvent in the projection space (as if there is no rotation set). Returns null if the event is null. This is used to talk to the OMGraphics, since they don't know about the map rotation.


getNonRotatedLocation

public java.awt.geom.Point2D getNonRotatedLocation(java.awt.event.MouseEvent event,
                                                   java.awt.geom.Point2D pnt)
Convenience function to get the pixel Point2D representing a screen location from a MouseEvent in the projection space (as if there is no rotation set). Returns null if the event is null. This is used to talk to the OMGraphics, since they don't know about the map rotation.


getNonRotatedShape

public java.awt.Shape getNonRotatedShape(java.awt.Shape shape)
If the map has been rotated, get a shape that has been transformed into the pixel space of the unrotated maps (the space the projected OMGraphics know about).

Parameters:
shape - input shape
Returns:
GeneralPath for transform shape if map is rotated, the input shape if the map is not rotated.

inverse

public <T extends java.awt.geom.Point2D> T inverse(double x,
                                                   double y,
                                                   T ret)
Checks the rotation set on the MapBean and accounts for it before calling inverse on the projection.

Parameters:
x - horizontal window pixel from left side
y - vertical window pixel from top
ret - Point2D object returned with coordinates suitable for projection where mouse event is.
Returns:
the provided T ret object, or new Point2D object from projection if ret is null.

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 queries 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.

Parameters:
set - the setting

isLayerRemovalDelayed

public boolean isLayerRemovalDelayed()
Returns:
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.


getProjectionFactory

public ProjectionFactory getProjectionFactory()

setProjectionFactory

public void setProjectionFactory(ProjectionFactory projFactory)

getUpdatedRotHelper

protected MapBean.RotationHelper getUpdatedRotHelper()
Handles all of the updating of the RotationHelper if needed, based on the current rotation settings on the MapBean.

Returns:
the locRotHelper, null if not needed.

getRotHelper

protected MapBean.RotationHelper getRotHelper()
Get the RotationHelper that assists with rotated maps.

Returns:
RotationHelper, may be null if map isn't rotated.

setRotHelper

protected void setRotHelper(MapBean.RotationHelper nRotHelper)
Parameters:
nRotHelper - the locRotHelper to set as the current one. Disposes of the old one.

setRotationAngle

public void setRotationAngle(double angle)
Set the rotation of the map in RADIANS.

Parameters:
angle - radians of rotation, increasing clockwise.

setRotationAngle

public void setRotationAngle(double angle,
                             boolean fastRotation)
Set the rotation of the map in RADIANS.

Parameters:
angle - radians of rotation, increasing clockwise.
fastRotation - if true, fireProjectionChange will not be called, and the RotationHelper will be used to spin image buffer.

getRotationAngle

public double getRotationAngle()
Get the rotation of the map in RADIANS.

Returns:
the angle the map has been rotated, in RADIANS, clockwise is positive.


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