[android] #5610 - Runtime style api - part 2

This commit is contained in:
Ivo van Dongen
2016-07-26 17:02:52 -04:00
parent ed821c06d9
commit 10b2cc60a7
73 changed files with 6974 additions and 297 deletions

View File

@@ -1,23 +0,0 @@
package com.mapbox.mapboxsdk.layers;
public class CustomLayer {
public String mID;
public long mContext;
public long mInitializeFunction;
public long mRenderFunction;
public long mDeinitializeFunction;
public CustomLayer(String id,
long context,
long initializeFunction,
long renderFunction,
long deinitializeFunction) {
this.mID = id;
this.mContext = context;
this.mInitializeFunction = initializeFunction;
this.mRenderFunction = renderFunction;
this.mDeinitializeFunction = deinitializeFunction;
}
}

View File

@@ -1,4 +0,0 @@
/**
* Do not use this package. Experimental feature.
*/
package com.mapbox.mapboxsdk.layers;

View File

@@ -78,7 +78,6 @@ import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.exceptions.IconBitmapChangedException;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.location.LocationListener;
import com.mapbox.mapboxsdk.location.LocationServices;
import com.mapbox.mapboxsdk.maps.widgets.CompassView;
@@ -2604,34 +2603,6 @@ public class MapView extends FrameLayout {
return mMapboxMap.getUiSettings().getAttributionTintColor();
}
//
// Custom layer
//
@UiThread
void addCustomLayer(CustomLayer customLayer, String before) {
if (mDestroyed) {
return;
}
mNativeMapView.addCustomLayer(customLayer, before);
}
@UiThread
void removeCustomLayer(String id) {
if (mDestroyed) {
return;
}
mNativeMapView.removeCustomLayer(id);
}
@UiThread
void invalidateCustomLayers() {
if (mDestroyed) {
return;
}
mNativeMapView.update();
}
/**
* Sets a callback object which will be triggered when the {@link MapboxMap} instance is ready to be used.
*

View File

@@ -38,7 +38,6 @@ import com.mapbox.mapboxsdk.constants.MyBearingTracking;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
@@ -59,6 +58,7 @@ import java.util.concurrent.TimeUnit;
* </p>
*/
public class MapboxMap {
private static final String TAG = MapboxMap.class.getSimpleName();
private MapView mMapView;
private UiSettings mUiSettings;
@@ -114,6 +114,21 @@ public class MapboxMap {
return getMapView().getNativeMapView().getLayer(layerId);
}
/**
* Tries to cast the Layer to T, returns null if it's another type
*/
@Nullable
@UiThread
public <T extends Layer> T getLayerAs(@NonNull String layerId) {
try {
//noinspection unchecked
return (T) getMapView().getNativeMapView().getLayer(layerId);
} catch (ClassCastException e) {
Log.e(TAG, String.format("Layer: %s is a different type: %s", layerId, e.getMessage()));
return null;
}
}
@UiThread
public void addLayer(@NonNull Layer layer) {
addLayer(layer, null);
@@ -1621,34 +1636,6 @@ public class MapboxMap {
return mOnMyBearingTrackingModeChangeListener;
}
//
// Custom layer
//
/**
* Do not use this method, experimental feature.
*/
@UiThread
public void addCustomLayer(CustomLayer customLayer, String before) {
mMapView.addCustomLayer(customLayer, before);
}
/**
* Do not use this method, experimental feature.
*/
@UiThread
public void removeCustomLayer(String id) {
mMapView.removeCustomLayer(id);
}
/**
* Do not use this method, experimental feature.
*/
@UiThread
public void invalidateCustomLayers() {
mMapView.invalidateCustomLayers();
}
MapView getMapView() {
return mMapView;
}

View File

@@ -16,7 +16,6 @@ import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.offline.OfflineManager;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
@@ -463,14 +462,6 @@ final class NativeMapView {
nativeFlyTo(mNativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom);
}
public void addCustomLayer(CustomLayer customLayer, String before) {
nativeAddCustomLayer(mNativeMapViewPtr, customLayer, before);
}
public void removeCustomLayer(String id) {
nativeRemoveCustomLayer(mNativeMapViewPtr, id);
}
public double[] getCameraValues() {
return nativeGetCameraValues(mNativeMapViewPtr);
}
@@ -483,6 +474,7 @@ final class NativeMapView {
public void addLayer(@NonNull Layer layer, @Nullable String before) {
nativeAddLayer(mNativeMapViewPtr, layer.getNativePtr(), before);
layer.invalidate();
}
public void removeLayer(@NonNull String layerId) throws NoSuchLayerException {
@@ -667,10 +659,6 @@ final class NativeMapView {
private native void nativeFlyTo(long nativeMapViewPtr, double angle, double latitude, double longitude, long duration, double pitch, double zoom);
private native void nativeAddCustomLayer(long nativeMapViewPtr, CustomLayer customLayer, String before);
private native void nativeRemoveCustomLayer(long nativeMapViewPtr, String id);
private native double[] nativeGetCameraValues(long mNativeMapViewPtr);
private native Layer nativeGetLayer(long nativeMapViewPtr, String layerId);

View File

@@ -16,4 +16,31 @@ public class BackgroundLayer extends Layer {
protected native void initialize(String layerId);
// Property getters
@SuppressWarnings("unchecked")
public PropertyValue<String> getBackgroundColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetBackgroundColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getBackgroundPattern() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetBackgroundPattern());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getBackgroundOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetBackgroundOpacity());
}
private native Object nativeGetBackgroundColor();
private native Object nativeGetBackgroundPattern();
private native Object nativeGetBackgroundOpacity();
}

View File

@@ -17,15 +17,77 @@ public class CircleLayer extends Layer {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
checkValidity();
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
checkValidity();
nativeSetFilter(filter);
}
// Property getters
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleRadius() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleRadius());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getCircleColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetCircleColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleBlur() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleBlur());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleOpacity());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getCircleTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetCircleTranslate());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getCircleTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetCircleTranslateAnchor());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getCirclePitchScale() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetCirclePitchScale());
}
private native Object nativeGetCircleRadius();
private native Object nativeGetCircleColor();
private native Object nativeGetCircleBlur();
private native Object nativeGetCircleOpacity();
private native Object nativeGetCircleTranslate();
private native Object nativeGetCircleTranslateAnchor();
private native Object nativeGetCirclePitchScale();
}

View File

@@ -0,0 +1,30 @@
package com.mapbox.mapboxsdk.style.layers;
/**
* Custom layer.
* <p/>
* Experimental feature. Do not use.
*/
public class CustomLayer extends Layer {
public CustomLayer(String id,
long context,
long initializeFunction,
long renderFunction,
long deinitializeFunction) {
initialize(id, initializeFunction, renderFunction, deinitializeFunction, context);
}
public CustomLayer(long nativePtr) {
super(nativePtr);
}
public void invalidate() {
nativeUpdate();
}
protected native void initialize(String id, long initializeFunction, long renderFunction, long deinitializeFunction, long context);
protected native void nativeUpdate();
}

View File

@@ -17,15 +17,77 @@ public class FillLayer extends Layer {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
checkValidity();
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
checkValidity();
nativeSetFilter(filter);
}
// Property getters
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getFillAntialias() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetFillAntialias());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getFillOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetFillOpacity());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getFillColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetFillColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getFillOutlineColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetFillOutlineColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getFillTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetFillTranslate());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getFillTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetFillTranslateAnchor());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getFillPattern() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetFillPattern());
}
private native Object nativeGetFillAntialias();
private native Object nativeGetFillOpacity();
private native Object nativeGetFillColor();
private native Object nativeGetFillOutlineColor();
private native Object nativeGetFillTranslate();
private native Object nativeGetFillTranslateAnchor();
private native Object nativeGetFillPattern();
}

View File

@@ -0,0 +1,85 @@
package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import java.util.HashMap;
import java.util.Map;
/**
* Representation of <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">Function</a> in the Mapbox style specification
*
* @param <T> the target property's value type. Make sure it matches.
*/
public class Function<T> {
public static class Stop<I, O> {
public final I in;
public final O out;
Stop(I in, O out) {
this.in = in;
this.out = out;
}
Object[] toValueObject() {
return new Object[]{in, out};
}
}
@SafeVarargs
public static <T> Function<T> zoom(@NonNull @Size(min = 1) Stop<Float, T>... stops) {
return new Function<T>(stops);
}
@SafeVarargs
public static <T> Function<T> zoom(
@FloatRange(from = 0, to = 1, fromInclusive = false, toInclusive = false) float base,
@NonNull @Size(min = 1) Stop<Float, T>... stops) {
return new Function<T>(stops)
.withBase(base);
}
public static <T> Stop<Float, T> stop(float in, Property<T> output) {
return new Stop<>(in, output.value);
}
private final Stop<Float, T>[] stops;
private Float base;
Function(@NonNull @Size(min = 1) Stop<Float, T>[] stops) {
this.stops = stops;
}
Function<T> withBase(float base) {
this.base = base;
return this;
}
@Nullable
public Float getBase() {
return base;
}
public Stop<Float, T>[] getStops() {
return stops;
}
Map<String, Object> toValueObject() {
Object[] stopsValue = new Object[stops.length];
for (int i = 0; i < stopsValue.length; i++) {
Stop stop = stops[i];
stopsValue[i] = stop.toValueObject();
}
Map<String, Object> value = new HashMap<>();
if (base != null) {
value.put("base", base);
}
value.put("stops", stopsValue);
return value;
}
}

View File

@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.NonNull;
import android.util.Log;
/**
* Base class for the different Layer types
@@ -9,17 +8,18 @@ import android.util.Log;
public abstract class Layer {
private long nativePtr;
private boolean invalidated;
public Layer(long nativePtr) {
Log.i(Layer.class.getSimpleName(), "Native pointer constructor: " + nativePtr);
this.nativePtr = nativePtr;
}
public Layer() {
Log.i(Layer.class.getSimpleName(), "Default constructor");
}
public void set(@NonNull Property<?>... properties) {
public void setProperties(@NonNull Property<?>... properties) {
checkValidity();
if (properties.length == 0) {
return;
}
@@ -28,9 +28,9 @@ public abstract class Layer {
for (Property<?> property : properties) {
if (property instanceof PaintProperty) {
updateClasses = true;
nativeSetPaintProperty(property.name, property.value);
nativeSetPaintProperty(property.name, convertValue(property.value));
} else {
nativeSetLayoutProperty(property.name, property.value);
nativeSetLayoutProperty(property.name, convertValue(property.value));
}
}
@@ -38,14 +38,42 @@ public abstract class Layer {
}
public String getId() {
checkValidity();
return nativeGetId();
}
public PropertyValue<String> getVisibility() {
checkValidity();
return new PropertyValue<>(nativeGetVisibility());
}
public float getMinZoom() {
checkValidity();
return nativeGetMinZoom();
}
public float getMaxZoom() {
checkValidity();
return nativeGetMaxZoom();
}
public void setMinZoom(float zoom) {
checkValidity();
nativeSetMinZoom(zoom);
}
public void setMaxZoom(float zoom) {
checkValidity();
nativeSetMaxZoom(zoom);
}
@Override
protected native void finalize() throws Throwable;
protected native String nativeGetId();
protected native Object nativeGetVisibility();
protected native void nativeSetLayoutProperty(String name, Object value);
protected native void nativeSetPaintProperty(String name, Object value);
@@ -56,13 +84,29 @@ public abstract class Layer {
protected native void nativeUpdateStyle(boolean updateClasses);
@Override
public String toString() {
return "Layer: " + getId();
}
protected native float nativeGetMinZoom();
protected native float nativeGetMaxZoom();
protected native void nativeSetMinZoom(float zoom);
protected native void nativeSetMaxZoom(float zoom);
public long getNativePtr() {
return nativePtr;
}
private Object convertValue(Object value) {
return value != null && value instanceof Function ? ((Function) value).toValueObject() : value;
}
protected void checkValidity() {
if (invalidated) {
throw new RuntimeException("Layer has been invalidated. Request a new reference after adding");
}
}
public void invalidate() {
this.invalidated = true;
}
}

View File

@@ -17,15 +17,133 @@ public class LineLayer extends Layer {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
checkValidity();
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
checkValidity();
nativeSetFilter(filter);
}
// Property getters
@SuppressWarnings("unchecked")
public PropertyValue<String> getLineCap() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLineCap());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getLineJoin() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLineJoin());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineMiterLimit() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineMiterLimit());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineRoundLimit() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineRoundLimit());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineOpacity());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getLineColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLineColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getLineTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetLineTranslate());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getLineTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLineTranslateAnchor());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineWidth());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineGapWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineGapWidth());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineOffset() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineOffset());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineBlur() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetLineBlur());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getLineDasharray() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetLineDasharray());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getLinePattern() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetLinePattern());
}
private native Object nativeGetLineCap();
private native Object nativeGetLineJoin();
private native Object nativeGetLineMiterLimit();
private native Object nativeGetLineRoundLimit();
private native Object nativeGetLineOpacity();
private native Object nativeGetLineColor();
private native Object nativeGetLineTranslate();
private native Object nativeGetLineTranslateAnchor();
private native Object nativeGetLineWidth();
private native Object nativeGetLineGapWidth();
private native Object nativeGetLineOffset();
private native Object nativeGetLineBlur();
private native Object nativeGetLineDasharray();
private native Object nativeGetLinePattern();
}

View File

@@ -11,6 +11,17 @@ import java.lang.annotation.RetentionPolicy;
*/
public abstract class Property<T> {
//visibility
public static final String VISIBLE = "visible";
public static final String NONE = "none";
@StringDef({
VISIBLE,
NONE
})
@Retention(RetentionPolicy.SOURCE)
public @interface VISIBILITY {}
//line-cap
public static final String LINE_CAP_BUTT = "butt";
public static final String LINE_CAP_ROUND = "round";

View File

@@ -0,0 +1,56 @@
package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.Nullable;
import android.util.Log;
/**
* Properties for Layer
*/
public class PropertyValue<T> {
private static final String TAG = PropertyValue.class.getSimpleName();
private final Object value;
/* package */ PropertyValue(Object value) {
this.value = value;
}
public boolean isNull() {
return value == null;
}
public boolean isFunction() {
return !isNull() && value instanceof Function;
}
public boolean isValue() {
return !isNull() && !isFunction();
}
@Nullable
public Function<T> getFunction() {
if (isFunction()) {
//noinspection unchecked
return (Function<T>) value;
} else {
Log.w(TAG, "not a function, try value");
return null;
}
}
@Nullable
public T getValue() {
if (isValue()) {
//noinspection unchecked
return (T) value;
} else {
Log.w(TAG, "not a value, try function");
return null;
}
}
@Override
public String toString() {
return String.format("%s (%s)", getClass().getSimpleName(), value != null ? value.getClass().getSimpleName() : null);
}
}

View File

@@ -17,7 +17,67 @@ public class RasterLayer extends Layer {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
checkValidity();
nativeSetSourceLayer(sourceLayer);
}
// Property getters
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterOpacity());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterHueRotate() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterHueRotate());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterBrightnessMin() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterBrightnessMin());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterBrightnessMax() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterBrightnessMax());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterSaturation() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterSaturation());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterContrast() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterContrast());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getRasterFadeDuration() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterFadeDuration());
}
private native Object nativeGetRasterOpacity();
private native Object nativeGetRasterHueRotate();
private native Object nativeGetRasterBrightnessMin();
private native Object nativeGetRasterBrightnessMax();
private native Object nativeGetRasterSaturation();
private native Object nativeGetRasterContrast();
private native Object nativeGetRasterFadeDuration();
}

