Class Circle

  • Direct Known Subclasses:
    FixedPixelCircle

    public class Circle
    extends Layer
    A Circle consists of a center LatLong and a non-negative radius in meters.

    A Circle holds two Paint objects to allow for different outline and filling. These paints define drawing parameters such as color, stroke width, pattern and transparency.

    • 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)  
    • 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 initial Paint used to fill this circle (may be null).
        paintStroke - the initial Paint used to stroke this circle (may be null).
        Throws:
        java.lang.IllegalArgumentException - if the given radius is negative or Float.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 initial Paint used to fill this circle (may be null).
        paintStroke - the initial Paint 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 given radius is negative or Float.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 this Layer on the given canvas.
        Specified by:
        draw in class Layer
        Parameters:
        boundingBox - the geographical area which should be drawn.
        zoomLevel - the zoom level at which this Layer should draw itself.
        canvas - the canvas on which this Layer 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 class Layer
        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 new Paint used to fill this circle (may be null).
      • setPaintStroke

        public void setPaintStroke​(org.mapsforge.core.graphics.Paint paintStroke)
        Parameters:
        paintStroke - the new Paint 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 given radius is negative or Float.NaN.