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:
Stephane Wasserhardt
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.bbn.openmap.event.AbstractMouseMode
AbstractMouseMode.MouseWheelTimerListener
 
Field Summary
protected  java.awt.geom.Point2D 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  java.awt.geom.Point2D intermediateDest
          Temporary destination point of the range rings to be drawn.
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  java.awt.geom.Point2D origin
          Origin point of the range rings to be drawn.
protected  DrawingAttributes rrAttributes
           
protected  Length units
          Distance units for label.
static java.lang.String UNITS_PROPERTY
           
 
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.
 java.text.Format getDistanceFormat()
          Give the Format object used to display distances.
protected  java.lang.String getLabelFor(double distance)
          Returns the String to be used as a labeler for the circle drawn using dest.
 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)
          Get the current Properties for this mouse mode.
 java.util.Properties getPropertyInfo(java.util.Properties list)
          Return property info metadata for this PropertyConsumer.
protected  void init()
           
 void listenerPaint(java.lang.Object source, java.awt.Graphics g)
          PaintListener method.
 void mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(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 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(Geo originGeo, double distance, java.awt.Graphics graphics, MapBean theMap)
          Paints a unique circle centered on origin and which crosses dest on the given Graphics.
protected  void paintLabel(Geo originGeo, double distance, java.awt.Graphics graphics, MapBean theMap)
          Paints a label for the circle drawn using dest on the given Graphics.
protected  void paintOrigin(java.awt.geom.Point2D llp, java.awt.Graphics graphics, MapBean theMap)
          Paints the origin point of the range rings and its label on the given Graphics.
protected  void paintOriginLabel(java.awt.geom.Point2D originPnt, java.awt.Graphics graphics, MapBean theMap)
          Paints the origin label of the range rings on the given Graphics.
protected  void paintOriginPoint(java.awt.geom.Point2D originPnt, java.awt.Graphics graphics, MapBean theMap)
          Paints the origin point of the range rings on the given Graphics.
protected  void paintRangeRings(java.awt.geom.Point2D originPnt, java.awt.geom.Point2D dest, java.awt.Graphics graphics, MapBean theMap)
          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 setActive(boolean active)
          If the MouseMode has been made inactive, clean out any input that might have been made to the info line.
 void setDistanceFormat(java.text.Format distanceFormat)
          Sets the Format object used to display distances.
 void setNumRings(int numRings)
          Sets the number of rings to display.
 void setProperties(java.lang.String prefix, java.util.Properties props)
          Set properties for this mouse mode
 
Methods inherited from class com.bbn.openmap.event.CoordMouseMode
findAndInit, findAndUndo, fireMouseLocation, getCoordFormatter, getCoordFormatterHandler, getInfoDelegator, propertyChange, 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, mouseEntered, 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

UNITS_PROPERTY

public static final java.lang.String UNITS_PROPERTY
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 java.awt.geom.Point2D origin
Origin point of the range rings to be drawn.


intermediateDest

protected java.awt.geom.Point2D intermediateDest
Temporary destination point of the range rings to be drawn.


destination

protected java.awt.geom.Point2D destination
Destination point of the range rings to be drawn.


rrAttributes

protected DrawingAttributes rrAttributes

units

protected Length units
Distance units for label.

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

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.

setActive

public void setActive(boolean active)
Description copied from class: CoordMouseMode
If the MouseMode has been made inactive, clean out any input that might have been made to the info line.

Specified by:
setActive in interface MapMouseMode
Overrides:
setActive in class CoordMouseMode
Parameters:
active - true if the mode has been made active, false if it has been made inactive.

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

mouseDragged

public void mouseDragged(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:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class CoordMouseMode
Parameters:
e - mouse event.

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

listenerPaint

public void listenerPaint(java.lang.Object source,
                          java.awt.Graphics g)
PaintListener method.

Specified by:
listenerPaint in interface PaintListener
Overrides:
listenerPaint in class AbstractMouseMode
Parameters:
source - the source object, most likely the MapBean
g - java.awt.Graphics

paintOrigin

protected void paintOrigin(java.awt.geom.Point2D llp,
                           java.awt.Graphics graphics,
                           MapBean theMap)
Paints the origin point of the range rings and its label on the given Graphics.

Parameters:
llp - the location of the origin.
graphics - The Graphics to paint on.

paintOriginPoint

protected void paintOriginPoint(java.awt.geom.Point2D originPnt,
                                java.awt.Graphics graphics,
                                MapBean theMap)
Paints the origin point of the range rings on the given Graphics.

Parameters:
originPnt - the origin point
graphics - The Graphics to paint on.

paintOriginLabel

protected void paintOriginLabel(java.awt.geom.Point2D originPnt,
                                java.awt.Graphics graphics,
                                MapBean theMap)
Paints the origin label of the range rings on the given Graphics.

Parameters:
originPnt - the origin point
graphics - The Graphics to paint on.

paintRangeRings

protected void paintRangeRings(java.awt.geom.Point2D originPnt,
                               java.awt.geom.Point2D dest,
                               java.awt.Graphics graphics,
                               MapBean theMap)
Paints the circles and their labels on the given Graphics.

Parameters:
originPnt - the origin location
dest - the location of the inner ring.
graphics - The Graphics to paint on.

paintCircle

protected void paintCircle(Geo originGeo,
                           double distance,
                           java.awt.Graphics graphics,
                           MapBean theMap)
Paints a unique circle centered on origin and which crosses dest on the given Graphics.

Parameters:
originGeo - the origin location
distance - the distance of the circle from the origin, in radians
graphics - The Graphics to paint on.

paintLabel

protected void paintLabel(Geo originGeo,
                          double distance,
                          java.awt.Graphics graphics,
                          MapBean theMap)
Paints a label for the circle drawn using dest on the given Graphics.

Parameters:
originGeo - the Geo for the origin location
distance - the distance of circle in radians.
graphics - The Graphics to paint in.

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(double distance)
Returns the String to be used as a labeler for the circle drawn using dest.

Parameters:
distance - The distance from the origin for the label, in radians.
Returns:
label String.

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)
Set properties for this mouse mode

Specified by:
setProperties in interface PropertyConsumer
Overrides:
setProperties in class CoordMouseMode
Parameters:
prefix - property prefix that should be prepended to property keys.
props - the properties containing key-values.

getProperties

public java.util.Properties getProperties(java.util.Properties props)
Get the current Properties for this mouse mode.

Specified by:
getProperties in interface PropertyConsumer
Overrides:
getProperties in class CoordMouseMode
Parameters:
props - The Properties object to add props to. A Properties object will be created if null.
Returns:
props

getPropertyInfo

public java.util.Properties getPropertyInfo(java.util.Properties list)
Return property info metadata for this PropertyConsumer.

Specified by:
getPropertyInfo in interface PropertyConsumer
Overrides:
getPropertyInfo in class CoordMouseMode
Parameters:
list - Properties to add to, may be null.
Returns:
Properties for this object.


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