From 10b2cc60a7b274f71b46976b1e9e89031b9e44ca Mon Sep 17 00:00:00 2001
From: Ivo van Dongen
Date: Tue, 26 Jul 2016 17:02:52 -0400
Subject: [PATCH] [android] #5610 - Runtime style api - part 2
---
.../mapbox/mapboxsdk/layers/CustomLayer.java | 23 -
.../mapbox/mapboxsdk/layers/package-info.java | 4 -
.../com/mapbox/mapboxsdk/maps/MapView.java | 29 -
.../com/mapbox/mapboxsdk/maps/MapboxMap.java | 45 +-
.../mapbox/mapboxsdk/maps/NativeMapView.java | 14 +-
.../style/layers/BackgroundLayer.java | 27 +
.../mapboxsdk/style/layers/CircleLayer.java | 62 +
.../mapboxsdk/style/layers/CustomLayer.java | 30 +
.../mapboxsdk/style/layers/FillLayer.java | 62 +
.../mapboxsdk/style/layers/Function.java | 85 ++
.../mapbox/mapboxsdk/style/layers/Layer.java | 64 +-
.../mapboxsdk/style/layers/LineLayer.java | 118 ++
.../mapboxsdk/style/layers/Property.java | 11 +
.../style/layers/PropertyFactory.java | 903 ++++++++++++-
.../mapboxsdk/style/layers/PropertyValue.java | 56 +
.../mapboxsdk/style/layers/RasterLayer.java | 60 +
.../mapboxsdk/style/layers/SymbolLayer.java | 390 ++++++
.../mapboxsdk/style/layers}/layer.java.ejs | 19 +
.../mapboxsdk/style/layers/property.java.ejs} | 11 +
.../style/layers/property_factory.java.ejs} | 39 +-
.../mapboxsdk/style/sources/RasterSource.java | 16 +
.../mapboxsdk/style/sources/TileSet.java | 290 +++++
.../mapboxsdk/style/sources/VectorSource.java | 6 +-
.../mapboxsdk/style/BackgroundLayerTest.java | 120 ++
.../mapboxsdk/style/CircleLayerTest.java | 232 ++++
.../mapbox/mapboxsdk/style/FillLayerTest.java | 232 ++++
.../mapbox/mapboxsdk/style/LineLayerTest.java | 386 ++++++
.../mapboxsdk/style/RasterLayerTest.java | 232 ++++
.../RuntimeStyleBackgroundLayerTest.java | 61 +
.../mapboxsdk/style/RuntimeStyleTests.java | 91 ++
.../style/RuntimeStyleTimingTests.java | 54 +
.../mapboxsdk/style/SymbolLayerTest.java | 1134 +++++++++++++++++
.../mapbox/mapboxsdk/style/layer.junit.ejs | 116 ++
.../utils/OnMapReadyIdlingResource.java | 51 +
.../src/main/AndroidManifest.xml | 5 +
.../activity/FeatureOverviewActivity.java | 12 +-
.../customlayer/CustomLayerActivity.java | 13 +-
.../activity/style/RuntimeStyleActivity.java | 86 +-
.../style/RuntimeStyleTestActivity.java | 69 +
.../style/RuntimeStyleTimingTestActivity.java | 87 ++
.../src/main/res/menu/menu_runtime_style.xml | 8 +
.../mapboxsdk/style/layers/FunctionTest.java | 29 +
platform/android/platform.gyp | 1 +
.../android/scripts/generate-style-code.js | 124 +-
platform/android/src/conversion/constant.hpp | 95 ++
.../android/src/conversion/conversion.hpp | 50 +
platform/android/src/jni.cpp | 38 -
.../android/src/style/android_conversion.hpp | 8 +-
.../android/src/style/conversion/function.hpp | 52 +
.../src/style/conversion/property_value.hpp | 38 +
.../android/src/style/conversion/types.hpp | 98 ++
.../src/style/conversion/types.hpp.ejs | 40 +
.../style/conversion/types_string_values.hpp | 209 +++
.../conversion/types_string_values.hpp.ejs | 48 +
.../src/style/layers/background_layer.cpp | 35 +-
.../src/style/layers/background_layer.hpp | 10 +-
.../android/src/style/layers/circle_layer.cpp | 63 +-
.../android/src/style/layers/circle_layer.hpp | 18 +-
.../android/src/style/layers/custom_layer.cpp | 57 +
.../android/src/style/layers/custom_layer.hpp | 32 +
.../android/src/style/layers/fill_layer.cpp | 63 +-
.../android/src/style/layers/fill_layer.hpp | 18 +-
platform/android/src/style/layers/layer.cpp | 59 +-
.../style/layers}/layer.cpp.ejs | 25 +-
platform/android/src/style/layers/layer.hpp | 14 +
.../style/layers}/layer.hpp.ejs | 9 +-
platform/android/src/style/layers/layers.cpp | 10 +-
.../android/src/style/layers/line_layer.cpp | 112 +-
.../android/src/style/layers/line_layer.hpp | 32 +-
.../android/src/style/layers/raster_layer.cpp | 63 +-
.../android/src/style/layers/raster_layer.hpp | 18 +-
.../android/src/style/layers/symbol_layer.cpp | 350 ++++-
.../android/src/style/layers/symbol_layer.hpp | 100 +-
73 files changed, 6974 insertions(+), 297 deletions(-)
delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/CustomLayer.java
delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/package-info.java
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CustomLayer.java
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Function.java
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java
rename platform/android/{scripts => MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers}/layer.java.ejs (65%)
rename platform/android/{scripts/layer_property.java.ejs => MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs} (81%)
rename platform/android/{scripts/layer_property_factory.java.ejs => MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs} (62%)
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BackgroundLayerTest.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/CircleLayerTest.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/FillLayerTest.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/LineLayerTest.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RasterLayerTest.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleBackgroundLayerTest.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTests.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTimingTests.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/SymbolLayerTest.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/layer.junit.ejs
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/espresso/utils/OnMapReadyIdlingResource.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java
create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java
create mode 100644 platform/android/src/conversion/constant.hpp
create mode 100644 platform/android/src/conversion/conversion.hpp
create mode 100644 platform/android/src/style/conversion/function.hpp
create mode 100644 platform/android/src/style/conversion/property_value.hpp
create mode 100644 platform/android/src/style/conversion/types.hpp
create mode 100644 platform/android/src/style/conversion/types.hpp.ejs
create mode 100644 platform/android/src/style/conversion/types_string_values.hpp
create mode 100644 platform/android/src/style/conversion/types_string_values.hpp.ejs
create mode 100644 platform/android/src/style/layers/custom_layer.cpp
create mode 100644 platform/android/src/style/layers/custom_layer.hpp
rename platform/android/{scripts => src/style/layers}/layer.cpp.ejs (72%)
rename platform/android/{scripts => src/style/layers}/layer.hpp.ejs (80%)
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/CustomLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/CustomLayer.java
deleted file mode 100644
index 30efd59a6e0..00000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/CustomLayer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.mapbox.mapboxsdk.layers;
-
-public class CustomLayer {
-
- public String mID;
- public long mContext;
- public long mInitializeFunction;
- public long mRenderFunction;
- public long mDeinitializeFunction;
-
- public CustomLayer(String id,
- long context,
- long initializeFunction,
- long renderFunction,
- long deinitializeFunction) {
- this.mID = id;
- this.mContext = context;
- this.mInitializeFunction = initializeFunction;
- this.mRenderFunction = renderFunction;
- this.mDeinitializeFunction = deinitializeFunction;
- }
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/package-info.java
deleted file mode 100644
index 4c58308c47a..00000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Do not use this package. Experimental feature.
- */
-package com.mapbox.mapboxsdk.layers;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index dafece66415..c4cf0b3efc1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -78,7 +78,6 @@
import com.mapbox.mapboxsdk.exceptions.IconBitmapChangedException;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
-import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.location.LocationListener;
import com.mapbox.mapboxsdk.location.LocationServices;
import com.mapbox.mapboxsdk.maps.widgets.CompassView;
@@ -2604,34 +2603,6 @@ int getAttributionTintColor() {
return mMapboxMap.getUiSettings().getAttributionTintColor();
}
- //
- // Custom layer
- //
-
- @UiThread
- void addCustomLayer(CustomLayer customLayer, String before) {
- if (mDestroyed) {
- return;
- }
- mNativeMapView.addCustomLayer(customLayer, before);
- }
-
- @UiThread
- void removeCustomLayer(String id) {
- if (mDestroyed) {
- return;
- }
- mNativeMapView.removeCustomLayer(id);
- }
-
- @UiThread
- void invalidateCustomLayers() {
- if (mDestroyed) {
- return;
- }
- mNativeMapView.update();
- }
-
/**
* Sets a callback object which will be triggered when the {@link MapboxMap} instance is ready to be used.
*
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
index 85287a62c17..275cc2aeab4 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
@@ -38,7 +38,6 @@
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
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;
@@ -59,6 +58,7 @@
*
*/
public class MapboxMap {
+ private static final String TAG = MapboxMap.class.getSimpleName();
private MapView mMapView;
private UiSettings mUiSettings;
@@ -114,6 +114,21 @@ public Layer getLayer(@NonNull String layerId) {
return getMapView().getNativeMapView().getLayer(layerId);
}
+ /**
+ * Tries to cast the Layer to T, returns null if it's another type
+ */
+ @Nullable
+ @UiThread
+ public T getLayerAs(@NonNull String layerId) {
+ try {
+ //noinspection unchecked
+ return (T) getMapView().getNativeMapView().getLayer(layerId);
+ } catch (ClassCastException e) {
+ Log.e(TAG, String.format("Layer: %s is a different type: %s", layerId, e.getMessage()));
+ return null;
+ }
+ }
+
@UiThread
public void addLayer(@NonNull Layer layer) {
addLayer(layer, null);
@@ -1621,34 +1636,6 @@ OnMyBearingTrackingModeChangeListener getOnMyBearingTrackingModeChangeListener()
return mOnMyBearingTrackingModeChangeListener;
}
- //
- // Custom layer
- //
-
- /**
- * Do not use this method, experimental feature.
- */
- @UiThread
- public void addCustomLayer(CustomLayer customLayer, String before) {
- mMapView.addCustomLayer(customLayer, before);
- }
-
- /**
- * Do not use this method, experimental feature.
- */
- @UiThread
- public void removeCustomLayer(String id) {
- mMapView.removeCustomLayer(id);
- }
-
- /**
- * Do not use this method, experimental feature.
- */
- @UiThread
- public void invalidateCustomLayers() {
- mMapView.invalidateCustomLayers();
- }
-
MapView getMapView() {
return mMapView;
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index c6cb48fdc36..973fa8b5e14 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -16,7 +16,6 @@
import com.mapbox.mapboxsdk.geometry.LatLng;
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;
@@ -463,14 +462,6 @@ public void flyTo(double angle, LatLng center, long duration, double pitch, doub
nativeFlyTo(mNativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom);
}
- public void addCustomLayer(CustomLayer customLayer, String before) {
- nativeAddCustomLayer(mNativeMapViewPtr, customLayer, before);
- }
-
- public void removeCustomLayer(String id) {
- nativeRemoveCustomLayer(mNativeMapViewPtr, id);
- }
-
public double[] getCameraValues() {
return nativeGetCameraValues(mNativeMapViewPtr);
}
@@ -483,6 +474,7 @@ public Layer getLayer(String layerId) {
public void addLayer(@NonNull Layer layer, @Nullable String before) {
nativeAddLayer(mNativeMapViewPtr, layer.getNativePtr(), before);
+ layer.invalidate();
}
public void removeLayer(@NonNull String layerId) throws NoSuchLayerException {
@@ -667,10 +659,6 @@ private native void nativeSetVisibleCoordinateBounds(long mNativeMapViewPtr, Lat
private native void nativeFlyTo(long nativeMapViewPtr, double angle, double latitude, double longitude, long duration, double pitch, double zoom);
- private native void nativeAddCustomLayer(long nativeMapViewPtr, CustomLayer customLayer, String before);
-
- private native void nativeRemoveCustomLayer(long nativeMapViewPtr, String id);
-
private native double[] nativeGetCameraValues(long mNativeMapViewPtr);
private native Layer nativeGetLayer(long nativeMapViewPtr, String layerId);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java
index 7dcd9eee462..f7a71155ad4 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java
@@ -16,4 +16,31 @@ public BackgroundLayer(String layerId) {
protected native void initialize(String layerId);
+
+ // Property getters
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getBackgroundColor() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetBackgroundColor());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getBackgroundPattern() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetBackgroundPattern());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getBackgroundOpacity() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetBackgroundOpacity());
+ }
+
+ private native Object nativeGetBackgroundColor();
+
+ private native Object nativeGetBackgroundPattern();
+
+ private native Object nativeGetBackgroundOpacity();
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java
index 8562ef1bf4d..6628fee47a6 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java
@@ -17,15 +17,77 @@ public CircleLayer(String layerId, String sourceId) {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
+ checkValidity();
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
+ checkValidity();
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
+ checkValidity();
nativeSetFilter(filter);
}
+
+ // Property getters
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getCircleRadius() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetCircleRadius());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getCircleColor() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetCircleColor());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getCircleBlur() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetCircleBlur());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getCircleOpacity() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetCircleOpacity());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getCircleTranslate() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetCircleTranslate());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getCircleTranslateAnchor() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetCircleTranslateAnchor());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getCirclePitchScale() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetCirclePitchScale());
+ }
+
+ private native Object nativeGetCircleRadius();
+
+ private native Object nativeGetCircleColor();
+
+ private native Object nativeGetCircleBlur();
+
+ private native Object nativeGetCircleOpacity();
+
+ private native Object nativeGetCircleTranslate();
+
+ private native Object nativeGetCircleTranslateAnchor();
+
+ private native Object nativeGetCirclePitchScale();
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CustomLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CustomLayer.java
new file mode 100644
index 00000000000..f25d46dba9a
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CustomLayer.java
@@ -0,0 +1,30 @@
+package com.mapbox.mapboxsdk.style.layers;
+
+/**
+ * Custom layer.
+ *
+ * Experimental feature. Do not use.
+ */
+public class CustomLayer extends Layer {
+
+ public CustomLayer(String id,
+ long context,
+ long initializeFunction,
+ long renderFunction,
+ long deinitializeFunction) {
+ initialize(id, initializeFunction, renderFunction, deinitializeFunction, context);
+ }
+
+ public CustomLayer(long nativePtr) {
+ super(nativePtr);
+ }
+
+ public void invalidate() {
+ nativeUpdate();
+ }
+
+ protected native void initialize(String id, long initializeFunction, long renderFunction, long deinitializeFunction, long context);
+
+ protected native void nativeUpdate();
+
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java
index b3eb5a39c13..7938af3c803 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java
@@ -17,15 +17,77 @@ public FillLayer(String layerId, String sourceId) {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
+ checkValidity();
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
+ checkValidity();
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
+ checkValidity();
nativeSetFilter(filter);
}
+
+ // Property getters
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getFillAntialias() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetFillAntialias());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getFillOpacity() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetFillOpacity());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getFillColor() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetFillColor());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getFillOutlineColor() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetFillOutlineColor());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getFillTranslate() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetFillTranslate());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getFillTranslateAnchor() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetFillTranslateAnchor());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getFillPattern() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetFillPattern());
+ }
+
+ private native Object nativeGetFillAntialias();
+
+ private native Object nativeGetFillOpacity();
+
+ private native Object nativeGetFillColor();
+
+ private native Object nativeGetFillOutlineColor();
+
+ private native Object nativeGetFillTranslate();
+
+ private native Object nativeGetFillTranslateAnchor();
+
+ private native Object nativeGetFillPattern();
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Function.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Function.java
new file mode 100644
index 00000000000..c776f9ff23e
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Function.java
@@ -0,0 +1,85 @@
+package com.mapbox.mapboxsdk.style.layers;
+
+import android.support.annotation.FloatRange;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.Size;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Representation of Function in the Mapbox style specification
+ *
+ * @param the target property's value type. Make sure it matches.
+ */
+public class Function {
+
+ public static class Stop {
+ public final I in;
+ public final O out;
+
+ Stop(I in, O out) {
+ this.in = in;
+ this.out = out;
+ }
+
+ Object[] toValueObject() {
+ return new Object[]{in, out};
+ }
+ }
+
+ @SafeVarargs
+ public static Function zoom(@NonNull @Size(min = 1) Stop... stops) {
+ return new Function(stops);
+ }
+
+ @SafeVarargs
+ public static Function zoom(
+ @FloatRange(from = 0, to = 1, fromInclusive = false, toInclusive = false) float base,
+ @NonNull @Size(min = 1) Stop... stops) {
+ return new Function(stops)
+ .withBase(base);
+ }
+
+ public static Stop stop(float in, Property output) {
+ return new Stop<>(in, output.value);
+ }
+
+ private final Stop[] stops;
+ private Float base;
+
+ Function(@NonNull @Size(min = 1) Stop[] stops) {
+ this.stops = stops;
+ }
+
+ Function withBase(float base) {
+ this.base = base;
+ return this;
+ }
+
+ @Nullable
+ public Float getBase() {
+ return base;
+ }
+
+ public Stop[] getStops() {
+ return stops;
+ }
+
+ Map toValueObject() {
+ Object[] stopsValue = new Object[stops.length];
+
+ for (int i = 0; i < stopsValue.length; i++) {
+ Stop stop = stops[i];
+ stopsValue[i] = stop.toValueObject();
+ }
+
+ Map value = new HashMap<>();
+ if (base != null) {
+ value.put("base", base);
+ }
+ value.put("stops", stopsValue);
+ return value;
+ }
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java
index eb316658ce8..387cedbd6cd 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java
@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.NonNull;
-import android.util.Log;
/**
* Base class for the different Layer types
@@ -9,17 +8,18 @@
public abstract class Layer {
private long nativePtr;
+ private boolean invalidated;
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) {
+ public void setProperties(@NonNull Property>... properties) {
+ checkValidity();
+
if (properties.length == 0) {
return;
}
@@ -28,9 +28,9 @@ public void set(@NonNull Property>... properties) {
for (Property> property : properties) {
if (property instanceof PaintProperty) {
updateClasses = true;
- nativeSetPaintProperty(property.name, property.value);
+ nativeSetPaintProperty(property.name, convertValue(property.value));
} else {
- nativeSetLayoutProperty(property.name, property.value);
+ nativeSetLayoutProperty(property.name, convertValue(property.value));
}
}
@@ -38,14 +38,42 @@ public void set(@NonNull Property>... properties) {
}
public String getId() {
+ checkValidity();
return nativeGetId();
}
+ public PropertyValue getVisibility() {
+ checkValidity();
+ return new PropertyValue<>(nativeGetVisibility());
+ }
+
+ public float getMinZoom() {
+ checkValidity();
+ return nativeGetMinZoom();
+ }
+
+ public float getMaxZoom() {
+ checkValidity();
+ return nativeGetMaxZoom();
+ }
+
+ public void setMinZoom(float zoom) {
+ checkValidity();
+ nativeSetMinZoom(zoom);
+ }
+
+ public void setMaxZoom(float zoom) {
+ checkValidity();
+ nativeSetMaxZoom(zoom);
+ }
+
@Override
protected native void finalize() throws Throwable;
protected native String nativeGetId();
+ protected native Object nativeGetVisibility();
+
protected native void nativeSetLayoutProperty(String name, Object value);
protected native void nativeSetPaintProperty(String name, Object value);
@@ -56,13 +84,29 @@ public String getId() {
protected native void nativeUpdateStyle(boolean updateClasses);
- @Override
- public String toString() {
- return "Layer: " + getId();
- }
+ protected native float nativeGetMinZoom();
+
+ protected native float nativeGetMaxZoom();
+
+ protected native void nativeSetMinZoom(float zoom);
+
+ protected native void nativeSetMaxZoom(float zoom);
public long getNativePtr() {
return nativePtr;
}
+ private Object convertValue(Object value) {
+ return value != null && value instanceof Function ? ((Function) value).toValueObject() : value;
+ }
+
+ protected void checkValidity() {
+ if (invalidated) {
+ throw new RuntimeException("Layer has been invalidated. Request a new reference after adding");
+ }
+ }
+
+ public void invalidate() {
+ this.invalidated = true;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
index 36c9d53d20b..11cd709f49b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
@@ -17,15 +17,133 @@ public LineLayer(String layerId, String sourceId) {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
+ checkValidity();
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
+ checkValidity();
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
+ checkValidity();
nativeSetFilter(filter);
}
+
+ // Property getters
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineCap() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineCap());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineJoin() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineJoin());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineMiterLimit() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineMiterLimit());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineRoundLimit() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineRoundLimit());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineOpacity() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineOpacity());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineColor() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineColor());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineTranslate() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineTranslate());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineTranslateAnchor() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineTranslateAnchor());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineWidth() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineWidth());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineGapWidth() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineGapWidth());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineOffset() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineOffset());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineBlur() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineBlur());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLineDasharray() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLineDasharray());
+ }
+
+ @SuppressWarnings("unchecked")
+ public PropertyValue getLinePattern() {
+ checkValidity();
+ return (PropertyValue) new PropertyValue(nativeGetLinePattern());
+ }
+
+ private native Object nativeGetLineCap();
+
+ private native Object nativeGetLineJoin();
+
+ private native Object nativeGetLineMiterLimit();
+
+ private native Object nativeGetLineRoundLimit();
+
+ private native Object nativeGetLineOpacity();
+
+ private native Object nativeGetLineColor();
+
+ private native Object nativeGetLineTranslate();
+
+ private native Object nativeGetLineTranslateAnchor();
+
+ private native Object nativeGetLineWidth();
+
+ private native Object nativeGetLineGapWidth();
+
+ private native Object nativeGetLineOffset();
+
+ private native Object nativeGetLineBlur();
+
+ private native Object nativeGetLineDasharray();
+
+ private native Object nativeGetLinePattern();
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
index 66cc7df111e..a31f1adb544 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
@@ -11,6 +11,17 @@
*/
public abstract class Property {
+ //visibility
+ public static final String VISIBLE = "visible";
+ public static final String NONE = "none";
+
+ @StringDef({
+ VISIBLE,
+ NONE
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface VISIBILITY {}
+
//line-cap
public static final String LINE_CAP_BUTT = "butt";
public static final String LINE_CAP_ROUND = "round";
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
index 4dcec0d9b37..88587dbb5b1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
@@ -6,395 +6,1292 @@
/**
* Constructs paint/layout properties for Layers
- * @see Layer style documentation
*/
public class PropertyFactory {
- public static Property visibility(Boolean visible) {
- return new LayoutProperty<>("visibility", visible? "visible": "none");
+ /**
+ * Set visibility
+ */
+ public static Property visibility(@Property.VISIBILITY String value) {
+ return new LayoutProperty<>("visibility", value);
+ }
+
+ /**
+ * Set visibility
+ */
+ public static Property> visibility(Function function) {
+ return new LayoutProperty<>("visibility", function);
}
+ /**
+ * Whether or not the fill should be antialiased.
+ */
public static Property fillAntialias(Boolean value) {
return new PaintProperty<>("fill-antialias", value);
}
+ /**
+ * Whether or not the fill should be antialiased.
+ */
+ public static Property> fillAntialias(Function function) {
+ return new PaintProperty<>("fill-antialias", function);
+ }
+
+ /**
+ * The opacity of the entire fill layer. In contrast to the fill-color, this value will also affect the 1px stroke around the fill, if the stroke is used.
+ */
public static Property fillOpacity(Float value) {
return new PaintProperty<>("fill-opacity", value);
}
+ /**
+ * The opacity of the entire fill layer. In contrast to the fill-color, this value will also affect the 1px stroke around the fill, if the stroke is used.
+ */
+ public static Property> fillOpacity(Function function) {
+ return new PaintProperty<>("fill-opacity", function);
+ }
+
+ /**
+ * The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used.
+ */
public static Property fillColor(@ColorInt int value) {
return new PaintProperty<>("fill-color", colorToRgbaString(value));
}
+ /**
+ * The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used.
+ */
public static Property fillColor(String value) {
return new PaintProperty<>("fill-color", value);
}
+ /**
+ * The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used.
+ */
+ public static Property> fillColor(Function function) {
+ return new PaintProperty<>("fill-color", function);
+ }
+
+ /**
+ * The outline color of the fill. Matches the value of `fill-color` if unspecified.
+ */
public static Property fillOutlineColor(@ColorInt int value) {
return new PaintProperty<>("fill-outline-color", colorToRgbaString(value));
}
+ /**
+ * The outline color of the fill. Matches the value of `fill-color` if unspecified.
+ */
public static Property fillOutlineColor(String value) {
return new PaintProperty<>("fill-outline-color", value);
}
+ /**
+ * The outline color of the fill. Matches the value of `fill-color` if unspecified.
+ */
+ public static Property> fillOutlineColor(Function function) {
+ return new PaintProperty<>("fill-outline-color", function);
+ }
+
+ /**
+ * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
public static Property fillTranslate(Float[] value) {
return new PaintProperty<>("fill-translate", value);
}
+ /**
+ * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
+ public static Property> fillTranslate(Function function) {
+ return new PaintProperty<>("fill-translate", function);
+ }
+
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen)
+ */
public static Property fillTranslateAnchor(@Property.FILL_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("fill-translate-anchor", value);
}
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen)
+ */
+ public static Property> fillTranslateAnchor(Function function) {
+ return new PaintProperty<>("fill-translate-anchor", function);
+ }
+
+ /**
+ * Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).
+ */
public static Property fillPattern(String value) {
return new PaintProperty<>("fill-pattern", value);
}
+ /**
+ * Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).
+ */
+ public static Property> fillPattern(Function function) {
+ return new PaintProperty<>("fill-pattern", function);
+ }
+
+ /**
+ * The opacity at which the line will be drawn.
+ */
public static Property lineOpacity(Float value) {
return new PaintProperty<>("line-opacity", value);
}
+ /**
+ * The opacity at which the line will be drawn.
+ */
+ public static Property> lineOpacity(Function function) {
+ return new PaintProperty<>("line-opacity", function);
+ }
+
+ /**
+ * The color with which the line will be drawn.
+ */
public static Property lineColor(@ColorInt int value) {
return new PaintProperty<>("line-color", colorToRgbaString(value));
}
+ /**
+ * The color with which the line will be drawn.
+ */
public static Property lineColor(String value) {
return new PaintProperty<>("line-color", value);
}
+ /**
+ * The color with which the line will be drawn.
+ */
+ public static Property> lineColor(Function function) {
+ return new PaintProperty<>("line-color", function);
+ }
+
+ /**
+ * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
public static Property lineTranslate(Float[] value) {
return new PaintProperty<>("line-translate", value);
}
+ /**
+ * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
+ public static Property> lineTranslate(Function function) {
+ return new PaintProperty<>("line-translate", function);
+ }
+
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen)
+ */
public static Property lineTranslateAnchor(@Property.LINE_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("line-translate-anchor", value);
}
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen)
+ */
+ public static Property> lineTranslateAnchor(Function function) {
+ return new PaintProperty<>("line-translate-anchor", function);
+ }
+
+ /**
+ * Stroke thickness.
+ */
public static Property lineWidth(Float value) {
return new PaintProperty<>("line-width", value);
}
+ /**
+ * Stroke thickness.
+ */
+ public static Property> lineWidth(Function function) {
+ return new PaintProperty<>("line-width", function);
+ }
+
+ /**
+ * Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap.
+ */
public static Property lineGapWidth(Float value) {
return new PaintProperty<>("line-gap-width", value);
}
+ /**
+ * Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap.
+ */
+ public static Property> lineGapWidth(Function function) {
+ return new PaintProperty<>("line-gap-width", function);
+ }
+
+ /**
+ * The line's offset perpendicular to its direction. Values may be positive or negative, where positive indicates "rightwards" (if you were moving in the direction of the line) and negative indicates "leftwards."
+ */
public static Property lineOffset(Float value) {
return new PaintProperty<>("line-offset", value);
}
+ /**
+ * The line's offset perpendicular to its direction. Values may be positive or negative, where positive indicates "rightwards" (if you were moving in the direction of the line) and negative indicates "leftwards."
+ */
+ public static Property> lineOffset(Function function) {
+ return new PaintProperty<>("line-offset", function);
+ }
+
+ /**
+ * Blur applied to the line, in pixels.
+ */
public static Property lineBlur(Float value) {
return new PaintProperty<>("line-blur", value);
}
+ /**
+ * Blur applied to the line, in pixels.
+ */
+ public static Property> lineBlur(Function function) {
+ return new PaintProperty<>("line-blur", function);
+ }
+
+ /**
+ * Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width.
+ */
public static Property lineDasharray(Float[] value) {
return new PaintProperty<>("line-dasharray", value);
}
+ /**
+ * Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width.
+ */
+ public static Property> lineDasharray(Function function) {
+ return new PaintProperty<>("line-dasharray", function);
+ }
+
+ /**
+ * Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512).
+ */
public static Property linePattern(String value) {
return new PaintProperty<>("line-pattern", value);
}
+ /**
+ * Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512).
+ */
+ public static Property> linePattern(Function function) {
+ return new PaintProperty<>("line-pattern", function);
+ }
+
+ /**
+ * The opacity at which the icon will be drawn.
+ */
public static Property iconOpacity(Float value) {
return new PaintProperty<>("icon-opacity", value);
}
+ /**
+ * The opacity at which the icon will be drawn.
+ */
+ public static Property> iconOpacity(Function function) {
+ return new PaintProperty<>("icon-opacity", function);
+ }
+
+ /**
+ * The color of the icon. This can only be used with sdf icons.
+ */
public static Property iconColor(@ColorInt int value) {
return new PaintProperty<>("icon-color", colorToRgbaString(value));
}
+ /**
+ * The color of the icon. This can only be used with sdf icons.
+ */
public static Property iconColor(String value) {
return new PaintProperty<>("icon-color", value);
}
+ /**
+ * The color of the icon. This can only be used with sdf icons.
+ */
+ public static Property> iconColor(Function function) {
+ return new PaintProperty<>("icon-color", function);
+ }
+
+ /**
+ * The color of the icon's halo. Icon halos can only be used with sdf icons.
+ */
public static Property iconHaloColor(@ColorInt int value) {
return new PaintProperty<>("icon-halo-color", colorToRgbaString(value));
}
+ /**
+ * The color of the icon's halo. Icon halos can only be used with sdf icons.
+ */
public static Property iconHaloColor(String value) {
return new PaintProperty<>("icon-halo-color", value);
}
+ /**
+ * The color of the icon's halo. Icon halos can only be used with sdf icons.
+ */
+ public static Property> iconHaloColor(Function function) {
+ return new PaintProperty<>("icon-halo-color", function);
+ }
+
+ /**
+ * Distance of halo to the icon outline.
+ */
public static Property iconHaloWidth(Float value) {
return new PaintProperty<>("icon-halo-width", value);
}
+ /**
+ * Distance of halo to the icon outline.
+ */
+ public static Property> iconHaloWidth(Function function) {
+ return new PaintProperty<>("icon-halo-width", function);
+ }
+
+ /**
+ * Fade out the halo towards the outside.
+ */
public static Property iconHaloBlur(Float value) {
return new PaintProperty<>("icon-halo-blur", value);
}
+ /**
+ * Fade out the halo towards the outside.
+ */
+ public static Property> iconHaloBlur(Function function) {
+ return new PaintProperty<>("icon-halo-blur", function);
+ }
+
+ /**
+ * Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.
+ */
public static Property iconTranslate(Float[] value) {
return new PaintProperty<>("icon-translate", value);
}
+ /**
+ * Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.
+ */
+ public static Property> iconTranslate(Function function) {
+ return new PaintProperty<>("icon-translate", function);
+ }
+
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen).
+ */
public static Property iconTranslateAnchor(@Property.ICON_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("icon-translate-anchor", value);
}
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen).
+ */
+ public static Property> iconTranslateAnchor(Function function) {
+ return new PaintProperty<>("icon-translate-anchor", function);
+ }
+
+ /**
+ * The opacity at which the text will be drawn.
+ */
public static Property textOpacity(Float value) {
return new PaintProperty<>("text-opacity", value);
}
+ /**
+ * The opacity at which the text will be drawn.
+ */
+ public static Property> textOpacity(Function function) {
+ return new PaintProperty<>("text-opacity", function);
+ }
+
+ /**
+ * The color with which the text will be drawn.
+ */
public static Property textColor(@ColorInt int value) {
return new PaintProperty<>("text-color", colorToRgbaString(value));
}
+ /**
+ * The color with which the text will be drawn.
+ */
public static Property textColor(String value) {
return new PaintProperty<>("text-color", value);
}
+ /**
+ * The color with which the text will be drawn.
+ */
+ public static Property> textColor(Function function) {
+ return new PaintProperty<>("text-color", function);
+ }
+
+ /**
+ * The color of the text's halo, which helps it stand out from backgrounds.
+ */
public static Property textHaloColor(@ColorInt int value) {
return new PaintProperty<>("text-halo-color", colorToRgbaString(value));
}
+ /**
+ * The color of the text's halo, which helps it stand out from backgrounds.
+ */
public static Property textHaloColor(String value) {
return new PaintProperty<>("text-halo-color", value);
}
+ /**
+ * The color of the text's halo, which helps it stand out from backgrounds.
+ */
+ public static Property> textHaloColor(Function function) {
+ return new PaintProperty<>("text-halo-color", function);
+ }
+
+ /**
+ * Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.
+ */
public static Property textHaloWidth(Float value) {
return new PaintProperty<>("text-halo-width", value);
}
+ /**
+ * Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.
+ */
+ public static Property> textHaloWidth(Function function) {
+ return new PaintProperty<>("text-halo-width", function);
+ }
+
+ /**
+ * The halo's fadeout distance towards the outside.
+ */
public static Property textHaloBlur(Float value) {
return new PaintProperty<>("text-halo-blur", value);
}
+ /**
+ * The halo's fadeout distance towards the outside.
+ */
+ public static Property> textHaloBlur(Function function) {
+ return new PaintProperty<>("text-halo-blur", function);
+ }
+
+ /**
+ * Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.
+ */
public static Property textTranslate(Float[] value) {
return new PaintProperty<>("text-translate", value);
}
+ /**
+ * Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.
+ */
+ public static Property> textTranslate(Function function) {
+ return new PaintProperty<>("text-translate", function);
+ }
+
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen).
+ */
public static Property textTranslateAnchor(@Property.TEXT_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("text-translate-anchor", value);
}
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen).
+ */
+ public static Property> textTranslateAnchor(Function function) {
+ return new PaintProperty<>("text-translate-anchor", function);
+ }
+
+ /**
+ * Circle radius.
+ */
public static Property circleRadius(Float value) {
return new PaintProperty<>("circle-radius", value);
}
+ /**
+ * Circle radius.
+ */
+ public static Property> circleRadius(Function function) {
+ return new PaintProperty<>("circle-radius", function);
+ }
+
+ /**
+ * The color of the circle.
+ */
public static Property circleColor(@ColorInt int value) {
return new PaintProperty<>("circle-color", colorToRgbaString(value));
}
+ /**
+ * The color of the circle.
+ */
public static Property circleColor(String value) {
return new PaintProperty<>("circle-color", value);
}
+ /**
+ * The color of the circle.
+ */
+ public static Property> circleColor(Function function) {
+ return new PaintProperty<>("circle-color", function);
+ }
+
+ /**
+ * Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity.
+ */
public static Property circleBlur(Float value) {
return new PaintProperty<>("circle-blur", value);
}
+ /**
+ * Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity.
+ */
+ public static Property> circleBlur(Function function) {
+ return new PaintProperty<>("circle-blur", function);
+ }
+
+ /**
+ * The opacity at which the circle will be drawn.
+ */
public static Property circleOpacity(Float value) {
return new PaintProperty<>("circle-opacity", value);
}
+ /**
+ * The opacity at which the circle will be drawn.
+ */
+ public static Property> circleOpacity(Function function) {
+ return new PaintProperty<>("circle-opacity", function);
+ }
+
+ /**
+ * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
public static Property circleTranslate(Float[] value) {
return new PaintProperty<>("circle-translate", value);
}
+ /**
+ * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
+ public static Property> circleTranslate(Function function) {
+ return new PaintProperty<>("circle-translate", function);
+ }
+
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen)
+ */
public static Property circleTranslateAnchor(@Property.CIRCLE_TRANSLATE_ANCHOR String value) {
return new PaintProperty<>("circle-translate-anchor", value);
}
+ /**
+ * Control whether the translation is relative to the map (north) or viewport (screen)
+ */
+ public static Property> circleTranslateAnchor(Function function) {
+ return new PaintProperty<>("circle-translate-anchor", function);
+ }
+
+ /**
+ * Controls the scaling behavior of the circle when the map is pitched. The value `map` scales circles according to their apparent distance to the camera. The value `viewport` results in no pitch-related scaling.
+ */
public static Property circlePitchScale(@Property.CIRCLE_PITCH_SCALE String value) {
return new PaintProperty<>("circle-pitch-scale", value);
}
+ /**
+ * Controls the scaling behavior of the circle when the map is pitched. The value `map` scales circles according to their apparent distance to the camera. The value `viewport` results in no pitch-related scaling.
+ */
+ public static Property> circlePitchScale(Function function) {
+ return new PaintProperty<>("circle-pitch-scale", function);
+ }
+
+ /**
+ * The opacity at which the image will be drawn.
+ */
public static Property rasterOpacity(Float value) {
return new PaintProperty<>("raster-opacity", value);
}
+ /**
+ * The opacity at which the image will be drawn.
+ */
+ public static Property> rasterOpacity(Function function) {
+ return new PaintProperty<>("raster-opacity", function);
+ }
+
+ /**
+ * Rotates hues around the color wheel.
+ */
public static Property rasterHueRotate(Float value) {
return new PaintProperty<>("raster-hue-rotate", value);
}
+ /**
+ * Rotates hues around the color wheel.
+ */
+ public static Property> rasterHueRotate(Function function) {
+ return new PaintProperty<>("raster-hue-rotate", function);
+ }
+
+ /**
+ * Increase or reduce the brightness of the image. The value is the minimum brightness.
+ */
public static Property rasterBrightnessMin(Float value) {
return new PaintProperty<>("raster-brightness-min", value);
}
+ /**
+ * Increase or reduce the brightness of the image. The value is the minimum brightness.
+ */
+ public static Property> rasterBrightnessMin(Function function) {
+ return new PaintProperty<>("raster-brightness-min", function);
+ }
+
+ /**
+ * Increase or reduce the brightness of the image. The value is the maximum brightness.
+ */
public static Property rasterBrightnessMax(Float value) {
return new PaintProperty<>("raster-brightness-max", value);
}
+ /**
+ * Increase or reduce the brightness of the image. The value is the maximum brightness.
+ */
+ public static Property> rasterBrightnessMax(Function function) {
+ return new PaintProperty<>("raster-brightness-max", function);
+ }
+
+ /**
+ * Increase or reduce the saturation of the image.
+ */
public static Property rasterSaturation(Float value) {
return new PaintProperty<>("raster-saturation", value);
}
+ /**
+ * Increase or reduce the saturation of the image.
+ */
+ public static Property> rasterSaturation(Function function) {
+ return new PaintProperty<>("raster-saturation", function);
+ }
+
+ /**
+ * Increase or reduce the contrast of the image.
+ */
public static Property rasterContrast(Float value) {
return new PaintProperty<>("raster-contrast", value);
}
+ /**
+ * Increase or reduce the contrast of the image.
+ */
+ public static Property> rasterContrast(Function function) {
+ return new PaintProperty<>("raster-contrast", function);
+ }
+
+ /**
+ * Fade duration when a new tile is added.
+ */
public static Property rasterFadeDuration(Float value) {
return new PaintProperty<>("raster-fade-duration", value);
}
+ /**
+ * Fade duration when a new tile is added.
+ */
+ public static Property> rasterFadeDuration(Function function) {
+ return new PaintProperty<>("raster-fade-duration", function);
+ }
+
+ /**
+ * The color with which the background will be drawn.
+ */
public static Property backgroundColor(@ColorInt int value) {
return new PaintProperty<>("background-color", colorToRgbaString(value));
}
+ /**
+ * The color with which the background will be drawn.
+ */
public static Property backgroundColor(String value) {
return new PaintProperty<>("background-color", value);
}
+ /**
+ * The color with which the background will be drawn.
+ */
+ public static Property> backgroundColor(Function function) {
+ return new PaintProperty<>("background-color", function);
+ }
+
+ /**
+ * Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).
+ */
public static Property backgroundPattern(String value) {
return new PaintProperty<>("background-pattern", value);
}
+ /**
+ * Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).
+ */
+ public static Property> backgroundPattern(Function function) {
+ return new PaintProperty<>("background-pattern", function);
+ }
+
+ /**
+ * The opacity at which the background will be drawn.
+ */
public static Property backgroundOpacity(Float value) {
return new PaintProperty<>("background-opacity", value);
}
+ /**
+ * The opacity at which the background will be drawn.
+ */
+ public static Property> backgroundOpacity(Function function) {
+ return new PaintProperty<>("background-opacity", function);
+ }
+
+ /**
+ * The display of line endings.
+ */
public static Property lineCap(@Property.LINE_CAP String value) {
return new LayoutProperty<>("line-cap", value);
}
+ /**
+ * The display of line endings.
+ */
+ public static Property> lineCap(Function function) {
+ return new LayoutProperty<>("line-cap", function);
+ }
+
+ /**
+ * The display of lines when joining.
+ */
public static Property lineJoin(@Property.LINE_JOIN String value) {
return new LayoutProperty<>("line-join", value);
}
+ /**
+ * The display of lines when joining.
+ */
+ public static Property> lineJoin(Function function) {
+ return new LayoutProperty<>("line-join", function);
+ }
+
+ /**
+ * Used to automatically convert miter joins to bevel joins for sharp angles.
+ */
public static Property lineMiterLimit(Float value) {
return new LayoutProperty<>("line-miter-limit", value);
}
+ /**
+ * Used to automatically convert miter joins to bevel joins for sharp angles.
+ */
+ public static Property> lineMiterLimit(Function function) {
+ return new LayoutProperty<>("line-miter-limit", function);
+ }
+
+ /**
+ * Used to automatically convert round joins to miter joins for shallow angles.
+ */
public static Property lineRoundLimit(Float value) {
return new LayoutProperty<>("line-round-limit", value);
}
+ /**
+ * Used to automatically convert round joins to miter joins for shallow angles.
+ */
+ public static Property> lineRoundLimit(Function