[android] #5610 - Runtime style api - part 2
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Do not use this package. Experimental feature.
|
||||
*/
|
||||
package com.mapbox.mapboxsdk.layers;
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<%
|
||||
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;
|
||||
|
||||
/**
|
||||
* <%- camelize(type) %> Layer
|
||||
*/
|
||||
public class <%- camelize(type) %>Layer extends Layer {
|
||||
|
||||
public <%- camelize(type) %>Layer(long nativePtr) {
|
||||
super(nativePtr);
|
||||
}
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
public <%- camelize(type) %>Layer(String layerId) {
|
||||
initialize(layerId);
|
||||
}
|
||||
|
||||
protected native void initialize(String layerId);
|
||||
<% } else { -%>
|
||||
public <%- camelize(type) %>Layer(String layerId, String sourceId) {
|
||||
initialize(layerId, sourceId);
|
||||
}
|
||||
|
||||
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) %>();
|
||||
|
||||
<% } -%>
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<%
|
||||
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;
|
||||
|
||||
import android.support.annotation.StringDef;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Paint/Layout properties for Layer
|
||||
*/
|
||||
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) { -%>
|
||||
public static final String <%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %> = "<%- value %>";
|
||||
<% } -%>
|
||||
|
||||
@StringDef({
|
||||
<% for (const value of property.values) { -%>
|
||||
<%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %>,
|
||||
<% } -%>
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface <%- snakeCaseUpper(property.name) %> {}
|
||||
|
||||
<% } -%>
|
||||
|
||||
//Class definition
|
||||
public final String name;
|
||||
public final T value;
|
||||
|
||||
/* package */ Property(String name, T value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<%
|
||||
const paintProperties = locals.paintProperties;
|
||||
const layoutProperties = locals.layoutProperties;
|
||||
-%>
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
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>
|
||||
*/
|
||||
public class PropertyFactory {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
return String.format("rgba(%d, %d, %d, %d)", (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user