%
const paintProperties = locals.paintProperties;
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
*
* @see Layer style documentation
*/
public class PropertyFactory {
/**
* Set the property visibility.
*
* @param value the visibility value
* @return property wrapper around visibility
*/
public static PropertyValue visibility(@Property.VISIBILITY String value) {
return new LayoutPropertyValue<>("visibility", value);
}
/**
* Set the property visibility.
*
* @param the function input type
* @param function the visibility function
* @return property wrapper around a String function
*/
public static PropertyValue> visibility(Function 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 PropertyValue <%- 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 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 the function input type
* @param function a wrapper function for <%- propertyType(property) %>
* @return property wrapper around a <%- propertyType(property) %> function
*/
public static PropertyValue>> <%- camelizeWithLeadingLowercase(property.name) %>(Function> function) {
return new PaintPropertyValue<>("<%- property.name %>", function);
}
<% } else if (supportsZoomFunction(property)) { -%>
/**
* <%- propertyFactoryMethodDoc(property) %>
*
* @param the zoom parameter type
* @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
* @return property wrapper around a <%- propertyType(property) %> function
*/
public static PropertyValue>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction> 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 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 the function input type
* @param function a wrapper function for <%- propertyType(property) %>
* @return property wrapper around a <%- propertyType(property) %> function
*/
public static PropertyValue>> <%- camelizeWithLeadingLowercase(property.name) %>(Function> function) {
return new LayoutPropertyValue<>("<%- property.name %>", function);
}
<% } else if (supportsZoomFunction(property)) { -%>
/**
* <%- propertyFactoryMethodDoc(property) %>
*
* @param the zoom parameter type
* @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
* @return property wrapper around a <%- propertyType(property) %> function
*/
public static PropertyValue>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction> function) {
return new LayoutPropertyValue<>("<%- property.name %>", function);
}
<% } -%>
<% } -%>
@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);
}
}