View File

@@ -17,15 +17,405 @@ public class SymbolLayer extends Layer {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
checkValidity();
nativeSetSourceLayer(sourceLayer);
}
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
checkValidity();
nativeSetFilter(filter);
}
// Property getters
@SuppressWarnings("unchecked")
public PropertyValue<String> getSymbolPlacement() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetSymbolPlacement());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getSymbolSpacing() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetSymbolSpacing());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getSymbolAvoidEdges() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetSymbolAvoidEdges());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getIconAllowOverlap() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconAllowOverlap());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getIconIgnorePlacement() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconIgnorePlacement());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getIconOptional() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconOptional());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconRotationAlignment() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconRotationAlignment());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconSize() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconSize());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconTextFit() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconTextFit());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getIconTextFitPadding() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconTextFitPadding());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconImage() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconImage());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconRotate() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconRotate());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconPadding() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconPadding());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getIconKeepUpright() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconKeepUpright());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getIconOffset() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconOffset());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextPitchAlignment() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextPitchAlignment());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextRotationAlignment() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextRotationAlignment());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextField() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextField());
}
@SuppressWarnings("unchecked")
public PropertyValue<String[]> getTextFont() {
checkValidity();
return (PropertyValue<String[]>) new PropertyValue(nativeGetTextFont());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextSize() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextSize());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextMaxWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextMaxWidth());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextLineHeight() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextLineHeight());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextLetterSpacing() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextLetterSpacing());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextJustify() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextJustify());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextAnchor());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextMaxAngle() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextMaxAngle());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextRotate() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextRotate());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextPadding() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextPadding());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getTextKeepUpright() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextKeepUpright());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextTransform() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextTransform());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getTextOffset() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetTextOffset());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getTextAllowOverlap() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextAllowOverlap());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getTextIgnorePlacement() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextIgnorePlacement());
}
@SuppressWarnings("unchecked")
public PropertyValue<Boolean> getTextOptional() {
checkValidity();
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextOptional());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconOpacity());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconHaloColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconHaloColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconHaloWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconHaloWidth());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getIconHaloBlur() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetIconHaloBlur());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getIconTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconTranslate());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetIconTranslateAnchor());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextOpacity() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextOpacity());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextHaloColor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextHaloColor());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextHaloWidth() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextHaloWidth());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTextHaloBlur() {
checkValidity();
return (PropertyValue<Float>) new PropertyValue(nativeGetTextHaloBlur());
}
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getTextTranslate() {
checkValidity();
return (PropertyValue<Float[]>) new PropertyValue(nativeGetTextTranslate());
}
@SuppressWarnings("unchecked")
public PropertyValue<String> getTextTranslateAnchor() {
checkValidity();
return (PropertyValue<String>) new PropertyValue(nativeGetTextTranslateAnchor());
}
private native Object nativeGetSymbolPlacement();
private native Object nativeGetSymbolSpacing();
private native Object nativeGetSymbolAvoidEdges();
private native Object nativeGetIconAllowOverlap();
private native Object nativeGetIconIgnorePlacement();
private native Object nativeGetIconOptional();
private native Object nativeGetIconRotationAlignment();
private native Object nativeGetIconSize();
private native Object nativeGetIconTextFit();
private native Object nativeGetIconTextFitPadding();
private native Object nativeGetIconImage();
private native Object nativeGetIconRotate();
private native Object nativeGetIconPadding();
private native Object nativeGetIconKeepUpright();
private native Object nativeGetIconOffset();
private native Object nativeGetTextPitchAlignment();
private native Object nativeGetTextRotationAlignment();
private native Object nativeGetTextField();
private native Object nativeGetTextFont();
private native Object nativeGetTextSize();
private native Object nativeGetTextMaxWidth();
private native Object nativeGetTextLineHeight();
private native Object nativeGetTextLetterSpacing();
private native Object nativeGetTextJustify();
private native Object nativeGetTextAnchor();
private native Object nativeGetTextMaxAngle();
private native Object nativeGetTextRotate();
private native Object nativeGetTextPadding();
private native Object nativeGetTextKeepUpright();
private native Object nativeGetTextTransform();
private native Object nativeGetTextOffset();
private native Object nativeGetTextAllowOverlap();
private native Object nativeGetTextIgnorePlacement();
private native Object nativeGetTextOptional();
private native Object nativeGetIconOpacity();
private native Object nativeGetIconColor();
private native Object nativeGetIconHaloColor();
private native Object nativeGetIconHaloWidth();
private native Object nativeGetIconHaloBlur();
private native Object nativeGetIconTranslate();
private native Object nativeGetIconTranslateAnchor();
private native Object nativeGetTextOpacity();
private native Object nativeGetTextColor();
private native Object nativeGetTextHaloColor();
private native Object nativeGetTextHaloWidth();
private native Object nativeGetTextHaloBlur();
private native Object nativeGetTextTranslate();
private native Object nativeGetTextTranslateAnchor();
}

View File

@@ -1,5 +1,6 @@
<%
const type = locals.type;
const properties = locals.properties;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style.layers;
@@ -27,18 +28,36 @@ public class <%- camelize(type) %>Layer extends Layer {
protected native void initialize(String layerId, String sourceId);
public void setSourceLayer(String sourceLayer) {
checkValidity();
nativeSetSourceLayer(sourceLayer);
}
<% } -%>
<% if (type !== 'background' && type !== 'raster') { -%>
public void setFilter(Filter.Statement filter) {
checkValidity();
this.setFilter(filter.toArray());
}
public void setFilter(Object[] filter) {
checkValidity();
nativeSetFilter(filter);
}
<% } -%>
// Property getters
<% for (const property of properties) { -%>
@SuppressWarnings("unchecked")
public PropertyValue<<%- propertyType(property) %>> get<%- camelize(property.name) %>() {
checkValidity();
return (PropertyValue<<%- propertyType(property) %>>) new PropertyValue(nativeGet<%- camelize(property.name) %>());
}
<% } -%>
<% for (const property of properties) { -%>
private native Object nativeGet<%- camelize(property.name) %>();
<% } -%>
}

View File

@@ -14,6 +14,17 @@ import java.lang.annotation.RetentionPolicy;
*/
public abstract class Property<T> {
//visibility
public static final String VISIBLE = "visible";
public static final String NONE = "none";
@StringDef({
VISIBLE,
NONE
})
@Retention(RetentionPolicy.SOURCE)
public @interface VISIBILITY {}
<% for (const property of properties) { -%>
//<%- property.name %>
<% for (const value of property.values) { -%>

View File

@@ -10,32 +10,65 @@ import android.support.annotation.ColorInt;
/**
* Constructs paint/layout properties for Layers
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers>Layer style documentation</a>
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers>Layer style documentation</a>
*/
public class PropertyFactory {
public static Property<String> visibility(Boolean visible) {
return new LayoutProperty<>("visibility", visible? "visible": "none");
/**
* Set visibility
*/
public static Property<String> visibility(@Property.VISIBILITY String value) {
return new LayoutProperty<>("visibility", value);
}
/**
* Set visibility
*/
public static Property<Function<String>> visibility(Function<String> function) {
return new LayoutProperty<>("visibility", function);
}
<% for (const property of paintProperties) { -%>
<% if (property.type == 'color') { -%>
/**
* <%- property.doc %>
*/
public static Property<String> <%- camelizeWithLeadingLowercase(property.name) %>(@ColorInt int value) {
return new PaintProperty<>("<%- property.name %>", colorToRgbaString(value));
}
<% } -%>
/**
* <%- property.doc %>
*/
public static Property<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
return new PaintProperty<>("<%- property.name %>", value);
}
/**
* <%- property.doc %>
*/
public static Property<Function<<%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<<%- propertyType(property) %>> function) {
return new PaintProperty<>("<%- property.name %>", function);
}
<% } -%>
<% for (const property of layoutProperties) { -%>
/**
* <%- property.doc %>
*/
public static Property<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
return new LayoutProperty<>("<%- property.name %>", value);
}
/**
* <%- property.doc %>
*/
public static Property<Function<<%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<<%- propertyType(property) %>> function) {
return new LayoutProperty<>("<%- property.name %>", function);
}
<% } -%>
@SuppressLint("DefaultLocale")
static String colorToRgbaString(@ColorInt int value) {

View File

@@ -2,9 +2,15 @@ package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
/**
* Construct a Raster Source.
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-raster">The style specificition</a>
*/
public class RasterSource extends Source {
public static final String TYPE = "raster";
private static final String URL_KEY = "url";
private static final String TILE_SIZE_KEY = "tileSize";
public RasterSource(String id, URL url) {
this(id, url.toExternalForm());
@@ -14,4 +20,14 @@ public class RasterSource extends Source {
super(id, TYPE);
this.put(URL_KEY, url);
}
public RasterSource(String id, TileSet tileSet) {
super(id, TYPE);
this.putAll(tileSet.toValueObject());
}
public RasterSource withTileSize(int tileSize) {
this.put(TILE_SIZE_KEY, (float) tileSize);
return this;
}
}

View File

@@ -0,0 +1,290 @@
package com.mapbox.mapboxsdk.style.sources;
import android.support.annotation.Size;
import com.mapbox.mapboxsdk.geometry.LatLng;
import java.util.HashMap;
import java.util.Map;
/**
* Tile set
*
* @see <a href="https://github.com/mapbox/tilejson-spec/tree/master/2.1.0">The tileset specification</a>
*/
public class TileSet {
private final String tilejson;
private String name;
private String description;
private String version;
private String attribution;
private String template;
private String legend;
private String scheme;
private final String[] tiles;
private String[] grids;
private String[] data;
private Float minZoom;
private Float maxZoom;
private Float[] bounds;
private Float[] center;
/**
* @param tilejson A semver.org style version number. Describes the version of the TileJSON spec that is implemented by this JSON object.
* @param tiles An array of tile endpoints. {z}, {x} and {y}, if present, are replaced with the corresponding integers.
* If multiple endpoints are specified, clients may use any combination of endpoints. All endpoints MUST return the same
* content for the same URL. The array MUST contain at least one endpoint.
* Example: "http:localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png"
*/
public TileSet(String tilejson, String... tiles) {
this.tilejson = tilejson;
this.tiles = tiles;
}
public String getTilejson() {
return tilejson;
}
public String getName() {
return name;
}
/**
* A name describing the tileset. The name can
* contain any legal character. Implementations SHOULD NOT interpret the
* name as HTML.
* "name": "compositing",
*/
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
/**
* A text description of the tileset. The
* description can contain any legal character.
* Implementations SHOULD NOT
* interpret the description as HTML.
* "description": "A simple, light grey world."
*/
public void setDescription(String description) {
this.description = description;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getAttribution() {
return attribution;
}
/**
* Default: null. Contains an attribution to be displayed
* when the map is shown to a user. Implementations MAY decide to treat this
* as HTML or literal text. For security reasons, make absolutely sure that
* this field can't be abused as a vector for XSS or beacon tracking.
* "attribution": "<a href='http:openstreetmap.org'>OSM contributors</a>",
*/
public void setAttribution(String attribution) {
this.attribution = attribution;
}
public String getTemplate() {
return template;
}
/**
* Contains a mustache template to be used to
* format data from grids for interaction.
* See https:github.com/mapbox/utfgrid-spec/tree/master/1.2
* for the interactivity specification.
* "template": "{{#__teaser__}}{{NAME}}{{/__teaser__}}"
*/
public void setTemplate(String template) {
this.template = template;
}
public String getLegend() {
return legend;
}
/**
* Contains a legend to be displayed with the map.
* Implementations MAY decide to treat this as HTML or literal text.
* For security reasons, make absolutely sure that this field can't be
* abused as a vector for XSS or beacon tracking.
* "legend": "Dangerous zones are red, safe zones are green"
*/
public void setLegend(String legend) {
this.legend = legend;
}
public String getScheme() {
return scheme;
}
/**
* Default: "xyz". Either "xyz" or "tms". Influences the y
* direction of the tile coordinates.
* The global-mercator (aka Spherical Mercator) profile is assumed.
* "scheme": "xyz"
*/
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String[] getTiles() {
return tiles;
}
public String[] getGrids() {
return grids;
}
/**
* An array of interactivity endpoints. {z}, {x}
* and {y}, if present, are replaced with the corresponding integers. If multiple
* endpoints are specified, clients may use any combination of endpoints.
* All endpoints MUST return the same content for the same URL.
* If the array doesn't contain any entries, interactivity is not supported
* for this tileset. See https:github.com/mapbox/utfgrid-spec/tree/master/1.2
* for the interactivity specification.
* <p/>
* Example: "http:localhost:8888/admin/1.0.0/broadband/{z}/{x}/{y}.grid.json"
*/
public void setGrids(String... grids) {
this.grids = grids;
}
public String[] getData() {
return data;
}
/**
* An array of data files in GeoJSON format.
* {z}, {x} and {y}, if present,
* are replaced with the corresponding integers. If multiple
* endpoints are specified, clients may use any combination of endpoints.
* All endpoints MUST return the same content for the same URL.
* If the array doesn't contain any entries, then no data is present in
* the map.
* <p/>
* "http:localhost:8888/admin/data.geojson"
*/
public void setData(String... data) {
this.data = data;
}
public float getMinZoom() {
return minZoom;
}
/**
* 0. >= 0, <= 22. An integer specifying the minimum zoom level.
*/
public void setMinZoom(float minZoom) {
this.minZoom = minZoom;
}
public float getMaxZoom() {
return maxZoom;
}
/**
* 0. >= 0, <= 22. An integer specifying the maximum zoom level.
*/
public void setMaxZoom(float maxZoom) {
this.maxZoom = maxZoom;
}
public Float[] getBounds() {
return bounds;
}
/**
* Default: [-180, -90, 180, 90]. The maximum extent of available map tiles. Bounds MUST define an area
* covered by all zoom levels. The bounds are represented in WGS:84
* latitude and longitude values, in the order left, bottom, right, top.
* Values may be integers or floating point numbers.
*/
public void setBounds(@Size(value = 4) Float... bounds) {
this.bounds = bounds;
}
public Float[] getCenter() {
return center;
}
/**
* The first value is the longitude, the second is latitude (both in
* WGS:84 values), the third value is the zoom level as an integer.
* Longitude and latitude MUST be within the specified bounds.
* The zoom level MUST be between minzoom and maxzoom.
* Implementations can use this value to set the default location. If the
* value is null, implementations may use their own algorithm for
* determining a default location.
*/
public void setCenter(@Size(value = 2) Float... center) {
this.center = center;
}
public void setCenter(LatLng center) {
this.center = new Float[]{(float) center.getLongitude(), (float) center.getLatitude()};
}
Map<String, Object> toValueObject() {
Map<String, Object> result = new HashMap<>();
result.put("tilejson", tilejson);
result.put("tiles", tiles);
if (name != null) {
result.put("name", name);
}
if (description != null) {
result.put("description", description);
}
if (version != null) {
result.put("version", version);
}
if (attribution != null) {
result.put("attribution", attribution);
}
if (template != null) {
result.put("template", template);
}
if (legend != null) {
result.put("legend", legend);
}
if (scheme != null) {
result.put("scheme", scheme);
}
if (grids != null) {
result.put("grids", grids);
}
if (data != null) {
result.put("data", data);
}
if (minZoom != null) {
result.put("minzoom", minZoom);
}
if (maxZoom != null) {
result.put("maxzoom", maxZoom);
}
if (bounds != null) {
result.put("bounds", bounds);
}
if (center != null) {
result.put("center", center);
}
return result;
}
}

View File

@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.style.sources;
import java.net.URL;
import java.util.HashMap;
public class VectorSource extends Source {
public static final String TYPE = "vector";
@@ -15,4 +14,9 @@ public class VectorSource extends Source {
super(id, TYPE);
this.put(URL_KEY, url);
}
public VectorSource(String id, TileSet tileSet) {
super(id, TYPE);
this.putAll(tileSet.toValueObject());
}
}

View File

@@ -0,0 +1,120 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
* Basic smoke tests for BackgroundLayer
*/
@RunWith(AndroidJUnit4.class)
public class BackgroundLayerTest extends BaseTest {
private static final String TAG = BackgroundLayerTest.class.getSimpleName();
@Rule
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
private BackgroundLayer layer;
private OnMapReadyIdlingResource idlingResource;
private MapboxMap mapboxMap;
@Before
public void setup() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
}
@Test
public void testSetVisibility() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
Log.i(TAG, "Retrieving layer");
layer = mapboxMap.getLayerAs("background");
Log.i(TAG, "visibility");
assertNotNull(layer);
//Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
//Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
public void testBackgroundColor() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
Log.i(TAG, "Retrieving layer");
layer = mapboxMap.getLayerAs("background");
Log.i(TAG, "background-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testBackgroundPattern() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
Log.i(TAG, "Retrieving layer");
layer = mapboxMap.getLayerAs("background");
Log.i(TAG, "background-pattern");
assertNotNull(layer);
//Set and Get
layer.setProperties(backgroundPattern("pedestrian-polygon"));
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
}
@Test
public void testBackgroundOpacity() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
Log.i(TAG, "Retrieving layer");
layer = mapboxMap.getLayerAs("background");
Log.i(TAG, "background-opacity");
assertNotNull(layer);
//Set and Get
layer.setProperties(backgroundOpacity(0.3f));
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
}
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
}

View File

@@ -0,0 +1,232 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
* Basic smoke tests for CircleLayer
*/
@RunWith(AndroidJUnit4.class)
public class CircleLayerTest extends BaseTest {
private static final String TAG = CircleLayerTest.class.getSimpleName();
@Rule
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
private CircleLayer layer;
private OnMapReadyIdlingResource idlingResource;
private MapboxMap mapboxMap;
@Before
public void setup() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
}
@Test
public void testSetVisibility() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "visibility");
assertNotNull(layer);
//Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
//Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
public void testCircleRadius() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "circle-radius");
assertNotNull(layer);
//Set and Get
layer.setProperties(circleRadius(0.3f));
assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
}
@Test
public void testCircleColor() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "circle-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testCircleBlur() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "circle-blur");
assertNotNull(layer);
//Set and Get
layer.setProperties(circleBlur(0.3f));
assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
}
@Test
public void testCircleOpacity() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "circle-opacity");
assertNotNull(layer);
//Set and Get
layer.setProperties(circleOpacity(0.3f));
assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
}
@Test
public void testCircleTranslate() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "circle-translate");
assertNotNull(layer);
//Set and Get
layer.setProperties(circleTranslate(new Float[]{0f,0f}));
assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f});
}
@Test
public void testCircleTranslateAnchor() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "circle-translate-anchor");
assertNotNull(layer);
//Set and Get
layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
}
@Test
public void testCirclePitchScale() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "circle-pitch-scale");
assertNotNull(layer);
//Set and Get
layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
}
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
}

