[android] #5610 - Initial Runtime Style Bindings

[android] #5610 - Adjusted public api after discussion

[android] #5610 - added jni binding for NativeMapView#getLayer

[android] #5610 - Added initial test Activity

[android] #5610 - Started on NativePeer implementation for Layer

[android] #5610 - replaced low-level jni code with high-level for native getLayer

[android] 5610 - completed basic layer peer class - constructible from java and c++

[android] #5610 - removed reference that was redundant and causing the finalizer exception

[android] #5610 - Added a property peer

[android] #5610 - added value type to do type conversions - wip

[android] #5610 - simplified property conversion approach - wrapped value with jenv

[android] #5610 - added some more value conversions

[android] #5610 - Finished conversion for basic types

[android] #5610 - allow color's to be set as either an android color int or a String to support all formats in the spec

[android] #5610 - encode color ints as rgba to retain alpha channel

[android] #5610 - recalculate classes after paint property

[android] #5610 - more examples

[android] #5610 - fixed the example

[android] #5610 - cleaned up example code before continueing

[android] #5610 - added layout property example

[android] #5610 - set visibility on layer

[android] #5610 - added removeLayer and example

[android] #5610 - added more type conversions

[android] #5610 - Started on peer classes for layer implementations - WIP

[android] #5610 - First complete layer subclass peer implementation

[android] #5610 - added a little bit of structure before adding the other layer types

[android] #5610 - generate the c++ headers from the style spec

[android] #5610 - make sure the visibility is set as a string

[android] #5610 - Generate c++ layer peer class implementations from the style spec

[android] #5610 - generate java layer peer classes

[android] #5610 - cleanup comments

[android] #5610 - register all c++ peer classes with jni

[android] #5610 - addLayer

[android] #5610 - comment out broken case

[android] #5610 - Sources api - very much WIP

[android] 5610 - GeoJson source implementation and geojson conversion

[android] #5610 - cleanup add source/layer example a bit

[android] #5610 - initial filter api

[android] #5610 - Added filter api on the relevant Layer classes

[android] #5610 - raster layer is not filterable

[android] #5610 - actually make it compile

[android] #5610 - completed filter implementation

[android] #5610 - Vector and Raster Source + examples

[android] #5610 - removed superfluous interface, moved filters to the correct package

[android] #5610 - fixed comments

[android] #5610 - moved tests to the right package

[android] #5610 - hide difference between paint and layout properties in public api, make more performant set method for proeprties

[android] #5610 - fix rebase issue
This commit is contained in:
Ivo van Dongen
2016-07-08 18:31:55 +02:00
parent b3c914fb3f
commit 9a3eadfd5b
60 changed files with 5510 additions and 2 deletions

View File

