outputEncode(out);
out.append("/Bounds ");
if (bounds != null) {
- outputDoubles(out, bounds);
+ GradientMaker.outputDoubles(out, bounds);
} else if (!functions.isEmpty()) {
// if there are n functions,
// there must be n-1 bounds.
// so let each function handle an equal portion
// of the whole. e.g. if there are 4, then [ 0.25 0.25 0.25 ]
int numberOfFunctions = functions.size();
- String functionsFraction = PDFNumber.doubleOut(Double.valueOf(1.0 / (numberOfFunctions)));
+ String functionsFraction = PDFNumber.doubleOut(1.0 / numberOfFunctions);
out.append("[ ");
for (int i = 0; i + 1 < numberOfFunctions; i++) {
out.append(functionsFraction);
private void outputDomain(StringBuilder p) {
if (domain != null) {
p.append("/Domain ");
- outputDoubles(p, domain);
+ GradientMaker.outputDoubles(p, domain);
p.append("\n");
} else {
p.append("/Domain [ 0 1 ]\n");
private void outputSize(StringBuilder out) {
if (size != null) {
out.append("/Size ");
- outputDoubles(out, size);
+ GradientMaker.outputDoubles(out, size);
out.append("\n");
}
}
private void outputRange(StringBuilder out) {
if (range != null) {
out.append("/Range ");
- outputDoubles(out, range);
+ GradientMaker.outputDoubles(out, range);
out.append("\n");
}
}
private void outputEncode(StringBuilder out) {
if (encode != null) {
out.append("/Encode ");
- outputDoubles(out, encode);
+ GradientMaker.outputDoubles(out, encode);
out.append("\n");
} else {
out.append("/Encode [ ");
private void outputDecode(StringBuilder out) {
if (decode != null) {
out.append("/Decode ");
- outputDoubles(out, decode);
+ GradientMaker.outputDoubles(out, decode);
out.append("\n");
}
}
private void outputInterpolationExponentN(StringBuilder out) {
out.append("/N ");
- out.append(PDFNumber.doubleOut(Double.valueOf(interpolationExponentN)));
+ out.append(PDFNumber.doubleOut(interpolationExponentN));
out.append("\n");
}
- private void outputDoubles(StringBuilder out, List<Double> doubles) {
- out.append("[ ");
- for (Double d : doubles) {
- out.append(PDFNumber.doubleOut(d));
- out.append(" ");
- }
- out.append("]");
- }
-
}
import org.apache.xmlgraphics.java2d.color.ColorUtil;
import org.apache.fop.pdf.PDFDeviceColorSpace;
+import org.apache.fop.pdf.PDFNumber;
public final class GradientMaker {
return gradientColors;
}
+ static void outputDoubles(StringBuilder out, List<Double> doubles) {
+ out.append("[ ");
+ for (Double d : doubles) {
+ out.append(PDFNumber.doubleOut(d));
+ out.append(" ");
+ }
+ out.append("]");
+ }
+
}
import java.util.List;
import org.apache.fop.pdf.PDFDeviceColorSpace;
-import org.apache.fop.pdf.PDFNumber;
public class Shading {
if (background != null) {
out.append("/Background ");
- outputDoubles(out, background);
+ GradientMaker.outputDoubles(out, background);
out.append("\n");
}
if (bbox != null) {
out.append("/BBox");
- outputDoubles(out, bbox);
+ GradientMaker.outputDoubles(out, bbox);
out.append("\n");
}
out.append(">>");
}
- private void outputDoubles(StringBuilder out, List<Double> doubles) {
- out.append("[ ");
- for (Double d : doubles) {
- out.append(PDFNumber.doubleOut(d));
- out.append(" ");
- }
- out.append("]");
- }
-
private void outputShadingType1(StringBuilder out, Shading.FunctionRenderer functionRenderer) {
if (domain != null) {
out.append("/Domain ");
- outputDoubles(out, domain);
+ GradientMaker.outputDoubles(out, domain);
out.append("\n");
} else {
out.append("/Domain [ 0 1 ] \n");
if (matrix != null) {
out.append("/Matrix ");
- outputDoubles(out, matrix);
+ GradientMaker.outputDoubles(out, matrix);
out.append("\n");
}
outputFunction(out, functionRenderer);
private void outputShadingType2or3(StringBuilder out, Shading.FunctionRenderer functionRenderer) {
if (coords != null) {
out.append("/Coords ");
- outputDoubles(out, coords);
+ GradientMaker.outputDoubles(out, coords);
out.append("\n");
}
if (domain != null) {
out.append("/Domain ");
- outputDoubles(out, domain);
+ GradientMaker.outputDoubles(out, domain);
out.append("\n");
} else {
out.append("/Domain [ 0 1 ] \n");
if (decode != null) {
out.append("/Decode ");
- outputDoubles(out, decode);
+ GradientMaker.outputDoubles(out, decode);
out.append("\n");
}
if (decode != null) {
out.append("/Decode ");
- outputDoubles(out, decode);
+ GradientMaker.outputDoubles(out, decode);
out.append("\n");
}