diff options
author | Lauren Budorick <lauren@mapbox.com> | 2017-07-26 13:18:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-26 13:18:47 -0700 |
commit | a8ef2af353de195648578bf0d753703cb6f34905 (patch) | |
tree | b6afc3efd568b0310c9e6287d4c0c9c78bee5baf /platform/android | |
parent | c5a5b4083795107b7df7bab39b461568a3861dba (diff) | |
download | qtlocation-mapboxgl-a8ef2af353de195648578bf0d753703cb6f34905.tar.gz |
[core][android][macos][ios] Implement property functions for line-join, text-justify, text-anchor (#9583)
Diffstat (limited to 'platform/android')
3 files changed, 180 insertions, 9 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java index 1c68878772..ef89c6809e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java @@ -1482,11 +1482,11 @@ public class PropertyFactory { /** * The display of lines when joining. * - * @param <Z> the zoom parameter type - * @param function a wrapper {@link CameraFunction} for String + * @param <T> the function input type + * @param function a wrapper function for String * @return property wrapper around a String function */ - public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> lineJoin(CameraFunction<Z, String> function) { + public static <T> PropertyValue<Function<T, String>> lineJoin(Function<T, String> function) { return new LayoutPropertyValue<>("line-join", function); } @@ -2103,11 +2103,11 @@ public class PropertyFactory { /** * Text justification options. * - * @param <Z> the zoom parameter type - * @param function a wrapper {@link CameraFunction} for String + * @param <T> the function input type + * @param function a wrapper function for String * @return property wrapper around a String function */ - public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> textJustify(CameraFunction<Z, String> function) { + public static <T> PropertyValue<Function<T, String>> textJustify(Function<T, String> function) { return new LayoutPropertyValue<>("text-justify", function); } @@ -2126,11 +2126,11 @@ public class PropertyFactory { /** * Part of the text placed closest to the anchor. * - * @param <Z> the zoom parameter type - * @param function a wrapper {@link CameraFunction} for String + * @param <T> the function input type + * @param function a wrapper function for String * @return property wrapper around a String function */ - public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> textAnchor(CameraFunction<Z, String> function) { + public static <T> PropertyValue<Function<T, String>> textAnchor(Function<T, String> function) { return new LayoutPropertyValue<>("text-anchor", function); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java index 7bdf47aff4..8123d24be8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java @@ -204,6 +204,63 @@ public class LineLayerTest extends BaseActivityTest { } @Test + public void testLineJoinAsIdentitySourceFunction() { + validateTestSetup(); + setupLayer(); + Timber.i("line-join"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineJoin(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getLineJoin()); + assertNotNull(layer.getLineJoin().getFunction()); + assertEquals(SourceFunction.class, layer.getLineJoin().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineJoin().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineJoin().getFunction().getStops().getClass()); + } + }); + } + + @Test + public void testLineJoinAsIntervalSourceFunction() { + validateTestSetup(); + setupLayer(); + Timber.i("line-join"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + lineJoin( + property( + "FeaturePropertyA", + interval( + stop(1, lineJoin(LINE_JOIN_BEVEL)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineJoin()); + assertNotNull(layer.getLineJoin().getFunction()); + assertEquals(SourceFunction.class, layer.getLineJoin().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineJoin().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getLineJoin().getFunction().getStops().getClass()); + } + }); + } + + @Test public void testLineMiterLimitAsConstant() { validateTestSetup(); setupLayer(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java index fc8c4320a5..e2694af348 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java @@ -1888,6 +1888,63 @@ public class SymbolLayerTest extends BaseActivityTest { } @Test + public void testTextJustifyAsIdentitySourceFunction() { + validateTestSetup(); + setupLayer(); + Timber.i("text-justify"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textJustify(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getTextJustify()); + assertNotNull(layer.getTextJustify().getFunction()); + assertEquals(SourceFunction.class, layer.getTextJustify().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextJustify().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextJustify().getFunction().getStops().getClass()); + } + }); + } + + @Test + public void testTextJustifyAsIntervalSourceFunction() { + validateTestSetup(); + setupLayer(); + Timber.i("text-justify"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textJustify( + property( + "FeaturePropertyA", + interval( + stop(1, textJustify(TEXT_JUSTIFY_LEFT)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextJustify()); + assertNotNull(layer.getTextJustify().getFunction()); + assertEquals(SourceFunction.class, layer.getTextJustify().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextJustify().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getTextJustify().getFunction().getStops().getClass()); + } + }); + } + + @Test public void testTextAnchorAsConstant() { validateTestSetup(); setupLayer(); @@ -1936,6 +1993,63 @@ public class SymbolLayerTest extends BaseActivityTest { } @Test + public void testTextAnchorAsIdentitySourceFunction() { + validateTestSetup(); + setupLayer(); + Timber.i("text-anchor"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textAnchor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getTextAnchor()); + assertNotNull(layer.getTextAnchor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextAnchor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextAnchor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextAnchor().getFunction().getStops().getClass()); + } + }); + } + + @Test + public void testTextAnchorAsIntervalSourceFunction() { + validateTestSetup(); + setupLayer(); + Timber.i("text-anchor"); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(layer); + + // Set + layer.setProperties( + textAnchor( + property( + "FeaturePropertyA", + interval( + stop(1, textAnchor(TEXT_ANCHOR_CENTER)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextAnchor()); + assertNotNull(layer.getTextAnchor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextAnchor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextAnchor().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getTextAnchor().getFunction().getStops().getClass()); + } + }); + } + + @Test public void testTextMaxAngleAsConstant() { validateTestSetup(); setupLayer(); |