Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions plugin-annotation/scripts/annotation.java.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
void setUsedDataDrivenProperties() {
<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
if (!(jsonObject.get(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>) instanceof JsonNull)) {
annotationManager.enableDataDrivenProperty(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>);
if (!(jsonObject.get(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>) instanceof JsonNull)) {
annotationManager.enableDataDrivenProperty(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>);
}
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
if (!(jsonObject.get(<%- camelize(type) %>Options.PROPERTY_zIndex) instanceof JsonNull)) {
annotationManager.enableDataDrivenProperty(<%- camelize(type) %>Options.PROPERTY_zIndex);
if (!(jsonObject.get(<%- camelize(type) %>Options.PROPERTY_Z_INDEX) instanceof JsonNull)) {
annotationManager.enableDataDrivenProperty(<%- camelize(type) %>Options.PROPERTY_Z_INDEX);
}
<% } -%>
}
Expand Down Expand Up @@ -174,7 +174,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
* @param index the z-index value
*/
public void setZIndex(int index) {
jsonObject.addProperty(<%- camelize(type) %>Options.PROPERTY_zIndex, index);
jsonObject.addProperty(<%- camelize(type) %>Options.PROPERTY_Z_INDEX, index);
}

/**
Expand All @@ -183,7 +183,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
* @return the z-index value, 0 if not set
*/
public int getZIndex() {
return jsonObject.get(<%- camelize(type) %>Options.PROPERTY_zIndex).getAsInt();
return jsonObject.get(<%- camelize(type) %>Options.PROPERTY_Z_INDEX).getAsInt();
}
<% } -%>

Expand All @@ -202,7 +202,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
* @return PointF value for <%- propertyType(property) %>
*/
public PointF get<%- camelize(property.name) %>() {
JsonArray jsonArray = jsonObject.getAsJsonArray(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>);
JsonArray jsonArray = jsonObject.getAsJsonArray(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>);
return new PointF(jsonArray.get(0).getAsFloat(), jsonArray.get(1).getAsFloat());
}

Expand All @@ -221,7 +221,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
JsonArray jsonArray = new JsonArray();
jsonArray.add(pointF.x);
jsonArray.add(pointF.y);
jsonObject.add(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>, jsonArray);
jsonObject.add(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>, jsonArray);
}
<% } else { -%>

Expand All @@ -234,7 +234,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
* @return property wrapper value around <%- propertyType(property) %>
*/
public <%- propertyType(property) %> get<%- camelize(property.name) %>() {
JsonArray jsonArray = jsonObject.getAsJsonArray(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>);
JsonArray jsonArray = jsonObject.getAsJsonArray(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>);
<%- propertyType(property) %> value = new <%- propertyType(property).substring(0, propertyType(property).length-1) %>jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
value[i] = jsonArray.get(i).getAs<%- propertyType(property).substring(0, propertyType(property).length-2) %>();
Expand All @@ -258,7 +258,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
for (<%- propertyType(property).substring(0, propertyType(property).length-2) %> element : value) {
jsonArray.add(element);
}
jsonObject.add(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>, jsonArray);
jsonObject.add(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>, jsonArray);
}
<% } -%>
<% } else if (property.type == 'color') { -%>
Expand All @@ -273,7 +273,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
*/
@ColorInt
public int get<%- camelize(property.name) %>AsInt() {
return ColorUtils.rgbaToColor(jsonObject.get(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>).getAs<%- propertyType(property) %>());
return ColorUtils.rgbaToColor(jsonObject.get(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>).getAs<%- propertyType(property) %>());
}

/**
Expand All @@ -285,7 +285,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
* @return color value for <%- propertyType(property) %>
*/
public String get<%- camelize(property.name) %>() {
return jsonObject.get(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>).getAs<%- propertyType(property) %>();
return jsonObject.get(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>).getAs<%- propertyType(property) %>();
}

/**
Expand All @@ -300,7 +300,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
* @param color value for <%- propertyType(property) %>
*/
public void set<%- camelize(property.name) %>(@ColorInt int color) {
jsonObject.addProperty(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>, ColorUtils.colorToRgbaString(color));
jsonObject.addProperty(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>, ColorUtils.colorToRgbaString(color));
}

/**
Expand Down Expand Up @@ -328,7 +328,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
* @return property wrapper value around <%- propertyType(property) %>
*/
public <%- propertyType(property) %> get<%- camelize(property.name) %>() {
return jsonObject.get(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>).getAs<%- propertyType(property) %>();
return jsonObject.get(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>).getAs<%- propertyType(property) %>();
}

/**
Expand All @@ -343,7 +343,7 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
* @param value constant property value for <%- propertyType(property) %>
*/
public void set<%- camelize(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
jsonObject.addProperty(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>, value);
jsonObject.addProperty(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>, value);
}
<% } -%>
<% } -%>
Expand Down
18 changes: 9 additions & 9 deletions plugin-annotation/scripts/annotation_manager.java.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize

<% for (const property of properties) { -%>
<% if (!supportsPropertyFunction(property) && property.name !== "line-gradient" && property.name !== "symbol-z-order") { -%>
private static final String PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %> = "<%- property.name %>";
private static final String PROPERTY_<%- snakeCaseUpper(property.name) %> = "<%- property.name %>";
<% } -%>
<% } -%>

