Class DrawSnapHelper
- java.lang.Object
-
- org.openstreetmap.josm.actions.mapmode.DrawSnapHelper
-
class DrawSnapHelper extends java.lang.Object
Class that enables the user to draw way segments in angles of exactly 30, 45, 60, 90 degrees. With enabled snapping, the new way node will be projected onto the helper line that indicates a certain fixed angle relative to the previous segment.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DrawSnapHelper.AnglePopupMenu
private static class
DrawSnapHelper.DisableAction
private static class
DrawSnapHelper.HelperAction
private static class
DrawSnapHelper.ProjectionAction
private static class
DrawSnapHelper.RepeatedAction
private static class
DrawSnapHelper.Snap30DegreesAction
private static class
DrawSnapHelper.Snap45DegreesAction
private static class
DrawSnapHelper.Snap90DegreesAction
-
Field Summary
Fields Modifier and Type Field Description private boolean
absoluteFix
private boolean
active
(package private) java.awt.event.MouseListener
anglePopupListener
private javax.swing.JCheckBoxMenuItem
checkBox
private double
customBaseHeading
(package private) EastNorth
dir2
private static java.lang.String
DRAW_ANGLESNAP_ANGLES
private DrawAction
drawAction
private double
e0
private boolean
fixed
private java.lang.String
fixFmt
private java.lang.String
labelText
private double
lastAngle
private double
n0
private double
pe
private double
pn
private EastNorth
projected
private EastNorth
projectionSource
private EastNorth
segmentPoint1
private EastNorth
segmentPoint2
private double[]
snapAngles
private boolean
snapOn
-
Constructor Summary
Constructors Constructor Description DrawSnapHelper(DrawAction drawAction)
Constructs a newSnapHelper
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
buildLabelText(double nearestAngle)
void
checkAngleSnapping(EastNorth currentEN, double baseHeading, double curHeading)
If mouse position is close to line at 15-30-45-...private void
computeSnapAngles()
void
drawIfNeeded(java.awt.Graphics2D g2, MapViewState mv)
Draw the snap hint line.(package private) void
enableSnapping()
Enable snapping.private static double
getAngleDelta(double a, double b)
private double
getNearestAngle(double angle)
EastNorth
getSnapPoint(EastNorth p)
Gets a snap point close to p.void
init()
Set the initial state(package private) boolean
isActive()
(package private) boolean
isSnapOn()
(package private) void
noSnapNow()
Disables snappingprivate static double
parseSnapAngle(java.lang.String string)
void
saveAngles(java.lang.String... angles)
Save the snap angles(package private) void
setBaseSegment(WaySegment seg)
(package private) void
setFixedMode()
void
setMenuCheckBox(javax.swing.JCheckBoxMenuItem checkBox)
Sets the menu checkbox.(package private) void
toggleSnapping()
(package private) void
unFixOrTurnOff()
(package private) void
unsetFixedMode()
-
-
-
Field Detail
-
drawAction
private final DrawAction drawAction
-
DRAW_ANGLESNAP_ANGLES
private static final java.lang.String DRAW_ANGLESNAP_ANGLES
- See Also:
- Constant Field Values
-
snapOn
private boolean snapOn
-
active
private boolean active
-
fixed
private boolean fixed
-
absoluteFix
private boolean absoluteFix
-
labelText
private java.lang.String labelText
-
lastAngle
private double lastAngle
-
customBaseHeading
private double customBaseHeading
-
segmentPoint1
private EastNorth segmentPoint1
-
segmentPoint2
private EastNorth segmentPoint2
-
projectionSource
private EastNorth projectionSource
-
snapAngles
private double[] snapAngles
-
pe
private double pe
-
pn
private double pn
-
e0
private double e0
-
n0
private double n0
-
fixFmt
private final java.lang.String fixFmt
-
checkBox
private javax.swing.JCheckBoxMenuItem checkBox
-
anglePopupListener
final java.awt.event.MouseListener anglePopupListener
-
-
Constructor Detail
-
DrawSnapHelper
DrawSnapHelper(DrawAction drawAction)
Constructs a newSnapHelper
.- Parameters:
drawAction
- enclosing DrawAction
-
-
Method Detail
-
init
public void init()
Set the initial state
-
computeSnapAngles
private void computeSnapAngles()
-
parseSnapAngle
private static double parseSnapAngle(java.lang.String string)
-
saveAngles
public void saveAngles(java.lang.String... angles)
Save the snap angles- Parameters:
angles
- The angles
-
setMenuCheckBox
public void setMenuCheckBox(javax.swing.JCheckBoxMenuItem checkBox)
Sets the menu checkbox.- Parameters:
checkBox
- menu checkbox
-
drawIfNeeded
public void drawIfNeeded(java.awt.Graphics2D g2, MapViewState mv)
Draw the snap hint line.- Parameters:
g2
- graphicsmv
- MapView state- Since:
- 10874
-
checkAngleSnapping
public void checkAngleSnapping(EastNorth currentEN, double baseHeading, double curHeading)
If mouse position is close to line at 15-30-45-... angle, remembers this direction- Parameters:
currentEN
- Current positionbaseHeading
- The headingcurHeading
- The current mouse heading
-
buildLabelText
private void buildLabelText(double nearestAngle)
-
getSnapPoint
public EastNorth getSnapPoint(EastNorth p)
Gets a snap point close to p. Stores the result for display.- Parameters:
p
- The point- Returns:
- The snap point close to p.
-
noSnapNow
void noSnapNow()
Disables snapping
-
setBaseSegment
void setBaseSegment(WaySegment seg)
-
enableSnapping
void enableSnapping()
Enable snapping.
-
toggleSnapping
void toggleSnapping()
-
setFixedMode
void setFixedMode()
-
unsetFixedMode
void unsetFixedMode()
-
isActive
boolean isActive()
-
isSnapOn
boolean isSnapOn()
-
getNearestAngle
private double getNearestAngle(double angle)
-
getAngleDelta
private static double getAngleDelta(double a, double b)
-
unFixOrTurnOff
void unFixOrTurnOff()
-
-