use of org.apache.poi.hssf.record.common.ExtendedColor in project poi by apache.
the class CFRule12Record method createColorScale.
/**
* Creates a new Color Scale / Color Gradient formatting
*
* @param sheet the sheet
*
* @return a new Color Scale / Color Gradient formatting
*/
public static CFRule12Record createColorScale(HSSFSheet sheet) {
int numPoints = 3;
ExtendedColor[] colors = new ExtendedColor[numPoints];
ColorGradientThreshold[] ts = new ColorGradientThreshold[numPoints];
for (int i = 0; i < ts.length; i++) {
ts[i] = new ColorGradientThreshold();
colors[i] = new ExtendedColor();
}
CFRule12Record r = new CFRule12Record(CONDITION_TYPE_COLOR_SCALE, ComparisonOperator.NO_COMPARISON);
ColorGradientFormatting cgf = r.createColorGradientFormatting();
cgf.setNumControlPoints(numPoints);
cgf.setThresholds(ts);
cgf.setColors(colors);
return r;
}
use of org.apache.poi.hssf.record.common.ExtendedColor in project poi by apache.
the class ColorGradientFormatting method toString.
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(" [Color Gradient Formatting]\n");
buffer.append(" .clamp = ").append(isClampToCurve()).append("\n");
buffer.append(" .background= ").append(isAppliesToBackground()).append("\n");
for (Threshold t : thresholds) {
buffer.append(t);
}
for (ExtendedColor c : colors) {
buffer.append(c);
}
buffer.append(" [/Color Gradient Formatting]\n");
return buffer.toString();
}
use of org.apache.poi.hssf.record.common.ExtendedColor in project poi by apache.
the class ColorGradientFormatting method getDataLength.
public int getDataLength() {
int len = 6;
for (Threshold t : thresholds) {
len += t.getDataLength();
}
for (ExtendedColor c : colors) {
len += c.getDataLength();
len += 8;
}
return len;
}
use of org.apache.poi.hssf.record.common.ExtendedColor in project poi by apache.
the class ColorGradientFormatting method serialize.
public void serialize(LittleEndianOutput out) {
out.writeShort(0);
out.writeByte(0);
out.writeByte(thresholds.length);
out.writeByte(thresholds.length);
out.writeByte(options);
for (ColorGradientThreshold t : thresholds) {
t.serialize(out);
}
double step = 1d / (colors.length - 1);
for (int i = 0; i < colors.length; i++) {
out.writeDouble(i * step);
ExtendedColor c = colors[i];
c.serialize(out);
}
}
Aggregations