diff options
Diffstat (limited to 'src/java/org/apache/fop/render/ps')
34 files changed, 294 insertions, 295 deletions
diff --git a/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java b/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java index aa0fc88b9..b8ff8ef3f 100644 --- a/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java +++ b/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java @@ -5,9 +5,9 @@ * 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. diff --git a/src/java/org/apache/fop/render/ps/EPSTranscoder.java b/src/java/org/apache/fop/render/ps/EPSTranscoder.java index c34772196..38e700a57 100644 --- a/src/java/org/apache/fop/render/ps/EPSTranscoder.java +++ b/src/java/org/apache/fop/render/ps/EPSTranscoder.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.ps; import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D; diff --git a/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java b/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java index d5b2d2a23..e315b1433 100644 --- a/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java +++ b/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java @@ -5,9 +5,9 @@ * 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. @@ -31,7 +31,7 @@ import org.apache.xmlgraphics.ps.PSDictionary; * ImageEncoder implementation for CCITT encoded images. */ public class ImageEncoderCCITTFax implements ImageEncoder { - + private final ImageRawCCITTFax ccitt; /** @@ -66,7 +66,7 @@ public class ImageEncoderCCITTFax implements ImageEncoder { throw new IllegalStateException( "Invalid compression scheme: " + compression); } - + return dict.toString() + " /CCITTFaxDecode"; } }
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/ps/ImageEncoderJPEG.java b/src/java/org/apache/fop/render/ps/ImageEncoderJPEG.java index ef4b9f16c..9baed2a8e 100644 --- a/src/java/org/apache/fop/render/ps/ImageEncoderJPEG.java +++ b/src/java/org/apache/fop/render/ps/ImageEncoderJPEG.java @@ -5,9 +5,9 @@ * 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. diff --git a/src/java/org/apache/fop/render/ps/PSEventProducer.java b/src/java/org/apache/fop/render/ps/PSEventProducer.java index 451ed1cea..c7c621e78 100644 --- a/src/java/org/apache/fop/render/ps/PSEventProducer.java +++ b/src/java/org/apache/fop/render/ps/PSEventProducer.java @@ -31,7 +31,7 @@ public interface PSEventProducer extends EventProducer { /** Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -50,9 +50,9 @@ public interface PSEventProducer extends EventProducer { public EventModel createEventModel() { return loadModel(getClass(), "event-model.xml"); } - + } - + /** * A PostScript dictionary could not be parsed. * @param source the event source @@ -61,5 +61,5 @@ public interface PSEventProducer extends EventProducer { * @event.severity ERROR */ void postscriptDictionaryParseError(Object source, String content, Exception e); - + } diff --git a/src/java/org/apache/fop/render/ps/PSEventProducer.xml b/src/java/org/apache/fop/render/ps/PSEventProducer.xml index a0078223a..f2fe60497 100644 --- a/src/java/org/apache/fop/render/ps/PSEventProducer.xml +++ b/src/java/org/apache/fop/render/ps/PSEventProducer.xml @@ -1,4 +1,3 @@ -<?xml version="1.0" encoding="UTF-8"?> -<catalogue xml:lang="en"> +<?xml version="1.0" encoding="UTF-8"?><catalogue xml:lang="en"> <message key="org.apache.fop.render.ps.PSEventProducer.postscriptDictionaryParseError">Failed to parse dictionary string. Reason: {e}, content = "{content}"</message> </catalogue> diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java index 63b12c5c8..6bb1f294b 100644 --- a/src/java/org/apache/fop/render/ps/PSFontUtils.java +++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java @@ -55,7 +55,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { /** logging instance */ protected static Log log = LogFactory.getLog(PSFontUtils.class); - + /** * Generates the PostScript code for the font dictionary. * @param gen PostScript generator to use for output @@ -63,11 +63,11 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { * @return a Map of PSResource instances representing all defined fonts (key: font key) * @throws IOException in case of an I/O problem */ - public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo) + public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo) throws IOException { return writeFontDict(gen, fontInfo, fontInfo.getFonts()); } - + /** * Generates the PostScript code for the font dictionary. * @param gen PostScript generator to use for output @@ -76,7 +76,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { * @return a Map of PSResource instances representing all defined fonts (key: font key) * @throws IOException in case of an I/O problem */ - public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts) + public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts) throws IOException { gen.commentln("%FOPBeginFontDict"); @@ -88,7 +88,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { PSResource fontRes = new PSResource(PSResource.TYPE_FONT, tf.getFontName()); fontResources.put(key, fontRes); embedFont(gen, tf, fontRes); - + if (tf instanceof SingleByteFont) { SingleByteFont sbf = (SingleByteFont)tf; for (int i = 0, c = sbf.getAdditionalEncodingCount(); i < c; i++) { @@ -108,12 +108,12 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { private static void reencodeFonts(PSGenerator gen, Map fonts) throws IOException { ResourceTracker tracker = gen.getResourceTracker(); - + if (!tracker.isResourceSupplied(WINANSI_ENCODING_RESOURCE)) { defineWinAnsiEncoding(gen); } gen.commentln("%FOPBeginFontReencode"); - + //Rewrite font encodings Iterator iter = fonts.keySet().iterator(); while (iter.hasNext()) { @@ -133,7 +133,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { //ignore (no encoding redefinition) } else { if (tf instanceof Base14Font) { - //Our Base 14 fonts don't use the default encoding + //Our Base 14 fonts don't use the default encoding redefineFontEncoding(gen, tf.getFontName(), tf.getEncodingName()); } } @@ -149,7 +149,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { if (tf == null) { //This is to avoid an NPE if a malconfigured font is in the configuration but not //used in the document. If it were used, we wouldn't get this far. - String fallbackKey = fontInfo.getInternalFontKey(Font.DEFAULT_FONT); + String fallbackKey = fontInfo.getInternalFontKey(Font.DEFAULT_FONT); tf = (Typeface)fonts.get(fallbackKey); } return tf; @@ -162,7 +162,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { * @param fontRes the PSResource associated with the font * @throws IOException In case of an I/O error */ - public static void embedFont(PSGenerator gen, Typeface tf, PSResource fontRes) + public static void embedFont(PSGenerator gen, Typeface tf, PSResource fontRes) throws IOException { boolean embeddedFont = false; if (FontType.TYPE1 == tf.getFontType()) { @@ -171,7 +171,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { if (isEmbeddable(cf)) { InputStream in = getInputStreamOnFont(gen, cf); if (in != null) { - gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, + gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, fontRes); embedType1Font(gen, in); gen.writeDSCComment(DSCConstants.END_RESOURCE); @@ -193,8 +193,8 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { private static boolean isEmbeddable(CustomFont font) { return font.isEmbeddable(); } - - private static InputStream getInputStreamOnFont(PSGenerator gen, CustomFont font) + + private static InputStream getInputStreamOnFont(PSGenerator gen, CustomFont font) throws IOException { if (isEmbeddable(font)) { Source source = font.getEmbedFileSource(); @@ -239,7 +239,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { * @param fonts the set of fonts to work with * @return a Map of PSResource instances representing all defined fonts (key: font key) */ - public static Map determineSuppliedFonts(ResourceTracker resTracker, + public static Map determineSuppliedFonts(ResourceTracker resTracker, FontInfo fontInfo, Map fonts) { Map fontResources = new java.util.HashMap(); Iterator iter = fonts.keySet().iterator(); @@ -337,5 +337,5 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { gen.getResourceTracker().registerSuppliedResource(res); return res; } - + } diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java index 994481d59..5f204ad70 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.ps; import java.awt.Dimension; @@ -46,7 +46,7 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { public PSGraphics2DAdapter(PSRenderer renderer) { this(renderer.gen, true); } - + /** * Constructor for use without a PSRenderer instance. * @param gen the PostScript generator @@ -56,16 +56,16 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { this.gen = gen; this.clip = clip; } - + /** {@inheritDoc} */ - public void paintImage(Graphics2DImagePainter painter, + public void paintImage(Graphics2DImagePainter painter, RendererContext context, int x, int y, int width, int height) throws IOException { float fwidth = width / 1000f; float fheight = height / 1000f; float fx = x / 1000f; float fy = y / 1000f; - + // get the 'width' and 'height' attributes of the SVG document Dimension dim = painter.getImageSize(); float imw = (float)dim.getWidth() / 1000f; @@ -82,7 +82,7 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { gen.defineRect(fx, fy, fwidth, fheight); gen.writeln("clip"); } - + // transform so that the coordinates (0,0) is from the top left // and positive is down and to the right. (0,0) is where the // viewBox puts it. diff --git a/src/java/org/apache/fop/render/ps/PSImageFormResource.java b/src/java/org/apache/fop/render/ps/PSImageFormResource.java index b00e2201d..11c3205e6 100644 --- a/src/java/org/apache/fop/render/ps/PSImageFormResource.java +++ b/src/java/org/apache/fop/render/ps/PSImageFormResource.java @@ -5,9 +5,9 @@ * 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. @@ -28,7 +28,7 @@ import org.apache.xmlgraphics.ps.PSResource; public class PSImageFormResource extends PSResource { private String uri; - + /** * Create a new Form Resource. * @param id An ID for the form @@ -37,7 +37,7 @@ public class PSImageFormResource extends PSResource { public PSImageFormResource(int id, String uri) { this("FOPForm:" + Integer.toString(id), uri); } - + /** /** * Create a new Form Resource. @@ -48,7 +48,7 @@ public class PSImageFormResource extends PSResource { super(PSResource.TYPE_FORM, name); this.uri = uri; } - + /** * Returns the image URI. * @return the image URI @@ -56,5 +56,5 @@ public class PSImageFormResource extends PSResource { public String getImageURI() { return this.uri; } - + } diff --git a/src/java/org/apache/fop/render/ps/PSImageUtils.java b/src/java/org/apache/fop/render/ps/PSImageUtils.java index 27eb736d8..7a011fbec 100644 --- a/src/java/org/apache/fop/render/ps/PSImageUtils.java +++ b/src/java/org/apache/fop/render/ps/PSImageUtils.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.ps; /** diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index f84f46bf9..9f8cdc771 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -5,9 +5,9 @@ * 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. @@ -121,7 +121,7 @@ import org.apache.fop.util.CharUtilities; * <br> * This renderer inserts FOP-specific comments into the PostScript stream which * may help certain users to do certain types of post-processing of the output. - * These comments all start with "%FOP". + * These comments all start with "%FOP". * * @author <a href="mailto:fop-dev@xmlgraphics.apache.org">Apache FOP Development Team</a> * @version $Id$ @@ -150,7 +150,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer private OutputStream outputStream; /** the temporary file in case of two-pass processing */ private File tempFile; - + /** The PostScript generator used to output the PostScript */ protected PSGenerator gen; /** Determines whether the PS file is generated in two passes to minimize file size */ @@ -181,13 +181,13 @@ public class PSRenderer extends AbstractPathOrientedRenderer /** Is used to determine the document's bounding box */ private Rectangle2D documentBoundingBox; - + /** This is a collection holding all document header comments */ private Collection headerComments; /** This is a collection holding all document footer comments */ private Collection footerComments; - + /** {@inheritDoc} */ public void setUserAgent(FOUserAgent agent) { super.setUserAgent(agent); @@ -215,7 +215,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected."); } } - + private int intValueOf(Object obj) { if (obj instanceof Integer) { return ((Integer)obj).intValue(); @@ -225,11 +225,11 @@ public class PSRenderer extends AbstractPathOrientedRenderer throw new IllegalArgumentException("Integer or String with a number expected."); } } - + /** * Sets the landscape mode for this renderer. * @param value false will normally generate a "pseudo-portrait" page, true will rotate - * a "wider-than-long" page by 90 degrees. + * a "wider-than-long" page by 90 degrees. */ public void setAutoRotateLandscape(boolean value) { this.autoRotateLandscape = value; @@ -251,7 +251,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer throw new IllegalArgumentException("Only language levels 2 or 3 are allowed/supported"); } } - + /** * Return the PostScript language level that the renderer produces. * @return the language level @@ -259,12 +259,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer public int getLanguageLevel() { return this.languageLevel; } - + /** * Sets the resource optimization mode. If set to true, the renderer does two passes to * only embed the necessary resources in the PostScript file. This is slower, but produces * smaller files. - * @param value true to enable the resource optimization + * @param value true to enable the resource optimization */ public void setOptimizeResources(boolean value) { this.twoPassGeneration = value; @@ -335,7 +335,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer protected void clip() { writeln("clip newpath"); } - + /** {@inheritDoc} */ protected void clipRect(float x, float y, float width, float height) { try { @@ -350,27 +350,27 @@ public class PSRenderer extends AbstractPathOrientedRenderer protected void moveTo(float x, float y) { writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " M"); } - + /** - * Moves the current point by (x, y) relative to the current position, - * omitting any connecting line segment. + * Moves the current point by (x, y) relative to the current position, + * omitting any connecting line segment. * @param x x coordinate * @param y y coordinate */ protected void rmoveTo(float x, float y) { writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " RM"); } - + /** {@inheritDoc} */ protected void lineTo(float x, float y) { writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " lineto"); } - + /** {@inheritDoc} */ protected void closePath() { writeln("cp"); } - + /** {@inheritDoc} */ protected void fillRect(float x, float y, float width, float height) { if (width != 0 && height != 0) { @@ -400,7 +400,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer protected boolean isImageInlined(String uri) { return !isOptimizeResources() || uri == null || "".equals(uri); } - + /** * Indicates whether an image should be inlined or added as a PostScript form. * @param info the ImageInfo object of the image @@ -410,7 +410,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer if (isImageInlined(info.getOriginalURI())) { return true; } - + if (!isOptimizeResources()) { throw new IllegalStateException("Must not get here if form support is enabled"); } @@ -423,7 +423,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer info, inlineFlavors); ImageProviderPipeline inlineChoice = manager.choosePipeline(inlineCandidates); ImageFlavor inlineFlavor = (inlineChoice != null ? inlineChoice.getTargetFlavor() : null); - + //Investigate choice for form mode ImageFlavor[] formFlavors = getFormFlavors(); ImageProviderPipeline[] formCandidates @@ -431,11 +431,11 @@ public class PSRenderer extends AbstractPathOrientedRenderer info, formFlavors); ImageProviderPipeline formChoice = manager.choosePipeline(formCandidates); ImageFlavor formFlavor = (formChoice != null ? formChoice.getTargetFlavor() : null); - + //Inline if form is not supported or if a better choice is available with inline mode return formFlavor == null || !formFlavor.equals(inlineFlavor); } - + /** {@inheritDoc} */ protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) { endTextObject(); @@ -445,7 +445,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer if (log.isDebugEnabled()) { log.debug("Handling image: " + uri); } - + ImageManager manager = getUserAgent().getFactory().getImageManager(); ImageInfo info = null; try { @@ -453,7 +453,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer info = manager.getImageInfo(uri, sessionContext); int width = (int)pos.getWidth(); int height = (int)pos.getHeight(); - + //millipoints --> points for PostScript float ptx = x / 1000f; float pty = y / 1000f; @@ -468,7 +468,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer Map hints = ImageUtil.getDefaultHints(sessionContext); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, getInlineFlavors(), hints, sessionContext); - + //...and embed as inline image if (img instanceof ImageGraphics2D) { ImageGraphics2D imageG2D = (ImageGraphics2D)img; @@ -488,7 +488,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer final ImageRawStream raw = (ImageRawStream)img; if (raw instanceof ImageRawEPS) { ImageRawEPS eps = (ImageRawEPS)raw; - Rectangle2D bbox = eps.getBoundingBox(); + Rectangle2D bbox = eps.getBoundingBox(); InputStream in = raw.createInputStream(); try { PSImageUtils.renderEPS(in, uri, @@ -525,9 +525,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer log.debug("Image " + info + " is embedded as a form later"); } //Don't load image at this time, just put a form placeholder in the stream - PSResource form = getFormForImage(uri); + PSResource form = getFormForImage(uri); Rectangle2D targetRect = new Rectangle2D.Double(ptx, pty, ptw, pth); - PSImageUtils.paintForm(form, info.getSize().getDimensionPt(), targetRect, gen); + PSImageUtils.paintForm(form, info.getSize().getDimensionPt(), targetRect, gen); } } catch (ImageException ie) { @@ -586,7 +586,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer } /** {@inheritDoc} */ - public void paintImage(RenderedImage image, RendererContext context, + public void paintImage(RenderedImage image, RendererContext context, int x, int y, int width, int height) throws IOException { float fx = (float)x / 1000f; x += currentIPPosition / 1000f; @@ -606,12 +606,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer * @param endy the y end position */ private void drawLine(float startx, float starty, float endx, float endy) { - writeln(gen.formatDouble(startx) + " " - + gen.formatDouble(starty) + " M " - + gen.formatDouble(endx) + " " + writeln(gen.formatDouble(startx) + " " + + gen.formatDouble(starty) + " M " + + gen.formatDouble(endx) + " " + gen.formatDouble(endy) + " lineto stroke newpath"); } - + /** Saves the graphics state of the rendering engine. */ public void saveGraphicsState() { endTextObject(); @@ -673,7 +673,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer handleIOTrouble(ioe); } } - + private String getPostScriptNameForFontKey(String key) { int pos = key.indexOf('_'); String postFix = null; @@ -695,7 +695,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer return tf.getFontName() + postFix; } } - + /** * Returns the PSResource for the given font key. * @param key the font key ("F*") @@ -706,7 +706,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer if (this.fontResources != null) { res = (PSResource)this.fontResources.get(key); } else { - this.fontResources = new java.util.HashMap(); + this.fontResources = new java.util.HashMap(); } if (res == null) { res = new PSResource(PSResource.TYPE_FONT, getPostScriptNameForFontKey(key)); @@ -714,7 +714,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer } return res; } - + /** * Changes the currently used font. * @param key key of the font ("F*") @@ -742,15 +742,15 @@ public class PSRenderer extends AbstractPathOrientedRenderer || area.hasTrait(Trait.BORDER_AFTER) || area.hasTrait(Trait.BORDER_START) || area.hasTrait(Trait.BORDER_END)) { - comment("%FOPBeginBackgroundAndBorder: " + comment("%FOPBeginBackgroundAndBorder: " + startx + " " + starty + " " + width + " " + height); super.drawBackAndBorders(area, startx, starty, width, height); - comment("%FOPEndBackgroundAndBorder"); + comment("%FOPEndBackgroundAndBorder"); } } - + /** {@inheritDoc} */ - protected void drawBorderLine(float x1, float y1, float x2, float y2, + protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { try { float w = x2 - x1; @@ -760,7 +760,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer return; } switch (style) { - case Constants.EN_DASHED: + case Constants.EN_DASHED: useColor(col); if (horz) { float unit = Math.abs(2 * h); @@ -902,14 +902,14 @@ public class PSRenderer extends AbstractPathOrientedRenderer handleIOTrouble(ioe); } } - + /** {@inheritDoc} */ public void startRenderer(OutputStream outputStream) throws IOException { log.debug("Rendering areas to PostScript..."); this.outputStream = outputStream; - OutputStream out; + OutputStream out; if (isOptimizeResources()) { this.tempFile = File.createTempFile("fop", null); out = new java.io.FileOutputStream(this.tempFile); @@ -917,7 +917,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer } else { out = this.outputStream; } - + //Setup for PostScript generation this.gen = new PSGenerator(out) { /** Need to subclass PSGenerator to have better URI resolution */ @@ -944,7 +944,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer gen.writeDSCComment(DSCConstants.BBOX, DSCConstants.ATEND); gen.writeDSCComment(DSCConstants.HIRES_BBOX, DSCConstants.ATEND); this.documentBoundingBox = new Rectangle2D.Double(); - gen.writeDSCComment(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES, + gen.writeDSCComment(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES, new Object[] {DSCConstants.ATEND}); if (headerComments != null) { for (Iterator iter = headerComments.iterator(); iter.hasNext();) { @@ -988,7 +988,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer PSResource res = (PSResource)this.fontResources.get(key); gen.notifyResourceUsage(res); }*/ - + //Write trailer gen.writeDSCComment(DSCConstants.TRAILER); if (footerComments != null) { @@ -1016,7 +1016,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer pageDeviceDictionary.clear(); } } - + /** * Used for two-pass production. This will rewrite the PostScript file from the temporary * file while adding all needed resources. @@ -1030,7 +1030,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer in = new java.io.BufferedInputStream(in); try { try { - ResourceHandler.process(this.userAgent, in, this.outputStream, + ResourceHandler.process(this.userAgent, in, this.outputStream, this.fontInfo, resTracker, this.formResources, this.currentPageNumber, this.documentBoundingBox); this.outputStream.flush(); @@ -1100,7 +1100,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer } super.processOffDocumentItem(oDI); } - + /** * Formats and writes a List of PSSetupCode instances to the output stream. * @param setupCodeList a List of PSSetupCode instances @@ -1111,8 +1111,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer Iterator i = setupCodeList.iterator(); while (i.hasNext()) { PSSetupCode setupCode = (PSSetupCode)i.next(); - gen.commentln("%FOPBegin" + type + ": (" - + (setupCode.getName() != null ? setupCode.getName() : "") + gen.commentln("%FOPBegin" + type + ": (" + + (setupCode.getName() != null ? setupCode.getName() : "") + ")"); LineNumberReader reader = new LineNumberReader( new java.io.StringReader(setupCode.getContent())); @@ -1137,9 +1137,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer if (this.currentPageNumber == 0) { writeHeader(); } - + this.currentPageNumber++; - + gen.getResourceTracker().notifyStartNewPage(); gen.getResourceTracker().notifyResourceUsageOnPage(PSProcSets.STD_PROCSET); gen.writeDSCComment(DSCConstants.PAGE, new Object[] @@ -1159,7 +1159,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer pageSizes.add(new Long(Math.round(pageHeight))); } pageDeviceDictionary.put("/PageSize", pageSizes); - + if (page.hasExtensionAttachments()) { for (Iterator iter = page.getExtensionAttachments().iterator(); iter.hasNext();) { @@ -1245,7 +1245,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer if (safeSetPageDevice) { content += " SSPD"; } else { - content += " setpagedevice"; + content += " setpagedevice"; } writeEnclosedExtensionAttachment(new PSSetPageDevice(content)); } @@ -1256,8 +1256,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer } concatMatrix(1, 0, 0, -1, 0, pageHeight); - gen.writeDSCComment(DSCConstants.END_PAGE_SETUP); - + gen.writeDSCComment(DSCConstants.END_PAGE_SETUP); + //Process page super.renderPage(page); @@ -1287,7 +1287,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer comment("%FOPEndRegionViewport"); } } - + /** Indicates the beginning of a text object. */ protected void beginTextObject() { if (!inTextMode) { @@ -1327,16 +1327,16 @@ public class PSRenderer extends AbstractPathOrientedRenderer handleIOTrouble(ioe); } } - + beginTextObject(); - writeln("1 0 0 -1 " + gen.formatDouble(rx / 1000f) + writeln("1 0 0 -1 " + gen.formatDouble(rx / 1000f) + " " + gen.formatDouble(bl / 1000f) + " Tm"); - + super.renderText(area); //Updates IPD renderTextDecoration(tf, fontsize, area, bl, rx); } - + /** {@inheritDoc} */ protected void renderWord(WordArea word) { renderText((TextArea)word.getParentArea(), word.getWord(), word.getLetterAdjustArray()); @@ -1349,9 +1349,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer String s = space.getSpace(); char sp = s.charAt(0); Font font = getFontFromArea(textArea); - - int tws = (space.isAdjustable() - ? ((TextArea) space.getParentArea()).getTextWordSpaceAdjust() + + int tws = (space.isAdjustable() + ? ((TextArea) space.getParentArea()).getTextWordSpaceAdjust() + 2 * textArea.getTextLetterSpaceAdjust() : 0); @@ -1366,7 +1366,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer } return tf; } - + private void renderText(AbstractTextArea area, String text, int[] letterAdjust) { String fontkey = getInternalFontNameForArea(area); int fontSize = area.getTraitAsInteger(Trait.FONT_SIZE); @@ -1411,8 +1411,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer int initialSize = text.length(); initialSize += initialSize / 2; StringBuffer sb = new StringBuffer(initialSize); - if (letterAdjust == null - && area.getTextLetterSpaceAdjust() == 0 + if (letterAdjust == null + && area.getTextLetterSpaceAdjust() == 0 && area.getTextWordSpaceAdjust() == 0) { sb.append("("); for (int i = start; i < end; i++) { @@ -1437,7 +1437,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer } int cw = tf.getWidth(mapped, fontsize) / 1000; int ladj = (letterAdjust != null && i < end - 1 ? letterAdjust[i + 1] : 0); - int tls = (i < end - 1 ? area.getTextLetterSpaceAdjust() : 0); + int tls = (i < end - 1 ? area.getTextLetterSpaceAdjust() : 0); offsets[i - start] = cw + ladj + tls + wordSpace; PSGenerator.escapeChar(codepoint, sb); } @@ -1479,7 +1479,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer return null; } } - + /** {@inheritDoc} */ protected void restoreStateStackAfterBreakOut(List breakOutList) { try { @@ -1496,16 +1496,16 @@ public class PSRenderer extends AbstractPathOrientedRenderer handleIOTrouble(ioe); } } - + /** - * {@inheritDoc} + * {@inheritDoc} */ protected void startVParea(CTM ctm, Rectangle2D clippingRect) { saveGraphicsState(); if (clippingRect != null) { - clipRect((float)clippingRect.getX() / 1000f, - (float)clippingRect.getY() / 1000f, - (float)clippingRect.getWidth() / 1000f, + clipRect((float)clippingRect.getX() / 1000f, + (float)clippingRect.getY() / 1000f, + (float)clippingRect.getWidth() / 1000f, (float)clippingRect.getHeight() / 1000f); } // multiply with current CTM @@ -1528,12 +1528,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer super.renderBlockViewport(bv, children); comment("%FOPEndBlockViewport"); } - + /** {@inheritDoc} */ protected void renderInlineParent(InlineParent ip) { super.renderInlineParent(ip); } - + /** * {@inheritDoc} */ @@ -1545,7 +1545,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer int style = area.getRuleStyle(); float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f; float starty = (currentBPPosition + area.getOffset()) / 1000f; - float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + area.getIPD()) / 1000f; float ruleThickness = area.getRuleThickness() / 1000f; Color col = (Color)area.getTrait(Trait.COLOR); @@ -1555,7 +1555,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer case EN_SOLID: case EN_DASHED: case EN_DOUBLE: - drawBorderLine(startx, starty, endx, starty + ruleThickness, + drawBorderLine(startx, starty, endx, starty + ruleThickness, true, true, style, col); break; case EN_DOTTED: @@ -1563,13 +1563,13 @@ public class PSRenderer extends AbstractPathOrientedRenderer //This displaces the dots to the right by half a dot's width //TODO There's room for improvement here gen.concatMatrix(1, 0, 0, 1, ruleThickness / 2, 0); - drawBorderLine(startx, starty, endx, starty + ruleThickness, + drawBorderLine(startx, starty, endx, starty + ruleThickness, true, true, style, col); break; case EN_GROOVE: case EN_RIDGE: float half = area.getRuleThickness() / 2000f; - + gen.useColor(lightenColor(col, 0.6f)); moveTo(startx, starty); lineTo(endx, starty); @@ -1606,7 +1606,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer } /** - * {@inheritDoc} + * {@inheritDoc} */ public void renderImage(Image image, Rectangle2D pos) { drawImage(image.getURL(), pos); @@ -1615,7 +1615,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer /** * {@inheritDoc} */ - protected RendererContext createRendererContext(int x, int y, int width, int height, + protected RendererContext createRendererContext(int x, int y, int width, int height, Map foreignAttributes) { RendererContext context = super.createRendererContext( x, y, width, height, foreignAttributes); @@ -1631,7 +1631,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer /** * Formats and writes a PSExtensionAttachment to the output stream. - * + * * @param attachment an PSExtensionAttachment instance */ private void writeEnclosedExtensionAttachment(PSExtensionAttachment attachment) @@ -1661,7 +1661,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer /** * Formats and writes a Collection of PSExtensionAttachment instances to * the output stream. - * + * * @param attachmentCollection * a Collection of PSExtensionAttachment instances */ @@ -1677,15 +1677,15 @@ public class PSRenderer extends AbstractPathOrientedRenderer iter.remove(); } } - + /** * Sets whether or not the safe set page device macro should be used * (as opposed to directly invoking setpagedevice) when setting the * postscript page device. - * + * * This option is a useful option when you want to guard against the possibility - * of invalid/unsupported postscript key/values being placed in the page device. - * + * of invalid/unsupported postscript key/values being placed in the page device. + * * @param safeSetPageDevice setting to false and the renderer will make a * standard "setpagedevice" call, setting to true will make a safe set page * device macro call (default is false). @@ -1701,14 +1701,14 @@ public class PSRenderer extends AbstractPathOrientedRenderer * It can cause problems (unwanted PostScript subsystem initgraphics/erasepage calls) * on some printers when the pagedevice is set. If this causes problems on a * particular implementation then use this setting with a 'false' value to try and - * minimize the number of setpagedevice calls in the postscript document output. + * minimize the number of setpagedevice calls in the postscript document output. * <p> * Set this value to false if you experience unwanted blank pages in your * postscript output. * @param dscCompliant boolean value (default is true) */ public void setDSCCompliant(boolean dscCompliant) { - this.dscCompliant = dscCompliant; + this.dscCompliant = dscCompliant; } } diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java index 3ce9751b5..867888ea5 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java +++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java @@ -5,9 +5,9 @@ * 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. @@ -27,7 +27,7 @@ import org.apache.fop.render.Renderer; import org.apache.xmlgraphics.ps.PSGenerator; /** - * Postscript renderer config + * Postscript renderer config */ public class PSRendererConfigurator extends PrintRendererConfigurator { @@ -50,7 +50,7 @@ public class PSRendererConfigurator extends PrintRendererConfigurator { super.configure(renderer); PSRenderer psRenderer = (PSRenderer)renderer; - + psRenderer.setAutoRotateLandscape( cfg.getChild("auto-rotate-landscape").getValueAsBoolean(false)); Configuration child; diff --git a/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java b/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java index f5a5cc89f..433f2ce7c 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java +++ b/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java @@ -32,5 +32,5 @@ public interface PSRendererContextConstants extends RendererContextConstants { /** The font information for the PostScript renderer. */ public static final String PS_FONT_INFO = "psFontInfo"; - + } diff --git a/src/java/org/apache/fop/render/ps/PSRendererMaker.java b/src/java/org/apache/fop/render/ps/PSRendererMaker.java index 657a65f70..8c64f2806 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererMaker.java +++ b/src/java/org/apache/fop/render/ps/PSRendererMaker.java @@ -5,9 +5,9 @@ * 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. @@ -31,7 +31,7 @@ import org.apache.fop.render.RendererConfigurator; public class PSRendererMaker extends AbstractRendererMaker { private static final String[] MIMES = new String[] {MimeConstants.MIME_POSTSCRIPT}; - + /** {@inheritDoc} */ public Renderer makeRenderer(FOUserAgent userAgent) { return new PSRenderer(); diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java index ebe098282..1d293fa71 100644 --- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java +++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java @@ -5,9 +5,9 @@ * 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. @@ -246,7 +246,7 @@ public class PSSVGHandler extends AbstractGenericSVGHandler nativeTextHandler = new NativeTextHandler(graphics, psInfo.getFontInfo()); graphics.setCustomTextHandler(nativeTextHandler); PSTextPainter textPainter = new PSTextPainter(nativeTextHandler); - ctx.setTextPainter(textPainter); + ctx.setTextPainter(textPainter); PSTextElementBridge tBridge = new PSTextElementBridge(textPainter); ctx.putBridge(tBridge); } @@ -279,10 +279,10 @@ public class PSSVGHandler extends AbstractGenericSVGHandler * an fo:block-container */ gen.writeln("newpath"); - gen.defineRect(xOffset / 1000f, yOffset / 1000f, + gen.defineRect(xOffset / 1000f, yOffset / 1000f, psInfo.getWidth() / 1000f, psInfo.getHeight() / 1000f); gen.writeln("clip"); - + // transform so that the coordinates (0,0) is from the top left // and positive is down and to the right. (0,0) is where the // viewBox puts it. @@ -323,6 +323,6 @@ public class PSSVGHandler extends AbstractGenericSVGHandler public boolean supportsRenderer(Renderer renderer) { return (renderer instanceof PSRenderer); } - + } diff --git a/src/java/org/apache/fop/render/ps/PSSupportedFlavors.java b/src/java/org/apache/fop/render/ps/PSSupportedFlavors.java index 8ccfa8e26..b5c42c99e 100644 --- a/src/java/org/apache/fop/render/ps/PSSupportedFlavors.java +++ b/src/java/org/apache/fop/render/ps/PSSupportedFlavors.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.ps; import org.apache.xmlgraphics.image.loader.ImageFlavor; @@ -31,8 +31,8 @@ public interface PSSupportedFlavors { {ImageFlavor.RAW_EPS, ImageFlavor.RAW_CCITTFAX, ImageFlavor.GRAPHICS2D, - ImageFlavor.BUFFERED_IMAGE, - ImageFlavor.RENDERED_IMAGE, + ImageFlavor.BUFFERED_IMAGE, + ImageFlavor.RENDERED_IMAGE, ImageFlavor.XML_DOM}; /** The flavors supported inline with PostScript level 3 and higher. */ @@ -41,17 +41,17 @@ public interface PSSupportedFlavors { ImageFlavor.RAW_JPEG, ImageFlavor.RAW_CCITTFAX, ImageFlavor.GRAPHICS2D, - ImageFlavor.BUFFERED_IMAGE, - ImageFlavor.RENDERED_IMAGE, + ImageFlavor.BUFFERED_IMAGE, + ImageFlavor.RENDERED_IMAGE, ImageFlavor.XML_DOM}; - + /** The flavors supported as forms with PostScript level 2. */ ImageFlavor[] LEVEL_2_FLAVORS_FORM = new ImageFlavor[] {//ImageFlavor.RAW_EPS, ImageFlavor.RAW_CCITTFAX, ImageFlavor.GRAPHICS2D, - ImageFlavor.BUFFERED_IMAGE, - ImageFlavor.RENDERED_IMAGE/*, + ImageFlavor.BUFFERED_IMAGE, + ImageFlavor.RENDERED_IMAGE/*, ImageFlavor.XML_DOM*/}; /** The flavors supported as forms with PostScript level 3 or higher. */ @@ -60,8 +60,8 @@ public interface PSSupportedFlavors { ImageFlavor.RAW_JPEG, ImageFlavor.RAW_CCITTFAX, ImageFlavor.GRAPHICS2D, - ImageFlavor.BUFFERED_IMAGE, - ImageFlavor.RENDERED_IMAGE/*, + ImageFlavor.BUFFERED_IMAGE, + ImageFlavor.RENDERED_IMAGE/*, ImageFlavor.XML_DOM*/}; - + } diff --git a/src/java/org/apache/fop/render/ps/PSTextElementBridge.java b/src/java/org/apache/fop/render/ps/PSTextElementBridge.java index 0f41ca525..ab0c2d723 100644 --- a/src/java/org/apache/fop/render/ps/PSTextElementBridge.java +++ b/src/java/org/apache/fop/render/ps/PSTextElementBridge.java @@ -5,9 +5,9 @@ * 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. @@ -36,7 +36,7 @@ import org.w3c.dom.Node; * @version $Id$ */ public class PSTextElementBridge extends SVGTextElementBridge { - + private PSTextPainter textPainter; /** diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java index 08cea6517..31cb4b605 100644 --- a/src/java/org/apache/fop/render/ps/PSTextPainter.java +++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java @@ -5,9 +5,9 @@ * 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. @@ -70,10 +70,10 @@ import org.apache.fop.fonts.FontTriplet; * @version $Id$ */ public class PSTextPainter implements TextPainter { - + /** the logger for this class */ protected Log log = LogFactory.getLog(PSTextPainter.class); - + private NativeTextHandler nativeTextHandler; private FontInfo fontInfo; @@ -81,7 +81,7 @@ public class PSTextPainter implements TextPainter { * Use the stroking text painter to get the bounds and shape. * Also used as a fallback to draw the string with strokes. */ - protected static final TextPainter + protected static final TextPainter PROXY_PAINTER = StrokingTextPainter.getInstance(); /** @@ -102,19 +102,19 @@ public class PSTextPainter implements TextPainter { public void paint(TextNode node, Graphics2D g2d) { String txt = node.getText(); Point2D loc = node.getLocation(); - + if (hasUnsupportedAttributes(node)) { PROXY_PAINTER.paint(node, g2d); } else { paintTextRuns(node.getTextRuns(), g2d, loc); } } - - + + private boolean hasUnsupportedAttributes(TextNode node) { Iterator i = node.getTextRuns().iterator(); while (i.hasNext()) { - StrokingTextPainter.TextRun + StrokingTextPainter.TextRun run = (StrokingTextPainter.TextRun)i.next(); AttributedCharacterIterator aci = run.getACI(); boolean hasUnsupported = hasUnsupportedAttributes(aci); @@ -127,17 +127,17 @@ public class PSTextPainter implements TextPainter { private boolean hasUnsupportedAttributes(AttributedCharacterIterator aci) { boolean hasunsupported = false; - + String text = getText(aci); Font font = makeFont(aci); if (hasUnsupportedGlyphs(text, font)) { log.trace("-> Unsupported glyphs found"); hasunsupported = true; } - + TextPaintInfo tpi = (TextPaintInfo) aci.getAttribute( GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO); - if ((tpi != null) + if ((tpi != null) && ((tpi.strokeStroke != null && tpi.strokePaint != null) || (tpi.strikethroughStroke != null) || (tpi.underlineStroke != null) @@ -169,7 +169,7 @@ public class PSTextPainter implements TextPainter { log.trace("-> word spacing found"); hasunsupported = true; } - + Object lengthAdjust = aci.getAttribute( GVTAttributedCharacterIterator.TextAttribute.LENGTH_ADJUST); if (lengthAdjust != null) { @@ -179,7 +179,7 @@ public class PSTextPainter implements TextPainter { Object writeMod = aci.getAttribute( GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE); - if (writeMod != null + if (writeMod != null && !GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE_LTR.equals( writeMod)) { log.trace("-> Unsupported writing modes found"); @@ -193,7 +193,7 @@ public class PSTextPainter implements TextPainter { log.trace("-> vertical orientation found"); hasunsupported = true; } - + Object rcDel = aci.getAttribute( GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER); //Batik 1.6 returns null here which makes it impossible to determine whether this can @@ -202,7 +202,7 @@ public class PSTextPainter implements TextPainter { log.trace("-> spans found"); hasunsupported = true; //Filter spans } - + if (hasunsupported) { log.trace("Unsupported attributes found in ACI, using StrokingTextPainter"); } @@ -219,7 +219,7 @@ public class PSTextPainter implements TextPainter { Point2D currentloc = loc; Iterator i = textRuns.iterator(); while (i.hasNext()) { - StrokingTextPainter.TextRun + StrokingTextPainter.TextRun run = (StrokingTextPainter.TextRun)i.next(); currentloc = paintTextRun(run, g2d, currentloc); } @@ -251,7 +251,7 @@ public class PSTextPainter implements TextPainter { } /** - * Paint an ACI on a Graphics2D at a given location. The method has to + * Paint an ACI on a Graphics2D at a given location. The method has to * update the location after painting. * @param aci ACI to paint * @param g2d Graphics2D to paint on @@ -260,18 +260,18 @@ public class PSTextPainter implements TextPainter { */ protected Point2D paintACI(AttributedCharacterIterator aci, Graphics2D g2d, Point2D loc) { //ACIUtils.dumpAttrs(aci); - + aci.first(); updateLocationFromACI(aci, loc); TextPaintInfo tpi = (TextPaintInfo) aci.getAttribute( GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO); - + if (tpi == null) { return loc; } - + TextNode.Anchor anchor = (TextNode.Anchor)aci.getAttribute( GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE); @@ -315,7 +315,7 @@ public class PSTextPainter implements TextPainter { default: //nop } } - + drawPrimitiveString(g2d, loc, font, txt, tx); loc.setLocation(loc.getX() + (double)advance, loc.getY()); return loc; @@ -354,25 +354,25 @@ public class PSTextPainter implements TextPainter { } if (ypos != null) { loc.setLocation(loc.getX(), ypos.doubleValue()); - } + } if (dxpos != null) { loc.setLocation(loc.getX() + dxpos.doubleValue(), loc.getY()); - } + } if (dypos != null) { loc.setLocation(loc.getX(), loc.getY() + dypos.doubleValue()); - } + } } private String getStyle(AttributedCharacterIterator aci) { Float posture = (Float)aci.getAttribute(TextAttribute.POSTURE); return ((posture != null) && (posture.floatValue() > 0.0)) - ? "italic" + ? "italic" : "normal"; } private int getWeight(AttributedCharacterIterator aci) { Float taWeight = (Float)aci.getAttribute(TextAttribute.WEIGHT); - return ((taWeight != null) && (taWeight.floatValue() > 1.0)) + return ((taWeight != null) && (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL; } @@ -479,8 +479,8 @@ public class PSTextPainter implements TextPainter { * @return the bounds of the text */ public Rectangle2D getBounds2D(TextNode node) { - /* (todo) getBounds2D() is too slow - * because it uses the StrokingTextPainter. We should implement this + /* (todo) getBounds2D() is too slow + * because it uses the StrokingTextPainter. We should implement this * method ourselves. */ return PROXY_PAINTER.getBounds2D(node); } diff --git a/src/java/org/apache/fop/render/ps/PSTranscoder.java b/src/java/org/apache/fop/render/ps/PSTranscoder.java index fd252b447..3585ab2f8 100644 --- a/src/java/org/apache/fop/render/ps/PSTranscoder.java +++ b/src/java/org/apache/fop/render/ps/PSTranscoder.java @@ -5,9 +5,9 @@ * 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. diff --git a/src/java/org/apache/fop/render/ps/ResourceHandler.java b/src/java/org/apache/fop/render/ps/ResourceHandler.java index 1a363c90e..bdd305164 100644 --- a/src/java/org/apache/fop/render/ps/ResourceHandler.java +++ b/src/java/org/apache/fop/render/ps/ResourceHandler.java @@ -5,9 +5,9 @@ * 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. @@ -94,18 +94,18 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { * @throws DSCException If there's an error in the DSC structure of the PS file * @throws IOException In case of an I/O error */ - public static void process(FOUserAgent userAgent, InputStream in, OutputStream out, + public static void process(FOUserAgent userAgent, InputStream in, OutputStream out, FontInfo fontInfo, ResourceTracker resTracker, Map formResources, int pageCount, Rectangle2D documentBoundingBox) throws DSCException, IOException { DSCParser parser = new DSCParser(in); PSGenerator gen = new PSGenerator(out); parser.setNestedDocumentHandler(new DefaultNestedDocumentHandler(gen)); - + //Skip DSC header DSCHeaderComment header = DSCTools.checkAndSkipDSC30Header(parser); header.generate(gen); - + parser.setFilter(new DSCFilter() { private final Set filtered = new java.util.HashSet(); { @@ -141,15 +141,15 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { PSFontUtils.determineSuppliedFonts(resTracker, fontInfo, fontInfo.getUsedFonts()); registerSuppliedForms(resTracker, formResources); - + //Supplied Resources - DSCCommentDocumentSuppliedResources supplied + DSCCommentDocumentSuppliedResources supplied = new DSCCommentDocumentSuppliedResources( resTracker.getDocumentSuppliedResources()); supplied.generate(gen); - + //Needed Resources - DSCCommentDocumentNeededResources needed + DSCCommentDocumentNeededResources needed = new DSCCommentDocumentNeededResources( resTracker.getDocumentNeededResources()); needed.generate(gen); @@ -167,7 +167,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { } event.generate(gen); } - + //Skip to the FOPFontSetup PostScriptComment fontSetupPlaceholder = parser.nextPSComment("FOPFontSetup", gen); if (fontSetupPlaceholder == null) { @@ -181,7 +181,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { if (pageOrTrailer == null) { throw new DSCException("Page expected, but none found"); } - + //Process individual pages (and skip as necessary) while (true) { DSCCommentPage page = (DSCCommentPage)pageOrTrailer; @@ -194,7 +194,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { break; } } - + //Write the rest while (parser.hasNext()) { DSCEvent event = parser.nextEvent(); @@ -218,7 +218,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { } } - private static void generateForms(ResourceTracker resTracker, FOUserAgent userAgent, + private static void generateForms(ResourceTracker resTracker, FOUserAgent userAgent, Map formResources, PSGenerator gen) throws IOException { if (formResources == null) { return; @@ -227,13 +227,13 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { while (iter.hasNext()) { PSImageFormResource form = (PSImageFormResource)iter.next(); final String uri = form.getImageURI(); - + ImageManager manager = userAgent.getFactory().getImageManager(); ImageInfo info = null; try { ImageSessionContext sessionContext = userAgent.getImageSessionContext(); info = manager.getImageInfo(uri, sessionContext); - + ImageFlavor[] flavors; if (gen.getPSLevel() >= 3) { flavors = LEVEL_3_FLAVORS_FORM; @@ -243,7 +243,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { Map hints = ImageUtil.getDefaultHints(sessionContext); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, flavors, hints, sessionContext); - + String imageDescription = info.getMimeType() + " " + info.getOriginalURI(); final Dimension2D dimensionsPt = info.getSize().getDimensionPt(); final Dimension2D dimensionsMpt = info.getSize().getDimensionMpt(); @@ -261,12 +261,12 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { PSGraphics2DAdapter adapter = new PSGraphics2DAdapter(gen, false); adapter.paintImage(imageG2D.getGraphics2DImagePainter(), null, - 0, 0, + 0, 0, (int)Math.round(dimensionsMpt.getWidth()), (int)Math.round(dimensionsMpt.getHeight())); gen.writeln("EndEPSF"); } - + }; formGen.generate(gen); } else if (img instanceof ImageRendered) { @@ -349,9 +349,9 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { gen.writeln("1 0 lineto"); gen.writeln("stroke"); } - + }; return formGen; } - + } diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java index 1eb1d9d13..a8bab26b6 100644 --- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java @@ -30,17 +30,17 @@ public abstract class AbstractPSCommentElement extends AbstractPSExtensionElemen /** * Default constructor - * + * * @param parent parent of this node * @see org.apache.fop.fo.FONode#FONode(FONode) */ public AbstractPSCommentElement(FONode parent) { super(parent); - } - + } + /** * @throws FOPException if there's a problem during processing - * @see org.apache.fop.fo.FONode#startOfNode() + * @see org.apache.fop.fo.FONode#startOfNode() */ protected void startOfNode() throws FOPException { if (parent.getNameId() != Constants.FO_DECLARATIONS diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java index 31e44d2d2..14865a8c9 100644 --- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.ps.extensions; // FOP @@ -37,10 +37,10 @@ public abstract class AbstractPSExtensionElement extends FONode { * extension attachment */ protected PSExtensionAttachment attachment; - + /** * Default constructor - * + * * @param parent parent of this node * @see org.apache.fop.fo.FONode#FONode(FONode) */ @@ -50,14 +50,14 @@ public abstract class AbstractPSExtensionElement extends FONode { /** * Blocks XSL FO's from having non-FO parents. - * + * * @param loc location in the FO source file * @param nsURI namespace of incoming node * @param localName (e.g. "table" for "fo:table") * @throws ValidationException if incoming node not valid for parent * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) */ - protected void validateChildNode(Locator loc, String nsURI, String localName) + protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { if (FO_URI.equals(nsURI)) { invalidChildError(loc, nsURI, localName); @@ -69,7 +69,7 @@ public abstract class AbstractPSExtensionElement extends FONode { * @param data array of characters containing text to be added * @param start starting array element to add * @param length of data array to add - * @param pList currently applicable PropertyList + * @param pList currently applicable PropertyList * @param locator location in fo source file. * @see org.apache.fop.fo.FONode#addCharacters(char[], int, int, PropertyList, Locator) */ @@ -92,7 +92,7 @@ public abstract class AbstractPSExtensionElement extends FONode { public String getNamespaceURI() { return PSExtensionElementMapping.NAMESPACE; } - + /** * @return a String representation of this object * @see org.apache.fop.fo.FONode#getNormalNamespacePrefix() @@ -112,7 +112,7 @@ public abstract class AbstractPSExtensionElement extends FONode { missingChildElementError("#PCDATA"); } } - + /** * @return the extension attachment if one is created by the extension element, null otherwise. * @see org.apache.fop.fo.FONode#getExtensionAttachment() @@ -123,7 +123,7 @@ public abstract class AbstractPSExtensionElement extends FONode { } return this.attachment; } - + /** * Instantiates extension attachment object * @return extension attachment diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java index 78b2f91eb..92108b551 100644 --- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java +++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.ps.extensions; // FOP @@ -35,7 +35,7 @@ import org.apache.fop.fo.extensions.ExtensionAttachment; public abstract class AbstractPSExtensionObject extends FONode { private PSSetupCode setupCode = new PSSetupCode(); - + /** * Main constructor. * @param parent the parent node @@ -46,7 +46,7 @@ public abstract class AbstractPSExtensionObject extends FONode { } /** {@inheritDoc} */ - protected void validateChildNode(Locator loc, String nsURI, String localName) + protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { if (FO_URI.equals(nsURI)) { invalidChildError(loc, nsURI, localName); @@ -69,14 +69,14 @@ public abstract class AbstractPSExtensionObject extends FONode { public String getNamespaceURI() { return PSExtensionElementMapping.NAMESPACE; } - + /**{@inheritDoc} */ public String getNormalNamespacePrefix() { return "ps"; } /** {@inheritDoc} */ - public void processNode(String elementName, Locator locator, + public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList propertyList) throws FOPException { String name = attlist.getValue("name"); @@ -88,12 +88,12 @@ public abstract class AbstractPSExtensionObject extends FONode { /** {@inheritDoc} */ protected void endOfNode() throws FOPException { super.endOfNode(); - String s = setupCode.getContent(); + String s = setupCode.getContent(); if (s == null || s.length() == 0) { missingChildElementError("#PCDATA"); } } - + /** {@inheritDoc} */ public ExtensionAttachment getExtensionAttachment() { return this.setupCode; diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java index 1dd0f4be6..c47649eb1 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java @@ -5,9 +5,9 @@ * 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. @@ -39,7 +39,7 @@ public class PSCommentAfterElement extends AbstractPSCommentElement { } /** - * @return local name + * @return local name * @see org.apache.fop.fo.FONode#getLocalName() */ public String getLocalName() { diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java index 5d3c863f5..f441553b7 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java @@ -5,9 +5,9 @@ * 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. @@ -51,5 +51,5 @@ public class PSCommentBeforeElement extends AbstractPSCommentElement { */ protected ExtensionAttachment instantiateExtensionAttachment() { return new PSCommentBefore(); - } + } } diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java index 9da2b0911..efee86aa8 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java @@ -31,7 +31,7 @@ import org.apache.fop.fo.extensions.ExtensionAttachment; * This is the pass-through value object for the PostScript extension. */ public abstract class PSExtensionAttachment implements ExtensionAttachment, XMLizable { - + /** extension node content */ protected String content; @@ -59,12 +59,12 @@ public abstract class PSExtensionAttachment implements ExtensionAttachment, XMLi public String getCategory() { return CATEGORY; } - + /** @return the content */ public String getContent() { return content; } - + /** * Sets the content for the setup code object. * @param content The content to set. @@ -72,10 +72,10 @@ public abstract class PSExtensionAttachment implements ExtensionAttachment, XMLi public void setContent(String content) { this.content = content; } - + /** * Generates SAX events representing the object's state. - * + * * @param handler ContentHandler instance to send the SAX events to * @throws SAXException if there's a problem generating the SAX events * @see org.apache.xmlgraphics.util.XMLizable#toSAX(org.xml.sax.ContentHandler) @@ -96,7 +96,7 @@ public abstract class PSExtensionAttachment implements ExtensionAttachment, XMLi String className = getClass().getName(); return className.substring(className.lastIndexOf('.') + 3); } - + /** * @return a string representation of this object * @see java.lang.Object#toString() diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java index 45ace5f80..d1a1ede37 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.ps.extensions; import org.apache.fop.fo.FONode; @@ -28,7 +28,7 @@ import org.apache.fop.fo.ElementMapping; public class PSExtensionElementMapping extends ElementMapping { /** Namespace for the extension */ - public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/postscript"; + public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/postscript"; /** Main constructor */ public PSExtensionElementMapping() { @@ -64,7 +64,7 @@ public class PSExtensionElementMapping extends ElementMapping { return new PSSetPageDeviceElement(parent); } } - + static class PSCommentBeforeMaker extends ElementMapping.Maker { public FONode make(FONode parent) { return new PSCommentBeforeElement(parent); diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java index e69500736..dee918f19 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java @@ -32,7 +32,7 @@ import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener; /** * ContentHandler (parser) for restoring PSExtension objects from XML. */ -public class PSExtensionHandler extends DefaultHandler +public class PSExtensionHandler extends DefaultHandler implements ContentHandlerFactory.ObjectSource { /** Logger instance */ @@ -40,12 +40,12 @@ public class PSExtensionHandler extends DefaultHandler private StringBuffer content = new StringBuffer(); private Attributes lastAttributes; - + private PSExtensionAttachment returnedObject; private ObjectBuiltListener listener; - + /** {@inheritDoc} */ - public void startElement(String uri, String localName, String qName, Attributes attributes) + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { boolean handled = false; if (PSExtensionAttachment.CATEGORY.equals(uri)) { @@ -61,10 +61,10 @@ public class PSExtensionHandler extends DefaultHandler } if (!handled) { if (PSExtensionAttachment.CATEGORY.equals(uri)) { - throw new SAXException("Unhandled element " + localName + throw new SAXException("Unhandled element " + localName + " in namespace: " + uri); } else { - log.warn("Unhandled element " + localName + log.warn("Unhandled element " + localName + " in namespace: " + uri); } } @@ -78,13 +78,13 @@ public class PSExtensionHandler extends DefaultHandler this.returnedObject = new PSSetupCode(name, content.toString()); } else if (PSSetPageDevice.ELEMENT.equals(localName)) { String name = lastAttributes.getValue("name"); - this.returnedObject = new PSSetPageDevice(name, content.toString()); + this.returnedObject = new PSSetPageDevice(name, content.toString()); } else if (PSCommentBefore.ELEMENT.equals(localName)) { - this.returnedObject = new PSCommentBefore(content.toString()); + this.returnedObject = new PSCommentBefore(content.toString()); } else if (PSCommentAfter.ELEMENT.equals(localName)) { this.returnedObject = new PSCommentAfter(content.toString()); } - } + } content.setLength(0); //Reset text buffer (see characters()) } diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandlerFactory.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandlerFactory.java index 655c96260..d94e236f7 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandlerFactory.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandlerFactory.java @@ -28,7 +28,7 @@ import org.xml.sax.ContentHandler; public class PSExtensionHandlerFactory implements ContentHandlerFactory { private static final String[] NAMESPACES = new String[] {PSSetupCode.CATEGORY}; - + /** {@inheritDoc} */ public String[] getSupportedNamespaces() { return NAMESPACES; diff --git a/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java index 207c11e76..686667c3d 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java @@ -24,13 +24,13 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; /** - * Extension element for fox:ps-page-setup-code. + * Extension element for fox:ps-page-setup-code. */ public class PSPageSetupCodeElement extends AbstractPSExtensionObject { /** The element name */ protected static final String ELEMENT = "ps-page-setup-code"; - + /** * Main constructor * @param parent parent FO node @@ -47,7 +47,7 @@ public class PSPageSetupCodeElement extends AbstractPSExtensionObject { "rule.childOfSPM"); } } - + /** {@inheritDoc} */ public String getLocalName() { return ELEMENT; diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java index 28ea3c24c..8bdb2adc0 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java @@ -62,12 +62,12 @@ public class PSSetPageDevice extends PSExtensionAttachment { */ public PSSetPageDevice() { } - + /** @return the name */ public String getName() { return name; } - + /** * Sets the name of the setup code object. * @param name The name to set. @@ -77,7 +77,7 @@ public class PSSetPageDevice extends PSExtensionAttachment { } /** - * @return a string representation of this object + * @return a string representation of this object * @see java.lang.Object#toString() */ public String toString() { diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java index 21acc8001..6cdd1c60c 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java @@ -29,7 +29,7 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.extensions.ExtensionAttachment; /** - * Extension element for ps:ps-setpagedevice. + * Extension element for ps:ps-setpagedevice. */ public class PSSetPageDeviceElement extends AbstractPSExtensionElement { @@ -69,7 +69,7 @@ public class PSSetPageDeviceElement extends AbstractPSExtensionElement { * @throws FOPException if there's a problem during processing * @see org.apache.fop.fo.FONode#processNode */ - public void processNode(String elementName, Locator locator, + public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList propertyList) throws FOPException { String name = attlist.getValue("name"); @@ -79,7 +79,7 @@ public class PSSetPageDeviceElement extends AbstractPSExtensionElement { } /** - * @return local name + * @return local name * @see org.apache.fop.fo.FONode#getLocalName() */ public String getLocalName() { return ELEMENT; diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetupCode.java b/src/java/org/apache/fop/render/ps/extensions/PSSetupCode.java index eb3ed0e39..e2236629c 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetupCode.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetupCode.java @@ -31,7 +31,7 @@ public class PSSetupCode extends PSExtensionAttachment { * element name */ protected static final String ELEMENT = "ps-setup-code"; - + private static final String ATT_NAME = "name"; /** @@ -44,7 +44,7 @@ public class PSSetupCode extends PSExtensionAttachment { */ public PSSetupCode() { } - + /** * Default constructor. * @param name the name of the setup code object, may be null @@ -54,12 +54,12 @@ public class PSSetupCode extends PSExtensionAttachment { super(content); this.name = name; } - + /** @return the name */ public String getName() { return name; } - + /** * Sets the name of the setup code object. * @param name The name to set. @@ -72,7 +72,7 @@ public class PSSetupCode extends PSExtensionAttachment { public String getCategory() { return CATEGORY; } - + /** {@inheritDoc} */ public String toString() { return "PSSetupCode(name=" + getName() + ", content='" + getContent() + "')"; @@ -85,7 +85,7 @@ public class PSSetupCode extends PSExtensionAttachment { protected String getElement() { return ELEMENT; } - + /** {@inheritDoc} */ public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java index e76dfeb64..4ac0af2b7 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java @@ -24,13 +24,13 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; /** - * Extension element for fox:ps-setup-code. + * Extension element for fox:ps-setup-code. */ public class PSSetupCodeElement extends AbstractPSExtensionObject { /** The element name */ protected static final String ELEMENT = "ps-setup-code"; - + /** * Main constructor * @param parent parent FO node @@ -38,7 +38,7 @@ public class PSSetupCodeElement extends AbstractPSExtensionObject { public PSSetupCodeElement(FONode parent) { super(parent); } - + /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); @@ -47,10 +47,10 @@ public class PSSetupCodeElement extends AbstractPSExtensionObject { "rule.childOfDeclarations"); } } - + /** {@inheritDoc} */ public String getLocalName() { return ELEMENT; } - + } |