Fix Android code generation templates & regenerate generated sources (#1239)

This commit is contained in:
Bart Louwers
2023-06-14 12:34:39 +02:00
committed by GitHub
parent 7bbfd30351
commit 4a24e468ed
9 changed files with 680 additions and 303 deletions

View File

@@ -48,7 +48,7 @@ public:
}; // class <%- camelize(type) %>Layer
class <%- camelize(type) %>JavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::<%- camelize(type) %>LayerFactory {
class <%- camelize(type) %>JavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::<%- camelize(type) %>LayerFactory {
public:
~<%- camelize(type) %>JavaLayerPeerFactory() override;
@@ -60,7 +60,7 @@ public:
LayerFactory* getLayerFactory() final { return this; }
}; // class <%- camelize(type) %>JavaLayerPeerFactory
}; // class <%- camelize(type) %>JavaLayerPeerFactory
} // namespace android
} // namespace mbgl

View File

@@ -16,7 +16,7 @@ import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.TransitionOptions;
/**
* Client-side hillshading visualization based on DEM data. Currently, the implementation only supports MapLibre Terrain RGB and Mapzen Terrarium tiles.
* Client-side hillshading visualization based on DEM data. Currently, the implementation only supports Mapbox Terrain RGB and Mapzen Terrarium tiles.
*
* @see <a href="https://maplibre.org/maplibre-style-spec/#layers-hillshade">The online documentation</a>
*/

View File

