Class OnLineStrategy
java.lang.Object
org.openstreetmap.josm.gui.mappaint.styleelement.placement.OnLineStrategy
- All Implemented Interfaces:
PositionForAreaStrategy
Places the label onto the line.
- Since:
- 11722, 11748 moved to own file
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classRotate the glyphs along a path.private static classA half segment that can be used to place text on it.private static classprivate static classA visitor that computes the side of the way that is the upper one for each segment and computes the dominant upper side of the way. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final OnLineStrategyAn instance of this class.private final double -
Constructor Summary
ConstructorsConstructorDescriptionOnLineStrategy(double yOffset) Create a new strategy that places the text on the line. -
Method Summary
Modifier and TypeMethodDescriptionprivate static List<OnLineStrategy.OffsetGlyph>computeOffsetGlyphs(List<GlyphVector> gvs, double startOffset, boolean rotateText) Create a list of glyphs with an offset along the wayprivate static doublebooleanfindLabelPlacement(MapViewPath path, Rectangle2D nb) Finds the correct position of a label / icon inside the area.private static Optional<OnLineStrategy.HalfSegment>findOptimalWayPosition(Rectangle2D rect, MapViewPath path) generateGlyphVectors(MapViewPath path, Rectangle2D nb, List<GlyphVector> gvs, boolean isDoubleTranslationBug) Generates the transformed glyph vectors for the given text.inthashCode()booleanChecks whether this placement strategy supports more detailed (rotation / ...) placement using a glyph vector.private static doubletheta(MapViewState.MapViewPoint start, MapViewState.MapViewPoint end) toString()private static doublewithAddedOffset(Point2D addToOffset) Create a new instance of the same strategy adding a offset
-
Field Details
-
INSTANCE
An instance of this class. -
yOffset
-
-
Constructor Details
-
OnLineStrategy
Create a new strategy that places the text on the line.- Parameters:
yOffset- The offset sidewards to the line.
-
-
Method Details
-
findLabelPlacement
Description copied from interface:PositionForAreaStrategyFinds the correct position of a label / icon inside the area.- Specified by:
findLabelPlacementin interfacePositionForAreaStrategy- Parameters:
path- The area to search innb- The bounding box of the thing we are searching a place for.- Returns:
- The position as rectangle with the same dimension as nb.
nullif none was found.
-
upsideTheta
-
supportsGlyphVector
Description copied from interface:PositionForAreaStrategyChecks whether this placement strategy supports more detailed (rotation / ...) placement using a glyph vector.- Specified by:
supportsGlyphVectorin interfacePositionForAreaStrategy- Returns:
trueif it is supported.
-
generateGlyphVectors
public List<GlyphVector> generateGlyphVectors(MapViewPath path, Rectangle2D nb, List<GlyphVector> gvs, boolean isDoubleTranslationBug) Description copied from interface:PositionForAreaStrategyGenerates the transformed glyph vectors for the given text.- Specified by:
generateGlyphVectorsin interfacePositionForAreaStrategy- Parameters:
path- The path to place the text alongnb- The bounds of the textgvs- The glyph vectors for the text. May be modifiedisDoubleTranslationBug-trueto fix a glyph placement bug.- Returns:
- The glyph vectors.
-
computeOffsetGlyphs
private static List<OnLineStrategy.OffsetGlyph> computeOffsetGlyphs(List<GlyphVector> gvs, double startOffset, boolean rotateText) Create a list of glyphs with an offset along the way- Parameters:
gvs- The list of glyphsstartOffset- The offset in the linerotateText- Rotate the text by 180°- Returns:
- The list of glyphs.
-
findOptimalWayPosition
private static Optional<OnLineStrategy.HalfSegment> findOptimalWayPosition(Rectangle2D rect, MapViewPath path) -
computeQuality
-
theta
-
withAddedOffset
Description copied from interface:PositionForAreaStrategyCreate a new instance of the same strategy adding a offset- Specified by:
withAddedOffsetin interfacePositionForAreaStrategy- Parameters:
addToOffset- The offset to add- Returns:
- The new strategy
-
toString
-
hashCode
-
equals
-