summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-08-03 16:03:03 -0400
committerIvo van Dongen <info@ivovandongen.nl>2016-08-03 18:34:23 -0400
commit52cb6122f87a6769fad4c4d826b49cd95a37c83b (patch)
tree11d4548c3ee19639d72102b42ffd8d62ed9a6f66 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style
parentf94c97988615071d7b03bacec015d667ee1b4116 (diff)
downloadqtlocation-mapboxgl-52cb6122f87a6769fad4c4d826b49cd95a37c83b.tar.gz
[android] #5858 - added convenience methods for color properties
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java31
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java54
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java67
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java68
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java31
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java175
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs44
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java21
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java23
9 files changed, 437 insertions, 77 deletions
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 f7a71155ad..fae68c518e 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
@@ -1,6 +1,13 @@
// 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 com.mapbox.mapboxsdk.exceptions.ConversionException;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+
+import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
+
/**
* Background Layer
*/
@@ -17,6 +24,11 @@ public class BackgroundLayer extends Layer {
protected native void initialize(String layerId);
+ public BackgroundLayer withProperties(@NonNull Property<?>... properties) {
+ setProperties(properties);
+ return this;
+ }
+
// Property getters
@SuppressWarnings("unchecked")
@@ -24,19 +36,34 @@ public class BackgroundLayer extends Layer {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetBackgroundColor());
}
+ /**
+ * The color with which the background will be drawn.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getBackgroundColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getBackgroundColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("background-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getBackgroundPattern() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetBackgroundPattern());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getBackgroundOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetBackgroundOpacity());
}
-
+
private native Object nativeGetBackgroundColor();
private native Object nativeGetBackgroundPattern();
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 6628fee47a..ce0e9fd5bd 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
@@ -1,6 +1,13 @@
// 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 com.mapbox.mapboxsdk.exceptions.ConversionException;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+
+import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
+
/**
* Circle Layer
*/
@@ -21,6 +28,11 @@ public class CircleLayer extends Layer {
nativeSetSourceLayer(sourceLayer);
}
+ public CircleLayer withSourceLayer(String sourceLayer) {
+ setSourceLayer(sourceLayer);
+ return this;
+ }
+
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
@@ -31,6 +43,21 @@ public class CircleLayer extends Layer {
nativeSetFilter(filter);
}
+ public CircleLayer withFilter(Object[] filter) {
+ setFilter(filter);
+ return this;
+ }
+
+ public CircleLayer withFilter(Filter.Statement filter) {
+ setFilter(filter);
+ return this;
+ }
+
+
+ public CircleLayer withProperties(@NonNull Property<?>... properties) {
+ setProperties(properties);
+ return this;
+ }
// Property getters
@@ -39,43 +66,58 @@ public class CircleLayer extends Layer {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleRadius());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getCircleColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetCircleColor());
}
+ /**
+ * The color of the circle.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getCircleColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getCircleColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("circle-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleBlur() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleBlur());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleOpacity());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getCircleTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetCircleTranslate());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getCircleTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetCircleTranslateAnchor());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getCirclePitchScale() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetCirclePitchScale());
}
-
+
private native Object nativeGetCircleRadius();
private native Object nativeGetCircleColor();
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 7938af3c80..d188129e2a 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
@@ -1,6 +1,13 @@
// 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 com.mapbox.mapboxsdk.exceptions.ConversionException;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+
+import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
+
/**
* Fill Layer
*/
@@ -21,6 +28,11 @@ public class FillLayer extends Layer {
nativeSetSourceLayer(sourceLayer);
}
+ public FillLayer withSourceLayer(String sourceLayer) {
+ setSourceLayer(sourceLayer);
+ return this;
+ }
+
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
@@ -31,6 +43,21 @@ public class FillLayer extends Layer {
nativeSetFilter(filter);
}
+ public FillLayer withFilter(Object[] filter) {
+ setFilter(filter);
+ return this;
+ }
+
+ public FillLayer withFilter(Filter.Statement filter) {
+ setFilter(filter);
+ return this;
+ }
+
+
+ public FillLayer withProperties(@NonNull Property<?>... properties) {
+ setProperties(properties);
+ return this;
+ }
// Property getters
@@ -39,43 +66,73 @@ public class FillLayer extends Layer {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetFillAntialias());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getFillOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetFillOpacity());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getFillColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetFillColor());
}
+ /**
+ * 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.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getFillColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getFillColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("fill-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getFillOutlineColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetFillOutlineColor());
}
+ /**
+ * The outline color of the fill. Matches the value of `fill-color` if unspecified.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getFillOutlineColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getFillOutlineColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("fill-outline-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getFillTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetFillTranslate());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getFillTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetFillTranslateAnchor());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getFillPattern() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetFillPattern());
}
-
+
private native Object nativeGetFillAntialias();
private native Object nativeGetFillOpacity();
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 11cd709f49..ab5dd0815e 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
@@ -1,6 +1,13 @@
// 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 com.mapbox.mapboxsdk.exceptions.ConversionException;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+
+import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
+
/**
* Line Layer
*/
@@ -21,6 +28,11 @@ public class LineLayer extends Layer {
nativeSetSourceLayer(sourceLayer);
}
+ public LineLayer withSourceLayer(String sourceLayer) {
+ setSourceLayer(sourceLayer);
+ return this;
+ }
+
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
@@ -31,6 +43,21 @@ public class LineLayer extends Layer {
nativeSetFilter(filter);
}
+ public LineLayer withFilter(Object[] filter) {
+ setFilter(filter);
+ return this;
+ }
+
+ public LineLayer withFilter(Filter.Statement filter) {
+ setFilter(filter);
+ return this;
+ }
+
+
+ public LineLayer withProperties(@NonNull Property<?>... properties) {
+ setProperties(properties);
+ return this;
+ }
// Property getters
@@ -39,85 +66,100 @@ public class LineLayer extends Layer {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLineCap());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getLineJoin() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLineJoin());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineMiterLimit() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineMiterLimit());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineRoundLimit() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineRoundLimit());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineOpacity());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getLineColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLineColor());
}
+ /**
+ * The color with which the line will be drawn.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getLineColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getLineColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("line-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getLineTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetLineTranslate());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getLineTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLineTranslateAnchor());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineWidth());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineGapWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineGapWidth());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineOffset() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineOffset());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineBlur() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineBlur());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getLineDasharray() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetLineDasharray());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getLinePattern() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLinePattern());
}
-
+
private native Object nativeGetLineCap();
private native Object nativeGetLineJoin();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java
index 1cbe5fb387..a6872cef0f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java
@@ -1,6 +1,13 @@
// 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 com.mapbox.mapboxsdk.exceptions.ConversionException;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+
+import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
+
/**
* Raster Layer
*/
@@ -21,6 +28,16 @@ public class RasterLayer extends Layer {
nativeSetSourceLayer(sourceLayer);
}
+ public RasterLayer withSourceLayer(String sourceLayer) {
+ setSourceLayer(sourceLayer);
+ return this;
+ }
+
+
+ public RasterLayer withProperties(@NonNull Property<?>... properties) {
+ setProperties(properties);
+ return this;
+ }
// Property getters
@@ -29,43 +46,43 @@ public class RasterLayer extends Layer {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterOpacity());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterHueRotate() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterHueRotate());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterBrightnessMin() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterBrightnessMin());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterBrightnessMax() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterBrightnessMax());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterSaturation() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterSaturation());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterContrast() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterContrast());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterFadeDuration() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterFadeDuration());
}
-
+
private native Object nativeGetRasterOpacity();
private native Object nativeGetRasterHueRotate();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
index 281b4fc028..ccbfdb411f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
@@ -1,6 +1,13 @@
// 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 com.mapbox.mapboxsdk.exceptions.ConversionException;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+
+import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
+
/**
* Symbol Layer
*/
@@ -21,6 +28,11 @@ public class SymbolLayer extends Layer {
nativeSetSourceLayer(sourceLayer);
}
+ public SymbolLayer withSourceLayer(String sourceLayer) {
+ setSourceLayer(sourceLayer);
+ return this;
+ }
+
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
@@ -31,6 +43,21 @@ public class SymbolLayer extends Layer {
nativeSetFilter(filter);
}
+ public SymbolLayer withFilter(Object[] filter) {
+ setFilter(filter);
+ return this;
+ }
+
+ public SymbolLayer withFilter(Filter.Statement filter) {
+ setFilter(filter);
+ return this;
+ }
+
+
+ public SymbolLayer withProperties(@NonNull Property<?>... properties) {
+ setProperties(properties);
+ return this;
+ }
// Property getters
@@ -39,289 +66,349 @@ public class SymbolLayer extends Layer {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetSymbolPlacement());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getSymbolSpacing() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetSymbolSpacing());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getSymbolAvoidEdges() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetSymbolAvoidEdges());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getIconAllowOverlap() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconAllowOverlap());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getIconIgnorePlacement() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconIgnorePlacement());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getIconOptional() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconOptional());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconRotationAlignment() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconRotationAlignment());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconSize() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconSize());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconTextFit() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconTextFit());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getIconTextFitPadding() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconTextFitPadding());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconImage() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconImage());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconRotate() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconRotate());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconPadding() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconPadding());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getIconKeepUpright() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconKeepUpright());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getIconOffset() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconOffset());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextPitchAlignment() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextPitchAlignment());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextRotationAlignment() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextRotationAlignment());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextField() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextField());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String[]> getTextFont() {
checkValidity();
return (PropertyValue<String[]>) new PropertyValue(nativeGetTextFont());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextSize() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextSize());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextMaxWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextMaxWidth());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextLineHeight() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextLineHeight());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextLetterSpacing() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextLetterSpacing());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextJustify() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextJustify());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextAnchor());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextMaxAngle() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextMaxAngle());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextRotate() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextRotate());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextPadding() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextPadding());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getTextKeepUpright() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextKeepUpright());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextTransform() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextTransform());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getTextOffset() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetTextOffset());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getTextAllowOverlap() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextAllowOverlap());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getTextIgnorePlacement() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextIgnorePlacement());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getTextOptional() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextOptional());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconOpacity());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconColor());
}
+ /**
+ * The color of the icon. This can only be used with sdf icons.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getIconColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getIconColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("icon-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconHaloColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconHaloColor());
}
+ /**
+ * The color of the icon's halo. Icon halos can only be used with sdf icons.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getIconHaloColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getIconHaloColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("icon-halo-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconHaloWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconHaloWidth());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconHaloBlur() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconHaloBlur());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getIconTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconTranslate());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconTranslateAnchor());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextOpacity());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextColor());
}
+ /**
+ * The color with which the text will be drawn.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getTextColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getTextColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("text-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextHaloColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextHaloColor());
}
+ /**
+ * The color of the text's halo, which helps it stand out from backgrounds.
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int getTextHaloColorAsInt() {
+ checkValidity();
+ PropertyValue<String> value = getTextHaloColor();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("text-halo-color was set as a Function");
+ }
+ }
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextHaloWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextHaloWidth());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextHaloBlur() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextHaloBlur());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getTextTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetTextTranslate());
}
-
+
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextTranslateAnchor());
}
-
+
private native Object nativeGetSymbolPlacement();
private native Object nativeGetSymbolSpacing();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs
index 79bf98d389..00d9f09124 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs
@@ -5,6 +5,13 @@
// 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 com.mapbox.mapboxsdk.exceptions.ConversionException;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+
+import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
+
/**
* <%- camelize(type) %> Layer
*/
@@ -31,6 +38,11 @@ public class <%- camelize(type) %>Layer extends Layer {
checkValidity();
nativeSetSourceLayer(sourceLayer);
}
+
+ public <%- camelize(type) %>Layer withSourceLayer(String sourceLayer) {
+ setSourceLayer(sourceLayer);
+ return this;
+ }
<% } -%>
<% if (type !== 'background' && type !== 'raster') { -%>
@@ -44,8 +56,23 @@ public class <%- camelize(type) %>Layer extends Layer {
nativeSetFilter(filter);
}
+ public <%- camelize(type) %>Layer withFilter(Object[] filter) {
+ setFilter(filter);
+ return this;
+ }
+
+ public <%- camelize(type) %>Layer withFilter(Filter.Statement filter) {
+ setFilter(filter);
+ return this;
+ }
+
<% } -%>
+ public <%- camelize(type) %>Layer withProperties(@NonNull Property<?>... properties) {
+ setProperties(properties);
+ return this;
+ }
+
// Property getters
<% for (const property of properties) { -%>
@@ -54,6 +81,23 @@ public class <%- camelize(type) %>Layer extends Layer {
checkValidity();
return (PropertyValue<<%- propertyType(property) %>>) new PropertyValue(nativeGet<%- camelize(property.name) %>());
}
+ <% if (property.type == 'color') { -%>
+ /**
+ * <%- property.doc %>
+ * @throws RuntimeException
+ */
+ @ColorInt
+ public int get<%- camelize(property.name) %>AsInt() {
+ checkValidity();
+ PropertyValue<<%- propertyType(property) %>> value = get<%- camelize(property.name) %>();
+ if (value.isValue()) {
+ return rgbaToColor(value.getValue());
+ } else {
+ throw new RuntimeException("<%- property.name %> was set as a Function");
+ }
+ }
+
+ <% } -%>
<% } -%>
<% for (const property of properties) { -%>
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
index f1399daf12..fc7928015e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
@@ -3,12 +3,27 @@ package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
import java.util.HashMap;
+/**
+ * A GeoJson source.
+ *
+ * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">the style specification</a>
+ */
public class GeoJsonSource extends Source {
public static final String TYPE = "geojson";
private static final String DATA_KEY = "data";
+ /**
+ * Create a GeoJsonSource from a raw json string
+ *
+ * @param id the source id
+ * @param geoJson raw Json body
+ */
public GeoJsonSource(String id, String geoJson) {
super(id, TYPE);
+ if (geoJson == null || geoJson.startsWith("http")) {
+ throw new IllegalArgumentException("Expected a raw json body");
+ }
+
//Wrap the String in a map as an Object is expected by the
//style conversion template
HashMap<String, String> wrapper = new HashMap<>();
@@ -16,6 +31,12 @@ public class GeoJsonSource extends Source {
this.put(DATA_KEY, wrapper);
}
+ /**
+ * Create a GeoJsonSource from a remote geo json file
+ *
+ * @param id the source id
+ * @param url remote json file
+ */
public GeoJsonSource(String id, URL url) {
super(id, TYPE);
this.put(DATA_KEY, url.toExternalForm());
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
index df3b73368c..381294083a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
@@ -2,19 +2,42 @@ package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
+/**
+ * A vector source.
+ *
+ * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-vector">the style specification</a>
+ */
public class VectorSource extends Source {
public static final String TYPE = "vector";
private static final String URL_KEY = "url";
+ /**
+ * Create a vector source from a remote url
+ *
+ * @param id the source id
+ * @param url the url
+ */
public VectorSource(String id, URL url) {
this(id, url.toExternalForm());
}
+ /**
+ * Create a vector source from a remote url
+ *
+ * @param id the source id
+ * @param url the url
+ */
public VectorSource(String id, String url) {
super(id, TYPE);
this.put(URL_KEY, url);
}
+ /**
+ * Create a vector source from a tilset
+ *
+ * @param id the source id
+ * @param tileSet the tileset
+ */
public VectorSource(String id, TileSet tileSet) {
super(id, TYPE);
this.putAll(tileSet.toValueObject());