Package org.mapsforge.map.layer.overlay
Class Circle
- java.lang.Object
-
- org.mapsforge.map.layer.Layer
-
- org.mapsforge.map.layer.overlay.Circle
-
- Direct Known Subclasses:
FixedPixelCircle
public class Circle extends Layer
ACircleconsists of a centerLatLongand a non-negative radius in meters. ACircleholds twoPaintobjects 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 Circle(org.mapsforge.core.model.LatLong latLong, float radius, org.mapsforge.core.graphics.Paint paintFill, org.mapsforge.core.graphics.Paint paintStroke)Circle(org.mapsforge.core.model.LatLong latLong, float radius, org.mapsforge.core.graphics.Paint paintFill, org.mapsforge.core.graphics.Paint paintStroke, boolean keepAligned)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(org.mapsforge.core.model.Point center, org.mapsforge.core.model.Point point, double latitude, byte zoomLevel)voiddraw(org.mapsforge.core.model.BoundingBox boundingBox, byte zoomLevel, org.mapsforge.core.graphics.Canvas canvas, org.mapsforge.core.model.Point topLeftPoint)Draws thisLayeron the given canvas.org.mapsforge.core.graphics.PaintgetPaintFill()org.mapsforge.core.graphics.PaintgetPaintStroke()org.mapsforge.core.model.LatLonggetPosition()Gets the geographic position of this layer element, if it exists.floatgetRadius()protected intgetRadiusInPixels(double latitude, byte zoomLevel)booleanisKeepAligned()voidsetLatLong(org.mapsforge.core.model.LatLong latLong)voidsetPaintFill(org.mapsforge.core.graphics.Paint paintFill)voidsetPaintStroke(org.mapsforge.core.graphics.Paint paintStroke)voidsetRadius(float radius)-
Methods inherited from class org.mapsforge.map.layer.Layer
getDisplayModel, isVisible, onAdd, onDestroy, onLongPress, onRemove, onScroll, onTap, requestRedraw, setDisplayModel, setVisible, setVisible
-
-
-
-
Constructor Detail
-
Circle
public Circle(org.mapsforge.core.model.LatLong latLong, float radius, org.mapsforge.core.graphics.Paint paintFill, org.mapsforge.core.graphics.Paint paintStroke)- Parameters:
latLong- the initial center point of this circle (may be null).radius- the initial non-negative radius of this circle in meters.paintFill- the initialPaintused to fill this circle (may be null).paintStroke- the initialPaintused to stroke this circle (may be null).- Throws:
java.lang.IllegalArgumentException- if the givenradiusis negative orFloat.NaN.
-
Circle
public Circle(org.mapsforge.core.model.LatLong latLong, float radius, org.mapsforge.core.graphics.Paint paintFill, org.mapsforge.core.graphics.Paint paintStroke, boolean keepAligned)- Parameters:
latLong- the initial center point of this circle (may be null).radius- the initial non-negative radius of this circle in meters.paintFill- the initialPaintused to fill this circle (may be null).paintStroke- the initialPaintused to stroke this circle (may be null).keepAligned- if set to true it will keep the bitmap aligned with the map, to avoid a moving effect of a bitmap shader.- Throws:
java.lang.IllegalArgumentException- if the givenradiusis negative orFloat.NaN.
-
-
Method Detail
-
contains
public boolean contains(org.mapsforge.core.model.Point center, org.mapsforge.core.model.Point point, double latitude, byte zoomLevel)
-
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:LayerDraws thisLayeron the given canvas.- Specified by:
drawin classLayer- Parameters:
boundingBox- the geographical area which should be drawn.zoomLevel- the zoom level at which thisLayershould draw itself.canvas- the canvas on which thisLayershould draw itself.topLeftPoint- the top-left pixel position of the canvas relative to the top-left map position.
-
getPaintFill
public org.mapsforge.core.graphics.Paint getPaintFill()
- Returns:
- the
Paintused to fill this circle (may be null).
-
getPaintStroke
public org.mapsforge.core.graphics.Paint getPaintStroke()
- Returns:
- the
Paintused to stroke this circle (may be null).
-
getPosition
public org.mapsforge.core.model.LatLong getPosition()
Description copied from class:LayerGets the geographic position of this layer element, if it exists. The default implementation of this method returns null.- Overrides:
getPositionin classLayer- Returns:
- the center point of this circle (may be null).
-
getRadius
public float getRadius()
- Returns:
- the non-negative radius of this circle in meters.
-
getRadiusInPixels
protected int getRadiusInPixels(double latitude, byte zoomLevel)- Returns:
- the non-negative radius of this circle in pixels.
-
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.
-
setLatLong
public void setLatLong(org.mapsforge.core.model.LatLong latLong)
- Parameters:
latLong- the new center point of this circle (may be null).
-
setPaintFill
public void setPaintFill(org.mapsforge.core.graphics.Paint paintFill)
- Parameters:
paintFill- the newPaintused to fill this circle (may be null).
-
setPaintStroke
public void setPaintStroke(org.mapsforge.core.graphics.Paint paintStroke)
- Parameters:
paintStroke- the newPaintused to stroke this circle (may be null).
-
setRadius
public void setRadius(float radius)
- Parameters:
radius- the new non-negative radius of this circle in meters.- Throws:
java.lang.IllegalArgumentException- if the givenradiusis negative orFloat.NaN.
-
-