Java Annotation API cleaner #1716
This commit is contained in:
@@ -7,7 +7,7 @@ public abstract class Annotation {
|
||||
|
||||
/**
|
||||
* The annotation id
|
||||
* <p/>
|
||||
*
|
||||
* Internal C++ id is stored as unsigned int.
|
||||
*/
|
||||
protected Long id; // null unless added to a MapView
|
||||
@@ -19,6 +19,10 @@ public abstract class Annotation {
|
||||
|
||||
public Annotation() {}
|
||||
|
||||
public float getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -32,6 +36,10 @@ public abstract class Annotation {
|
||||
mapView.removeAnnotation(this);
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -44,4 +52,13 @@ public abstract class Annotation {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
// TODO: Implement getZIndex of Google Maps Android API
|
||||
// public float getZIndex() {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement setZIndex of Google Maps Android API
|
||||
// public void setZIndex(float zIndex) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
public abstract class AnnotationOptions {
|
||||
|
||||
protected Annotation annotation;
|
||||
|
||||
public AnnotationOptions() {}
|
||||
|
||||
public AnnotationOptions alpha(float alpha) {
|
||||
annotation.alpha = alpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return annotation.alpha;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return annotation.visible;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
public class CircleOptions {
|
||||
public class CircleOptions extends AnnotationOptions {
|
||||
|
||||
private Circle circle;
|
||||
|
||||
|
||||
@@ -5,11 +5,6 @@ import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
public class Marker extends Annotation {
|
||||
|
||||
/**
|
||||
* Member fields are without access qualifiers
|
||||
* so that they can be directly set by MarkerOptions
|
||||
* from within the module.
|
||||
*/
|
||||
float anchorU;
|
||||
float anchorV;
|
||||
boolean draggable;
|
||||
@@ -36,6 +31,14 @@ public class Marker extends Annotation {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public float getAnchorU() {
|
||||
return anchorU;
|
||||
}
|
||||
|
||||
public float getAnchorV() {
|
||||
return anchorV;
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: Google Maps Android API uses String for IDs.
|
||||
*
|
||||
@@ -63,9 +66,6 @@ public class Marker extends Annotation {
|
||||
return title;
|
||||
}
|
||||
|
||||
// Method in Google Maps Android API
|
||||
// public int hashCode()
|
||||
|
||||
public void hideInfoWindow() {
|
||||
//TODO hideInfoWindow
|
||||
infoWindowShown = false;
|
||||
@@ -83,8 +83,9 @@ public class Marker extends Annotation {
|
||||
return infoWindowShown;
|
||||
}
|
||||
|
||||
void setAlpha(float alpha) {
|
||||
this.alpha = alpha;
|
||||
void setAnchor(float u, float v) {
|
||||
this.anchorU = u;
|
||||
this.anchorV = v;
|
||||
}
|
||||
|
||||
void setDraggable(boolean draggable) {
|
||||
@@ -95,11 +96,6 @@ public class Marker extends Annotation {
|
||||
this.flat = flat;
|
||||
}
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
// void setIcon(BitmapDescriptor icon) {
|
||||
//
|
||||
// }
|
||||
|
||||
void setInfoWindowAnchor(float u, float v) {
|
||||
infoWindowAnchorU = u;
|
||||
infoWindowAnchorV = v;
|
||||
@@ -124,4 +120,13 @@ public class Marker extends Annotation {
|
||||
void showInfoWindow() {
|
||||
infoWindowShown = true;
|
||||
}
|
||||
|
||||
|
||||
// TODO Method in Google Maps Android API
|
||||
// public int hashCode()
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
// void setIcon(BitmapDescriptor icon) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -2,49 +2,34 @@ package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
/**
|
||||
* Created by Nicholas Hallahan on 7/13/15.
|
||||
* nick@theoutpost.io
|
||||
*/
|
||||
public class MarkerOptions {
|
||||
|
||||
private Marker marker;
|
||||
public class MarkerOptions extends AnnotationOptions {
|
||||
|
||||
public MarkerOptions() {
|
||||
marker = new Marker();
|
||||
}
|
||||
|
||||
public MarkerOptions alpha(float alpha) {
|
||||
marker.alpha = alpha;
|
||||
return this;
|
||||
annotation = new Marker();
|
||||
}
|
||||
|
||||
public MarkerOptions anchor(float u, float v) {
|
||||
marker.anchorU = u;
|
||||
marker.anchorV = v;
|
||||
((Marker)annotation).anchorU = u;
|
||||
((Marker)annotation).anchorV = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions draggable(boolean draggable) {
|
||||
marker.draggable = draggable;
|
||||
((Marker)annotation).draggable = draggable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions flat(boolean flat) {
|
||||
marker.flat = flat;
|
||||
((Marker)annotation).flat = flat;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return marker.alpha;
|
||||
}
|
||||
|
||||
public float getAnchorU() {
|
||||
return marker.anchorU;
|
||||
return ((Marker)annotation).anchorU;
|
||||
}
|
||||
|
||||
public float getAnchorV() {
|
||||
return marker.anchorV;
|
||||
return ((Marker)annotation).anchorV;
|
||||
}
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
@@ -53,81 +38,82 @@ public class MarkerOptions {
|
||||
// }
|
||||
|
||||
public float getInfoWindowAnchorU() {
|
||||
return marker.infoWindowAnchorU;
|
||||
return ((Marker)annotation).infoWindowAnchorU;
|
||||
}
|
||||
|
||||
public float getInfoWindowAnchorV() {
|
||||
return marker.infoWindowAnchorV;
|
||||
return ((Marker)annotation).infoWindowAnchorV;
|
||||
}
|
||||
|
||||
public Marker getMarker() {
|
||||
return marker;
|
||||
return (Marker)annotation;
|
||||
}
|
||||
|
||||
public LatLng getPosition() {
|
||||
return marker.position;
|
||||
return ((Marker)annotation).position;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return marker.rotation;
|
||||
return ((Marker)annotation).rotation;
|
||||
}
|
||||
|
||||
public String getSnippet() {
|
||||
return marker.snippet;
|
||||
return ((Marker)annotation).snippet;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return marker.title;
|
||||
return ((Marker)annotation).title;
|
||||
}
|
||||
|
||||
public MarkerOptions infoWindowAnchor(float u, float v) {
|
||||
((Marker)annotation).infoWindowAnchorU = u;
|
||||
((Marker)annotation).infoWindowAnchorV = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return ((Marker)annotation).draggable;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return ((Marker)annotation).flat;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return ((Marker)annotation).visible;
|
||||
}
|
||||
|
||||
public MarkerOptions position(LatLng position) {
|
||||
((Marker)annotation).position = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions rotation(float rotation) {
|
||||
((Marker)annotation).rotation = rotation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions snippet(String snippet) {
|
||||
((Marker)annotation).snippet = snippet;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions title(String title) {
|
||||
((Marker)annotation).title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions visible(boolean visible) {
|
||||
annotation.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
// public MarkerOptions icon(BitmapDescriptor icon) {
|
||||
//
|
||||
// }
|
||||
|
||||
public MarkerOptions infoWindowAnchor(float u, float v) {
|
||||
marker.infoWindowAnchorU = u;
|
||||
marker.infoWindowAnchorV = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return marker.draggable;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return marker.flat;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return marker.visible;
|
||||
}
|
||||
|
||||
public MarkerOptions position(LatLng position) {
|
||||
marker.position = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions rotation(float rotation) {
|
||||
marker.rotation = rotation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions snippet(String snippet) {
|
||||
marker.snippet = snippet;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions title(String title) {
|
||||
marker.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions visible(boolean visible) {
|
||||
marker.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
// public void writeToParcel (Parcel out, int flags)
|
||||
|
||||
|
||||
@@ -14,14 +14,26 @@ public abstract class MultiPoint extends Annotation {
|
||||
points = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the points.
|
||||
*
|
||||
* @return points - as a copy
|
||||
*/
|
||||
public List<LatLng> getPoints() {
|
||||
return points;
|
||||
return new ArrayList<>(points);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the points of this polyline. This method will take a copy
|
||||
* of the points, so further mutations to points will have no effect
|
||||
* on this polyline.
|
||||
*
|
||||
* @param points
|
||||
*/
|
||||
void setPoints(List<LatLng> points) {
|
||||
this.points = new ArrayList<>(points);
|
||||
}
|
||||
|
||||
// TODO: Implement getZIndex of Google Maps Android API
|
||||
// public float getZIndex() {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement hashCode of Google Maps Android API
|
||||
// public int hashCode() {
|
||||
@@ -33,18 +45,9 @@ public abstract class MultiPoint extends Annotation {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Sets the points of this polyline. This method will take a copy
|
||||
* of the points, so further mutations to points will have no effect
|
||||
* on this polyline.
|
||||
*
|
||||
* @param points
|
||||
*/
|
||||
void setPoints(List<LatLng> points) {
|
||||
this.points = new ArrayList<>();
|
||||
for (LatLng latLng : points) {
|
||||
this.points.add(latLng);
|
||||
}
|
||||
}
|
||||
// TODO: Implement setGeodesic of Google Maps Android API
|
||||
// public void setGeodesic(boolean geodesic) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MultiPointOptions extends AnnotationOptions {
|
||||
|
||||
public MultiPointOptions() {}
|
||||
|
||||
public List<LatLng> getPoints() {
|
||||
// the getter gives us a copy, which is the safe thing to do...
|
||||
return ((MultiPoint)annotation).getPoints();
|
||||
}
|
||||
}
|
||||
@@ -22,11 +22,6 @@ public class Polygon extends MultiPoint {
|
||||
holes = new ArrayList<>();
|
||||
}
|
||||
|
||||
// TODO: Implement equals of Google Maps Android API
|
||||
// public boolean equals (Object other) {
|
||||
//
|
||||
// }
|
||||
|
||||
public int getFillColor() {
|
||||
return fillColor;
|
||||
}
|
||||
@@ -43,16 +38,6 @@ public class Polygon extends MultiPoint {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
// TODO: Implement getZIndex of Google Maps Android API
|
||||
// public float getZIndex() {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement hashCode of Google Maps Android API
|
||||
// public int hashCode () {
|
||||
//
|
||||
// }
|
||||
|
||||
public void setFillAlpha(float alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
@@ -63,18 +48,14 @@ public class Polygon extends MultiPoint {
|
||||
|
||||
/**
|
||||
* Sets the holes of this polygon. This method will take a copy of the holes,
|
||||
* so further mutations to holes will have no effect on this polygon.
|
||||
* so further mutations to holes parameter will have no effect on this polygon.
|
||||
*
|
||||
* @param holes
|
||||
*/
|
||||
public void setHoles(List<? extends List<LatLng>> holes) {
|
||||
this.holes = new ArrayList<>();
|
||||
for (List<LatLng> hole : holes) {
|
||||
List<LatLng> newHole = new ArrayList<>();
|
||||
this.holes.add(newHole);
|
||||
for (LatLng latLng : hole) {
|
||||
newHole.add(latLng);
|
||||
}
|
||||
this.holes.add(new ArrayList<>(hole));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +74,14 @@ public class Polygon extends MultiPoint {
|
||||
strokeWidth = width;
|
||||
}
|
||||
|
||||
// TODO: Implement setZIndex of Google Maps Android API
|
||||
// public void setZIndex(float zIndex) {
|
||||
|
||||
// TODO: Implement equals of Google Maps Android API
|
||||
// public boolean equals (Object other) {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement hashCode of Google Maps Android API
|
||||
// public int hashCode () {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -6,16 +6,14 @@ import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PolygonOptions {
|
||||
|
||||
private Polygon polygon;
|
||||
public class PolygonOptions extends MultiPointOptions {
|
||||
|
||||
public PolygonOptions() {
|
||||
polygon = new Polygon();
|
||||
annotation = new Polygon();
|
||||
}
|
||||
|
||||
public PolygonOptions add(LatLng point) {
|
||||
polygon.points.add(point);
|
||||
((MultiPoint)annotation).points.add(point);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -38,47 +36,47 @@ public class PolygonOptions {
|
||||
for (LatLng point : points) {
|
||||
hole.add(point);
|
||||
}
|
||||
polygon.holes.add(hole);
|
||||
((Polygon)annotation).holes.add(hole);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolygonOptions fillColor(int color) {
|
||||
polygon.fillColor = color;
|
||||
((Polygon)annotation).fillColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getFillColor() {
|
||||
return polygon.fillColor;
|
||||
return ((Polygon)annotation).fillColor;
|
||||
}
|
||||
|
||||
public List<List<LatLng>> getHoles() {
|
||||
return polygon.holes;
|
||||
return ((Polygon)annotation).holes;
|
||||
}
|
||||
|
||||
public Polygon getPolygon() {
|
||||
return polygon;
|
||||
return ((Polygon)annotation);
|
||||
}
|
||||
|
||||
public int getStrokeColor() {
|
||||
return polygon.strokeColor;
|
||||
return ((Polygon)annotation).strokeColor;
|
||||
}
|
||||
|
||||
public float getStrokeWidth() {
|
||||
return polygon.strokeWidth;
|
||||
return ((Polygon)annotation).strokeWidth;
|
||||
}
|
||||
|
||||
// TODO: Implement getZIndex of Google Maps Android API
|
||||
// public float getZIndex() {
|
||||
//
|
||||
// }
|
||||
|
||||
public PolygonOptions strokeColor(int color) {
|
||||
polygon.strokeColor = color;
|
||||
((Polygon)annotation).strokeColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolygonOptions strokeWidth(float width) {
|
||||
polygon.strokeWidth = width;
|
||||
((Polygon)annotation).strokeWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolygonOptions visible(boolean visible) {
|
||||
annotation.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -87,9 +85,4 @@ public class PolygonOptions {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement zIndex of Google Maps Android API
|
||||
// public PolygonOptions zIndex(float zIndex) {
|
||||
//
|
||||
// return this;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -15,11 +15,6 @@ public class Polyline extends MultiPoint {
|
||||
super();
|
||||
}
|
||||
|
||||
// TODO: Implement equals of Google Maps Android API
|
||||
// public boolean equals(Object other) {
|
||||
//
|
||||
// }
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
@@ -38,10 +33,6 @@ public class Polyline extends MultiPoint {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
// TODO: Implement setGeodesic of Google Maps Android API
|
||||
// public void setGeodesic(boolean geodesic) {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Sets the width of the polyline.
|
||||
@@ -53,9 +44,8 @@ public class Polyline extends MultiPoint {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
// TODO: Implement setZIndex of Google Maps Android API
|
||||
// public void setZIndex(float zIndex) {
|
||||
// TODO: Implement equals of Google Maps Android API
|
||||
// public boolean equals(Object other) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -4,21 +4,14 @@ import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PolylineOptions {
|
||||
|
||||
private Polyline polyline;
|
||||
public class PolylineOptions extends MultiPointOptions {
|
||||
|
||||
public PolylineOptions() {
|
||||
polyline = new Polyline();
|
||||
}
|
||||
|
||||
public PolylineOptions alpha(float alpha) {
|
||||
polyline.alpha = alpha;
|
||||
return this;
|
||||
annotation = new Polyline();
|
||||
}
|
||||
|
||||
public PolylineOptions add(LatLng point) {
|
||||
polyline.points.add(point);
|
||||
((MultiPoint)annotation).points.add(point);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -37,47 +30,24 @@ public class PolylineOptions {
|
||||
}
|
||||
|
||||
public PolylineOptions color(int color) {
|
||||
polyline.color = color;
|
||||
((Polyline)annotation).color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Implement geodesic of Google Maps Android API
|
||||
// public PolylineOptions geodesic (boolean geodesic) {
|
||||
//
|
||||
// }
|
||||
|
||||
public int getColor() {
|
||||
return polyline.color;
|
||||
}
|
||||
|
||||
public List<LatLng> getPoints() {
|
||||
return polyline.points;
|
||||
return ((Polyline)annotation).color;
|
||||
}
|
||||
|
||||
public Polyline getPolyline() {
|
||||
return polyline;
|
||||
return ((Polyline)annotation);
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return polyline.width;
|
||||
}
|
||||
|
||||
// TODO: Implement getZIndex of Google Maps Android API
|
||||
// public float getZIndex() {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement isGeodesic of Google Maps Android API
|
||||
// public boolean isGeodesic() {
|
||||
//
|
||||
// }
|
||||
|
||||
public boolean isVisible() {
|
||||
return polyline.visible;
|
||||
return ((Polyline)annotation).width;
|
||||
}
|
||||
|
||||
public PolylineOptions visible(boolean visible) {
|
||||
polyline.visible = visible;
|
||||
annotation.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -88,19 +58,13 @@ public class PolylineOptions {
|
||||
* @return
|
||||
*/
|
||||
public PolylineOptions width(float width) {
|
||||
polyline.width = width;
|
||||
((Polyline)annotation).width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Implement writeToParcel of Google Maps Android API
|
||||
// public void writeToParcel(Parcel out, int flags) {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement zIndex of Google Maps Android API
|
||||
// public PolylineOptions zIndex(float zIndex) {
|
||||
//
|
||||
// return this;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user