public static final class RasterStyle.Builder extends Object implements AutoCloseable
The default raster style has a white modulation color, with brightness, contrast and transparency values all equal to 1.
Example usage:
var rasterStyle = RasterStyle.newBuilder().opacity(0.5).contrast(0.7).build();
Constructor and Description |
---|
Builder(RasterStyle.Builder other) |
Modifier and Type | Method and Description |
---|---|
RasterStyle.Builder |
brightness(double brightness)
Sets the brightness.
|
RasterStyle |
build()
Returns a newly created raster style, based on the properties set on this builder.
|
void |
close() |
RasterStyle.Builder |
contrast(double contrast)
Sets the contrast.
|
protected void |
finalize() |
RasterStyle.Builder |
modulationColor(android.graphics.Color color)
Sets the color that is modulated with the raster.
|
RasterStyle.Builder |
opacity(double opacity)
Sets the opacity of the raster.
|
public Builder(@NotNull RasterStyle.Builder other)
public void close()
close
in interface AutoCloseable
@NotNull public RasterStyle build()
@NotNull public RasterStyle.Builder opacity(double opacity) throws IllegalArgumentException
This can also be achieved by setting a modulation color with opacity directly. When both opacity and a modulation color are set, the opacity set using this method takes precedence over that of the modulation color.
This parameter is optional. If not set, default is 1.
opacity
- the alpha value. Must be contained in the [0, 1]
interval (0 is fully transparent, 1 is fully opaque).IllegalArgumentException
- when opacity < 0 or opacity > 1.@NotNull public RasterStyle.Builder brightness(double brightness) throws IllegalArgumentException
The brightness is a value in [0, 2]
. A value of 1 (the default) leaves the brightness unchanged. Values larger than 1 makes the colors brighter, while a value smaller than 1 makes the colors less bright.
This parameter is optional. If not set, default is 1.
brightness
- the brightnessIllegalArgumentException
- when brightness < 0 or brightness > 2.@NotNull public RasterStyle.Builder contrast(double contrast) throws IllegalArgumentException
The contrast is a value in [0, 2]
. A value of 1 (the default) leaves the contrast unchanged. A value larger than 1 enhances the contrast of dark colors by making them brighter, while a value smaller than 1 enhances the contrast of bright colors by making them darker.
This parameter is optional. If not set, default is 1.
contrast
- the contrastIllegalArgumentException
- when contrast < 0 or contrast > 2.@NotNull public RasterStyle.Builder modulationColor(@NotNull android.graphics.Color color)
For example using a raster with gray-scale colors and a red modulation color will result in a resulting painted raster with red hues.
Using a white color has no effect.
This parameter is optional. If not set, default is white.
color
- the modulation color