View File

@@ -0,0 +1,232 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
* Basic smoke tests for FillLayer
*/
@RunWith(AndroidJUnit4.class)
public class FillLayerTest extends BaseTest {
private static final String TAG = FillLayerTest.class.getSimpleName();
@Rule
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
private FillLayer layer;
private OnMapReadyIdlingResource idlingResource;
private MapboxMap mapboxMap;
@Before
public void setup() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
}
@Test
public void testSetVisibility() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "visibility");
assertNotNull(layer);
//Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
//Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
public void testFillAntialias() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "fill-antialias");
assertNotNull(layer);
//Set and Get
layer.setProperties(fillAntialias(true));
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
}
@Test
public void testFillOpacity() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "fill-opacity");
assertNotNull(layer);
//Set and Get
layer.setProperties(fillOpacity(0.3f));
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
}
@Test
public void testFillColor() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "fill-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testFillOutlineColor() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "fill-outline-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testFillTranslate() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "fill-translate");
assertNotNull(layer);
//Set and Get
layer.setProperties(fillTranslate(new Float[]{0f,0f}));
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
}
@Test
public void testFillTranslateAnchor() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "fill-translate-anchor");
assertNotNull(layer);
//Set and Get
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
}
@Test
public void testFillPattern() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "fill-pattern");
assertNotNull(layer);
//Set and Get
layer.setProperties(fillPattern("pedestrian-polygon"));
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
}
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
}

View File

@@ -0,0 +1,386 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
* Basic smoke tests for LineLayer
*/
@RunWith(AndroidJUnit4.class)
public class LineLayerTest extends BaseTest {
private static final String TAG = LineLayerTest.class.getSimpleName();
@Rule
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
private LineLayer layer;
private OnMapReadyIdlingResource idlingResource;
private MapboxMap mapboxMap;
@Before
public void setup() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
}
@Test
public void testSetVisibility() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "visibility");
assertNotNull(layer);
//Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
//Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
public void testLineCap() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-cap");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineCap(LINE_CAP_BUTT));
assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
}
@Test
public void testLineJoin() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-join");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
}
@Test
public void testLineMiterLimit() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-miter-limit");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineMiterLimit(0.3f));
assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
}
@Test
public void testLineRoundLimit() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-round-limit");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineRoundLimit(0.3f));
assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
}
@Test
public void testLineOpacity() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-opacity");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineOpacity(0.3f));
assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
}
@Test
public void testLineColor() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testLineTranslate() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-translate");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineTranslate(new Float[]{0f,0f}));
assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f});
}
@Test
public void testLineTranslateAnchor() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-translate-anchor");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
}
@Test
public void testLineWidth() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-width");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineWidth(0.3f));
assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
}
@Test
public void testLineGapWidth() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-gap-width");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineGapWidth(0.3f));
assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
}
@Test
public void testLineOffset() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-offset");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineOffset(0.3f));
assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
}
@Test
public void testLineBlur() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-blur");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineBlur(0.3f));
assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
}
@Test
public void testLineDasharray() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-dasharray");
assertNotNull(layer);
//Set and Get
layer.setProperties(lineDasharray(new Float[]{}));
assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{});
}
@Test
public void testLinePattern() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "line-pattern");
assertNotNull(layer);
//Set and Get
layer.setProperties(linePattern("pedestrian-polygon"));
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
}
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
}

View File

@@ -0,0 +1,232 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
* Basic smoke tests for RasterLayer
*/
@RunWith(AndroidJUnit4.class)
public class RasterLayerTest extends BaseTest {
private static final String TAG = RasterLayerTest.class.getSimpleName();
@Rule
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
private RasterLayer layer;
private OnMapReadyIdlingResource idlingResource;
private MapboxMap mapboxMap;
@Before
public void setup() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
}
@Test
public void testSetVisibility() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "visibility");
assertNotNull(layer);
//Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
//Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
public void testRasterOpacity() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "raster-opacity");
assertNotNull(layer);
//Set and Get
layer.setProperties(rasterOpacity(0.3f));
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
}
@Test
public void testRasterHueRotate() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "raster-hue-rotate");
assertNotNull(layer);
//Set and Get
layer.setProperties(rasterHueRotate(0.3f));
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
}
@Test
public void testRasterBrightnessMin() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "raster-brightness-min");
assertNotNull(layer);
//Set and Get
layer.setProperties(rasterBrightnessMin(0.3f));
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
}
@Test
public void testRasterBrightnessMax() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "raster-brightness-max");
assertNotNull(layer);
//Set and Get
layer.setProperties(rasterBrightnessMax(0.3f));
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
}
@Test
public void testRasterSaturation() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "raster-saturation");
assertNotNull(layer);
//Set and Get
layer.setProperties(rasterSaturation(0.3f));
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
}
@Test
public void testRasterContrast() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "raster-contrast");
assertNotNull(layer);
//Set and Get
layer.setProperties(rasterContrast(0.3f));
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
}
@Test
public void testRasterFadeDuration() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
Log.i(TAG, "raster-fade-duration");
assertNotNull(layer);
//Set and Get
layer.setProperties(rasterFadeDuration(0.3f));
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
}
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
}

View File

@@ -0,0 +1,61 @@
package com.mapbox.mapboxsdk.style;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Basic smoke tests for BackgroundLayer
*/
@RunWith(AndroidJUnit4.class)
public class RuntimeStyleBackgroundLayerTest
extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> {
private static final String TAG = RuntimeStyleBackgroundLayerTest.class.getSimpleName();
public RuntimeStyleBackgroundLayerTest() {
super(RuntimeStyleTestActivity.class);
}
@Before
public void setUp() throws Exception {
super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
}
@Test
public void testSetVisibility() {
getActivity().mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
Log.i(TAG, "visibility");
BackgroundLayer layer = mapboxMap.getLayerAs("background");
assertNotNull(layer);
//Get initial
assertEquals(layer.getVisibility().getValue(), Property.VISIBLE);
//Set
layer.setProperties(PropertyFactory.visibility(Property.NONE));
assertEquals(layer.getVisibility().getValue(), Property.NONE);
}
});
}
@After
public void tearDown() throws Exception {
super.tearDown();
}
}

View File

@@ -0,0 +1,91 @@
package com.mapbox.mapboxsdk.style;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* Basic smoke tests for Layer and Source
*/
@RunWith(AndroidJUnit4.class)
public class RuntimeStyleTests extends BaseTest {
@Rule
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
private OnMapReadyIdlingResource idlingResource;
@Before
public void registerIdlingResource() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
}
@Test
public void testGetAddRemoveLayer() {
checkViewIsDisplayed(R.id.mapView);
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
//Get initial
assertNotNull(mapboxMap.getLayer("building"));
//Remove
try {
mapboxMap.removeLayer("building");
} catch (NoSuchLayerException e) {
assertFalse(true);
}
assertNull(mapboxMap.getLayer("building"));
//Add
FillLayer layer = new FillLayer("building", "composite");
layer.setSourceLayer("building");
mapboxMap.addLayer(layer);
assertNotNull(mapboxMap.getLayer("building"));
try {
layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
assertTrue("Never reached as the reference is invalid after adding", false);
} catch (Exception e) {
//Expected, reference is no longer valid
}
}
@Test
public void testAddRemoveSource() {
checkViewIsDisplayed(R.id.mapView);
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
mapboxMap.removeSource("my-source");
}
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
}

View File

@@ -0,0 +1,54 @@
package com.mapbox.mapboxsdk.style;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTimingTestActivity;
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Basic smoke tests for adding Layer and Source as early as possible (in onCreate)
*/
@RunWith(AndroidJUnit4.class)
public class RuntimeStyleTimingTests extends BaseTest {
@Rule
public final ActivityTestRule<RuntimeStyleTimingTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTimingTestActivity.class);
private OnMapReadyIdlingResource idlingResource;
@Before
public void registerIdlingResource() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
}
@Test
public void testGetAddRemoveLayer() {
checkViewIsDisplayed(R.id.mapView);
//We're good if it didn't crash
}
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
}

View File

@@ -0,0 +1,116 @@
<%
const type = locals.type;
const properties = locals.properties;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.style;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
* Basic smoke tests for <%- camelize(type) %>Layer
*/
@RunWith(AndroidJUnit4.class)
public class <%- camelize(type) %>LayerTest extends BaseTest {
private static final String TAG = <%- camelize(type) %>LayerTest.class.getSimpleName();
@Rule
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
private <%- camelize(type) %>Layer layer;
private OnMapReadyIdlingResource idlingResource;
private MapboxMap mapboxMap;
@Before
public void setup() {
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
Espresso.registerIdlingResources(idlingResource);
}
@Test
public void testSetVisibility() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
<% if (type === 'background') { -%>
Log.i(TAG, "Retrieving layer");
layer = mapboxMap.getLayerAs("background");
<% } else { -%>
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
<% } -%>
Log.i(TAG, "visibility");
assertNotNull(layer);
//Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
//Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
<% for (const property of properties) { -%>
@Test
public void test<%- camelize(property.name) %>() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
<% if (type === 'background') { -%>
Log.i(TAG, "Retrieving layer");
layer = mapboxMap.getLayerAs("background");
<% } else { -%>
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.addLayer(layer);
//Layer reference is now stale, get new reference
layer = mapboxMap.getLayerAs("my-layer");
}
<% } -%>
Log.i(TAG, "<%- property.name %>");
assertNotNull(layer);
//Set and Get
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
}
<% } -%>
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
}

View File

@@ -0,0 +1,51 @@
package com.mapbox.mapboxsdk.testapp.espresso.utils;
import android.app.Activity;
import android.support.test.espresso.IdlingResource;
import android.util.Log;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import java.lang.reflect.Field;
public class OnMapReadyIdlingResource implements IdlingResource {
private final Activity activity;
private IdlingResource.ResourceCallback resourceCallback;
public OnMapReadyIdlingResource(Activity activity) {
this.activity = activity;
}
@Override
public String getName() {
return getClass().getSimpleName();
}
@Override
public boolean isIdleNow() {
boolean idle = isMapboxMapReady();
if (idle && resourceCallback != null) {
resourceCallback.onTransitionToIdle();
}
return idle;
}
@Override
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
this.resourceCallback = resourceCallback;
}
private boolean isMapboxMapReady() {
try {
Field field = activity.getClass().getDeclaredField("mapboxMap");
field.setAccessible(true);
Object value = field.get(activity);
Log.e(MapboxConstants.TAG, "isMapboxReady called with value " + (value != null));
return value != null;
} catch (Exception e) {
Log.e(MapboxConstants.TAG, "could not reflect", e);
return false;
}
}
}

