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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "plugin-annotation/gl-js"]
path = plugin-annotation/gl-js
url = https://github.com/mapbox/mapbox-gl-js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ public void testTextLineHeightAsConstant() {
});
}

@Test
public void testTextVariableAnchorAsConstant() {
validateTestSetup();
setupSymbolManager();
Timber.i("text-variable-anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(symbolManager);

symbolManager.setTextVariableAnchor(new String[]{TEXT_ANCHOR_RIGHT, TEXT_ANCHOR_TOP});
assertEquals((String[]) symbolManager.getTextVariableAnchor(), (String[]) new String[]{TEXT_ANCHOR_RIGHT, TEXT_ANCHOR_TOP});
});
}

@Test
public void testTextMaxAngleAsConstant() {
validateTestSetup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ private void setupAnnotation() {
});
}

@Test
public void testSymbolSortKey() {
validateTestSetup();
setupAnnotation();
Timber.i("symbol-sort-key");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(symbol);

symbol.setSymbolSortKey(0.3f);
assertEquals((Float) symbol.getSymbolSortKey(), (Float) 0.3f);
});
}

@Test
public void testIconSize() {
validateTestSetup();
Expand Down Expand Up @@ -182,8 +195,21 @@ public void testTextJustify() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(symbol);

symbol.setTextJustify(TEXT_JUSTIFY_LEFT);
assertEquals((String) symbol.getTextJustify(), (String) TEXT_JUSTIFY_LEFT);
symbol.setTextJustify(TEXT_JUSTIFY_AUTO);
assertEquals((String) symbol.getTextJustify(), (String) TEXT_JUSTIFY_AUTO);
});
}

@Test
public void testTextRadialOffset() {
validateTestSetup();
setupAnnotation();
Timber.i("text-radial-offset");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(symbol);

symbol.setTextRadialOffset(0.3f);
assertEquals((Float) symbol.getTextRadialOffset(), (Float) 0.3f);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected void onCreate(Bundle savedInstanceState) {
.withLatLng(new LatLng(6.687337, 0.381457))
.withIconImage(ID_ICON_AIRPORT)
.withIconSize(1.3f)
.withZIndex(10)
.withSymbolSortKey(10.0f)
.withDraggable(true);
symbol = symbolManager.create(symbolOptions);
Timber.e(symbol.toString());
Expand All @@ -109,7 +109,7 @@ protected void onCreate(Bundle savedInstanceState) {
.withIconImage(MAKI_ICON_CIRCLE)
.withIconColor(ColorUtils.colorToRgbaString(Color.YELLOW))
.withIconSize(2.5f)
.withZIndex(5)
.withSymbolSortKey(5.0f)
.withDraggable(true);
symbolManager.create(nearbyOptions);

Expand Down Expand Up @@ -196,7 +196,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
} else if (item.getItemId() == R.id.menu_action_text_size) {
symbol.setTextSize(22f);
} else if (item.getItemId() == R.id.menu_action_z_index) {
symbol.setZIndex(0);
symbol.setSymbolSortKey(0.0f);
} else if (item.getItemId() == R.id.menu_action_halo) {
symbol.setIconHaloWidth(5.0f);
symbol.setIconHaloColor(Color.RED);
Expand Down
6 changes: 6 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- run:
name: Init submodules
command: git submodule update --init --recursive
- save_cache:
paths:
- ~/.gradle
Expand Down Expand Up @@ -85,6 +88,9 @@ jobs:
IS_LOCAL_DEVELOPMENT: false
steps:
- checkout
- run:
name: Init submodules
command: git submodule update --init --recursive
- run:
name: Generate Maven credentials
shell: /bin/bash -euo pipefail
Expand Down
1 change: 1 addition & 0 deletions plugin-annotation/gl-js
Submodule gl-js added at 429633
31 changes: 0 additions & 31 deletions plugin-annotation/scripts/annotation.java.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
annotationManager.enableDataDrivenProperty(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>);
}
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
if (!(jsonObject.get(<%- camelize(type) %>Options.PROPERTY_Z_INDEX) instanceof JsonNull)) {
annotationManager.enableDataDrivenProperty(<%- camelize(type) %>Options.PROPERTY_Z_INDEX);
}
<% } -%>
}
<% if (type === "circle" || type === "symbol") { -%>
Expand Down Expand Up @@ -160,32 +155,6 @@ public class <%- camelize(type) %> extends Annotation<<%- geometryType(type) %>>
return latLngs;
}
<% } -%>
<% if (type === "symbol") { -%>

/**
* Set the z-index of a symbol.
* <p>
* If a symbol z-index is higher as another symbol it will be rendered above it.
* </p>
* <p>
* Default value is 0.
* </p>
*
* @param index the z-index value
*/
public void setZIndex(int index) {
jsonObject.addProperty(<%- camelize(type) %>Options.PROPERTY_Z_INDEX, index);
}

/**
* Get the z-index of a symbol.
*
* @return the z-index value, 0 if not set
*/
public int getZIndex() {
return jsonObject.get(<%- camelize(type) %>Options.PROPERTY_Z_INDEX).getAsInt();
}
<% } -%>

