diff options
Diffstat (limited to 'src/java/org/apache/fop/svg')
14 files changed, 118 insertions, 31 deletions
diff --git a/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java b/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java index acb59ed7d..1622d4f51 100644 --- a/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java +++ b/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java @@ -37,12 +37,13 @@ import org.apache.fop.fonts.FontInfo; */ public abstract class AbstractFOPBridgeContext extends BridgeContext { - /** The font list. */ + /** the font list */ protected final FontInfo fontInfo; - + /** image manager */ protected final ImageManager imageManager; + /** image session context */ protected final ImageSessionContext imageSessionContext; - + /** link transform */ protected final AffineTransform linkTransform; /** @@ -122,6 +123,10 @@ public abstract class AbstractFOPBridgeContext extends BridgeContext { return this.imageSessionContext; } + /** + * @param className name of bridge class to load and construct + * @param testFor class name to test for presence + */ protected void putElementBridgeConditional(String className, String testFor) { try { Class.forName(testFor); @@ -137,6 +142,7 @@ public abstract class AbstractFOPBridgeContext extends BridgeContext { // Make sure any 'sub bridge contexts' also have our bridges. //TODO There's no matching method in the super-class here + /** @return new bridge context */ public abstract BridgeContext createBridgeContext(); } diff --git a/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java b/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java index 31895cebe..c4191077f 100644 --- a/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java +++ b/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java @@ -160,10 +160,15 @@ public abstract class AbstractFOPImageElementBridge extends SVGImageElementBridg */ public class LoaderImageNode extends AbstractGraphicsNode { + /** image */ protected final Image image; + /** bridge context */ protected final BridgeContext ctx; + /** image element */ protected final Element imageElement; + /** parsed url */ protected final ParsedURL purl; + /** original graphics mode */ protected GraphicsNode origGraphicsNode = null; /** diff --git a/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java b/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java index eec402075..fc007b90a 100644 --- a/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java +++ b/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java @@ -129,7 +129,10 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder { this.resolver = resolver; } - /** {@inheritDoc} */ + /** + * @param cfg the configuration + * @throws ConfigurationException if not caught + */ public void configure(Configuration cfg) throws ConfigurationException { this.cfg = cfg; } diff --git a/src/java/org/apache/fop/svg/FOPTextHandler.java b/src/java/org/apache/fop/svg/FOPTextHandler.java index 8fa9eeedd..cb59c7472 100644 --- a/src/java/org/apache/fop/svg/FOPTextHandler.java +++ b/src/java/org/apache/fop/svg/FOPTextHandler.java @@ -19,9 +19,12 @@ package org.apache.fop.svg; +/** an fop extension to text handler */ public interface FOPTextHandler extends org.apache.xmlgraphics.java2d.TextHandler { + /** @param font override font */ void setOverrideFont(org.apache.fop.fonts.Font font); + /** @return font info */ org.apache.fop.fonts.FontInfo getFontInfo(); } diff --git a/src/java/org/apache/fop/svg/FOPTextHandlerAdapter.java b/src/java/org/apache/fop/svg/FOPTextHandlerAdapter.java new file mode 100644 index 000000000..6f326546e --- /dev/null +++ b/src/java/org/apache/fop/svg/FOPTextHandlerAdapter.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.svg; + +import org.apache.xmlgraphics.java2d.StrokingTextHandler; + +/** + * The <code>FOPTextHandlerAdapter</code> class is an adapter class to permit use of + * FOPTextHandler without incurring deprecation warnings caused by the underlying + * org.apache.xmlgraphics.java2d.TextHandler.drawString(String...) method. + * @see org.apache.xmlgraphics.java2d.TextHandler + */ +public abstract class FOPTextHandlerAdapter extends StrokingTextHandler implements FOPTextHandler { +} diff --git a/src/java/org/apache/fop/svg/GraphicsConfiguration.java b/src/java/org/apache/fop/svg/GraphicsConfiguration.java index 881096b9a..83fd79b9d 100644 --- a/src/java/org/apache/fop/svg/GraphicsConfiguration.java +++ b/src/java/org/apache/fop/svg/GraphicsConfiguration.java @@ -29,9 +29,12 @@ import java.awt.image.VolatileImage; * for JDK 1.3 because there is no VolatileImage there. * */ -abstract public class GraphicsConfiguration extends java.awt.GraphicsConfiguration { +public abstract class GraphicsConfiguration extends java.awt.GraphicsConfiguration { /** + * @param width of image + * @param height of image + * @return new volatile image * @see java.awt.GraphicsConfiguration#createCompatibleVolatileImage(int, int) * @since JDK 1.4 */ @@ -40,6 +43,10 @@ abstract public class GraphicsConfiguration extends java.awt.GraphicsConfigurati } /** + * @param width of image + * @param height of image + * @param transparency of image + * @return new volatile image * @see java.awt.GraphicsConfiguration#createCompatibleVolatileImage(int, int, int) * @since JDK 1.5 */ diff --git a/src/java/org/apache/fop/svg/NativeImageHandler.java b/src/java/org/apache/fop/svg/NativeImageHandler.java index 8e74cba1d..e9d8116e6 100644 --- a/src/java/org/apache/fop/svg/NativeImageHandler.java +++ b/src/java/org/apache/fop/svg/NativeImageHandler.java @@ -19,6 +19,7 @@ package org.apache.fop.svg; +/** native image handler */ public interface NativeImageHandler { /** diff --git a/src/java/org/apache/fop/svg/NativeTextPainter.java b/src/java/org/apache/fop/svg/NativeTextPainter.java index 7da7269c2..14fa6460d 100644 --- a/src/java/org/apache/fop/svg/NativeTextPainter.java +++ b/src/java/org/apache/fop/svg/NativeTextPainter.java @@ -190,6 +190,10 @@ public abstract class NativeTextPainter extends StrokingTextPainter { return chars; } + /** + * @param runaci an attributed character iterator + * @param layout a text span layout + */ protected final void logTextRun(AttributedCharacterIterator runaci, TextSpanLayout layout) { if (log.isTraceEnabled()) { int charCount = runaci.getEndIndex() - runaci.getBeginIndex(); @@ -202,6 +206,12 @@ public abstract class NativeTextPainter extends StrokingTextPainter { } } + /** + * @param ch a character + * @param layout a text span layout + * @param index an index + * @param visibleChar visible character flag + */ protected final void logCharacter(char ch, TextSpanLayout layout, int index, boolean visibleChar) { if (log.isTraceEnabled()) { diff --git a/src/java/org/apache/fop/svg/PDFBridgeContext.java b/src/java/org/apache/fop/svg/PDFBridgeContext.java index e8569f881..a38465ed4 100644 --- a/src/java/org/apache/fop/svg/PDFBridgeContext.java +++ b/src/java/org/apache/fop/svg/PDFBridgeContext.java @@ -125,6 +125,7 @@ public class PDFBridgeContext extends AbstractFOPBridgeContext { // Make sure any 'sub bridge contexts' also have our bridges. //TODO There's no matching method in the super-class here + /** @return the new bridge context */ public BridgeContext createBridgeContext() { return new PDFBridgeContext(getUserAgent(), getDocumentLoader(), fontInfo, diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index b6dadac96..45189133a 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -776,7 +776,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand * @param fill true if the paint should be set for filling * @return true if the paint is handled natively, false if the paint should be rasterized */ - protected boolean applyPaint(Paint paint, boolean fill) { + protected boolean applyPaint(Paint paint, boolean fill) { // CSOK: MethodLength preparePainting(); if (paint instanceof Color) { @@ -1053,6 +1053,11 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand return true; } + /** + * @param paint some paint + * @param shape a shape + * @return true (always) + */ protected boolean applyUnknownPaint(Paint paint, Shape shape) { preparePainting(); @@ -1200,6 +1205,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand case BasicStroke.CAP_SQUARE: currentStream.write(2 + " J\n"); break; + default: + break; } int lj = bs.getLineJoin(); @@ -1213,6 +1220,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand case BasicStroke.JOIN_BEVEL: currentStream.write(2 + " j\n"); break; + default: + break; } float lw = bs.getLineWidth(); currentStream.write(PDFNumber.doubleOut(lw) + " w\n"); @@ -1228,7 +1237,11 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand drawInnerRenderedImage(key, img, xform); } - /** {@inheritDoc} */ + /** + * @param key a key + * @param img an image + * @param xform a transform + */ public void drawInnerRenderedImage(String key, RenderedImage img, AffineTransform xform) { preparePainting(); PDFXObject xObject = pdfDoc.getXObject(key); diff --git a/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java b/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java index 4ec6ad634..a41b7e229 100644 --- a/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java +++ b/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java @@ -33,11 +33,11 @@ import java.awt.image.ColorModel; */ class PDFGraphicsConfiguration extends GraphicsConfiguration { // We use this to get a good colormodel.. - private static final BufferedImage BI_WITH_ALPHA = - new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); + private static final BufferedImage BI_WITH_ALPHA + = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); // We use this to get a good colormodel.. - private static final BufferedImage BI_WITHOUT_ALPHA = - new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + private static final BufferedImage BI_WITHOUT_ALPHA + = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); /** * Construct a buffered image with an alpha channel, unless diff --git a/src/java/org/apache/fop/svg/PDFGraphicsDevice.java b/src/java/org/apache/fop/svg/PDFGraphicsDevice.java index 1d3dd6196..538dd16c2 100644 --- a/src/java/org/apache/fop/svg/PDFGraphicsDevice.java +++ b/src/java/org/apache/fop/svg/PDFGraphicsDevice.java @@ -62,7 +62,7 @@ class PDFGraphicsDevice extends GraphicsDevice { * @return an array containing the one graphics configuration */ public GraphicsConfiguration[] getConfigurations() { - return new GraphicsConfiguration[]{ gc }; + return new GraphicsConfiguration[] {gc}; } /** diff --git a/src/java/org/apache/fop/svg/SVGEventProducer.java b/src/java/org/apache/fop/svg/SVGEventProducer.java index 27d7da215..743649717 100644 --- a/src/java/org/apache/fop/svg/SVGEventProducer.java +++ b/src/java/org/apache/fop/svg/SVGEventProducer.java @@ -30,7 +30,10 @@ public interface SVGEventProducer extends EventProducer { /** * Provider class for the event producer. */ - class Provider { + final class Provider { + + private Provider() { + } /** * Returns an event producer. diff --git a/src/java/org/apache/fop/svg/SVGUtilities.java b/src/java/org/apache/fop/svg/SVGUtilities.java index 97cd31eed..3401307cf 100644 --- a/src/java/org/apache/fop/svg/SVGUtilities.java +++ b/src/java/org/apache/fop/svg/SVGUtilities.java @@ -34,7 +34,11 @@ import org.apache.batik.util.XMLConstants; /** * Some utilities for creating svg DOM documents and elements. */ -public class SVGUtilities { +public final class SVGUtilities { + + private SVGUtilities() { + } + private static final String SVG_NS = SVGDOMImplementation.SVG_NAMESPACE_URI; /** @@ -43,7 +47,7 @@ public class SVGUtilities { * @param height the height of the root svg element * @return a new SVG Document */ - public static final Document createSVGDocument(float width, + public static Document createSVGDocument(float width, float height) { DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); Document doc = impl.createDocument(SVG_NS, "svg", null); @@ -60,9 +64,9 @@ public class SVGUtilities { * @param font the font * @return the width of the string in the given font */ - public static final float getStringWidth(String str, java.awt.Font font) { - Rectangle2D rect = - font.getStringBounds(str, 0, str.length(), + public static float getStringWidth(String str, java.awt.Font font) { + Rectangle2D rect + = font.getStringBounds(str, 0, str.length(), new FontRenderContext(new AffineTransform(), true, true)); return (float)rect.getWidth(); @@ -74,10 +78,10 @@ public class SVGUtilities { * @param font the font * @return the height of the string in the given font */ - public static final float getStringHeight(String str, + public static float getStringHeight(String str, java.awt.Font font) { - Rectangle2D rect = - font.getStringBounds(str, 0, str.length(), + Rectangle2D rect + = font.getStringBounds(str, 0, str.length(), new FontRenderContext(new AffineTransform(), true, true)); return (float)rect.getHeight(); @@ -89,7 +93,7 @@ public class SVGUtilities { * @param font the font * @return the bounds of the string */ - public static final Rectangle2D getStringBounds(String str, + public static Rectangle2D getStringBounds(String str, java.awt.Font font) { return font.getStringBounds(str, 0, str.length(), new FontRenderContext(new AffineTransform(), @@ -105,7 +109,7 @@ public class SVGUtilities { * @param y2 the end y position * @return the new line element */ - public static final Element createLine(Document doc, float x, float y, + public static Element createLine(Document doc, float x, float y, float x2, float y2) { Element ellipse = doc.createElementNS(SVG_NS, "line"); ellipse.setAttributeNS(null, "x1", "" + x); @@ -124,7 +128,7 @@ public class SVGUtilities { * @param ry the y axis radius * @return the new ellipse element */ - public static final Element createEllipse(Document doc, float cx, + public static Element createEllipse(Document doc, float cx, float cy, float rx, float ry) { Element ellipse = doc.createElementNS(SVG_NS, "ellipse"); ellipse.setAttributeNS(null, "cx", "" + cx); @@ -140,7 +144,7 @@ public class SVGUtilities { * @param str the string for the d attribute on the path * @return the new path element */ - public static final Element createPath(Document doc, String str) { + public static Element createPath(Document doc, String str) { Element path = doc.createElementNS(SVG_NS, "path"); path.setAttributeNS(null, "d", str); return path; @@ -154,7 +158,7 @@ public class SVGUtilities { * @param str the string * @return the new text element */ - public static final Element createText(Document doc, float x, float y, + public static Element createText(Document doc, float x, float y, String str) { Element textGraph = doc.createElementNS(SVG_NS, "text"); textGraph.setAttributeNS(null, "x", "" + x); @@ -173,7 +177,7 @@ public class SVGUtilities { * @param height the height of the rectangle * @return the new rectangle element */ - public static final Element createRect(Document doc, float x, float y, + public static Element createRect(Document doc, float x, float y, float width, float height) { Element border = doc.createElementNS(SVG_NS, "rect"); border.setAttributeNS(null, "x", "" + x); @@ -188,7 +192,7 @@ public class SVGUtilities { * @param doc the document to create the element * @return the new g element */ - public static final Element createG(Document doc) { + public static Element createG(Document doc) { Element border = doc.createElementNS(SVG_NS, "g"); return border; } @@ -200,7 +204,7 @@ public class SVGUtilities { * @param id the id of the clipping path * @return the new clip element */ - public static final Element createClip(Document doc, Element els, + public static Element createClip(Document doc, Element els, String id) { Element border = doc.createElementNS(SVG_NS, "clipPath"); border.setAttributeNS(null, "id", id); @@ -216,7 +220,7 @@ public class SVGUtilities { * @param height the height to set on the image * @return a new image element */ - public static final Element createImage(Document doc, String ref, + public static Element createImage(Document doc, String ref, float width, float height) { Element border = doc.createElementNS(SVG_NS, "image"); border.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "href", @@ -234,7 +238,7 @@ public class SVGUtilities { * @param width the width to wrap * @return the new element containing the wrapped text */ - public static final Element wrapText(Document doc, String str, + public static Element wrapText(Document doc, String str, java.awt.Font font, float width) { Element g = createG(doc); Element text; |