com.bbn.openmap.event
Class RangeRingsMouseMode

java.lang.Object
  extended by com.bbn.openmap.MapHandlerChild
      extended by com.bbn.openmap.OMComponent
          extended by com.bbn.openmap.event.AbstractMouseMode
              extended by com.bbn.openmap.event.CoordMouseMode
                  extended by com.bbn.openmap.event.RangeRingsMouseMode
All Implemented Interfaces:
MapMouseMode, PaintListener, LightMapHandlerChild, PropertyConsumer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener

public class RangeRingsMouseMode
extends CoordMouseMode

Mouse mode for drawing temporary range rings on a map bean.
The whole map bean is repainted each time the range rings needs to be repainted. The map bean needs to use a mouseDelegator to repaint properly.

Author:
St�phane Wasserhardt
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.bbn.openmap.event.AbstractMouseMode
AbstractMouseMode.MouseWheelTimerListener
 
Field Summary
protected  LatLonPoint destination
          Destination point of the range rings to be drawn.
 java.text.DecimalFormat df
           
protected  java.text.Format distanceFormat
          Format used to draw distances.
protected  LatLonPoint intermediateDest
          Temporary destination point of the range rings to be drawn.
protected  MapBean mapBean
          Active MapBean.
static java.lang.String modeID
           
static java.lang.String NUM_RINGS_PROPERTY
          The property string used to set the numRings member variable.
protected  int numRings
          Number of rings to draw.
protected  LatLonPoint origin
          Origin point of the range rings to be drawn.
 
Fields inherited from class com.bbn.openmap.event.CoordMouseMode
coordFormatter, coordFormatterHandler, CoordFormatterProperty, infoDelegator
 
Fields inherited from class com.bbn.openmap.event.AbstractMouseMode
cursor, CursorIDProperty, guiIcon, iconName, IconProperty, ID, IDProperty, logger, mouseSupport, mouseTimer, mouseWheelListener, MouseWheelListenerProperty, mouseWheelTimerInterval, MouseWheelTimerIntervalProperty, mouseWheelTimerListener, MouseWheelZoomProperty, noMouseWheelListenerTimer, NoMouseWheelListenerTimerProperty, prettyName, PrettyNameProperty, propertyChangeSupport, visible, ZOOM_IN, ZOOM_OUT, zoomWhenMouseWheelUp
 
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
RangeRingsMouseMode()
           
RangeRingsMouseMode(boolean shouldConsumeEvents)
           
RangeRingsMouseMode(java.lang.String name, boolean shouldConsumeEvents)
           
 
Method Summary
protected  void cleanUp()
          Called when the range rings must be cleared, before repainting a clean map.
protected  void finished()
          Called when the end point of the range rings has been selected, before painting on the map.
 java.text.Format getDistanceFormat()
          Give the Format object used to display distances.
protected  java.lang.String getLabelFor(LatLonPoint dest)
          Returns the String to be used as a labeler for the circle drawn using dest.
 MapBean getMapBean()
          Return the map bean.
 int getNumRings()
          Returns the number of rings to display.
protected  java.lang.String getOriginLabel()
          Returns the String to be used as a labeler for the origin point of the range rings.
 java.util.Properties getProperties(java.util.Properties props)
          PropertyConsumer method, to fill in a Properties object, reflecting the current values of the OMComponent.
 java.util.Properties getPropertyInfo(java.util.Properties list)
          Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer.
