You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2014/07/18 21:48:02 UTC
svn commit: r1611783 [1/2] - in /xmlgraphics/fop/trunk: ./
src/java/org/apache/fop/pdf/ src/java/org/apache/fop/render/gradient/
src/java/org/apache/fop/render/ps/ src/java/org/apache/fop/render/ps/svg/
src/java/org/apache/fop/render/shading/ src/java/...
Author: vhennebert
Date: Fri Jul 18 19:48:02 2014
New Revision: 1611783
URL: http://svn.apache.org/r1611783
Log:
Merged branch FOP-2393_gradient-rendering back into trunk
Added:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/gradient/
- copied from r1611778, xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/gradient/
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/gradient/
- copied from r1611778, xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/gradient/
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java
- copied unchanged from r1611778, xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/expected-linear-gradient.ps
- copied unchanged from r1611778, xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/ps/svg/expected-linear-gradient.ps
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/expected-radial-gradient.ps
- copied unchanged from r1611778, xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/ps/svg/expected-radial-gradient.ps
Removed:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/svg/PSFunction.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/svg/PSPattern.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/svg/PSShading.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/shading/
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/PSSVGGraphics2DTestCase.java
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/axial-shading-expected.dat
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/expected.ps
Modified:
xmlgraphics/fop/trunk/ (props changed)
xmlgraphics/fop/trunk/build.xml
xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFactory.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFunction.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFPattern.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFShading.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/gradient/GradientMaker.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java
Propchange: xmlgraphics/fop/trunk/
------------------------------------------------------------------------------
Merged /xmlgraphics/fop/branches/FOP-2393_gradient-rendering:r1609496-1611778
Modified: xmlgraphics/fop/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/build.xml?rev=1611783&r1=1611782&r2=1611783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/build.xml (original)
+++ xmlgraphics/fop/trunk/build.xml Fri Jul 18 19:48:02 2014
@@ -732,6 +732,7 @@ list of possible build targets.
<include name="**/*.fo"/>
<include name="**/BidiTestData*.ser"/>
<include name="**/*.afp"/>
+ <include name="**/*.ps"/>
<include name="**/*.xsl"/>
</fileset>
<fileset dir="${build.dir}/test-gensrc">
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFactory.java?rev=1611783&r1=1611782&r2=1611783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFactory.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFactory.java Fri Jul 18 19:48:02 2014
@@ -20,14 +20,12 @@
package org.apache.fop.pdf;
// Java
-import java.awt.Color;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Iterator;
@@ -41,7 +39,6 @@ import org.apache.commons.io.output.Byte
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.xmlgraphics.java2d.color.ColorUtil;
import org.apache.xmlgraphics.java2d.color.NamedColorSpace;
import org.apache.xmlgraphics.xmp.Metadata;
@@ -244,188 +241,35 @@ public class PDFFactory {
/* ========================= functions ================================= */
/**
- * Make a Type 0 sampled function
- *
- * @param theDomain List objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange List objects of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theSize A List object of Integer objects.
- * This is the number of samples in each input dimension.
- * I can't imagine there being more or less than two input dimensions,
- * so maybe this should be an array of length 2.
- *
- * See page 265 of the PDF 1.3 Spec.
- * @param theBitsPerSample An int specifying the number of bits user
- * to represent each sample value.
- * Limited to 1,2,4,8,12,16,24 or 32.
- * See page 265 of the 1.3 PDF Spec.
- * @param theOrder The order of interpolation between samples.
- * Default is 1 (one). Limited
- * to 1 (one) or 3, which means linear or cubic-spline interpolation.
- *
- * This attribute is optional.
- *
- * See page 265 in the PDF 1.3 spec.
- * @param theEncode List objects of Double objects.
- * This is the linear mapping of input values intop the domain
- * of the function's sample table. Default is hard to represent in
- * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
- * This attribute is optional.
- *
- * See page 265 in the PDF 1.3 spec.
- * @param theDecode List objects of Double objects.
- * This is a linear mapping of sample values into the range.
- * The default is just the range.
- *
- * This attribute is optional.
- * Read about it on page 265 of the PDF 1.3 spec.
- * @param theFunctionDataStream The sample values that specify
- * the function are provided in a stream.
- *
- * This is optional, but is almost always used.
- *
- * Page 265 of the PDF 1.3 spec has more.
- * @param theFilter This is a vector of String objects which
- * are the various filters that have are to be
- * applied to the stream to make sense of it.
- * Order matters, so watch out.
- *
- * This is not documented in the Function section of the PDF 1.3 spec,
- * it was deduced from samples that this is sometimes used, even if we may never
- * use it in FOP. It is added for completeness sake.
- * @param theFunctionType This is the type of function (0,2,3, or 4).
- * It should be 0 as this is the constructor for sampled functions.
- * @return the PDF function that was created
- */
- public PDFFunction makeFunction(int theFunctionType, List theDomain,
- List theRange, List theSize,
- int theBitsPerSample, int theOrder,
- List theEncode, List theDecode,
- StringBuffer theFunctionDataStream,
- List theFilter) {
- // Type 0 function
- PDFFunction function = new PDFFunction(theFunctionType, theDomain,
- theRange, theSize,
- theBitsPerSample, theOrder,
- theEncode, theDecode,
- theFunctionDataStream,
- theFilter);
-
- function = registerFunction(function);
- return (function);
- }
-
- /**
* make a type Exponential interpolation function
* (for shading usually)
- *
- * @param theDomain List objects of Double objects.
+ * @param domain List objects of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange List of Doubles that is the Range of the function.
+ * @param range List of Doubles that is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theCZero This is a vector of Double objects which defines the function result
+ * @param cZero This is a vector of Double objects which defines the function result
* when x=0.
*
* This attribute is optional.
* It's described on page 268 of the PDF 1.3 spec.
- * @param theCOne This is a vector of Double objects which defines the function result
+ * @param cOne This is a vector of Double objects which defines the function result
* when x=1.
*
* This attribute is optional.
* It's described on page 268 of the PDF 1.3 spec.
- * @param theInterpolationExponentN This is the inerpolation exponent.
+ * @param interpolationExponentN This is the inerpolation exponent.
*
* This attribute is required.
* PDF Spec page 268
- * @param theFunctionType The type of the function, which should be 2.
- * @return the PDF function that was created
- */
- public PDFFunction makeFunction(int theFunctionType, List theDomain,
- List theRange, List theCZero,
- List theCOne,
- double theInterpolationExponentN) { // type 2
- PDFFunction function = new PDFFunction(theFunctionType, theDomain,
- theRange, theCZero, theCOne,
- theInterpolationExponentN);
- function = registerFunction(function);
- return (function);
- }
-
- /**
- * Make a Type 3 Stitching function
- *
- * @param theDomain List objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange List objects of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theFunctions An List of the PDFFunction objects
- * that the stitching function stitches.
*
- * This attributed is required.
- * It is described on page 269 of the PDF spec.
- * @param theBounds This is a vector of Doubles representing
- * the numbers that, in conjunction with Domain
- * define the intervals to which each function from
- * the 'functions' object applies. It must be in
- * order of increasing magnitude, and each must be
- * within Domain.
- *
- * It basically sets how much of the gradient each function handles.
- *
- * This attributed is required.
- * It's described on page 269 of the PDF 1.3 spec.
- * @param theEncode List objects of Double objects.
- * This is the linear mapping of input values intop the domain
- * of the function's sample table. Default is hard to represent in
- * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
- * This attribute is required.
- *
- * See page 270 in the PDF 1.3 spec.
- * @param theFunctionType This is the function type. It should be 3,
- * for a stitching function.
- * @return the PDF function that was created
- */
- public PDFFunction makeFunction(int theFunctionType, List theDomain,
- List theRange, List theFunctions,
- List theBounds,
- List theEncode) {
- // Type 3
-
- PDFFunction function = new PDFFunction(theFunctionType, theDomain,
- theRange, theFunctions,
- theBounds, theEncode);
-
- function = registerFunction(function);
- return (function);
- }
-
- /**
- * make a postscript calculator function
- *
- * @param theNumber the PDF object number
- * @param theFunctionType the type of function to make
- * @param theDomain the domain values
- * @param theRange the range values of the function
- * @param theFunctionDataStream a string containing the pdf drawing
* @return the PDF function that was created
*/
- public PDFFunction makeFunction(int theNumber, int theFunctionType,
- List theDomain, List theRange,
- StringBuffer theFunctionDataStream) {
- // Type 4
- PDFFunction function = new PDFFunction(theFunctionType, theDomain,
- theRange,
- theFunctionDataStream);
-
+ public PDFFunction makeFunction(List domain, List range, float[] cZero, float[] cOne,
+ double interpolationExponentN) {
+ PDFFunction function = new PDFFunction(domain, range, cZero, cOne, interpolationExponentN);
function = registerFunction(function);
- return (function);
-
+ return function;
}
/**
@@ -445,175 +289,6 @@ public class PDFFactory {
/* ========================= shadings ================================== */
/**
- * make a function based shading object
- *
- * @param res the PDF resource context to add the shading, may be null
- * @param theShadingType The type of shading object, which should be 1 for function
- * based shading.
- * @param theColorSpace The colorspace is 'DeviceRGB' or something similar.
- * @param theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox List of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Whether or not to anti-alias.
- * @param theDomain Optional vector of Doubles specifying the domain.
- * @param theMatrix List of Doubles specifying the matrix.
- * If it's a pattern, then the matrix maps it to pattern space.
- * If it's a shading, then it maps it to current user space.
- * It's optional, the default is the identity matrix
- * @param theFunction The PDF Function that maps an (x,y) location to a color
- * @return the PDF shading that was created
- */
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theDomain,
- List theMatrix,
- PDFFunction theFunction) {
- // make Shading of Type 1
- PDFShading shading = new PDFShading(theShadingType,
- theColorSpace, theBackground,
- theBBox, theAntiAlias, theDomain,
- theMatrix, theFunction);
-
- shading = registerShading(res, shading);
- return (shading);
- }
-
- /**
- * Make an axial or radial shading object.
- *
- * @param res the PDF resource context to add the shading, may be null
- * @param theShadingType 2 or 3 for axial or radial shading
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox List of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theCoords List of four (type 2) or 6 (type 3) Double
- * @param theDomain List of Doubles specifying the domain
- * @param theFunction the Stitching (PDFfunction type 3) function,
- * even if it's stitching a single function
- * @param theExtend List of Booleans of whether to extend the
- * start and end colors past the start and end points
- * The default is [false, false]
- * @return the PDF shading that was created
- */
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theCoords,
- List theDomain, PDFFunction theFunction,
- List theExtend) {
- // make Shading of Type 2 or 3
- PDFShading shading = new PDFShading(theShadingType,
- theColorSpace, theBackground,
- theBBox, theAntiAlias, theCoords,
- theDomain, theFunction,
- theExtend);
-
- shading = registerShading(res, shading);
-
- return (shading);
- }
-
- /**
- * Make a free-form gouraud shaded triangle mesh, coons patch mesh, or tensor patch mesh
- * shading object
- *
- * @param res the PDF resource context to add the shading, may be null
- * @param theShadingType 4, 6, or 7 depending on whether it's
- * Free-form gouraud-shaded triangle meshes, coons patch meshes,
- * or tensor product patch meshes, respectively.
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox List of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theBitsPerCoordinate 1,2,4,8,12,16,24 or 32.
- * @param theBitsPerComponent 1,2,4,8,12, and 16
- * @param theBitsPerFlag 2,4,8.
- * @param theDecode List of Doubles see PDF 1.3 spec pages 303 to 312.
- * @param theFunction the PDFFunction
- * @return the PDF shading that was created
- */
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias,
- int theBitsPerCoordinate,
- int theBitsPerComponent,
- int theBitsPerFlag, List theDecode,
- PDFFunction theFunction) {
- // make Shading of type 4,6 or 7
- PDFShading shading = new PDFShading(theShadingType,
- theColorSpace, theBackground,
- theBBox, theAntiAlias,
- theBitsPerCoordinate,
- theBitsPerComponent,
- theBitsPerFlag, theDecode,
- theFunction);
-
- shading = registerShading(res, shading);
-
- return (shading);
- }
-
- /**
- * make a Lattice-Form Gouraud mesh shading object
- *
- * @param res the PDF resource context to add the shading, may be null
- * @param theShadingType 5 for lattice-Form Gouraud shaded-triangle mesh
- * without spaces. "Shading1" or "Sh1" are good examples.
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox List of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theBitsPerCoordinate 1,2,4,8,12,16, 24, or 32
- * @param theBitsPerComponent 1,2,4,8,12,24,32
- * @param theDecode List of Doubles. See page 305 in PDF 1.3 spec.
- * @param theVerticesPerRow number of vertices in each "row" of the lattice.
- * @param theFunction The PDFFunction that's mapped on to this shape
- * @return the PDF shading that was created
- */
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias,
- int theBitsPerCoordinate,
- int theBitsPerComponent, List theDecode,
- int theVerticesPerRow,
- PDFFunction theFunction) {
- // make shading of Type 5
- PDFShading shading = new PDFShading(theShadingType,
- theColorSpace, theBackground,
- theBBox, theAntiAlias,
- theBitsPerCoordinate,
- theBitsPerComponent, theDecode,
- theVerticesPerRow, theFunction);
-
- shading = registerShading(res, shading);
-
- return (shading);
- }
-
- /**
* Registers a shading object against the document
* @param res The PDF resource context
* @param shading The shading object to be registered
@@ -697,148 +372,6 @@ public class PDFFactory {
return pattern;
}
- /**
- * Make a smooth shading pattern
- *
- * @param res the PDF resource context to add the shading, may be null
- * @param thePatternType the type of the pattern, which is 2, smooth shading
- * @param theShading the PDF Shading object that comprises this pattern
- * @param theXUID optional:the extended unique Identifier if used.
- * @param theExtGState optional: the extended graphics state, if used.
- * @param theMatrix Optional:List of Doubles that specify the matrix.
- * @return the PDF pattern that was created
- */
- public PDFPattern makePattern(PDFResourceContext res,
- int thePatternType, PDFShading theShading,
- List theXUID, StringBuffer theExtGState,
- List theMatrix) {
- PDFPattern pattern = new PDFPattern(2, theShading,
- theXUID, theExtGState, theMatrix);
-
- PDFPattern oldpatt = getDocument().findPattern(pattern);
- if (oldpatt == null) {
- getDocument().registerObject(pattern);
- } else {
- pattern = oldpatt;
- }
-
- if (res != null) {
- res.getPDFResources().addPattern(pattern);
- } else {
- getDocument().getResources().addPattern(pattern);
- }
-
- return (pattern);
- }
-
- /**
- * Make a gradient
- *
- * @param res the PDF resource context to add the shading, may be null
- * @param radial if true a radial gradient will be created
- * @param theColorspace the colorspace of the gradient
- * @param theColors the list of colors for the gradient
- * @param theBounds the list of bounds associated with the colors
- * @param theCoords the coordinates for the gradient
- * @param theMatrix the coordinate-transformation matrix
- * @return the PDF pattern that was created
- */
- public PDFPattern makeGradient(PDFResourceContext res, boolean radial,
- PDFDeviceColorSpace theColorspace,
- List theColors, List theBounds,
- List theCoords, List theMatrix) {
- PDFShading myShad;
- PDFFunction myfunky;
- PDFFunction myfunc;
- List theCzero;
- List theCone;
- PDFPattern myPattern;
- //PDFColorSpace theColorSpace;
- double interpolation = 1.000;
- List theFunctions = new ArrayList();
-
- int currentPosition;
- int lastPosition = theColors.size() - 1;
-
-
- // if 5 elements, the penultimate element is 3.
- // do not go beyond that, because you always need
- // to have a next color when creating the function.
-
- for (currentPosition = 0; currentPosition < lastPosition;
- currentPosition++) { // for every consecutive color pair
- Color currentColor = (Color)theColors.get(currentPosition);
- Color nextColor = (Color)theColors.get(currentPosition + 1);
-
- // colorspace must be consistent, so we simply convert to sRGB where necessary
- if (!currentColor.getColorSpace().isCS_sRGB()) {
- //Convert to sRGB
- currentColor = ColorUtil.toSRGBColor(currentColor);
- theColors.set(currentPosition, currentColor);
- }
- if (!nextColor.getColorSpace().isCS_sRGB()) {
- //Convert to sRGB
- nextColor = ColorUtil.toSRGBColor(nextColor);
- theColors.set(currentPosition + 1, nextColor);
- }
-
- theCzero = toColorVector(currentColor);
- theCone = toColorVector(nextColor);
-
- myfunc = makeFunction(2, null, null, theCzero, theCone,
- interpolation);
-
- theFunctions.add(myfunc);
-
- } // end of for every consecutive color pair
-
- myfunky = makeFunction(3, null, null, theFunctions, theBounds,
- null);
-
- if (radial) {
- if (theCoords.size() == 6) {
- myShad = makeShading(res, 3, getDocument().getPDFColorSpace(),
- null, null,
- false, theCoords, null, myfunky,
- null);
- } else { // if the center x, center y, and radius specifiy
- // the gradient, then assume the same center x, center y,
- // and radius of zero for the other necessary component
- List newCoords = new ArrayList();
- newCoords.add(theCoords.get(0));
- newCoords.add(theCoords.get(1));
- newCoords.add(theCoords.get(2));
- newCoords.add(theCoords.get(0));
- newCoords.add(theCoords.get(1));
- newCoords.add(new Double(0.0));
-
- myShad = makeShading(res, 3, getDocument().getPDFColorSpace(),
- null, null,
- false, newCoords, null, myfunky,
- null);
-
- }
- } else {
- myShad = makeShading(res, 2, getDocument().getPDFColorSpace(),
- null, null,
- false, theCoords, null, myfunky,
- null);
-
- }
-
- myPattern = makePattern(res, 2, myShad, null, null, theMatrix);
-
- return (myPattern);
- }
-
- private List toColorVector(Color nextColor) {
- List vector = new java.util.ArrayList();
- float[] comps = nextColor.getColorComponents(null);
- for (int i = 0, c = comps.length; i < c; i++) {
- vector.add(new Double(comps[i]));
- }
- return vector;
- }
/* ============= named destinations and the name dictionary ============ */
@@ -1866,16 +1399,11 @@ public class PDFFactory {
String colorName = ncs.getColorName();
final Double zero = new Double(0d);
final Double one = new Double(1d);
- List theDomain = Arrays.asList(new Double[] {zero, one});
- List theRange = Arrays.asList(new Double[] {zero, one, zero, one, zero, one});
- List theCZero = Arrays.asList(new Double[] {one, one, one});
- List theCOne = new ArrayList();
- float[] comps = ncs.getRGBColor().getColorComponents(null);
- for (int i = 0, c = comps.length; i < c; i++) {
- theCOne.add(new Double(comps[i]));
- }
- PDFFunction tintFunction = makeFunction(2, theDomain, theRange,
- theCZero, theCOne, 1.0d);
+ List domain = Arrays.asList(new Double[] {zero, one});
+ List range = Arrays.asList(new Double[] {zero, one, zero, one, zero, one});
+ float[] cZero = new float[] {1f, 1f, 1f};
+ float[] cOne = ncs.getRGBColor().getColorComponents(null);
+ PDFFunction tintFunction = makeFunction(domain, range, cZero, cOne, 1.0d);
PDFSeparationColorSpace cs = new PDFSeparationColorSpace(colorName, tintFunction);
getDocument().registerObject(cs);
if (res != null) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFunction.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFunction.java?rev=1611783&r1=1611782&r2=1611783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFunction.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFunction.java Fri Jul 18 19:48:02 2014
@@ -19,12 +19,15 @@
package org.apache.fop.pdf;
-// Java...
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
-import org.apache.fop.render.shading.Function;
-import org.apache.fop.render.shading.FunctionDelegate;
-import org.apache.fop.render.shading.FunctionPattern;
+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.GradientMaker.DoubleFormatter;
/**
* class representing a PDF Function.
@@ -37,75 +40,11 @@ import org.apache.fop.render.shading.Fun
*
* All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.
*/
-public class PDFFunction extends PDFObject implements Function {
+public class PDFFunction extends PDFObject {
- private FunctionDelegate delegate;
+ private final Function function;
- /**
- * create an complete Function object of Type 0, A Sampled function.
- *
- * Use null for an optional object parameter if you choose not to use it.
- * For optional int parameters, pass the default.
- *
- * @param theDomain List objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange List objects of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theSize A List object of Integer objects.
- * This is the number of samples in each input dimension.
- * I can't imagine there being more or less than two input dimensions,
- * so maybe this should be an array of length 2.
- *
- * See page 265 of the PDF 1.3 Spec.
- * @param theBitsPerSample An int specifying the number of bits
- used to represent each sample value.
- * Limited to 1,2,4,8,12,16,24 or 32.
- * See page 265 of the 1.3 PDF Spec.
- * @param theOrder The order of interpolation between samples. Default is 1 (one). Limited
- * to 1 (one) or 3, which means linear or cubic-spline interpolation.
- *
- * This attribute is optional.
- *
- * See page 265 in the PDF 1.3 spec.
- * @param theEncode List objects of Double objects.
- * This is the linear mapping of input values intop the domain
- * of the function's sample table. Default is hard to represent in
- * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
- * This attribute is optional.
- *
- * See page 265 in the PDF 1.3 spec.
- * @param theDecode List objects of Double objects.
- * This is a linear mapping of sample values into the range.
- * The default is just the range.
- *
- * This attribute is optional.
- * Read about it on page 265 of the PDF 1.3 spec.
- * @param theFunctionDataStream The sample values that specify
- * the function are provided in a stream.
- *
- * This is optional, but is almost always used.
- *
- * Page 265 of the PDF 1.3 spec has more.
- * @param theFilter This is a vector of String objects which are the various filters that
- * have are to be applied to the stream to make sense of it. Order matters,
- * so watch out.
- *
- * This is not documented in the Function section of the PDF 1.3 spec,
- * it was deduced from samples that this is sometimes used, even if we may never
- * use it in FOP. It is added for completeness sake.
- * @param theFunctionType This is the type of function (0,2,3, or 4).
- * It should be 0 as this is the constructor for sampled functions.
- */
- public PDFFunction(int theFunctionType, List<Double> theDomain,
- List<Double> theRange, List<Double> theSize, int theBitsPerSample,
- int theOrder, List<Double> theEncode, List<Double> theDecode,
- StringBuffer theFunctionDataStream, List<String> theFilter) {
- delegate = new FunctionDelegate(this, theFunctionType, theDomain, theRange,
- theSize, theBitsPerSample, theOrder, theEncode, theDecode,
- theFunctionDataStream, theFilter);
- }
+ private final List<PDFFunction> pdfFunctions;
/**
* create an complete Function object of Type 2, an Exponential Interpolation function.
@@ -113,104 +52,44 @@ public class PDFFunction extends PDFObje
* Use null for an optional object parameter if you choose not to use it.
* For optional int parameters, pass the default.
*
- * @param theDomain List objects of Double objects.
+ * @param domain List objects of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange List of Doubles that is the Range of the function.
+ * @param range List of Doubles that is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theCZero This is a vector of Double objects which defines the function result
+ * @param cZero This is a vector of Double objects which defines the function result
* when x=0.
*
* This attribute is optional.
* It's described on page 268 of the PDF 1.3 spec.
- * @param theCOne This is a vector of Double objects which defines the function result
+ * @param cOne This is a vector of Double objects which defines the function result
* when x=1.
*
* This attribute is optional.
* It's described on page 268 of the PDF 1.3 spec.
- * @param theInterpolationExponentN This is the inerpolation exponent.
+ * @param interpolationExponentN This is the inerpolation exponent.
*
* This attribute is required.
* PDF Spec page 268
- * @param theFunctionType The type of the function, which should be 2.
*/
- public PDFFunction(int theFunctionType, List<Double> theDomain,
- List<Double> theRange, List<Double> theCZero, List<Double> theCOne,
- double theInterpolationExponentN) {
- delegate = new FunctionDelegate(this, theFunctionType, theDomain, theRange,
- theCZero, theCOne, theInterpolationExponentN);
+ public PDFFunction(List<Double> domain, List<Double> range, float[] cZero, float[] cOne,
+ double interpolationExponentN) {
+ this(new Function(domain, range, cZero, cOne, interpolationExponentN));
}
- /**
- * create an complete Function object of Type 3, a Stitching function.
- *
- * Use null for an optional object parameter if you choose not to use it.
- * For optional int parameters, pass the default.
- *
- * @param theDomain List objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange List objects of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theFunctions A List of the PDFFunction objects that the stitching function stitches.
- *
- * This attributed is required.
- * It is described on page 269 of the PDF spec.
- * @param theBounds This is a vector of Doubles representing the numbers that,
- * in conjunction with Domain define the intervals to which each function from
- * the 'functions' object applies. It must be in order of increasing magnitude,
- * and each must be within Domain.
- *
- * It basically sets how much of the gradient each function handles.
- *
- * This attributed is required.
- * It's described on page 269 of the PDF 1.3 spec.
- * @param theEncode List objects of Double objects.
- * This is the linear mapping of input values intop the domain
- * of the function's sample table. Default is hard to represent in
- * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
- * This attribute is required.
- *
- * See page 270 in the PDF 1.3 spec.
- * @param theFunctionType This is the function type. It should be 3,
- * for a stitching function.
- */
- public PDFFunction(int theFunctionType, List<Double> theDomain,
- List<Double> theRange, List<Function> theFunctions,
- List<Double> theBounds, List<Double> theEncode) {
- delegate = new FunctionDelegate(this, theFunctionType, theDomain, theRange,
- theFunctions, theBounds, theEncode);
+ @SuppressWarnings("unchecked")
+ public PDFFunction(Function function) {
+ this(function, Collections.EMPTY_LIST);
+ }
+ public PDFFunction(Function function, List<PDFFunction> pdfFunctions) {
+ this.function = function;
+ this.pdfFunctions = pdfFunctions;
}
- /**
- * create an complete Function object of Type 4, a postscript calculator function.
- *
- * Use null for an optional object parameter if you choose not to use it.
- * For optional int parameters, pass the default.
- *
- * @param theDomain List object of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange List object of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theFunctionDataStream This is a stream of arithmetic,
- * boolean, and stack operators and boolean constants.
- * I end up enclosing it in the '{' and '}' braces for you, so don't do it
- * yourself.
- *
- * This attribute is required.
- * It's described on page 269 of the PDF 1.3 spec.
- * @param theFunctionType The type of function which should be 4, as this is
- * a Postscript calculator function
- */
- public PDFFunction(int theFunctionType, List<Double> theDomain,
- List<Double> theRange, StringBuffer theFunctionDataStream) {
- delegate = new FunctionDelegate(this, theFunctionType, theDomain, theRange,
- theFunctionDataStream);
+ public Function getFunction() {
+ return function;
}
/**
@@ -230,8 +109,25 @@ public class PDFFunction extends PDFObje
public byte[] toByteString() {
- FunctionPattern pattern = new FunctionPattern(this);
- return encode(pattern.toWriteableString());
+ List<String> functionsStrings = new ArrayList<String>(function.getFunctions().size());
+ for (PDFFunction f : pdfFunctions) {
+ functionsStrings.add(f.referencePDF());
+ }
+ SubFunctionRenderer subFunctionRenderer = new SubFunctionRenderer() {
+
+ public void outputFunction(StringBuilder out, int functionIndex) {
+ out.append(pdfFunctions.get(functionIndex).referencePDF());
+ }
+ };
+ StringBuilder out = new StringBuilder();
+ GradientMaker.DoubleFormatter doubleFormatter = new DoubleFormatter() {
+
+ public String formatDouble(double d) {
+ return PDFNumber.doubleOut(d);
+ }
+ };
+ function.output(out, doubleFormatter, subFunctionRenderer);
+ return encode(out.toString());
}
/** {@inheritDoc} */
@@ -245,91 +141,51 @@ public class PDFFunction extends PDFObje
if (!(obj instanceof PDFFunction)) {
return false;
}
- PDFFunction func = (PDFFunction)obj;
- if (delegate.getFunctionType() != func.getFunctionType()) {
+ Function func = ((PDFFunction) obj).function;
+ if (function.getFunctionType() != func.getFunctionType()) {
return false;
}
- if (delegate.getBitsPerSample() != func.getBitsPerSample()) {
+ if (function.getBitsPerSample() != func.getBitsPerSample()) {
return false;
}
- if (delegate.getOrder() != func.getOrder()) {
+ if (function.getOrder() != func.getOrder()) {
return false;
}
- if (delegate.getInterpolationExponentN() != func.getInterpolationExponentN()) {
+ if (function.getInterpolationExponentN() != func.getInterpolationExponentN()) {
return false;
}
- if (delegate.getDomain() != null) {
- if (!delegate.getDomain().equals(func.getDomain())) {
+ if (function.getDomain() != null) {
+ if (!function.getDomain().equals(func.getDomain())) {
return false;
}
} else if (func.getDomain() != null) {
return false;
}
- if (delegate.getRange() != null) {
- if (!delegate.getRange().equals(func.getRange())) {
+ if (function.getRange() != null) {
+ if (!function.getRange().equals(func.getRange())) {
return false;
}
} else if (func.getRange() != null) {
return false;
}
- if (delegate.getSize() != null) {
- if (!delegate.getSize().equals(func.getSize())) {
- return false;
- }
- } else if (func.getSize() != null) {
- return false;
- }
- if (delegate.getEncode() != null) {
- if (!delegate.getEncode().equals(func.getEncode())) {
+ if (function.getEncode() != null) {
+ if (!function.getEncode().equals(func.getEncode())) {
return false;
}
} else if (func.getEncode() != null) {
return false;
}
- if (delegate.getDecode() != null) {
- if (!delegate.getDecode().equals(func.getDecode())) {
- return false;
- }
- } else if (func.getDecode() != null) {
- return false;
- }
- if (delegate.getDataStream() != null) {
- if (!delegate.getDataStream().equals(func.getDataStream())) {
- return false;
- }
- } else if (func.getDataStream() != null) {
- return false;
- }
- if (delegate.getFilter() != null) {
- if (!delegate.getFilter().equals(func.getFilter())) {
- return false;
- }
- } else if (func.getFilter() != null) {
- return false;
- }
- if (delegate.getCZero() != null) {
- if (!delegate.getCZero().equals(func.getCZero())) {
- return false;
- }
- } else if (func.getCZero() != null) {
+ if (!Arrays.equals(function.getCZero(), func.getCZero())) {
return false;
}
- if (delegate.getCOne() != null) {
- if (!delegate.getCOne().equals(func.getCOne())) {
- return false;
- }
- } else if (func.getCOne() != null) {
+ if (!Arrays.equals(function.getCOne(), func.getCOne())) {
return false;
}
- if (delegate.getFunctions() != null) {
- if (!delegate.getFunctions().equals(func.getFunctions())) {
- return false;
- }
- } else if (func.getFunctions() != null) {
+ if (!pdfFunctions.equals(((PDFFunction) obj).pdfFunctions)) {
return false;
}
- if (delegate.getBounds() != null) {
- if (!delegate.getBounds().equals(func.getBounds())) {
+ if (function.getBounds() != null) {
+ if (!function.getBounds().equals(func.getBounds())) {
return false;
}
} else if (func.getBounds() != null) {
@@ -338,63 +194,4 @@ public class PDFFunction extends PDFObje
return true;
}
- public int getFunctionType() {
- return delegate.getFunctionType();
- }
-
- public List<Double> getBounds() {
- return delegate.getBounds();
- }
-
- public List<Double> getDomain() {
- return delegate.getDomain();
- }
-
- public List<Double> getSize() {
- return delegate.getSize();
- }
-
- public List<String> getFilter() {
- return delegate.getFilter();
- }
-
- public List<Double> getEncode() {
- return delegate.getEncode();
- }
-
- public List<Function> getFunctions() {
- return delegate.getFunctions();
- }
-
- public int getBitsPerSample() {
- return delegate.getBitsPerSample();
- }
-
- public double getInterpolationExponentN() {
- return delegate.getInterpolationExponentN();
- }
-
- public int getOrder() {
- return delegate.getOrder();
- }
-
- public List<Double> getRange() {
- return delegate.getRange();
- }
-
- public List<Double> getDecode() {
- return delegate.getDecode();
- }
-
- public StringBuffer getDataStream() {
- return delegate.getDataStream();
- }
-
- public List<Double> getCZero() {
- return delegate.getCZero();
- }
-
- public List<Double> getCOne() {
- return delegate.getCOne();
- }
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFPattern.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFPattern.java?rev=1611783&r1=1611782&r2=1611783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFPattern.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFPattern.java Fri Jul 18 19:48:02 2014
@@ -23,9 +23,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
-import org.apache.fop.render.shading.Pattern;
-import org.apache.fop.render.shading.Shading;
-
/**
* class representing a PDF Function.
*
@@ -36,7 +33,7 @@ import org.apache.fop.render.shading.Sha
*
* All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.
*/
-public class PDFPattern extends PDFPathPaint implements Pattern {
+public class PDFPattern extends PDFPathPaint {
/**
* The resources associated with this pattern
@@ -144,19 +141,18 @@ public class PDFPattern extends PDFPathP
* Create a type 2 pattern (smooth shading)
*
* @param thePatternType the type of the pattern, which is 2, smooth shading
- * @param theShading the PDF Shading object that comprises this pattern
+ * @param shading the Shading object that comprises this pattern
* @param theXUID optional:the extended unique Identifier if used.
* @param theExtGState optional: the extended graphics state, if used.
* @param theMatrix Optional:List of Doubles that specify the matrix.
*/
- public PDFPattern(int thePatternType, Shading theShading,
+ public PDFPattern(int thePatternType, PDFShading shading,
List theXUID, StringBuffer theExtGState,
List theMatrix) {
super();
this.patternType = 2; // thePatternType;
- assert theShading instanceof PDFShading;
- this.shading = (PDFShading)theShading;
+ this.shading = shading;
this.xUID = theXUID;
// this isn't really implemented, so it should always be null.
// I just don't want to have to add a new parameter once it is implemented.
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFShading.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFShading.java?rev=1611783&r1=1611782&r2=1611783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFShading.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFShading.java Fri Jul 18 19:48:02 2014
@@ -19,12 +19,12 @@
package org.apache.fop.pdf;
-// Java...
import java.util.List;
-import org.apache.fop.render.shading.Function;
-import org.apache.fop.render.shading.Shading;
-import org.apache.fop.render.shading.ShadingPattern;
+import org.apache.fop.render.gradient.GradientMaker;
+import org.apache.fop.render.gradient.GradientMaker.DoubleFormatter;
+import org.apache.fop.render.gradient.Shading;
+
/**
* class representing a PDF Smooth Shading object.
@@ -36,7 +36,7 @@ import org.apache.fop.render.shading.Sha
*
* All PDF Functions have a shadingType (0,2,3, or 4), a Domain, and a Range.
*/
-public class PDFShading extends PDFObject implements Shading {
+public class PDFShading extends PDFObject {
// Guts common to all function types
/**
@@ -44,266 +44,23 @@ public class PDFShading extends PDFObjec
*/
protected String shadingName;
- /**
- * Required: The Type of shading (1,2,3,4,5,6,7)
- */
- protected int shadingType = 3; // Default
-
- /**
- * A ColorSpace representing the colorspace. "DeviceRGB" is an example.
- */
- protected PDFDeviceColorSpace colorSpace;
-
- /**
- * The background color. Since shading is opaque,
- * this is very rarely used.
- */
- protected List background;
-
- /**
- * Optional: A List specifying the clipping rectangle
- */
- protected List bBox;
-
- /**
- * Optional: A flag whether or not to filter the shading function
- * to prevent aliasing artifacts. Default is false.
- */
- protected boolean antiAlias;
-
- /**
- * Optional for Type 1: Array of four numbers, xmin, xmax, ymin, ymax.
- * Default is [0 1 0 1]
- * Optional for Type 2: An array of two numbers between which the blend
- * varies between start and end points. Default is 0, 1.
- * Optional for Type 3: An array of two numbers between which the blend
- * varies between start and end points. Default is 0, 1.
- */
- protected List domain;
-
- /**
- * Optional for Type 1: A transformation matrix
- */
- protected List matrix;
-
- /**
- * Required for Type 1, 2, and 3:
- * The object of the color mapping function (usually type 2 or 3).
- * Optional for Type 4,5,6, and 7: When it's nearly the same thing.
- */
- protected PDFFunction function;
-
- /**
- * Required for Type 2: An Array of four numbers specifying
- * the starting and ending coordinate pairs
- * Required for Type 3: An Array of six numbers [x0,y0,r0,x1,y1,r1]
- * specifying the centers and radii of
- * the starting and ending circles.
- */
- protected List coords;
-
- /**
- * Required for Type 2+3: An Array of two boolean values specifying
- * whether to extend the start and end colors past the start
- * and end points, respectively.
- * Default is false, false.
- */
- protected List extend;
-
- /**
- * Required for Type 4,5,6, and 7: Specifies the number of bits used
- * to represent each vertex coordinate.
- * Allowed to be 1,2,4,8,12,16,24, or 32.
- */
- protected int bitsPerCoordinate;
-
- /**
- * Required for Type 4,5,6, and 7: Specifies the number of bits used
- * to represent the edge flag for each vertex.
- * Allowed to be 2,4,or 8, while the Edge flag itself is allowed to
- * be 0,1 or 2.
- */
- protected int bitsPerFlag;
+ private final Shading shading;
- /**
- * Required for Type 4,5,6, and 7: Array of Doubles which specifies
- * how to decode coordinate and color component values.
- * Each type has a differing number of decode array members, so check
- * the spec.
- * Page 303 in PDF Spec 1.3
- */
- protected List decode;
-
- /**
- * Required for Type 4,5,6, and 7: Specifies the number of bits used
- * to represent each color coordinate.
- * Allowed to be 1,2,4,8,12, or 16
- */
- protected int bitsPerComponent;
-
- /**
- * Required for Type 5:The number of vertices in each "row" of
- * the lattice; it must be greater than or equal to 2.
- */
- protected int verticesPerRow;
-
- /**
- * Constructor for type function based shading
- *
- * @param theShadingType The type of shading object, which should be 1 for function
- * based shading.
- * @param theColorSpace The colorspace is 'DeviceRGB' or something similar.
- * @param theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox List of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Whether or not to anti-alias.
- * @param theDomain Optional vector of Doubles specifying the domain.
- * @param theMatrix List of Doubles specifying the matrix.
- * If it's a pattern, then the matrix maps it to pattern space.
- * If it's a shading, then it maps it to current user space.
- * It's optional, the default is the identity matrix
- * @param theFunction The PDF Function that maps an (x,y) location to a color
- */
- public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theDomain,
- List theMatrix, PDFFunction theFunction) {
- super();
- this.shadingType = theShadingType; // 1
- this.colorSpace = theColorSpace;
- this.background = theBackground;
- this.bBox = theBBox;
- this.antiAlias = theAntiAlias;
-
- this.domain = theDomain;
- this.matrix = theMatrix;
- this.function = theFunction;
-
- }
+ private final PDFFunction pdfFunction;
/**
* Constructor for Type 2 and 3
*
- * @param theShadingType 2 or 3 for axial or radial shading
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox List of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theCoords List of four (type 2) or 6 (type 3) Double
- * @param theDomain List of Doubles specifying the domain
- * @param theFunction the Stitching (PDFfunction type 3) function,
+ * @param shadingType 2 or 3 for axial or radial shading
+ * @param colorSpace "DeviceRGB" or similar.
+ * @param coords List of four (type 2) or 6 (type 3) Double
+ * @param pdfFunction the Stitching (PDFfunction type 3) function,
* even if it's stitching a single function
- * @param theExtend List of Booleans of whether to extend the start
- * and end colors past the start and end points
- * The default is [false, false]
- */
- public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theCoords,
- List theDomain, Function theFunction,
- List theExtend) {
- super();
- this.shadingType = theShadingType; // 2 or 3
- this.colorSpace = theColorSpace;
- this.background = theBackground;
- this.bBox = theBBox;
- this.antiAlias = theAntiAlias;
-
- this.coords = theCoords;
- this.domain = theDomain;
- assert theFunction instanceof PDFFunction;
- this.function = (PDFFunction)theFunction;
- this.extend = theExtend;
-
- }
-
- /**
- * Constructor for Type 4,6, or 7
- *
- * @param theShadingType 4, 6, or 7 depending on whether it's
- * Free-form gouraud-shaded triangle meshes, coons patch meshes,
- * or tensor product patch meshes, respectively.
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox List of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theBitsPerCoordinate 1,2,4,8,12,16,24 or 32.
- * @param theBitsPerComponent 1,2,4,8,12, and 16
- * @param theBitsPerFlag 2,4,8.
- * @param theDecode List of Doubles see PDF 1.3 spec pages 303 to 312.
- * @param theFunction the PDFFunction
*/
- public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, int theBitsPerCoordinate,
- int theBitsPerComponent, int theBitsPerFlag,
- List theDecode, PDFFunction theFunction) {
- super();
-
- this.shadingType = theShadingType; // 4,6 or 7
- this.colorSpace = theColorSpace;
- this.background = theBackground;
- this.bBox = theBBox;
- this.antiAlias = theAntiAlias;
-
- this.bitsPerCoordinate = theBitsPerCoordinate;
- this.bitsPerComponent = theBitsPerComponent;
- this.bitsPerFlag = theBitsPerFlag;
- this.decode = theDecode;
- this.function = theFunction;
- }
-
- /**
- * Constructor for type 5
- *
- * @param theShadingType 5 for lattice-Form Gouraud shaded-triangle mesh
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox List of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theBitsPerCoordinate 1,2,4,8,12,16, 24, or 32
- * @param theBitsPerComponent 1,2,4,8,12,24,32
- * @param theDecode List of Doubles. See page 305 in PDF 1.3 spec.
- * @param theVerticesPerRow number of vertices in each "row" of the lattice.
- * @param theFunction The PDFFunction that's mapped on to this shape
- */
- public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, int theBitsPerCoordinate,
- int theBitsPerComponent, List theDecode,
- int theVerticesPerRow, PDFFunction theFunction) {
- super();
- this.shadingType = theShadingType; // 5
- this.colorSpace = theColorSpace;
- this.background = theBackground;
- this.bBox = theBBox;
- this.antiAlias = theAntiAlias;
-
- this.bitsPerCoordinate = theBitsPerCoordinate;
- this.bitsPerComponent = theBitsPerComponent;
- this.decode = theDecode;
- this.verticesPerRow = theVerticesPerRow;
- this.function = theFunction;
-
+ public PDFShading(int shadingType, PDFDeviceColorSpace colorSpace,
+ List coords, PDFFunction pdfFunction) {
+ shading = new Shading(shadingType, colorSpace, coords, pdfFunction.getFunction());
+ this.pdfFunction = pdfFunction;
}
/**
@@ -340,8 +97,21 @@ public class PDFShading extends PDFObjec
* @return the PDF string.
*/
public String toPDFString() {
- ShadingPattern pattern = new ShadingPattern(this);
- return pattern.toString(colorSpace, shadingType, background, bBox, antiAlias);
+ Shading.FunctionRenderer functionRenderer = new Shading.FunctionRenderer() {
+
+ public void outputFunction(StringBuilder out) {
+ out.append(pdfFunction.referencePDF());
+ }
+ };
+ StringBuilder out = new StringBuilder();
+ GradientMaker.DoubleFormatter doubleFormatter = new DoubleFormatter() {
+
+ public String formatDouble(double d) {
+ return PDFNumber.doubleOut(d);
+ }
+ };
+ shading.output(out, doubleFormatter, functionRenderer);
+ return out.toString();
}
/** {@inheritDoc} */
@@ -355,257 +125,54 @@ public class PDFShading extends PDFObjec
if (!(obj instanceof PDFShading)) {
return false;
}
- PDFShading shad = (PDFShading)obj;
- if (shadingType != shad.shadingType) {
+ Shading other = ((PDFShading) obj).shading;
+ if (shading.getShadingType() != other.getShadingType()) {
return false;
}
- if (antiAlias != shad.antiAlias) {
+ if (shading.isAntiAlias() != other.isAntiAlias()) {
return false;
}
- if (bitsPerCoordinate != shad.bitsPerCoordinate) {
+ if (shading.getBitsPerCoordinate() != other.getBitsPerCoordinate()) {
return false;
}
- if (bitsPerFlag != shad.bitsPerFlag) {
+ if (shading.getBitsPerFlag() != other.getBitsPerFlag()) {
return false;
}
- if (bitsPerComponent != shad.bitsPerComponent) {
+ if (shading.getBitsPerComponent() != other.getBitsPerComponent()) {
return false;
}
- if (verticesPerRow != shad.verticesPerRow) {
+ if (shading.getVerticesPerRow() != other.getVerticesPerRow()) {
return false;
}
- if (colorSpace != null) {
- if (!colorSpace.equals(shad.colorSpace)) {
+ if (shading.getColorSpace() != null) {
+ if (!shading.getColorSpace().equals(other.getColorSpace())) {
return false;
}
- } else if (shad.colorSpace != null) {
+ } else if (other.getColorSpace() != null) {
return false;
}
- if (background != null) {
- if (!background.equals(shad.background)) {
+ if (shading.getCoords() != null) {
+ if (!shading.getCoords().equals(other.getCoords())) {
return false;
}
- } else if (shad.background != null) {
+ } else if (other.getCoords() != null) {
return false;
}
- if (bBox != null) {
- if (!bBox.equals(shad.bBox)) {
+ if (shading.getExtend() != null) {
+ if (!shading.getExtend().equals(other.getExtend())) {
return false;
}
- } else if (shad.bBox != null) {
+ } else if (other.getExtend() != null) {
return false;
}
- if (domain != null) {
- if (!domain.equals(shad.domain)) {
+ if (shading.getFunction() != null) {
+ if (!shading.getFunction().equals(other.getFunction())) {
return false;
}
- } else if (shad.domain != null) {
- return false;
- }
- if (matrix != null) {
- if (!matrix.equals(shad.matrix)) {
- return false;
- }
- } else if (shad.matrix != null) {
- return false;
- }
- if (coords != null) {
- if (!coords.equals(shad.coords)) {
- return false;
- }
- } else if (shad.coords != null) {
- return false;
- }
- if (extend != null) {
- if (!extend.equals(shad.extend)) {
- return false;
- }
- } else if (shad.extend != null) {
- return false;
- }
- if (decode != null) {
- if (!decode.equals(shad.decode)) {
- return false;
- }
- } else if (shad.decode != null) {
- return false;
- }
- if (function != null) {
- if (!function.equals(shad.function)) {
- return false;
- }
- } else if (shad.function != null) {
+ } else if (other.getFunction() != null) {
return false;
}
return true;
}
- /**
- * A method to write a type 1 shading object
- * @param p The StringBuffer to write the shading object
- * @return Returns the StringBuffer to which the shading object was written
- */
- public StringBuffer handleShadingType1(StringBuffer p) {
- if (this.domain != null) {
- p.append("/Domain [ ");
- for (int domainIndex = 0; domainIndex < domain.size(); domainIndex++) {
- p.append(PDFNumber.doubleOut((Double)this.domain.get(domainIndex))
- + " ");
- }
- p.append("] \n");
- } else {
- p.append("/Domain [ 0 1 ] \n");
- }
-
- if (this.matrix != null) {
- p.append("/Matrix [ ");
- for (int matrixIndex = 0; matrixIndex < matrix.size(); matrixIndex++) {
- p.append(PDFNumber.doubleOut((Double)this.matrix.get(matrixIndex))
- + " ");
- }
- p.append("] \n");
- }
-
- if (this.function != null) {
- p.append("/Function ");
- p.append(this.function.referencePDF() + " \n");
- }
- return p;
- }
-
- /**
- * A method to write a type 2 or 3 shading object
- * @param p The StringBuffer to write the shading object
- * @return Returns the StringBuffer to which the shading object was written
- */
- public StringBuffer handleShadingType2or3(StringBuffer p) {
- // 3 is radial shading (circular gradient)
- if (this.coords != null) {
- p.append("/Coords [ ");
- for (int coordIndex = 0; coordIndex < coords.size(); coordIndex++) {
- p.append(PDFNumber.doubleOut((Double)this.coords.get(coordIndex))
- + " ");
- }
- p.append("] \n");
- }
-
- // DOMAIN
- if (this.domain != null) {
- p.append("/Domain [ ");
- for (int domainIndex = 0; domainIndex < domain.size(); domainIndex++) {
- p.append(PDFNumber.doubleOut((Double)this.domain.get(domainIndex))
- + " ");
- }
- p.append("] \n");
- } else {
- p.append("/Domain [ 0 1 ] \n");
- }
-
- if (this.extend != null) {
- p.append("/Extend [ ");
- for (int extendIndex = 0; extendIndex < extend.size(); extendIndex++) {
- p.append((this.extend.get(extendIndex)) + " ");
- }
-
- p.append("] \n");
- } else {
- p.append("/Extend [ true true ] \n");
- }
-
-
- if (this.function != null) {
- p.append("/Function ");
- p.append(this.function.referencePDF() + " \n");
- }
-
- return p;
- }
-
- /**
- * A method to write a type 4, 6 or 7 shading object
- * @param p The StringBuffer to write the shading object
- * @return Returns the StringBuffer to which the shading object was written
- */
- public StringBuffer handleShadingType4or6or7(StringBuffer p) {
- // 6:coons patch meshes
- // 7://tensor product patch meshes (which no one ever uses)
- if (this.bitsPerCoordinate > 0) {
- p.append("/BitsPerCoordinate " + this.bitsPerCoordinate
- + " \n");
- } else {
- p.append("/BitsPerCoordinate 1 \n");
- }
-
- if (this.bitsPerComponent > 0) {
- p.append("/BitsPerComponent " + this.bitsPerComponent
- + " \n");
- } else {
- p.append("/BitsPerComponent 1 \n");
- }
-
- if (this.bitsPerFlag > 0) {
- p.append("/BitsPerFlag " + this.bitsPerFlag + " \n");
- } else {
- p.append("/BitsPerFlag 2 \n");
- }
-
- if (this.decode != null) {
- p.append("/Decode [ ");
- for (int decodeIndex = 0; decodeIndex < decode.size(); decodeIndex++) {
- p.append((this.decode.get(decodeIndex)) + " ");
- }
-
- p.append("] \n");
- }
-
- if (this.function != null) {
- p.append("/Function ");
- p.append(this.function.referencePDF() + " \n");
- }
-
- return p;
- }
-
- /**
- * A method to write a type 5 shading object
- * @param p The StringBuffer to write the shading object
- * @return Returns the StringBuffer to which the shading object was written
- */
- public StringBuffer handleShadingType5(StringBuffer p) {
- if (this.bitsPerCoordinate > 0) {
- p.append("/BitsPerCoordinate " + this.bitsPerCoordinate
- + " \n");
- } else {
- p.append("/BitsPerCoordinate 1 \n");
- }
-
- if (this.bitsPerComponent > 0) {
- p.append("/BitsPerComponent " + this.bitsPerComponent
- + " \n");
- } else {
- p.append("/BitsPerComponent 1 \n");
- }
-
- if (this.decode != null) {
- p.append("/Decode [ ");
- for (int decodeIndex = 0; decodeIndex < decode.size(); decodeIndex++) {
- p.append((this.decode.get(decodeIndex)) + " ");
- }
-
- p.append("] \n");
- }
-
- if (this.function != null) {
- p.append("/Function ");
- p.append(this.function.referencePDF() + " \n");
- }
-
- if (this.verticesPerRow > 0) {
- p.append("/VerticesPerRow " + this.verticesPerRow + " \n");
- } else {
- p.append("/VerticesPerRow 2 \n");
- }
-
- return p;
- }
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/gradient/GradientMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/gradient/GradientMaker.java?rev=1611783&r1=1611778&r2=1611783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/gradient/GradientMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/gradient/GradientMaker.java Fri Jul 18 19:48:02 2014
@@ -63,7 +63,7 @@ public final class GradientMaker {
double dy = focus.getY() - center.getY();
double d = Math.sqrt(dx * dx + dy * dy);
if (d > radius) {
- // The center point must be within the circle with
+ // The focal point must be within the circle with
// radius radius centered at center so limit it to that.
double scale = (radius * .9999) / d;
dx *= scale;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java?rev=1611783&r1=1611782&r2=1611783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java Fri Jul 18 19:48:02 2014
@@ -33,8 +33,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.imageio.ImageIO;
@@ -314,19 +312,6 @@ public class PSImageHandlerSVG implement
}
}
String nodeName = curNode.getLocalName();
- //Special case where rasterization needed for radial gradients
- if (nodeName != null && nodeName.equals("ellipse")) {
- String found = "";
- String ellipseFill = curNode.getAttributes().getNamedItem("fill").getNodeValue();
- Pattern pattern = Pattern.compile("#(.*?)\\)");
- Matcher matcher = pattern.matcher(ellipseFill);
- if (matcher.find()) {
- found = matcher.group(1);
- }
- if (gradientsFound.get(found) != null) {
- return true;
- }
- }
boolean inMatch = false;
if (!isMatched) {
inMatch = nodeName != null && gradMatches.contains(nodeName);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java?rev=1611783&r1=1611782&r2=1611783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java Fri Jul 18 19:48:02 2014
@@ -19,34 +19,29 @@
package org.apache.fop.render.ps.svg;
-import java.awt.Color;
import java.awt.Graphics;
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.batik.ext.awt.LinearGradientPaint;
-import org.apache.batik.ext.awt.MultipleGradientPaint;
import org.apache.batik.ext.awt.RadialGradientPaint;
import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.fop.pdf.PDFDeviceColorSpace;
-import org.apache.fop.render.shading.Function;
-import org.apache.fop.render.shading.GradientFactory;
-import org.apache.fop.render.shading.GradientRegistrar;
-import org.apache.fop.render.shading.PSGradientFactory;
-import org.apache.fop.render.shading.Pattern;
-import org.apache.fop.render.shading.Shading;
+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.GradientMaker.DoubleFormatter;
+import org.apache.fop.render.gradient.Pattern;
+import org.apache.fop.render.gradient.Shading;
-public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar {
+public class PSSVGGraphics2D extends PSGraphics2D {
private static final Log LOG = LogFactory.getLog(PSSVGGraphics2D.class);
@@ -79,167 +74,72 @@ public class PSSVGGraphics2D extends PSG
protected void applyPaint(Paint paint, boolean fill) {
super.applyPaint(paint, fill);
- if (paint instanceof RadialGradientPaint) {
- RadialGradientPaint rgp = (RadialGradientPaint)paint;
+ if (paint instanceof LinearGradientPaint) {
+ Pattern pattern = GradientMaker.makeLinearGradient((LinearGradientPaint) paint,
+ getBaseTransform(), getTransform());
try {
- handleRadialGradient(rgp, gen);
+ gen.write(outputPattern(pattern));
} catch (IOException ioe) {
handleIOException(ioe);
}
- } else if (paint instanceof LinearGradientPaint) {
- LinearGradientPaint lgp = (LinearGradientPaint)paint;
+ } else if (paint instanceof RadialGradientPaint) {
+ Pattern pattern = GradientMaker.makeRadialGradient((RadialGradientPaint) paint,
+ getBaseTransform(), getTransform());
try {
- handleLinearGradient(lgp, gen);
+ gen.write(outputPattern(pattern));
} catch (IOException ioe) {
handleIOException(ioe);
}
}
}
- private void handleLinearGradient(LinearGradientPaint lgp, PSGenerator gen) throws IOException {
- MultipleGradientPaint.CycleMethodEnum cycle = lgp.getCycleMethod();
- if (cycle != MultipleGradientPaint.NO_CYCLE) {
- return;
- }
- float[] fractions = lgp.getFractions();
- Color[] cols = lgp.getColors();
-
- AffineTransform transform = new AffineTransform(getBaseTransform());
- transform.concatenate(getTransform());
- transform.concatenate(lgp.getTransform());
-
- List theMatrix = new ArrayList();
- double [] mat = new double[6];
- transform.getMatrix(mat);
- for (int idx = 0; idx < mat.length; idx++) {
- theMatrix.add(Double.valueOf(mat[idx]));
- }
-
-
- List<Double> theCoords = new java.util.ArrayList<Double>();
+ private String outputPattern(Pattern pattern) {
+ StringBuilder p = new StringBuilder(64);
+ p.append("/Pattern setcolorspace\n");
+ p.append("<< \n/Type /Pattern \n");
+ p.append("/PatternType " + pattern.getPatternType() + " \n");
- AffineTransform start = applyTransform(lgp.getTransform(),
- lgp.getStartPoint().getX(), lgp.getStartPoint().getY());
- AffineTransform end = applyTransform(lgp.getTransform(), lgp.getEndPoint().getX(), lgp.getEndPoint().getY());
- double startX = start.getTranslateX();
- double startY = start.getTranslateY();
- double endX = end.getTranslateX();
- double endY = end.getTranslateY();
-
- double width = endX - startX;
- double height = endY - startY;
-
- startX = startX + width * fractions[0];
- endX = endX - width * (1 - fractions[fractions.length - 1]);
- startY = startY + (height * fractions[0]);
- endY = endY - height * (1 - fractions[fractions.length - 1]);
-
- theCoords.add(startX);
- theCoords.add(startY);
- theCoords.add(endX);
- theCoords.add(endY);
-
-
- List<Color> someColors = new java.util.ArrayList<Color>();
- for (int count = 0; count < cols.length; count++) {
- Color c1 = cols[count];
- if (c1.getAlpha() != 255) {
- LOG.warn("Opacity is not currently supported for Postscript output");
- }
- someColors.add(c1);
+ if (pattern.getShading() != null) {
+ p.append("/Shading ");
+ outputShading(p, pattern.getShading());
+ p.append(" \n");
}
- List<Double> theBounds = new java.util.ArrayList<Double>();
- for (int count = 1; count < fractions.length - 1; count++) {
- float offset = fractions[count];
- theBounds.add(Double.valueOf(offset));
+ p.append(">> \n");
+ p.append("[ ");
+ for (double m : pattern.getMatrix()) {
+ p.append(getPSGenerator().formatDouble(m));
+ p.append(" ");
}
- PDFDeviceColorSpace colSpace;
- colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
-
- PSGradientFactory gradientFactory = (PSGradientFactory)GradientFactory.newInstance(this);
- PSPattern myPattern = gradientFactory.createGradient(false, colSpace,
- someColors, theBounds, theCoords, theMatrix);
-
- gen.write(myPattern.toString());
+ p.append("] ");
+ p.append("makepattern setcolor\n");
+ return p.toString();
}
+ private void outputShading(StringBuilder out, Shading shading) {
+ final GradientMaker.DoubleFormatter doubleFormatter = new DoubleFormatter() {
-
- private void handleRadialGradient(RadialGradientPaint rgp, PSGenerator gen) throws IOException {
- MultipleGradientPaint.CycleMethodEnum cycle = rgp.getCycleMethod();
- if (cycle != MultipleGradientPaint.NO_CYCLE) {
- return;
- }
-
- AffineTransform transform;
- transform = new AffineTransform(getBaseTransform());
- transform.concatenate(getTransform());
- transform.concatenate(rgp.getTransform());
-
- AffineTransform resultCentre = applyTransform(rgp.getTransform(),
- rgp.getCenterPoint().getX(), rgp.getCenterPoint().getY());
- AffineTransform resultFocus = applyTransform(rgp.getTransform(),
- rgp.getFocusPoint().getX(), rgp.getFocusPoint().getY());
- double scale = Math.sqrt(rgp.getTransform().getDeterminant());
- double radius = rgp.getRadius() * scale;
- double centreX = resultCentre.getTranslateX();
- double centreY = resultCentre.getTranslateY();
- double focusX = resultFocus.getTranslateX();
- double focusY = resultFocus.getTranslateY();
-
- List<Double> theMatrix = new java.util.ArrayList<Double>();
- double [] mat = new double[6];
- transform.getMatrix(mat);
- for (int idx = 0; idx < mat.length; idx++) {
- theMatrix.add(Double.valueOf(mat[idx]));
- }
-
- List<Double> theCoords = new java.util.ArrayList<Double>();
- float[] fractions = rgp.getFractions();
-
- theCoords.add(centreX);
- theCoords.add(centreY);
- theCoords.add(radius * rgp.getFractions()[0]);
- theCoords.add(focusX);
- theCoords.add(focusY);
- theCoords.add(radius * fractions[fractions.length - 1]);
-
- Color[] cols = rgp.getColors();
- List<Color> someColors = new java.util.ArrayList<Color>();
- for (int count = 0; count < cols.length; count++) {
- Color cc = cols[count];
- if (cc.getAlpha() != 255) {
- /* This should never happen because radial gradients with opacity should now
- * be rasterized in the PSImageHandlerSVG class. Please see the shouldRaster()
- * method for more information. */
- LOG.warn("Opacity is not currently supported for Postscript output");
+ public String formatDouble(double d) {
+ return getPSGenerator().formatDouble(d);
}
-
- someColors.add(cc);
- }
-
- List<Double> theBounds = new java.util.ArrayList<Double>();
- for (int count = 1; count < fractions.length - 1; count++) {
- float offset = fractions[count];
- theBounds.add(Double.valueOf(offset));
- }
- PDFDeviceColorSpace colSpace;
- colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
-
- PSGradientFactory gradientFactory = (PSGradientFactory)GradientFactory.newInstance(this);
- PSPattern myPattern = gradientFactory.createGradient(true, colSpace,
- someColors, theBounds, theCoords, theMatrix);
-
- gen.write(myPattern.toString());
- }
-
- private AffineTransform applyTransform(AffineTransform base, double posX, double posY) {
- AffineTransform result = AffineTransform.getTranslateInstance(posX, posY);
- AffineTransform orig = base;
- orig.concatenate(result);
- return orig;
+ };
+ final Function function = shading.getFunction();
+ Shading.FunctionRenderer functionRenderer = new Shading.FunctionRenderer() {
+
+ public void outputFunction(StringBuilder out) {
+ SubFunctionRenderer subFunctionRenderer = new Function.SubFunctionRenderer() {
+
+ public void outputFunction(StringBuilder out, int functionIndex) {
+ Function subFunction = function.getFunctions().get(functionIndex);
+ assert subFunction.getFunctions().isEmpty();
+ subFunction.output(out, doubleFormatter, null);
+ }
+ };
+ function.output(out, doubleFormatter, subFunctionRenderer);
+ }
+ };
+ shading.output(out, doubleFormatter, functionRenderer);
}
protected AffineTransform getBaseTransform() {
@@ -259,36 +159,4 @@ public class PSSVGGraphics2D extends PSG
return new PSSVGGraphics2D(this);
}
- /**
- * Registers a function object against the output format document
- * @param function The function object to register
- * @return Returns either the function which has already been registered
- * or the current new registered object.
- */
- public Function registerFunction(Function function) {
- //Objects aren't needed to be registered in Postscript
- return function;
- }
-
- /**
- * Registers a shading object against the otuput format document
- * @param shading The shading object to register
- * @return Returs either the shading which has already been registered
- * or the current new registered object
- */
- public Shading registerShading(Shading shading) {
- //Objects aren't needed to be registered in Postscript
- return shading;
- }
-
- /**
- * Registers a pattern object against the output format document
- * @param pattern The pattern object to register
- * @return Returns either the pattern which has already been registered
- * or the current new registered object
- */
- public Pattern registerPattern(Pattern pattern) {
- // TODO Auto-generated method stub
- return pattern;
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org