[android] javadoc - inter-link style properties properly

This commit is contained in:
Ivo van Dongen
2016-10-04 14:26:04 +02:00
committed by Ivo van Dongen
parent 93166aef48
commit dd7713f6ee
19 changed files with 473 additions and 90 deletions

View File

@@ -9,7 +9,9 @@ import android.support.annotation.NonNull;
import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
/**
* Background Layer
* The background color or pattern of the map.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-background">The online documentation</a>
*/
public class BackgroundLayer extends Layer {

View File

@@ -9,7 +9,9 @@ import android.support.annotation.NonNull;
import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
/**
* Circle Layer
* A filled circle.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-circle">The online documentation</a>
*/
public class CircleLayer extends Layer {

View File

@@ -9,7 +9,9 @@ import android.support.annotation.NonNull;
import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
/**
* Fill Layer
* A filled polygon with an optional stroked border.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-fill">The online documentation</a>
*/
public class FillLayer extends Layer {

View File

@@ -1,16 +1,18 @@
package com.mapbox.mapboxsdk.style.layers;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
/**
* Utility to build filter expressions more easily:
* Utility to build filter expressions more easily.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-filter">Style spec</a>
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-filter">The online documentation</a>
*/
public class Filter {
/**
* Base {@link Filter} statement. Subclassed to provide concrete statements.
*/
public abstract static class Statement {
protected final String operator;
@@ -18,13 +20,26 @@ public class Filter {
this.operator = operator;
}
/**
* Generate a raw array representation of the filter
*
* @return the filter represented as an array
*/
public abstract Object[] toArray();
}
/**
* Represents a {@link Filter} statement. Can be unary (eg `has()`, etc) or take any number of values.
*/
public static class SimpleStatement extends Statement {
private final String key;
private final Object[] values;
/**
* @param operator the operator (eg `=`, etc)
* @param key the property key
* @param values the values to operate on, if any
*/
public SimpleStatement(String operator, String key, Object... values) {
super(operator);
this.key = key;
@@ -32,6 +47,9 @@ public class Filter {
}
/**
* {@inheritDoc}
*/
@Override
public Object[] toArray() {
ArrayList<Object> array = new ArrayList<>(2 + values.length);
@@ -42,14 +60,24 @@ public class Filter {
}
}
/**
* Represents a collection of {@link Statement}s with an operator that describes their relationship
*/
public static class CompoundStatement extends Statement {
private final Statement[] statements;
/**
* @param operator the relationship operator
* @param statements the statements to compound
*/
public CompoundStatement(String operator, Statement... statements) {
super(operator);
this.statements = statements;
}
/**
* {@inheritDoc}
*/
@Override
public Object[] toArray() {
ArrayList<Object> array = new ArrayList<>(1 + statements.length);
@@ -61,54 +89,140 @@ public class Filter {
}
}
/**
* Groups a collection of statements in an 'all' relationship
*
* @param statements the collection of statements
* @return the statements compounded
*/
public static Statement all(Statement... statements) {
return new CompoundStatement("all", statements);
}
/**
* Groups a collection of statements in an 'any' relationship
*
* @param statements the collection of statements
* @return the statements compounded
*/
public static Statement any(Statement... statements) {
return new CompoundStatement("any", statements);
}
/**
* Groups a collection of statements in an 'none' relationship
*
* @param statements the collection of statements
* @return the statements compounded
*/
public static Statement none(Statement... statements) {
return new CompoundStatement("none", statements);
}
/**
* Check the property's existence
*
* @param key the property key
* @return the statement
*/
public static Statement has(String key) {
return new SimpleStatement("has", key);
}
/**
* Check the property's existence, negated
*
* @param key the property key
* @return the statement
*/
public static Statement notHas(String key) {
return new SimpleStatement("!has", key);
}
/**
* Check the property equals the given value
*
* @param key the property key
* @param value the value to check against
* @return the statement
*/
public static Statement eq(String key, Object value) {
return new SimpleStatement("==", key, value);
}
/**
* Check the property does not equals the given value
*
* @param key the property key
* @param value the value to check against
* @return the statement
*/
public static Statement neq(String key, Object value) {
return new SimpleStatement("!=", key, value);
}
/**
* Check the property exceeds the given value
*
* @param key the property key
* @param value the value to check against
* @return the statement
*/
public static Statement gt(String key, Object value) {
return new SimpleStatement(">", key, value);
}
/**
* Check the property exceeds or equals the given value
*
* @param key the property key
* @param value the value to check against
* @return the statement
*/
public static Statement gte(String key, Object value) {
return new SimpleStatement(">=", key, value);
}
/**
* Check the property does not exceeds the given value
*
* @param key the property key
* @param value the value to check against
* @return the statement
*/
public static Statement lt(String key, Object value) {
return new SimpleStatement("<", key, value);
}
/**
* Check the property equals or does not exceeds the given value
*
* @param key the property key
* @param value the value to check against
* @return the statement
*/
public static Statement lte(String key, Object value) {
return new SimpleStatement("<=", key, value);
}
/**
* Check the property is within the given set
*
* @param key the property key
* @param values the set of values to check against
* @return the statement
*/
public static Statement in(String key, Object... values) {
return new SimpleStatement("in", key, values);
}
/**
* Check the property is not within the given set
*
* @param key the property key
* @param values the set of values to check against
* @return the statement
*/
public static Statement notIn(String key, Object... values) {
return new SimpleStatement("!in", key, values);
}

View File

@@ -9,12 +9,22 @@ import java.util.HashMap;
import java.util.Map;
/**
* Representation of <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">Function</a> in the Mapbox style specification
* Functions are used to change properties in relation to the state of the map.
* <p>
* Currently, only zoom functions are supported.
* </p>
*
* @param <T> the target property's value type. Make sure it matches.
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The online documentation</a>
*/
public class Function<T> {
/**
* A stop represents a certain point in the range of this function
*
* @param <I> input
* @param <O> output
*/
public static class Stop<I, O> {
public final I in;
public final O out;
@@ -24,6 +34,9 @@ public class Function<T> {
this.out = out;
}
/**
* @return an array representation of the Stop
*/
Object[] toValueObject() {
return new Object[]{in, out};
}
@@ -34,11 +47,31 @@ public class Function<T> {
}
}
/**
* Zoom functions allow the appearance of a map feature to change with map’s zoom.
* Zoom functions can be used to create the illusion of depth and control data density.
* Each stop is an array with two elements, the first is a zoom and the second is a function output value.
*
* @param stops the stops that define the function
* @param <T> the property type
* @return the {@link Function}
*/
@SafeVarargs
public static <T> Function<T> zoom(@NonNull @Size(min = 1) Stop<Float, T>... stops) {
return new Function<T>(stops);
}
/**
* Zoom functions allow the appearance of a map feature to change with map’s zoom.
* Zoom functions can be used to create the illusion of depth and control data density.
* Each stop is an array with two elements, the first is a zoom and the second is a function output value.
*
* @param stops the stops that define the function
* @param base the exponential base of the interpolation curve - Default 1
* @param <T> the property type
* @return the {@link Function}
*/
@SafeVarargs
public static <T> Function<T> zoom(
@FloatRange(from = 0, to = 1, fromInclusive = false, toInclusive = false) float base,
@@ -47,6 +80,14 @@ public class Function<T> {
.withBase(base);
}
/**
* Creates a stop to use in a {@link Function}
*
* @param in the input for the stop
* @param output the output for the stop
* @param <T> the output property type
* @return the {@link Stop}
*/
public static <T> Stop<Float, T> stop(float in, Property<T> output) {
return new Stop<>(in, output.value);
}
@@ -63,11 +104,17 @@ public class Function<T> {
return this;
}
/**
* @return the base
*/
@Nullable
public Float getBase() {
return base;
}
/**
* @return the stops in this function
*/
public Stop<Float, T>[] getStops() {
return stops;
}

View File

@@ -9,7 +9,9 @@ import android.support.annotation.NonNull;
import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
/**
* Line Layer
* A stroked line.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-line">The online documentation</a>
*/
public class LineLayer extends Layer {

View File

@@ -44,6 +44,9 @@ public abstract class Property<T> {
*/
public static final String LINE_CAP_SQUARE = "square";
/**
* The display of line endings.
*/
@StringDef({
LINE_CAP_BUTT,
LINE_CAP_ROUND,
@@ -67,6 +70,9 @@ public abstract class Property<T> {
*/
public static final String LINE_JOIN_MITER = "miter";
/**
* The display of lines when joining.
*/
@StringDef({
LINE_JOIN_BEVEL,
LINE_JOIN_ROUND,
@@ -82,10 +88,13 @@ public abstract class Property<T> {
*/
public static final String SYMBOL_PLACEMENT_POINT = "point";
/**
* The label is placed along the line of the geometry. Can only be used on `LineString` and `Polygon` geometries.
* The label is placed along the line of the geometry. Can only be used on LineString and Polygon geometries.
*/
public static final String SYMBOL_PLACEMENT_LINE = "line";
/**
* Label placement relative to its geometry.
*/
@StringDef({
SYMBOL_PLACEMENT_POINT,
SYMBOL_PLACEMENT_LINE,
@@ -96,18 +105,21 @@ public abstract class Property<T> {
//ICON_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of icons.
/**
* When `symbol-placement` is set to `point`, aligns icons east-west. When `symbol-placement` is set to `line`, aligns icon x-axes with the line.
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns icons east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns icon x-axes with the line.
*/
public static final String ICON_ROTATION_ALIGNMENT_MAP = "map";
/**
* Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`.
* Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of {@link SYMBOL_PLACEMENT}.
*/
public static final String ICON_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
/**
* When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line`, this is equivalent to `map`.
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_MAP}.
*/
public static final String ICON_ROTATION_ALIGNMENT_AUTO = "auto";
/**
* In combination with `symbol-placement`, determines the rotation behavior of icons.
*/
@StringDef({
ICON_ROTATION_ALIGNMENT_MAP,
ICON_ROTATION_ALIGNMENT_VIEWPORT,
@@ -135,6 +147,9 @@ public abstract class Property<T> {
*/
public static final String ICON_TEXT_FIT_BOTH = "both";
/**
* Scales the icon to fit around the associated text.
*/
@StringDef({
ICON_TEXT_FIT_NONE,
ICON_TEXT_FIT_WIDTH,
@@ -155,10 +170,13 @@ public abstract class Property<T> {
*/
public static final String TEXT_PITCH_ALIGNMENT_VIEWPORT = "viewport";
/**
* Automatically matches the value of `text-rotation-alignment`.
* Automatically matches the value of {@link TEXT_ROTATION_ALIGNMENT}.
*/
public static final String TEXT_PITCH_ALIGNMENT_AUTO = "auto";
/**
* Orientation of text when map is pitched.
*/
@StringDef({
TEXT_PITCH_ALIGNMENT_MAP,
TEXT_PITCH_ALIGNMENT_VIEWPORT,
@@ -170,18 +188,21 @@ public abstract class Property<T> {
//TEXT_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text.
/**
* When `symbol-placement` is set to `point`, aligns text east-west. When `symbol-placement` is set to `line`, aligns text x-axes with the line.
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns text east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns text x-axes with the line.
*/
public static final String TEXT_ROTATION_ALIGNMENT_MAP = "map";
/**
* Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`.
* Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of {@link SYMBOL_PLACEMENT}.
*/
public static final String TEXT_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
/**
* When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line`, this is equivalent to `map`.
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_MAP}.
*/
public static final String TEXT_ROTATION_ALIGNMENT_AUTO = "auto";
/**
* In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text.
*/
@StringDef({
TEXT_ROTATION_ALIGNMENT_MAP,
TEXT_ROTATION_ALIGNMENT_VIEWPORT,
@@ -205,6 +226,9 @@ public abstract class Property<T> {
*/
public static final String TEXT_JUSTIFY_RIGHT = "right";
/**
* Text justification options.
*/
@StringDef({
TEXT_JUSTIFY_LEFT,
TEXT_JUSTIFY_CENTER,
@@ -252,6 +276,9 @@ public abstract class Property<T> {
*/
public static final String TEXT_ANCHOR_BOTTOM_RIGHT = "bottom-right";
/**
* Part of the text placed closest to the anchor.
*/
@StringDef({
TEXT_ANCHOR_CENTER,
TEXT_ANCHOR_LEFT,
@@ -281,6 +308,9 @@ public abstract class Property<T> {
*/
public static final String TEXT_TRANSFORM_LOWERCASE = "lowercase";
/**
* Specifies how to capitalize text, similar to the CSS `text-transform` property.
*/
@StringDef({
TEXT_TRANSFORM_NONE,
TEXT_TRANSFORM_UPPERCASE,
@@ -300,6 +330,9 @@ public abstract class Property<T> {
*/
public static final String FILL_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
/**
* Controls the translation reference point.
*/
@StringDef({
FILL_TRANSLATE_ANCHOR_MAP,
FILL_TRANSLATE_ANCHOR_VIEWPORT,
@@ -318,6 +351,9 @@ public abstract class Property<T> {
*/
public static final String LINE_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
/**
* Controls the translation reference point.
*/
@StringDef({
LINE_TRANSLATE_ANCHOR_MAP,
LINE_TRANSLATE_ANCHOR_VIEWPORT,
@@ -336,6 +372,9 @@ public abstract class Property<T> {
*/
public static final String ICON_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
/**
* Controls the translation reference point.
*/
@StringDef({
ICON_TRANSLATE_ANCHOR_MAP,
ICON_TRANSLATE_ANCHOR_VIEWPORT,
@@ -354,6 +393,9 @@ public abstract class Property<T> {
*/
public static final String TEXT_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
/**
* Controls the translation reference point.
*/
@StringDef({
TEXT_TRANSLATE_ANCHOR_MAP,
TEXT_TRANSLATE_ANCHOR_VIEWPORT,
@@ -372,6 +414,9 @@ public abstract class Property<T> {
*/
public static final String CIRCLE_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
/**
* Controls the translation reference point.
*/
@StringDef({
CIRCLE_TRANSLATE_ANCHOR_MAP,
CIRCLE_TRANSLATE_ANCHOR_VIEWPORT,
@@ -390,6 +435,9 @@ public abstract class Property<T> {
*/
public static final String CIRCLE_PITCH_SCALE_VIEWPORT = "viewport";
/**
* Controls the scaling behavior of the circle when the map is pitched.
*/
@StringDef({
CIRCLE_PITCH_SCALE_MAP,
CIRCLE_PITCH_SCALE_VIEWPORT,

View File

@@ -52,7 +52,7 @@ public class PropertyFactory {
}
/**
* The opacity of the entire fill layer. In contrast to the `fillColor`, this value will also affect the 1px stroke around the fill, if the stroke is used.
* The opacity of the entire fill layer. In contrast to the {@link PropertyFactory#fillColor}, this value will also affect the 1px stroke around the fill, if the stroke is used.
*
* @param value a Float value
* @return property wrapper around Float
@@ -62,7 +62,7 @@ public class PropertyFactory {
}
/**
* The opacity of the entire fill layer. In contrast to the `fillColor`, this value will also affect the 1px stroke around the fill, if the stroke is used.
* The opacity of the entire fill layer. In contrast to the {@link PropertyFactory#fillColor}, this value will also affect the 1px stroke around the fill, if the stroke is used.
*
* @param function a wrapper function for Float
* @return property wrapper around a Float function
@@ -102,7 +102,7 @@ public class PropertyFactory {
}
/**
* The outline color of the fill. Matches the value of `fillColor` if unspecified.
* The outline color of the fill. Matches the value of {@link PropertyFactory#fillColor} if unspecified.
*
* @param value a int color value
* @return property wrapper around String color
@@ -112,7 +112,7 @@ public class PropertyFactory {
}
/**
* The outline color of the fill. Matches the value of `fillColor` if unspecified.
* The outline color of the fill. Matches the value of {@link PropertyFactory#fillColor} if unspecified.
*
* @param value a String value
* @return property wrapper around String
@@ -122,7 +122,7 @@ public class PropertyFactory {
}
/**
* The outline color of the fill. Matches the value of `fillColor` if unspecified.
* The outline color of the fill. Matches the value of {@link PropertyFactory#fillColor} if unspecified.
*
* @param function a wrapper function for String
* @return property wrapper around a String function
@@ -1282,7 +1282,7 @@ public class PropertyFactory {
}
/**
* In combination with `symbolPlacement`, determines the rotation behavior of icons.
* In combination with {@link Property.SYMBOL_PLACEMENT}, determines the rotation behavior of icons.
*
* @param value a String value
* @return property wrapper around String
@@ -1292,7 +1292,7 @@ public class PropertyFactory {
}
/**
* In combination with `symbolPlacement`, determines the rotation behavior of icons.
* In combination with {@link Property.SYMBOL_PLACEMENT}, determines the rotation behavior of icons.
*
* @param function a wrapper function for String
* @return property wrapper around a String function
@@ -1342,7 +1342,7 @@ public class PropertyFactory {
}
/**
* Size of the additional area added to dimensions determined by `iconTextFit`, in clockwise order: top, right, bottom, left.
* Size of the additional area added to dimensions determined by {@link Property.ICON_TEXT_FIT}, in clockwise order: top, right, bottom, left.
*
* @param value a Float[] value
* @return property wrapper around Float[]
@@ -1352,7 +1352,7 @@ public class PropertyFactory {
}
/**
* Size of the additional area added to dimensions determined by `iconTextFit`, in clockwise order: top, right, bottom, left.
* Size of the additional area added to dimensions determined by {@link Property.ICON_TEXT_FIT}, in clockwise order: top, right, bottom, left.
*
* @param function a wrapper function for Float[]
* @return property wrapper around a Float[] function
@@ -1482,7 +1482,7 @@ public class PropertyFactory {
}
/**
* In combination with `symbolPlacement`, determines the rotation behavior of the individual glyphs forming the text.
* In combination with {@link Property.SYMBOL_PLACEMENT}, determines the rotation behavior of the individual glyphs forming the text.
*
* @param value a String value
* @return property wrapper around String
@@ -1492,7 +1492,7 @@ public class PropertyFactory {
}
/**
* In combination with `symbolPlacement`, determines the rotation behavior of the individual glyphs forming the text.
* In combination with {@link Property.SYMBOL_PLACEMENT}, determines the rotation behavior of the individual glyphs forming the text.
*
* @param function a wrapper function for String
* @return property wrapper around a String function
@@ -1742,7 +1742,7 @@ public class PropertyFactory {
}
/**
* Specifies how to capitalize text, similar to the CSS `text-transform` property.
* Specifies how to capitalize text, similar to the CSS {@link PropertyFactory#textTransform} property.
*
* @param value a String value
* @return property wrapper around String
@@ -1752,7 +1752,7 @@ public class PropertyFactory {
}
/**
* Specifies how to capitalize text, similar to the CSS `text-transform` property.
* Specifies how to capitalize text, similar to the CSS {@link PropertyFactory#textTransform} property.
*
* @param function a wrapper function for String
* @return property wrapper around a String function

View File

@@ -9,7 +9,9 @@ import android.support.annotation.NonNull;
import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
/**
* Raster Layer
* Raster map textures such as satellite imagery.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-raster">The online documentation</a>
*/
public class RasterLayer extends Layer {

View File

@@ -9,7 +9,9 @@ import android.support.annotation.NonNull;
import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
/**
* Symbol Layer
* An icon or a text label.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-symbol">The online documentation</a>
*/
public class SymbolLayer extends Layer {

View File

@@ -1,6 +1,7 @@
<%
const type = locals.type;
const properties = locals.properties;
const doc = locals.doc;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
@@ -13,7 +14,9 @@ import android.support.annotation.NonNull;
import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
/**
* <%- camelize(type) %> Layer
* <%- doc %>
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-<%- type %>">The online documentation</a>
*/
public class <%- camelize(type) %>Layer extends Layer {

View File

@@ -37,11 +37,14 @@ public abstract class Property<T> {
<% for (const value in property.values) { -%>
/**
* <%- property.values[value].doc %>
* <%- propertyValueDoc(property, value) %>
*/
public static final String <%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %> = "<%- value %>";
<% } -%>
/**
* <%- property.doc %>
*/
@StringDef({
<% for (const value of Object.keys(property.values)) { -%>
<%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %>,

View File

@@ -38,7 +38,7 @@ public class PropertyFactory {
<% for (const property of paintProperties) { -%>
<% if (property.type == 'color') { -%>
/**
* <%- propertyDoc(property.name, property) %>
* <%- propertyFactoryMethodDoc(property) %>
*
* @param value a int color value
* @return property wrapper around String color
@@ -49,7 +49,7 @@ public class PropertyFactory {
<% } -%>
/**
* <%- propertyDoc(property.name, property) %>
* <%- propertyFactoryMethodDoc(property) %>
*
* @param value a <%- propertyType(property) %> value
* @return property wrapper around <%- propertyType(property) %>
@@ -59,7 +59,7 @@ public class PropertyFactory {
}
/**
* <%- propertyDoc(property.name, property) %>
* <%- propertyFactoryMethodDoc(property) %>
*
* @param function a wrapper function for <%- propertyType(property) %>
* @return property wrapper around a <%- propertyType(property) %> function
@@ -71,7 +71,7 @@ public class PropertyFactory {
<% } -%>
<% for (const property of layoutProperties) { -%>
/**
* <%- propertyDoc(property.name, property) %>
* <%- propertyFactoryMethodDoc(property) %>
*
* @param value a <%- propertyType(property) %> value
* @return property wrapper around <%- propertyType(property) %>
@@ -81,7 +81,7 @@ public class PropertyFactory {
}
/**
* <%- propertyDoc(property.name, property) %>
* <%- propertyFactoryMethodDoc(property) %>
*
* @param function a wrapper function for <%- propertyType(property) %>
* @return property wrapper around a <%- propertyType(property) %> function

View File

@@ -3,13 +3,17 @@ package com.mapbox.mapboxsdk.style.sources;
import java.util.HashMap;
/**
* Options for the <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">GeoJsonSource</a>
* Options for the {@link GeoJsonSource}
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">The online documentation</a>
*/
public class GeoJsonOptions extends HashMap<String, Object> {
/**
* Defaults to 18.
* Maximum zoom level at which to create vector tiles (higher means greater detail at high zoom levels).
*
* @param maxZoom the maximum zoom - Defaults to 18.
* @return the current instance for chaining
*/
public GeoJsonOptions withMaxZoom(int maxZoom) {
this.put("maxzoom", maxZoom);
@@ -17,8 +21,10 @@ public class GeoJsonOptions extends HashMap<String, Object> {
}
/**
* Defaults to 128.
* Tile buffer size on each side (measured in 1/512ths of a tile; higher means fewer rendering artifacts near tile edges but slower performance).
*
* @param buffer the buffer size - Defaults to 128.
* @return the current instance for chaining
*/
public GeoJsonOptions withBuffer(int buffer) {
this.put("buffer", buffer);
@@ -26,8 +32,10 @@ public class GeoJsonOptions extends HashMap<String, Object> {
}
/**
* Defaults to 0.375.
* Douglas-Peucker simplification tolerance (higher means simpler geometries and faster performance).
*
* @param tolerance the tolerance - Defaults to 0.375
* @return the current instance for chaining
*/
public GeoJsonOptions withTolerance(float tolerance) {
this.put("tolerance", tolerance);
@@ -35,8 +43,10 @@ public class GeoJsonOptions extends HashMap<String, Object> {
}
/**
* Defaults to false.
* If the data is a collection of point features, setting this to true clusters the points by radius into groups.
*
* @param cluster cluster? - Defaults to false
* @return the current instance for chaining
*/
public GeoJsonOptions withCluster(boolean cluster) {
this.put("cluster", cluster);
@@ -44,8 +54,10 @@ public class GeoJsonOptions extends HashMap<String, Object> {
}
/**
* Defaults to 50.
* Radius of each cluster when clustering points, measured in 1/512ths of a tile.
* Max zoom to cluster points on.
*
* @param clusterMaxZoom clusterMaxZoom cluster maximum zoom - Defaults to one zoom less than maxzoom (so that last zoom features are not clustered)
* @return the current instance for chaining
*/
public GeoJsonOptions withClusterMaxZoom(int clusterMaxZoom) {
this.put("clusterMaxZoom", clusterMaxZoom);
@@ -53,7 +65,10 @@ public class GeoJsonOptions extends HashMap<String, Object> {
}
/**
* Max zoom to cluster points on. Defaults to one zoom less than maxzoom (so that last zoom features are not clustered).
* Radius of each cluster when clustering points, measured in 1/512ths of a tile.
*
* @param clusterRadius cluster radius - Defaults to 50
* @return the current instance for chaining
*/
public GeoJsonOptions withClusterRadius(int clusterRadius) {
this.put("clusterRadius", clusterRadius);

View File

@@ -8,7 +8,7 @@ import java.util.ArrayList;
import java.util.HashMap;
/**
* A GeoJson source.
* A GeoJson source. Exposes a {@link FeatureCollection} from Json.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">the style specification</a>
*/
@@ -16,6 +16,8 @@ public class GeoJsonSource extends Source {
/**
* Internal use
*
* @param nativePtr - pointer to native peer
*/
public GeoJsonSource(long nativePtr) {
super(nativePtr);
@@ -32,7 +34,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create an empty GeoJsonSource
* Create an empty GeoJsonSource with non-default {@link GeoJsonOptions}
*
* @param id the source id
* @param options options
@@ -46,7 +48,7 @@ public class GeoJsonSource extends Source {
* Create a GeoJsonSource from a raw json string
*
* @param id the source id
* @param geoJson raw Json body
* @param geoJson raw Json FeatureCollection
*/
public GeoJsonSource(String id, String geoJson) {
if (geoJson == null || geoJson.startsWith("http")) {
@@ -57,7 +59,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create a GeoJsonSource from a raw json string
* Create a GeoJsonSource from a raw json string and non-default {@link GeoJsonOptions}
*
* @param id the source id
* @param geoJson raw Json body
@@ -83,7 +85,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create a GeoJsonSource from a remote geo json file
* Create a GeoJsonSource from a remote geo json file and non-default {@link GeoJsonOptions}
*
* @param id the source id
* @param url remote json file
@@ -95,7 +97,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create a GeoJsonSource from a FeatureCollection
* Create a GeoJsonSource from a {@link FeatureCollection}
*
* @param id the source id
* @param features the features
@@ -106,7 +108,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create a GeoJsonSource from a FeatureCollection
* Create a GeoJsonSource from a {@link FeatureCollection} and non-default {@link GeoJsonOptions}
*
* @param id the source id
* @param features the features
@@ -117,21 +119,41 @@ public class GeoJsonSource extends Source {
setGeoJson(features);
}
/**
* Updates the GeoJson
*
* @param features the GeoJSON {@link FeatureCollection}
*/
public void setGeoJson(FeatureCollection features) {
checkValidity();
setGeoJson(features.toJson());
}
/**
* Updates the GeoJson
*
* @param json the raw GeoJson FeatureCollection string
*/
public void setGeoJson(String json) {
checkValidity();
setRawJson(json);
}
/**
* Updates the url
*
* @param url the GeoJSON FeatureCollection url
*/
public void setUrl(URL url) {
checkValidity();
setUrl(url.toExternalForm());
}
/**
* Updates the url
*
* @param url the GeoJSON FeatureCollection url
*/
public void setUrl(String url) {
checkValidity();
nativeSetUrl(url);

View File

@@ -3,36 +3,71 @@ package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
/**
* Construct a Raster Source.
* Raster Source enables the use of raster tiles.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-raster">The style specificition</a>
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-raster">The style specification</a>
*/
public class RasterSource extends Source {
public static final int DEFAULT_TILE_SIZE = 512;
/**
* Internal use
*
* @param nativePtr - pointer to native peer
*/
public RasterSource(long nativePtr) {
super(nativePtr);
}
/**
* Create the raster source from an URL
*
* @param id the source id
* @param url the source url
*/
public RasterSource(String id, URL url) {
this(id, url.toExternalForm());
}
/**
* Create the raster source from an URL
*
* @param id the source id
* @param url the source url
*/
public RasterSource(String id, String url) {
initialize(id, url, DEFAULT_TILE_SIZE);
}
/**
* Create the raster source from an URL with a specific tile size
*
* @param id the source id
* @param url the source url
* @param tileSize the tile size
*/
public RasterSource(String id, String url, int tileSize) {
initialize(id, url, tileSize);
}
/**
* Create the raster source from a {@link TileSet}
*
* @param id the source id
* @param tileSet the {@link TileSet}
*/
public RasterSource(String id, TileSet tileSet) {
initialize(id, tileSet.toValueObject(), DEFAULT_TILE_SIZE);
}
/**
* Create the raster source from a {@link TileSet} with a specific tile size
*
* @param id the source id
* @param tileSet the {@link TileSet}
* @param tileSize tje tile size
*/
public RasterSource(String id, TileSet tileSet, int tileSize) {
initialize(id, tileSet.toValueObject(), tileSize);
}

View File

@@ -1,7 +1,5 @@
package com.mapbox.mapboxsdk.style.sources;
import java.util.HashMap;
/**
* Base Peer class for sources. see source.hpp for the other half of the peer.
*/
@@ -9,6 +7,11 @@ public abstract class Source {
private long nativePtr;
private boolean invalidated;
/**
* Internal use
*
* @param nativePtr - pointer to native peer
*/
public Source(long nativePtr) {
this.nativePtr = nativePtr;
}
@@ -16,11 +19,21 @@ public abstract class Source {
public Source() {
}
/**
* Retrieve the source id
*
* @return the source id
*/
public String getId() {
checkValidity();
return nativeGetId();
}
/**
* Internal use
*
* @return the native peer pointer
*/
public long getNativePtr() {
return nativePtr;
}
@@ -33,6 +46,9 @@ public abstract class Source {
}
}
/**
* Internal use - invalidates the source for further use (after adding it to the map)
*/
public final void invalidate() {
this.invalidated = true;
}

View File

@@ -3,7 +3,7 @@ package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
/**
* A vector source.
* Vector source enables the use of vector tiles.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-vector">the style specification</a>
*/
@@ -11,6 +11,8 @@ public class VectorSource extends Source {
/**
* Internal use
*
* @param nativePtr - pointer to native peer
*/
public VectorSource(long nativePtr) {
super(nativePtr);