// Property accessors
<% for (const property of properties) { -%>
Expand Down
20 changes: 1 addition & 19 deletions plugin-annotation/scripts/annotation_manager.java.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize

@VisibleForTesting
<%- camelize(type) %>Manager(@NonNull MapView mapView, @NonNull MapboxMap mapboxMap, @NonNull Style style, @NonNull CoreElementProvider<<%- camelize(type) %>Layer> coreElementProvider, @Nullable String belowLayerId, @Nullable GeoJsonOptions geoJsonOptions, DraggableAnnotationController<<%- camelize(type) %>, On<%- camelize(type) %>DragListener> draggableAnnotationController) {
<% if (type === "symbol") { -%>
super(mapView, mapboxMap, style, coreElementProvider, new SymbolComparator(), draggableAnnotationController, belowLayerId, geoJsonOptions);
<% } else { -%>
super(mapView, mapboxMap, style, coreElementProvider, null, draggableAnnotationController, belowLayerId, geoJsonOptions);
<% } -%>
super(mapView, mapboxMap, style, coreElementProvider, draggableAnnotationController, belowLayerId, geoJsonOptions);
}

@Override
Expand All @@ -92,9 +88,6 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
<% if (supportsPropertyFunction(property)) { -%>
dataDrivenPropertyUsageMap.put(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>, false);
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
dataDrivenPropertyUsageMap.put(<%- camelize(type) %>Options.PROPERTY_Z_INDEX, false);
<% } -%>
}

Expand All @@ -107,11 +100,6 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(get(<%- camelize(type) %>Options.PROPERTY_<%- snakeCaseUpper(property.name) %>)));
break;
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
case <%- camelize(type) %>Options.PROPERTY_Z_INDEX:
layer.setProperties(symbolZOrder(Property.SYMBOL_Z_ORDER_SOURCE));
break;
<% } -%>
}
}
Expand All @@ -130,9 +118,6 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
* Learn more about above properties in the <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/">Style specification</a>.
* <p>
* Out of spec properties:<br>
<% if (type === "symbol") { -%>
* "z-index" - Integer, z-index of the feature within the manager<br>
<% } -%>
* "is-draggable" - Boolean, true if the <%- type %> should be draggable, false otherwise
*
* @param json the GeoJSON defining the list of <%- type %>s to build
Expand All @@ -157,9 +142,6 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
* Learn more about above properties in the <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/">Style specification</a>.
* <p>
* Out of spec properties:<br>
<% if (type === "symbol") { -%>
* "z-index" - Integer, z-index of the feature within the manager<br>
<% } -%>
* "is-draggable" - Boolean, true if the <%- type %> should be draggable, false otherwise
*
* @param featureCollection the featureCollection defining the list of <%- type %>s to build
Expand Down
21 changes: 0 additions & 21 deletions plugin-annotation/scripts/annotation_manager_unit_test.junit.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ public class <%- camelize(type) %>ManagerTest {
feature.add<%- propertyType(property) -%>Property("<%- property.name %>", <%- defaultValueJava(property) %>);
<% } -%>
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
feature.addNumberProperty("z-index", 2);
<% } -%>
feature.addBooleanProperty("is-draggable", true);

Expand All @@ -234,9 +231,6 @@ public class <%- camelize(type) %>ManagerTest {
assertEquals(<%- type %>.get<%- camelize(property.name) %>(), <%- defaultValueJava(property) %>);
<% } -%>
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
assertEquals(<%- type %>.getZIndex(), 2);
<% } -%>
assertTrue(<%- type %>.isDraggable());
}
Expand Down Expand Up @@ -465,21 +459,6 @@ public class <%- camelize(type) %>ManagerTest {
<% } -%>
<% } -%>

