return "en"; // userLanguages;
}
+ public String getMedia() {
+ return "";
+ }
+
+
/**
* Returns the user stylesheet uri.
* @return null if no user style sheet was specified.
private String getHyphenationWord(char[] characters, int wordStart) {
boolean wordendFound = false;
int counter = 0;
- char[] newWord = new char[100]; // create a buffer
+ char[] newWord = new char[characters.length]; // create a buffer
while ((!wordendFound)
&& ((wordStart + counter) < characters.length)) {
char tk = characters[wordStart + counter];
protected float currentGreen = 0;
protected float currentBlue = 0;
- /**
- * The parent component, used to set up the font.
- * This is needed as FontSetup needs a live AWT component
- * in order to generate valid font measures.
- */
- protected Component parent;
-
/**
* options
*/
throws IOException {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
svgDocument = impl.createDocument(svgNS, "svg", null);
-
- svgRoot = svgDocument.getDocumentElement();
- }
+ ProcessingInstruction pi =
+ svgDocument.createProcessingInstruction(
+ "xml",
+ " version=\"1.0\" encoding=\"ISO-8859-1\"");
+ svgRoot = svgDocument.getDocumentElement();
+ svgDocument.insertBefore(pi, svgRoot);
+ }
public void stopRenderer(OutputStream outputStream)
throws IOException {
return currentAnnotList;
}
+ public void addJpegImage(JpegImage jpeg, float x, float y, float width, float height) {
+ int xObjectNum = this.pdfDoc.addImage(jpeg);
+
+ AffineTransform at = getTransform();
+ double[] matrix = new double[6];
+ at.getMatrix(matrix);
+ currentStream.write("q\n");
+ Shape imclip = getClip();
+ writeClip(imclip);
+ currentStream.write("" + matrix[0] + " " + matrix[1] + " "
+ + matrix[2] + " " + matrix[3] + " "
+ + matrix[4] + " " + matrix[5] + " cm\n");
+
+ currentStream.write("" + width + " 0 0 "
+ + (-height) + " "
+ + x + " "
+ + (y + height) + " cm\n" + "/Im"
+ + xObjectNum + " Do\nQ\n");
+ }
+
/**
* Draws as much of the specified image as is currently available.
* The image is drawn with its top-left corner at
return false;
}
- Dimension size = new Dimension(width, height);
+ Dimension size = new Dimension(width * 3, height * 3);
BufferedImage buf = buildBufferedImage(size);
java.awt.Graphics2D g = buf.createGraphics();
g.setComposite(AlphaComposite.SrcOver);
g.setBackground(new Color(1, 1, 1, 0));
g.setPaint(new Color(1, 1, 1, 0));
- g.fillRect(0, 0, width, height);
+ g.fillRect(0, 0, width * 3, height * 3);
g.clip(new Rectangle(0, 0, buf.getWidth(), buf.getHeight()));
- if (!g.drawImage(img, 0, 0, observer)) {
+ if (!g.drawImage(img, 0, 0, buf.getWidth(), buf.getHeight(), observer)) {
return false;
}
g.dispose();
}
try {
- FopImage fopimg = new TempImage(width, height, result, mask);
+ FopImage fopimg = new TempImage(buf.getWidth(), buf.getHeight(), result, mask);
int xObjectNum = this.pdfDoc.addImage(fopimg);
AffineTransform at = getTransform();
double[] matrix = new double[6];
*/
public void draw(Shape s) {
// System.out.println("draw(Shape)");
+ Color c;
+ c = getColor();
+ if(c.getAlpha() == 0) {
+ return;
+ }
+
currentStream.write("q\n");
Shape imclip = getClip();
writeClip(imclip);
- Color c = getColor();
applyColor(c, false);
applyPaint(getPaint(), false);
* but it should be fixed...).
*/
public Rectangle getBounds() {
+System.out.println("getting getBounds");
return null;
}
* The default transform (1:1).
*/
public AffineTransform getDefaultTransform() {
+System.out.println("getting getDefaultTransform");
return new AffineTransform();
}
* in the future).
*/
public AffineTransform getNormalizingTransform() {
- return new AffineTransform();
+System.out.println("getting getNormalizingTransform");
+ return new AffineTransform(2, 0, 0, 2, 0, 0);
}
/**
--- /dev/null
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
+package org.apache.fop.svg;
+
+import java.awt.Cursor;
+import java.awt.geom.AffineTransform;
+
+import org.apache.batik.bridge.*;
+
+import org.apache.batik.css.HiddenChildElementSupport;
+import org.apache.batik.gvt.CompositeGraphicsNode;
+import org.apache.batik.gvt.GraphicsNode;
+
+import org.apache.fop.pdf.*;
+import org.apache.fop.image.*;
+import org.apache.fop.apps.*;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.svg.SVGAElement;
+
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.Graphics2D;
+import java.awt.color.ICC_Profile;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.dom.util.XLinkSupport;
+import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
+import org.apache.batik.ext.awt.image.renderable.ClipRable8Bit;
+import org.apache.batik.ext.awt.image.renderable.Filter;
+import org.apache.batik.ext.awt.image.spi.ImageTagRegistry;
+import org.apache.batik.gvt.CompositeGraphicsNode;
+import org.apache.batik.gvt.GraphicsNode;
+import org.apache.batik.gvt.ImageNode;
+import org.apache.batik.gvt.RasterImageNode;
+import org.apache.batik.gvt.AbstractGraphicsNode;
+import org.apache.batik.gvt.filter.GraphicsNodeRable8Bit;
+import org.apache.batik.util.ParsedURL;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.svg.SVGDocument;
+import org.w3c.dom.svg.SVGSVGElement;
+
+/**
+ * Bridge class for the <image> element when jpeg images.
+ *
+ * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
+ */
+public class PDFImageElementBridge extends SVGImageElementBridge {
+
+ /**
+ * Constructs a new bridge for the <image> element.
+ */
+ public PDFImageElementBridge() {}
+/*
+ protected GraphicsNode createRasterImageNode(BridgeContext ctx,
+ Element e, ParsedURL purl) {
+
+ try {
+ JpegImage jpeg = new JpegImage(new URL(purl.toString()));
+ PDFFilter filter = jpeg.getPDFFilter();
+ PDFJpegNode node = new PDFJpegNode(jpeg);
+ Rectangle2D bounds = node.getPrimitiveBounds();
+ float [] vb = new float[4];
+ vb[0] = 0; // x
+ vb[1] = 0; // y
+ vb[2] = (float) bounds.getWidth(); // width
+ vb[3] = (float) bounds.getHeight(); // height
+
+ // handles the 'preserveAspectRatio', 'overflow' and 'clip' and sets the
+ // appropriate AffineTransform to the image node
+ initializeViewport(ctx, e, node, vb, bounds);
+
+ return node;
+ } catch (Exception ex) {
+ }
+
+ return super.createRasterImageNode(ctx, e, purl);
+ }
+*/
+ public static class PDFJpegNode extends AbstractGraphicsNode {
+ JpegImage jpeg;
+ public PDFJpegNode(JpegImage j) {
+ jpeg = j;
+ }
+
+ public Shape getOutline() {
+ return getPrimitiveBounds();
+ }
+
+ public void primitivePaint(Graphics2D g2d) {
+ if (g2d instanceof PDFGraphics2D) {
+ PDFGraphics2D pdfg = (PDFGraphics2D) g2d;
+ pdfg.setTransform(getTransform());
+ float x = 0;
+ float y = 0;
+ try {
+ float width = jpeg.getWidth();
+ float height = jpeg.getHeight();
+ pdfg.addJpegImage(jpeg, x, y, width, height);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public Rectangle2D getGeometryBounds() {
+ return getPrimitiveBounds();
+ }
+
+ public Rectangle2D getPrimitiveBounds() {
+ try {
+ return new Rectangle2D.Double(0, 0, jpeg.getWidth(),
+ jpeg.getHeight());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+ }
+
+}
return wordWidth / 1000f;
}
- /**
- * Initiates a text selection on a particular AttributedCharacterIterator,
- * using the text/font metrics employed by this TextPainter instance.
- * @param x the x coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param y the y coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param aci the AttributedCharacterIterator describing the text
- * @return an instance of Mark which encapsulates the state necessary to
- * implement hit testing and text selection.
- */
- public Mark selectAt(double x, double y, AttributedCharacterIterator aci,
+ public Mark getMark(TextNode node, int pos, boolean all) {
+ System.out.println("PDFText getMark");
+ return null;
+ }
+
+ public Mark selectAt(double x, double y,
TextNode node) {
System.out.println("PDFText selectAt");
return null;
}
- /**
- * Continues a text selection on a particular AttributedCharacterIterator,
- * using the text/font metrics employed by this TextPainter instance.
- * @param x the x coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param y the y coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param aci the AttributedCharacterIterator describing the text
- * @return an instance of Mark which encapsulates the state necessary to
- * implement hit testing and text selection.
- */
- public Mark selectTo(double x, double y, Mark beginMark,
- AttributedCharacterIterator aci,
- TextNode node) {
+ public Mark selectTo(double x, double y, Mark beginMark) {
System.out.println("PDFText selectTo");
return null;
}
- /**
- * Select all of the text represented by an AttributedCharacterIterator,
- * using the text/font metrics employed by this TextPainter instance.
- * @param x the x coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param y the y coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param aci the AttributedCharacterIterator describing the text
- * @return an instance of Mark which encapsulates the state necessary to
- * implement hit testing and text selection.
- */
public Mark selectAll(double x, double y,
- AttributedCharacterIterator aci,
TextNode node) {
System.out.println("PDFText selectAll");
return null;
}
-
- /**
- * Selects the first glyph in the text node.
- */
- public Mark selectFirst(double x, double y,
- AttributedCharacterIterator aci,
- TextNode node) {
+ public Mark selectFirst(TextNode node) {
System.out.println("PDFText selectFirst");
return null;
}
-
- /**
- * Selects the last glyph in the text node.
- */
- public Mark selectLast(double x, double y,
- AttributedCharacterIterator aci,
- TextNode node) {
+ public Mark selectLast(TextNode node) {
System.out.println("PDFText selectLast");
return null;
}
- /*
- * Get an array of index pairs corresponding to the indices within an
- * AttributedCharacterIterator regions bounded by two Marks.
- * Note that the instances of Mark passed to this function
- * <em>must come</em>
- * from the same TextPainter that generated them via selectAt() and
- * selectTo(), since the TextPainter implementation may rely on hidden
- * implementation details of its own Mark implementation.
- */
- public int[] getSelected(AttributedCharacterIterator aci, Mark start,
+ public int[] getSelected(Mark start,
Mark finish) {
System.out.println("PDFText getSelected");
return null;
}
-
- /*
- * Get a Shape in userspace coords which encloses the textnode
- * glyphs bounded by two Marks.
- * Note that the instances of Mark passed to this function
- * <em>must come</em>
- * from the same TextPainter that generated them via selectAt() and
- * selectTo(), since the TextPainter implementation may rely on hidden
- * implementation details of its own Mark implementation.
- */
public Shape getHighlightShape(Mark beginMark, Mark endMark) {
System.out.println("PDFText getHighlightShape");
return null;
}
- /*
- * Get a Shape in userspace coords which defines the textnode glyph outlines.
- * @param node the TextNode to measure
- * @param frc the font rendering context.
- * @param includeDecoration whether to include text decoration
- * outlines.
- * @param includeStroke whether to create the "stroke shape outlines"
- * instead of glyph outlines.
- */
public Shape getShape(TextNode node) {
System.out.println("PDFText getShape");
return null;
}
- /*
- * Get a Shape in userspace coords which defines the textnode glyph outlines.
- * @param node the TextNode to measure
- * @param frc the font rendering context.
- * @param includeDecoration whether to include text decoration
- * outlines.
- * @param includeStroke whether to create the "stroke shape outlines"
- * instead of glyph outlines.
- */
public Shape getDecoratedShape(TextNode node) {
System.out.println("PDFText getDecoratedShape");
return new Rectangle(1, 1);
}
- /*
- * Get a Rectangle2D in userspace coords which encloses the textnode
- * glyphs composed from an AttributedCharacterIterator.
- * @param node the TextNode to measure
- * @param g2d the Graphics2D to use
- * @param context rendering context.
- */
public Rectangle2D getBounds(TextNode node) {
System.out.println("PDFText getBounds");
return null;
}
- /*
- * Get a Rectangle2D in userspace coords which encloses the textnode
- * glyphs composed from an AttributedCharacterIterator, inclusive of
- * glyph decoration (underline, overline, strikethrough).
- * @param node the TextNode to measure
- * @param g2d the Graphics2D to use
- * @param context rendering context.
- */
public Rectangle2D getDecoratedBounds(TextNode node) {
System.out.println("PDFText getDecoratedBounds");
return null;
}
- /*
- * Get a Rectangle2D in userspace coords which encloses the
- * textnode glyphs (as-painted, inclusive of decoration and stroke, but
- * exclusive of filters, etc.) composed from an AttributedCharacterIterator.
- * @param node the TextNode to measure
- * @param g2d the Graphics2D to use
- * @param context rendering context.
- */
public Rectangle2D getPaintedBounds(TextNode node) {
// System.out.println("PDFText getPaintedBounds");
return null;
AffineTransform currentTransform = new AffineTransform(1, 0, 0, 1, 0, 0);
pdfAElementBridge.setCurrentTransform(currentTransform);
ctx.putBridge(pdfAElementBridge);
+ ctx.putBridge(new PDFImageElementBridge());
GraphicsNode gvtRoot;
try {
gvtRoot = builder.build(ctx, svgDoc);
}
}
+ public String getMedia() {
+ return "";
+ }
+
+
/**
* Returns the user stylesheet specified in the
* <tt>TranscodingHints</tt> or null if any.
return "en"; // userLanguages;
}
+ public String getMedia() {
+ return "";
+ }
+
/**
* Returns the user stylesheet uri.
* @return null if no user style sheet was specified.