From e38b48159c287f75733fbf165806f49a396ba196 Mon Sep 17 00:00:00 2001 From: Manuel Mall Date: Fri, 28 Apr 2006 11:58:33 +0000 Subject: [PATCH] Some cleanup of the AFP Renderer code (tab char removal and a few other things). Changed AFP extension namespace to http://xmlgraphics.apache.org/fop/extensions/afp. Added another missing file. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@397875 13f79535-47bb-0310-9956-ffa450edef68 --- .../services/org.apache.fop.fo.ElementMapping | 1 + .../apache/fop/render/afp/AFPRenderer.java | 19 +-- .../exceptions/NestedRuntimeException.java | 155 +++++++++--------- .../exceptions/RendererRuntimeException.java | 38 ++--- .../render/afp/extensions/AFPAttribute.java | 1 + .../afp/extensions/AFPElementMapping.java | 2 +- .../render/afp/extensions/AFPPageSetup.java | 2 +- .../apache/fop/render/afp/fonts/AFPFont.java | 1 + .../afp/fonts/CharacterSetOrientation.java | 6 +- .../fop/render/afp/fonts/FopCharacterSet.java | 3 +- .../fop/render/afp/fonts/OutlineFont.java | 4 +- .../fop/render/afp/modca/IMImageObject.java | 2 +- .../fop/render/afp/modca/ImageObject.java | 2 +- .../render/afp/modca/ImageRasterPattern.java | 2 +- .../fop/render/afp/modca/ImageSegment.java | 2 +- .../fop/render/afp/modca/PageObject.java | 2 +- .../afp/modca/PresentationTextData.java | 24 +-- .../render/afp/tools/DTDEntityResolver.java | 11 +- .../afp/tools/StructuredFieldReader.java | 4 +- 19 files changed, 144 insertions(+), 137 deletions(-) create mode 100644 src/sandbox/META-INF/services/org.apache.fop.fo.ElementMapping diff --git a/src/sandbox/META-INF/services/org.apache.fop.fo.ElementMapping b/src/sandbox/META-INF/services/org.apache.fop.fo.ElementMapping new file mode 100644 index 000000000..d38bb6677 --- /dev/null +++ b/src/sandbox/META-INF/services/org.apache.fop.fo.ElementMapping @@ -0,0 +1 @@ +org.apache.fop.render.afp.extensions.AFPElementMapping \ No newline at end of file diff --git a/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java b/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java index e4505d050..9cee8d121 100644 --- a/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java @@ -1157,9 +1157,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } convertToGrayScaleImage(io, fopimage.getBitmaps()); } - } - else - { + } else { if (!fopimage.load(FopImage.BITMAP)) { return; } @@ -1276,7 +1274,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { // Create an AFPFontAttributes object from the current font details AFPFontAttributes afpFontAttributes = - new AFPFontAttributes(name, tf,_currentFontSize); + new AFPFontAttributes(name, tf, _currentFontSize); if (!_currentPageFonts.containsKey(afpFontAttributes.getFontKey())) { // Font not found on current page, so add the new one @@ -1547,7 +1545,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { || rotation == 270) { _portraitRotation = rotation; } else { - throw new IllegalArgumentException("The portrait rotation must be one of the values 0, 90, 180, 270"); + throw new IllegalArgumentException("The portrait rotation must be one" + + " of the values 0, 90, 180, 270"); } @@ -1568,8 +1567,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { || rotation == 270) { _landscapeRotation = rotation; } else { - throw new IllegalArgumentException("The landscape rotation must be one of the values 0, 90, 180, 270"); - + throw new IllegalArgumentException("The landscape rotation must be one" + + " of the values 0, 90, 180, 270"); } } @@ -1692,21 +1691,21 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } ViewPortPos(Rectangle2D view, CTM ctm) { - ViewPortPos currentVP = (ViewPortPos)viewPortPositions.get(viewPortPositions.size()-1); + ViewPortPos currentVP = (ViewPortPos)viewPortPositions.get(viewPortPositions.size() - 1); int xOrigin; int yOrigin; int width; int height; switch (currentVP.rot) { case 90: - width = mpts2units(view.getHeight());; + width = mpts2units(view.getHeight()); height = mpts2units(view.getWidth()); xOrigin = _pageWidth - width - mpts2units(view.getY()) - currentVP.y; yOrigin = mpts2units(view.getX()) + currentVP.x; break; case 180: width = mpts2units(view.getWidth()); - height = mpts2units(view.getHeight());; + height = mpts2units(view.getHeight()); xOrigin = _pageWidth - width - mpts2units(view.getX()) - currentVP.x; yOrigin = _pageHeight - height - mpts2units(view.getY()) - currentVP.y; break; diff --git a/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java b/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java index 92254e6e6..3e8c1d947 100644 --- a/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java +++ b/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java @@ -15,6 +15,7 @@ */ /* $Id$ */ + package org.apache.fop.render.afp.exceptions; import java.io.PrintStream; @@ -28,81 +29,81 @@ import java.io.PrintWriter; * */ public abstract class NestedRuntimeException extends RuntimeException { - - /** Root cause of this nested exception */ - private Throwable _underlyingException; - - /** - * Construct a NestedRuntimeException with the specified detail message. - * @param msg The detail message. - */ - public NestedRuntimeException(String msg) { - super(msg); - } - - /** - * Construct a NestedRuntimeException with the specified - * detail message and nested exception. - * @param msg The detail message. - * @param t The nested exception. - */ - public NestedRuntimeException(String msg, Throwable t) { - super(msg); - _underlyingException = t; - - } - - /** - * Gets the original triggering exception - * @return The original exception as a throwable. - */ - public Throwable getUnderlyingException() { - - return _underlyingException; - - } - - /** - * Return the detail message, including the message from the nested - * exception if there is one. - * @return The detail message. - */ - public String getMessage() { - - if (_underlyingException == null) { - return super.getMessage(); - } else { - return super.getMessage() - + "; nested exception is " - + _underlyingException.getClass().getName(); - } - - } - - /** - * Print the composite message and the embedded stack trace to the specified stream. - * @param ps the print stream - */ - public void printStackTrace(PrintStream ps) { - if (_underlyingException == null) { - super.printStackTrace(ps); - } else { - ps.println(this); - _underlyingException.printStackTrace(ps); - } - } - - /** - * Print the composite message and the embedded stack trace to the specified writer. - * @param pw the print writer - */ - public void printStackTrace(PrintWriter pw) { - if (_underlyingException == null) { - super.printStackTrace(pw); - } else { - pw.println(this); - _underlyingException.printStackTrace(pw); - } - } - + + /** Root cause of this nested exception */ + private Throwable _underlyingException; + + /** + * Construct a NestedRuntimeException with the specified detail message. + * @param msg The detail message. + */ + public NestedRuntimeException(String msg) { + super(msg); + } + + /** + * Construct a NestedRuntimeException with the specified + * detail message and nested exception. + * @param msg The detail message. + * @param t The nested exception. + */ + public NestedRuntimeException(String msg, Throwable t) { + super(msg); + _underlyingException = t; + + } + + /** + * Gets the original triggering exception + * @return The original exception as a throwable. + */ + public Throwable getUnderlyingException() { + + return _underlyingException; + + } + + /** + * Return the detail message, including the message from the nested + * exception if there is one. + * @return The detail message. + */ + public String getMessage() { + + if (_underlyingException == null) { + return super.getMessage(); + } else { + return super.getMessage() + + "; nested exception is " + + _underlyingException.getClass().getName(); + } + + } + + /** + * Print the composite message and the embedded stack trace to the specified stream. + * @param ps the print stream + */ + public void printStackTrace(PrintStream ps) { + if (_underlyingException == null) { + super.printStackTrace(ps); + } else { + ps.println(this); + _underlyingException.printStackTrace(ps); + } + } + + /** + * Print the composite message and the embedded stack trace to the specified writer. + * @param pw the print writer + */ + public void printStackTrace(PrintWriter pw) { + if (_underlyingException == null) { + super.printStackTrace(pw); + } else { + pw.println(this); + _underlyingException.printStackTrace(pw); + } + } + } diff --git a/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java b/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java index a3be63ecb..d04247196 100644 --- a/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java +++ b/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java @@ -23,23 +23,23 @@ package org.apache.fop.render.afp.exceptions; *