<% if (type === "symbol") { -%>
@Test
public void testSymbolZOrderLayerProperty() {
<%- type %>Manager = new <%- camelize(type) %>Manager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
verify(<%- type %>Layer, times(0)).setProperties(argThat(new PropertyValueMatcher(symbolZOrder(Property.SYMBOL_Z_ORDER_SOURCE))));

<%- camelize(type) %>Options options = new <%- camelize(type) %>Options().withLatLng(new LatLng());
<%- type %>Manager.create(options);
verify(<%- type %>Layer, times(1)).setProperties(argThat(new PropertyValueMatcher(symbolZOrder(Property.SYMBOL_Z_ORDER_SOURCE))));

<%- type %>Manager.create(options);
verify(<%- type %>Layer, times(1)).setProperties(argThat(new PropertyValueMatcher(symbolZOrder(Property.SYMBOL_Z_ORDER_SOURCE))));
}
<% } -%>

@Test
public void test<%- camelize(type) %>LayerFilter() {
<%- type %>Manager = new <%- camelize(type) %>Manager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
Expand Down
39 changes: 0 additions & 39 deletions plugin-annotation/scripts/annotation_options.java.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,11 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
private <%- propertyType(property) %> <%- camelizeWithLeadingLowercase(property.name) %>;
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
private int zIndex;
<% } -%>

<% for (const property of properties) { -%>
<% if (supportsPropertyFunction(property)) { -%>
static final String PROPERTY_<%- snakeCaseUpper(property.name) %> = "<%- property.name %>";
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
static final String PROPERTY_Z_INDEX = "z-index";
<% } -%>
private static final String PROPERTY_IS_DRAGGABLE = "is-draggable";
<% for (const property of properties) { -%>
Expand Down Expand Up @@ -234,31 +228,6 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
return geometry;
}
<% } -%>
<% if (type === "symbol") { -%>

/**
* Set the zIndex of the symbol, which represents the place of the symbol on the map inside a layer.
* <p>
* A higher value brings the symbol to the front.
* </p>
*
* @param zIndex the z index
* @return this
*/
public SymbolOptions withZIndex(int zIndex) {
this.zIndex = zIndex;
return this;
}

/**
* Get the zIndex of the symbol, which represents the place of the symbol on the map inside a layer.
*
* @return the z index
*/
public int getZIndex() {
return zIndex;
}
<% } -%>

/**
* Returns whether this <%- type %> is draggable, meaning it can be dragged across the screen when touched and moved.
Expand Down Expand Up @@ -314,9 +283,6 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
jsonObject.addProperty(PROPERTY_<%- snakeCaseUpper(property.name) %>, <%- camelizeWithLeadingLowercase(property.name) %>);
<% } -%>
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
jsonObject.addProperty(PROPERTY_Z_INDEX, zIndex);
<% } -%>
<%- camelize(type) %> <%- type %> = new <%- camelize(type) %>(id, annotationManager, jsonObject, geometry);
<%- type %>.setDraggable(isDraggable);
Expand Down Expand Up @@ -357,11 +323,6 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
}
<% } -%>
<% } -%>
<% } -%>
<% if (type === "symbol") { -%>
if (feature.hasProperty(PROPERTY_Z_INDEX)) {
options.zIndex = feature.getProperty(PROPERTY_Z_INDEX).getAsInt();
}
<% } -%>
if (feature.hasProperty(PROPERTY_IS_DRAGGABLE)) {
options.isDraggable = feature.getProperty(PROPERTY_IS_DRAGGABLE).getAsBoolean();
Expand Down
5 changes: 4 additions & 1 deletion plugin-annotation/scripts/code-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const fs = require('fs');
const ejs = require('ejs');
const spec = require('./v8');
const spec = require('./../gl-js/src/style-spec/reference/v8');
const _ = require('lodash');
const path = require('path');

Expand Down Expand Up @@ -227,6 +227,9 @@ global.defaultValueJava = function(property) {
}
if(property.name.endsWith("-font")) {
return 'new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}';
}
if(property.name.endsWith("text-variable-anchor")){
return 'new String[]{TEXT_ANCHOR_RIGHT, TEXT_ANCHOR_TOP}'
}
switch (property.type) {
case 'boolean':
Expand Down
Loading