public class DistanceMouseMode extends CoordMouseMode
To use this mouse mode in the OpenMap demo (in setWidgets): create the mouse mode, such as
DistanceMouseMode distMode = new DistanceMouseMode(true, id, DistanceMouseMode.DISTANCE_ALL);
Add the distance mouse mode to the mouse delegator md.addMouseMode(distMode);
This class can easily be extended, for example to create waypoints for objects.
NOTE: If some lines are not properly erased (because the mouse went outside the map for example), just use the redraw from the menu.
You can set the units used for measurements by setting the property:
prefix.units= < name for Length.java (km, miles, meters, nm, all) >Note that "all" will display nm, km, and miles.
AbstractMouseMode.MouseWheelTimerListener
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AllUnitsPropertyValue
Special units value for displaying all units ...
|
java.text.DecimalFormat |
df |
double |
distance
Distance of the current segment
|
int |
lineType
The line type to be displayed, see OMGraphic.
|
static java.lang.String |
modeID
Mouse mode identifier, is "Distance".
|
boolean |
mousePressed
Flag, true if the mouse has already been pressed
|
static java.lang.String |
RepaintToCleanProperty |
java.awt.geom.Point2D |
rPoint1
rPoint1 is the anchor point of a line segment
|
java.awt.geom.Point2D |
rPoint2
rPoint2 is the new (current) point of a line segment
|
java.util.Vector<java.awt.geom.Point2D> |
segments
Vector to store all distance segments, first point and last point pairs
|
static java.lang.String |
ShowAngleProperty |
static java.lang.String |
ShowCircleProperty |
protected MapBean |
theMap |
double |
totalDistance
The cumulative distance from the first mouse click
|
static java.lang.String |
UnitProperty |
coordFormatter, coordFormatterHandler, CoordFormatterProperty, infoDelegator
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
i18n, propertyPrefix
beanContextChildSupport, isolated
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
Constructor and Description |
---|
DistanceMouseMode()
Construct a DistanceMouseMode.
|
DistanceMouseMode(boolean consumeEvents)
Construct a DistanceMouseMode.
|
DistanceMouseMode(boolean consumeEvents,
InformationDelegator id)
Construct a DistanceMouseMode.
|
DistanceMouseMode(boolean consumeEvents,
InformationDelegator id,
Length units)
Construct a DistanceMouseMode.
|
DistanceMouseMode(boolean consumeEvents,
InformationDelegator id,
Length units,
int lType)
Construct a DistanceMouseMode.
|
DistanceMouseMode(java.lang.String name,
boolean consumeEvents)
Construct an DistanceMouseMode.
|
DistanceMouseMode(java.lang.String name,
boolean consumeEvents,
InformationDelegator id)
Construct a DistanceMouseMode.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanUp()
Reset the segments and distances
|
protected java.lang.String |
createDistanceInformationLine(java.awt.geom.Point2D llp,
double distance,
double azimuth) |
void |
eraseCircle()
Erase the current segment circle.
|
void |
eraseLines()
Erase all line segments.
|
double |
getGreatCircleDist(double phi1,
double lambda0,
double phi,
double lambda,
int units)
Return the distance in the chosen unit between two points (in decimal
degrees).
|
int |
getLineType()
Return the line type either LINETYPE_GREATCIRCLE, LINETYPE_RHUMB,
LINETYPE_STRAIGHT
|
MapBean |
getMapBean()
Return the map bean.
|
java.util.Properties |
getProperties(java.util.Properties getList)
PropertyConsumer interface method.
|
java.util.Properties |
getPropertyInfo(java.util.Properties list)
PropertyConsumer interface method.
|
boolean |
getRepaintToClean() |
boolean |
getShowAzimuth()
Whether the display of the azimuth angle on or off.
|
boolean |
getShowCircle()
Get whether the drawing of the rubberband circle on/off.
|
double |
getSphericalAzimuth(double phi1,
double lambda0,
double phi,
double lambda)
Return the azimuth angle in decimal degrees from north.
|
double |
getTotalDistance() |
Length |
getUnit()
Return the unit of distance being displayed: Length.NM, Length.KM or
Length.MILE.
|
boolean |
isDisplayCircle() |
boolean |
isShowAngle() |
void |
listenerPaint(java.awt.Graphics g)
Called by the MapBean when it repaints, to let the MouseMode know when to
update itself on the map.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Process a mouseClicked event.
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Process a mouseEntered event.
|
void |
mouseExited(java.awt.event.MouseEvent e)
Process a mouseExited event.
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Draw a rubberband line and circle as the mouse is moved.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Process a mouse pressed event.
|
void |
paintCircle(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2)
Draw a rubberband circle between two points
|
void |
paintCircle(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2,
java.awt.Graphics graphics)
Draw a rubberband circle between two points
|
void |
paintLine(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2)
Draw a rubberband line between two points
|
void |
paintLine(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2,
java.awt.Graphics graphics)
Draw a rubberband line between two points into the Graphics object.
|
void |
paintRubberband(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2)
Draw a rubberband line and circle between two points
|
void |
paintRubberband(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2,
java.awt.Graphics g)
Draw a rubberband line and circle between two points
|
void |
setDisplayCircle(boolean displayCircle) |
void |
setLineType(int lype)
Set the line type to be drawn see also OMGraphic
|
void |
setMapBean(MapBean aMap)
Set the map bean.
|
void |
setProperties(java.lang.String prefix,
java.util.Properties setList)
PropertyConsumer interface method.
|
void |
setRepaintToClean(boolean rtc) |
void |
setShowAngle(boolean showAngle) |
void |
setTotalDistance(double totalDistance) |
void |
setUnit(Length units)
Set the unit of distance to be displayed: Length.NM, Length.KM or
Length.MILE.
|
void |
showAzimuth(boolean onOff)
Switch the display of the azimuth angle on or off.
|
void |
showCircle(boolean onOff)
Set the drawing of the rubberband circle on/off.
|
findAndInit, findAndUndo, fireMouseLocation, getCoordFormatter, getCoordFormatterHandler, getInfoDelegator, mouseDragged, propertyChange, setActive, setCoordFormatter, setCoordFormatterHandler, setInfoDelegator
actAsProxyFor, actAsProxyFor, addMapMouseListener, addPropertyChangeListener, getClassToUseForIconRetrieval, getGUIIcon, getIconName, getID, getModeCursor, getMouseSupport, getMouseWheelTimerInterval, getNoMouseWheelListener, getPrettyName, getProxied, getProxyDistributionMask, isConsumeEvents, isMouseWheelListener, isNoMouseWheelListenerTimer, isProxyFor, isVisible, isZoomWhenMouseWheelUp, mouseReleased, mouseWheelMoved, releaseProxy, removeAllMapMouseListeners, removeMapMouseListener, removePropertyChangeListener, setConsumeEvents, setGUIIcon, setIconName, setID, setModeCursor, setModeCursor, setMouseSupport, setMouseWheelListener, setMouseWheelTimerInterval, setNoMouseWheelListener, setNoMouseWheelListenerTimer, setPrettyName, setProxyDistributionMask, setVisible, setZoomWhenMouseWheelUp, updateMouseWheelMoved
getPropertyPrefix, setProperties, setPropertyPrefix
addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, firePropertyChange, fireVetoableChange, getBeanContext, isIsolated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, setIsolated
public static final transient java.lang.String modeID
public static final java.lang.String UnitProperty
public static final java.lang.String ShowCircleProperty
public static final java.lang.String ShowAngleProperty
public static final java.lang.String RepaintToCleanProperty
public transient java.text.DecimalFormat df
public static final java.lang.String AllUnitsPropertyValue
public java.awt.geom.Point2D rPoint1
public java.awt.geom.Point2D rPoint2
public boolean mousePressed
public java.util.Vector<java.awt.geom.Point2D> segments
public double distance
public double totalDistance
public int lineType
protected transient MapBean theMap
public DistanceMouseMode()
public DistanceMouseMode(boolean consumeEvents)
consumeEvents
- the mode setting.public DistanceMouseMode(java.lang.String name, boolean consumeEvents)
name
- the ID of the mode.consumeEvents
- if true, events are propagated to the first
MapMouseListener that successfully processes the event, if false,
events are propagated to all MapMouseListeners. You need to
setInfoDelegator, setUnit and setLineType if you use this
constructor.public DistanceMouseMode(boolean consumeEvents, InformationDelegator id, Length units)
consumeEvents
- the mode setting.id
- the calling object's info delegator.units
- the unit of distance that will be displayed, such as
Length.NM, Length.KM or Length.MILE. If null, display all of them.public DistanceMouseMode(boolean consumeEvents, InformationDelegator id, Length units, int lType)
consumeEvents
- the mode setting.id
- the calling object's info delegator.units
- the unit of distance that will be displayed, such as
Length.NM, Length.KM or Length.MILE. If null, display all of them.lType
- the line type that will be displayed such as
LINETYPE_GREATCIRCLE, LINETYPE_RHUMB, LINETYPE_STRAIGHTpublic DistanceMouseMode(boolean consumeEvents, InformationDelegator id)
consumeEvents
- the mode setting.id
- the calling object's info delegator.public DistanceMouseMode(java.lang.String name, boolean consumeEvents, InformationDelegator id)
name
- the ID of the mode.consumeEvents
- the mode setting.id
- the calling object's info delegator.public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
mouseClicked
in class AbstractMouseMode
e
- mouse event.public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class AbstractMouseMode
e
- mouse event.public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
mouseMoved
in class CoordMouseMode
e
- mouse event.protected java.lang.String createDistanceInformationLine(java.awt.geom.Point2D llp, double distance, double azimuth)
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
mouseEntered
in class AbstractMouseMode
e
- mouse event.public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
mouseExited
in class AbstractMouseMode
e
- mouse event.public void paintLine(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
pt1
- the anchor point.pt2
- the current (mouse) position.public void paintLine(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2, java.awt.Graphics graphics)
pt1
- the anchor point.pt2
- the current (mouse) position.graphics
- a java.awt.Graphics object to render into.public void paintCircle(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
pt1
- the anchor point.pt2
- the current (mouse) position.public void paintCircle(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2, java.awt.Graphics graphics)
pt1
- the anchor point.pt2
- the current (mouse) position.graphics
- a java.awt.Graphics object to render into.public void paintRubberband(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
pt1
- the anchor point.pt2
- the current (mouse) position.public void paintRubberband(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2, java.awt.Graphics g)
pt1
- the anchor point.pt2
- the current (mouse) position.g
- a java.awt.Graphics object to render into.public void eraseLines()
public void eraseCircle()
public void cleanUp()
public double getGreatCircleDist(double phi1, double lambda0, double phi, double lambda, int units)
phi1
- latitude in decimal degrees of start pointlambda0
- longitude in decimal degrees of start pointphi
- latitude in decimal degrees of end pointlambda
- longitude in decimal degrees of end pointunits
- the unit of distance, DISTANCE_NM, DISTANCE_KM,
DISTANCE_MILE or all 3 types DISTANCE_ALLpublic double getSphericalAzimuth(double phi1, double lambda0, double phi, double lambda)
phi1
- latitude in decimal degrees of start pointlambda0
- longitude in decimal degrees of start pointphi
- latitude in decimal degrees of end pointlambda
- longitude in decimal degrees of end pointpublic void setMapBean(MapBean aMap)
aMap
- a map beanpublic MapBean getMapBean()
public void setUnit(Length units)
public Length getUnit()
public void showAzimuth(boolean onOff)
onOff
- true to display the azimuth angle, false to turn offpublic boolean getShowAzimuth()
public void setLineType(int lype)
lype
- either LINETYPE_GREATCIRCLE, LINETYPE_RHUMB,
LINETYPE_STRAIGHTpublic int getLineType()
public void showCircle(boolean onOff)
onOff
- true or falsepublic boolean getShowCircle()
public void setRepaintToClean(boolean rtc)
public boolean getRepaintToClean()
public void setProperties(java.lang.String prefix, java.util.Properties setList)
setProperties
in interface PropertyConsumer
setProperties
in class CoordMouseMode
prefix
- the token to prefix the property namessetList
- the Properties
objectpublic java.util.Properties getProperties(java.util.Properties getList)
getProperties
in interface PropertyConsumer
getProperties
in class CoordMouseMode
getList
- a Properties object to load the PropertyConsumer properties
into. If props equals null, then a new Properties object should be
created.public java.util.Properties getPropertyInfo(java.util.Properties list)
getPropertyInfo
in interface PropertyConsumer
getPropertyInfo
in class CoordMouseMode
list
- a Properties object to load the PropertyConsumer properties
into. If getList equals null, then a new Properties object should
be created.public void listenerPaint(java.awt.Graphics g)
listenerPaint
in interface PaintListener
listenerPaint
in class AbstractMouseMode
public boolean isDisplayCircle()
public void setDisplayCircle(boolean displayCircle)
public boolean isShowAngle()
public void setShowAngle(boolean showAngle)
public double getTotalDistance()
public void setTotalDistance(double totalDistance)
Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details