jeremias    2003/03/27 02:44:41

  Modified:    src/java/org/apache/fop/pdf PDFState.java PDFShading.java
  Log:
  The PDF object number doesn't get passed to the constructor anymore. Adjust for that.
  Use the toPDFString() (returns String) method instead of toPDF() (returns byte[]) 
where appropriate. String to byte[] conversion is done in PDFObject in a well-defined 
location instead of scattered around the codebase.
  
  Revision  Changes    Path
  1.2       +1 -1      xml-fop/src/java/org/apache/fop/pdf/PDFState.java
  
  Index: PDFState.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFState.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFState.java     11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFState.java     27 Mar 2003 10:44:41 -0000      1.2
  @@ -366,7 +366,7 @@
           PDFGState defaultState = PDFGState.DEFAULT;
   
           PDFGState state;
  -        PDFGState newstate = new PDFGState(0);
  +        PDFGState newstate = new PDFGState();
           newstate.addValues(defaultState);
           for (Iterator iter = stateStack.iterator(); iter.hasNext();) {
               HashMap map = (HashMap)iter.next();
  
  
  
  1.2       +26 -32    xml-fop/src/java/org/apache/fop/pdf/PDFShading.java
  
  Index: PDFShading.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFShading.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFShading.java   11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFShading.java   27 Mar 2003 10:44:41 -0000      1.2
  @@ -177,9 +177,6 @@
       /**
        * Constructor for type function based shading
        *
  -     * @param theNumber The object number of this PDF object
  -     * @param theShadingName The name of the shading pattern. Can be anything
  -     * without spaces. "Shading1" or "Sh1" are good examples.
        * @param theShadingType The type of shading object, which should be 1 for 
function
        * based shading.
        * @param theColorSpace The colorspace is 'DeviceRGB' or something similar.
  @@ -198,13 +195,11 @@
        * 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 theNumber, String theShadingName,
  -                      int theShadingType, PDFColorSpace theColorSpace,
  +    public PDFShading(int theShadingType, PDFColorSpace theColorSpace,
                         List theBackground, List theBBox,
                         boolean theAntiAlias, List theDomain,
                         List theMatrix, PDFFunction theFunction) {
  -        super(theNumber);
  -        this.shadingName = theShadingName;
  +        super();
           this.shadingType = theShadingType;    // 1
           this.colorSpace = theColorSpace;
           this.background = theBackground;
  @@ -220,9 +215,6 @@
       /**
        * Constructor for Type 2 and 3
        *
  -     * @param theNumber The object number of this PDF object.
  -     * @param theShadingName The name of the shading pattern. Can be anything
  -     * without spaces. "Shading1" or "Sh1" are good examples.
        * @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
  @@ -241,14 +233,12 @@
        *                  and end colors past the start and end points
        * The default is [false, false]
        */
  -    public PDFShading(int theNumber, String theShadingName,
  -                      int theShadingType, PDFColorSpace theColorSpace,
  +    public PDFShading(int theShadingType, PDFColorSpace theColorSpace,
                         List theBackground, List theBBox,
                         boolean theAntiAlias, List theCoords,
                         List theDomain, PDFFunction theFunction,
                         List theExtend) {
  -        super(theNumber);
  -        this.shadingName = theShadingName;
  +        super();
           this.shadingType = theShadingType;    // 2 or 3
           this.colorSpace = theColorSpace;
           this.background = theBackground;
  @@ -265,12 +255,9 @@
       /**
        * Constructor for Type 4,6, or 7
        *
  -     * @param theNumber The object number of this PDF object.
        * @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 theShadingName The name of the shading pattern. Can be anything
  -     * 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.
  @@ -286,13 +273,12 @@
        * @param theDecode List of Doubles see PDF 1.3 spec pages 303 to 312.
        * @param theFunction the PDFFunction
        */
  -    public PDFShading(int theNumber, String theShadingName,
  -                      int theShadingType, PDFColorSpace theColorSpace,
  +    public PDFShading(int theShadingType, PDFColorSpace theColorSpace,
                         List theBackground, List theBBox,
                         boolean theAntiAlias, int theBitsPerCoordinate,
                         int theBitsPerComponent, int theBitsPerFlag,
                         List theDecode, PDFFunction theFunction) {
  -        super(theNumber);
  +        super();
   
           this.shadingType = theShadingType;    // 4,6 or 7
           this.colorSpace = theColorSpace;
  @@ -311,8 +297,6 @@
        * Constructor for type 5
        *
        * @param theShadingType 5 for lattice-Form Gouraud shaded-triangle mesh
  -     * @param theShadingName The name of the shading pattern. Can be anything
  -     * 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.
  @@ -327,16 +311,13 @@
        * @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
  -     * @param theNumber the object number of this PDF object.
        */
  -    public PDFShading(int theNumber, String theShadingName,
  -                      int theShadingType, PDFColorSpace theColorSpace,
  +    public PDFShading(int theShadingType, PDFColorSpace theColorSpace,
                         List theBackground, List theBBox,
                         boolean theAntiAlias, int theBitsPerCoordinate,
                         int theBitsPerComponent, List theDecode,
                         int theVerticesPerRow, PDFFunction theFunction) {
  -        super(theNumber);
  -        this.shadingName = theShadingName;
  +        super();
           this.shadingType = theShadingType;    // 5
           this.colorSpace = theColorSpace;
           this.background = theBackground;
  @@ -361,6 +342,19 @@
       }
   
       /**
  +     * Sets the name of the shading
  +     * @param name the name of the shading pattern. Can be anything
  +     * without spaces. "Shading1" or "Sh1" are good examples.
  +     */
  +    public void setName(String name) {
  +        if (name.indexOf(" ") >= 0) {
  +            throw new IllegalArgumentException(
  +                    "Shading name must not contain any spaces");
  +        }
  +        this.shadingName = name;
  +    }
  +
  +    /**
        * represent as PDF. Whatever the shadingType is, the correct
        * representation spits out. The sets of required and optional
        * attributes are different for each type, but if a required
  @@ -371,12 +365,12 @@
        *
        * @return the PDF string.
        */
  -    public byte[] toPDF() {
  +    public String toPDFString() {
           int vectorSize;
           int tempInt;
  -        StringBuffer p = new StringBuffer();
  -        p.append(this.number + " " + this.generation
  -                 + " obj\n<< \n/ShadingType " + this.shadingType + " \n");
  +        StringBuffer p = new StringBuffer(128);
  +        p.append(getObjectID() 
  +            + "<< \n/ShadingType " + this.shadingType + " \n");
           if (this.colorSpace != null) {
               p.append("/ColorSpace /"
                        + this.colorSpace.getColorSpacePDFString() + " \n");
  @@ -563,7 +557,7 @@
   
           p.append(">> \nendobj\n");
   
  -        return (p.toString().getBytes());
  +        return (p.toString());
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to