@@ -2660,6 +2660,10 @@ public class MapView extends FrameLayout {
return mMyLocationView;
}
NativeMapView getNativeMapView() {
return mNativeMapView;
}
@UiThread
void snapshot(@NonNull final MapboxMap.SnapshotReadyCallback callback, @Nullable final Bitmap bitmap) {
TextureView textureView = (TextureView) findViewById(R.id.textureView);

View File

@@ -40,6 +40,9 @@ import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.style.sources.Source;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
@@ -103,6 +106,39 @@ public class MapboxMap {
mMarkerViewManager = new MarkerViewManager(this, mapView);
}
// Style
@Nullable
@UiThread
public Layer getLayer(@NonNull String layerId) {
return getMapView().getNativeMapView().getLayer(layerId);
}
@UiThread
public void addLayer(@NonNull Layer layer) {
addLayer(layer, null);
}
@UiThread
public void addLayer(@NonNull Layer layer, String before) {
getMapView().getNativeMapView().addLayer(layer, before);
}
@UiThread
public void removeLayer(@NonNull String layerId) throws NoSuchLayerException {
getMapView().getNativeMapView().removeLayer(layerId);
}
@UiThread
public void addSource(@NonNull Source source) {
getMapView().getNativeMapView().addSource(source);
}
@UiThread
public void removeSource(@NonNull String sourceId) {
getMapView().getNativeMapView().removeSource(sourceId);
}
//
// MinZoom
//

View File

@@ -5,6 +5,8 @@ import android.content.Context;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Surface;
import com.mapbox.mapboxsdk.annotations.Icon;
@@ -16,6 +18,9 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.offline.OfflineManager;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.style.sources.Source;
import java.util.List;
@@ -470,6 +475,28 @@ final class NativeMapView {
return nativeGetCameraValues(mNativeMapViewPtr);
}
// Runtime style Api
public Layer getLayer(String layerId) {
return nativeGetLayer(mNativeMapViewPtr, layerId);
}
public void addLayer(@NonNull Layer layer, @Nullable String before) {
nativeAddLayer(mNativeMapViewPtr, layer.getNativePtr(), before);
}
public void removeLayer(@NonNull String layerId) throws NoSuchLayerException {
nativeRemoveLayer(mNativeMapViewPtr, layerId);
}
public void addSource(@NonNull Source source) {
nativeAddSource(mNativeMapViewPtr, source.getId(), source);
}
public void removeSource(@NonNull String sourceId) {
nativeRemoveSource(mNativeMapViewPtr, sourceId);
}
//
// Callbacks
//
@@ -633,7 +660,7 @@ final class NativeMapView {
private native LatLng nativeLatLngForPixel(long nativeMapViewPtr, float x, float y);
private native double nativeGetTopOffsetPixelsForAnnotationSymbol(long nativeMapViewPtr, String symbolName);
private native void nativeJumpTo(long nativeMapViewPtr, double angle, double latitude, double longitude, double pitch, double zoom);
private native void nativeEaseTo(long nativeMapViewPtr, double angle, double latitude, double longitude, long duration, double pitch, double zoom, boolean easingInterpolator);
@@ -645,4 +672,14 @@ final class NativeMapView {
private native void nativeRemoveCustomLayer(long nativeMapViewPtr, String id);
private native double[] nativeGetCameraValues(long mNativeMapViewPtr);
private native Layer nativeGetLayer(long nativeMapViewPtr, String layerId);
private native void nativeAddLayer(long nativeMapViewPtr, long layerPtr, String before);
private native void nativeRemoveLayer(long nativeMapViewPtr, String layerId) throws NoSuchLayerException;
private native void nativeAddSource(long mNativeMapViewPtr, String id, Source source);
private native void nativeRemoveSource(long mNativeMapViewPtr, String sourceId);
}

View File

@@ -0,0 +1,19 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
/**
* Background Layer
*/
public class BackgroundLayer extends Layer {
public BackgroundLayer(long nativePtr) {
super(nativePtr);
}
public BackgroundLayer(String layerId) {
initialize(layerId);
}
protected native void initialize(String layerId);
}

View File

@@ -0,0 +1,31 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
/**
* Circle Layer
*/
public class CircleLayer extends Layer {
public CircleLayer(long nativePtr) {
super(nativePtr);
}
public CircleLayer(String layerId, String sourceId) {
initialize(layerId, sourceId);
}
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
nativeSetFilter(filter);
}
}

View File

@@ -0,0 +1,31 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
/**
* Fill Layer
*/
public class FillLayer extends Layer {
public FillLayer(long nativePtr) {
super(nativePtr);
}
public FillLayer(String layerId, String sourceId) {
initialize(layerId, sourceId);
}
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
nativeSetFilter(filter);
}
}

View File