View File

@@ -317,6 +317,11 @@
android:value="@string/category_imagegenerator" />
</activity>
<!-- For Unit tests -->
<activity android:name=".activity.style.RuntimeStyleTestActivity"/>
<activity android:name=".activity.style.RuntimeStyleTimingTestActivity"/>
<!-- Configuration Settings -->
<meta-data
android:name="com.mapbox.TestEventsServer"

View File

@@ -120,8 +120,8 @@ public class FeatureOverviewActivity extends AppCompatActivity {
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startFeature(features.get(requestCode));
}else{
Snackbar.make(findViewById(android.R.id.content),"Can't open without the location permission.",Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(findViewById(android.R.id.content), "Can't open without the location permission.", Snackbar.LENGTH_SHORT).show();
}
}
@@ -147,7 +147,7 @@ public class FeatureOverviewActivity extends AppCompatActivity {
String packageName = getApplicationContext().getPackageName();
String metaDataKey = getString(R.string.category);
for (ActivityInfo info : app.activities) {
if (info.name.startsWith(packageName) && !info.name.equals(FeatureOverviewActivity.class.getName())) {
if (info.labelRes != 0 && info.name.startsWith(packageName) && !info.name.equals(FeatureOverviewActivity.class.getName())) {
String label = getString(info.labelRes);
String description = resolveString(info.descriptionRes);
String category = resolveMetaData(info.metaData, metaDataKey);
@@ -176,10 +176,10 @@ public class FeatureOverviewActivity extends AppCompatActivity {
return category;
}
private String resolveString(@StringRes int stringRes){
try{
private String resolveString(@StringRes int stringRes) {
try {
return getString(stringRes);
}catch (Resources.NotFoundException e){
} catch (Resources.NotFoundException e) {
return "-";
}
}

View File

@@ -6,18 +6,21 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.style.layers.CustomLayer;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.model.customlayer.ExampleCustomLayer;
public class CustomLayerActivity extends AppCompatActivity {
private static final String TAG = CustomLayerActivity.class.getSimpleName();
private MapboxMap mapboxMap;
private MapView mapView;
@@ -66,10 +69,14 @@ public class CustomLayerActivity extends AppCompatActivity {
private void swapCustomLayer() {
if (isShowingCustomLayer) {
mapboxMap.removeCustomLayer("custom");
try {
mapboxMap.removeLayer("custom");
} catch (NoSuchLayerException e) {
Log.e(TAG, "No custom layer to remove");
}
fab.setImageResource(R.drawable.ic_layers_24dp);
} else {
mapboxMap.addCustomLayer(new CustomLayer("custom",
mapboxMap.addLayer(new CustomLayer("custom",
ExampleCustomLayer.createContext(),
ExampleCustomLayer.InitializeFunction,
ExampleCustomLayer.RenderFunction,

View File

@@ -6,6 +6,7 @@ import android.support.annotation.RawRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
@@ -16,14 +17,17 @@ import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.Function;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.style.sources.RasterSource;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.style.sources.TileSet;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.mapbox.mapboxsdk.testapp.R;
@@ -36,6 +40,7 @@ import java.io.StringWriter;
import java.io.Writer;
import static com.mapbox.mapboxsdk.style.layers.Filter.*;
import static com.mapbox.mapboxsdk.style.layers.Function.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@@ -138,6 +143,12 @@ public class RuntimeStyleActivity extends AppCompatActivity {
case R.id.action_add_satellite_layer:
addSatelliteLayer();
return true;
case R.id.action_update_water_color_on_zoom:
updateWaterColorOnZoom();
return true;
case R.id.action_add_custom_tiles:
addCustomTileSource();
return true;
default:
return super.onOptionsItemSelected(item);
}
@@ -148,7 +159,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
for (String roadLayer : roadLayers) {
Layer layer = mapboxMap.getLayer(roadLayer);
if (layer != null) {
layer.set(visibility(false));
layer.setProperties(visibility(VISIBLE));
}
}
}
@@ -162,7 +173,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
for (String roadLayer : roadLayers) {
Layer layer = mapboxMap.getLayer(roadLayer);
if (layer != null) {
layer.set(symbolPlacement(SYMBOL_PLACEMENT_POINT));
layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT));
}
}
}
@@ -172,16 +183,16 @@ public class RuntimeStyleActivity extends AppCompatActivity {
private void setBackgroundOpacity() {
Layer background = mapboxMap.getLayer("background");
if (background != null) {
background.set(backgroundOpacity(0.2f));
background.setProperties(backgroundOpacity(0.2f));
}
}
private void setWaterColor() {
Layer water = mapboxMap.getLayer("water");
if (water != null) {
water.set(
visibility(true),
fillColor(Color.RED)
water.setProperties(
visibility(VISIBLE),
fillColor(Color.RED)
);
} else {
Toast.makeText(RuntimeStyleActivity.this, "No water layer in this style", Toast.LENGTH_SHORT).show();
@@ -210,7 +221,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
mapboxMap.addSource(source);
FillLayer layer = new FillLayer("parksLayer", "amsterdam-spots");
layer.set(
layer.setProperties(
fillColor(Color.RED),
fillOutlineColor(Color.BLUE),
fillOpacity(0.3f),
@@ -224,7 +235,18 @@ public class RuntimeStyleActivity extends AppCompatActivity {
//layer.setPaintProperty(fillColor(Color.RED)); //XXX But not after the object is attached
//Or get the object later and set it. It's all good.
mapboxMap.getLayer("parksLayer").set(fillColor(Color.RED));
mapboxMap.getLayer("parksLayer").setProperties(fillColor(Color.RED));
//You can get a typed layer, if you're sure it's of that type. Use with care
layer = mapboxMap.getLayerAs("parksLayer");
//And get some properties
PropertyValue<Boolean> fillAntialias = layer.getFillAntialias();
Log.d(TAG, "Fill anti alias: " + fillAntialias.getValue());
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
PropertyValue<String> fillTranslateAnchor = layer.getFillTranslateAnchor();
Log.d(TAG, "Fill translate anchor: " + fillTranslateAnchor.getValue());
PropertyValue<String> visibility = layer.getVisibility();
Log.d(TAG, "Visibility: " + visibility.getValue());
//Get a good look at it all
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12));
@@ -237,7 +259,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
LineLayer layer = new LineLayer("terrainLayer", "my-terrain-source");
layer.setSourceLayer("contour");
layer.set(
layer.setProperties(
lineJoin(Property.LINE_JOIN_ROUND),
lineCap(Property.LINE_CAP_ROUND),
lineColor(Color.RED),
@@ -245,17 +267,50 @@ public class RuntimeStyleActivity extends AppCompatActivity {
);
mapboxMap.addLayer(layer);
//Need to get a fresh handle
layer = mapboxMap.getLayerAs("terrainLayer");
//Make sure it's also applied after the fact
layer.setMinZoom(10);
layer.setMaxZoom(15);
layer = (LineLayer) mapboxMap.getLayer("terrainLayer");
Toast.makeText(this, String.format("Set min/max zoom to %s - %s", layer.getMinZoom(), layer.getMaxZoom()), Toast.LENGTH_SHORT).show();
}
private void addSatelliteLayer() {
//Add a source
Source source = new RasterSource("my-raster-source", "mapbox://mapbox.satellite");
Source source = new RasterSource("my-raster-source", "mapbox://mapbox.satellite").withTileSize(512);
mapboxMap.addSource(source);
//Add a layer
mapboxMap.addLayer(new RasterLayer("satellite-layer", "my-raster-source"));
}
private void updateWaterColorOnZoom() {
FillLayer layer = mapboxMap.getLayerAs("water");
if (layer == null) {
return;
}
//Set a zoom function to update the color of the water
layer.setProperties(fillColor(zoom(0.8f,
stop(1, fillColor(Color.GREEN)),
stop(4, fillColor(Color.BLUE)),
stop(12, fillColor(Color.RED)),
stop(20, fillColor(Color.BLACK))
)));
//do some animations to show it off properly
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1), 1500);
PropertyValue<String> fillColor = layer.getFillColor();
Function<String> function = fillColor.getFunction();
Log.d(TAG, "Fill color base: " + function.getBase());
Log.d(TAG, "Fill color #stops: " + function.getStops().length);
}
private String readRawResource(@RawRes int rawResource) throws IOException {
InputStream is = getResources().openRawResource(rawResource);
Writer writer = new StringWriter();
@@ -284,6 +339,17 @@ public class RuntimeStyleActivity extends AppCompatActivity {
}
}
private void addCustomTileSource() {
//Add a source
Source source = new VectorSource("custom-tile-source", new TileSet("2.1.0", "https://vector.mapzen.com/osm/all/{z}/{x}/{y}.mvt?api_key=vector-tiles-LM25tq4"));
mapboxMap.addSource(source);
//Add a layer
FillLayer layer = new FillLayer("custom-tile-layers", "custom-tile-source");
layer.setSourceLayer("water");
mapboxMap.addLayer(layer);
}
private static class DefaultCallback implements MapboxMap.CancelableCallback {
@Override

View File

@@ -0,0 +1,69 @@
package com.mapbox.mapboxsdk.testapp.activity.style;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity for unit test execution
*/
public class RuntimeStyleTestActivity extends AppCompatActivity {
private static final String TAG = RuntimeStyleTestActivity.class.getSimpleName();
public MapView mapView;
private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_runtime_style);
//Initialize map as normal
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
RuntimeStyleTestActivity.this.mapboxMap = mapboxMap;
}
});
}
public MapboxMap getMapboxMap() {
return mapboxMap;
}
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
}

View File

@@ -0,0 +1,87 @@
package com.mapbox.mapboxsdk.testapp.activity.style;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.mapbox.mapboxsdk.testapp.R;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
* Test activity for unit test execution
*/
public class RuntimeStyleTimingTestActivity extends AppCompatActivity {
private static final String TAG = RuntimeStyleTimingTestActivity.class.getSimpleName();
public MapView mapView;
private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_runtime_style);
//Initialize map as normal
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
RuntimeStyleTimingTestActivity.this.mapboxMap = mapboxMap;
VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr");
mapboxMap.addSource(museums);
CircleLayer museumsLayer = new CircleLayer("museums", "museums_source");
museumsLayer.setSourceLayer("museum-cusco");
museumsLayer.setProperties(
visibility(VISIBLE),
circleRadius(8f),
circleColor(Color.argb(1, 55, 148, 179))
);
mapboxMap.addLayer(museumsLayer);
}
});
}
public MapboxMap getMapboxMap() {
return mapboxMap;
}
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
}

View File

@@ -34,4 +34,12 @@
android:id="@+id/action_add_satellite_layer"
android:title="Add a satellite layer"
mapbox:showAsAction="never"/>
<item
android:id="@+id/action_update_water_color_on_zoom"
android:title="Change the water color on zoom"
mapbox:showAsAction="never"/>
<item
android:id="@+id/action_add_custom_tiles"
android:title="Custom tiles"
mapbox:showAsAction="never"/>
</menu>

View File

@@ -0,0 +1,29 @@
package com.mapbox.mapboxsdk.style.layers;
import org.junit.Test;
import static com.mapbox.mapboxsdk.style.layers.Function.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import static org.junit.Assert.*;
/**
* Tests Function
*/
public class FunctionTest {
@Test
public void testZoomFunction() {
Function zoomF = zoom(
stop(1f, lineBlur(1f)),
stop(10f, lineBlur(20f))
);
assertNotNull(zoomF.toValueObject());
assertArrayEquals(
new Object[]{new Object[]{1f, 1f}, new Object[]{10f, 20f}},
(Object[]) zoomF.toValueObject().get("stops")
);
}
}

View File

@@ -43,6 +43,7 @@
'src/style/layers/line_layer.cpp',
'src/style/layers/raster_layer.cpp',
'src/style/layers/symbol_layer.cpp',
'src/style/layers/custom_layer.cpp',
'../default/string_stdlib.cpp',
'../default/image.cpp',
'../default/png_reader.cpp',

View File

@@ -22,18 +22,11 @@ global.camelizeWithLeadingLowercase = function (str) {
});
}
global.snakeCaseUpper = function (str) {
global.snakeCaseUpper = function snakeCaseUpper(str) {
return str.replace(/-/g, "_").toUpperCase();
}
global.propertyType = function propertyType(property) {
//TODO: Doe we want these exceptions?
// if (/-translate-anchor$/.test(property.name)) {
// return 'TranslateAnchorType';
// }
// if (/-(rotation|pitch)-alignment$/.test(property.name)) {
// return 'AlignmentType';
// }
switch (property.type) {
case 'boolean':
return 'Boolean';
@@ -42,9 +35,9 @@ global.propertyType = function propertyType(property) {
case 'string':
return 'String';
case 'enum':
return `String`;
return 'String';
case 'color':
return `String`;
return 'String';
case 'array':
return `${propertyType({type:property.value})}[]`;
default:
@@ -52,6 +45,53 @@ global.propertyType = function propertyType(property) {
}
}
global.propertyJNIType = function propertyJNIType(property) {
switch (property.type) {
case 'boolean':
return 'jboolean';
case 'jfloat':
return 'Float';
case 'String':
return 'String';
case 'enum':
return 'String';
case 'color':
return 'String';
case 'array':
return `jarray<${propertyType({type:property.value})}[]>`;
default:
return 'jobject*';
}
}
global.propertyNativeType = function (property) {
if (/-translate-anchor$/.test(property.name)) {
return 'TranslateAnchorType';
}
if (/-(rotation|pitch)-alignment$/.test(property.name)) {
return 'AlignmentType';
}
switch (property.type) {
case 'boolean':
return 'bool';
case 'number':
return 'float';
case 'string':
return 'std::string';
case 'enum':
return `${camelize(property.name)}Type`;
case 'color':
return `Color`;
case 'array':
if (property.length) {
return `std::array<${propertyType({type: property.value})}, ${property.length}>`;
} else {
return `std::vector<${propertyType({type: property.value})}>`;
}
default: throw new Error(`unknown type for ${property.name}`)
}
}
global.propertyTypeAnnotation = function propertyTypeAnnotation(property) {
switch (property.type) {
case 'enum':
@@ -61,6 +101,42 @@ global.propertyTypeAnnotation = function propertyTypeAnnotation(property) {
}
};
global.defaultValueJava = function(property) {
if(property.name.endsWith("-pattern")) {
return '"pedestrian-polygon"';
}
if(property.name.endsWith("-font")) {
return 'new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}';
}
switch (property.type) {
case 'boolean':
return 'true';
case 'number':
return '0.3f';
case 'string':
return '"' + property['default'] + '"';
case 'enum':
return snakeCaseUpper(property.name) + "_" + snakeCaseUpper(property.values[0]);
case 'color':
return '"rgba(0, 0, 0, 1)"';
case 'array':
switch (property.value) {
case 'string':
return '[' + property['default'] + "]";
case 'number':
var result ='new Float[]{';
for (var i = 0; i < property.length; i++) {
result += "0f";
if (i +1 != property.length) {
result += ",";
}
}
return result + "}";
}
default: throw new Error(`unknown type for ${property.name}`)
}
}
//Process Layers
const layers = spec.layer.type.values.map((type) => {
const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => {
@@ -81,24 +157,27 @@ const layers = spec.layer.type.values.map((type) => {
type: type,
layoutProperties: layoutProperties,
paintProperties: paintProperties,
properties: layoutProperties.concat(paintProperties)
};
});
const layerHpp = ejs.compile(fs.readFileSync('platform/android/scripts/layer.hpp.ejs', 'utf8'), {strict: true});
const layerCpp = ejs.compile(fs.readFileSync('platform/android/scripts/layer.cpp.ejs', 'utf8'), {strict: true});
const layerJava = ejs.compile(fs.readFileSync('platform/android/scripts/layer.java.ejs', 'utf8'), {strict: true});
const layerHpp = ejs.compile(fs.readFileSync('platform/android/src/style/layers/layer.hpp.ejs', 'utf8'), {strict: true});
const layerCpp = ejs.compile(fs.readFileSync('platform/android/src/style/layers/layer.cpp.ejs', 'utf8'), {strict: true});
const layerJava = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs', 'utf8'), {strict: true});
const layerJavaUnitTests = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/layer.junit.ejs', 'utf8'), {strict: true});
for (const layer of layers) {
fs.writeFileSync(`platform/android/src/style/layers/${layer.type}_layer.hpp`, layerHpp(layer));
fs.writeFileSync(`platform/android/src/style/layers/${layer.type}_layer.cpp`, layerCpp(layer));
fs.writeFileSync(`platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/${camelize(layer.type)}Layer.java`, layerJava(layer));
fs.writeFileSync(`platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/${camelize(layer.type)}LayerTest.java`, layerJavaUnitTests(layer));
}
//Process all layer properties
const layoutProperties = _(layers).map('layoutProperties').flatten().value();
const paintProperties = _(layers).map('paintProperties').flatten().value();
const propertiesTemplate = ejs.compile(fs.readFileSync('platform/android/scripts/layer_property_factory.java.ejs', 'utf8'), {strict: true});
const propertiesTemplate = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs', 'utf8'), {strict: true});
fs.writeFileSync(
`platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java`,
propertiesTemplate({layoutProperties: layoutProperties, paintProperties: paintProperties})
@@ -106,9 +185,22 @@ fs.writeFileSync(
//Create types for the enum properties
const enumProperties = _(layoutProperties).union(paintProperties).filter({'type': 'enum'}).value();
const enumPropertyTemplate = ejs.compile(fs.readFileSync('platform/android/scripts/layer_property.java.ejs', 'utf8'), {strict: true});
const enumPropertyJavaTemplate = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs', 'utf8'), {strict: true});
fs.writeFileSync(
`platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java`,
enumPropertyTemplate({properties: enumProperties})
enumPropertyJavaTemplate({properties: enumProperties})
);
//De-dup types before generating cpp headers
const enumPropertiesDeDup = _(enumProperties).uniq(global.propertyNativeType).value();
const enumPropertyHppTypeStringValueTemplate = ejs.compile(fs.readFileSync('platform/android/src/style/conversion/types_string_values.hpp.ejs', 'utf8'), {strict: true});
fs.writeFileSync(
`platform/android/src/style/conversion/types_string_values.hpp`,
enumPropertyHppTypeStringValueTemplate({properties: enumPropertiesDeDup})
);
const enumPropertyHppTypeTemplate = ejs.compile(fs.readFileSync('platform/android/src/style/conversion/types.hpp.ejs', 'utf8'), {strict: true});
fs.writeFileSync(
`platform/android/src/style/conversion/types.hpp`,
enumPropertyHppTypeTemplate({properties: enumPropertiesDeDup})
);

View File

@@ -0,0 +1,95 @@
#pragma once
#include "conversion.hpp"
#include <mbgl/util/optional.hpp>
#include <jni/jni.hpp>
#include <string>
#include <array>
#include <vector>
#include <sstream>
namespace mbgl {
namespace android {
namespace conversion {
template <>
struct Converter<jni::jobject*, bool> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const bool& value) const {
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/Boolean")).release();
static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "(Z)V");
return {&jni::NewObject(env, *javaClass, *constructor, (jboolean) value)};
}
};
template <>
struct Converter<jni::jobject*, float> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const float& value) const {
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/Float")).release();
static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "(F)V");
return {&jni::NewObject(env, *javaClass, *constructor, (jfloat) value)};
}
};
template <>
struct Converter<jni::jobject*, std::string> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const std::string& value) const {
return {jni::Make<jni::String>(env, value).Get()};
}
};
template <>
struct Converter<jni::jobject*, Color> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const Color& value) const {
std::stringstream sstream;
sstream << "rgba(" << value.r << ", " << value.g << ", " << value.b << ", " << value.a << ")";
std::string result = sstream.str();
return convert<jni::jobject*, std::string>(env, result);
}
};
template <std::size_t N>
struct Converter<jni::jobject*, std::array<float, N>> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const std::array<float, N>& value) const {
std::vector<float> v;
for (const float& id : value) {
v.push_back(id);
}
return convert<jni::jobject*, std::vector<float>>(env, v);
}
};
template <>
struct Converter<jni::jobject*, std::vector<std::string>> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const std::vector<std::string>& value) const {
static jni::jclass* stringCass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/String")).release();
jni::jarray<jni::jobject>& jarray = jni::NewObjectArray(env, value.size(), *stringCass);
for(size_t i = 0; i < value.size(); i = i + 1) {
Result<jni::jobject*> converted = convert<jni::jobject*, std::string>(env, value.at(i));
jni::SetObjectArrayElement(env, jarray, i, *converted);
}
return &jarray;
}
};
template <>
struct Converter<jni::jobject*, std::vector<float>> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const std::vector<float>& value) const {
static jni::jclass* floatClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/lang/Float")).release();
jni::jarray<jni::jobject>& jarray = jni::NewObjectArray(env, value.size(), *floatClass);
for(size_t i = 0; i < value.size(); i = i + 1) {
Result<jni::jobject*> converted = convert<jni::jobject*, float>(env, value.at(i));
jni::SetObjectArrayElement(env, jarray, i, *converted);
}
return &jarray;
}
};
} // namespace conversion
} // namespace style
} // namespace mbgl

