diff options
author | Lauren Budorick <lauren@mapbox.com> | 2017-04-27 15:56:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-27 15:56:55 -0700 |
commit | f6e79d70735361438655f279c8699a786d25458c (patch) | |
tree | cc01ae7aba097bae4aa84beb12ac6b8f34f4d51a /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style | |
parent | 839ad87f37a4880804fb4c79157d998ac59954b5 (diff) | |
download | qtlocation-mapboxgl-f6e79d70735361438655f279c8699a786d25458c.tar.gz |
[core] Render fill-extrusion layers (#8431)
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style')
3 files changed, 524 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java new file mode 100644 index 0000000000..6772da73b1 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java @@ -0,0 +1,339 @@ +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. + +package com.mapbox.mapboxsdk.style.layers; + +import android.support.annotation.ColorInt; +import android.support.annotation.NonNull; +import android.support.annotation.UiThread; + +import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; + +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; + +/** + * An extruded (3D) polygon. + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-fill-extrusion">The online documentation</a> + */ +@UiThread +public class FillExtrusionLayer extends Layer { + + /** + * Creates a FillExtrusionLayer. + * + * @param nativePtr pointer used by core + */ + public FillExtrusionLayer(long nativePtr) { + super(nativePtr); + } + + /** + * Creates a FillExtrusionLayer. + * + * @param layerId the id of the layer + * @param sourceId the id of the source + */ + public FillExtrusionLayer(String layerId, String sourceId) { + initialize(layerId, sourceId); + } + + protected native void initialize(String layerId, String sourceId); + + /** + * Set the source layer. + * + * @param sourceLayer the source layer to set + */ + public void setSourceLayer(String sourceLayer) { + nativeSetSourceLayer(sourceLayer); + } + + /** + * Set the source Layer. + * + * @param sourceLayer the source layer to set + * @return This + */ + public FillExtrusionLayer withSourceLayer(String sourceLayer) { + setSourceLayer(sourceLayer); + return this; + } + + /** + * Get the source layer. + * + * @return sourceLayer the source layer to get + */ + public String getSourceLayer() { + return nativeGetSourceLayer(); + } + + /** + * Set a single filter. + * + * @param filter the filter to set + */ + public void setFilter(Filter.Statement filter) { + nativeSetFilter(filter.toArray()); + } + + /** + * Set a single filter. + * + * @param filter the filter to set + * @return This + */ + public FillExtrusionLayer withFilter(Filter.Statement filter) { + setFilter(filter); + return this; + } + + /** + * Set a property or properties. + * + * @param properties the var-args properties + * @return This + */ + public FillExtrusionLayer withProperties(@NonNull PropertyValue<?>... properties) { + setProperties(properties); + return this; + } + + // Property getters + + /** + * Get the FillExtrusionOpacity property + * + * @return property wrapper value around Float + */ + @SuppressWarnings("unchecked") + public PropertyValue<Float> getFillExtrusionOpacity() { + return (PropertyValue<Float>) new PropertyValue("fill-extrusion-opacity", nativeGetFillExtrusionOpacity()); + } + + /** + * Get the FillExtrusionOpacity property transition options + * + * @return transition options for Float + */ + public TransitionOptions getFillExtrusionOpacityTransition() { + return nativeGetFillExtrusionOpacityTransition(); + } + + /** + * Set the FillExtrusionOpacity property transition options + * + * @param options transition options for Float + */ + public void setFillExtrusionOpacityTransition(TransitionOptions options) { + nativeSetFillExtrusionOpacityTransition(options.getDuration(), options.getDelay()); + } + + /** + * Get the FillExtrusionColor property + * + * @return property wrapper value around String + */ + @SuppressWarnings("unchecked") + public PropertyValue<String> getFillExtrusionColor() { + return (PropertyValue<String>) new PropertyValue("fill-extrusion-color", nativeGetFillExtrusionColor()); + } + + /** + * The base color of the extruded fill. The extrusion's surfaces will be shaded differently based on this color in combination with the root `light` settings. If this color is specified as `rgba` with an alpha component, the alpha component will be ignored; use `fill-extrusion-opacity` to set layer opacity. + * + * @return int representation of a rgba string color + * @throws RuntimeException thrown if property isn't a value + */ + @ColorInt + public int getFillExtrusionColorAsInt() { + PropertyValue<String> value = getFillExtrusionColor(); + if (value.isValue()) { + return rgbaToColor(value.getValue()); + } else { + throw new RuntimeException("fill-extrusion-color was set as a Function"); + } + } + + /** + * Get the FillExtrusionColor property transition options + * + * @return transition options for String + */ + public TransitionOptions getFillExtrusionColorTransition() { + return nativeGetFillExtrusionColorTransition(); + } + + /** + * Set the FillExtrusionColor property transition options + * + * @param options transition options for String + */ + public void setFillExtrusionColorTransition(TransitionOptions options) { + nativeSetFillExtrusionColorTransition(options.getDuration(), options.getDelay()); + } + + /** + * Get the FillExtrusionTranslate property + * + * @return property wrapper value around Float[] + */ + @SuppressWarnings("unchecked") + public PropertyValue<Float[]> getFillExtrusionTranslate() { + return (PropertyValue<Float[]>) new PropertyValue("fill-extrusion-translate", nativeGetFillExtrusionTranslate()); + } + + /** + * Get the FillExtrusionTranslate property transition options + * + * @return transition options for Float[] + */ + public TransitionOptions getFillExtrusionTranslateTransition() { + return nativeGetFillExtrusionTranslateTransition(); + } + + /** + * Set the FillExtrusionTranslate property transition options + * + * @param options transition options for Float[] + */ + public void setFillExtrusionTranslateTransition(TransitionOptions options) { + nativeSetFillExtrusionTranslateTransition(options.getDuration(), options.getDelay()); + } + + /** + * Get the FillExtrusionTranslateAnchor property + * + * @return property wrapper value around String + */ + @SuppressWarnings("unchecked") + public PropertyValue<String> getFillExtrusionTranslateAnchor() { + return (PropertyValue<String>) new PropertyValue("fill-extrusion-translate-anchor", nativeGetFillExtrusionTranslateAnchor()); + } + + /** + * Get the FillExtrusionPattern property + * + * @return property wrapper value around String + */ + @SuppressWarnings("unchecked") + public PropertyValue<String> getFillExtrusionPattern() { + return (PropertyValue<String>) new PropertyValue("fill-extrusion-pattern", nativeGetFillExtrusionPattern()); + } + + /** + * Get the FillExtrusionPattern property transition options + * + * @return transition options for String + */ + public TransitionOptions getFillExtrusionPatternTransition() { + return nativeGetFillExtrusionPatternTransition(); + } + + /** + * Set the FillExtrusionPattern property transition options + * + * @param options transition options for String + */ + public void setFillExtrusionPatternTransition(TransitionOptions options) { + nativeSetFillExtrusionPatternTransition(options.getDuration(), options.getDelay()); + } + + /** + * Get the FillExtrusionHeight property + * + * @return property wrapper value around Float + */ + @SuppressWarnings("unchecked") + public PropertyValue<Float> getFillExtrusionHeight() { + return (PropertyValue<Float>) new PropertyValue("fill-extrusion-height", nativeGetFillExtrusionHeight()); + } + + /** + * Get the FillExtrusionHeight property transition options + * + * @return transition options for Float + */ + public TransitionOptions getFillExtrusionHeightTransition() { + return nativeGetFillExtrusionHeightTransition(); + } + + /** + * Set the FillExtrusionHeight property transition options + * + * @param options transition options for Float + */ + public void setFillExtrusionHeightTransition(TransitionOptions options) { + nativeSetFillExtrusionHeightTransition(options.getDuration(), options.getDelay()); + } + + /** + * Get the FillExtrusionBase property + * + * @return property wrapper value around Float + */ + @SuppressWarnings("unchecked") + public PropertyValue<Float> getFillExtrusionBase() { + return (PropertyValue<Float>) new PropertyValue("fill-extrusion-base", nativeGetFillExtrusionBase()); + } + + /** + * Get the FillExtrusionBase property transition options + * + * @return transition options for Float + */ + public TransitionOptions getFillExtrusionBaseTransition() { + return nativeGetFillExtrusionBaseTransition(); + } + + /** + * Set the FillExtrusionBase property transition options + * + * @param options transition options for Float + */ + public void setFillExtrusionBaseTransition(TransitionOptions options) { + nativeSetFillExtrusionBaseTransition(options.getDuration(), options.getDelay()); + } + + private native Object nativeGetFillExtrusionOpacity(); + + private native TransitionOptions nativeGetFillExtrusionOpacityTransition(); + + private native void nativeSetFillExtrusionOpacityTransition(long duration, long delay); + + private native Object nativeGetFillExtrusionColor(); + + private native TransitionOptions nativeGetFillExtrusionColorTransition(); + + private native void nativeSetFillExtrusionColorTransition(long duration, long delay); + + private native Object nativeGetFillExtrusionTranslate(); + + private native TransitionOptions nativeGetFillExtrusionTranslateTransition(); + + private native void nativeSetFillExtrusionTranslateTransition(long duration, long delay); + + private native Object nativeGetFillExtrusionTranslateAnchor(); + + private native Object nativeGetFillExtrusionPattern(); + + private native TransitionOptions nativeGetFillExtrusionPatternTransition(); + + private native void nativeSetFillExtrusionPatternTransition(long duration, long delay); + + private native Object nativeGetFillExtrusionHeight(); + + private native TransitionOptions nativeGetFillExtrusionHeightTransition(); + + private native void nativeSetFillExtrusionHeightTransition(long duration, long delay); + + private native Object nativeGetFillExtrusionBase(); + + private native TransitionOptions nativeGetFillExtrusionBaseTransition(); + + private native void nativeSetFillExtrusionBaseTransition(long duration, long delay); + + @Override + protected native void finalize() throws Throwable; + +} 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 641ee551a2..48e0ec5de3 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 @@ -446,6 +446,27 @@ public final class Property { @Retention(RetentionPolicy.SOURCE) public @interface CIRCLE_PITCH_SCALE {} + // FILL_EXTRUSION_TRANSLATE_ANCHOR: Controls the translation reference point. + + /** + * The fill extrusion is translated relative to the map. + */ + public static final String FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP = "map"; + /** + * The fill extrusion is translated relative to the viewport. + */ + public static final String FILL_EXTRUSION_TRANSLATE_ANCHOR_VIEWPORT = "viewport"; + + /** + * Controls the translation reference point. + */ + @StringDef({ + FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP, + FILL_EXTRUSION_TRANSLATE_ANCHOR_VIEWPORT, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface FILL_EXTRUSION_TRANSLATE_ANCHOR {} + private Property() { } 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 e37245000e..e4ea9676fa 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 @@ -1029,6 +1029,170 @@ public class PropertyFactory { } /** + * The opacity of the entire fill extrusion layer. This is rendered on a per-layer, not per-feature, basis, and data-driven styling is not available. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue<Float> fillExtrusionOpacity(Float value) { + return new PaintPropertyValue<>("fill-extrusion-opacity", value); + } + + + /** + * The opacity of the entire fill extrusion layer. This is rendered on a per-layer, not per-feature, basis, and data-driven styling is not available. + * + * @param <Z> the zoom parameter type + * @param function a wrapper {@link CameraFunction} for Float + * @return property wrapper around a Float function + */ + public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> fillExtrusionOpacity(CameraFunction<Z, Float> function) { + return new PaintPropertyValue<>("fill-extrusion-opacity", function); + } + + /** + * The base color of the extruded fill. The extrusion's surfaces will be shaded differently based on this color in combination with the root `light` settings. If this color is specified as `rgba` with an alpha component, the alpha component will be ignored; use {@link PropertyFactory#fillExtrusionOpacity} to set layer opacity. + * + * @param value a int color value + * @return property wrapper around String color + */ + public static PropertyValue<String> fillExtrusionColor(@ColorInt int value) { + return new PaintPropertyValue<>("fill-extrusion-color", colorToRgbaString(value)); + } + + /** + * The base color of the extruded fill. The extrusion's surfaces will be shaded differently based on this color in combination with the root `light` settings. If this color is specified as `rgba` with an alpha component, the alpha component will be ignored; use {@link PropertyFactory#fillExtrusionOpacity} to set layer opacity. + * + * @param value a String value + * @return property wrapper around String + */ + public static PropertyValue<String> fillExtrusionColor(String value) { + return new PaintPropertyValue<>("fill-extrusion-color", value); + } + + + /** + * The base color of the extruded fill. The extrusion's surfaces will be shaded differently based on this color in combination with the root `light` settings. If this color is specified as `rgba` with an alpha component, the alpha component will be ignored; use {@link PropertyFactory#fillExtrusionOpacity} to set layer opacity. + * + * @param <T> the function input type + * @param function a wrapper function for String + * @return property wrapper around a String function + */ + public static <T> PropertyValue<Function<T, String>> fillExtrusionColor(Function<T, String> function) { + return new PaintPropertyValue<>("fill-extrusion-color", function); + } + + /** + * The geometry's offset. Values are [x, y] where negatives indicate left and up (on the flat plane), respectively. + * + * @param value a Float[] value + * @return property wrapper around Float[] + */ + public static PropertyValue<Float[]> fillExtrusionTranslate(Float[] value) { + return new PaintPropertyValue<>("fill-extrusion-translate", value); + } + + + /** + * The geometry's offset. Values are [x, y] where negatives indicate left and up (on the flat plane), respectively. + * + * @param <Z> the zoom parameter type + * @param function a wrapper {@link CameraFunction} for Float[] + * @return property wrapper around a Float[] function + */ + public static <Z extends Number> PropertyValue<CameraFunction<Z, Float[]>> fillExtrusionTranslate(CameraFunction<Z, Float[]> function) { + return new PaintPropertyValue<>("fill-extrusion-translate", function); + } + + /** + * Controls the translation reference point. + * + * @param value a String value + * @return property wrapper around String + */ + public static PropertyValue<String> fillExtrusionTranslateAnchor(@Property.FILL_EXTRUSION_TRANSLATE_ANCHOR String value) { + return new PaintPropertyValue<>("fill-extrusion-translate-anchor", value); + } + + + /** + * Controls the translation reference point. + * + * @param <Z> the zoom parameter type + * @param function a wrapper {@link CameraFunction} for String + * @return property wrapper around a String function + */ + public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> fillExtrusionTranslateAnchor(CameraFunction<Z, String> function) { + return new PaintPropertyValue<>("fill-extrusion-translate-anchor", function); + } + + /** + * Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). + * + * @param value a String value + * @return property wrapper around String + */ + public static PropertyValue<String> fillExtrusionPattern(String value) { + return new PaintPropertyValue<>("fill-extrusion-pattern", value); + } + + + /** + * Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). + * + * @param <Z> the zoom parameter type + * @param function a wrapper {@link CameraFunction} for String + * @return property wrapper around a String function + */ + public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> fillExtrusionPattern(CameraFunction<Z, String> function) { + return new PaintPropertyValue<>("fill-extrusion-pattern", function); + } + + /** + * The height with which to extrude this layer. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue<Float> fillExtrusionHeight(Float value) { + return new PaintPropertyValue<>("fill-extrusion-height", value); + } + + + /** + * The height with which to extrude this layer. + * + * @param <T> the function input type + * @param function a wrapper function for Float + * @return property wrapper around a Float function + */ + public static <T> PropertyValue<Function<T, Float>> fillExtrusionHeight(Function<T, Float> function) { + return new PaintPropertyValue<>("fill-extrusion-height", function); + } + + /** + * The height with which to extrude the base of this layer. Must be less than or equal to {@link PropertyFactory#fillExtrusionHeight}. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue<Float> fillExtrusionBase(Float value) { + return new PaintPropertyValue<>("fill-extrusion-base", value); + } + + + /** + * The height with which to extrude the base of this layer. Must be less than or equal to {@link PropertyFactory#fillExtrusionHeight}. + * + * @param <T> the function input type + * @param function a wrapper function for Float + * @return property wrapper around a Float function + */ + public static <T> PropertyValue<Function<T, Float>> fillExtrusionBase(Function<T, Float> function) { + return new PaintPropertyValue<>("fill-extrusion-base", function); + } + + /** * The opacity at which the image will be drawn. * * @param value a Float value |