import java.util.List;
import org.apache.fop.render.gradient.Function;
+import org.apache.fop.render.gradient.Function.SubFunctionRenderer;
/**
* class representing a PDF Function.
for (PDFFunction f : pdfFunctions) {
functionsStrings.add(f.referencePDF());
}
- return encode(function.toWriteableString(functionsStrings));
+ SubFunctionRenderer subFunctionRenderer = new SubFunctionRenderer() {
+
+ public void outputFunction(StringBuilder out, int functionIndex) {
+ out.append(pdfFunctions.get(functionIndex).referencePDF());
+ }
+ };
+ return encode(function.toWriteableString(subFunctionRenderer));
}
/** {@inheritDoc} */
public class Function {
+ public interface SubFunctionRenderer {
+
+ void outputFunction(StringBuilder out, int functionIndex);
+ }
+
/**
* Required: The Type of function (0,2,3,4) default is 0.
*/
return cOne;
}
- public String toWriteableString(List<String> functionsStrings) {
+ public String toWriteableString(SubFunctionRenderer subFunctionRenderer) {
StringBuilder out = new StringBuilder(256);
out.append("<<\n/FunctionType " + functionType + "\n");
outputDomain(out);
outputRange(out);
if (!functions.isEmpty()) {
out.append("/Functions [ ");
- for (String f : functionsStrings) {
- out.append(f);
+ for (int i = 0; i < functions.size(); i++) {
+ subFunctionRenderer.outputFunction(out, i);
out.append(' ');
}
out.append("]\n");
import java.awt.Paint;
import java.awt.geom.AffineTransform;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.fop.render.gradient.Function;
+import org.apache.fop.render.gradient.Function.SubFunctionRenderer;
import org.apache.fop.render.gradient.GradientMaker;
import org.apache.fop.render.gradient.Pattern;
import org.apache.fop.render.gradient.Shading;
Shading.FunctionRenderer functionRenderer = new Shading.FunctionRenderer() {
public void outputFunction(StringBuilder out) {
- List<String> functionsStrings = new ArrayList<String>(function.getFunctions().size());
- for (Function f : function.getFunctions()) {
- functionsStrings.add(functionToString(f));
- }
- out.append(function.toWriteableString(functionsStrings));
+ SubFunctionRenderer subFunctionRenderer = new Function.SubFunctionRenderer() {
+
+ public void outputFunction(StringBuilder out, int functionIndex) {
+ Function subFunction = function.getFunctions().get(functionIndex);
+ assert subFunction.getFunctions().isEmpty();
+ out.append(subFunction.toWriteableString(null));
+ }
+ };
+ out.append(function.toWriteableString(subFunctionRenderer));
}
};
shading.output(p, functionRenderer);
}
- private String functionToString(Function function) {
- List<String> functionsStrings = new ArrayList<String>(function.getFunctions().size());
- for (Function f : function.getFunctions()) {
- functionsStrings.add(functionToString(f));
- }
- return function.toWriteableString(functionsStrings);
- }
-
protected AffineTransform getBaseTransform() {
AffineTransform at = new AffineTransform(this.getTransform());
return at;