summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-01-17 17:43:49 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-02 09:44:42 -0800
commitf562ecdfc3a08f7b9b0c2be938f237852a82d374 (patch)
tree71c3ceb4b2a877d124f4b069fa80156d701a6125 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs
parent8a5bff8ee630673c6ebc496322eab94a41ae9353 (diff)
downloadqtlocation-mapboxgl-f562ecdfc3a08f7b9b0c2be938f237852a82d374.tar.gz
[android] data driven style implementation
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs180
1 files changed, 110 insertions, 70 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs
index e9b7b6dcd1..2d3421d1d9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs
@@ -3,11 +3,15 @@
const layoutProperties = locals.layoutProperties;
-%>
// 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.annotation.SuppressLint;
import android.support.annotation.ColorInt;
+import com.mapbox.mapboxsdk.style.functions.Function;
+import com.mapbox.mapboxsdk.style.functions.CameraFunction;
+
/**
* Constructs paint/layout properties for Layers
*
@@ -15,85 +19,121 @@ import android.support.annotation.ColorInt;
*/
public class PropertyFactory {
- /**
- * Set the property visibility.
- *
- * @param value the visibility value
- * @return property wrapper around visibility
- */
- public static Property<String> visibility(@Property.VISIBILITY String value) {
- return new LayoutProperty<>("visibility", value);
- }
-
- /**
- * Set the property visibility.
- *
- * @param function the visibility function
- * @return property wrapper around a String function
- */
- public static Property<Function<String>> visibility(Function<String> function) {
- return new LayoutProperty<>("visibility", function);
- }
+ /**
+ * Set the property visibility.
+ *
+ * @param value the visibility value
+ * @return property wrapper around visibility
+ */
+ public static PropertyValue<String> visibility(@Property.VISIBILITY String value) {
+ return new LayoutPropertyValue<>("visibility", value);
+ }
+
+ /**
+ * Set the property visibility.
+ *
+ * @param <T> the function input type
+ * @param function the visibility function
+ * @return property wrapper around a String function
+ */
+ public static <T> PropertyValue<Function<T, String>> visibility(Function<T, String> function) {
+ return new LayoutPropertyValue<>("visibility", function);
+ }
<% for (const property of paintProperties) { -%>
<% if (property.type == 'color') { -%>
- /**
- * <%- propertyFactoryMethodDoc(property) %>
- *
- * @param value a int color value
- * @return property wrapper around String color
- */
- public static Property<String> <%- camelizeWithLeadingLowercase(property.name) %>(@ColorInt int value) {
- return new PaintProperty<>("<%- property.name %>", colorToRgbaString(value));
- }
+ /**
+ * <%- propertyFactoryMethodDoc(property) %>
+ *
+ * @param value a int color value
+ * @return property wrapper around String color
+ */
+ public static PropertyValue<String> <%- camelizeWithLeadingLowercase(property.name) %>(@ColorInt int value) {
+ return new PaintPropertyValue<>("<%- property.name %>", colorToRgbaString(value));
+ }
<% } -%>
- /**
- * <%- propertyFactoryMethodDoc(property) %>
- *
- * @param value a <%- propertyType(property) %> value
- * @return property wrapper around <%- propertyType(property) %>
- */
- public static Property<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
- return new PaintProperty<>("<%- property.name %>", value);
- }
-
- /**
- * <%- propertyFactoryMethodDoc(property) %>
- *
- * @param function a wrapper function for <%- propertyType(property) %>
- * @return property wrapper around a <%- propertyType(property) %> function
- */
- public static Property<Function<<%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<<%- propertyType(property) %>> function) {
- return new PaintProperty<>("<%- property.name %>", function);
- }
+ /**
+ * <%- propertyFactoryMethodDoc(property) %>
+ *
+ * @param value a <%- propertyType(property) %> value
+ * @return property wrapper around <%- propertyType(property) %>
+ */
+ public static PropertyValue<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
+ return new PaintPropertyValue<>("<%- property.name %>", value);
+ }
+
+<% if (supportsPropertyFunction(property)) { -%>
+
+ /**
+ * <%- propertyFactoryMethodDoc(property) %>
+ *
+ * @param <T> the function input type
+ * @param function a wrapper function for <%- propertyType(property) %>
+ * @return property wrapper around a <%- propertyType(property) %> function
+ */
+ public static <T> PropertyValue<Function<T, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<T, <%- propertyType(property) %>> function) {
+ return new PaintPropertyValue<>("<%- property.name %>", function);
+ }
+
+<% } else if (supportsZoomFunction(property)) { -%>
+
+ /**
+ * <%- propertyFactoryMethodDoc(property) %>
+ *
+ * @param <Z> the zoom parameter type
+ * @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
+ * @return property wrapper around a <%- propertyType(property) %> function
+ */
+ public static <Z extends Number> PropertyValue<CameraFunction<Z, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction<Z, <%- propertyType(property) %>> function) {
+ return new PaintPropertyValue<>("<%- property.name %>", function);
+ }
<% } -%>
+<% } -%>
<% for (const property of layoutProperties) { -%>
- /**
- * <%- propertyFactoryMethodDoc(property) %>
- *
- * @param value a <%- propertyType(property) %> value
- * @return property wrapper around <%- propertyType(property) %>
- */
- public static Property<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
- return new LayoutProperty<>("<%- property.name %>", value);
- }
-
- /**
- * <%- propertyFactoryMethodDoc(property) %>
- *
- * @param function a wrapper function for <%- propertyType(property) %>
- * @return property wrapper around a <%- propertyType(property) %> function
- */
- public static Property<Function<<%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<<%- propertyType(property) %>> function) {
- return new LayoutProperty<>("<%- property.name %>", function);
- }
+ /**
+ * <%- propertyFactoryMethodDoc(property) %>
+ *
+ * @param value a <%- propertyType(property) %> value
+ * @return property wrapper around <%- propertyType(property) %>
+ */
+ public static PropertyValue<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
+ return new LayoutPropertyValue<>("<%- property.name %>", value);
+ }
+
+
+<% if (supportsPropertyFunction(property)) { -%>
+
+ /**
+ * <%- propertyFactoryMethodDoc(property) %>
+ *
+ * @param <T> the function input type
+ * @param function a wrapper function for <%- propertyType(property) %>
+ * @return property wrapper around a <%- propertyType(property) %> function
+ */
+ public static <T> PropertyValue<Function<T, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<T, <%- propertyType(property) %>> function) {
+ return new LayoutPropertyValue<>("<%- property.name %>", function);
+ }
+<% } else if (supportsZoomFunction(property)) { -%>
+
+ /**
+ * <%- propertyFactoryMethodDoc(property) %>
+ *
+ * @param <Z> the zoom parameter type
+ * @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
+ * @return property wrapper around a <%- propertyType(property) %> function
+ */
+ public static <Z extends Number> PropertyValue<CameraFunction<Z, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction<Z, <%- propertyType(property) %>> function) {
+ return new LayoutPropertyValue<>("<%- property.name %>", function);
+ }
+
+<% } -%>
<% } -%>
- @SuppressLint("DefaultLocale")
- static String colorToRgbaString(@ColorInt int value) {
- return String.format("rgba(%d, %d, %d, %d)", (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF);
- }
+ @SuppressLint("DefaultLocale")
+ public static String colorToRgbaString(@ColorInt int value) {
+ return String.format("rgba(%d, %d, %d, %d)", (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF);
+ }
}