com.dynamicpdf.api.Grayscale Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dynamicpdf-api Show documentation
Show all versions of dynamicpdf-api Show documentation
A Java Client API that uses the DynamicPDF API to create, merge, split, form fill, stamp, secure/encrypt PDF documents.
package com.dynamicpdf.api;
/**
* Represents a grayscale color.
*/
public class Grayscale extends Color {
private String colorString;
private float grayLevel;
Grayscale(String colorString) {
setColorString(colorString);
}
/**
* Initializes a new instance of the Grayscale
class.
* @param grayLevel The gray level for the color.
*/
public Grayscale(float grayLevel) {
this.grayLevel = grayLevel;
}
/**
* Gets the color black.
* @return The color black.
*/
public static Grayscale getBlack() {
return new Grayscale(0);
}
/**
* Gets the color white.
* @return The color white.
*/
public static Grayscale getWhite() {
return new Grayscale(1);
}
/**
* Gets the color string.
* @return The color string.
*/
public String getColorString() {
if (colorString != null) {
return colorString;
} else {
return "gray(" + Float.toString(grayLevel).replaceAll("\\.?0*$", "") + ")";
}
}
void setColorString(String value) {
colorString = value;
}
}