Add PropertyFactory.iconPadding(Float) overload for better backcompat (#2880)

This commit is contained in:
Alexey Kon
2024-10-01 09:48:01 -07:00
committed by GitHub
parent 7d19efbdde
commit 56f6c5f5cf
4 changed files with 32 additions and 0 deletions

View File

@@ -2047,6 +2047,16 @@ The unit is in density-independent pixels only for SDF sprites that were created
return new LayoutPropertyValue<>("icon-rotate", value);
}
/**
* Size of additional area round the icon bounding box used for detecting symbol collisions.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> iconPadding(Float value) {
return new LayoutPropertyValue<>("icon-padding", value);
}
/**
* Size of additional area round the icon bounding box used for detecting symbol collisions.
*

View File

@@ -90,6 +90,18 @@ public class PropertyFactory {
return new LayoutPropertyValue<>("<%- property.name %>", value);
}
<% } -%>
<% if (property.type === 'padding') { -%>
/**
* <%- propertyFactoryMethodDoc(property) %>
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> <%- camelizeWithLeadingLowercase(property.name) %>(Float value) {
return new LayoutPropertyValue<>("<%- property.name %>", value);
}
<% } -%>
/**
* <%- propertyFactoryMethodDoc(property) %>

View File

@@ -425,6 +425,10 @@ public class SymbolLayerTest extends BaseLayerTest {
Float[] propertyValue = {2.0f, 2.0f, 2.0f, 2.0f};
layer.setProperties(iconPadding(propertyValue));
assertEquals(layer.getIconPadding().getValue(), propertyValue);
// Single number value can be used too for backward compatibility
Float number = propertyValue[0] + 1.0f;
layer.setProperties(iconPadding(number));
assertEquals(layer.getIconPadding().getValue(), new Float[]{number, number, number, number});
}
@Test

View File

@@ -232,6 +232,12 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
<% } -%>
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(propertyValue));
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
<% if (property.type === 'padding') { -%>
// Single number value can be used too for backward compatibility
Float number = propertyValue[0] + 1.0f;
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(number));
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), new Float[]{number, number, number, number});
<% } -%>
<% if (property.tokens) { -%>
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("{token}"));