View File

@@ -0,0 +1,50 @@
#pragma once
#include <mbgl/util/variant.hpp>
#include <jni/jni.hpp>
#include <string>
namespace mbgl {
namespace android {
namespace conversion {
struct Error { std::string message; };
template <class T>
class Result : private variant<T, Error> {
public:
using variant<T, Error>::variant;
explicit operator bool() const {
return this->template is<T>();
}
T& operator*() {
assert(this->template is<T>());
return this->template get<T>();
}
const T& operator*() const {
assert(this->template is<T>());
return this->template get<T>();
}
const Error& error() const {
assert(this->template is<Error>());
return this->template get<Error>();
}
};
template <class T, class V>
struct Converter;
template <class T, typename V, class...Args>
Result<T> convert(jni::JNIEnv& env, const V& value, Args&&...args) {
return Converter<T, V>()(env, value, std::forward<Args>(args)...);
}
} // namespace conversion
} // namespace android
} // namespace mbgl

View File

@@ -18,7 +18,6 @@
#include <mbgl/map/camera.hpp>
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/style/layer.hpp>
#include <mbgl/style/layers/custom_layer.hpp>
#include <mbgl/sprite/sprite_image.hpp>
#include <mbgl/platform/event.hpp>
#include <mbgl/platform/log.hpp>
@@ -102,13 +101,6 @@ jni::jfieldID* rectFTopId = nullptr;
jni::jfieldID* rectFRightId = nullptr;
jni::jfieldID* rectFBottomId = nullptr;
jni::jclass* customLayerClass = nullptr;
jni::jfieldID* customLayerIdId = nullptr;
jni::jfieldID* customLayerContextId = nullptr;
jni::jfieldID* customLayerInitializeFunctionId = nullptr;
jni::jfieldID* customLayerRenderFunctionId = nullptr;
jni::jfieldID* customLayerDeinitializeFunctionId = nullptr;
// Offline declarations start
jni::jfieldID* offlineManagerClassPtrId = nullptr;
@@ -1069,26 +1061,6 @@ void nativeFlyTo(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdouble
nativeMapView->getMap().flyTo(cameraOptions, animationOptions);
}
void nativeAddCustomLayer(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jni::jobject* customLayer, jni::jstring* before) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddCustomLayer");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().addLayer(std::make_unique<mbgl::style::CustomLayer>(
std_string_from_jstring(env, reinterpret_cast<jni::jstring*>(jni::GetField<jni::jobject*>(*env, customLayer, *customLayerIdId))),
reinterpret_cast<mbgl::style::CustomLayerInitializeFunction>(jni::GetField<jlong>(*env, customLayer, *customLayerInitializeFunctionId)),
reinterpret_cast<mbgl::style::CustomLayerRenderFunction>(jni::GetField<jlong>(*env, customLayer, *customLayerRenderFunctionId)),
reinterpret_cast<mbgl::style::CustomLayerDeinitializeFunction>(jni::GetField<jlong>(*env, customLayer, *customLayerDeinitializeFunctionId)),
reinterpret_cast<void*>(jni::GetField<jlong>(*env, customLayer, *customLayerContextId))),
before ? mbgl::optional<std::string>(std_string_from_jstring(env, before)) : mbgl::optional<std::string>());
}
void nativeRemoveCustomLayer(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jni::jstring* id) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRemoveCustomLayer");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().removeLayer(std_string_from_jstring(env, id));
}
jni::jobject* nativeGetLayer(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jni::jstring* layerId) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetLayer");
@@ -1693,14 +1665,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
rectFTopId = &jni::GetFieldID(env, *rectFClass, "top", "F");
rectFBottomId = &jni::GetFieldID(env, *rectFClass, "bottom", "F");
customLayerClass = &jni::FindClass(env, "com/mapbox/mapboxsdk/layers/CustomLayer");
customLayerClass = jni::NewGlobalRef(env, customLayerClass).release();
customLayerIdId = &jni::GetFieldID(env, *customLayerClass, "mID", "Ljava/lang/String;");
customLayerContextId = &jni::GetFieldID(env, *customLayerClass, "mContext", "J");
customLayerInitializeFunctionId = &jni::GetFieldID(env, *customLayerClass, "mInitializeFunction", "J");
customLayerRenderFunctionId = &jni::GetFieldID(env, *customLayerClass, "mRenderFunction", "J");
customLayerDeinitializeFunctionId = &jni::GetFieldID(env, *customLayerClass, "mDeinitializeFunction", "J");
jni::jclass& nativeMapViewClass = jni::FindClass(env, "com/mapbox/mapboxsdk/maps/NativeMapView");
onInvalidateId = &jni::GetMethodID(env, nativeMapViewClass, "onInvalidate", "()V");
@@ -1779,8 +1743,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
MAKE_NATIVE_METHOD(nativeJumpTo, "(JDDDDD)V"),
MAKE_NATIVE_METHOD(nativeEaseTo, "(JDDDJDDZ)V"),
MAKE_NATIVE_METHOD(nativeFlyTo, "(JDDDJDD)V"),
MAKE_NATIVE_METHOD(nativeAddCustomLayer, "(JLcom/mapbox/mapboxsdk/layers/CustomLayer;Ljava/lang/String;)V"),
MAKE_NATIVE_METHOD(nativeRemoveCustomLayer, "(JLjava/lang/String;)V"),
MAKE_NATIVE_METHOD(nativeGetLayer, "(JLjava/lang/String;)Lcom/mapbox/mapboxsdk/style/layers/Layer;"),
MAKE_NATIVE_METHOD(nativeAddLayer, "(JJLjava/lang/String;)V"),
MAKE_NATIVE_METHOD(nativeRemoveLayer, "(JLjava/lang/String;)V"),

View File

@@ -13,10 +13,6 @@ namespace mbgl {
namespace style {
namespace conversion {
//XXX
#pragma GCC diagnostic ignored "-Wunused-parameter"
inline bool isUndefined(const mbgl::android::Value& value) {
return value.isNull();
}
@@ -48,7 +44,7 @@ inline optional<mbgl::android::Value> objectMember(const mbgl::android::Value& v
}
template <class Fn>
optional<Error> eachMember(const mbgl::android::Value& value, Fn&& fn) {
optional<Error> eachMember(const mbgl::android::Value&, Fn&&) {
//TODO
mbgl::Log::Warning(mbgl::Event::Android, "eachMember not implemented");
return {};
@@ -92,4 +88,4 @@ inline optional<Value> toValue(const mbgl::android::Value& value) {
} // namespace conversion
} // namespace style
} // namespace mbgl
} // namespace mbgl

View File

@@ -0,0 +1,52 @@
#pragma once
#include <mbgl/style/property_value.hpp>
#include "../../conversion/conversion.hpp"
#include "../../conversion/constant.hpp"
#include "types.hpp"
#include "function.hpp"
#include <jni/jni.hpp>
#include <tuple>
#include <vector>
namespace mbgl {
namespace android {
namespace conversion {
template <class T>
inline jni::jobject* toFunctionStopJavaArray(jni::JNIEnv& env, std::vector<std::pair<float, T>> value) {
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/layers/Function$Stop")).release();
static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
jni::jarray<jni::jobject>& jarray = jni::NewObjectArray(env, value.size(), *javaClass);
for(size_t i = 0; i < value.size(); i = i + 1) {
jni::SetObjectArrayElement(env, jarray, i, &jni::NewObject(env, *javaClass, *constructor, value[i].first, *convert<jni::jobject*, T>(env, value[i].second)));
}
return &jarray;
}
template <class T>
struct Converter<jni::jobject*, mbgl::style::Function<T>> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::Function<T>& value) const {
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/layers/Function")).release();
static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "([Lcom/mapbox/mapboxsdk/style/layers/Function$Stop;)V");
static jni::jmethodID* withBase = &jni::GetMethodID(env, *javaClass, "withBase", "(F)Lcom/mapbox/mapboxsdk/style/layers/Function;");
//Create object
jni::jobject* jfunction = &jni::NewObject(env, *javaClass, *constructor, *toFunctionStopJavaArray(env, value.getStops()));
//Set base
jni::CallMethod<jni::jobject*>(env, jfunction, *withBase, value.getBase());
return {jfunction};
}
};
} // namespace conversion
} // namespace android
} // namespace mbgl