*/ public class RendererRuntimeException extends NestedRuntimeException { - - /** - * Constructs a RendererRuntimeException with the specified message. - * @param msg the exception mesaage - */ - public RendererRuntimeException(String msg) { - super(msg); - } - - /** - * Constructs a RendererRuntimeException with the specified message - * wrapping the underlying exception. - * @param msg the exception mesaage - * @param t the underlying exception - */ - public RendererRuntimeException(String msg, Throwable t) { - super(msg, t); - } - + + /** + * Constructs a RendererRuntimeException with the specified message. + * @param msg the exception mesaage + */ + public RendererRuntimeException(String msg) { + super(msg); + } + + /** + * Constructs a RendererRuntimeException with the specified message + * wrapping the underlying exception. + * @param msg the exception mesaage + * @param t the underlying exception + */ + public RendererRuntimeException(String msg, Throwable t) { + super(msg, t); + } + } diff --git a/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java b/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java index a1c63856b..421408902 100755 --- a/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java +++ b/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java @@ -48,6 +48,7 @@ public class AFPAttribute extends StringProperty.Maker { /** * Overide the make method to return the property object + * @param propertyList the property list from which to make the property * @return property The property object. */ public Property make(PropertyList propertyList) { diff --git a/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java b/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java index 350b75c1e..53421021e 100755 --- a/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java +++ b/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java @@ -47,7 +47,7 @@ public class AFPElementMapping extends ElementMapping { /** * The namespace used for AFP extensions */ - public static final String NAMESPACE = "http://org.apache.fop/extensions/afp"; + public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/extensions/afp"; /** * The usual namespace prefix used for AFP extensions diff --git a/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java b/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java index d95a3a458..a3984d2be 100644 --- a/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java +++ b/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java @@ -71,7 +71,7 @@ public class AFPPageSetup implements ExtensionAttachment, Serializable { /** * Sets the value - * @param value The value name to set. + * @param source The value name to set. */ public void setValue(String source) { this.value = source; diff --git a/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java b/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java index d17536a8d..b7f27d65e 100644 --- a/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java +++ b/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java @@ -76,6 +76,7 @@ public abstract class AFPFont extends Typeface { /** * Returns the character set for a given size * @param size the font size + * @return the character set object */ public abstract CharacterSet getCharacterSet(int size); diff --git a/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java b/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java index 68eb2e413..084edfb5e 100644 --- a/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java +++ b/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java @@ -178,7 +178,7 @@ public class CharacterSetOrientation { /** * XHeight refers to the height of the lower case letters above * the baseline. - * @return heightX the typical height of characters + * @return heightX the typical height of characters */ public int getXHeight() { return _xHeight; @@ -224,7 +224,7 @@ public class CharacterSetOrientation { * Descender depth is the distance from the character baseline to * the bottom of a character box. A negative descender depth signifies * that all of the graphic character is above the character baseline. - * @param descender the descender value in millipoints + * @param descender the descender value in millipoints */ public void setDescender(int descender) { _descender = descender; @@ -250,7 +250,7 @@ public class CharacterSetOrientation { * Set the width (in 1/1000ths of a point size) of the character * identified by the parameter passed. * @param character the character for which the width is being set - * @param width the widths of the character + * @param width the widths of the character */ public void setWidth(int character, int width) { diff --git a/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java b/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java index 635cef025..ff8f9240e 100644 --- a/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java +++ b/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java @@ -15,6 +15,7 @@ */ /* $Id$ */ + package org.apache.fop.render.afp.fonts; import org.apache.fop.fonts.Typeface; @@ -35,7 +36,7 @@ public class FopCharacterSet extends CharacterSet { * @param encoding the encoding of the font * @param name the character set name * @param size the font size - * @param Typeface the fop character set + * @param characterSet the fop character set */ public FopCharacterSet( String codePage, diff --git a/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java b/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java index 00757f4ba..eabd3f631 100644 --- a/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java +++ b/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java @@ -15,8 +15,8 @@ */ /* $Id$ */ -package org.apache.fop.render.afp.fonts; +package org.apache.fop.render.afp.fonts; /** * A font defined as a set of lines and curves as opposed to a bitmap font. An @@ -154,7 +154,7 @@ public class OutlineFont extends AFPFont { public int[] getWidths(int size) { int[] widths = _characterSet.getWidths(); - for (int i = 0 ; i < widths.length; i++) { + for (int i = 0; i < widths.length; i++) { widths[i] = widths[i] / 1000 * size; } return widths; diff --git a/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java b/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java index aa510da6b..9a6e195d1 100644 --- a/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java +++ b/src/sandbox/org/apache/fop/render/afp/modca/IMImageObject.java @@ -59,7 +59,7 @@ public class IMImageObject extends AbstractNamedAFPObject { /** * Constructor for the image object with the specified name, * the name must be a fixed length of eight characters. - * @param name The name of the image. + * @param name The name of the image. */ public IMImageObject(String name) { diff --git a/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java b/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java index 8e4e4c386..fc027b8af 100644 --- a/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java +++ b/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java @@ -42,7 +42,7 @@ public class ImageObject extends AbstractNamedAFPObject { /** * Constructor for the image object with the specified name, * the name must be a fixed length of eight characters. - * @param name The name of the image. + * @param name The name of the image. */ public ImageObject(String name) { diff --git a/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java b/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java index c49f392b5..673f04cad 100644 --- a/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java +++ b/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java @@ -749,7 +749,7 @@ public class ImageRasterPattern { break; } - for(int i = 0; i < repeat; i++) { + for (int i = 0; i < repeat; i++) { System.arraycopy(greypattern, 0, rasterdata, i * 32, 32); diff --git a/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java b/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java index 0e5a2f691..9a27b79f7 100644 --- a/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java +++ b/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java @@ -65,7 +65,7 @@ public class ImageSegment extends AbstractAFPObject { /** * Constructor for the image segment with the specified name, * the name must be a fixed length of eight characters. - * @param name The name of the image. + * @param name The name of the image. */ public ImageSegment(String name) { diff --git a/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java b/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java index 9bf543eee..102d7380e 100644 --- a/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java +++ b/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java @@ -70,7 +70,7 @@ public class PageObject extends AbstractPageObject { /** * Adds an overlay to the page resources - * @param the overlay to add + * @param overlay the overlay to add */ public void addOverlay(Overlay overlay) { if (_resourceGroup == null) { diff --git a/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java b/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java index 38495c859..99b6f452d 100644 --- a/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java +++ b/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java @@ -488,18 +488,18 @@ public class PresentationTextData extends AbstractAFPObject { ByteArrayOutputStream afpdata) { afpdata.write(new byte[] { - 15 // Control sequence length - , (byte)0x81 // Control sequence function type - , 0x00 // Reserved; must be zero - , 0x01 // Color space - 0x01 = RGB - , 0x00 // Reserved; must be zero - , 0x00 // Reserved; must be zero - , 0x00 // Reserved; must be zero - , 0x00 // Reserved; must be zero - , 8 // Number of bits in component 1 - , 8 // Number of bits in component 2 - , 8 // Number of bits in component 3 - , 0 // Number of bits in component 4 + 15 // Control sequence length + , (byte)0x81 // Control sequence function type + , 0x00 // Reserved; must be zero + , 0x01 // Color space - 0x01 = RGB + , 0x00 // Reserved; must be zero + , 0x00 // Reserved; must be zero + , 0x00 // Reserved; must be zero + , 0x00 // Reserved; must be zero + , 8 // Number of bits in component 1 + , 8 // Number of bits in component 2 + , 8 // Number of bits in component 3 + , 0 // Number of bits in component 4 , (byte)(col.getRed()) // Red intensity , (byte)(col.getGreen()) // Green intensity , (byte)(col.getBlue()) // Blue intensity diff --git a/src/sandbox/org/apache/fop/render/afp/tools/DTDEntityResolver.java b/src/sandbox/org/apache/fop/render/afp/tools/DTDEntityResolver.java index 94f4c46bd..ffdab85e4 100644 --- a/src/sandbox/org/apache/fop/render/afp/tools/DTDEntityResolver.java +++ b/src/sandbox/org/apache/fop/render/afp/tools/DTDEntityResolver.java @@ -15,6 +15,7 @@ */ /* $Id$ */ + package org.apache.fop.render.afp.tools; import java.io.IOException; @@ -67,11 +68,11 @@ public class DTDEntityResolver implements EntityResolver { throws IOException { URL resource = null; - if( AFP_DTD_1_2_ID.equals(publicId) ) { + if ( AFP_DTD_1_2_ID.equals(publicId) ) { resource = getResource( AFP_DTD_1_2_RESOURCE ); - } else if( AFP_DTD_1_1_ID.equals(publicId) ) { + } else if ( AFP_DTD_1_1_ID.equals(publicId) ) { resource = getResource( AFP_DTD_1_1_RESOURCE ); - } else if( AFP_DTD_1_0_ID.equals(publicId) ) { + } else if ( AFP_DTD_1_0_ID.equals(publicId) ) { throw new FontRuntimeException( "The AFP Installed Font Definition 1.0 DTD is not longer supported" ); } else if( systemId != null && systemId.indexOf("afp-fonts.dtd") >= 0 ) { @@ -95,14 +96,14 @@ public class DTDEntityResolver implements EntityResolver { * @return the URL of the required resource * @throws FontRuntimeException if the resource could not be found. */ - private URL getResource( String resourcePath ) { + private URL getResource(String resourcePath) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = ClassLoader.getSystemClassLoader(); } URL resource = cl.getResource( resourcePath ); - if( resource == null ) { + if (resource == null) { throw new FontRuntimeException( "Resource " + resourcePath + " could not be found on the classpath" ); } diff --git a/src/sandbox/org/apache/fop/render/afp/tools/StructuredFieldReader.java b/src/sandbox/org/apache/fop/render/afp/tools/StructuredFieldReader.java index 7df320c27..4c1a52f3e 100644 --- a/src/sandbox/org/apache/fop/render/afp/tools/StructuredFieldReader.java +++ b/src/sandbox/org/apache/fop/render/afp/tools/StructuredFieldReader.java @@ -58,6 +58,7 @@ public class StructuredFieldReader { * Get the next structured field as identified by the identifer * parameter (this must be a valid MO:DCA structured field. * @param identifier the three byte identifier + * @throws IOException */ public byte[] getNext(byte[] identifier) throws IOException { @@ -109,7 +110,8 @@ public class StructuredFieldReader { length[0] = bufferData[b]; length[1] = bufferData[a]; - int reclength = ((length[0] & 0xFF) << 8) + (length[1] & 0xFF) - identifier.length -2; + int reclength = ((length[0] & 0xFF) << 8) + + (length[1] & 0xFF) - identifier.length - 2; byte[] retval = new byte[reclength]; -- 2.39.5