Expand Down Expand Up @@ -110,11 +110,11 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
void initializeDataDrivenPropertyMap() {
<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
dataDrivenPropertyUsageMap.put(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>, false);
dataDrivenPropertyUsageMap.put(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>, false);
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
dataDrivenPropertyUsageMap.put(<%- camelize(type) %>Options.PROPERTY_zIndex, false);
dataDrivenPropertyUsageMap.put(<%- camelize(type) %>Options.PROPERTY_Z_INDEX, false);
<% } -%>
}

Expand All @@ -123,13 +123,13 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
switch (property) {
<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
case <%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>:
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(get(<%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>)));
case <%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>:
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(get(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>)));
break;
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
case <%- camelize(type) %>Options.PROPERTY_zIndex:
case <%- camelize(type) %>Options.PROPERTY_Z_INDEX:
layer.setProperties(symbolZOrder(Property.SYMBOL_Z_ORDER_SOURCE));
break;
<% } -%>
Expand All @@ -144,7 +144,7 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
* All supported properties are:<br>
<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
* <%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %> - <%- propertyType(property) -%><br>
* <%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %> - <%- propertyType(property) -%><br>
<% } -%>
<% } -%>
* Learn more about above properties in the <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/">Style specification</a>.
Expand All @@ -171,7 +171,7 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
* All supported properties are:<br>
<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
* <%- camelize(type) %>Options.PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %> - <%- propertyType(property) -%><br>
* <%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %> - <%- propertyType(property) -%><br>
<% } -%>
<% } -%>
* Learn more about above properties in the <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/">Style specification</a>.
Expand Down Expand Up @@ -245,7 +245,7 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
*/
public void set<%- camelize(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), "") %> <%- propertyType(property) %> value) {
PropertyValue propertyValue = <%- camelizeWithLeadingLowercase(property.name) %>(value);
constantPropertyUsageMap.put(PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>, propertyValue);
constantPropertyUsageMap.put(PROPERTY_<%- snakeCaseUpper(property.name) %>, propertyValue);
layer.setProperties(propertyValue);
}

Expand Down
28 changes: 14 additions & 14 deletions plugin-annotation/scripts/annotation_options.java.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>

<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
static final String PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %> = "<%- property.name %>";
static final String PROPERTY_<%- snakeCaseUpper(property.name) %> = "<%- property.name %>";
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
static final String PROPERTY_zIndex = "z-index";
static final String PROPERTY_Z_INDEX = "z-index";
<% } -%>
private static final String PROPERTY_isDraggable = "is-draggable";
private static final String PROPERTY_IS_DRAGGABLE = "is-draggable";
<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>

Expand Down Expand Up @@ -215,14 +215,14 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
<% if (propertyType(property).endsWith("[]")) { -%>
jsonObject.add(PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>, convertArray(<%- camelizeWithLeadingLowercase(property.name) %>));
jsonObject.add(PROPERTY_<%- snakeCaseUpper(property.name) %>, convertArray(<%- camelizeWithLeadingLowercase(property.name) %>));
<% } else { -%>
jsonObject.addProperty(PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>, <%- camelizeWithLeadingLowercase(property.name) %>);
jsonObject.addProperty(PROPERTY_<%- snakeCaseUpper(property.name) %>, <%- camelizeWithLeadingLowercase(property.name) %>);
<% } -%>
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
jsonObject.addProperty(PROPERTY_zIndex, zIndex);
jsonObject.addProperty(PROPERTY_Z_INDEX, zIndex);
<% } -%>
<%- camelize(type) %> <%- type %> = new <%- camelize(type) %>(id, annotationManager, jsonObject, geometry);
<%- type %>.setDraggable(isDraggable);
Expand Down Expand Up @@ -253,23 +253,23 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
<% if (propertyType(property).endsWith("[]")) { -%>
if (feature.hasProperty(PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>)) {
options.<%- camelizeWithLeadingLowercase(property.name) %> = to<%- propertyType(property).slice(0, -2) -%>Array(feature.getProperty(PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>).getAsJsonArray());
if (feature.hasProperty(PROPERTY_<%- snakeCaseUpper(property.name) %>)) {
options.<%- camelizeWithLeadingLowercase(property.name) %> = to<%- propertyType(property).slice(0, -2) -%>Array(feature.getProperty(PROPERTY_<%- snakeCaseUpper(property.name) %>).getAsJsonArray());
}
<% } else { -%>
if (feature.hasProperty(PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>)) {
options.<%- camelizeWithLeadingLowercase(property.name) %> = feature.getProperty(PROPERTY_<%- camelizeWithLeadingLowercase(property.name) %>).getAs<%- propertyType(property) %>();
if (feature.hasProperty(PROPERTY_<%- snakeCaseUpper(property.name) %>)) {
options.<%- camelizeWithLeadingLowercase(property.name) %> = feature.getProperty(PROPERTY_<%- snakeCaseUpper(property.name) %>).getAs<%- propertyType(property) %>();
}
<% } -%>
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
if (feature.hasProperty(PROPERTY_zIndex)) {
options.zIndex = feature.getProperty(PROPERTY_zIndex).getAsInt();
if (feature.hasProperty(PROPERTY_Z_INDEX)) {
options.zIndex = feature.getProperty(PROPERTY_Z_INDEX).getAsInt();
}
<% } -%>
if (feature.hasProperty(PROPERTY_isDraggable)) {
options.isDraggable = feature.getProperty(PROPERTY_isDraggable).getAsBoolean();
if (feature.hasProperty(PROPERTY_IS_DRAGGABLE)) {
options.isDraggable = feature.getProperty(PROPERTY_IS_DRAGGABLE).getAsBoolean();
}
return options;
}
Expand Down
Loading