View File

@@ -0,0 +1,38 @@
#pragma once
#include <mbgl/style/property_value.hpp>
#include "../../conversion/conversion.hpp"
#include "../../conversion/constant.hpp"
#include "types.hpp"
#include "function.hpp"
namespace mbgl {
namespace android {
namespace conversion {
template <class T>
struct Converter<jni::jobject*, mbgl::style::PropertyValue<T>> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::PropertyValue<T>& value) const {
if(value.isUndefined()) {
//Return a nullptr representing a Java null value
return {nullptr};
} else if (value.isConstant()) {
//Time to convert the constant value
Result<jni::jobject*> result = convert<jni::jobject*, T>(env, value.asConstant());
return {*result};
//return converted;
} else if (value.isFunction()) {
//Must be a function than
return convert<jni::jobject*, mbgl::style::Function<T>>(env, value.asFunction());
} else {
throw std::runtime_error("Unknown property value type");
}
}
};
} // namespace conversion
} // namespace android
} // namespace mbgl

View File

@@ -0,0 +1,98 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
#pragma once
#include "types_string_values.hpp"
#include "../../conversion/conversion.hpp"
#include "../../conversion/constant.hpp"
#include <mbgl/style/types.hpp>
#include <mbgl/util/optional.hpp>
#include <jni/jni.hpp>
#include <string>
namespace mbgl {
namespace android {
namespace conversion {
template <>
struct Converter<jni::jobject*, mbgl::style::VisibilityType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::VisibilityType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::LineCapType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::LineCapType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::LineJoinType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::LineJoinType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::SymbolPlacementType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::SymbolPlacementType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::AlignmentType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::AlignmentType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::IconTextFitType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::IconTextFitType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::TextJustifyType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextJustifyType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::TextAnchorType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextAnchorType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::TextTransformType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextTransformType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::TranslateAnchorType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TranslateAnchorType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::CirclePitchScaleType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::CirclePitchScaleType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
} // namespace conversion
} // namespace android
} // namespace mbgl

View File

@@ -0,0 +1,40 @@
<%
const properties = locals.properties;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
#pragma once
#include "types_string_values.hpp"
#include "../../conversion/conversion.hpp"
#include "../../conversion/constant.hpp"
#include <mbgl/style/types.hpp>
#include <mbgl/util/optional.hpp>
#include <jni/jni.hpp>
#include <string>
namespace mbgl {
namespace android {
namespace conversion {
template <>
struct Converter<jni::jobject*, mbgl::style::VisibilityType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::VisibilityType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
<% for (const property of properties) { -%>
template <>
struct Converter<jni::jobject*, mbgl::style::<%- propertyNativeType(property) %>> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::<%- propertyNativeType(property) %>& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
<% } -%>
} // namespace conversion
} // namespace android
} // namespace mbgl

View File