@@ -0,0 +1,115 @@
package com.mapbox.mapboxsdk.style.layers;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Utility to build filter expressions more easily:
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-filter">Style spec</a>
*/
public class Filter {
public abstract static class Statement {
protected final String operator;
public Statement(String operator) {
this.operator = operator;
}
public abstract Object[] toArray();
}
public static class SimpleStatement extends Statement {
private final String key;
private final Object[] values;
public SimpleStatement(String operator, String key, Object... values) {
super(operator);
this.key = key;
this.values = values;
}
@Override
public Object[] toArray() {
ArrayList<Object> array = new ArrayList<>(2 + values.length);
array.add(operator);
array.add(key);
array.addAll(Arrays.asList(values));
return array.toArray();
}
}
public static class CompoundStatement extends Statement {
private final Statement[] statements;
public CompoundStatement(String operator, Statement... statements) {
super(operator);
this.statements = statements;
}
@Override
public Object[] toArray() {
ArrayList<Object> array = new ArrayList<>(1 + statements.length);
array.add(operator);
for (Statement statement : statements) {
array.add(statement.toArray());
}
return array.toArray();
}
}
public static Statement all(Statement... statements) {
return new CompoundStatement("all", statements);
}
public static Statement any(Statement... statements) {
return new CompoundStatement("any", statements);
}
public static Statement none(Statement... statements) {
return new CompoundStatement("none", statements);
}
public static Statement has(String key) {
return new SimpleStatement("has", key);
}
public static Statement notHas(String key) {
return new SimpleStatement("!has", key);
}
public static Statement eq(String key, Object value) {
return new SimpleStatement("==", key, value);
}
public static Statement neq(String key, Object value) {
return new SimpleStatement("!=", key, value);
}
public static Statement gt(String key, Object value) {
return new SimpleStatement(">", key, value);
}
public static Statement gte(String key, Object value) {
return new SimpleStatement(">=", key, value);
}
public static Statement lt(String key, Object value) {
return new SimpleStatement("<", key, value);
}
public static Statement lte(String key, Object value) {
return new SimpleStatement("<=", key, value);
}
public static Statement in(String key, Object... values) {
return new SimpleStatement("in", key, values);
}
public static Statement notIn(String key, Object... values) {
return new SimpleStatement("!in", key, values);
}
}

View File

@@ -0,0 +1,68 @@
package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.NonNull;
import android.util.Log;
/**
* Base class for the different Layer types
*/
public abstract class Layer {
private long nativePtr;
public Layer(long nativePtr) {
Log.i(Layer.class.getSimpleName(), "Native pointer constructor: " + nativePtr);
this.nativePtr = nativePtr;
}
public Layer() {
Log.i(Layer.class.getSimpleName(), "Default constructor");
}
public void set(@NonNull Property<?>... properties) {
if (properties.length == 0) {
return;
}
boolean updateClasses = false;
for (Property<?> property : properties) {
if (property instanceof PaintProperty) {
updateClasses = true;
nativeSetPaintProperty(property.name, property.value);
} else {
nativeSetLayoutProperty(property.name, property.value);
}
}
nativeUpdateStyle(updateClasses);
}
public String getId() {
return nativeGetId();
}
@Override
protected native void finalize() throws Throwable;
protected native String nativeGetId();
protected native void nativeSetLayoutProperty(String name, Object value);
protected native void nativeSetPaintProperty(String name, Object value);
protected native void nativeSetFilter(Object[] filter);
protected native void nativeSetSourceLayer(String sourceLayer);
protected native void nativeUpdateStyle(boolean updateClasses);
@Override
public String toString() {
return "Layer: " + getId();
}
public long getNativePtr() {
return nativePtr;
}
}

View File

@@ -0,0 +1,9 @@
package com.mapbox.mapboxsdk.style.layers;
class LayoutProperty<T> extends Property<T> {
LayoutProperty(String name, T value) {
super(name, value);
}
}

View File

@@ -0,0 +1,31 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
/**
* Line Layer
*/
public class LineLayer extends Layer {
public LineLayer(long nativePtr) {
super(nativePtr);
}
public LineLayer(String layerId, String sourceId) {
initialize(layerId, sourceId);
}
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
nativeSetFilter(filter);
}
}

View File

@@ -0,0 +1,11 @@
package com.mapbox.mapboxsdk.style.layers;
/**
* No such layer.
*/
public class NoSuchLayerException extends Exception {
public NoSuchLayerException(String message) {
super(message);
}
}

View File

@@ -0,0 +1,9 @@
package com.mapbox.mapboxsdk.style.layers;
class PaintProperty<T> extends Property<T> {
PaintProperty(String name, T value) {
super(name, value);
}
}

View File