protected  void init()
           
 void listenerPaint(java.awt.Graphics g)
          PaintListener interface, notifying the MouseMode that the MapBean has repainted itself.
 void mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseEntered(java.awt.event.MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseMoved(java.awt.event.MouseEvent e)
          Fires a mouse location to the InformationDelegator, and then calls the super class method which calls the MouseSupport method.
 void mousePressed(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been released on a component.
protected  void paintCircle(LatLonPoint dest)
          Paints a unique circle centered on origin and which crosses dest on the map bean.
protected  void paintCircle(LatLonPoint dest, java.awt.Graphics graphics)
          Paints a unique circle centered on origin and which crosses dest on the given Graphics.
protected  void paintLabel(LatLonPoint dest)
          Paints a label for the circle drawn using dest on the map bean.
protected  void paintLabel(LatLonPoint dest, java.awt.Graphics graphics)
          Paints a label for the circle drawn using dest on the given Graphics.
protected  void paintOrigin()
          Paints the origin point of the range rings and its label on the map bean.
protected  void paintOrigin(java.awt.Graphics graphics)
          Paints the origin point of the range rings and its label on the given Graphics.
protected  void paintOriginLabel(java.awt.Graphics graphics)
          Paints the origin label of the range rings on the given Graphics.
protected  void paintOriginPoint(java.awt.Graphics graphics)
          Paints the origin point of the range rings on the given Graphics.
protected  void paintRangeRings(LatLonPoint dest)
          Paints the circles and their labels on the map bean.
protected  void paintRangeRings(LatLonPoint dest, java.awt.Graphics graphics)
          Paints the circles and their labels on the given Graphics.
protected  void prepareCircle(OMCircle circle)
          Customizes the given OMCicle before it is rendered.
protected  void prepareLabel(OMText text)
          Customizes the given OMText before it is rendered.
protected  void preparePoint(OMPoint point)
          Customizes the given OMPoint before it is rendered.
 void redraw()
          Repaints the map bean.
 void setDistanceFormat(java.text.Format distanceFormat)
          Sets the Format object used to display distances.
 void setMapBean(MapBean aMap)
          Set the map bean.
 void setNumRings(int numRings)
          Sets the number of rings to display.
 void setProperties(java.lang.String prefix, java.util.Properties props)
          Sets the properties for the OMComponent.
protected  void startUp()
          Called when the origin point of the range rings has been selected, before painting on the map.
protected  void update()
          Called when the origin point of the range is is known, and the mouse is moving on the map, but before painting on the map.
 
Methods inherited from class com.bbn.openmap.event.CoordMouseMode
findAndInit, findAndUndo, fireMouseLocation, getCoordFormatter, getCoordFormatterHandler, getInfoDelegator, mouseDragged, propertyChange, setActive, setCoordFormatter, setCoordFormatterHandler, setInfoDelegator
 
Methods inherited from class com.bbn.openmap.event.AbstractMouseMode
actAsProxyFor, actAsProxyFor, addMapMouseListener, addPropertyChangeListener, getClassToUseForIconRetrieval, getGUIIcon, getIconName, getID, getModeCursor, getMouseSupport, getMouseWheelTimerInterval, getNoMouseWheelListener, getPrettyName, getProxied, getProxyDistributionMask, isConsumeEvents, isMouseWheelListener, isNoMouseWheelListenerTimer, isProxyFor, isVisible, isZoomWhenMouseWheelUp, mouseExited, mouseWheelMoved, releaseProxy, removeAllMapMouseListeners, removeMapMouseListener, removePropertyChangeListener, setConsumeEvents, setGUIIcon, setIconName, setID, setModeCursor, setModeCursor, setMouseSupport, setMouseWheelListener, setMouseWheelTimerInterval, setNoMouseWheelListener, setNoMouseWheelListenerTimer, setPrettyName, setProxyDistributionMask, setVisible, setZoomWhenMouseWheelUp, updateMouseWheelMoved
 
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, setBeanContext, setIsolated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modeID

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

NUM_RINGS_PROPERTY

public static final java.lang.String NUM_RINGS_PROPERTY
The property string used to set the numRings member variable.

See Also:
Constant Field Values

df

public transient java.text.DecimalFormat df

distanceFormat

protected java.text.Format distanceFormat
Format used to draw distances.


numRings

protected int numRings
Number of rings to draw. Must be a positive integer, or else the value 1 will be used. Default value is 3.


origin

protected LatLonPoint origin
Origin point of the range rings to be drawn.


intermediateDest

protected LatLonPoint intermediateDest
Temporary destination point of the range rings to be drawn.


destination

protected LatLonPoint destination
Destination point of the range rings to be drawn.


mapBean

protected MapBean mapBean
Active MapBean.

Constructor Detail

RangeRingsMouseMode

public RangeRingsMouseMode()

RangeRingsMouseMode

public RangeRingsMouseMode(boolean shouldConsumeEvents)

RangeRingsMouseMode

public RangeRingsMouseMode(java.lang.String name,
                           boolean shouldConsumeEvents)
Method Detail

init

protected void init()

getMapBean

public MapBean getMapBean()
Return the map bean.

Returns:
The map bean.

setMapBean

public void setMapBean(MapBean aMap)
Set the map bean.

Parameters:
aMap - a map bean

getDistanceFormat

public java.text.Format getDistanceFormat()
Give the Format object used to display distances.

Returns:
Format.

setDistanceFormat

public void setDistanceFormat(java.text.Format distanceFormat)
Sets the Format object used to display distances.

Parameters:
distanceFormat - Format.

getNumRings

public int getNumRings()
Returns the number of rings to display.

Returns:
the number of rings to display.

setNumRings

public void setNumRings(int numRings)
Sets the number of rings to display.

Parameters:
numRings - the number of rings to display.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Description copied from class: AbstractMouseMode
Invoked when the mouse has been clicked on a component. Calls fireMapMouseClicked on MouseSupport.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class AbstractMouseMode
Parameters:
e - MouseEvent

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Description copied from class: AbstractMouseMode
Invoked when a mouse button has been pressed on a component. Calls fiewMapMousePressed on the MouseSupport. Also requests focus on the source of the MouseEvent, so that key events can be processed.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class AbstractMouseMode
Parameters:
e - MouseEvent

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Description copied from class: AbstractMouseMode
Invoked when a mouse button has been released on a component. Calls fireMapMouseReleased on the MouseSupport.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class AbstractMouseMode
Parameters:
e - MouseEvent

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Description copied from class: CoordMouseMode
Fires a mouse location to the InformationDelegator, and then calls the super class method which calls the MouseSupport method.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class CoordMouseMode
Parameters:
e - MouseEvent to be handled

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Description copied from class: AbstractMouseMode
Invoked when the mouse enters a component. Calls fireMapMouseEntered on the MouseSupport.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class AbstractMouseMode
Parameters:
e - MouseEvent

redraw

public void redraw()
Repaints the map bean. When this mouse mode is active, it is registered as a paintListener for the mapBean by the mouseDelegator, so the listenerPaint method can draw the range rings on the map bean.


listenerPaint

public void listenerPaint(java.awt.Graphics g)
Description copied from class: AbstractMouseMode
PaintListener interface, notifying the MouseMode that the MapBean has repainted itself. Useful if the MouseMode is drawing stuff.

Specified by:
listenerPaint in interface PaintListener
Overrides:
listenerPaint in class AbstractMouseMode

paintOrigin

protected void paintOrigin()
Paints the origin point of the range rings and its label on the map bean.


paintOrigin

protected void paintOrigin(java.awt.Graphics graphics)
Paints the origin point of the range rings and its label on the given Graphics.

Parameters:
graphics - The Graphics to paint on.

paintOriginPoint

protected void paintOriginPoint(java.awt.Graphics graphics)
Paints the origin point of the range rings on the given Graphics.

Parameters:
graphics - The Graphics to paint on.

paintOriginLabel

protected void paintOriginLabel(java.awt.Graphics graphics)
Paints the origin label of the range rings on the given Graphics.

Parameters:
graphics - The Graphics to paint on.

paintRangeRings

protected void paintRangeRings(LatLonPoint dest)
Paints the circles and their labels on the map bean.

Parameters:
dest - The destination point, used with the origin member variable to compute the rings.

paintRangeRings

protected void paintRangeRings(LatLonPoint dest,
                               java.awt.Graphics graphics)
Paints the circles and their labels on the given Graphics.

Parameters:
dest - The destination point, used with the origin member variable to compute the rings.
graphics - The Graphics to paint on.

paintCircle

protected void paintCircle(LatLonPoint dest)
Paints a unique circle centered on origin and which crosses dest on the map bean.

Parameters:
dest - A point on the circle.

paintCircle

protected void paintCircle(LatLonPoint dest,
                           java.awt.Graphics graphics)
Paints a unique circle centered on origin and which crosses dest on the given Graphics.

Parameters:
dest - A point on the circle.
graphics - The Graphics to paint on.

paintLabel

protected void paintLabel(LatLonPoint dest)
Paints a label for the circle drawn using dest on the map bean.

Parameters:
dest - A point on the circle.

paintLabel

protected void paintLabel(LatLonPoint dest,
                          java.awt.Graphics graphics)
Paints a label for the circle drawn using dest on the given Graphics.

Parameters:
dest - A point on the circle.
graphics - The Graphics to paint on.

preparePoint

protected void preparePoint(OMPoint point)
Customizes the given OMPoint before it is rendered.

Parameters:
point - OMPoint.

prepareCircle

protected void prepareCircle(OMCircle circle)
Customizes the given OMCicle before it is rendered.

Parameters:
circle - OMCircle.

prepareLabel

protected void prepareLabel(OMText text)
Customizes the given OMText before it is rendered.

Parameters:
text - OMText.

getOriginLabel

protected java.lang.String getOriginLabel()
Returns the String to be used as a labeler for the origin point of the range rings.

Returns:
label String.

getLabelFor

protected java.lang.String getLabelFor(LatLonPoint dest)
Returns the String to be used as a labeler for the circle drawn using dest.

Parameters:
dest - A point on a circle.
Returns:
label String.

startUp

protected void startUp()
Called when the origin point of the range rings has been selected, before painting on the map.


update

protected void update()
Called when the origin point of the range is is known, and the mouse is moving on the map, but before painting on the map.


finished

protected void finished()
Called when the end point of the range rings has been selected, before painting on the map.


cleanUp

protected void cleanUp()
Called when the range rings must be cleared, before repainting a clean map.


setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties props)
Description copied from class: OMComponent
Sets the properties for the OMComponent.

Specified by:
setProperties in interface PropertyConsumer
Overrides:
setProperties in class CoordMouseMode
Parameters:
prefix - the token to prefix the property names
props - the Properties object

getProperties

public java.util.Properties getProperties(java.util.Properties props)
Description copied from class: OMComponent
PropertyConsumer method, to fill in a Properties object, reflecting the current values of the OMComponent. If the component has a propertyPrefix set, the property keys should have that prefix plus a separating '.' prepended to each property key it uses for configuration.

Specified by:
getProperties in interface PropertyConsumer
Overrides:
getProperties in class CoordMouseMode
Parameters:
props - a Properties object to load the PropertyConsumer properties into. If props equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

getPropertyInfo

public java.util.Properties getPropertyInfo(java.util.Properties list)
Description copied from class: OMComponent
Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer. The key for each property should be the raw property name (without a prefix) with a value that is a String that describes what the property key represents, along with any other information about the property that would be helpful (range, default value, etc.). For Layer, this method should at least return the 'prettyName' property.

Specified by:
getPropertyInfo in interface PropertyConsumer
Overrides:
getPropertyInfo in class CoordMouseMode
Parameters:
list - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.


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