@@ -1806,7 +1806,7 @@ public class PropertyFactory {
}
/**
* If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like MapLibre GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.
* If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.
*
* @param value a Boolean value
* @return property wrapper around Boolean
@@ -1816,7 +1816,7 @@ public class PropertyFactory {
}
/**
* If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like MapLibre GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.
* If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.
*
* @param value a Boolean value
* @return property wrapper around Boolean

View File

@@ -1,87 +1,262 @@
<% const type = locals.type; const properties = locals.properties; const doc =
locals.doc; -%> // This file is generated. Edit scripts/generate-style-code.js,
then run `make style-code`. <% if (type === 'location-indicator') { -%> package
org.maplibre.android.location; <% } else { -%> package
org.maplibre.android.style.layers; <% } -%> import androidx.annotation.ColorInt;
import androidx.annotation.Keep; import androidx.annotation.NonNull; import
androidx.annotation.Nullable; import androidx.annotation.UiThread; import static
org.maplibre.android.utils.ColorUtils.rgbaToColor; import
com.google.gson.JsonArray; import com.google.gson.JsonElement; import
org.maplibre.android.style.expressions.Expression; import
org.maplibre.android.style.layers.TransitionOptions; <% if (type === 'symbol') {
-%> import org.maplibre.android.style.types.Formatted; import
org.maplibre.android.style.types.FormattedSection; <% } -%> <% if (type ===
'location-indicator') { -%> import org.maplibre.android.style.layers.Layer;
import org.maplibre.android.style.layers.PropertyValue; <% } -%> /** * <%- doc
%> * * @see
<a href="https://maplibre.org/maplibre-style-spec/#layers-<%- type %>"
>The online documentation</a
>
*/ @UiThread <% if (type === 'location-indicator') { -%> class <%-
camelize(type) %>Layer extends Layer { <% } else { -%> public class <%-
camelize(type) %>Layer extends Layer { <% } -%> /** * Creates a <%-
camelize(type) %>Layer. * * @param nativePtr pointer used by core */ @Keep <%-
camelize(type) %>Layer(long nativePtr) { super(nativePtr); } <% if (type ===
'background' || type === 'location-indicator') { -%> /** * Creates a <%-
camelize(type) %>Layer. * * @param layerId the id of the layer */ public <%-
camelize(type) %>Layer(String layerId) { super(); initialize(layerId); } @Keep
protected native void initialize(String layerId); <% } else { -%> /** * Creates
a <%- camelize(type) %>Layer. * * @param layerId the id of the layer * @param
sourceId the id of the source */ public <%- camelize(type) %>Layer(String
layerId, String sourceId) { super(); initialize(layerId, sourceId); } @Keep
protected native void initialize(String layerId, String sourceId); /** * Set the
source layer. * * @param sourceLayer the source layer to set */ public void
setSourceLayer(String sourceLayer) { checkThread();
nativeSetSourceLayer(sourceLayer); } /** * Set the source Layer. * * @param
sourceLayer the source layer to set * @return This */ @NonNull public <%-
camelize(type) %>Layer withSourceLayer(String sourceLayer) {
setSourceLayer(sourceLayer); return this; } <% } -%> <% if (type !==
'background' && type !== 'location-indicator' && type !== 'custom') { -%> /** *
Get the source id. * * @return id of the source */ @NonNull public String
getSourceId() { checkThread(); return nativeGetSourceId(); } <% } -%> <% if
(type !== 'background' && type !== 'location-indicator' && type !== 'raster' &&
type !== 'hillshade') { -%> /** * Get the source layer. * * @return sourceLayer
the source layer to get */ @NonNull public String getSourceLayer() {
checkThread(); return nativeGetSourceLayer(); } /** * Set a single expression
filter. * * @param filter the expression filter to set */ public void
setFilter(@NonNull Expression filter) { checkThread();
nativeSetFilter(filter.toArray()); } /** * Set a single expression filter. * *
@param filter the expression filter to set * @return This */ @NonNull public <%-
camelize(type) %>Layer withFilter(@NonNull Expression filter) {
setFilter(filter); return this; } /** * Get a single expression filter. * *
@return the expression filter to get */ @Nullable public Expression getFilter()
{ checkThread(); JsonElement jsonElement = nativeGetFilter(); if (jsonElement !=
null) { return Expression.Converter.convert(jsonElement); } else { return null;
} } <% } -%> /** * Set a property or properties. * * @param properties the
var-args properties * @return This */ @NonNull public <%- camelize(type) %>Layer
withProperties(@NonNull PropertyValue<?>... properties) {
setProperties(properties); return this; } // Property getters <% for (const
property of properties) { -%> /** * Get the <%- camelize(property.name) %>
property * * @return property wrapper value around <%- propertyType(property) %>
*/ @NonNull @SuppressWarnings("unchecked") public PropertyValue<<%-
propertyType(property) %>> get<%- camelize(property.name) %>() { checkThread();
return (PropertyValue<<%- propertyType(property) %>>) new PropertyValue("<%-
property.name %>", nativeGet<%- camelize(property.name) %>()); } <% if
(property.type == 'color') { -%> /** * <%- property.doc %> * * @return int
representation of a rgba string color * @throws RuntimeException thrown if
property isn't a value */ @ColorInt public int get<%- camelize(property.name)
%>AsInt() { checkThread(); 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"); } } <% } -%> <% if
(property.transition) { -%> /** * Get the <%- camelize(property.name) %>
property transition options * * @return transition options for <%-
propertyType(property) %> */ @NonNull public TransitionOptions get<%-
camelize(property.name) %>Transition() { checkThread(); return nativeGet<%-
camelize(property.name) %>Transition(); } /** * Set the <%-
camelize(property.name) %> property transition options * * @param options
transition options for <%- propertyType(property) %> */ public void set<%-
camelize(property.name) %>Transition(@NonNull TransitionOptions options) {
checkThread(); nativeSet<%- camelize(property.name)
%>Transition(options.getDuration(), options.getDelay()); } <% } -%> <% } -%> <%
for (const property of properties) { -%> @NonNull @Keep private native Object
nativeGet<%- camelize(property.name) %>(); <% if (property.transition) { -%>
@NonNull @Keep private native TransitionOptions nativeGet<%-
camelize(property.name) %>Transition(); @Keep private native void nativeSet<%-
camelize(property.name) %>Transition(long duration, long delay); <% } -%> <% }
-%> @Override @Keep protected native void finalize() throws Throwable; }
<%
const type = locals.type;
const properties = locals.properties;
const doc = locals.doc;
-%>
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
<% if (type === 'location-indicator') { -%>
package org.maplibre.android.location;
<% } else { -%>
package org.maplibre.android.style.layers;
<% } -%>
import androidx.annotation.ColorInt;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import static org.maplibre.android.utils.ColorUtils.rgbaToColor;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.TransitionOptions;
<% if (type === 'symbol') { -%>
import org.maplibre.android.style.types.Formatted;
import org.maplibre.android.style.types.FormattedSection;
<% } -%>
<% if (type === 'location-indicator') { -%>
import org.maplibre.android.style.layers.Layer;
import org.maplibre.android.style.layers.PropertyValue;
<% } -%>
/**
* <%- doc %>
*
* @see <a href="https://maplibre.org/maplibre-style-spec/#layers-<%- type %>">The online documentation</a>
*/
@UiThread
<% if (type === 'location-indicator') { -%>
class <%- camelize(type) %>Layer extends Layer {
<% } else { -%>
public class <%- camelize(type) %>Layer extends Layer {
<% } -%>
/**
* Creates a <%- camelize(type) %>Layer.
*
* @param nativePtr pointer used by core
*/
@Keep
<%- camelize(type) %>Layer(long nativePtr) {
super(nativePtr);
}
<% if (type === 'background' || type === 'location-indicator') { -%>
/**
* Creates a <%- camelize(type) %>Layer.
*
* @param layerId the id of the layer
*/
public <%- camelize(type) %>Layer(String layerId) {
super();
initialize(layerId);
}
@Keep
protected native void initialize(String layerId);
<% } else { -%>
/**
* Creates a <%- camelize(type) %>Layer.
*
* @param layerId the id of the layer
* @param sourceId the id of the source
*/
public <%- camelize(type) %>Layer(String layerId, String sourceId) {
super();
initialize(layerId, sourceId);
}
@Keep
protected native void initialize(String layerId, String sourceId);
/**
* Set the source layer.
*
* @param sourceLayer the source layer to set
*/
public void setSourceLayer(String sourceLayer) {
checkThread();
nativeSetSourceLayer(sourceLayer);
}
/**
* Set the source Layer.
*
* @param sourceLayer the source layer to set
* @return This
*/
@NonNull
public <%- camelize(type) %>Layer withSourceLayer(String sourceLayer) {
setSourceLayer(sourceLayer);
return this;
}
<% } -%>
<% if (type !== 'background' && type !== 'location-indicator' && type !== 'custom') { -%>
/**
* Get the source id.
*
* @return id of the source
*/
@NonNull
public String getSourceId() {
checkThread();
return nativeGetSourceId();
}
<% } -%>
<% if (type !== 'background' && type !== 'location-indicator' && type !== 'raster' && type !== 'hillshade') { -%>
/**
* Get the source layer.
*
* @return sourceLayer the source layer to get
*/
@NonNull
public String getSourceLayer() {
checkThread();
return nativeGetSourceLayer();
}
/**
* Set a single expression filter.
*
* @param filter the expression filter to set
*/
public void setFilter(@NonNull Expression filter) {
checkThread();
nativeSetFilter(filter.toArray());
}
/**
* Set a single expression filter.
*
* @param filter the expression filter to set
* @return This
*/
@NonNull
public <%- camelize(type) %>Layer withFilter(@NonNull Expression filter) {
setFilter(filter);
return this;
}
/**
* Get a single expression filter.
*
* @return the expression filter to get
*/
@Nullable
public Expression getFilter() {
checkThread();
JsonElement jsonElement = nativeGetFilter();
if (jsonElement != null) {
return Expression.Converter.convert(jsonElement);
} else {
return null;
}
}
<% } -%>
/**
* Set a property or properties.
*
* @param properties the var-args properties
* @return This
*/
@NonNull
public <%- camelize(type) %>Layer withProperties(@NonNull PropertyValue<?>... properties) {
setProperties(properties);
return this;
}
// Property getters
<% for (const property of properties) { -%>
/**
* Get the <%- camelize(property.name) %> property
*
* @return property wrapper value around <%- propertyType(property) %>
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<<%- propertyType(property) %>> get<%- camelize(property.name) %>() {
checkThread();
return (PropertyValue<<%- propertyType(property) %>>) new PropertyValue("<%- property.name %>", nativeGet<%- camelize(property.name) %>());
}
<% if (property.type == 'color') { -%>
/**
* <%- property.doc %>
*
* @return int representation of a rgba string color
* @throws RuntimeException thrown if property isn't a value
*/
@ColorInt
public int get<%- camelize(property.name) %>AsInt() {
checkThread();
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");
}
}
<% } -%>
<% if (property.transition) { -%>
/**
* Get the <%- camelize(property.name) %> property transition options
*
* @return transition options for <%- propertyType(property) %>
*/
@NonNull
public TransitionOptions get<%- camelize(property.name) %>Transition() {
checkThread();
return nativeGet<%- camelize(property.name) %>Transition();
}
/**
* Set the <%- camelize(property.name) %> property transition options
*
* @param options transition options for <%- propertyType(property) %>
*/
public void set<%- camelize(property.name) %>Transition(@NonNull TransitionOptions options) {
checkThread();
nativeSet<%- camelize(property.name) %>Transition(options.getDuration(), options.getDelay());
}
<% } -%>
<% } -%>
<% for (const property of properties) { -%>
@NonNull
@Keep
private native Object nativeGet<%- camelize(property.name) %>();
<% if (property.transition) { -%>
@NonNull
@Keep
private native TransitionOptions nativeGet<%- camelize(property.name) %>Transition();
@Keep
private native void nativeSet<%- camelize(property.name) %>Transition(long duration, long delay);
<% } -%>
<% } -%>
@Override
@Keep
protected native void finalize() throws Throwable;
}

View File

@@ -1,70 +1,115 @@
<% const paintProperties = locals.paintProperties; const layoutProperties =
locals.layoutProperties; const locationIndicator = locals.locationIndicator; -%>
// This file is generated. Edit scripts/generate-style-code.js, then run `make
style-code`. <% if (locationIndicator) { -%> package
org.maplibre.android.location; <% } else { -%> package
org.maplibre.android.style.layers; <% } -%> import androidx.annotation.ColorInt;
import org.maplibre.android.style.expressions.Expression; import
org.maplibre.android.style.types.Formatted; import static
org.maplibre.android.utils.ColorUtils.colorToRgbaString; <% if
(locationIndicator) { -%> import
org.maplibre.android.style.layers.LayoutPropertyValue; import
org.maplibre.android.style.layers.PaintPropertyValue; import
org.maplibre.android.style.layers.Property; import
org.maplibre.android.style.layers.PropertyValue; <% } -%> /** * Constructs
paint/layout properties for Layers * * @see
<a href="https://maplibre.org/maplibre-style-spec/#layers"
>Layer style documentation</a
>
*/ <% if (locationIndicator) { -%> class LocationPropertyFactory { <% } else {
-%> public class PropertyFactory { <% } -%> /** * 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); } <% 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<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 PropertyValue<<%-
propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name)
%>(<%- propertyTypeAnnotation(property) %><%- iff(() =>
propertyTypeAnnotation(property), " ") %><%- propertyType(property) %>
value) { return new PaintPropertyValue<>("<%- property.name %>", value); }
/** * <%- propertyFactoryMethodDoc(property) %> * * @param expression an
expression statement * @return property wrapper around an expression
statement */ public static PropertyValue<Expression>
<%- camelizeWithLeadingLowercase(property.name) %>(Expression expression)
{ return new PaintPropertyValue<>("<%- property.name %>", expression); }
<% } -%> <% for (const property of layoutProperties) { -%> <% if
(property.type === 'formatted') { -%> /** * <%-
propertyFactoryMethodDoc(property) %> * * @param value a String value *
@return property wrapper around String */ public static
PropertyValue<String>
<%- camelizeWithLeadingLowercase(property.name) %>(String value) {
return new LayoutPropertyValue<>("<%- property.name %>", 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 LayoutPropertyValue<>("<%- property.name %>",
value); } /** * <%- propertyFactoryMethodDoc(property) %> * * @param
value a <%- propertyType(property) %> value * @return property wrapper
around <%- propertyType(property) %> */ public static
PropertyValue<Expression>
<%- camelizeWithLeadingLowercase(property.name) %>(Expression value) {
return new LayoutPropertyValue<>("<%- property.name %>", value); } <%
} -%> }
</Expression></String
></Expression
></String
></String
>
<%
const paintProperties = locals.paintProperties;
const layoutProperties = locals.layoutProperties;
const locationIndicator = locals.locationIndicator;
-%>
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
<% if (locationIndicator) { -%>
package org.maplibre.android.location;
<% } else { -%>
package org.maplibre.android.style.layers;
<% } -%>
import androidx.annotation.ColorInt;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.types.Formatted;
import static org.maplibre.android.utils.ColorUtils.colorToRgbaString;
<% if (locationIndicator) { -%>
import org.maplibre.android.style.layers.LayoutPropertyValue;
import org.maplibre.android.style.layers.PaintPropertyValue;
import org.maplibre.android.style.layers.Property;
import org.maplibre.android.style.layers.PropertyValue;
<% } -%>
/**
* Constructs paint/layout properties for Layers
*
* @see <a href="https://maplibre.org/maplibre-style-spec/#layers">Layer style documentation</a>
*/
<% if (locationIndicator) { -%>
class LocationPropertyFactory {
<% } else { -%>
public class PropertyFactory {
<% } -%>
/**
* 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);
}
<% 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<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 PropertyValue<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
return new PaintPropertyValue<>("<%- property.name %>", value);
}
/**
* <%- propertyFactoryMethodDoc(property) %>
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> <%- camelizeWithLeadingLowercase(property.name) %>(Expression expression) {
return new PaintPropertyValue<>("<%- property.name %>", expression);
}
<% } -%>
<% for (const property of layoutProperties) { -%>
<% if (property.type === 'formatted') { -%>
/**
* <%- propertyFactoryMethodDoc(property) %>
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> <%- camelizeWithLeadingLowercase(property.name) %>(String value) {
return new LayoutPropertyValue<>("<%- property.name %>", 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 LayoutPropertyValue<>("<%- property.name %>", value);
}
/**
* <%- propertyFactoryMethodDoc(property) %>
*
* @param value a <%- propertyType(property) %> value
* @return property wrapper around <%- propertyType(property) %>
*/
public static PropertyValue<Expression> <%- camelizeWithLeadingLowercase(property.name) %>(Expression value) {
return new LayoutPropertyValue<>("<%- property.name %>", value);
}
<% } -%>
}

View File

@@ -1,61 +1,154 @@
<% const properties = locals.properties; const doc = locals.doc; -%> // This
file is generated. Edit scripts/generate-style-code.js, then run `make
style-code`. package org.maplibre.android.style.light; import
androidx.annotation.ColorInt; import androidx.annotation.Keep; import
androidx.annotation.NonNull; import androidx.annotation.UiThread; import
org.maplibre.android.style.layers.Property; import
org.maplibre.android.style.layers.TransitionOptions; import
org.maplibre.android.utils.ColorUtils; import
org.maplibre.android.utils.ThreadUtils; /** * The global light source. * * @see
<a href="https://maplibre.org/maplibre-style-spec/#light"
>The online documentation</a
>
*/ @UiThread public class Light { private static final String TAG =
"Mbgl-Light"; @Keep private long nativePtr; /** * Creates a Light. * * @param
nativePtr pointer used by core */ @Keep Light(long nativePtr) { checkThread();
this.nativePtr = nativePtr; } <% for (const property of properties) { -%> <% if
(property.name == "position") {-%> /** * Set the <%- camelize(property.name) %>
property. <%- property.doc %> * * @param position of the light */ public void
set<%- camelize(property.name) %>(@NonNull Position position) { checkThread();
nativeSet<%- camelize(property.name) %>(position); } /** * Get the <%-
camelize(property.name) %> property. <%- property.doc %> * * @return <%-
property.name %> as Position */ @NonNull public Position get<%-
camelize(property.name) %>() { checkThread(); return nativeGet<%-
camelize(property.name) %>(); } <% } else { -%> <% if (property.name == "color")
{-%> /** * Set the <%- camelize(property.name) %> property. <%- property.doc %>
* * @param <%- property.name %> as int */ public void set<%-
camelize(property.name) %>(@ColorInt int <%- property.name %>) { checkThread();
nativeSet<%- camelize(property.name) %>(ColorUtils.colorToRgbaString(<%-
property.name %>)); } <% } -%> /** * Set the <%- camelize(property.name) %>
property. <%- property.doc %> * * @param <%- property.name %> as <%-
propertyType(property) %> */ public void set<%- camelize(property.name) %>(<%-
propertyTypeAnnotation(property) %><%- iff(() =>
propertyTypeAnnotation(property), " ") %><%- propertyJavaType(property) %> <%-
property.name %>) { checkThread(); nativeSet<%- camelize(property.name) %>(<%-
property.name %>); } /** * Get the <%- camelize(property.name) %> property. <%-
property.doc %> * * @return <%- property.name %> as <%- propertyType(property)
%> */ @NonNull <%- propertyTypeAnnotation(property) %> public <%-
propertyJavaType(property) %> get<%- camelize(property.name) %>() {
checkThread(); return nativeGet<%- camelize(property.name) %>(); } <% } -%> <%
if (property.transition) { -%> /** * Get the <%- camelize(property.name) %>
property transition options. * * @return transition options for <%-
property.name %> */ @NonNull public TransitionOptions get<%-
camelize(property.name) %>Transition() { checkThread(); return nativeGet<%-
camelize(property.name) %>Transition(); } /** * Set the <%-
camelize(property.name) %> property transition options. * * @param options
transition options for <%- property.name %> */ public void set<%-
camelize(property.name) %>Transition(@NonNull TransitionOptions options) {
checkThread(); nativeSet<%- camelize(property.name)
%>Transition(options.getDuration(), options.getDelay()); } <% } -%> <% } -%>
private void checkThread(){ ThreadUtils.checkThread(TAG); } <% for (const
property of properties) { -%> <% if (property.name == "position") {-%> @Keep
private native void nativeSet<%- camelize(property.name) %>(Position position);
@NonNull @Keep private native Position nativeGet<%- camelize(property.name)
%>(); <% } else { -%> @Keep private native void nativeSet<%-
camelize(property.name) %>(<%- propertyJavaType(property) -%> <%- property.name
%>); @NonNull @Keep private native <%- propertyJavaType(property) -%>
nativeGet<%- camelize(property.name) %>(); <% } -%> <% if (property.transition)
{ -%> @NonNull @Keep private native TransitionOptions nativeGet<%-
camelize(property.name) %>Transition(); @Keep private native void nativeSet<%-
camelize(property.name) %>Transition(long duration, long delay); <% } -%> <% }
-%> }
<%
const properties = locals.properties;
const doc = locals.doc;
-%>
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package org.maplibre.android.style.light;
import androidx.annotation.ColorInt;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.UiThread;
import org.maplibre.android.style.layers.Property;
import org.maplibre.android.style.layers.TransitionOptions;
import org.maplibre.android.utils.ColorUtils;
import org.maplibre.android.utils.ThreadUtils;
/**
* The global light source.
*
* @see <a href="https://maplibre.org/maplibre-style-spec/#light">The online documentation</a>
*/
@UiThread
public class Light {
private static final String TAG = "Mbgl-Light";
@Keep
private long nativePtr;
/**
* Creates a Light.
*
* @param nativePtr pointer used by core
*/
@Keep
Light(long nativePtr) {
checkThread();
this.nativePtr = nativePtr;
}
<% for (const property of properties) { -%>
<% if (property.name == "position") {-%>
/**
* Set the <%- camelize(property.name) %> property. <%- property.doc %>
*
* @param position of the light
*/
public void set<%- camelize(property.name) %>(@NonNull Position position) {
checkThread();
nativeSet<%- camelize(property.name) %>(position);
}
/**
* Get the <%- camelize(property.name) %> property. <%- property.doc %>
*
* @return <%- property.name %> as Position
*/
@NonNull
public Position get<%- camelize(property.name) %>() {
checkThread();
return nativeGet<%- camelize(property.name) %>();
}
<% } else { -%>
<% if (property.name == "color") {-%>
/**
* Set the <%- camelize(property.name) %> property. <%- property.doc %>
*
* @param <%- property.name %> as int
*/
public void set<%- camelize(property.name) %>(@ColorInt int <%- property.name %>) {
checkThread();
nativeSet<%- camelize(property.name) %>(ColorUtils.colorToRgbaString(<%- property.name %>));
}
<% } -%>
/**
* Set the <%- camelize(property.name) %> property. <%- property.doc %>
*
* @param <%- property.name %> as <%- propertyType(property) %>
*/
public void set<%- camelize(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyJavaType(property) %> <%- property.name %>) {
checkThread();
nativeSet<%- camelize(property.name) %>(<%- property.name %>);
}
/**
* Get the <%- camelize(property.name) %> property. <%- property.doc %>
*
* @return <%- property.name %> as <%- propertyType(property) %>
*/
@NonNull
<%- propertyTypeAnnotation(property) %> public <%- propertyJavaType(property) %> get<%- camelize(property.name) %>() {
checkThread();
return nativeGet<%- camelize(property.name) %>();
}
<% } -%>
<% if (property.transition) { -%>
/**
* Get the <%- camelize(property.name) %> property transition options.
*
* @return transition options for <%- property.name %>
*/
@NonNull
public TransitionOptions get<%- camelize(property.name) %>Transition() {
checkThread();
return nativeGet<%- camelize(property.name) %>Transition();
}
/**
* Set the <%- camelize(property.name) %> property transition options.
*
* @param options transition options for <%- property.name %>
*/
public void set<%- camelize(property.name) %>Transition(@NonNull TransitionOptions options) {
checkThread();
nativeSet<%- camelize(property.name) %>Transition(options.getDuration(), options.getDelay());
}
<% } -%>
<% } -%>
private void checkThread(){
ThreadUtils.checkThread(TAG);
}
<% for (const property of properties) { -%>
<% if (property.name == "position") {-%>
@Keep
private native void nativeSet<%- camelize(property.name) %>(Position position);
@NonNull
@Keep
private native Position nativeGet<%- camelize(property.name) %>();
<% } else { -%>
@Keep
private native void nativeSet<%- camelize(property.name) %>(<%- propertyJavaType(property) -%> <%- property.name %>);
@NonNull
@Keep
private native <%- propertyJavaType(property) -%> nativeGet<%- camelize(property.name) %>();
<% } -%>
<% if (property.transition) { -%>
@NonNull
@Keep
private native TransitionOptions nativeGet<%- camelize(property.name) %>Transition();
@Keep
private native void nativeSet<%- camelize(property.name) %>Transition(long duration, long delay);
<% } -%>
<% } -%>
}