[core] Add line-gradient property
Porting of https://github.com/mapbox/mapbox-gl-js/pull/6303 See the link above for the description of the feature and its limitations). Based on patch from @lbud (Lauren Budorick).
This commit is contained in:
@@ -478,6 +478,34 @@ public class LineLayer extends Layer {
|
||||
nativeSetLinePatternTransition(options.getDuration(), options.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the LineGradient property
|
||||
*
|
||||
* @return property wrapper value around String
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getLineGradient() {
|
||||
checkThread();
|
||||
return (PropertyValue<String>) new PropertyValue("line-gradient", nativeGetLineGradient());
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
|
||||
*
|
||||
* @return int representation of a rgba string color
|
||||
* @throws RuntimeException thrown if property isn't a value
|
||||
*/
|
||||
@ColorInt
|
||||
public int getLineGradientAsInt() {
|
||||
checkThread();
|
||||
PropertyValue<String> value = getLineGradient();
|
||||
if (value.isValue()) {
|
||||
return rgbaToColor(value.getValue());
|
||||
} else {
|
||||
throw new RuntimeException("line-gradient was set as a Function");
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private native Object nativeGetLineCap();
|
||||
|
||||
@@ -574,6 +602,9 @@ public class LineLayer extends Layer {
|
||||
@Keep
|
||||
private native void nativeSetLinePatternTransition(long duration, long delay);
|
||||
|
||||
@Keep
|
||||
private native Object nativeGetLineGradient();
|
||||
|
||||
@Override
|
||||
@Keep
|
||||
protected native void finalize() throws Throwable;
|
||||
|
||||
@@ -394,6 +394,36 @@ public class PropertyFactory {
|
||||
return new PaintPropertyValue<>("line-pattern", expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
|
||||
*
|
||||
* @param value a int color value
|
||||
* @return property wrapper around String color
|
||||
*/
|
||||
public static PropertyValue<String> lineGradient(@ColorInt int value) {
|
||||
return new PaintPropertyValue<>("line-gradient", colorToRgbaString(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
|
||||
*
|
||||
* @param value a String value
|
||||
* @return property wrapper around String
|
||||
*/
|
||||
public static PropertyValue<String> lineGradient(String value) {
|
||||
return new PaintPropertyValue<>("line-gradient", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
*/
|
||||
public static PropertyValue<Expression> lineGradient(Expression expression) {
|
||||
return new PaintPropertyValue<>("line-gradient", expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* The opacity at which the icon will be drawn.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user