Package org.mapsforge.map.layer.overlay
Class Polygon
- java.lang.Object
-
- org.mapsforge.map.layer.Layer
-
- org.mapsforge.map.layer.overlay.Polygon
-
public class Polygon extends Layer
APolygon
draws a closed connected series of line segments specified by a list ofLatLongs
. If the first and the lastLatLong
are not equal, thePolygon
will be closed automatically. APolygon
holds twoPaint
objects to allow for different outline and filling. These paints define drawing parameters such as color, stroke width, pattern and transparency.
-
-
Field Summary
-
Fields inherited from class org.mapsforge.map.layer.Layer
displayModel
-
-
Constructor Summary
Constructors Constructor Description Polygon(org.mapsforge.core.graphics.Paint paintFill, org.mapsforge.core.graphics.Paint paintStroke, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
Polygon(org.mapsforge.core.graphics.Paint paintFill, org.mapsforge.core.graphics.Paint paintStroke, org.mapsforge.core.graphics.GraphicFactory graphicFactory, boolean keepAligned)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPoint(org.mapsforge.core.model.LatLong point)
void
addPoints(java.util.List<org.mapsforge.core.model.LatLong> points)
void
clear()
boolean
contains(org.mapsforge.core.model.LatLong tapLatLong)
void
draw(org.mapsforge.core.model.BoundingBox boundingBox, byte zoomLevel, org.mapsforge.core.graphics.Canvas canvas, org.mapsforge.core.model.Point topLeftPoint)
Draws thisLayer
on the given canvas.java.util.List<org.mapsforge.core.model.LatLong>
getLatLongs()
org.mapsforge.core.graphics.Paint
getPaintFill()
org.mapsforge.core.graphics.Paint
getPaintStroke()
boolean
isKeepAligned()
void
setPaintFill(org.mapsforge.core.graphics.Paint paintFill)
void
setPaintStroke(org.mapsforge.core.graphics.Paint paintStroke)
void
setPoints(java.util.List<org.mapsforge.core.model.LatLong> points)
-
Methods inherited from class org.mapsforge.map.layer.Layer
getDisplayModel, getPosition, isVisible, onAdd, onDestroy, onLongPress, onRemove, onScroll, onTap, requestRedraw, setDisplayModel, setVisible, setVisible
-
-
-
-
Constructor Detail
-
Polygon
public Polygon(org.mapsforge.core.graphics.Paint paintFill, org.mapsforge.core.graphics.Paint paintStroke, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
- Parameters:
paintFill
- the initialPaint
used to fill this polygon (may be null).paintStroke
- the initialPaint
used to stroke this polygon (may be null).graphicFactory
- the GraphicFactory
-
Polygon
public Polygon(org.mapsforge.core.graphics.Paint paintFill, org.mapsforge.core.graphics.Paint paintStroke, org.mapsforge.core.graphics.GraphicFactory graphicFactory, boolean keepAligned)
- Parameters:
paintFill
- the initialPaint
used to fill this polygon (may be null).paintStroke
- the initialPaint
used to stroke this polygon (may be null).graphicFactory
- the GraphicFactorykeepAligned
- if set to true it will keep the bitmap aligned with the map, to avoid a moving effect of a bitmap shader.
-
-
Method Detail
-
addPoint
public void addPoint(org.mapsforge.core.model.LatLong point)
-
addPoints
public void addPoints(java.util.List<org.mapsforge.core.model.LatLong> points)
-
clear
public void clear()
-
contains
public boolean contains(org.mapsforge.core.model.LatLong tapLatLong)
-
draw
public void draw(org.mapsforge.core.model.BoundingBox boundingBox, byte zoomLevel, org.mapsforge.core.graphics.Canvas canvas, org.mapsforge.core.model.Point topLeftPoint)
Description copied from class:Layer
Draws thisLayer
on the given canvas.- Specified by:
draw
in classLayer
- Parameters:
boundingBox
- the geographical area which should be drawn.zoomLevel
- the zoom level at which thisLayer
should draw itself.canvas
- the canvas on which thisLayer
should draw itself.topLeftPoint
- the top-left pixel position of the canvas relative to the top-left map position.
-
getLatLongs
public java.util.List<org.mapsforge.core.model.LatLong> getLatLongs()
- Returns:
- a thread-safe list of LatLongs in this polygon.
-
getPaintFill
public org.mapsforge.core.graphics.Paint getPaintFill()
- Returns:
- the
Paint
used to fill this polygon (may be null).
-
getPaintStroke
public org.mapsforge.core.graphics.Paint getPaintStroke()
- Returns:
- the
Paint
used to stroke this polygon (may be null).
-
isKeepAligned
public boolean isKeepAligned()
- Returns:
- true if it keeps the bitmap aligned with the map, to avoid a moving effect of a bitmap shader, false otherwise.
-
setPaintFill
public void setPaintFill(org.mapsforge.core.graphics.Paint paintFill)
- Parameters:
paintFill
- the newPaint
used to fill this polygon (may be null).
-
setPaintStroke
public void setPaintStroke(org.mapsforge.core.graphics.Paint paintStroke)
- Parameters:
paintStroke
- the newPaint
used to stroke this polygon (may be null).
-
setPoints
public void setPoints(java.util.List<org.mapsforge.core.model.LatLong> points)
-
-