jeremias    2003/03/27 03:27:29

  Modified:    src/java/org/apache/fop/svg PDFGraphics2D.java
  Log:
  Adjust to changes in PDF library.
  Remove duplicate text encoding code now in PDFText.
  
  Revision  Changes    Path
  1.3       +21 -44    xml-fop/src/java/org/apache/fop/svg/PDFGraphics2D.java
  
  Index: PDFGraphics2D.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFGraphics2D.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PDFGraphics2D.java        12 Mar 2003 08:02:05 -0000      1.2
  +++ PDFGraphics2D.java        27 Mar 2003 11:27:28 -0000      1.3
  @@ -57,6 +57,7 @@
   import org.apache.fop.pdf.PDFColor;
   import org.apache.fop.pdf.PDFState;
   import org.apache.fop.pdf.PDFNumber;
  +import org.apache.fop.pdf.PDFText;
   import org.apache.fop.pdf.PDFXObject;
   import org.apache.fop.pdf.PDFPattern;
   import org.apache.fop.pdf.PDFDocument;
  @@ -317,10 +318,11 @@
       
               if (linkType != PDFLink.EXTERNAL) {
                   String pdfdest = "/FitR " + dest;
  -                resourceContext.addAnnotation(pdfDoc.makeLink(rect, pageRef, 
pdfdest));
  +                resourceContext.addAnnotation(
  +                    pdfDoc.getFactory().makeLink(rect, pageRef, pdfdest));
               } else {
  -                resourceContext.addAnnotation(pdfDoc.makeLink(rect,
  -                                                     dest, linkType, 0));
  +                resourceContext.addAnnotation(
  +                    pdfDoc.getFactory().makeLink(rect, dest, linkType, 0));
               }
           }
       }
  @@ -673,7 +675,8 @@
           if (c.getAlpha() != 255) {
               Map vals = new java.util.HashMap();
               vals.put(PDFGState.GSTATE_ALPHA_STROKE, new Float(c.getAlpha() / 255f));
  -            PDFGState gstate = pdfDoc.makeGState(vals, graphicsState.getGState());
  +            PDFGState gstate = pdfDoc.getFactory().makeGState(
  +                    vals, graphicsState.getGState());
               //gstate.setAlpha(c.getAlpha() / 255f, false);
               resourceContext.addGState(gstate);
               currentStream.write("/" + gstate.getName() + " gs\n");
  @@ -917,7 +920,8 @@
               }
   
               PDFColorSpace aColorSpace = new PDFColorSpace(PDFColorSpace.DEVICE_RGB);
  -            PDFPattern myPat = pdfDoc.createGradient(resourceContext, false, 
aColorSpace,
  +            PDFPattern myPat = pdfDoc.getFactory().makeGradient(
  +                    resourceContext, false, aColorSpace,
                       someColors, theBounds, theCoords);
               currentStream.write(myPat.getColorSpaceOut(fill));
   
  @@ -964,7 +968,8 @@
                   theBounds.add(new Double(offset));
               }
               PDFColorSpace colSpace = new PDFColorSpace(PDFColorSpace.DEVICE_RGB);
  -            PDFPattern myPat = pdfDoc.createGradient(resourceContext, true, 
colSpace,
  +            PDFPattern myPat = pdfDoc.getFactory().makeGradient(
  +                                    resourceContext, true, colSpace,
                                       someColors, theBounds, theCoords);
   
               currentStream.write(myPat.getColorSpaceOut(fill));
  @@ -981,8 +986,8 @@
           FontInfo fi = new FontInfo();
           FontSetup.setup(fi, null);
   
  -        PDFResources res = pdfDoc.makeResources();
  -        PDFResourceContext context = new PDFResourceContext(0, pdfDoc, res);
  +        PDFResources res = pdfDoc.getFactory().makeResources();
  +        PDFResourceContext context = new PDFResourceContext(res);
           PDFGraphics2D pattGraphic = new PDFGraphics2D(textAsShapes, fi,
                                           pdfDoc, context, pageRef,
                                           "", 0);
  @@ -1024,7 +1029,8 @@
   
           FontSetup.addToResources(pdfDoc, res, fi);
   
  -        PDFPattern myPat = pdfDoc.makePattern(resourceContext, 1, res, 1, 1, bbox,
  +        PDFPattern myPat = pdfDoc.getFactory().makePattern(
  +                                resourceContext, 1, res, 1, 1, bbox,
                                   rect.getWidth(), rect.getHeight(),
                                   translate, null, pattStream.getBuffer());
   
  @@ -1032,7 +1038,7 @@
   
           PDFAnnotList annots = context.getAnnotations();
           if (annots != null) {
  -            this.pdfDoc.addAnnotList(annots);
  +            this.pdfDoc.addObject(annots);
           }
   
           if (outputStream != null) {
  @@ -1236,7 +1242,8 @@
           if (salpha != 255) {
               Map vals = new java.util.HashMap();
               vals.put(PDFGState.GSTATE_ALPHA_NONSTROKE, new Float(salpha / 255f));
  -            PDFGState gstate = pdfDoc.makeGState(vals, graphicsState.getGState());
  +            PDFGState gstate = pdfDoc.getFactory().makeGState(
  +                    vals, graphicsState.getGState());
               resourceContext.addGState(gstate);
               currentStream.write("/" + gstate.getName() + " gs\n");
           }
  @@ -1300,7 +1307,7 @@
                       currentStream.write(ch);
                   }
               } else {
  -                currentStream.write(getUnicodeString(ch));
  +                currentStream.write(PDFText.toUnicodeHex(ch));
               }
   
               if (kerningAvailable && (i + 1) < l) {
  @@ -1333,37 +1340,6 @@
       }
   
       /**
  -     * Convert a char to a multibyte hex representation
  -     */
  -    private String getUnicodeString(char c) {
  -
  -        StringBuffer buf = new StringBuffer(4);
  -        byte[] uniBytes = null;
  -        try {
  -            char[] a = {
  -                c
  -            };
  -            uniBytes = new String(a).getBytes("UnicodeBigUnmarked");
  -        } catch (Exception e) {
  -            // This should never fail
  -        }
  -
  -        for (int i = 0; i < uniBytes.length; i++) {
  -            int b = (uniBytes[i] < 0) ? (int)(256 + uniBytes[i])
  -                    : (int)uniBytes[i];
  -
  -            String hexString = Integer.toHexString(b);
  -            if (hexString.length() == 1) {
  -                buf = buf.append("0" + hexString);
  -            } else {
  -                buf = buf.append(hexString);
  -            }
  -        }
  -
  -        return buf.toString();
  -    }
  -
  -    /**
        * Renders the text of the specified iterator, using the
        * <code>Graphics2D</code> context's current <code>Paint</code>. The
        * iterator must specify a font
  @@ -1489,7 +1465,8 @@
           if (c.getAlpha() != 255) {
               Map vals = new java.util.HashMap();
               vals.put(PDFGState.GSTATE_ALPHA_NONSTROKE, new Float(c.getAlpha() / 
255f));
  -            PDFGState gstate = pdfDoc.makeGState(vals, graphicsState.getGState());
  +            PDFGState gstate = pdfDoc.getFactory().makeGState(
  +                        vals, graphicsState.getGState());
               resourceContext.addGState(gstate);
               currentStream.write("/" + gstate.getName() + " gs\n");
           }
  
  
  

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

Reply via email to