Code example for ShapeDrawable

Methods: getShape, setShape

0
    public int getMultiplicity() { 
		return multiplicity;
	} 
 
    public void setShape(Shape shape) {
        drawable.setShape(shape);
    } 
 
    public ShapeDrawable getDrawable() {
        return drawable;
    } 
 
    public void updateShape(RasterParameters rasterParameters, Projection projection, int color, int textColor, int zoomLevel) {
        Shape shape = drawable.getShape();
        if (rasterParameters != null) {
            if (shape == null) {
                shape = new RasterShape();
                drawable.setShape(shape);
            } 
            RasterShape rasterShape = (RasterShape)shape;
 
            float lon_delta = rasterParameters.getLongitudeDelta() / 2.0f * 1e6f;
            float lat_delta = rasterParameters.getLatitudeDelta() / 2.0f * 1e6f;
            GeoPoint geoPoint = getPoint();
            projection.toPixels(geoPoint, center);
            projection.toPixels(new GeoPoint(
                    (int) (geoPoint.getLatitudeE6() + lat_delta),
                    (int) (geoPoint.getLongitudeE6() - lon_delta)), topLeft);
            projection.toPixels(new GeoPoint(
                    (int) (geoPoint.getLatitudeE6() - lat_delta),
                    (int) (geoPoint.getLongitudeE6() + lon_delta)), bottomRight);
            topLeft.offset(-center.x, -center.y);
            bottomRight.offset(-center.x, -center.y);
            rasterShape.update(topLeft, bottomRight, color, getMultiplicity(), textColor);
        } else { 
            if (shape == null) {
                shape = new StrokeShape();
                drawable.setShape(shape);
            } 
            StrokeShape strokeShape = (StrokeShape) shape;
            strokeShape.update(zoomLevel + 1, color);
 
        }