@@ -0,0 +1,209 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
#pragma once
#include <mbgl/style/types.hpp>
#include <string>
#include <stdexcept>
namespace mbgl {
namespace android {
namespace conversion {
//visibility
inline std::string toString(mbgl::style::VisibilityType value) {
switch (value) {
case mbgl::style::VisibilityType::Visible:
return "visible";
break;
case mbgl::style::VisibilityType::None:
return "none";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//line-cap
inline std::string toString(mbgl::style::LineCapType value) {
switch (value) {
case mbgl::style::LineCapType::Butt:
return "butt";
break;
case mbgl::style::LineCapType::Round:
return "round";
break;
case mbgl::style::LineCapType::Square:
return "square";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//line-join
inline std::string toString(mbgl::style::LineJoinType value) {
switch (value) {
case mbgl::style::LineJoinType::Bevel:
return "bevel";
break;
case mbgl::style::LineJoinType::Round:
return "round";
break;
case mbgl::style::LineJoinType::Miter:
return "miter";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//symbol-placement
inline std::string toString(mbgl::style::SymbolPlacementType value) {
switch (value) {
case mbgl::style::SymbolPlacementType::Point:
return "point";
break;
case mbgl::style::SymbolPlacementType::Line:
return "line";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//icon-rotation-alignment
inline std::string toString(mbgl::style::AlignmentType value) {
switch (value) {
case mbgl::style::AlignmentType::Map:
return "map";
break;
case mbgl::style::AlignmentType::Viewport:
return "viewport";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//icon-text-fit
inline std::string toString(mbgl::style::IconTextFitType value) {
switch (value) {
case mbgl::style::IconTextFitType::None:
return "none";
break;
case mbgl::style::IconTextFitType::Both:
return "both";
break;
case mbgl::style::IconTextFitType::Width:
return "width";
break;
case mbgl::style::IconTextFitType::Height:
return "height";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//text-justify
inline std::string toString(mbgl::style::TextJustifyType value) {
switch (value) {
case mbgl::style::TextJustifyType::Left:
return "left";
break;
case mbgl::style::TextJustifyType::Center:
return "center";
break;
case mbgl::style::TextJustifyType::Right:
return "right";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//text-anchor
inline std::string toString(mbgl::style::TextAnchorType value) {
switch (value) {
case mbgl::style::TextAnchorType::Center:
return "center";
break;
case mbgl::style::TextAnchorType::Left:
return "left";
break;
case mbgl::style::TextAnchorType::Right:
return "right";
break;
case mbgl::style::TextAnchorType::Top:
return "top";
break;
case mbgl::style::TextAnchorType::Bottom:
return "bottom";
break;
case mbgl::style::TextAnchorType::TopLeft:
return "top-left";
break;
case mbgl::style::TextAnchorType::TopRight:
return "top-right";
break;
case mbgl::style::TextAnchorType::BottomLeft:
return "bottom-left";
break;
case mbgl::style::TextAnchorType::BottomRight:
return "bottom-right";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//text-transform
inline std::string toString(mbgl::style::TextTransformType value) {
switch (value) {
case mbgl::style::TextTransformType::None:
return "none";
break;
case mbgl::style::TextTransformType::Uppercase:
return "uppercase";
break;
case mbgl::style::TextTransformType::Lowercase:
return "lowercase";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//fill-translate-anchor
inline std::string toString(mbgl::style::TranslateAnchorType value) {
switch (value) {
case mbgl::style::TranslateAnchorType::Map:
return "map";
break;
case mbgl::style::TranslateAnchorType::Viewport:
return "viewport";
break;
default:
throw std::runtime_error("Not implemented");
}
}
//circle-pitch-scale
inline std::string toString(mbgl::style::CirclePitchScaleType value) {
switch (value) {
case mbgl::style::CirclePitchScaleType::Map:
return "map";
break;
case mbgl::style::CirclePitchScaleType::Viewport:
return "viewport";
break;
default:
throw std::runtime_error("Not implemented");
}
}
} // namespace conversion
} // namespace android
} // namespace mbgl

View File

@@ -0,0 +1,48 @@
<%
const properties = locals.properties;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
#pragma once
#include <mbgl/style/types.hpp>
#include <string>
#include <stdexcept>
namespace mbgl {
namespace android {
namespace conversion {
//visibility
inline std::string toString(mbgl::style::VisibilityType value) {
switch (value) {
case mbgl::style::VisibilityType::Visible:
return "visible";
break;
case mbgl::style::VisibilityType::None:
return "none";
break;
default:
throw std::runtime_error("Not implemented");
}
}
<% for (const property of properties) { -%>
//<%- property.name %>
inline std::string toString(mbgl::style::<%- propertyNativeType(property) %> value) {
switch (value) {
<% for (const value of property.values) { -%>
case mbgl::style::<%- propertyNativeType(property) %>::<%- camelize(value) %>:
return "<%- value %>";
break;
<% } -%>
default:
throw std::runtime_error("Not implemented");
}
}
<% } -%>
} // namespace conversion
} // namespace android
} // namespace mbgl

View File

@@ -4,25 +4,41 @@
#include <string>
//XXX
#include <mbgl/platform/log.hpp>
#include "../conversion/property_value.hpp"
namespace mbgl {
namespace android {
BackgroundLayer::BackgroundLayer(jni::JNIEnv& env, jni::String layerId)
: Layer(env, std::make_unique<mbgl::style::BackgroundLayer>(jni::Make<std::string>(env, layerId))) {
mbgl::Log::Debug(mbgl::Event::JNI, "BackgroundLayer constructed, owning reference");
}
BackgroundLayer::BackgroundLayer(mbgl::Map& map, mbgl::style::BackgroundLayer& coreLayer)
: Layer(map, coreLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "BackgroundLayer Non-owning reference constructor");
}
BackgroundLayer::~BackgroundLayer() = default;
// Property getters
jni::Object<jni::ObjectTag> BackgroundLayer::getBackgroundColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> BackgroundLayer::getBackgroundPattern(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundPattern());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> BackgroundLayer::getBackgroundOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::BackgroundLayer>()->BackgroundLayer::getBackgroundOpacity());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Class<BackgroundLayer> BackgroundLayer::javaClass;
jni::jobject* BackgroundLayer::createJavaPeer(jni::JNIEnv& env) {
@@ -31,8 +47,6 @@ namespace android {
}
void BackgroundLayer::registerNative(jni::JNIEnv& env) {
mbgl::Log::Debug(mbgl::Event::JNI, "Registering native background layer");
//Lookup the class
BackgroundLayer::javaClass = *jni::Class<BackgroundLayer>::Find(env).NewGlobalRef(env).release();
@@ -43,9 +57,10 @@ namespace android {
env, BackgroundLayer::javaClass, "nativePtr",
std::make_unique<BackgroundLayer, JNIEnv&, jni::String>,
"initialize",
"finalize"
);
"finalize",
METHOD(&BackgroundLayer::getBackgroundColor, "nativeGetBackgroundColor"),
METHOD(&BackgroundLayer::getBackgroundPattern, "nativeGetBackgroundPattern"),
METHOD(&BackgroundLayer::getBackgroundOpacity, "nativeGetBackgroundOpacity"));
}
} // namespace android

View File

@@ -24,8 +24,16 @@ public:
~BackgroundLayer();
// Property getters
jni::Object<jni::ObjectTag> getBackgroundColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getBackgroundPattern(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getBackgroundOpacity(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
};
}; // class BackgroundLayer
} // namespace android
} // namespace mbgl

View File

@@ -4,25 +4,65 @@
#include <string>
//XXX
#include <mbgl/platform/log.hpp>
#include "../conversion/property_value.hpp"
namespace mbgl {
namespace android {
CircleLayer::CircleLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
: Layer(env, std::make_unique<mbgl::style::CircleLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
mbgl::Log::Debug(mbgl::Event::JNI, "CircleLayer constructed, owning reference");
}
CircleLayer::CircleLayer(mbgl::Map& map, mbgl::style::CircleLayer& coreLayer)
: Layer(map, coreLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "CircleLayer Non-owning reference constructor");
}
CircleLayer::~CircleLayer() = default;
// Property getters
jni::Object<jni::ObjectTag> CircleLayer::getCircleRadius(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleRadius());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> CircleLayer::getCircleColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> CircleLayer::getCircleBlur(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleBlur());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> CircleLayer::getCircleOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleOpacity());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> CircleLayer::getCircleTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleTranslate());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> CircleLayer::getCircleTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleTranslateAnchor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> CircleLayer::getCirclePitchScale(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCirclePitchScale());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Class<CircleLayer> CircleLayer::javaClass;
jni::jobject* CircleLayer::createJavaPeer(jni::JNIEnv& env) {
@@ -31,8 +71,6 @@ namespace android {
}
void CircleLayer::registerNative(jni::JNIEnv& env) {
mbgl::Log::Debug(mbgl::Event::JNI, "Registering native background layer");
//Lookup the class
CircleLayer::javaClass = *jni::Class<CircleLayer>::Find(env).NewGlobalRef(env).release();
@@ -43,9 +81,14 @@ namespace android {
env, CircleLayer::javaClass, "nativePtr",
std::make_unique<CircleLayer, JNIEnv&, jni::String, jni::String>,
"initialize",
"finalize"
);
"finalize",
METHOD(&CircleLayer::getCircleRadius, "nativeGetCircleRadius"),
METHOD(&CircleLayer::getCircleColor, "nativeGetCircleColor"),
METHOD(&CircleLayer::getCircleBlur, "nativeGetCircleBlur"),
METHOD(&CircleLayer::getCircleOpacity, "nativeGetCircleOpacity"),
METHOD(&CircleLayer::getCircleTranslate, "nativeGetCircleTranslate"),
METHOD(&CircleLayer::getCircleTranslateAnchor, "nativeGetCircleTranslateAnchor"),
METHOD(&CircleLayer::getCirclePitchScale, "nativeGetCirclePitchScale"));
}
} // namespace android

View File

@@ -24,8 +24,24 @@ public:
~CircleLayer();
// Property getters
jni::Object<jni::ObjectTag> getCircleRadius(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getCircleColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getCircleBlur(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getCircleOpacity(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getCircleTranslate(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getCircleTranslateAnchor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getCirclePitchScale(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
};
}; // class CircleLayer
} // namespace android
} // namespace mbgl

View File

@@ -0,0 +1,57 @@
#include "custom_layer.hpp"
#include <string>
#include <mbgl/platform/log.hpp>
namespace mbgl {
namespace android {
CustomLayer::CustomLayer(jni::JNIEnv& env, jni::String layerId, jni::jlong initializeFunction, jni::jlong renderFunction, jni::jlong deinitializeFunction, jni::jlong context)
: Layer(env, std::make_unique<mbgl::style::CustomLayer>(
jni::Make<std::string>(env, layerId),
reinterpret_cast<mbgl::style::CustomLayerInitializeFunction>(initializeFunction),
reinterpret_cast<mbgl::style::CustomLayerRenderFunction>(renderFunction),
reinterpret_cast<mbgl::style::CustomLayerDeinitializeFunction>(deinitializeFunction),
reinterpret_cast<void*>(context))
) {
}
CustomLayer::CustomLayer(mbgl::Map& map, mbgl::style::CustomLayer& coreLayer)
: Layer(map, coreLayer) {
}
CustomLayer::~CustomLayer() = default;
void CustomLayer::update(jni::JNIEnv&) {
if (map) {
map->update(mbgl::Update::Repaint);
} else {
Log::Error(mbgl::Event::JNI, "No map reference, cannot update");
}
}
jni::Class<CustomLayer> CustomLayer::javaClass;
jni::jobject* CustomLayer::createJavaPeer(jni::JNIEnv& env) {
static auto constructor = CustomLayer::javaClass.template GetConstructor<jni::jlong>(env);
return CustomLayer::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void CustomLayer::registerNative(jni::JNIEnv& env) {
//Lookup the class
CustomLayer::javaClass = *jni::Class<CustomLayer>::Find(env).NewGlobalRef(env).release();
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
//Register the peer
jni::RegisterNativePeer<CustomLayer>(
env, CustomLayer::javaClass, "nativePtr",
std::make_unique<CustomLayer, JNIEnv&, jni::String, jni::jlong, jni::jlong, jni::jlong, jni::jlong>,
"initialize",
"finalize",
METHOD(&CustomLayer::update, "nativeUpdate"));
}
} // namespace android
} // namespace mbgl

View File

@@ -0,0 +1,32 @@
#pragma once
#include "layer.hpp"
#include <mbgl/style/layers/custom_layer.hpp>
#include <jni/jni.hpp>
namespace mbgl {
namespace android {
class CustomLayer : public Layer {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/CustomLayer"; };
static jni::Class<CustomLayer> javaClass;
static void registerNative(jni::JNIEnv&);
CustomLayer(jni::JNIEnv&, jni::String, jni::jlong, jni::jlong, jni::jlong, jni::jlong);
CustomLayer(mbgl::Map&, mbgl::style::CustomLayer&);
~CustomLayer();
void update(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
}; // class CustomLayer
} // namespace android
} // namespace mbgl

View File

@@ -4,25 +4,65 @@
#include <string>
//XXX
#include <mbgl/platform/log.hpp>
#include "../conversion/property_value.hpp"
namespace mbgl {
namespace android {
FillLayer::FillLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
: Layer(env, std::make_unique<mbgl::style::FillLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
mbgl::Log::Debug(mbgl::Event::JNI, "FillLayer constructed, owning reference");
}
FillLayer::FillLayer(mbgl::Map& map, mbgl::style::FillLayer& coreLayer)
: Layer(map, coreLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "FillLayer Non-owning reference constructor");
}
FillLayer::~FillLayer() = default;
// Property getters
jni::Object<jni::ObjectTag> FillLayer::getFillAntialias(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillAntialias());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> FillLayer::getFillOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillOpacity());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> FillLayer::getFillColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> FillLayer::getFillOutlineColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillOutlineColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> FillLayer::getFillTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillTranslate());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> FillLayer::getFillTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillTranslateAnchor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> FillLayer::getFillPattern(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::FillLayer>()->FillLayer::getFillPattern());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Class<FillLayer> FillLayer::javaClass;
jni::jobject* FillLayer::createJavaPeer(jni::JNIEnv& env) {
@@ -31,8 +71,6 @@ namespace android {
}
void FillLayer::registerNative(jni::JNIEnv& env) {
mbgl::Log::Debug(mbgl::Event::JNI, "Registering native background layer");
//Lookup the class
FillLayer::javaClass = *jni::Class<FillLayer>::Find(env).NewGlobalRef(env).release();
@@ -43,9 +81,14 @@ namespace android {
env, FillLayer::javaClass, "nativePtr",
std::make_unique<FillLayer, JNIEnv&, jni::String, jni::String>,
"initialize",
"finalize"
);
"finalize",
METHOD(&FillLayer::getFillAntialias, "nativeGetFillAntialias"),
METHOD(&FillLayer::getFillOpacity, "nativeGetFillOpacity"),
METHOD(&FillLayer::getFillColor, "nativeGetFillColor"),
METHOD(&FillLayer::getFillOutlineColor, "nativeGetFillOutlineColor"),
METHOD(&FillLayer::getFillTranslate, "nativeGetFillTranslate"),
METHOD(&FillLayer::getFillTranslateAnchor, "nativeGetFillTranslateAnchor"),
METHOD(&FillLayer::getFillPattern, "nativeGetFillPattern"));
}
} // namespace android

View File

@@ -24,8 +24,24 @@ public:
~FillLayer();
// Property getters
jni::Object<jni::ObjectTag> getFillAntialias(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getFillOpacity(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getFillColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getFillOutlineColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getFillTranslate(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getFillTranslateAnchor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getFillPattern(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
};
}; // class FillLayer
} // namespace android
} // namespace mbgl

View File

@@ -4,10 +4,15 @@
#include <jni/jni.hpp>
#include <mbgl/platform/log.hpp>
//Java -> C++ conversion
#include <mbgl/style/conversion.hpp>
#include <mbgl/style/conversion/layer.hpp>
#include <mbgl/style/conversion/source.hpp>
//C++ -> Java conversion
#include "../conversion/property_value.hpp"
#include <string>
namespace mbgl {
@@ -16,19 +21,15 @@ namespace android {
/**
* Invoked when the construction is initiated from the jvm through a subclass
*/
Layer::Layer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> coreLayer)
Layer::Layer(jni::JNIEnv&, std::unique_ptr<mbgl::style::Layer> coreLayer)
: ownedLayer(std::move(coreLayer))
, layer(*ownedLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "Layer constructed, owning reference");
}
Layer::Layer(mbgl::Map& coreMap, mbgl::style::Layer& coreLayer) : layer(coreLayer) , map(&coreMap) {
mbgl::Log::Debug(mbgl::Event::JNI, "Non-owning reference constructor");
}
Layer::~Layer() {
mbgl::Log::Debug(mbgl::Event::JNI, "Layer destroyed");
}
jni::String Layer::getId(jni::JNIEnv& env) {
@@ -41,8 +42,6 @@ namespace android {
}
void Layer::setLayoutProperty(jni::JNIEnv& env, jni::String jname, jni::Object<> jvalue) {
mbgl::Log::Debug(mbgl::Event::JNI, "Set layout property");
Value value(env, jvalue);
//Convert and set property
@@ -51,16 +50,9 @@ namespace android {
mbgl::Log::Error(mbgl::Event::JNI, "Error setting property: " + jni::Make<std::string>(env, jname) + " " + error->message);
return;
}
//Update the style if attached
if (ownedLayer == nullptr) {
map->update(mbgl::Update::RecalculateStyle);
}
}
void Layer::setPaintProperty(jni::JNIEnv& env, jni::String jname, jni::Object<> jvalue) {
mbgl::Log::Debug(mbgl::Event::JNI, "Set paint property");
Value value(env, jvalue);
//Convert and set property
@@ -72,8 +64,6 @@ namespace android {
}
void Layer::updateStyle(jni::JNIEnv&, jni::jboolean updateClasses) {
mbgl::Log::Debug(mbgl::Event::JNI, "Update style property. Update classes: " + std::to_string(updateClasses));
//Update the style only if attached
if (ownedLayer == nullptr) {
Update flags = mbgl::Update::RecalculateStyle;
@@ -89,7 +79,6 @@ namespace android {
void Layer::setFilter(jni::JNIEnv& env, jni::Array<jni::Object<>> jfilter) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
mbgl::Log::Debug(mbgl::Event::JNI, "Set filter");
Value wrapped(env, jfilter);
Filter filter;
@@ -118,7 +107,6 @@ namespace android {
using namespace mbgl::style;
std::string layerId = jni::Make<std::string>(env, sourceLayer);
mbgl::Log::Debug(mbgl::Event::JNI, "Set source layer: " + layerId);
if (layer.is<FillLayer>()) {
layer.as<FillLayer>()->setSourceLayer(layerId);
@@ -133,11 +121,30 @@ namespace android {
}
}
jni::jfloat Layer::getMinZoom(jni::JNIEnv&){
return layer.getMinZoom();
}
jni::jfloat Layer::getMaxZoom(jni::JNIEnv&) {
return layer.getMaxZoom();
}
void Layer::setMinZoom(jni::JNIEnv&, jni::jfloat zoom) {
layer.setMinZoom(zoom);
}
void Layer::setMaxZoom(jni::JNIEnv&, jni::jfloat zoom) {
layer.setMaxZoom(zoom);
}
jni::Object<jni::ObjectTag> Layer::getVisibility(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return jni::Object<jni::ObjectTag>(*convert<jni::jobject*>(env, layer.getVisibility()));
}
jni::Class<Layer> Layer::javaClass;
void Layer::registerNative(jni::JNIEnv& env) {
mbgl::Log::Debug(mbgl::Event::JNI, "Registering native base layer");
//Lookup the class
Layer::javaClass = *jni::Class<Layer>::Find(env).NewGlobalRef(env).release();
@@ -150,9 +157,15 @@ namespace android {
METHOD(&Layer::setPaintProperty, "nativeSetPaintProperty"),
METHOD(&Layer::updateStyle, "nativeUpdateStyle"),
METHOD(&Layer::setFilter, "nativeSetFilter"),
METHOD(&Layer::setSourceLayer, "nativeSetSourceLayer")
METHOD(&Layer::setSourceLayer, "nativeSetSourceLayer"),
METHOD(&Layer::getMinZoom, "nativeGetMinZoom"),
METHOD(&Layer::getMaxZoom, "nativeGetMaxZoom"),
METHOD(&Layer::setMinZoom, "nativeSetMinZoom"),
METHOD(&Layer::setMaxZoom, "nativeSetMaxZoom"),
METHOD(&Layer::getVisibility, "nativeGetVisibility")
);
}
}
}
} //android
} //mbgl

View File

@@ -1,5 +1,6 @@
<%
const type = locals.type;
const properties = locals.properties;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
@@ -7,8 +8,7 @@
#include <string>
//XXX
#include <mbgl/platform/log.hpp>
#include "../conversion/property_value.hpp"
namespace mbgl {
namespace android {
@@ -20,17 +20,24 @@ namespace android {
<%- camelize(type) %>Layer::<%- camelize(type) %>Layer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
: Layer(env, std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
<% } -%>
mbgl::Log::Debug(mbgl::Event::JNI, "<%- camelize(type) %>Layer constructed, owning reference");
}
<%- camelize(type) %>Layer::<%- camelize(type) %>Layer(mbgl::Map& map, mbgl::style::<%- camelize(type) %>Layer& coreLayer)
: Layer(map, coreLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "<%- camelize(type) %>Layer Non-owning reference constructor");
}
<%- camelize(type) %>Layer::~<%- camelize(type) %>Layer() = default;
// Property getters
<% for (const property of properties) { -%>
jni::Object<jni::ObjectTag> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::<%- camelize(type) %>Layer>()-><%- camelize(type) %>Layer::get<%- camelize(property.name) %>());
return jni::Object<jni::ObjectTag>(*converted);
}
<% } -%>
jni::Class<<%- camelize(type) %>Layer> <%- camelize(type) %>Layer::javaClass;
jni::jobject* <%- camelize(type) %>Layer::createJavaPeer(jni::JNIEnv& env) {
@@ -39,8 +46,6 @@ namespace android {
}
void <%- camelize(type) %>Layer::registerNative(jni::JNIEnv& env) {
mbgl::Log::Debug(mbgl::Event::JNI, "Registering native background layer");
//Lookup the class
<%- camelize(type) %>Layer::javaClass = *jni::Class<<%- camelize(type) %>Layer>::Find(env).NewGlobalRef(env).release();
@@ -55,9 +60,9 @@ namespace android {
std::make_unique<<%- camelize(type) %>Layer, JNIEnv&, jni::String, jni::String>,
<% } -%>
"initialize",
"finalize"
);
"finalize",<% for(var i = 0; i < properties.length; i++) {%>
METHOD(&<%- camelize(type) %>Layer::get<%- camelize(properties[i].name) %>, "nativeGet<%- camelize(properties[i].name) %>")<% if(i != (properties.length -1)) {-%>,<% } -%>
<% } -%>);
}
} // namespace android

View File

@@ -45,12 +45,26 @@ public:
void updateStyle(jni::JNIEnv&, jni::jboolean updateClasses);
//Zoom
jni::jfloat getMinZoom(jni::JNIEnv&);
jni::jfloat getMaxZoom(jni::JNIEnv&);
void setMinZoom(jni::JNIEnv&, jni::jfloat zoom);
void setMaxZoom(jni::JNIEnv&, jni::jfloat zoom);
/* common properties, but not shared by all */
void setFilter(jni::JNIEnv& env, jni::Array<jni::Object<>> jfilter);
void setSourceLayer(jni::JNIEnv& env, jni::String sourceLayer);
//Property getters
jni::Object<jni::ObjectTag> getVisibility(jni::JNIEnv&);
protected:
std::unique_ptr<mbgl::style::Layer> ownedLayer;
mbgl::style::Layer& layer;

View File

@@ -1,5 +1,6 @@
<%
const type = locals.type;
const properties = locals.properties;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
@@ -31,8 +32,14 @@ public:
~<%- camelize(type) %>Layer();
// Property getters
<% for (const property of properties) { -%>
jni::Object<jni::ObjectTag> get<%- camelize(property.name) %>(jni::JNIEnv&);
<% } -%>
jni::jobject* createJavaPeer(jni::JNIEnv&);
};
}; // class <%- camelize(type) %>Layer
} // namespace android
} // namespace mbgl

View File

@@ -6,6 +6,7 @@
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/style/layers/custom_layer.hpp>
#include "background_layer.hpp"
#include "circle_layer.hpp"
@@ -13,6 +14,7 @@
#include "line_layer.hpp"
#include "raster_layer.hpp"
#include "symbol_layer.hpp"
#include "custom_layer.hpp"
namespace mbgl {
namespace android {
@@ -31,6 +33,8 @@ Layer* initializeLayerPeer(mbgl::Map& map, mbgl::style::Layer& coreLayer) {
layer = new RasterLayer(map, *coreLayer.as<mbgl::style::RasterLayer>());
} else if (coreLayer.is<mbgl::style::SymbolLayer>()) {
layer = new SymbolLayer(map, *coreLayer.as<mbgl::style::SymbolLayer>());
} else if (coreLayer.is<mbgl::style::CustomLayer>()) {
layer = new CustomLayer(map, *coreLayer.as<mbgl::style::CustomLayer>());
} else {
throw new std::runtime_error("Layer type not implemented");
}
@@ -42,7 +46,6 @@ jni::jobject* createJavaLayerPeer(jni::JNIEnv& env, mbgl::Map& map, mbgl::style:
std::unique_ptr<Layer> peerLayer = std::unique_ptr<Layer>(initializeLayerPeer(map, coreLayer));
jni::jobject* result = peerLayer->createJavaPeer(env);
peerLayer.release();
return result;
}
@@ -54,7 +57,8 @@ void registerNativeLayers(jni::JNIEnv& env) {
LineLayer::registerNative(env);
RasterLayer::registerNative(env);
SymbolLayer::registerNative(env);
CustomLayer::registerNative(env);
}
}
}
} //android
} //mbgl

View File

@@ -4,25 +4,107 @@
#include <string>
//XXX
#include <mbgl/platform/log.hpp>
#include "../conversion/property_value.hpp"
namespace mbgl {
namespace android {
LineLayer::LineLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
: Layer(env, std::make_unique<mbgl::style::LineLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
mbgl::Log::Debug(mbgl::Event::JNI, "LineLayer constructed, owning reference");
}
LineLayer::LineLayer(mbgl::Map& map, mbgl::style::LineLayer& coreLayer)
: Layer(map, coreLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "LineLayer Non-owning reference constructor");
}
LineLayer::~LineLayer() = default;
// Property getters
jni::Object<jni::ObjectTag> LineLayer::getLineCap(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineCap());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineJoin(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineJoin());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineMiterLimit(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineMiterLimit());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineRoundLimit(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineRoundLimit());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineOpacity());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineTranslate());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineTranslateAnchor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineWidth());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineGapWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineGapWidth());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineOffset(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineOffset());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineBlur(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineBlur());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLineDasharray(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineDasharray());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> LineLayer::getLinePattern(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLinePattern());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Class<LineLayer> LineLayer::javaClass;
jni::jobject* LineLayer::createJavaPeer(jni::JNIEnv& env) {
@@ -31,8 +113,6 @@ namespace android {
}
void LineLayer::registerNative(jni::JNIEnv& env) {
mbgl::Log::Debug(mbgl::Event::JNI, "Registering native background layer");
//Lookup the class
LineLayer::javaClass = *jni::Class<LineLayer>::Find(env).NewGlobalRef(env).release();
@@ -43,9 +123,21 @@ namespace android {
env, LineLayer::javaClass, "nativePtr",
std::make_unique<LineLayer, JNIEnv&, jni::String, jni::String>,
"initialize",
"finalize"
);
"finalize",
METHOD(&LineLayer::getLineCap, "nativeGetLineCap"),
METHOD(&LineLayer::getLineJoin, "nativeGetLineJoin"),
METHOD(&LineLayer::getLineMiterLimit, "nativeGetLineMiterLimit"),
METHOD(&LineLayer::getLineRoundLimit, "nativeGetLineRoundLimit"),
METHOD(&LineLayer::getLineOpacity, "nativeGetLineOpacity"),
METHOD(&LineLayer::getLineColor, "nativeGetLineColor"),
METHOD(&LineLayer::getLineTranslate, "nativeGetLineTranslate"),
METHOD(&LineLayer::getLineTranslateAnchor, "nativeGetLineTranslateAnchor"),
METHOD(&LineLayer::getLineWidth, "nativeGetLineWidth"),
METHOD(&LineLayer::getLineGapWidth, "nativeGetLineGapWidth"),
METHOD(&LineLayer::getLineOffset, "nativeGetLineOffset"),
METHOD(&LineLayer::getLineBlur, "nativeGetLineBlur"),
METHOD(&LineLayer::getLineDasharray, "nativeGetLineDasharray"),
METHOD(&LineLayer::getLinePattern, "nativeGetLinePattern"));
}
} // namespace android

View File

@@ -24,8 +24,38 @@ public:
~LineLayer();
// Property getters
jni::Object<jni::ObjectTag> getLineCap(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineJoin(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineMiterLimit(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineRoundLimit(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineOpacity(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineTranslate(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineTranslateAnchor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineWidth(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineGapWidth(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineOffset(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineBlur(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLineDasharray(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getLinePattern(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
};
}; // class LineLayer
} // namespace android
} // namespace mbgl

View File

@@ -4,25 +4,65 @@
#include <string>
//XXX
#include <mbgl/platform/log.hpp>
#include "../conversion/property_value.hpp"
namespace mbgl {
namespace android {
RasterLayer::RasterLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
: Layer(env, std::make_unique<mbgl::style::RasterLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
mbgl::Log::Debug(mbgl::Event::JNI, "RasterLayer constructed, owning reference");
}
RasterLayer::RasterLayer(mbgl::Map& map, mbgl::style::RasterLayer& coreLayer)
: Layer(map, coreLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "RasterLayer Non-owning reference constructor");
}
RasterLayer::~RasterLayer() = default;
// Property getters
jni::Object<jni::ObjectTag> RasterLayer::getRasterOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterOpacity());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> RasterLayer::getRasterHueRotate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterHueRotate());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> RasterLayer::getRasterBrightnessMin(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterBrightnessMin());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> RasterLayer::getRasterBrightnessMax(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterBrightnessMax());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> RasterLayer::getRasterSaturation(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterSaturation());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> RasterLayer::getRasterContrast(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterContrast());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> RasterLayer::getRasterFadeDuration(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::RasterLayer>()->RasterLayer::getRasterFadeDuration());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Class<RasterLayer> RasterLayer::javaClass;
jni::jobject* RasterLayer::createJavaPeer(jni::JNIEnv& env) {
@@ -31,8 +71,6 @@ namespace android {
}
void RasterLayer::registerNative(jni::JNIEnv& env) {
mbgl::Log::Debug(mbgl::Event::JNI, "Registering native background layer");
//Lookup the class
RasterLayer::javaClass = *jni::Class<RasterLayer>::Find(env).NewGlobalRef(env).release();
@@ -43,9 +81,14 @@ namespace android {
env, RasterLayer::javaClass, "nativePtr",
std::make_unique<RasterLayer, JNIEnv&, jni::String, jni::String>,
"initialize",
"finalize"
);
"finalize",
METHOD(&RasterLayer::getRasterOpacity, "nativeGetRasterOpacity"),
METHOD(&RasterLayer::getRasterHueRotate, "nativeGetRasterHueRotate"),
METHOD(&RasterLayer::getRasterBrightnessMin, "nativeGetRasterBrightnessMin"),
METHOD(&RasterLayer::getRasterBrightnessMax, "nativeGetRasterBrightnessMax"),
METHOD(&RasterLayer::getRasterSaturation, "nativeGetRasterSaturation"),
METHOD(&RasterLayer::getRasterContrast, "nativeGetRasterContrast"),
METHOD(&RasterLayer::getRasterFadeDuration, "nativeGetRasterFadeDuration"));
}
} // namespace android

View File

@@ -24,8 +24,24 @@ public:
~RasterLayer();
// Property getters
jni::Object<jni::ObjectTag> getRasterOpacity(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getRasterHueRotate(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getRasterBrightnessMin(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getRasterBrightnessMax(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getRasterSaturation(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getRasterContrast(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getRasterFadeDuration(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
};
}; // class RasterLayer
} // namespace android
} // namespace mbgl

View File

@@ -4,25 +4,311 @@
#include <string>
//XXX
#include <mbgl/platform/log.hpp>
#include "../conversion/property_value.hpp"
namespace mbgl {
namespace android {
SymbolLayer::SymbolLayer(jni::JNIEnv& env, jni::String layerId, jni::String sourceId)
: Layer(env, std::make_unique<mbgl::style::SymbolLayer>(jni::Make<std::string>(env, layerId), jni::Make<std::string>(env, sourceId))) {
mbgl::Log::Debug(mbgl::Event::JNI, "SymbolLayer constructed, owning reference");
}
SymbolLayer::SymbolLayer(mbgl::Map& map, mbgl::style::SymbolLayer& coreLayer)
: Layer(map, coreLayer) {
mbgl::Log::Debug(mbgl::Event::JNI, "SymbolLayer Non-owning reference constructor");
}
SymbolLayer::~SymbolLayer() = default;
// Property getters
jni::Object<jni::ObjectTag> SymbolLayer::getSymbolPlacement(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolPlacement());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getSymbolSpacing(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolSpacing());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getSymbolAvoidEdges(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getSymbolAvoidEdges());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconAllowOverlap(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconAllowOverlap());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconIgnorePlacement(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconIgnorePlacement());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconOptional(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOptional());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconRotationAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconRotationAlignment());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconSize(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconSize());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconTextFit(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTextFit());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconTextFitPadding(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTextFitPadding());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconImage(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconImage());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconRotate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconRotate());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconPadding(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconPadding());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconKeepUpright(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconKeepUpright());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconOffset(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOffset());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextPitchAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextPitchAlignment());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextRotationAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextRotationAlignment());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextField(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextField());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextFont(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextFont());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextSize(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextSize());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextMaxWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextMaxWidth());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextLineHeight(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextLineHeight());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextLetterSpacing(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextLetterSpacing());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextJustify(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextJustify());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextAnchor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextMaxAngle(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextMaxAngle());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextRotate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextRotate());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextPadding(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextPadding());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextKeepUpright(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextKeepUpright());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextTransform(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTransform());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextOffset(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOffset());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextAllowOverlap(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextAllowOverlap());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextIgnorePlacement(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextIgnorePlacement());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextOptional(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOptional());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconOpacity());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconHaloColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconHaloWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloWidth());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconHaloBlur(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconHaloBlur());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTranslate());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconTranslateAnchor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextOpacity(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextOpacity());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextHaloColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloColor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextHaloWidth(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloWidth());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextHaloBlur(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextHaloBlur());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextTranslate(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTranslate());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getTextTranslateAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getTextTranslateAnchor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Class<SymbolLayer> SymbolLayer::javaClass;
jni::jobject* SymbolLayer::createJavaPeer(jni::JNIEnv& env) {
@@ -31,8 +317,6 @@ namespace android {
}
void SymbolLayer::registerNative(jni::JNIEnv& env) {
mbgl::Log::Debug(mbgl::Event::JNI, "Registering native background layer");
//Lookup the class
SymbolLayer::javaClass = *jni::Class<SymbolLayer>::Find(env).NewGlobalRef(env).release();
@@ -43,9 +327,55 @@ namespace android {
env, SymbolLayer::javaClass, "nativePtr",
std::make_unique<SymbolLayer, JNIEnv&, jni::String, jni::String>,
"initialize",
"finalize"
);
"finalize",
METHOD(&SymbolLayer::getSymbolPlacement, "nativeGetSymbolPlacement"),
METHOD(&SymbolLayer::getSymbolSpacing, "nativeGetSymbolSpacing"),
METHOD(&SymbolLayer::getSymbolAvoidEdges, "nativeGetSymbolAvoidEdges"),
METHOD(&SymbolLayer::getIconAllowOverlap, "nativeGetIconAllowOverlap"),
METHOD(&SymbolLayer::getIconIgnorePlacement, "nativeGetIconIgnorePlacement"),
METHOD(&SymbolLayer::getIconOptional, "nativeGetIconOptional"),
METHOD(&SymbolLayer::getIconRotationAlignment, "nativeGetIconRotationAlignment"),
METHOD(&SymbolLayer::getIconSize, "nativeGetIconSize"),
METHOD(&SymbolLayer::getIconTextFit, "nativeGetIconTextFit"),
METHOD(&SymbolLayer::getIconTextFitPadding, "nativeGetIconTextFitPadding"),
METHOD(&SymbolLayer::getIconImage, "nativeGetIconImage"),
METHOD(&SymbolLayer::getIconRotate, "nativeGetIconRotate"),
METHOD(&SymbolLayer::getIconPadding, "nativeGetIconPadding"),
METHOD(&SymbolLayer::getIconKeepUpright, "nativeGetIconKeepUpright"),
METHOD(&SymbolLayer::getIconOffset, "nativeGetIconOffset"),
METHOD(&SymbolLayer::getTextPitchAlignment, "nativeGetTextPitchAlignment"),
METHOD(&SymbolLayer::getTextRotationAlignment, "nativeGetTextRotationAlignment"),
METHOD(&SymbolLayer::getTextField, "nativeGetTextField"),
METHOD(&SymbolLayer::getTextFont, "nativeGetTextFont"),
METHOD(&SymbolLayer::getTextSize, "nativeGetTextSize"),
METHOD(&SymbolLayer::getTextMaxWidth, "nativeGetTextMaxWidth"),
METHOD(&SymbolLayer::getTextLineHeight, "nativeGetTextLineHeight"),
METHOD(&SymbolLayer::getTextLetterSpacing, "nativeGetTextLetterSpacing"),
METHOD(&SymbolLayer::getTextJustify, "nativeGetTextJustify"),
METHOD(&SymbolLayer::getTextAnchor, "nativeGetTextAnchor"),
METHOD(&SymbolLayer::getTextMaxAngle, "nativeGetTextMaxAngle"),
METHOD(&SymbolLayer::getTextRotate, "nativeGetTextRotate"),
METHOD(&SymbolLayer::getTextPadding, "nativeGetTextPadding"),
METHOD(&SymbolLayer::getTextKeepUpright, "nativeGetTextKeepUpright"),
METHOD(&SymbolLayer::getTextTransform, "nativeGetTextTransform"),
METHOD(&SymbolLayer::getTextOffset, "nativeGetTextOffset"),
METHOD(&SymbolLayer::getTextAllowOverlap, "nativeGetTextAllowOverlap"),
METHOD(&SymbolLayer::getTextIgnorePlacement, "nativeGetTextIgnorePlacement"),
METHOD(&SymbolLayer::getTextOptional, "nativeGetTextOptional"),
METHOD(&SymbolLayer::getIconOpacity, "nativeGetIconOpacity"),
METHOD(&SymbolLayer::getIconColor, "nativeGetIconColor"),
METHOD(&SymbolLayer::getIconHaloColor, "nativeGetIconHaloColor"),
METHOD(&SymbolLayer::getIconHaloWidth, "nativeGetIconHaloWidth"),
METHOD(&SymbolLayer::getIconHaloBlur, "nativeGetIconHaloBlur"),
METHOD(&SymbolLayer::getIconTranslate, "nativeGetIconTranslate"),
METHOD(&SymbolLayer::getIconTranslateAnchor, "nativeGetIconTranslateAnchor"),
METHOD(&SymbolLayer::getTextOpacity, "nativeGetTextOpacity"),
METHOD(&SymbolLayer::getTextColor, "nativeGetTextColor"),
METHOD(&SymbolLayer::getTextHaloColor, "nativeGetTextHaloColor"),
METHOD(&SymbolLayer::getTextHaloWidth, "nativeGetTextHaloWidth"),
METHOD(&SymbolLayer::getTextHaloBlur, "nativeGetTextHaloBlur"),
METHOD(&SymbolLayer::getTextTranslate, "nativeGetTextTranslate"),
METHOD(&SymbolLayer::getTextTranslateAnchor, "nativeGetTextTranslateAnchor"));
}
} // namespace android

View File

@@ -24,8 +24,106 @@ public:
~SymbolLayer();
// Property getters
jni::Object<jni::ObjectTag> getSymbolPlacement(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getSymbolSpacing(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getSymbolAvoidEdges(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconAllowOverlap(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconIgnorePlacement(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconOptional(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconRotationAlignment(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconSize(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconTextFit(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconTextFitPadding(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconImage(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconRotate(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconPadding(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconKeepUpright(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconOffset(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextPitchAlignment(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextRotationAlignment(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextField(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextFont(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextSize(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextMaxWidth(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextLineHeight(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextLetterSpacing(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextJustify(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextAnchor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextMaxAngle(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextRotate(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextPadding(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextKeepUpright(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextTransform(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextOffset(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextAllowOverlap(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextIgnorePlacement(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextOptional(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconOpacity(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconHaloColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconHaloWidth(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconHaloBlur(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconTranslate(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconTranslateAnchor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextOpacity(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextHaloColor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextHaloWidth(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextHaloBlur(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextTranslate(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextTranslateAnchor(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);
};
}; // class SymbolLayer
} // namespace android
} // namespace mbgl