1 51 package org.apache.fop.svg; 52 53 import org.apache.batik.bridge.*; 54 55 import org.apache.fop.image.*; 56 57 import java.awt.Shape ; 58 import java.awt.Graphics2D ; 59 import java.awt.geom.Rectangle2D ; 60 import java.awt.geom.Rectangle2D ; 61 62 import org.apache.batik.gvt.AbstractGraphicsNode; 63 64 69 public class PDFImageElementBridge extends SVGImageElementBridge { 70 71 74 public PDFImageElementBridge() {} 75 101 public static class PDFJpegNode extends AbstractGraphicsNode { 102 JpegImage jpeg; 103 public PDFJpegNode(JpegImage j) { 104 jpeg = j; 105 } 106 107 public Shape getOutline() { 108 return getPrimitiveBounds(); 109 } 110 111 public void primitivePaint(Graphics2D g2d) { 112 if (g2d instanceof PDFGraphics2D) { 113 PDFGraphics2D pdfg = (PDFGraphics2D) g2d; 114 pdfg.setTransform(getTransform()); 115 float x = 0; 116 float y = 0; 117 try { 118 float width = jpeg.getWidth(); 119 float height = jpeg.getHeight(); 120 pdfg.addJpegImage(jpeg, x, y, width, height); 121 } catch (Exception e) { 122 e.printStackTrace(); 123 } 124 } 125 } 126 127 public Rectangle2D getGeometryBounds() { 128 return getPrimitiveBounds(); 129 } 130 131 public Rectangle2D getPrimitiveBounds() { 132 try { 133 return new Rectangle2D.Double (0, 0, jpeg.getWidth(), 134 jpeg.getHeight()); 135 } catch (Exception e) { 136 e.printStackTrace(); 137 } 138 return null; 139 } 140 141 public Rectangle2D getSensitiveBounds() { 142 return getPrimitiveBounds(); 143 } 144 145 } 146 147 } 148 | Popular Tags |