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
ACircle
consists of a centerLatLong
and a non-negative radius in meters. ACircle
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 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 boolean
contains(org.mapsforge.core.model.Point center, org.mapsforge.core.model.Point point, double latitude, byte zoomLevel)
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.org.mapsforge.core.graphics.Paint
getPaintFill()
org.mapsforge.core.graphics.Paint
getPaintStroke()
org.mapsforge.core.model.LatLong
getPosition()
Gets the geographic position of this layer element, if it exists.float
getRadius()
protected int
getRadiusInPixels(double latitude, byte zoomLevel)
boolean
isKeepAligned()
void
setLatLong(org.mapsforge.core.model.LatLong latLong)
void
setPaintFill(org.mapsforge.core.graphics.Paint paintFill)
void
setPaintStroke(org.mapsforge.core.graphics.Paint paintStroke)
void
setRadius(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 initialPaint
used to fill this circle (may be null).paintStroke
- the initialPaint
used to stroke this circle (may be null).- Throws:
java.lang.IllegalArgumentException
- if the givenradius
is 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 initialPaint
used to fill this circle (may be null).paintStroke
- the initialPaint
used 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 givenradius
is 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: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.
-
getPaintFill
public org.mapsforge.core.graphics.Paint getPaintFill()
- Returns:
- the
Paint
used to fill this circle (may be null).
-
getPaintStroke
public org.mapsforge.core.graphics.Paint getPaintStroke()
- Returns:
- the
Paint
used to stroke this circle (may be null).
-
getPosition
public org.mapsforge.core.model.LatLong getPosition()
Description copied from class:Layer
Gets the geographic position of this layer element, if it exists. The default implementation of this method returns null.- Overrides:
getPosition
in 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 newPaint
used to fill this circle (may be null).
-
setPaintStroke
public void setPaintStroke(org.mapsforge.core.graphics.Paint paintStroke)
- Parameters:
paintStroke
- the newPaint
used 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 givenradius
is negative orFloat.NaN
.
-
-