diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-07-08 18:31:55 +0200 |
---|---|---|
committer | Ivo van Dongen <info@ivovandongen.nl> | 2016-07-26 16:29:26 -0400 |
commit | 9a3eadfd5baa8b070bf8d34fbd90ecae964f170c (patch) | |
tree | e8120b8f52821a9650ea2387d8eaf393404e0a0b /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java | |
parent | b3c914fb3f52f6a2b96d663f1c57c97c34eb5e23 (diff) | |
download | qtlocation-mapboxgl-9a3eadfd5baa8b070bf8d34fbd90ecae964f170c.tar.gz |
[android] #5610 - Initial Runtime Style Bindings
[android] #5610 - Adjusted public api after discussion
[android] #5610 - added jni binding for NativeMapView#getLayer
[android] #5610 - Added initial test Activity
[android] #5610 - Started on NativePeer implementation for Layer
[android] #5610 - replaced low-level jni code with high-level for native getLayer
[android] 5610 - completed basic layer peer class - constructible from java and c++
[android] #5610 - removed reference that was redundant and causing the finalizer exception
[android] #5610 - Added a property peer
[android] #5610 - added value type to do type conversions - wip
[android] #5610 - simplified property conversion approach - wrapped value with jenv
[android] #5610 - added some more value conversions
[android] #5610 - Finished conversion for basic types
[android] #5610 - allow color's to be set as either an android color int or a String to support all formats in the spec
[android] #5610 - encode color ints as rgba to retain alpha channel
[android] #5610 - recalculate classes after paint property
[android] #5610 - more examples
[android] #5610 - fixed the example
[android] #5610 - cleaned up example code before continueing
[android] #5610 - added layout property example
[android] #5610 - set visibility on layer
[android] #5610 - added removeLayer and example
[android] #5610 - added more type conversions
[android] #5610 - Started on peer classes for layer implementations - WIP
[android] #5610 - First complete layer subclass peer implementation
[android] #5610 - added a little bit of structure before adding the other layer types
[android] #5610 - generate the c++ headers from the style spec
[android] #5610 - make sure the visibility is set as a string
[android] #5610 - Generate c++ layer peer class implementations from the style spec
[android] #5610 - generate java layer peer classes
[android] #5610 - cleanup comments
[android] #5610 - register all c++ peer classes with jni
[android] #5610 - addLayer
[android] #5610 - comment out broken case
[android] #5610 - Sources api - very much WIP
[android] 5610 - GeoJson source implementation and geojson conversion
[android] #5610 - cleanup add source/layer example a bit
[android] #5610 - initial filter api
[android] #5610 - Added filter api on the relevant Layer classes
[android] #5610 - raster layer is not filterable
[android] #5610 - actually make it compile
[android] #5610 - completed filter implementation
[android] #5610 - Vector and Raster Source + examples
[android] #5610 - removed superfluous interface, moved filters to the correct package
[android] #5610 - fixed comments
[android] #5610 - moved tests to the right package
[android] #5610 - hide difference between paint and layout properties in public api, make more performant set method for proeprties
[android] #5610 - fix rebase issue
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java new file mode 100644 index 0000000000..04da4da0cb --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java @@ -0,0 +1,115 @@ +package com.mapbox.mapboxsdk.style.layers; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * Utility to build filter expressions more easily: + * + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-filter">Style spec</a> + */ +public class Filter { + + public abstract static class Statement { + protected final String operator; + + public Statement(String operator) { + this.operator = operator; + } + + public abstract Object[] toArray(); + } + + public static class SimpleStatement extends Statement { + private final String key; + private final Object[] values; + + public SimpleStatement(String operator, String key, Object... values) { + super(operator); + this.key = key; + this.values = values; + } + + + @Override + public Object[] toArray() { + ArrayList<Object> array = new ArrayList<>(2 + values.length); + array.add(operator); + array.add(key); + array.addAll(Arrays.asList(values)); + return array.toArray(); + } + } + + public static class CompoundStatement extends Statement { + private final Statement[] statements; + + public CompoundStatement(String operator, Statement... statements) { + super(operator); + this.statements = statements; + } + + @Override + public Object[] toArray() { + ArrayList<Object> array = new ArrayList<>(1 + statements.length); + array.add(operator); + for (Statement statement : statements) { + array.add(statement.toArray()); + } + return array.toArray(); + } + } + + public static Statement all(Statement... statements) { + return new CompoundStatement("all", statements); + } + + public static Statement any(Statement... statements) { + return new CompoundStatement("any", statements); + } + + public static Statement none(Statement... statements) { + return new CompoundStatement("none", statements); + } + + public static Statement has(String key) { + return new SimpleStatement("has", key); + } + + public static Statement notHas(String key) { + return new SimpleStatement("!has", key); + } + + public static Statement eq(String key, Object value) { + return new SimpleStatement("==", key, value); + } + + public static Statement neq(String key, Object value) { + return new SimpleStatement("!=", key, value); + } + + public static Statement gt(String key, Object value) { + return new SimpleStatement(">", key, value); + } + + public static Statement gte(String key, Object value) { + return new SimpleStatement(">=", key, value); + } + + public static Statement lt(String key, Object value) { + return new SimpleStatement("<", key, value); + } + + public static Statement lte(String key, Object value) { + return new SimpleStatement("<=", key, value); + } + + public static Statement in(String key, Object... values) { + return new SimpleStatement("in", key, values); + } + + public static Statement notIn(String key, Object... values) { + return new SimpleStatement("!in", key, values); + } + +} |