@@ -0,0 +1,226 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Paint/Layout properties for Layer
*/
public abstract class Property<T> {
//line-cap
public static final String LINE_CAP_BUTT = "butt";
public static final String LINE_CAP_ROUND = "round";
public static final String LINE_CAP_SQUARE = "square";
@StringDef({
LINE_CAP_BUTT,
LINE_CAP_ROUND,
LINE_CAP_SQUARE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface LINE_CAP {}
//line-join
public static final String LINE_JOIN_BEVEL = "bevel";
public static final String LINE_JOIN_ROUND = "round";
public static final String LINE_JOIN_MITER = "miter";
@StringDef({
LINE_JOIN_BEVEL,
LINE_JOIN_ROUND,
LINE_JOIN_MITER,
})
@Retention(RetentionPolicy.SOURCE)
public @interface LINE_JOIN {}
//symbol-placement
public static final String SYMBOL_PLACEMENT_POINT = "point";
public static final String SYMBOL_PLACEMENT_LINE = "line";
@StringDef({
SYMBOL_PLACEMENT_POINT,
SYMBOL_PLACEMENT_LINE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface SYMBOL_PLACEMENT {}
//icon-rotation-alignment
public static final String ICON_ROTATION_ALIGNMENT_MAP = "map";
public static final String ICON_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
@StringDef({
ICON_ROTATION_ALIGNMENT_MAP,
ICON_ROTATION_ALIGNMENT_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ICON_ROTATION_ALIGNMENT {}
//icon-text-fit
public static final String ICON_TEXT_FIT_NONE = "none";
public static final String ICON_TEXT_FIT_BOTH = "both";
public static final String ICON_TEXT_FIT_WIDTH = "width";
public static final String ICON_TEXT_FIT_HEIGHT = "height";
@StringDef({
ICON_TEXT_FIT_NONE,
ICON_TEXT_FIT_BOTH,
ICON_TEXT_FIT_WIDTH,
ICON_TEXT_FIT_HEIGHT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ICON_TEXT_FIT {}
//text-pitch-alignment
public static final String TEXT_PITCH_ALIGNMENT_MAP = "map";
public static final String TEXT_PITCH_ALIGNMENT_VIEWPORT = "viewport";
@StringDef({
TEXT_PITCH_ALIGNMENT_MAP,
TEXT_PITCH_ALIGNMENT_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TEXT_PITCH_ALIGNMENT {}
//text-rotation-alignment
public static final String TEXT_ROTATION_ALIGNMENT_MAP = "map";
public static final String TEXT_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
@StringDef({
TEXT_ROTATION_ALIGNMENT_MAP,
TEXT_ROTATION_ALIGNMENT_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TEXT_ROTATION_ALIGNMENT {}
//text-justify
public static final String TEXT_JUSTIFY_LEFT = "left";
public static final String TEXT_JUSTIFY_CENTER = "center";
public static final String TEXT_JUSTIFY_RIGHT = "right";
@StringDef({
TEXT_JUSTIFY_LEFT,
TEXT_JUSTIFY_CENTER,
TEXT_JUSTIFY_RIGHT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TEXT_JUSTIFY {}
//text-anchor
public static final String TEXT_ANCHOR_CENTER = "center";
public static final String TEXT_ANCHOR_LEFT = "left";
public static final String TEXT_ANCHOR_RIGHT = "right";
public static final String TEXT_ANCHOR_TOP = "top";
public static final String TEXT_ANCHOR_BOTTOM = "bottom";
public static final String TEXT_ANCHOR_TOP_LEFT = "top-left";
public static final String TEXT_ANCHOR_TOP_RIGHT = "top-right";
public static final String TEXT_ANCHOR_BOTTOM_LEFT = "bottom-left";
public static final String TEXT_ANCHOR_BOTTOM_RIGHT = "bottom-right";
@StringDef({
TEXT_ANCHOR_CENTER,
TEXT_ANCHOR_LEFT,
TEXT_ANCHOR_RIGHT,
TEXT_ANCHOR_TOP,
TEXT_ANCHOR_BOTTOM,
TEXT_ANCHOR_TOP_LEFT,
TEXT_ANCHOR_TOP_RIGHT,
TEXT_ANCHOR_BOTTOM_LEFT,
TEXT_ANCHOR_BOTTOM_RIGHT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TEXT_ANCHOR {}
//text-transform
public static final String TEXT_TRANSFORM_NONE = "none";
public static final String TEXT_TRANSFORM_UPPERCASE = "uppercase";
public static final String TEXT_TRANSFORM_LOWERCASE = "lowercase";
@StringDef({
TEXT_TRANSFORM_NONE,
TEXT_TRANSFORM_UPPERCASE,
TEXT_TRANSFORM_LOWERCASE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TEXT_TRANSFORM {}
//fill-translate-anchor
public static final String FILL_TRANSLATE_ANCHOR_MAP = "map";
public static final String FILL_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
@StringDef({
FILL_TRANSLATE_ANCHOR_MAP,
FILL_TRANSLATE_ANCHOR_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface FILL_TRANSLATE_ANCHOR {}
//line-translate-anchor
public static final String LINE_TRANSLATE_ANCHOR_MAP = "map";
public static final String LINE_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
@StringDef({
LINE_TRANSLATE_ANCHOR_MAP,
LINE_TRANSLATE_ANCHOR_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface LINE_TRANSLATE_ANCHOR {}
//icon-translate-anchor
public static final String ICON_TRANSLATE_ANCHOR_MAP = "map";
public static final String ICON_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
@StringDef({
ICON_TRANSLATE_ANCHOR_MAP,
ICON_TRANSLATE_ANCHOR_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ICON_TRANSLATE_ANCHOR {}
//text-translate-anchor
public static final String TEXT_TRANSLATE_ANCHOR_MAP = "map";
public static final String TEXT_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
@StringDef({
TEXT_TRANSLATE_ANCHOR_MAP,
TEXT_TRANSLATE_ANCHOR_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TEXT_TRANSLATE_ANCHOR {}
//circle-translate-anchor
public static final String CIRCLE_TRANSLATE_ANCHOR_MAP = "map";
public static final String CIRCLE_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
@StringDef({
CIRCLE_TRANSLATE_ANCHOR_MAP,
CIRCLE_TRANSLATE_ANCHOR_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface CIRCLE_TRANSLATE_ANCHOR {}
//circle-pitch-scale
public static final String CIRCLE_PITCH_SCALE_MAP = "map";
public static final String CIRCLE_PITCH_SCALE_VIEWPORT = "viewport";
@StringDef({
CIRCLE_PITCH_SCALE_MAP,
CIRCLE_PITCH_SCALE_VIEWPORT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface CIRCLE_PITCH_SCALE {}
//Class definition
public final String name;
public final T value;
/* package */ Property(String name, T value) {
this.name = name;
this.value = value;
}
}

View File

@@ -0,0 +1,403 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
import android.annotation.SuppressLint;
import android.support.annotation.ColorInt;
/**
* Constructs paint/layout properties for Layers
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers>Layer style documentation</a>
*
*/
public class PropertyFactory {
public static Property<String> visibility(Boolean visible) {
return new LayoutProperty<>("visibility", visible? "visible": "none");
}
public static Property<Boolean> fillAntialias(Boolean value) {
return new PaintProperty<>("fill-antialias", value);
}
public static Property<Float> fillOpacity(Float value) {
return new PaintProperty<>("fill-opacity", value);
}
public static Property<String> fillColor(@ColorInt int value) {
return new PaintProperty<>("fill-color", colorToRgbaString(value));
}
public static Property<String> fillColor(String value) {
return new PaintProperty<>("fill-color", value);
}
public static Property<String> fillOutlineColor(@ColorInt int value) {
return new PaintProperty<>("fill-outline-color", colorToRgbaString(value));
}
public static Property<String> fillOutlineColor(String value) {
return new PaintProperty<>("fill-outline-color", value);
}
public static Property<Float[]> fillTranslate(Float[] value) {
return new PaintProperty<>("fill-translate", value);
}
public static Property<String> fillTranslateAnchor(@Property.FILL_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("fill-translate-anchor", value);
}
public static Property<String> fillPattern(String value) {
return new PaintProperty<>("fill-pattern", value);
}
public static Property<Float> lineOpacity(Float value) {
return new PaintProperty<>("line-opacity", value);
}
public static Property<String> lineColor(@ColorInt int value) {
return new PaintProperty<>("line-color", colorToRgbaString(value));
}
public static Property<String> lineColor(String value) {
return new PaintProperty<>("line-color", value);
}
public static Property<Float[]> lineTranslate(Float[] value) {
return new PaintProperty<>("line-translate", value);
}
public static Property<String> lineTranslateAnchor(@Property.LINE_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("line-translate-anchor", value);
}
public static Property<Float> lineWidth(Float value) {
return new PaintProperty<>("line-width", value);
}
public static Property<Float> lineGapWidth(Float value) {
return new PaintProperty<>("line-gap-width", value);
}
public static Property<Float> lineOffset(Float value) {
return new PaintProperty<>("line-offset", value);
}
public static Property<Float> lineBlur(Float value) {
return new PaintProperty<>("line-blur", value);
}
public static Property<Float[]> lineDasharray(Float[] value) {
return new PaintProperty<>("line-dasharray", value);
}
public static Property<String> linePattern(String value) {
return new PaintProperty<>("line-pattern", value);
}
public static Property<Float> iconOpacity(Float value) {
return new PaintProperty<>("icon-opacity", value);
}
public static Property<String> iconColor(@ColorInt int value) {
return new PaintProperty<>("icon-color", colorToRgbaString(value));
}
public static Property<String> iconColor(String value) {
return new PaintProperty<>("icon-color", value);
}
public static Property<String> iconHaloColor(@ColorInt int value) {
return new PaintProperty<>("icon-halo-color", colorToRgbaString(value));
}
public static Property<String> iconHaloColor(String value) {
return new PaintProperty<>("icon-halo-color", value);
}
public static Property<Float> iconHaloWidth(Float value) {
return new PaintProperty<>("icon-halo-width", value);
}
public static Property<Float> iconHaloBlur(Float value) {
return new PaintProperty<>("icon-halo-blur", value);
}
public static Property<Float[]> iconTranslate(Float[] value) {
return new PaintProperty<>("icon-translate", value);
}
public static Property<String> iconTranslateAnchor(@Property.ICON_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("icon-translate-anchor", value);
}
public static Property<Float> textOpacity(Float value) {
return new PaintProperty<>("text-opacity", value);
}
public static Property<String> textColor(@ColorInt int value) {
return new PaintProperty<>("text-color", colorToRgbaString(value));
}
public static Property<String> textColor(String value) {
return new PaintProperty<>("text-color", value);
}
public static Property<String> textHaloColor(@ColorInt int value) {
return new PaintProperty<>("text-halo-color", colorToRgbaString(value));
}
public static Property<String> textHaloColor(String value) {
return new PaintProperty<>("text-halo-color", value);
}
public static Property<Float> textHaloWidth(Float value) {
return new PaintProperty<>("text-halo-width", value);
}
public static Property<Float> textHaloBlur(Float value) {
return new PaintProperty<>("text-halo-blur", value);
}
public static Property<Float[]> textTranslate(Float[] value) {
return new PaintProperty<>("text-translate", value);
}
public static Property<String> textTranslateAnchor(@Property.TEXT_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("text-translate-anchor", value);
}
public static Property<Float> circleRadius(Float value) {
return new PaintProperty<>("circle-radius", value);
}
public static Property<String> circleColor(@ColorInt int value) {
return new PaintProperty<>("circle-color", colorToRgbaString(value));
}
public static Property<String> circleColor(String value) {
return new PaintProperty<>("circle-color", value);
}
public static Property<Float> circleBlur(Float value) {
return new PaintProperty<>("circle-blur", value);
}
public static Property<Float> circleOpacity(Float value) {
return new PaintProperty<>("circle-opacity", value);
}
public static Property<Float[]> circleTranslate(Float[] value) {
return new PaintProperty<>("circle-translate", value);
}
public static Property<String> circleTranslateAnchor(@Property.CIRCLE_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("circle-translate-anchor", value);
}
public static Property<String> circlePitchScale(@Property.CIRCLE_PITCH_SCALE String value) {
return new PaintProperty<>("circle-pitch-scale", value);
}
public static Property<Float> rasterOpacity(Float value) {
return new PaintProperty<>("raster-opacity", value);
}
public static Property<Float> rasterHueRotate(Float value) {
return new PaintProperty<>("raster-hue-rotate", value);
}
public static Property<Float> rasterBrightnessMin(Float value) {
return new PaintProperty<>("raster-brightness-min", value);
}
public static Property<Float> rasterBrightnessMax(Float value) {
return new PaintProperty<>("raster-brightness-max", value);
}
public static Property<Float> rasterSaturation(Float value) {
return new PaintProperty<>("raster-saturation", value);
}
public static Property<Float> rasterContrast(Float value) {
return new PaintProperty<>("raster-contrast", value);
}
public static Property<Float> rasterFadeDuration(Float value) {
return new PaintProperty<>("raster-fade-duration", value);
}
public static Property<String> backgroundColor(@ColorInt int value) {
return new PaintProperty<>("background-color", colorToRgbaString(value));
}
public static Property<String> backgroundColor(String value) {
return new PaintProperty<>("background-color", value);
}
public static Property<String> backgroundPattern(String value) {
return new PaintProperty<>("background-pattern", value);
}
public static Property<Float> backgroundOpacity(Float value) {
return new PaintProperty<>("background-opacity", value);
}
public static Property<String> lineCap(@Property.LINE_CAP String value) {
return new LayoutProperty<>("line-cap", value);
}
public static Property<String> lineJoin(@Property.LINE_JOIN String value) {
return new LayoutProperty<>("line-join", value);
}
public static Property<Float> lineMiterLimit(Float value) {
return new LayoutProperty<>("line-miter-limit", value);
}
public static Property<Float> lineRoundLimit(Float value) {
return new LayoutProperty<>("line-round-limit", value);
}
public static Property<String> symbolPlacement(@Property.SYMBOL_PLACEMENT String value) {
return new LayoutProperty<>("symbol-placement", value);
}
public static Property<Float> symbolSpacing(Float value) {
return new LayoutProperty<>("symbol-spacing", value);
}
public static Property<Boolean> symbolAvoidEdges(Boolean value) {
return new LayoutProperty<>("symbol-avoid-edges", value);
}
public static Property<Boolean> iconAllowOverlap(Boolean value) {
return new LayoutProperty<>("icon-allow-overlap", value);
}
public static Property<Boolean> iconIgnorePlacement(Boolean value) {
return new LayoutProperty<>("icon-ignore-placement", value);
}
public static Property<Boolean> iconOptional(Boolean value) {
return new LayoutProperty<>("icon-optional", value);
}
public static Property<String> iconRotationAlignment(@Property.ICON_ROTATION_ALIGNMENT String value) {
return new LayoutProperty<>("icon-rotation-alignment", value);
}
public static Property<Float> iconSize(Float value) {
return new LayoutProperty<>("icon-size", value);
}
public static Property<String> iconTextFit(@Property.ICON_TEXT_FIT String value) {
return new LayoutProperty<>("icon-text-fit", value);
}
public static Property<Float[]> iconTextFitPadding(Float[] value) {
return new LayoutProperty<>("icon-text-fit-padding", value);
}
public static Property<String> iconImage(String value) {
return new LayoutProperty<>("icon-image", value);
}
public static Property<Float> iconRotate(Float value) {
return new LayoutProperty<>("icon-rotate", value);
}
public static Property<Float> iconPadding(Float value) {
return new LayoutProperty<>("icon-padding", value);
}
public static Property<Boolean> iconKeepUpright(Boolean value) {
return new LayoutProperty<>("icon-keep-upright", value);
}
public static Property<Float[]> iconOffset(Float[] value) {
return new LayoutProperty<>("icon-offset", value);
}
public static Property<String> textPitchAlignment(@Property.TEXT_PITCH_ALIGNMENT String value) {
return new LayoutProperty<>("text-pitch-alignment", value);
}
public static Property<String> textRotationAlignment(@Property.TEXT_ROTATION_ALIGNMENT String value) {
return new LayoutProperty<>("text-rotation-alignment", value);
}
public static Property<String> textField(String value) {
return new LayoutProperty<>("text-field", value);
}
public static Property<String[]> textFont(String[] value) {
return new LayoutProperty<>("text-font", value);
}
public static Property<Float> textSize(Float value) {
return new LayoutProperty<>("text-size", value);
}
public static Property<Float> textMaxWidth(Float value) {
return new LayoutProperty<>("text-max-width", value);
}
public static Property<Float> textLineHeight(Float value) {
return new LayoutProperty<>("text-line-height", value);
}
public static Property<Float> textLetterSpacing(Float value) {
return new LayoutProperty<>("text-letter-spacing", value);
}
public static Property<String> textJustify(@Property.TEXT_JUSTIFY String value) {
return new LayoutProperty<>("text-justify", value);
}
public static Property<String> textAnchor(@Property.TEXT_ANCHOR String value) {
return new LayoutProperty<>("text-anchor", value);
}
public static Property<Float> textMaxAngle(Float value) {
return new LayoutProperty<>("text-max-angle", value);
}
public static Property<Float> textRotate(Float value) {
return new LayoutProperty<>("text-rotate", value);
}
public static Property<Float> textPadding(Float value) {
return new LayoutProperty<>("text-padding", value);
}
public static Property<Boolean> textKeepUpright(Boolean value) {
return new LayoutProperty<>("text-keep-upright", value);
}
public static Property<String> textTransform(@Property.TEXT_TRANSFORM String value) {
return new LayoutProperty<>("text-transform", value);
}
public static Property<Float[]> textOffset(Float[] value) {
return new LayoutProperty<>("text-offset", value);
}
public static Property<Boolean> textAllowOverlap(Boolean value) {
return new LayoutProperty<>("text-allow-overlap", value);
}
public static Property<Boolean> textIgnorePlacement(Boolean value) {
return new LayoutProperty<>("text-ignore-placement", value);
}
public static Property<Boolean> textOptional(Boolean value) {
return new LayoutProperty<>("text-optional", value);
}
@SuppressLint("DefaultLocale")
static String colorToRgbaString(@ColorInt int value) {
return String.format("rgba(%d, %d, %d, %d)", (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF);
}
}

View File

@@ -0,0 +1,23 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
/**
* Raster Layer
*/
public class RasterLayer extends Layer {
public RasterLayer(long nativePtr) {
super(nativePtr);
}
public RasterLayer(String layerId, String sourceId) {
initialize(layerId, sourceId);
}
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
nativeSetSourceLayer(sourceLayer);
}
}

View File

@@ -0,0 +1,31 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
/**
* Symbol Layer
*/
public class SymbolLayer extends Layer {
public SymbolLayer(long nativePtr) {
super(nativePtr);
}
public SymbolLayer(String layerId, String sourceId) {
initialize(layerId, sourceId);
}
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
nativeSetFilter(filter);
}
}

View File

@@ -0,0 +1,23 @@
package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
import java.util.HashMap;
public class GeoJsonSource extends Source {
public static final String TYPE = "geojson";
private static final String DATA_KEY = "data";
public GeoJsonSource(String id, String geoJson) {
super(id, TYPE);
//Wrap the String in a map as an Object is expected by the
//style conversion template
HashMap<String, String> wrapper = new HashMap<>();
wrapper.put(DATA_KEY, geoJson);
this.put(DATA_KEY, wrapper);
}
public GeoJsonSource(String id, URL url) {
super(id, TYPE);
this.put(DATA_KEY, url.toExternalForm());
}
}

View File

@@ -0,0 +1,17 @@
package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
public class RasterSource extends Source {
public static final String TYPE = "raster";
private static final String URL_KEY = "url";
public RasterSource(String id, URL url) {
this(id, url.toExternalForm());
}
public RasterSource(String id, String url) {
super(id, TYPE);
this.put(URL_KEY, url);
}
}

View File

@@ -0,0 +1,16 @@
package com.mapbox.mapboxsdk.style.sources;
import java.util.HashMap;
public abstract class Source extends HashMap<String, Object> {
private final String id;
protected Source(String id, String type) {
this.put("type", type);
this.id = id;
}
public String getId() {
return id;
}
}

View File

@@ -0,0 +1,18 @@
package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
import java.util.HashMap;
public class VectorSource extends Source {
public static final String TYPE = "vector";
private static final String URL_KEY = "url";
public VectorSource(String id, URL url) {
this(id, url.toExternalForm());
}
public VectorSource(String id, String url) {
super(id, TYPE);
this.put(URL_KEY, url);
}
}