From 29e8badcec8bd40eca2ef4940133f08eeefdda11 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Sat, 14 Aug 2010 17:17:00 +0000 Subject: Bugzilla #49733: Resolved compilation (safe one), Checkstyle and many Javadoc warnings. Submitted by: Glenn Adams Changes to patch: - Restored the deprecated Graphics2DAdapter method (to be removed after Barcode4J 2.1 is released). - Restored Renderer.startPageSequence(LineArea) pending discussion about removal. - build.xml: set max VM to 1024MB instead of 2048MB to allow for 32-bit JVMs. - build.xml: restored longer taskdef names. - Restored Checkstyle 4 file for people running older IDEs. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@985537 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/java2d/CustomFontMetricsMapper.java | 4 +++- .../org/apache/fop/render/java2d/FontMetricsMapper.java | 2 +- .../org/apache/fop/render/java2d/Java2DBorderPainter.java | 7 ++++++- src/java/org/apache/fop/render/java2d/Java2DRenderer.java | 3 ++- src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java | 13 +++++++------ src/java/org/apache/fop/render/java2d/Java2DUtil.java | 5 ++++- 6 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src/java/org/apache/fop/render/java2d') diff --git a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java index 1d9d7d56e..6394964ac 100644 --- a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java +++ b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java @@ -16,6 +16,7 @@ */ /* $Id$ */ + package org.apache.fop.render.java2d; import java.awt.Font; @@ -29,6 +30,7 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import org.apache.fop.fonts.CustomFont; +import org.apache.fop.fonts.FontMetrics; import org.apache.fop.fonts.FontType; import org.apache.fop.fonts.LazyFont; import org.apache.fop.fonts.Typeface; @@ -36,7 +38,7 @@ import org.apache.fop.fonts.Typeface; /** * FontMetricsMapper that delegates most methods to an underlying * {@link FontMetrics} instance. This class was designed to allow - * the underlying {@link java.awt.Font} to be loaded from a + * the underlying {@link Font} to be loaded from a * user-configured file not registered in the current graphics environment. */ public class CustomFontMetricsMapper extends Typeface implements FontMetricsMapper { diff --git a/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java index 17073dd6c..806a07d6c 100644 --- a/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java +++ b/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java @@ -28,7 +28,7 @@ import org.apache.fop.fonts.FontMetrics; public interface FontMetricsMapper extends FontMetrics { /** - * Gets a {@link Font} instance of the font that this + * Gets a {@link java.awt.Font} instance of the font that this * {@link FontMetrics} describes in the desired size. * @param size font size * @return font with the desired characteristics. diff --git a/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java b/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java index c5e0a3f5c..e4576373d 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java +++ b/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java @@ -47,6 +47,10 @@ public class Java2DBorderPainter extends BorderPainter { private GeneralPath currentPath = null; + /** + * Construct a java2d border painter. + * @param painter a painter + */ public Java2DBorderPainter(Java2DPainter painter) { this.painter = painter; } @@ -60,7 +64,8 @@ public class Java2DBorderPainter extends BorderPainter { } /** {@inheritDoc} */ - protected void drawBorderLine(int x1, int y1, int x2, int y2, boolean horz, + protected void drawBorderLine // CSOK: ParameterNumber + (int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, Color color) { float w = x2 - x1; float h = y2 - y1; diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index 4cb0c988e..cbd50c954 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -536,7 +536,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** {@inheritDoc} */ - protected void drawBorderLine(float x1, float y1, float x2, float y2, + protected void drawBorderLine // CSOK: ParameterNumber + (float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { Graphics2D g2d = state.getGraph(); float width = x2 - x1; diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java index de987af25..4c20a8959 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java +++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java @@ -81,16 +81,17 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler */ public static class Java2DInfo { /** see Java2D_STATE */ - public Java2DGraphicsState state; + public Java2DGraphicsState state; // CSOK: VisibilityModifier /** see Java2D_WIDTH */ - public int width; + public int width; // CSOK: VisibilityModifier /** see Java2D_HEIGHT */ - public int height; + public int height; // CSOK: VisibilityModifier /** see Java2D_XPOS */ - public int currentXPosition; + public int currentXPosition; // CSOK: VisibilityModifier /** see Java2D_YPOS */ - public int currentYPosition; - public boolean paintAsBitmap; + public int currentYPosition; // CSOK: VisibilityModifier + /** paint as bitmap */ + public boolean paintAsBitmap; // CSOK: VisibilityModifier /** {@inheritDoc} */ public String toString() { diff --git a/src/java/org/apache/fop/render/java2d/Java2DUtil.java b/src/java/org/apache/fop/render/java2d/Java2DUtil.java index aa2be78e0..7e11ab263 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DUtil.java +++ b/src/java/org/apache/fop/render/java2d/Java2DUtil.java @@ -30,7 +30,10 @@ import org.apache.fop.fonts.FontManager; /** * Rendering-related utilities for Java2D. */ -public class Java2DUtil { +public final class Java2DUtil { + + private Java2DUtil() { + } /** * Builds a default {@link FontInfo} object for use with output formats using the Java2D -- cgit v1.2.3 From aba436311c935f145aa984c855f88bfd3a9cb1c1 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Sat, 14 Aug 2010 19:28:26 +0000 Subject: Removed many "// CSOK: ConstantName" instances for constants, by converting them to uppercase as they should really be. Fixed some other non-Checkstyle issues on the way, imports mainly. Removed some "log" instances that were not used. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@985571 13f79535-47bb-0310-9956-ffa450edef68 --- .../plan/src/org/apache/fop/plan/PlanHints.java | 18 ++--- .../plan/src/org/apache/fop/plan/PlanRenderer.java | 5 +- .../src/org/apache/fop/plan/SimplePlanDrawer.java | 8 +- src/java/org/apache/fop/afp/AFPDataObjectInfo.java | 5 -- src/java/org/apache/fop/afp/AFPGraphics2D.java | 24 +++--- src/java/org/apache/fop/afp/AFPStreamer.java | 7 +- src/java/org/apache/fop/afp/DataStream.java | 13 ++-- src/java/org/apache/fop/afp/Factory.java | 5 -- .../org/apache/fop/afp/fonts/CharacterSet.java | 1 - src/java/org/apache/fop/afp/fonts/RasterFont.java | 11 ++- .../fop/afp/goca/GraphicsSetProcessColor.java | 2 +- .../apache/fop/afp/modca/AbstractAFPObject.java | 6 +- .../fop/afp/modca/AbstractEnvironmentGroup.java | 2 +- .../fop/afp/modca/AbstractNamedAFPObject.java | 4 +- .../afp/modca/AbstractTripletStructuredObject.java | 4 +- .../fop/afp/modca/ActiveEnvironmentGroup.java | 2 +- .../org/apache/fop/afp/modca/MapCodedFont.java | 4 +- .../org/apache/fop/afp/modca/MapPageOverlay.java | 6 +- .../org/apache/fop/afp/modca/MapPageSegment.java | 6 +- .../apache/fop/afp/ptoca/LineDataInfoProducer.java | 5 +- .../fop/afp/svg/AFPGraphicsConfiguration.java | 8 +- src/java/org/apache/fop/area/IDTracker.java | 15 ++-- .../apache/fop/events/model/EventModelParser.java | 5 +- src/java/org/apache/fop/fo/FOEventHandler.java | 5 +- src/java/org/apache/fop/fo/FObj.java | 4 +- .../fop/fo/extensions/ExtensionElementMapping.java | 16 ++-- src/java/org/apache/fop/fo/flow/Marker.java | 1 - src/java/org/apache/fop/fo/pagination/Region.java | 1 - .../fop/fo/properties/CharacterProperty.java | 4 +- .../apache/fop/fo/properties/ColorProperty.java | 4 +- .../properties/CommonBorderPaddingBackground.java | 12 +-- .../org/apache/fop/fo/properties/CommonFont.java | 4 +- .../fop/fo/properties/CommonHyphenation.java | 10 +-- .../fop/fo/properties/CondLengthProperty.java | 4 +- .../fo/properties/CorrespondingPropertyMaker.java | 2 +- .../org/apache/fop/fo/properties/EnumNumber.java | 4 +- .../org/apache/fop/fo/properties/EnumProperty.java | 4 +- .../org/apache/fop/fo/properties/FixedLength.java | 4 +- .../fop/fo/properties/FontFamilyProperty.java | 4 +- .../org/apache/fop/fo/properties/KeepProperty.java | 4 +- .../apache/fop/fo/properties/NumberProperty.java | 10 +-- .../apache/fop/fo/properties/StringProperty.java | 9 +-- src/java/org/apache/fop/fonts/FontSetup.java | 8 -- .../BalancingColumnBreakingAlgorithm.java | 20 ++--- .../apache/fop/layoutmgr/LayoutManagerMapping.java | 11 +-- .../org/apache/fop/layoutmgr/SpaceResolver.java | 87 +++++++++++----------- src/java/org/apache/fop/layoutmgr/TraitSetter.java | 11 ++- .../AbstractPageNumberCitationLayoutManager.java | 1 - .../layoutmgr/inline/BasicScaledBaselineTable.java | 4 +- .../layoutmgr/inline/LineLayoutPossibilities.java | 10 +-- .../inline/PageNumberCitationLayoutManager.java | 1 - .../fop/layoutmgr/inline/ScaledBaselineTable.java | 2 - .../layoutmgr/table/TableContentLayoutManager.java | 23 +++--- .../fop/layoutmgr/table/TableRowIterator.java | 2 - src/java/org/apache/fop/pdf/PDFEmbeddedFile.java | 6 -- src/java/org/apache/fop/pdf/PDFEncryptionJCE.java | 1 - .../org/apache/fop/pdf/PDFEncryptionManager.java | 19 +++-- .../fop/render/afp/AFPForeignAttributeReader.java | 11 ++- .../fop/render/afp/extensions/AFPPageOverlay.java | 2 - .../intermediate/AbstractIFDocumentHandler.java | 6 -- .../apache/fop/render/java2d/Java2DPainter.java | 6 -- .../org/apache/fop/render/pcl/HardcodedFonts.java | 5 +- src/java/org/apache/fop/render/pcl/PCLPainter.java | 6 -- .../apache/fop/render/pcl/PCLRendererContext.java | 3 - .../apache/fop/render/pdf/PDFBorderPainter.java | 5 +- .../org/apache/fop/render/ps/PSSVGHandler.java | 5 -- .../fop/render/rtf/rtflib/rtfdoc/RtfList.java | 3 +- .../org/apache/fop/render/svg/SVGPainter.java | 8 +- test/java/org/apache/fop/GenericFOPTestCase.java | 13 ++-- .../apache/fop/config/BaseUserConfigTestCase.java | 2 +- test/java/org/apache/fop/events/EventChecker.java | 2 +- test/java/org/apache/fop/memory/Stats.java | 2 +- .../org/apache/fop/render/pdf/PDFCMapTestCase.java | 60 +++++++-------- test/java/org/apache/fop/util/DigestFilter.java | 4 +- 74 files changed, 264 insertions(+), 357 deletions(-) (limited to 'src/java/org/apache/fop/render/java2d') diff --git a/examples/plan/src/org/apache/fop/plan/PlanHints.java b/examples/plan/src/org/apache/fop/plan/PlanHints.java index 2a2c1333a..a50d91139 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanHints.java +++ b/examples/plan/src/org/apache/fop/plan/PlanHints.java @@ -25,22 +25,22 @@ package org.apache.fop.plan; public interface PlanHints { /** Border attribute */ - public static final String PLAN_BORDER = "border"; + String PLAN_BORDER = "border"; /** Legend attribute */ - public static final String PLAN_LEGEND = "legend"; + String PLAN_LEGEND = "legend"; /** Font family attribute */ - public static final String FONT_FAMILY = "font-family"; + String FONT_FAMILY = "font-family"; /** Font size attribute */ - public static final String FONT_SIZE = "font-size"; + String FONT_SIZE = "font-size"; /** Legent type attribute */ - public static final String LEGEND_TYPE = "legendType"; + String LEGEND_TYPE = "legendType"; /** Locale attribute */ - public static final String LOCALE = "locale"; + String LOCALE = "locale"; /** Label type attribute */ - public static final String LABEL_TYPE = "labelType"; + String LABEL_TYPE = "labelType"; /** Label font size attribute */ - public static final String LABEL_FONT_SIZE = "labelFontSize"; + String LABEL_FONT_SIZE = "labelFontSize"; /** Label font attribute */ - public static final String LABEL_FONT = "labelFont"; + String LABEL_FONT = "labelFont"; } diff --git a/examples/plan/src/org/apache/fop/plan/PlanRenderer.java b/examples/plan/src/org/apache/fop/plan/PlanRenderer.java index 8b7978259..7d41962fb 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanRenderer.java +++ b/examples/plan/src/org/apache/fop/plan/PlanRenderer.java @@ -109,8 +109,8 @@ public class PlanRenderer { hints.put(PlanHints.FONT_FAMILY, fontFamily); hints.put(PlanHints.FONT_SIZE, new Float(fontSize)); hints.put(PlanHints.LOCALE, locale); - Document doc = - planDrawer.createDocument(data, width, height, hints); + Document doc + = planDrawer.createDocument(data, width, height, hints); return doc; } @@ -152,6 +152,7 @@ public class PlanRenderer { } else if (t.equals("grouping")) { data.setType(ActionInfo.GROUPING); } else { + throw new IllegalArgumentException("Unknown action type: " + t); } for (int i = 0; i < childs.getLength(); i++) { diff --git a/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java b/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java index 46b07601a..a8ba062ed 100644 --- a/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java +++ b/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java @@ -243,8 +243,8 @@ public class SimplePlanDrawer implements PlanDrawer { - lastWeek.getTime() + 43200000) / 86400000); int days = (int)((end.getTime() - start.getTime() + 43200000) / 86400000); - int daysFromEnd = - (int)((future.getTime() - end.getTime() + int daysFromEnd + = (int)((future.getTime() - end.getTime() + 43200000) / 86400000); Element taskGraphic; switch (type) { @@ -299,8 +299,8 @@ public class SimplePlanDrawer implements PlanDrawer { topEdge = lastTop; } } - int currentDays = - (int)((currentDate.getTime() - lastWeek.getTime() + int currentDays + = (int)((currentDate.getTime() - lastWeek.getTime() + 43200000) / 86400000); text = SVGUtilities.createText(doc, diff --git a/src/java/org/apache/fop/afp/AFPDataObjectInfo.java b/src/java/org/apache/fop/afp/AFPDataObjectInfo.java index 66ef8e595..7589ef4fe 100644 --- a/src/java/org/apache/fop/afp/AFPDataObjectInfo.java +++ b/src/java/org/apache/fop/afp/AFPDataObjectInfo.java @@ -19,9 +19,6 @@ package org.apache.fop.afp; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.apache.fop.afp.modca.Registry; import org.apache.fop.afp.modca.triplets.MappingOptionTriplet; @@ -29,8 +26,6 @@ import org.apache.fop.afp.modca.triplets.MappingOptionTriplet; * A list of parameters associated with an AFP data objects */ public class AFPDataObjectInfo { - private static final Log log // CSOK: ConstantName - = LogFactory.getLog("org.apache.xmlgraphics.afp"); /** the object area info */ private AFPObjectAreaInfo objectAreaInfo; diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java index 5fa6bae2d..af58b5471 100644 --- a/src/java/org/apache/fop/afp/AFPGraphics2D.java +++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java @@ -75,7 +75,7 @@ import org.apache.fop.svg.NativeImageHandler; */ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHandler { - private static final Log log = LogFactory.getLog(AFPGraphics2D.class); // CSOK: ConstantName + private static final Log LOG = LogFactory.getLog(AFPGraphics2D.class); private static final int X = 0; @@ -321,7 +321,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand graphicsObj.setLineType(type); } } else { - log.warn("Unsupported Stroke: " + stroke.getClass().getName()); + LOG.warn("Unsupported Stroke: " + stroke.getClass().getName()); } } @@ -339,7 +339,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand if (paint instanceof Color) { return true; } - log.debug("NYI: applyPaint() " + paint + " fill=" + fill); + LOG.debug("NYI: applyPaint() " + paint + " fill=" + fill); if (paint instanceof TexturePaint) { // TexturePaint texturePaint = (TexturePaint)paint; // BufferedImage bufferedImage = texturePaint.getImage(); @@ -490,7 +490,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand currentPosition = new double[]{openingCoords[0], openingCoords[1]}; break; default: - log.debug("Unrecognised path iterator type"); + LOG.debug("Unrecognised path iterator type"); break; } } @@ -498,13 +498,13 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand /** {@inheritDoc} */ public void draw(Shape shape) { - log.debug("draw() shape=" + shape); + LOG.debug("draw() shape=" + shape); doDrawing(shape, false); } /** {@inheritDoc} */ public void fill(Shape shape) { - log.debug("fill() shape=" + shape); + LOG.debug("fill() shape=" + shape); doDrawing(shape, true); } @@ -516,7 +516,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand */ public void handleIOException(IOException ioe) { // TODO Surely, there's a better way to do this. - log.error(ioe.getMessage()); + LOG.error(ioe.getMessage()); ioe.printStackTrace(); } @@ -659,29 +659,29 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand /** {@inheritDoc} */ public void drawRenderableImage(RenderableImage img, AffineTransform xform) { - log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform); + LOG.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform); } /** {@inheritDoc} */ public FontMetrics getFontMetrics(Font f) { - log.debug("getFontMetrics() NYI: f=" + f); + LOG.debug("getFontMetrics() NYI: f=" + f); return null; } /** {@inheritDoc} */ public void setXORMode(Color col) { - log.debug("setXORMode() NYI: col=" + col); + LOG.debug("setXORMode() NYI: col=" + col); } /** {@inheritDoc} */ public void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y, float width, float height) { - log.debug("NYI: addNativeImage() " + "image=" + image + LOG.debug("NYI: addNativeImage() " + "image=" + image + ",x=" + x + ",y=" + y + ",width=" + width + ",height=" + height); } /** {@inheritDoc} */ public void copyArea(int x, int y, int width, int height, int dx, int dy) { - log.debug("copyArea() NYI: "); + LOG.debug("copyArea() NYI: "); } } diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java index a24e90cbf..33d1dbf90 100644 --- a/src/java/org/apache/fop/afp/AFPStreamer.java +++ b/src/java/org/apache/fop/afp/AFPStreamer.java @@ -31,6 +31,7 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.afp.modca.ResourceGroup; import org.apache.fop.afp.modca.StreamedResourceGroup; @@ -39,7 +40,7 @@ import org.apache.fop.afp.modca.StreamedResourceGroup; */ public class AFPStreamer implements Streamable { /** Static logging instance */ - private static final Log log = LogFactory.getLog(AFPStreamer.class); // CSOK: ConstantName + private static final Log LOG = LogFactory.getLog(AFPStreamer.class); private static final String AFPDATASTREAM_TEMP_FILE_PREFIX = "AFPDataStream_"; @@ -119,7 +120,7 @@ public class AFPStreamer implements Streamable { if (level.isExternal()) { String filePath = level.getExternalFilePath(); if (filePath == null) { - log.warn("No file path provided for external resource, using default."); + LOG.warn("No file path provided for external resource, using default."); filePath = defaultResourceGroupFilePath; } resourceGroup = (ResourceGroup)pathResourceGroupMap.get(filePath); @@ -128,7 +129,7 @@ public class AFPStreamer implements Streamable { try { os = new BufferedOutputStream(new FileOutputStream(filePath)); } catch (FileNotFoundException fnfe) { - log.error("Failed to create/open external resource group file '" + LOG.error("Failed to create/open external resource group file '" + filePath + "'"); } finally { if (os != null) { diff --git a/src/java/org/apache/fop/afp/DataStream.java b/src/java/org/apache/fop/afp/DataStream.java index 096c2e60e..843e3fa65 100644 --- a/src/java/org/apache/fop/afp/DataStream.java +++ b/src/java/org/apache/fop/afp/DataStream.java @@ -30,8 +30,8 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.afp.fonts.AFPFontAttributes; import org.apache.fop.afp.fonts.AFPFont; +import org.apache.fop.afp.fonts.AFPFontAttributes; import org.apache.fop.afp.fonts.CharacterSet; import org.apache.fop.afp.modca.AbstractPageObject; import org.apache.fop.afp.modca.Document; @@ -42,10 +42,10 @@ import org.apache.fop.afp.modca.PageObject; import org.apache.fop.afp.modca.ResourceGroup; import org.apache.fop.afp.modca.TagLogicalElementBean; import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; -import org.apache.fop.afp.ptoca.PtocaProducer; import org.apache.fop.afp.ptoca.PtocaBuilder; -import org.apache.fop.util.CharUtilities; +import org.apache.fop.afp.ptoca.PtocaProducer; import org.apache.fop.fonts.Font; +import org.apache.fop.util.CharUtilities; /** * A data stream is a continuous ordered stream of data elements and objects @@ -65,8 +65,7 @@ import org.apache.fop.fonts.Font; public class DataStream { /** Static logging instance */ - protected static final Log log // CSOK: ConstantName - = LogFactory.getLog("org.apache.xmlgraphics.afp"); + protected static final Log LOG = LogFactory.getLog("org.apache.xmlgraphics.afp"); /** Boolean completion indicator */ private boolean complete = false; @@ -163,7 +162,7 @@ public class DataStream { public void endDocument() throws IOException { if (complete) { String msg = "Invalid state - document already ended."; - log.warn("endDocument():: " + msg); + LOG.warn("endDocument():: " + msg); throw new IllegalStateException(msg); } @@ -357,7 +356,7 @@ public class DataStream { * @param letterSpacing letter spacing to draw text with * @param wordSpacing word Spacing to draw text with * @param font is the font to draw text with - * @param charSet is the AFP Character Set to use with the text + * @param charSet is the AFP Character Set to use with the text * @throws UnsupportedEncodingException thrown if character encoding is not supported */ public void createText diff --git a/src/java/org/apache/fop/afp/Factory.java b/src/java/org/apache/fop/afp/Factory.java index f29453cf5..ef68a22fb 100644 --- a/src/java/org/apache/fop/afp/Factory.java +++ b/src/java/org/apache/fop/afp/Factory.java @@ -21,8 +21,6 @@ package org.apache.fop.afp; import java.io.OutputStream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.fop.afp.goca.GraphicsData; import org.apache.fop.afp.ioca.ImageContent; import org.apache.fop.afp.ioca.ImageRasterData; @@ -65,9 +63,6 @@ import org.apache.fop.afp.util.StringUtils; */ public class Factory { - /** Static logging instance */ - private static final Log log = LogFactory.getLog(Factory.class); // CSOK: ConstantName - private static final String OBJECT_ENVIRONMENT_GROUP_NAME_PREFIX = "OEG"; private static final String ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX = "AEG"; diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/afp/fonts/CharacterSet.java index 22cb52d4d..7123d4138 100644 --- a/src/java/org/apache/fop/afp/fonts/CharacterSet.java +++ b/src/java/org/apache/fop/afp/fonts/CharacterSet.java @@ -21,7 +21,6 @@ package org.apache.fop.afp.fonts; import java.io.File; import java.io.UnsupportedEncodingException; -import java.net.URI; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; diff --git a/src/java/org/apache/fop/afp/fonts/RasterFont.java b/src/java/org/apache/fop/afp/fonts/RasterFont.java index 6ad5375bf..2a4d5d270 100644 --- a/src/java/org/apache/fop/afp/fonts/RasterFont.java +++ b/src/java/org/apache/fop/afp/fonts/RasterFont.java @@ -37,8 +37,7 @@ import org.apache.commons.logging.LogFactory; public class RasterFont extends AFPFont { /** Static logging instance */ - protected static final Log log // CSOK: ConstantName - = LogFactory.getLog("org.apache.fop.afp.fonts"); + protected static final Log LOG = LogFactory.getLog("org.apache.fop.afp.fonts"); private final SortedMap/**/ charSets = new java.util.TreeMap/**/(); @@ -118,7 +117,7 @@ public class RasterFont extends AFPFont { substitutionCharSets.put(requestedSize, csm); String msg = "No " + (size / 1000f) + "pt font " + getFontName() + " found, substituted with " + fontSize.intValue() / 1000f + "pt font"; - log.warn(msg); + LOG.warn(msg); } } @@ -126,7 +125,7 @@ public class RasterFont extends AFPFont { // Still no match -> error String msg = "No font found for font " + getFontName() + " with point size " + size / 1000f; - log.error(msg); + LOG.error(msg); throw new FontRuntimeException(msg); } @@ -145,7 +144,7 @@ public class RasterFont extends AFPFont { return csm.getFirstChar(); } else { String msg = "getFirstChar() - No character set found for font:" + getFontName(); - log.error(msg); + LOG.error(msg); throw new FontRuntimeException(msg); } } @@ -162,7 +161,7 @@ public class RasterFont extends AFPFont { return csm.getLastChar(); } else { String msg = "getLastChar() - No character set found for font:" + getFontName(); - log.error(msg); + LOG.error(msg); throw new FontRuntimeException(msg); } diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java index 4d45b22cb..aba02f76c 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java @@ -75,7 +75,7 @@ public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder { } else if (colSpaceType == ColorSpace.TYPE_RGB) { colspace = RGB; } else { - log.error("unsupported colorspace " + colSpaceType); + LOG.error("unsupported colorspace " + colSpaceType); colspace = RGB; } diff --git a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java index be92ce0b6..4b1439da0 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java @@ -27,6 +27,7 @@ import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.afp.Streamable; import org.apache.fop.afp.util.BinaryUtils; @@ -38,8 +39,7 @@ import org.apache.fop.afp.util.BinaryUtils; public abstract class AbstractAFPObject implements Streamable { /** Static logging instance */ - protected static final Log log // CSOK: ConstantName - = LogFactory.getLog("org.apache.xmlgraphics.afp.modca"); + protected static final Log LOG = LogFactory.getLog("org.apache.xmlgraphics.afp.modca"); /** the structured field class id */ protected static final byte SF_CLASS = (byte)0xD3; @@ -189,7 +189,7 @@ public abstract class AbstractAFPObject implements Streamable { protected String truncate(String str, int maxLength) { if (str.length() > maxLength) { str = str.substring(0, maxLength); - log.warn("truncated character string '" + LOG.warn("truncated character string '" + str + "', longer than " + maxLength + " chars"); } return str; diff --git a/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java index 19f2c94a3..d06311a47 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java +++ b/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java @@ -73,7 +73,7 @@ public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject { mpo.addOverlay(name); } catch (MaximumSizeExceededException ex) { // Should never happen (but log just in case) - log.error("createOverlay():: resulted in a MaximumSizeExceededException"); + LOG.error("createOverlay():: resulted in a MaximumSizeExceededException"); } } } diff --git a/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java index 4e0dbc349..b349e1f7d 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java @@ -73,7 +73,7 @@ public abstract class AbstractNamedAFPObject extends AbstractTripletStructuredOb name = (name + " ").substring(0, afpNameLen); } else if (name.length() > afpNameLen) { String truncatedName = name.substring(nameLen - afpNameLen, nameLen); - log.warn("Constructor:: name '" + name + "'" + LOG.warn("Constructor:: name '" + name + "'" + " truncated to " + afpNameLen + " chars" + " ('" + truncatedName + "')"); name = truncatedName; @@ -83,7 +83,7 @@ public abstract class AbstractNamedAFPObject extends AbstractTripletStructuredOb nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); } catch (UnsupportedEncodingException usee) { nameBytes = name.getBytes(); - log.warn( + LOG.warn( "Constructor:: UnsupportedEncodingException translating the name " + name); } diff --git a/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java b/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java index efc38f3b8..4b269086e 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java @@ -27,8 +27,6 @@ import java.util.List; import org.apache.fop.afp.modca.Registry.ObjectType; import org.apache.fop.afp.modca.triplets.AbstractTriplet; -import org.apache.fop.afp.modca.triplets.AttributeQualifierTriplet; -import org.apache.fop.afp.modca.triplets.AttributeValueTriplet; import org.apache.fop.afp.modca.triplets.CommentTriplet; import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; import org.apache.fop.afp.modca.triplets.ObjectClassificationTriplet; @@ -150,7 +148,7 @@ public class AbstractTripletStructuredObject extends AbstractStructuredObject { if (fqNameTriplet != null) { return fqNameTriplet.getFullyQualifiedName(); } - log.warn(this + " has no fully qualified name"); + LOG.warn(this + " has no fully qualified name"); return null; } diff --git a/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java index 4af687a92..696787bc4 100644 --- a/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java +++ b/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java @@ -185,7 +185,7 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { mapCodedFont.addFont(fontRef, font, size, orientation); } catch (MaximumSizeExceededException ex) { // Should never happen (but log just in case) - log.error("createFont():: resulted in a MaximumSizeExceededException"); + LOG.error("createFont():: resulted in a MaximumSizeExceededException"); } } } diff --git a/src/java/org/apache/fop/afp/modca/MapCodedFont.java b/src/java/org/apache/fop/afp/modca/MapCodedFont.java index 8d99d8eaa..69d8ccf31 100644 --- a/src/java/org/apache/fop/afp/modca/MapCodedFont.java +++ b/src/java/org/apache/fop/afp/modca/MapCodedFont.java @@ -180,7 +180,7 @@ public class MapCodedFont extends AbstractStructuredObject { if (cs == null) { String msg = "Character set not found for font " + font.getFontName() + " with point size " + size; - log.error(msg); + LOG.error(msg); throw new FontRuntimeException(msg); } @@ -243,7 +243,7 @@ public class MapCodedFont extends AbstractStructuredObject { } else { String msg = "Font of type " + font.getClass().getName() + " not recognized."; - log.error(msg); + LOG.error(msg); throw new FontRuntimeException(msg); } diff --git a/src/java/org/apache/fop/afp/modca/MapPageOverlay.java b/src/java/org/apache/fop/afp/modca/MapPageOverlay.java index 9fd3c7059..6f5855c93 100644 --- a/src/java/org/apache/fop/afp/modca/MapPageOverlay.java +++ b/src/java/org/apache/fop/afp/modca/MapPageOverlay.java @@ -69,14 +69,14 @@ public class MapPageOverlay extends AbstractAFPObject { throw new IllegalArgumentException("The name of overlay " + name + " must be 8 characters"); } - if (log.isDebugEnabled()) { - log.debug("addOverlay():: adding overlay " + name); + if (LOG.isDebugEnabled()) { + LOG.debug("addOverlay():: adding overlay " + name); } try { byte[] data = name.getBytes(AFPConstants.EBCIDIC_ENCODING); getOverlays().add(data); } catch (UnsupportedEncodingException usee) { - log.error("addOverlay():: UnsupportedEncodingException translating the name " + LOG.error("addOverlay():: UnsupportedEncodingException translating the name " + name); } } diff --git a/src/java/org/apache/fop/afp/modca/MapPageSegment.java b/src/java/org/apache/fop/afp/modca/MapPageSegment.java index e2afd0257..8bb7afe46 100644 --- a/src/java/org/apache/fop/afp/modca/MapPageSegment.java +++ b/src/java/org/apache/fop/afp/modca/MapPageSegment.java @@ -67,8 +67,8 @@ public class MapPageSegment extends AbstractAFPObject { throw new IllegalArgumentException("The name of page segment " + name + " must not be longer than 8 characters"); } - if (log.isDebugEnabled()) { - log.debug("addPageSegment():: adding page segment " + name); + if (LOG.isDebugEnabled()) { + LOG.debug("addPageSegment():: adding page segment " + name); } getPageSegments().add(name); } @@ -124,7 +124,7 @@ public class MapPageSegment extends AbstractAFPObject { byte[] nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); System.arraycopy(nameBytes, 0, data, pos, nameBytes.length); } catch (UnsupportedEncodingException usee) { - log.error("UnsupportedEncodingException translating the name " + LOG.error("UnsupportedEncodingException translating the name " + name); } pos += 8; diff --git a/src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java b/src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java index ad2a5d716..cf00674fb 100644 --- a/src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java +++ b/src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java @@ -32,8 +32,7 @@ import org.apache.fop.afp.AFPLineDataInfo; public class LineDataInfoProducer implements PtocaProducer, PtocaConstants { /** Static logging instance */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(LineDataInfoProducer.class); + private static final Log LOG = LogFactory.getLog(LineDataInfoProducer.class); private AFPLineDataInfo lineDataInfo; @@ -62,7 +61,7 @@ public class LineDataInfoProducer implements PtocaProducer, PtocaConstants { } else if (x1 == x2) { builder.drawBaxisRule(y2 - y1, thickness); } else { - log.error("Invalid axis rule: unable to draw line"); + LOG.error("Invalid axis rule: unable to draw line"); return; } } diff --git a/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java b/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java index b8ed5159a..0a051e675 100644 --- a/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java +++ b/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java @@ -109,7 +109,7 @@ public class AFPGraphicsConfiguration extends GraphicsConfiguration { } } - private static final Log log // CSOK: ConstantName + private static final Log LOG = LogFactory.getLog(AFPGraphicsConfiguration.class); private AffineTransform defaultTransform = null; @@ -122,7 +122,7 @@ public class AFPGraphicsConfiguration extends GraphicsConfiguration { * @return the default transform for the configuration */ public AffineTransform getDefaultTransform() { - log.debug("getDefaultTransform()"); + LOG.debug("getDefaultTransform()"); if (defaultTransform == null) { defaultTransform = new AffineTransform(); } @@ -137,7 +137,7 @@ public class AFPGraphicsConfiguration extends GraphicsConfiguration { * @return the normalizing transform for the configuration */ public AffineTransform getNormalizingTransform() { - log.debug("getNormalizingTransform()"); + LOG.debug("getNormalizingTransform()"); if (normalizingTransform == null) { normalizingTransform = new AffineTransform(2, 0, 0, 2, 0, 0); } @@ -146,7 +146,7 @@ public class AFPGraphicsConfiguration extends GraphicsConfiguration { /** {@inheritDoc} */ public GraphicsDevice getDevice() { - log.debug("getDevice()"); + LOG.debug("getDevice()"); return graphicsDevice; } } diff --git a/src/java/org/apache/fop/area/IDTracker.java b/src/java/org/apache/fop/area/IDTracker.java index c0607d1bd..829c8c58d 100644 --- a/src/java/org/apache/fop/area/IDTracker.java +++ b/src/java/org/apache/fop/area/IDTracker.java @@ -34,8 +34,7 @@ import org.apache.commons.logging.LogFactory; */ public class IDTracker { - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(IDTracker.class); + private static final Log LOG = LogFactory.getLog(IDTracker.class); // HashMap of ID's whose area is located on one or more consecutive // PageViewports. Each ID has an arraylist of PageViewports that @@ -59,8 +58,8 @@ public class IDTracker { * @param pv a page viewport that contains the area with this ID */ public void associateIDWithPageViewport(String id, PageViewport pv) { - if (log.isDebugEnabled()) { - log.debug("associateIDWithPageViewport(" + id + ", " + pv + ")"); + if (LOG.isDebugEnabled()) { + LOG.debug("associateIDWithPageViewport(" + id + ", " + pv + ")"); } List pvList = (List) idLocations.get(id); if (pvList == null) { // first time ID located @@ -93,8 +92,8 @@ public class IDTracker { * @param id the id of the object being processed */ public void signalPendingID(String id) { - if (log.isDebugEnabled()) { - log.debug("signalPendingID(" + id + ")"); + if (LOG.isDebugEnabled()) { + LOG.debug("signalPendingID(" + id + ")"); } unfinishedIDs.add(id); } @@ -107,8 +106,8 @@ public class IDTracker { * @param id the id of the formatting object which was just finished */ public void signalIDProcessed(String id) { - if (log.isDebugEnabled()) { - log.debug("signalIDProcessed(" + id + ")"); + if (LOG.isDebugEnabled()) { + LOG.debug("signalIDProcessed(" + id + ")"); } alreadyResolvedIDs.add(id); diff --git a/src/java/org/apache/fop/events/model/EventModelParser.java b/src/java/org/apache/fop/events/model/EventModelParser.java index be7c61790..5441d1c4f 100644 --- a/src/java/org/apache/fop/events/model/EventModelParser.java +++ b/src/java/org/apache/fop/events/model/EventModelParser.java @@ -46,8 +46,7 @@ public final class EventModelParser { } /** Logger instance */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(EventModelParser.class); + private static final Log LOG = LogFactory.getLog(EventModelParser.class); private static SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); @@ -61,7 +60,7 @@ public final class EventModelParser { public static EventModel parse(Source src) throws TransformerException { Transformer transformer = tFactory.newTransformer(); - transformer.setErrorListener(new DefaultErrorListener(log)); + transformer.setErrorListener(new DefaultErrorListener(LOG)); EventModel model = new EventModel(); SAXResult res = new SAXResult(getContentHandler(model)); diff --git a/src/java/org/apache/fop/fo/FOEventHandler.java b/src/java/org/apache/fop/fo/FOEventHandler.java index 238a4ced6..e280af2d7 100644 --- a/src/java/org/apache/fop/fo/FOEventHandler.java +++ b/src/java/org/apache/fop/fo/FOEventHandler.java @@ -40,11 +40,10 @@ import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.PageNumberCitationLast; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; -import org.apache.fop.fo.flow.table.TableFooter; -import org.apache.fop.fo.flow.table.TableHeader; -import org.apache.fop.fo.flow.table.TablePart; import org.apache.fop.fo.flow.table.TableCell; import org.apache.fop.fo.flow.table.TableColumn; +import org.apache.fop.fo.flow.table.TableFooter; +import org.apache.fop.fo.flow.table.TableHeader; import org.apache.fop.fo.flow.table.TableRow; import org.apache.fop.fo.pagination.Flow; import org.apache.fop.fo.pagination.PageSequence; diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 244013c4d..cb265b008 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -44,7 +44,7 @@ import org.apache.fop.fo.properties.PropertyMaker; public abstract class FObj extends FONode implements Constants { /** the list of property makers */ - private static final PropertyMaker[] propertyListTable // CSOK: ConstantName + private static final PropertyMaker[] PROPERTY_LIST_TABLE = FOPropertyMapping.getGenericMappings(); /** @@ -108,7 +108,7 @@ public abstract class FObj extends FONode implements Constants { * @return the requested Property Maker */ public static PropertyMaker getPropertyMakerFor(int propId) { - return propertyListTable[propId]; + return PROPERTY_LIST_TABLE[propId]; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java index 32d0d745c..a12bed0fa 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java @@ -37,18 +37,18 @@ public class ExtensionElementMapping extends ElementMapping { /** The FOP extension namespace URI */ public static final String URI = "http://xmlgraphics.apache.org/fop/extensions"; - private static final Set propertyAttributes // CSOK: ConstantName + private static final Set PROPERTY_ATTRIBUTES = new java.util.HashSet(); static { //These are FOP's standard extension properties (fox:*) - propertyAttributes.add("block-progression-unit"); - propertyAttributes.add("widow-content-limit"); - propertyAttributes.add("orphan-content-limit"); - propertyAttributes.add("internal-destination"); - propertyAttributes.add("disable-column-balancing"); + PROPERTY_ATTRIBUTES.add("block-progression-unit"); + PROPERTY_ATTRIBUTES.add("widow-content-limit"); + PROPERTY_ATTRIBUTES.add("orphan-content-limit"); + PROPERTY_ATTRIBUTES.add("internal-destination"); + PROPERTY_ATTRIBUTES.add("disable-column-balancing"); //These are FOP's extension properties for accessibility - propertyAttributes.add("alt-text"); + PROPERTY_ATTRIBUTES.add("alt-text"); } /** @@ -93,7 +93,7 @@ public class ExtensionElementMapping extends ElementMapping { if (!URI.equals(attributeName.getNamespaceURI())) { throw new IllegalArgumentException("The namespace URIs don't match"); } - return propertyAttributes.contains(attributeName.getLocalName()); + return PROPERTY_ATTRIBUTES.contains(attributeName.getLocalName()); } } diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java index e23a13f33..d8f69af28 100644 --- a/src/java/org/apache/fop/fo/flow/Marker.java +++ b/src/java/org/apache/fop/fo/flow/Marker.java @@ -19,7 +19,6 @@ package org.apache.fop.fo.flow; -import java.util.Collections; import java.util.Map; import org.xml.sax.Attributes; diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index 6f94418be..ea449cdff 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -31,7 +31,6 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.expr.PropertyException; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; /** diff --git a/src/java/org/apache/fop/fo/properties/CharacterProperty.java b/src/java/org/apache/fop/fo/properties/CharacterProperty.java index 71b70ebee..5fef57a8b 100644 --- a/src/java/org/apache/fop/fo/properties/CharacterProperty.java +++ b/src/java/org/apache/fop/fo/properties/CharacterProperty.java @@ -51,7 +51,7 @@ public final class CharacterProperty extends Property { } /** cache containing all canonical CharacterProperty instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(CharacterProperty.class); private final char character; @@ -69,7 +69,7 @@ public final class CharacterProperty extends Property { * @return the character property instance */ public static CharacterProperty getInstance(char character) { - return (CharacterProperty) cache.fetch( + return (CharacterProperty) CACHE.fetch( new CharacterProperty(character)); } diff --git a/src/java/org/apache/fop/fo/properties/ColorProperty.java b/src/java/org/apache/fop/fo/properties/ColorProperty.java index 95725f3e8..e7b8d5931 100644 --- a/src/java/org/apache/fop/fo/properties/ColorProperty.java +++ b/src/java/org/apache/fop/fo/properties/ColorProperty.java @@ -33,7 +33,7 @@ import org.apache.fop.util.ColorUtil; public final class ColorProperty extends Property { /** cache holding canonical ColorProperty instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(ColorProperty.class); /** @@ -103,7 +103,7 @@ public final class ColorProperty extends Property { ColorProperty instance = new ColorProperty( ColorUtil.parseColorString( foUserAgent, value)); - return (ColorProperty)cache.fetch(instance); + return (ColorProperty)CACHE.fetch(instance); } /** diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java index b3ae7d8cd..d39dc24f0 100644 --- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java +++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java @@ -48,7 +48,7 @@ public class CommonBorderPaddingBackground { // CSOK: FinalCl * cache holding all canonical instances * (w/ absolute background-position-* and padding-*) */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(CommonBorderPaddingBackground.class); private int hash = -1; @@ -102,7 +102,7 @@ public class CommonBorderPaddingBackground { // CSOK: FinalCl public static final class BorderInfo { /** cache holding all canonical instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(BorderInfo.class); private int mStyle; // Enum for border style @@ -129,7 +129,7 @@ public class CommonBorderPaddingBackground { // CSOK: FinalCl * @return a cached BorderInfo instance */ public static BorderInfo getInstance(int style, CondLengthProperty width, Color color) { - return cache.fetch(new BorderInfo(style, width, color)); + return CACHE.fetch(new BorderInfo(style, width, color)); } /** @@ -214,7 +214,7 @@ public class CommonBorderPaddingBackground { // CSOK: FinalCl * A border info with style "none". Used as a singleton, in the collapsing-border model, * for elements which don't specify any border on some of their sides. */ - private static final BorderInfo defaultBorderInfo // CSOK: ConstantName + private static final BorderInfo DEFAULT_BORDER_INFO = BorderInfo.getInstance(Constants.EN_NONE, new ConditionalNullLength(), null); /** @@ -276,7 +276,7 @@ public class CommonBorderPaddingBackground { // CSOK: FinalCl * @return a BorderInfo instance with style set to {@link Constants#EN_NONE} */ public static BorderInfo getDefaultBorderInfo() { - return defaultBorderInfo; + return DEFAULT_BORDER_INFO; } private BorderInfo[] borderInfo = new BorderInfo[4]; @@ -366,7 +366,7 @@ public class CommonBorderPaddingBackground { // CSOK: FinalCl || newInstance.backgroundPositionHorizontal.isAbsolute()) && (newInstance.backgroundPositionVertical == null || newInstance.backgroundPositionVertical.isAbsolute())) { - cachedInstance = cache.fetch(newInstance); + cachedInstance = CACHE.fetch(newInstance); } /* for non-cached, or not-yet-cached instances, preload the image */ diff --git a/src/java/org/apache/fop/fo/properties/CommonFont.java b/src/java/org/apache/fop/fo/properties/CommonFont.java index f3f7d3f69..b12f84ad2 100644 --- a/src/java/org/apache/fop/fo/properties/CommonFont.java +++ b/src/java/org/apache/fop/fo/properties/CommonFont.java @@ -37,7 +37,7 @@ public final class CommonFont { /** cache holding canonical CommonFont instances (only those with * absolute font-size and font-size-adjust) */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(CommonFont.class); /** hashcode of this instance */ @@ -129,7 +129,7 @@ public final class CommonFont { fontSize, fontSizeAdjust); - return cache.fetch(commonFont); + return CACHE.fetch(commonFont); } /** @return an array with the font-family names */ diff --git a/src/java/org/apache/fop/fo/properties/CommonHyphenation.java b/src/java/org/apache/fop/fo/properties/CommonHyphenation.java index c65b5b616..65b2cebbd 100644 --- a/src/java/org/apache/fop/fo/properties/CommonHyphenation.java +++ b/src/java/org/apache/fop/fo/properties/CommonHyphenation.java @@ -36,11 +36,9 @@ import org.apache.fop.fonts.Typeface; public final class CommonHyphenation { /** Logger */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(CommonHyphenation.class); + private static final Log LOG = LogFactory.getLog(CommonHyphenation.class); - private static final PropertyCache cache // CSOK: ConstantName - = new PropertyCache(CommonHyphenation.class); + private static final PropertyCache CACHE = new PropertyCache(CommonHyphenation.class); private int hash = 0; @@ -119,7 +117,7 @@ public final class CommonHyphenation { hyphenationPushCharacterCount, hyphenationRemainCharacterCount); - return cache.fetch(instance); + return CACHE.fetch(instance); } @@ -168,7 +166,7 @@ public final class CommonHyphenation { } } if (warn) { - log.warn("Substituted specified hyphenation character (0x" + LOG.warn("Substituted specified hyphenation character (0x" + Integer.toHexString(hyphChar) + ") with 0x" + Integer.toHexString(effHyphChar) + " because the font doesn't have the specified hyphenation character: " diff --git a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java index dc7d80c39..1ab7ec3ad 100644 --- a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java +++ b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java @@ -33,7 +33,7 @@ import org.apache.fop.fo.expr.PropertyException; public class CondLengthProperty extends Property implements CompoundDatatype { /** cache holding canonical instances (for absolute conditional lengths) */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(CondLengthProperty.class); /** components */ @@ -159,7 +159,7 @@ public class CondLengthProperty extends Property implements CompoundDatatype { */ public CondLengthProperty getCondLength() { if (this.length.getLength().isAbsolute()) { - CondLengthProperty clp = (CondLengthProperty) cache.fetch(this); + CondLengthProperty clp = (CondLengthProperty) CACHE.fetch(this); if (clp == this) { isCached = true; } diff --git a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java index 18c6f09a6..6183b9e56 100644 --- a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java @@ -19,12 +19,12 @@ package org.apache.fop.fo.properties; -import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; /** + * Maker class for handling corresponding properties. */ public class CorrespondingPropertyMaker { /** base property maker */ diff --git a/src/java/org/apache/fop/fo/properties/EnumNumber.java b/src/java/org/apache/fop/fo/properties/EnumNumber.java index 6a2879479..153a716df 100644 --- a/src/java/org/apache/fop/fo/properties/EnumNumber.java +++ b/src/java/org/apache/fop/fo/properties/EnumNumber.java @@ -29,7 +29,7 @@ import org.apache.fop.fo.expr.PropertyException; public final class EnumNumber extends Property implements Numeric { /** cache holding all canonical EnumNumber instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(EnumNumber.class); private final EnumProperty enumProperty; @@ -50,7 +50,7 @@ public final class EnumNumber extends Property implements Numeric { * @return the canonical instance */ public static EnumNumber getInstance(Property enumProperty) { - return (EnumNumber)cache.fetch( + return (EnumNumber)CACHE.fetch( new EnumNumber((EnumProperty) enumProperty)); } diff --git a/src/java/org/apache/fop/fo/properties/EnumProperty.java b/src/java/org/apache/fop/fo/properties/EnumProperty.java index db26cfdc6..ae704f1c9 100644 --- a/src/java/org/apache/fop/fo/properties/EnumProperty.java +++ b/src/java/org/apache/fop/fo/properties/EnumProperty.java @@ -29,7 +29,7 @@ import org.apache.fop.fo.expr.PropertyException; public final class EnumProperty extends Property { /** cache holding all canonical EnumProperty instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(EnumProperty.class); /** @@ -93,7 +93,7 @@ public final class EnumProperty extends Property { * @return an enumeration property */ public static EnumProperty getInstance(int explicitValue, String text) { - return (EnumProperty) cache.fetch( + return (EnumProperty) CACHE.fetch( new EnumProperty(explicitValue, text)); } diff --git a/src/java/org/apache/fop/fo/properties/FixedLength.java b/src/java/org/apache/fop/fo/properties/FixedLength.java index cc4d04c69..c35c6f6c9 100644 --- a/src/java/org/apache/fop/fo/properties/FixedLength.java +++ b/src/java/org/apache/fop/fo/properties/FixedLength.java @@ -45,7 +45,7 @@ public final class FixedLength extends LengthProperty { public static final String MPT = "mpt"; /** cache holding all canonical FixedLength instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(FixedLength.class); /** canonical zero-length instance */ @@ -82,7 +82,7 @@ public final class FixedLength extends LengthProperty { if (numUnits == 0.0) { return ZERO_FIXED_LENGTH; } else { - return (FixedLength)cache.fetch( + return (FixedLength)CACHE.fetch( new FixedLength(numUnits, units, sourceResolution)); } diff --git a/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java b/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java index 5b05aa959..330101ee7 100644 --- a/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java +++ b/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java @@ -31,7 +31,7 @@ import org.apache.fop.fo.expr.PropertyException; public final class FontFamilyProperty extends ListProperty { /** cache holding all canonical FontFamilyProperty instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(FontFamilyProperty.class); private int hash = 0; @@ -95,7 +95,7 @@ public final class FontFamilyProperty extends ListProperty { prop.addProperty(StringProperty.getInstance(tmpVal)); } } - return cache.fetch(prop); + return CACHE.fetch(prop); } } diff --git a/src/java/org/apache/fop/fo/properties/KeepProperty.java b/src/java/org/apache/fop/fo/properties/KeepProperty.java index 7c5b6124f..0bc44e459 100644 --- a/src/java/org/apache/fop/fo/properties/KeepProperty.java +++ b/src/java/org/apache/fop/fo/properties/KeepProperty.java @@ -30,7 +30,7 @@ import org.apache.fop.fo.expr.PropertyException; public final class KeepProperty extends Property implements CompoundDatatype { /** class holding all canonical KeepProperty instances*/ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(KeepProperty.class); private boolean isCachedValue = false; @@ -165,7 +165,7 @@ public final class KeepProperty extends Property implements CompoundDatatype { * this property */ public KeepProperty getKeep() { - KeepProperty keep = (KeepProperty) cache.fetch(this); + KeepProperty keep = (KeepProperty) CACHE.fetch(this); /* make sure setComponent() can never alter cached values */ keep.isCachedValue = true; return keep; diff --git a/src/java/org/apache/fop/fo/properties/NumberProperty.java b/src/java/org/apache/fop/fo/properties/NumberProperty.java index d54161b8d..97844d723 100644 --- a/src/java/org/apache/fop/fo/properties/NumberProperty.java +++ b/src/java/org/apache/fop/fo/properties/NumberProperty.java @@ -106,7 +106,7 @@ public final class NumberProperty extends Property implements Numeric { } /** cache holding all canonical NumberProperty instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(NumberProperty.class); private final Number number; @@ -144,7 +144,7 @@ public final class NumberProperty extends Property implements Numeric { * @return the canonical NumberProperty */ public static NumberProperty getInstance(Double num) { - return (NumberProperty)cache.fetch( + return (NumberProperty)CACHE.fetch( new NumberProperty(num.doubleValue())); } @@ -155,7 +155,7 @@ public final class NumberProperty extends Property implements Numeric { * @return the canonical NumberProperty */ public static NumberProperty getInstance(Integer num) { - return (NumberProperty)cache.fetch( + return (NumberProperty)CACHE.fetch( new NumberProperty(num.intValue())); } @@ -166,7 +166,7 @@ public final class NumberProperty extends Property implements Numeric { * @return the canonical NumberProperty */ public static NumberProperty getInstance(double num) { - return (NumberProperty)cache.fetch( + return (NumberProperty)CACHE.fetch( new NumberProperty(num)); } @@ -177,7 +177,7 @@ public final class NumberProperty extends Property implements Numeric { * @return the canonical NumberProperty */ public static NumberProperty getInstance(int num) { - return (NumberProperty)cache.fetch( + return (NumberProperty)CACHE.fetch( new NumberProperty(num)); } diff --git a/src/java/org/apache/fop/fo/properties/StringProperty.java b/src/java/org/apache/fop/fo/properties/StringProperty.java index ab4544c0a..9bbe33070 100644 --- a/src/java/org/apache/fop/fo/properties/StringProperty.java +++ b/src/java/org/apache/fop/fo/properties/StringProperty.java @@ -21,11 +21,6 @@ package org.apache.fop.fo.properties; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.FOValidationEventProducer; -import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.expr.PropertyException; - -import java.util.Set; /** * Exists primarily as a container for its Maker inner class, which is @@ -83,7 +78,7 @@ public final class StringProperty extends Property { } /** cache containing all canonical StringProperty instances */ - private static final PropertyCache cache // CSOK: ConstantName + private static final PropertyCache CACHE = new PropertyCache(StringProperty.class); /** canonical instance for empty strings */ @@ -109,7 +104,7 @@ public final class StringProperty extends Property { if ("".equals(str) || str == null) { return EMPTY_STRING_PROPERTY; } else { - return (StringProperty)cache.fetch( + return (StringProperty)CACHE.fetch( new StringProperty(str)); } } diff --git a/src/java/org/apache/fop/fonts/FontSetup.java b/src/java/org/apache/fop/fonts/FontSetup.java index 7ceef5a9c..1f49f7bb5 100644 --- a/src/java/org/apache/fop/fonts/FontSetup.java +++ b/src/java/org/apache/fop/fonts/FontSetup.java @@ -25,8 +25,6 @@ import java.util.List; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.fop.fonts.base14.Courier; import org.apache.fop.fonts.base14.CourierBold; import org.apache.fop.fonts.base14.CourierBoldOblique; @@ -56,12 +54,6 @@ public final class FontSetup { private FontSetup() { } - /** - * logging instance - */ - private static Log log // CSOK: ConstantName - = LogFactory.getLog(FontSetup.class); - /** * Sets up a font info * @param fontInfo font info diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java index a6fbdd49c..b8bbc0c6c 100644 --- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java @@ -21,6 +21,7 @@ package org.apache.fop.layoutmgr; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.fo.Constants; import org.apache.fop.traits.MinOptMax; @@ -30,8 +31,7 @@ import org.apache.fop.traits.MinOptMax; */ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(BalancingColumnBreakingAlgorithm.class); + private static final Log LOG = LogFactory.getLog(BalancingColumnBreakingAlgorithm.class); private int columnCount; private int fullLen; @@ -74,8 +74,8 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { protected double computeDemerits(KnuthNode activeNode, KnuthElement element, int fitnessClass, double r) { double dem = super.computeDemerits(activeNode, element, fitnessClass, r); - if (log.isTraceEnabled()) { - log.trace("original demerit=" + dem + " " + totalWidth + if (LOG.isTraceEnabled()) { + LOG.trace("original demerit=" + dem + " " + totalWidth + " line=" + activeNode.line + "/" + columnCount + " pos=" + activeNode.position + "/" + (par.size() - 1)); } @@ -91,13 +91,13 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { if (remParts > 0) { avgRestLen = restLen / remParts; } - if (log.isTraceEnabled()) { - log.trace("remaining parts: " + remParts + " rest len: " + restLen + if (LOG.isTraceEnabled()) { + LOG.trace("remaining parts: " + remParts + " rest len: " + restLen + " avg=" + avgRestLen); } double balance = (idealPartLen - partLen) / 1000f; - if (log.isTraceEnabled()) { - log.trace("balance=" + balance); + if (LOG.isTraceEnabled()) { + LOG.trace("balance=" + balance); } double absBalance = Math.abs(balance); dem = absBalance; @@ -120,8 +120,8 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { //We don't want more columns than available dem = Double.MAX_VALUE; } - if (log.isTraceEnabled()) { - log.trace("effective dem=" + dem + " " + totalWidth); + if (LOG.isTraceEnabled()) { + LOG.trace("effective dem=" + dem + " " + totalWidth); } return dem; } diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java index 1a31f8d49..2acf67c1f 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java @@ -67,14 +67,12 @@ import org.apache.fop.fo.pagination.SideRegion; import org.apache.fop.fo.pagination.StaticContent; import org.apache.fop.fo.pagination.Title; import org.apache.fop.layoutmgr.inline.BasicLinkLayoutManager; -import org.apache.fop.layoutmgr.inline.BidiLayoutManager; import org.apache.fop.layoutmgr.inline.CharacterLayoutManager; import org.apache.fop.layoutmgr.inline.ContentLayoutManager; import org.apache.fop.layoutmgr.inline.ExternalGraphicLayoutManager; import org.apache.fop.layoutmgr.inline.FootnoteLayoutManager; import org.apache.fop.layoutmgr.inline.ICLayoutManager; import org.apache.fop.layoutmgr.inline.InlineLayoutManager; -import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager; import org.apache.fop.layoutmgr.inline.InstreamForeignObjectLM; import org.apache.fop.layoutmgr.inline.LeaderLayoutManager; import org.apache.fop.layoutmgr.inline.PageNumberCitationLastLayoutManager; @@ -93,8 +91,7 @@ import org.apache.fop.util.CharUtilities; public class LayoutManagerMapping implements LayoutManagerMaker { /** logging instance */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(LayoutManagerMapping.class); + private static final Log LOG = LogFactory.getLog(LayoutManagerMapping.class); /** The map of LayoutManagerMakers */ private Map makers = new HashMap(); @@ -159,10 +156,10 @@ public class LayoutManagerMapping implements LayoutManagerMaker { Maker maker = (Maker) makers.get(node.getClass()); if (maker == null) { if (FOElementMapping.URI.equals(node.getNamespaceURI())) { - log.error("No LayoutManager maker for class " + node.getClass()); + LOG.error("No LayoutManager maker for class " + node.getClass()); } else { - if (log.isDebugEnabled()) { - log.debug("Skipping the creation of a layout manager for " + node.getClass()); + if (LOG.isDebugEnabled()) { + LOG.debug("Skipping the creation of a layout manager for " + node.getClass()); } } } else { diff --git a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java index c49bb2d9a..6890d4ebc 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java @@ -35,8 +35,7 @@ import org.apache.fop.traits.MinOptMax; public final class SpaceResolver { /** Logger instance */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(SpaceResolver.class); + private static final Log LOG = LogFactory.getLog(SpaceResolver.class); private UnresolvedListElementWithLength[] firstPart; private BreakElement breakPoss; @@ -94,25 +93,25 @@ public final class SpaceResolver { //Add pending elements from higher level FOs if (breakPoss != null) { if (breakPoss.getPendingAfterMarks() != null) { - if (log.isTraceEnabled()) { - log.trace(" adding pending before break: " + if (LOG.isTraceEnabled()) { + LOG.trace(" adding pending before break: " + breakPoss.getPendingAfterMarks()); } first.addAll(0, breakPoss.getPendingAfterMarks()); } if (breakPoss.getPendingBeforeMarks() != null) { - if (log.isTraceEnabled()) { - log.trace(" adding pending after break: " + if (LOG.isTraceEnabled()) { + LOG.trace(" adding pending after break: " + breakPoss.getPendingBeforeMarks()); } second.addAll(0, breakPoss.getPendingBeforeMarks()); } } - if (log.isTraceEnabled()) { - log.trace("before: " + first); - log.trace(" break: " + breakPoss); - log.trace("after: " + second); - log.trace("NO-BREAK: " + toString(noBreak, noBreakLengths)); + if (LOG.isTraceEnabled()) { + LOG.trace("before: " + first); + LOG.trace(" break: " + breakPoss); + LOG.trace("after: " + second); + LOG.trace("NO-BREAK: " + toString(noBreak, noBreakLengths)); } if (first != null) { @@ -164,15 +163,15 @@ public final class SpaceResolver { if (elems[effIndex] instanceof BorderOrPaddingElement) { BorderOrPaddingElement bop = (BorderOrPaddingElement)elems[effIndex]; if (bop.isConditional() && !(bop.isFirst() || bop.isLast())) { - if (log.isDebugEnabled()) { - log.debug("Nulling conditional element: " + bop); + if (LOG.isDebugEnabled()) { + LOG.debug("Nulling conditional element: " + bop); } lengths[effIndex] = null; } } } - if (log.isTraceEnabled() && elems.length > 0) { - log.trace("-->Resulting list: " + toString(elems, lengths)); + if (LOG.isTraceEnabled() && elems.length > 0) { + LOG.trace("-->Resulting list: " + toString(elems, lengths)); } } @@ -194,20 +193,20 @@ public final class SpaceResolver { } else if (!elems[effIndex].isConditional()) { break; } - if (log.isDebugEnabled()) { - log.debug("Nulling conditional element using 4.3.1, rule 1: " + elems[effIndex]); + if (LOG.isDebugEnabled()) { + LOG.debug("Nulling conditional element using 4.3.1, rule 1: " + elems[effIndex]); } lengths[effIndex] = null; } - if (log.isTraceEnabled() && elems.length > 0) { - log.trace("-->Resulting list: " + toString(elems, lengths)); + if (LOG.isTraceEnabled() && elems.length > 0) { + LOG.trace("-->Resulting list: " + toString(elems, lengths)); } } private void performSpaceResolutionRules2to3(UnresolvedListElement[] elems, MinOptMax[] lengths, int start, int end) { - if (log.isTraceEnabled()) { - log.trace("rule 2-3: " + start + "-" + end); + if (LOG.isTraceEnabled()) { + LOG.trace("rule 2-3: " + start + "-" + end); } SpaceElement space; int remaining; @@ -236,8 +235,8 @@ public final class SpaceResolver { } space = (SpaceElement)elems[i]; if (!space.isForcing()) { - if (log.isDebugEnabled()) { - log.debug("Nulling non-forcing space-specifier using 4.3.1, rule 2: " + if (LOG.isDebugEnabled()) { + LOG.debug("Nulling non-forcing space-specifier using 4.3.1, rule 2: " + elems[i]); } lengths[i] = null; @@ -256,8 +255,8 @@ public final class SpaceResolver { space = (SpaceElement)elems[i]; highestPrecedence = Math.max(highestPrecedence, space.getPrecedence()); } - if (highestPrecedence != 0 && log.isDebugEnabled()) { - log.debug("Highest precedence is " + highestPrecedence); + if (highestPrecedence != 0 && LOG.isDebugEnabled()) { + LOG.debug("Highest precedence is " + highestPrecedence); } //Suppress space-specifiers with lower precedence remaining = 0; @@ -268,8 +267,8 @@ public final class SpaceResolver { } space = (SpaceElement)elems[i]; if (space.getPrecedence() != highestPrecedence) { - if (log.isDebugEnabled()) { - log.debug("Nulling space-specifier with precedence " + if (LOG.isDebugEnabled()) { + LOG.debug("Nulling space-specifier with precedence " + space.getPrecedence() + " using 4.3.1, rule 3: " + elems[i]); } @@ -279,8 +278,8 @@ public final class SpaceResolver { remaining++; } } - if (log.isDebugEnabled()) { - log.debug("Greatest optimum: " + greatestOptimum); + if (LOG.isDebugEnabled()) { + LOG.debug("Greatest optimum: " + greatestOptimum); } if (remaining <= 1) { return; @@ -293,8 +292,8 @@ public final class SpaceResolver { } space = (SpaceElement)elems[i]; if (space.getLength().getOpt() < greatestOptimum) { - if (log.isDebugEnabled()) { - log.debug("Nulling space-specifier with smaller optimum length " + if (LOG.isDebugEnabled()) { + LOG.debug("Nulling space-specifier with smaller optimum length " + "using 4.3.1, rule 3: " + elems[i]); } @@ -317,8 +316,8 @@ public final class SpaceResolver { min = Math.max(min, space.getLength().getMin()); max = Math.min(max, space.getLength().getMax()); if (remaining > 1) { - if (log.isDebugEnabled()) { - log.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: " + if (LOG.isDebugEnabled()) { + LOG.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: " + elems[i]); } lengths[i] = null; @@ -328,9 +327,9 @@ public final class SpaceResolver { } } - if (log.isTraceEnabled() && elems.length > 0) { - log.trace("Remaining spaces: " + remaining); - log.trace("-->Resulting list: " + toString(elems, lengths)); + if (LOG.isTraceEnabled() && elems.length > 0) { + LOG.trace("Remaining spaces: " + remaining); + LOG.trace("-->Resulting list: " + toString(elems, lengths)); } } @@ -390,7 +389,7 @@ public final class SpaceResolver { if (hasFirstPart()) { //Now that we've handled isFirst/isLast conditions, we need to look at the //active part in its normal order so swap it back. - log.trace("Swapping first and second parts."); + LOG.trace("Swapping first and second parts."); UnresolvedListElementWithLength[] tempList; MinOptMax[] tempLengths; tempList = secondPart; @@ -598,8 +597,8 @@ public final class SpaceResolver { * @param elems the element list */ public static void resolveElementList(List elems) { - if (log.isTraceEnabled()) { - log.trace(elems); + if (LOG.isTraceEnabled()) { + LOG.trace(elems); } boolean first = true; boolean last = false; @@ -611,8 +610,8 @@ public final class SpaceResolver { while (iter.hasNext()) { ListElement el = (ListElement)iter.next(); if (el.isUnresolvedElement()) { - if (log.isTraceEnabled()) { - log.trace("unresolved found: " + el + " " + first + "/" + last); + if (LOG.isTraceEnabled()) { + LOG.trace("unresolved found: " + el + " " + first + "/" + last); } BreakElement breakPoss = null; //Clear temp lists @@ -649,7 +648,7 @@ public final class SpaceResolver { } //last = !iter.hasNext(); if (breakPoss == null && unresolvedSecond.size() == 0 && !last) { - log.trace("Swap first and second parts in no-break condition," + LOG.trace("Swap first and second parts in no-break condition," + " second part is empty."); //The first list is reversed, so swap if this shouldn't happen List swapList = unresolvedSecond; @@ -657,7 +656,7 @@ public final class SpaceResolver { unresolvedFirst = swapList; } - log.debug("----start space resolution (first=" + first + ", last=" + last + ")..."); + LOG.debug("----start space resolution (first=" + first + ", last=" + last + ")..."); SpaceResolver resolver = new SpaceResolver( unresolvedFirst, breakPoss, unresolvedSecond, first, last); if (!last) { @@ -667,7 +666,7 @@ public final class SpaceResolver { if (!last && skipNextElement) { iter.next(); } - log.debug("----end space resolution."); + LOG.debug("----end space resolution."); } first = false; } diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java index 800850177..6039ad941 100644 --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -45,8 +45,7 @@ public final class TraitSetter { } /** logger */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(TraitSetter.class); + private static final Log LOG = LogFactory.getLog(TraitSetter.class); /** * Sets border and padding traits on areas. @@ -343,7 +342,7 @@ public final class TraitSetter { + backProps.backgroundPositionHorizontal.getValue(refContext)); } else { // TODO Area IPD has to be set for this to work - log.warn("Horizontal background image positioning ignored" + LOG.warn("Horizontal background image positioning ignored" + " because the IPD was not set on the area." + " (Yes, it's a bug in FOP)"); } @@ -360,7 +359,7 @@ public final class TraitSetter { + backProps.backgroundPositionVertical.getValue(refContext)); } else { // TODO Area BPD has to be set for this to work - log.warn("Vertical background image positioning ignored" + LOG.warn("Vertical background image positioning ignored" + " because the BPD was not set on the area." + " (Yes, it's a bug in FOP)"); } @@ -411,7 +410,7 @@ public final class TraitSetter { back.setHoriz(horizontal); } else { //TODO Area IPD has to be set for this to work - log.warn("Horizontal background image positioning ignored" + LOG.warn("Horizontal background image positioning ignored" + " because the IPD was not set on the area." + " (Yes, it's a bug in FOP)"); } @@ -435,7 +434,7 @@ public final class TraitSetter { back.setVertical(vertical); } else { //TODO Area BPD has to be set for this to work - log.warn("Vertical background image positioning ignored" + LOG.warn("Vertical background image positioning ignored" + " because the BPD was not set on the area." + " (Yes, it's a bug in FOP)"); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java index c2dde9f9e..e090fbae6 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java @@ -30,7 +30,6 @@ import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.TraitSetter; diff --git a/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java b/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java index f2664ed1c..467f2e154 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java @@ -21,9 +21,7 @@ package org.apache.fop.layoutmgr.inline; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.datatypes.Length; -import org.apache.fop.datatypes.LengthBase; -import org.apache.fop.datatypes.SimplePercentBaseContext; + import org.apache.fop.fo.Constants; diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java index 3eed124b2..49c97b7b6 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java @@ -23,6 +23,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.layoutmgr.Position; /** @@ -31,8 +32,7 @@ import org.apache.fop.layoutmgr.Position; public class LineLayoutPossibilities { /** logger instance */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(LineLayoutPossibilities.class); + private static final Log LOG = LogFactory.getLog(LineLayoutPossibilities.class); private final class Possibility { private int lineCount; @@ -157,7 +157,7 @@ public class LineLayoutPossibilities { possibilitiesList.set(index, restoredPossibility); } else { // this should not happen - log.error("LineLayoutPossibilities restorePossibilities()," + LOG.error("LineLayoutPossibilities restorePossibilities()," + " min= " + getMinLineCount() + " max= " + getMaxLineCount() + " restored= " + restoredPossibility.getLineCount()); @@ -258,12 +258,12 @@ public class LineLayoutPossibilities { && adj <= (getMaxLineCount() - getChosenLineCount()) && getLineCount(chosenIndex + adj) == getChosenLineCount() + adj) { chosenIndex += adj; - log.debug("chosenLineCount= " + (getChosenLineCount() - adj) + " adjustment= " + adj + LOG.debug("chosenLineCount= " + (getChosenLineCount() - adj) + " adjustment= " + adj + " => chosenLineCount= " + getLineCount(chosenIndex)); return adj; } else { // this should not happen! - log.warn("Cannot apply the desired line count adjustment."); + LOG.warn("Cannot apply the desired line count adjustment."); return 0; } } diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java index 62041e888..b9f786c97 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java @@ -25,7 +25,6 @@ import org.apache.fop.area.inline.TextArea; import org.apache.fop.area.inline.UnresolvedPageNumber; import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.LayoutManager; /** * LayoutManager for the fo:page-number-citation formatting object diff --git a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java index a2a1dce27..19a1a1f8a 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java @@ -19,8 +19,6 @@ package org.apache.fop.layoutmgr.inline; -import org.apache.fop.datatypes.Length; - /** * The FOP specific incarnation of the XSL-FO scaled baseline table. * All baseline tables are scaled to the font size of the font they diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 1a3297ad5..db5b4736c 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -55,8 +55,7 @@ import org.apache.fop.util.BreakUtil; public class TableContentLayoutManager implements PercentBaseContext { /** Logger **/ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(TableContentLayoutManager.class); + private static final Log LOG = LogFactory.getLog(TableContentLayoutManager.class); private TableLayoutManager tableLM; private TableRowIterator bodyIter; @@ -138,8 +137,8 @@ public class TableContentLayoutManager implements PercentBaseContext { * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int) */ public List getNextKnuthElements(LayoutContext context, int alignment) { - if (log.isDebugEnabled()) { - log.debug("==> Columns: " + getTableLM().getColumns()); + if (LOG.isDebugEnabled()) { + LOG.debug("==> Columns: " + getTableLM().getColumns()); } KnuthBox headerAsFirst = null; KnuthBox headerAsSecondToLast = null; @@ -149,8 +148,8 @@ public class TableContentLayoutManager implements PercentBaseContext { headerIter, context, alignment, TableRowIterator.HEADER); this.headerNetHeight = ElementListUtils.calcContentLength(this.headerList); - if (log.isDebugEnabled()) { - log.debug("==> Header: " + if (LOG.isDebugEnabled()) { + LOG.debug("==> Header: " + headerNetHeight + " - " + this.headerList); } TableHeaderFooterPosition pos = new TableHeaderFooterPosition( @@ -169,8 +168,8 @@ public class TableContentLayoutManager implements PercentBaseContext { footerIter, context, alignment, TableRowIterator.FOOTER); this.footerNetHeight = ElementListUtils.calcContentLength(this.footerList); - if (log.isDebugEnabled()) { - log.debug("==> Footer: " + if (LOG.isDebugEnabled()) { + LOG.debug("==> Footer: " + footerNetHeight + " - " + this.footerList); } //We can simply add the table footer at the end of the whole list @@ -378,14 +377,14 @@ public class TableContentLayoutManager implements PercentBaseContext { } else if (pos instanceof TableContentPosition) { tablePositions.add(pos); } else { - if (log.isDebugEnabled()) { - log.debug("Ignoring position: " + pos); + if (LOG.isDebugEnabled()) { + LOG.debug("Ignoring position: " + pos); } } } if (lastPos instanceof TableHFPenaltyPosition) { TableHFPenaltyPosition penaltyPos = (TableHFPenaltyPosition)lastPos; - log.debug("Break at penalty!"); + LOG.debug("Break at penalty!"); if (penaltyPos.headerElements != null) { //Header positions for the penalty position are in the last element and need to //be handled first before all other TableContentPositions @@ -411,7 +410,7 @@ public class TableContentLayoutManager implements PercentBaseContext { if (tablePositions.isEmpty()) { // TODO make sure this actually never happens - log.error("tablePositions empty." + LOG.error("tablePositions empty." + " Please send your FO file to fop-users@xmlgraphics.apache.org"); } else { // Here we are sure that posIter iterates only over TableContentPosition instances diff --git a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java index 282cd0fd5..35cba6da6 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java @@ -28,8 +28,6 @@ import org.apache.fop.fo.FONode.FONodeIterator; import org.apache.fop.fo.flow.table.EffRow; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; -import org.apache.fop.fo.flow.table.TablePart; - /** * Iterator that lets the table layout manager step over all the rows of a part of the diff --git a/src/java/org/apache/fop/pdf/PDFEmbeddedFile.java b/src/java/org/apache/fop/pdf/PDFEmbeddedFile.java index db9a49271..24a471e1e 100644 --- a/src/java/org/apache/fop/pdf/PDFEmbeddedFile.java +++ b/src/java/org/apache/fop/pdf/PDFEmbeddedFile.java @@ -21,17 +21,11 @@ package org.apache.fop.pdf; import java.util.Date; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * This class represents an embedded file stream. */ public class PDFEmbeddedFile extends PDFStream { - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(PDFEmbeddedFile.class.getName()); - /** * Creates a new embedded file stream. */ diff --git a/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java b/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java index 90b530774..269f0639d 100644 --- a/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java +++ b/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java @@ -21,7 +21,6 @@ package org.apache.fop.pdf; // Java import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.security.InvalidKeyException; import java.security.MessageDigest; diff --git a/src/java/org/apache/fop/pdf/PDFEncryptionManager.java b/src/java/org/apache/fop/pdf/PDFEncryptionManager.java index 60844c588..3f5ae2a3d 100644 --- a/src/java/org/apache/fop/pdf/PDFEncryptionManager.java +++ b/src/java/org/apache/fop/pdf/PDFEncryptionManager.java @@ -37,8 +37,7 @@ public final class PDFEncryptionManager { } /** logging instance */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(PDFEncryptionManager.class); + private static final Log LOG = LogFactory.getLog(PDFEncryptionManager.class); /** * Indicates whether JCE is available. @@ -64,12 +63,12 @@ public final class PDFEncryptionManager { Provider[] providers; providers = Security.getProviders("Cipher.RC4"); if (providers == null) { - log.warn("Cipher provider for RC4 not available."); + LOG.warn("Cipher provider for RC4 not available."); return false; } providers = Security.getProviders("MessageDigest.MD5"); if (providers == null) { - log.warn("MessageDigest provider for MD5 not available."); + LOG.warn("MessageDigest provider for MD5 not available."); return false; } return true; @@ -92,13 +91,13 @@ public final class PDFEncryptionManager { if (params != null) { if (!checkAvailableAlgorithms()) { if (isJCEAvailable()) { - log.warn("PDF encryption has been requested, JCE is " + LOG.warn("PDF encryption has been requested, JCE is " + "available but there's no " + "JCE provider available that provides the " + "necessary algorithms. The PDF won't be " + "encrypted."); } else { - log.warn("PDF encryption has been requested but JCE is " + LOG.warn("PDF encryption has been requested but JCE is " + "unavailable! The PDF won't be encrypted."); } } @@ -123,19 +122,19 @@ public final class PDFEncryptionManager { return (PDFEncryption)obj; } catch (ClassNotFoundException e) { if (checkAvailableAlgorithms()) { - log.warn("JCE and algorithms available, but the " + LOG.warn("JCE and algorithms available, but the " + "implementation class unavailable. Please do a full " + "rebuild."); } return null; } catch (NoSuchMethodException e) { - log.error(e); + LOG.error(e); return null; } catch (IllegalAccessException e) { - log.error(e); + LOG.error(e); return null; } catch (InvocationTargetException e) { - log.error(e); + LOG.error(e); return null; } } diff --git a/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java b/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java index aad31f18e..a03aaf816 100644 --- a/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java +++ b/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java @@ -35,8 +35,7 @@ import org.apache.fop.render.afp.extensions.AFPElementMapping; * Parses any AFP foreign attributes */ public class AFPForeignAttributeReader { - private static final Log log // CSOK: ConstantName - = LogFactory.getLog("org.apache.xmlgraphics.afp"); + private static final Log LOG = LogFactory.getLog("org.apache.xmlgraphics.afp"); /** the resource-name attribute */ public static final QName RESOURCE_NAME = new QName( @@ -95,7 +94,7 @@ public class AFPForeignAttributeReader { = (String)foreignAttributes.get(RESOURCE_GROUP_FILE); if (resourceGroupFile == null) { String msg = RESOURCE_GROUP_FILE + " not specified"; - log.error(msg); + LOG.error(msg); throw new UnsupportedOperationException(msg); } File resourceExternalGroupFile = new File(resourceGroupFile); @@ -107,20 +106,20 @@ public class AFPForeignAttributeReader { } catch (SecurityException ex) { String msg = "unable to gain write access to external resource file: " + resourceGroupFile; - log.error(msg); + LOG.error(msg); } try { boolean exists = resourceExternalGroupFile.exists(); if (exists) { - log.warn("overwriting external resource file: " + LOG.warn("overwriting external resource file: " + resourceGroupFile); } resourceLevel.setExternalFilePath(resourceGroupFile); } catch (SecurityException ex) { String msg = "unable to gain read access to external resource file: " + resourceGroupFile; - log.error(msg); + LOG.error(msg); } } } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java index b14a4eb9d..a82fe3457 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java @@ -19,8 +19,6 @@ package org.apache.fop.render.afp.extensions; -import java.net.URI; - import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; diff --git a/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java b/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java index cd15a9d72..b156b6c3a 100644 --- a/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java +++ b/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java @@ -19,9 +19,6 @@ package org.apache.fop.render.intermediate; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.apache.fop.apps.FOUserAgent; /** @@ -29,9 +26,6 @@ import org.apache.fop.apps.FOUserAgent; */ public abstract class AbstractIFDocumentHandler implements IFDocumentHandler { - /** logging instance */ - private static Log log = LogFactory.getLog(AbstractIFDocumentHandler.class); - private IFContext ifContext; /** diff --git a/src/java/org/apache/fop/render/java2d/Java2DPainter.java b/src/java/org/apache/fop/render/java2d/Java2DPainter.java index a2b9c9613..396645768 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DPainter.java +++ b/src/java/org/apache/fop/render/java2d/Java2DPainter.java @@ -33,9 +33,6 @@ import java.util.Stack; import org.w3c.dom.Document; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; @@ -54,9 +51,6 @@ import org.apache.fop.util.CharUtilities; */ public class Java2DPainter extends AbstractIFPainter { - /** logging instance */ - private static Log log = LogFactory.getLog(Java2DPainter.class); - /** the IF context */ protected IFContext ifContext; diff --git a/src/java/org/apache/fop/render/pcl/HardcodedFonts.java b/src/java/org/apache/fop/render/pcl/HardcodedFonts.java index 429d36167..185e1ece5 100644 --- a/src/java/org/apache/fop/render/pcl/HardcodedFonts.java +++ b/src/java/org/apache/fop/render/pcl/HardcodedFonts.java @@ -34,8 +34,7 @@ final class HardcodedFonts { } /** logging instance */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(HardcodedFonts.class); + private static final Log LOG = LogFactory.getLog(HardcodedFonts.class); /** * Sets the current font (NOTE: Hard-coded font mappings ATM!) @@ -62,7 +61,7 @@ final class HardcodedFonts { try { fontcode = Integer.parseInt(name.substring(1)); } catch (Exception e) { - log.error(e); + LOG.error(e); } } //Note "(ON" selects ISO 8859-1 symbol set as used by PCLGenerator diff --git a/src/java/org/apache/fop/render/pcl/PCLPainter.java b/src/java/org/apache/fop/render/pcl/PCLPainter.java index d0e82ed7d..00b25a5e3 100644 --- a/src/java/org/apache/fop/render/pcl/PCLPainter.java +++ b/src/java/org/apache/fop/render/pcl/PCLPainter.java @@ -34,9 +34,6 @@ import java.util.Stack; import org.w3c.dom.Document; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageProcessingHints; @@ -65,9 +62,6 @@ import org.apache.fop.util.CharUtilities; */ public class PCLPainter extends AbstractIFPainter implements PCLConstants { - /** logging instance */ - private static Log log = LogFactory.getLog(PCLPainter.class); - private static final boolean DEBUG = false; private PCLDocumentHandler parent; diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java index 6c2c592b1..d54973ac8 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java +++ b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java @@ -19,9 +19,6 @@ package org.apache.fop.render.pcl; -import org.apache.xmlgraphics.util.QName; - -import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RendererContext; diff --git a/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java b/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java index 10db33b0f..287f89607 100644 --- a/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java +++ b/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java @@ -37,8 +37,7 @@ import org.apache.fop.util.ColorUtil; public class PDFBorderPainter extends BorderPainter { /** logging instance */ - private static final Log log // CSOK: ConstantName - = LogFactory.getLog(PDFBorderPainter.class); + private static final Log LOG = LogFactory.getLog(PDFBorderPainter.class); private PDFContentGenerator generator; @@ -70,7 +69,7 @@ public class PDFBorderPainter extends BorderPainter { float w = x2 - x1; float h = y2 - y1; if ((w < 0) || (h < 0)) { - log.error("Negative extent received (w=" + w + ", h=" + h + LOG.error("Negative extent received (w=" + w + ", h=" + h + "). Border won't be painted."); return; } diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java index 5cc1a1b01..66b26fb33 100644 --- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java +++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java @@ -30,8 +30,6 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; import org.apache.batik.gvt.GraphicsNode; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; import org.apache.xmlgraphics.ps.PSGenerator; @@ -57,9 +55,6 @@ import org.apache.fop.svg.SVGUserAgent; public class PSSVGHandler extends AbstractGenericSVGHandler implements PSRendererContextConstants { - /** logging instance */ - private static Log log = LogFactory.getLog(PSSVGHandler.class); - /** * Create a new PostScript XML handler for use by the PostScript renderer. */ diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java index f44199bee..13748a3bf 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java @@ -26,9 +26,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; * the FOP project. */ -import java.io.Writer; import java.io.IOException; -import java.util.Date; +import java.io.Writer; import java.util.Random; /** diff --git a/src/sandbox/org/apache/fop/render/svg/SVGPainter.java b/src/sandbox/org/apache/fop/render/svg/SVGPainter.java index 2477099a4..bcc3a6913 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGPainter.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGPainter.java @@ -34,17 +34,14 @@ import org.w3c.dom.Document; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; import org.apache.xmlgraphics.xmp.Metadata; -import org.apache.fop.apps.MimeConstants; import org.apache.fop.ResourceEventProducer; +import org.apache.fop.apps.MimeConstants; import org.apache.fop.render.ImageHandlerUtil; import org.apache.fop.render.RenderingContext; import org.apache.fop.render.intermediate.AbstractIFPainter; @@ -64,9 +61,6 @@ import org.apache.fop.util.XMLUtil; */ public class SVGPainter extends AbstractIFPainter implements SVGConstants { - /** logging instance */ - private static Log log = LogFactory.getLog(SVGPainter.class); - private AbstractSVGDocumentHandler parent; /** The SAX content handler that receives the generated XML events. */ diff --git a/test/java/org/apache/fop/GenericFOPTestCase.java b/test/java/org/apache/fop/GenericFOPTestCase.java index 26053cdad..5b51a34e1 100644 --- a/test/java/org/apache/fop/GenericFOPTestCase.java +++ b/test/java/org/apache/fop/GenericFOPTestCase.java @@ -31,12 +31,13 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.apache.fop.apps.Fop; +import org.xml.sax.InputSource; + import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; import org.apache.fop.util.DigestFilter; -import org.xml.sax.InputSource; /** * Framework for simple regression testing. @@ -76,8 +77,8 @@ public final class GenericFOPTestCase extends TestCase { public void testSimple() throws Exception { final String digestIn = "17bf13298796065f7775db8707133aeb"; final String digestOut = "e2761f51152f6663911e567901596707"; - final String fo = - "" + final String fo + = "" + " " + " " @@ -118,8 +119,8 @@ public final class GenericFOPTestCase extends TestCase { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); foUserAgent.setCreationDate(new Date(10000)); MessageDigest outDigest = MessageDigest.getInstance("MD5"); - DigestOutputStream out = - new DigestOutputStream(new ByteArrayOutputStream(), outDigest); + DigestOutputStream out + = new DigestOutputStream(new ByteArrayOutputStream(), outDigest); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); InputSource source = new InputSource(new StringReader(fo)); DigestFilter filter = new DigestFilter("MD5"); diff --git a/test/java/org/apache/fop/config/BaseUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseUserConfigTestCase.java index 5c803317e..6ce833312 100644 --- a/test/java/org/apache/fop/config/BaseUserConfigTestCase.java +++ b/test/java/org/apache/fop/config/BaseUserConfigTestCase.java @@ -100,7 +100,7 @@ public abstract class BaseUserConfigTestCase extends BasePDFTestCase { /** * @return user config File */ - abstract protected String getUserConfigFilename(); + protected abstract String getUserConfigFilename(); /* * @see junit.framework.TestCase#getName() diff --git a/test/java/org/apache/fop/events/EventChecker.java b/test/java/org/apache/fop/events/EventChecker.java index 767c590ed..afef11d87 100644 --- a/test/java/org/apache/fop/events/EventChecker.java +++ b/test/java/org/apache/fop/events/EventChecker.java @@ -40,7 +40,7 @@ class EventChecker extends Assert implements EventListener { if (event.getEventID().equals(expectedEventID)) { eventReceived = true; } else { - fail("Unexpected event: id = " + event.getEventID() + ": "+ msg); + fail("Unexpected event: id = " + event.getEventID() + ": " + msg); } } diff --git a/test/java/org/apache/fop/memory/Stats.java b/test/java/org/apache/fop/memory/Stats.java index 9e371251d..354952347 100644 --- a/test/java/org/apache/fop/memory/Stats.java +++ b/test/java/org/apache/fop/memory/Stats.java @@ -71,7 +71,7 @@ class Stats { public void dumpFinalStats() { long duration = System.currentTimeMillis() - startTime; System.out.println("Final statistics"); - System.out.println("Pages produced: " +totalPagesProduced); + System.out.println("Pages produced: " + totalPagesProduced); long ppm = 60000 * totalPagesProduced / duration; System.out.println("Average speed: " + ppm + "ppm"); } diff --git a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java index f5d2f84cf..bd5c8ade1 100644 --- a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java @@ -27,38 +27,38 @@ import org.apache.fop.pdf.CMapBuilder; /** Simple sanity test of the PDFCmap class */ public class PDFCMapTestCase extends TestCase { + private static final String EOL = "\n"; public void testPDFCMapFillInPDF() throws Exception { - final String EOL = "\n"; - final String expected = - "%!PS-Adobe-3.0 Resource-CMap" + EOL - +"%%DocumentNeededResources: ProcSet (CIDInit)" + EOL - +"%%IncludeResource: ProcSet (CIDInit)" + EOL - +"%%BeginResource: CMap (test)" + EOL - +"%%EndComments" + EOL - +"/CIDInit /ProcSet findresource begin" + EOL - +"12 dict begin" + EOL - +"begincmap" + EOL - +"/CIDSystemInfo 3 dict dup begin" + EOL - +" /Registry (Adobe) def" + EOL - +" /Ordering (Identity) def" + EOL - +" /Supplement 0 def" + EOL - +"end def" + EOL - +"/CMapVersion 1 def" + EOL - +"/CMapType 1 def" + EOL - +"/CMapName /test def" + EOL - +"1 begincodespacerange" + EOL - +"<0000> " + EOL - +"endcodespacerange" + EOL - +"1 begincidrange" + EOL - +"<0000> 0" + EOL - +"endcidrange" + EOL - +"endcmap" + EOL - +"CMapName currentdict /CMap defineresource pop" + EOL - +"end" + EOL - +"end" + EOL - +"%%EndResource" + EOL - +"%%EOF" + EOL + final String expected + = "%!PS-Adobe-3.0 Resource-CMap" + EOL + + "%%DocumentNeededResources: ProcSet (CIDInit)" + EOL + + "%%IncludeResource: ProcSet (CIDInit)" + EOL + + "%%BeginResource: CMap (test)" + EOL + + "%%EndComments" + EOL + + "/CIDInit /ProcSet findresource begin" + EOL + + "12 dict begin" + EOL + + "begincmap" + EOL + + "/CIDSystemInfo 3 dict dup begin" + EOL + + " /Registry (Adobe) def" + EOL + + " /Ordering (Identity) def" + EOL + + " /Supplement 0 def" + EOL + + "end def" + EOL + + "/CMapVersion 1 def" + EOL + + "/CMapType 1 def" + EOL + + "/CMapName /test def" + EOL + + "1 begincodespacerange" + EOL + + "<0000> " + EOL + + "endcodespacerange" + EOL + + "1 begincidrange" + EOL + + "<0000> 0" + EOL + + "endcidrange" + EOL + + "endcmap" + EOL + + "CMapName currentdict /CMap defineresource pop" + EOL + + "end" + EOL + + "end" + EOL + + "%%EndResource" + EOL + + "%%EOF" + EOL ; final StringWriter w = new StringWriter(); diff --git a/test/java/org/apache/fop/util/DigestFilter.java b/test/java/org/apache/fop/util/DigestFilter.java index 0384b42df..94e8d67d2 100644 --- a/test/java/org/apache/fop/util/DigestFilter.java +++ b/test/java/org/apache/fop/util/DigestFilter.java @@ -43,7 +43,7 @@ import org.xml.sax.helpers.XMLFilterImpl; public class DigestFilter extends XMLFilterImpl { private MessageDigest digest; - private byte value[]; + private byte[] value; private boolean isNamespaceAware; public DigestFilter(String algorithm) throws NoSuchAlgorithmException { @@ -133,7 +133,7 @@ public class DigestFilter extends XMLFilterImpl { */ public void setFeature(String feature, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { - if(feature.equals("http://xml.org/sax/features/namespaces")) { + if (feature.equals("http://xml.org/sax/features/namespaces")) { isNamespaceAware = value; } super.setFeature(feature, value); -- cgit v1.2.3 From 0f58f09a9af76099cc5c0858557b558e09b0f093 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Fri, 27 Aug 2010 13:23:11 +0000 Subject: Fixed indentation git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@990144 13f79535-47bb-0310-9956-ffa450edef68 --- .../BalancingColumnBreakingAlgorithm.java | 4 +- .../apache/fop/layoutmgr/BreakingAlgorithm.java | 20 ++--- .../fop/layoutmgr/inline/LineLayoutManager.java | 20 ++--- .../fop/layoutmgr/inline/TextLayoutManager.java | 8 +- .../org/apache/fop/layoutmgr/table/CellPart.java | 4 +- .../layoutmgr/table/TableCellLayoutManager.java | 8 +- src/java/org/apache/fop/pdf/PDFCIDFont.java | 8 +- src/java/org/apache/fop/pdf/PDFFactory.java | 90 +++++++++++----------- src/java/org/apache/fop/pdf/PDFFontDescriptor.java | 10 +-- src/java/org/apache/fop/pdf/PDFFunction.java | 10 +-- src/java/org/apache/fop/pdf/PDFPattern.java | 12 +-- src/java/org/apache/fop/pdf/PDFShading.java | 46 +++++------ .../fop/render/AbstractPathOrientedRenderer.java | 26 +++---- src/java/org/apache/fop/render/afp/AFPPainter.java | 10 +-- .../fop/render/intermediate/BorderPainter.java | 6 +- .../apache/fop/render/intermediate/IFRenderer.java | 8 +- .../fop/render/java2d/Java2DBorderPainter.java | 4 +- .../apache/fop/render/java2d/Java2DRenderer.java | 4 +- src/java/org/apache/fop/render/pcl/PCLPainter.java | 10 +-- .../apache/fop/render/pdf/PDFBorderPainter.java | 14 ++-- .../org/apache/fop/render/ps/PSBorderPainter.java | 14 ++-- src/java/org/apache/fop/render/ps/PSPainter.java | 8 +- .../org/apache/fop/render/txt/TXTRenderer.java | 6 +- src/java/org/apache/fop/util/ColorExt.java | 8 +- 24 files changed, 179 insertions(+), 179 deletions(-) (limited to 'src/java/org/apache/fop/render/java2d') diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java index b8bbc0c6c..0eae6fa9c 100644 --- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java @@ -55,8 +55,8 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { * @param columnCount number of columns * @see PageBreakingAlgorithm */ - public BalancingColumnBreakingAlgorithm // CSOK: ParameterNumber - (LayoutManager topLevelLM, + public BalancingColumnBreakingAlgorithm( // CSOK: ParameterNumber + LayoutManager topLevelLM, PageProvider pageProvider, PageBreakingLayoutListener layoutListener, int alignment, int alignmentLast, diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java index f8d78d477..15f8ffa8d 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java @@ -285,11 +285,11 @@ public abstract class BreakingAlgorithm { * @param totalDemerits a real number * @param previous a node */ - public KnuthNode // CSOK: ParameterNumber - (int position, int line, int fitness, - int totalWidth, int totalStretch, int totalShrink, - double adjustRatio, int availableShrink, int availableStretch, - int difference, double totalDemerits, KnuthNode previous) { + public KnuthNode( // CSOK: ParameterNumber + int position, int line, int fitness, + int totalWidth, int totalStretch, int totalShrink, + double adjustRatio, int availableShrink, int availableStretch, + int difference, double totalDemerits, KnuthNode previous) { this.position = position; this.line = line; this.fitness = fitness; @@ -671,11 +671,11 @@ public abstract class BreakingAlgorithm { * @param previous active node for the preceding breakpoint * @return a new node */ - protected KnuthNode createNode // CSOK: ParameterNumber - (int position, int line, int fitness, - int totalWidth, int totalStretch, int totalShrink, - double adjustRatio, int availableShrink, int availableStretch, - int difference, double totalDemerits, KnuthNode previous) { + protected KnuthNode createNode( // CSOK: ParameterNumber + int position, int line, int fitness, + int totalWidth, int totalStretch, int totalShrink, + double adjustRatio, int availableShrink, int availableStretch, + int difference, double totalDemerits, KnuthNode previous) { return new KnuthNode(position, line, fitness, totalWidth, totalStretch, totalShrink, adjustRatio, availableShrink, availableStretch, diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 7e87de241..8332c9462 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -132,10 +132,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager private int spaceAfter; private int baseline; - LineBreakPosition // CSOK: ParameterNumber - (LayoutManager lm, int index, int startIndex, int breakIndex, - int shrink, int stretch, int diff, double ipdA, double adjust, int ind, - int lh, int lw, int sb, int sa, int bl) { + LineBreakPosition( // CSOK: ParameterNumber + LayoutManager lm, int index, int startIndex, int breakIndex, + int shrink, int stretch, int diff, double ipdA, double adjust, int ind, + int lh, int lw, int sb, int sa, int bl) { super(lm, breakIndex); availableShrink = shrink; availableStretch = stretch; @@ -331,9 +331,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager private int follow; private static final double MAX_DEMERITS = 10e6; - public LineBreakingAlgorithm // CSOK: ParameterNumber - (int pageAlign, int textAlign, int textAlignLast, int indent, int fillerWidth, - int lh, int ld, int fl, boolean first, int maxFlagCount, LineLayoutManager llm) { + public LineBreakingAlgorithm( // CSOK: ParameterNumber + int pageAlign, int textAlign, int textAlignLast, int indent, int fillerWidth, + int lh, int ld, int fl, boolean first, int maxFlagCount, LineLayoutManager llm) { super(textAlign, textAlignLast, first, false, maxFlagCount); pageAlignment = pageAlign; textIndent = indent; @@ -410,9 +410,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager activePossibility = -1; } - private LineBreakPosition makeLineBreakPosition // CSOK: ParameterNumber - (KnuthSequence par, int firstElementIndex, int lastElementIndex, int availableShrink, - int availableStretch, int difference, double ratio, int indent) { + private LineBreakPosition makeLineBreakPosition( // CSOK: ParameterNumber + KnuthSequence par, int firstElementIndex, int lastElementIndex, int availableShrink, + int availableStretch, int difference, double ratio, int indent) { // line height calculation - spaceBefore may differ from spaceAfter // by 1mpt due to rounding int spaceBefore = (lineHeight - lead - follow) / 2; diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index 4c45fbe66..cbe2e2639 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -81,10 +81,10 @@ public class TextLayoutManager extends LeafNodeLayoutManager { private boolean breakOppAfter; private final Font font; - AreaInfo // CSOK: ParameterNumber - (int startIndex, int breakIndex, int wordSpaceCount, int letterSpaceCount, - MinOptMax areaIPD, boolean isHyphenated, boolean isSpace, boolean breakOppAfter, - Font font) { + AreaInfo( // CSOK: ParameterNumber + int startIndex, int breakIndex, int wordSpaceCount, int letterSpaceCount, + MinOptMax areaIPD, boolean isHyphenated, boolean isSpace, boolean breakOppAfter, + Font font) { assert startIndex <= breakIndex; this.startIndex = startIndex; this.breakIndex = breakIndex; diff --git a/src/java/org/apache/fop/layoutmgr/table/CellPart.java b/src/java/org/apache/fop/layoutmgr/table/CellPart.java index 8af3a3d43..cde19e67b 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CellPart.java +++ b/src/java/org/apache/fop/layoutmgr/table/CellPart.java @@ -61,8 +61,8 @@ class CellPart { * @param bpAfterLast width of (possibly optional) border- and padding-after if this * part will be the last one on the page */ - protected CellPart // CSOK: ParameterNumber - (PrimaryGridUnit pgu, int start, int end, boolean last, + protected CellPart( // CSOK: ParameterNumber + PrimaryGridUnit pgu, int start, int end, boolean last, int condBeforeContentLength, int length, int condAfterContentLength, int bpBeforeNormal, int bpBeforeFirst, int bpAfterNormal, int bpAfterLast) { diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index 5fb733a51..ded18384d 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -277,10 +277,10 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager * this row is placed on a previous page). Used to calculate the placement of the * row's background image if any */ - public void addAreas // CSOK: ParameterNumber - (PositionIterator parentIter, LayoutContext layoutContext, int[] spannedGridRowHeights, - int startRow, int endRow, int borderBeforeWhich, int borderAfterWhich, boolean firstOnPage, - boolean lastOnPage, RowPainter painter, int firstRowHeight) { + public void addAreas( // CSOK: ParameterNumber + PositionIterator parentIter, LayoutContext layoutContext, int[] spannedGridRowHeights, + int startRow, int endRow, int borderBeforeWhich, int borderAfterWhich, + boolean firstOnPage, boolean lastOnPage, RowPainter painter, int firstRowHeight) { getParentArea(null); addId(); diff --git a/src/java/org/apache/fop/pdf/PDFCIDFont.java b/src/java/org/apache/fop/pdf/PDFCIDFont.java index 9a91dd992..459fe2584 100644 --- a/src/java/org/apache/fop/pdf/PDFCIDFont.java +++ b/src/java/org/apache/fop/pdf/PDFCIDFont.java @@ -56,10 +56,10 @@ public class PDFCIDFont extends PDFObject { * @param supplement Supplement number * @param descriptor CID font descriptor */ - public PDFCIDFont // CSOK: ParameterNumber - (String basefont, CIDFontType cidtype, int dw, - int[] w, String registry, String ordering, - int supplement, PDFCIDFontDescriptor descriptor) { + public PDFCIDFont( // CSOK: ParameterNumber + String basefont, CIDFontType cidtype, int dw, + int[] w, String registry, String ordering, + int supplement, PDFCIDFontDescriptor descriptor) { this(basefont, cidtype, dw, new PDFWArray(w), diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index 8ebd15127..752d14207 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -292,13 +292,13 @@ public class PDFFactory { * It should be 0 as this is the constructor for sampled functions. * @return the PDF function that was created */ - public PDFFunction makeFunction // CSOK: ParameterNumber - (int theFunctionType, List theDomain, - List theRange, List theSize, - int theBitsPerSample, int theOrder, - List theEncode, List theDecode, - StringBuffer theFunctionDataStream, - List theFilter) { + public PDFFunction makeFunction( // CSOK: ParameterNumber + int theFunctionType, List theDomain, + List theRange, List theSize, + int theBitsPerSample, int theOrder, + List theEncode, List theDecode, + StringBuffer theFunctionDataStream, + List theFilter) { // Type 0 function PDFFunction function = new PDFFunction(theFunctionType, theDomain, theRange, theSize, @@ -466,13 +466,13 @@ public class PDFFactory { * @param theFunction The PDF Function that maps an (x,y) location to a color * @return the PDF shading that was created */ - public PDFShading makeShading // CSOK: ParameterNumber - (PDFResourceContext res, int theShadingType, - PDFDeviceColorSpace theColorSpace, - List theBackground, List theBBox, - boolean theAntiAlias, List theDomain, - List theMatrix, - PDFFunction theFunction) { + public PDFShading makeShading( // CSOK: ParameterNumber + PDFResourceContext res, int theShadingType, + PDFDeviceColorSpace theColorSpace, + List theBackground, List theBBox, + boolean theAntiAlias, List theDomain, + List theMatrix, + PDFFunction theFunction) { // make Shading of Type 1 PDFShading shading = new PDFShading(theShadingType, theColorSpace, theBackground, @@ -519,13 +519,13 @@ public class PDFFactory { * The default is [false, false] * @return the PDF shading that was created */ - public PDFShading makeShading // CSOK: ParameterNumber - (PDFResourceContext res, int theShadingType, - PDFDeviceColorSpace theColorSpace, - List theBackground, List theBBox, - boolean theAntiAlias, List theCoords, - List theDomain, PDFFunction theFunction, - List theExtend) { + public PDFShading makeShading( // CSOK: ParameterNumber + PDFResourceContext res, int theShadingType, + PDFDeviceColorSpace theColorSpace, + List theBackground, List theBBox, + boolean theAntiAlias, List theCoords, + List theDomain, PDFFunction theFunction, + List theExtend) { // make Shading of Type 2 or 3 PDFShading shading = new PDFShading(theShadingType, theColorSpace, theBackground, @@ -573,15 +573,15 @@ public class PDFFactory { * @param theFunction the PDFFunction * @return the PDF shading that was created */ - public PDFShading makeShading // CSOK: ParameterNumber - (PDFResourceContext res, int theShadingType, - PDFDeviceColorSpace theColorSpace, - List theBackground, List theBBox, - boolean theAntiAlias, - int theBitsPerCoordinate, - int theBitsPerComponent, - int theBitsPerFlag, List theDecode, - PDFFunction theFunction) { + public PDFShading makeShading( // CSOK: ParameterNumber + PDFResourceContext res, int theShadingType, + PDFDeviceColorSpace theColorSpace, + List theBackground, List theBBox, + boolean theAntiAlias, + int theBitsPerCoordinate, + int theBitsPerComponent, + int theBitsPerFlag, List theDecode, + PDFFunction theFunction) { // make Shading of type 4,6 or 7 PDFShading shading = new PDFShading(theShadingType, theColorSpace, theBackground, @@ -629,15 +629,15 @@ public class PDFFactory { * @param theFunction The PDFFunction that's mapped on to this shape * @return the PDF shading that was created */ - public PDFShading makeShading // CSOK: ParameterNumber - (PDFResourceContext res, int theShadingType, - PDFDeviceColorSpace theColorSpace, - List theBackground, List theBBox, - boolean theAntiAlias, - int theBitsPerCoordinate, - int theBitsPerComponent, List theDecode, - int theVerticesPerRow, - PDFFunction theFunction) { + public PDFShading makeShading( // CSOK: ParameterNumber + PDFResourceContext res, int theShadingType, + PDFDeviceColorSpace theColorSpace, + List theBackground, List theBBox, + boolean theAntiAlias, + int theBitsPerCoordinate, + int theBitsPerComponent, List theDecode, + int theVerticesPerRow, + PDFFunction theFunction) { // make shading of Type 5 PDFShading shading = new PDFShading(theShadingType, theColorSpace, theBackground, @@ -680,12 +680,12 @@ public class PDFFactory { * @param thePatternDataStream The stream of pattern data to be tiled. * @return the PDF pattern that was created */ - public PDFPattern makePattern // CSOK: ParameterNumber - (PDFResourceContext res, int thePatternType, // 1 - PDFResources theResources, int thePaintType, int theTilingType, - List theBBox, double theXStep, - double theYStep, List theMatrix, - List theXUID, StringBuffer thePatternDataStream) { + public PDFPattern makePattern( // CSOK: ParameterNumber + PDFResourceContext res, int thePatternType, // 1 + PDFResources theResources, int thePaintType, int theTilingType, + List theBBox, double theXStep, + double theYStep, List theMatrix, + List theXUID, StringBuffer thePatternDataStream) { // PDFResources theResources PDFPattern pattern = new PDFPattern(theResources, 1, thePaintType, theTilingType, diff --git a/src/java/org/apache/fop/pdf/PDFFontDescriptor.java b/src/java/org/apache/fop/pdf/PDFFontDescriptor.java index 4350ed7dd..9d255545f 100644 --- a/src/java/org/apache/fop/pdf/PDFFontDescriptor.java +++ b/src/java/org/apache/fop/pdf/PDFFontDescriptor.java @@ -40,11 +40,11 @@ public class PDFFontDescriptor extends PDFDictionary { * @param italicAngle the angle of the vertical dominant strokes * @param stemV the width of the dominant vertical stems of glyphs */ - public PDFFontDescriptor // CSOK: ParameterNumber - (String basefont, int ascent, - int descent, int capHeight, int flags, - PDFRectangle fontBBox, int italicAngle, - int stemV) { + public PDFFontDescriptor( // CSOK: ParameterNumber + String basefont, int ascent, + int descent, int capHeight, int flags, + PDFRectangle fontBBox, int italicAngle, + int stemV) { super(); put("Type", new PDFName("FontDescriptor")); diff --git a/src/java/org/apache/fop/pdf/PDFFunction.java b/src/java/org/apache/fop/pdf/PDFFunction.java index 5b5d41490..9e93ebee8 100644 --- a/src/java/org/apache/fop/pdf/PDFFunction.java +++ b/src/java/org/apache/fop/pdf/PDFFunction.java @@ -211,11 +211,11 @@ public class PDFFunction extends PDFObject { * @param theFunctionType This is the type of function (0,2,3, or 4). * It should be 0 as this is the constructor for sampled functions. */ - public PDFFunction // CSOK: ParameterNumber - (int theFunctionType, List theDomain, - List theRange, List theSize, int theBitsPerSample, - int theOrder, List theEncode, List theDecode, - StringBuffer theFunctionDataStream, List theFilter) { + public PDFFunction( // CSOK: ParameterNumber + int theFunctionType, List theDomain, + List theRange, List theSize, int theBitsPerSample, + int theOrder, List theEncode, List theDecode, + StringBuffer theFunctionDataStream, List theFilter) { super(); this.functionType = 0; // dang well better be 0; diff --git a/src/java/org/apache/fop/pdf/PDFPattern.java b/src/java/org/apache/fop/pdf/PDFPattern.java index ebde4ac6a..74f56377e 100644 --- a/src/java/org/apache/fop/pdf/PDFPattern.java +++ b/src/java/org/apache/fop/pdf/PDFPattern.java @@ -117,12 +117,12 @@ public class PDFPattern extends PDFPathPaint { * @param theXUID Optional vector of Integers that uniquely identify the pattern * @param thePatternDataStream The stream of pattern data to be tiled. */ - public PDFPattern // CSOK: ParameterNumber - (PDFResources theResources, int thePatternType, // 1 - int thePaintType, int theTilingType, List theBBox, - double theXStep, double theYStep, - List theMatrix, List theXUID, - StringBuffer thePatternDataStream) { + public PDFPattern( // CSOK: ParameterNumber + PDFResources theResources, int thePatternType, // 1 + int thePaintType, int theTilingType, List theBBox, + double theXStep, double theYStep, + List theMatrix, List theXUID, + StringBuffer thePatternDataStream) { super(); this.resources = theResources; // This next parameter is implicit to all constructors, and is diff --git a/src/java/org/apache/fop/pdf/PDFShading.java b/src/java/org/apache/fop/pdf/PDFShading.java index 10d7bf628..2f955b850 100644 --- a/src/java/org/apache/fop/pdf/PDFShading.java +++ b/src/java/org/apache/fop/pdf/PDFShading.java @@ -164,11 +164,11 @@ public class PDFShading extends PDFObject { * It's optional, the default is the identity matrix * @param theFunction The PDF Function that maps an (x,y) location to a color */ - public PDFShading // CSOK: ParameterNumber - (int theShadingType, PDFDeviceColorSpace theColorSpace, - List theBackground, List theBBox, - boolean theAntiAlias, List theDomain, - List theMatrix, PDFFunction theFunction) { + public PDFShading( // CSOK: ParameterNumber + int theShadingType, PDFDeviceColorSpace theColorSpace, + List theBackground, List theBBox, + boolean theAntiAlias, List theDomain, + List theMatrix, PDFFunction theFunction) { super(); this.shadingType = theShadingType; // 1 this.colorSpace = theColorSpace; @@ -203,12 +203,12 @@ public class PDFShading extends PDFObject { * and end colors past the start and end points * The default is [false, false] */ - public PDFShading // CSOK: ParameterNumber - (int theShadingType, PDFDeviceColorSpace theColorSpace, - List theBackground, List theBBox, - boolean theAntiAlias, List theCoords, - List theDomain, PDFFunction theFunction, - List theExtend) { + public PDFShading( // CSOK: ParameterNumber + int theShadingType, PDFDeviceColorSpace theColorSpace, + List theBackground, List theBBox, + boolean theAntiAlias, List theCoords, + List theDomain, PDFFunction theFunction, + List theExtend) { super(); this.shadingType = theShadingType; // 2 or 3 this.colorSpace = theColorSpace; @@ -244,12 +244,12 @@ public class PDFShading extends PDFObject { * @param theDecode List of Doubles see PDF 1.3 spec pages 303 to 312. * @param theFunction the PDFFunction */ - public PDFShading // CSOK: ParameterNumber - (int theShadingType, PDFDeviceColorSpace theColorSpace, - List theBackground, List theBBox, - boolean theAntiAlias, int theBitsPerCoordinate, - int theBitsPerComponent, int theBitsPerFlag, - List theDecode, PDFFunction theFunction) { + public PDFShading( // CSOK: ParameterNumber + int theShadingType, PDFDeviceColorSpace theColorSpace, + List theBackground, List theBBox, + boolean theAntiAlias, int theBitsPerCoordinate, + int theBitsPerComponent, int theBitsPerFlag, + List theDecode, PDFFunction theFunction) { super(); this.shadingType = theShadingType; // 4,6 or 7 @@ -284,12 +284,12 @@ public class PDFShading extends PDFObject { * @param theVerticesPerRow number of vertices in each "row" of the lattice. * @param theFunction The PDFFunction that's mapped on to this shape */ - public PDFShading // CSOK: ParameterNumber - (int theShadingType, PDFDeviceColorSpace theColorSpace, - List theBackground, List theBBox, - boolean theAntiAlias, int theBitsPerCoordinate, - int theBitsPerComponent, List theDecode, - int theVerticesPerRow, PDFFunction theFunction) { + public PDFShading( // CSOK: ParameterNumber + int theShadingType, PDFDeviceColorSpace theColorSpace, + List theBackground, List theBBox, + boolean theAntiAlias, int theBitsPerCoordinate, + int theBitsPerComponent, List theDecode, + int theVerticesPerRow, PDFFunction theFunction) { super(); this.shadingType = theShadingType; // 5 this.colorSpace = theColorSpace; diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index ac4936a43..cfce3a875 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -172,10 +172,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param bpsStart the border-start traits * @param bpsEnd the border-end traits */ - protected void drawBackground // CSOK: ParameterNumber - (float startx, float starty, float width, float height, Trait.Background back, - BorderProps bpsBefore, BorderProps bpsAfter, - BorderProps bpsStart, BorderProps bpsEnd) { + protected void drawBackground( // CSOK: ParameterNumber + float startx, float starty, float width, float height, Trait.Background back, + BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) { if (back != null) { endTextObject(); @@ -261,10 +261,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param bpsStart the border-start traits * @param bpsEnd the border-end traits */ - protected void drawBorders // CSOK: ParameterNumber - (float startx, float starty, float width, float height, - BorderProps bpsBefore, BorderProps bpsAfter, - BorderProps bpsStart, BorderProps bpsEnd) { + protected void drawBorders( // CSOK: ParameterNumber + float startx, float starty, float width, float height, + BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) { Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height); drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd); } @@ -282,8 +282,8 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param bpsStart the border specification on the start side * @param bpsEnd the border specification on the end side */ - protected void drawBorders // CSOK: MethodLength - (Rectangle2D.Float borderRect, + protected void drawBorders( // CSOK: MethodLength + Rectangle2D.Float borderRect, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) { //TODO generalize each of the four conditions into using a parameterized drawBorder() boolean[] border = new boolean[] { @@ -858,9 +858,9 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param style the border style (one of Constants.EN_DASHED etc.) * @param col the color for the border segment */ - protected abstract void drawBorderLine // CSOK: ParameterNumber - (float x1, float y1, float x2, float y2, boolean horz, - boolean startOrBefore, int style, Color col); + protected abstract void drawBorderLine( // CSOK: ParameterNumber + float x1, float y1, float x2, float y2, boolean horz, + boolean startOrBefore, int style, Color col); /** {@inheritDoc} */ public void renderForeignObject(ForeignObject fo, Rectangle2D pos) { diff --git a/src/java/org/apache/fop/render/afp/AFPPainter.java b/src/java/org/apache/fop/render/afp/AFPPainter.java index 21bc4ab48..0bbfef3e8 100644 --- a/src/java/org/apache/fop/render/afp/AFPPainter.java +++ b/src/java/org/apache/fop/render/afp/AFPPainter.java @@ -281,8 +281,8 @@ public class AFPPainter extends AbstractIFPainter { return mpt / 1000f; } - protected void drawBorderLine // CSOK: ParameterNumber - (int x1, int y1, int x2, int y2, boolean horz, + protected void drawBorderLine( // CSOK: ParameterNumber + int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, Color color) throws IOException { BorderPaintingInfo borderPaintInfo = new BorderPaintingInfo( toPoints(x1), toPoints(y1), toPoints(x2), toPoints(y2), @@ -317,9 +317,9 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawText // CSOK: MethodLength - (int x, int y, final int letterSpacing, final int wordSpacing, final int[] dx, - final String text) throws IFException { + public void drawText( // CSOK: MethodLength + int x, int y, final int letterSpacing, final int wordSpacing, final int[] dx, + final String text) throws IFException { final int fontSize = this.state.getFontSize(); getPaintingState().setFontSize(fontSize); diff --git a/src/java/org/apache/fop/render/intermediate/BorderPainter.java b/src/java/org/apache/fop/render/intermediate/BorderPainter.java index ad37b1dc1..20402369a 100644 --- a/src/java/org/apache/fop/render/intermediate/BorderPainter.java +++ b/src/java/org/apache/fop/render/intermediate/BorderPainter.java @@ -217,9 +217,9 @@ public abstract class BorderPainter { * @param color the border color * @throws IOException if an I/O error occurs */ - protected abstract void drawBorderLine // CSOK: ParameterNumber - (int x1, int y1, int x2, int y2, - boolean horz, boolean startOrBefore, int style, Color color) throws IOException; + protected abstract void drawBorderLine( // CSOK: ParameterNumber + int x1, int y1, int x2, int y2, + boolean horz, boolean startOrBefore, int style, Color color) throws IOException; /** * Draws a line/rule. diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index 23a5da3e3..bdeb1e9a1 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -1238,8 +1238,8 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - protected void drawBorders // CSOK: ParameterNumber - (float startx, float starty, + protected void drawBorders( // CSOK: ParameterNumber + float startx, float starty, float width, float height, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) { @@ -1252,8 +1252,8 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - protected void drawBorderLine // CSOK: ParameterNumber - (float x1, float y1, float x2, float y2, boolean horz, + protected void drawBorderLine( // CSOK: ParameterNumber + float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { //Simplified implementation that is only used by renderTextDecoration() //drawBorders() is overridden and uses the Painter's high-level method drawBorderRect() diff --git a/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java b/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java index e4576373d..b2b29188b 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java +++ b/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java @@ -64,8 +64,8 @@ public class Java2DBorderPainter extends BorderPainter { } /** {@inheritDoc} */ - protected void drawBorderLine // CSOK: ParameterNumber - (int x1, int y1, int x2, int y2, boolean horz, + protected void drawBorderLine( // CSOK: ParameterNumber + int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, Color color) { float w = x2 - x1; float h = y2 - y1; diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index cbd50c954..73af5c8be 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -536,8 +536,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } /** {@inheritDoc} */ - protected void drawBorderLine // CSOK: ParameterNumber - (float x1, float y1, float x2, float y2, + protected void drawBorderLine( // CSOK: ParameterNumber + float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { Graphics2D g2d = state.getGraph(); float width = x2 - x1; diff --git a/src/java/org/apache/fop/render/pcl/PCLPainter.java b/src/java/org/apache/fop/render/pcl/PCLPainter.java index 00b25a5e3..afae8ac27 100644 --- a/src/java/org/apache/fop/render/pcl/PCLPainter.java +++ b/src/java/org/apache/fop/render/pcl/PCLPainter.java @@ -390,11 +390,11 @@ public class PCLPainter extends AbstractIFPainter implements PCLConstants { private static final double SAFETY_MARGIN_FACTOR = 0.05; - private Rectangle getTextBoundingBox // CSOK: ParameterNumber - (int x, int y, - int letterSpacing, int wordSpacing, int[] dx, - String text, - Font font, FontMetricsMapper metrics) { + private Rectangle getTextBoundingBox( // CSOK: ParameterNumber + int x, int y, + int letterSpacing, int wordSpacing, int[] dx, + String text, + Font font, FontMetricsMapper metrics) { int maxAscent = metrics.getMaxAscent(font.getFontSize()) / 1000; int descent = metrics.getDescender(font.getFontSize()) / 1000; //is negative int safetyMargin = (int)(SAFETY_MARGIN_FACTOR * font.getFontSize()); diff --git a/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java b/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java index 287f89607..f8090fdeb 100644 --- a/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java +++ b/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java @@ -50,9 +50,9 @@ public class PDFBorderPainter extends BorderPainter { } /** {@inheritDoc} */ - protected void drawBorderLine // CSOK: ParameterNumber - (int x1, int y1, int x2, int y2, boolean horz, - boolean startOrBefore, int style, Color col) { + protected void drawBorderLine( // CSOK: ParameterNumber + int x1, int y1, int x2, int y2, boolean horz, + boolean startOrBefore, int style, Color col) { drawBorderLine(generator, x1 / 1000f, y1 / 1000f, x2 / 1000f, y2 / 1000f, horz, startOrBefore, style, col); } @@ -61,10 +61,10 @@ public class PDFBorderPainter extends BorderPainter { * @param generator pdf content generator * @see BorderPainter#drawBorderLine */ - public static void drawBorderLine // CSOK: ParameterNumber|MethodLength - (PDFContentGenerator generator, - float x1, float y1, float x2, float y2, boolean horz, // CSOK: JavadocMethod - boolean startOrBefore, int style, Color col) { // CSOK: JavadocMethod + public static void drawBorderLine( // CSOK: ParameterNumber|MethodLength + PDFContentGenerator generator, + float x1, float y1, float x2, float y2, boolean horz, // CSOK: JavadocMethod + boolean startOrBefore, int style, Color col) { // CSOK: JavadocMethod float colFactor; float w = x2 - x1; float h = y2 - y1; diff --git a/src/java/org/apache/fop/render/ps/PSBorderPainter.java b/src/java/org/apache/fop/render/ps/PSBorderPainter.java index f5d5169c4..2d881571a 100644 --- a/src/java/org/apache/fop/render/ps/PSBorderPainter.java +++ b/src/java/org/apache/fop/render/ps/PSBorderPainter.java @@ -52,9 +52,9 @@ public class PSBorderPainter extends BorderPainter { } /** {@inheritDoc} */ - protected void drawBorderLine // CSOK: ParameterNumber - (int x1, int y1, int x2, int y2, boolean horz, - boolean startOrBefore, int style, Color col) throws IOException { + protected void drawBorderLine( // CSOK: ParameterNumber + int x1, int y1, int x2, int y2, boolean horz, + boolean startOrBefore, int style, Color col) throws IOException { drawBorderLine(generator, toPoints(x1), toPoints(y1), toPoints(x2), toPoints(y2), horz, startOrBefore, style, col); } @@ -71,10 +71,10 @@ public class PSBorderPainter extends BorderPainter { * @param gen ps content generator * @see BorderPainter#drawBorderLine */ - public static void drawBorderLine // CSOK: ParameterNumber - (PSGenerator gen, - float x1, float y1, float x2, float y2, boolean horz, // CSOK: JavadocMethod - boolean startOrBefore, int style, Color col) // CSOK: JavadocMethod + public static void drawBorderLine( // CSOK: ParameterNumber + PSGenerator gen, + float x1, float y1, float x2, float y2, boolean horz, // CSOK: JavadocMethod + boolean startOrBefore, int style, Color col) // CSOK: JavadocMethod throws IOException { // CSOK: JavadocMethod float w = x2 - x1; float h = y2 - y1; diff --git a/src/java/org/apache/fop/render/ps/PSPainter.java b/src/java/org/apache/fop/render/ps/PSPainter.java index 05a8121b8..b8a6d40f6 100644 --- a/src/java/org/apache/fop/render/ps/PSPainter.java +++ b/src/java/org/apache/fop/render/ps/PSPainter.java @@ -403,10 +403,10 @@ public class PSPainter extends AbstractIFPainter { } } - private void writeText // CSOK: ParameterNumber - (String text, int start, int len, - int letterSpacing, int wordSpacing, int[] dx, - Font font, Typeface tf) throws IOException { + private void writeText( // CSOK: ParameterNumber + String text, int start, int len, + int letterSpacing, int wordSpacing, int[] dx, + Font font, Typeface tf) throws IOException { PSGenerator generator = getGenerator(); int end = start + len; int initialSize = len; diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java index b64eb172c..aa36ea28f 100644 --- a/src/java/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java @@ -494,9 +494,9 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { /** * {@inheritDoc} */ - protected void drawBorderLine // CSOK: ParameterNumber - (float x1, float y1, float x2, float y2, - boolean horz, boolean startOrBefore, int style, Color col) { + protected void drawBorderLine( // CSOK: ParameterNumber + float x1, float y1, float x2, float y2, + boolean horz, boolean startOrBefore, int style, Color col) { int borderHeight = bm.getHeight(); int borderWidth = bm.getWidth(); diff --git a/src/java/org/apache/fop/util/ColorExt.java b/src/java/org/apache/fop/util/ColorExt.java index 6f4e21382..30f6e9fc3 100644 --- a/src/java/org/apache/fop/util/ColorExt.java +++ b/src/java/org/apache/fop/util/ColorExt.java @@ -118,10 +118,10 @@ public final class ColorExt extends Color { * ICC color values * @return the requested color object */ - public static ColorExt createFromSvgIccColor // CSOK: ParameterNumber - (float red, float green, - float blue, float opacity, String profileName, String profileHref, - ColorSpace profileCS, float[] colorValues) { + public static ColorExt createFromSvgIccColor( // CSOK: ParameterNumber + float red, float green, + float blue, float opacity, String profileName, String profileHref, + ColorSpace profileCS, float[] colorValues) { //TODO this method is not referenced by FOP, can it be deleted? ColorExt ce = new ColorExt(red, green, blue, opacity); ce.rgbReplacementRed = -1; -- cgit v1.2.3 From 2e8f9428b4fa41d5a78f4cf67731bc8a9105272e Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 23 Nov 2010 19:23:59 +0000 Subject: Bugzilla #49695: Replaced magic numbers with constants from UnitConv and GraphicsConstants Patch submitted by Joshua Marquart (joshua dot marquart _at. firstdata .dot_ com), applied with some modifications git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1038291 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/apps/FOUserAgent.java | 3 ++- src/java/org/apache/fop/apps/FopFactory.java | 5 +++-- src/java/org/apache/fop/apps/FopFactoryConfigurator.java | 11 ++++++----- .../apache/fop/image/loader/batik/ImageConverterSVG2G2D.java | 3 ++- src/java/org/apache/fop/render/awt/AWTRenderer.java | 10 ++++++---- .../fop/render/java2d/Java2DImageHandlerRenderedImage.java | 3 ++- src/java/org/apache/fop/render/java2d/Java2DRenderer.java | 5 +++-- src/java/org/apache/fop/render/rtf/FoUnitsConverter.java | 5 +++-- src/java/org/apache/fop/svg/AbstractFOPTranscoder.java | 9 +++++---- src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java | 4 +++- src/java/org/apache/fop/svg/PDFGraphics2D.java | 4 +++- status.xml | 3 +++ 12 files changed, 41 insertions(+), 24 deletions(-) (limited to 'src/java/org/apache/fop/render/java2d') diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index 0a65203cc..071066e04 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.loader.ImageContext; import org.apache.xmlgraphics.image.loader.ImageSessionContext; import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext; +import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.Version; import org.apache.fop.accessibility.Accessibility; @@ -450,7 +451,7 @@ public class FOUserAgent { * @see #getTargetResolution() */ public float getTargetPixelUnitToMillimeter() { - return 25.4f / this.targetResolution; + return UnitConv.IN2MM / this.targetResolution; } /** @return the resolution for resolution-dependant output */ diff --git a/src/java/org/apache/fop/apps/FopFactory.java b/src/java/org/apache/fop/apps/FopFactory.java index 7bcdd2703..b86c52cf6 100644 --- a/src/java/org/apache/fop/apps/FopFactory.java +++ b/src/java/org/apache/fop/apps/FopFactory.java @@ -42,6 +42,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.loader.ImageContext; import org.apache.xmlgraphics.image.loader.ImageManager; +import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.fo.ElementMapping; import org.apache.fop.fo.ElementMappingRegistry; @@ -539,7 +540,7 @@ public class FopFactory implements ImageContext { * @see #getSourceResolution() */ public float getSourcePixelUnitToMillimeter() { - return 25.4f / getSourceResolution(); + return UnitConv.IN2MM / getSourceResolution(); } /** @@ -567,7 +568,7 @@ public class FopFactory implements ImageContext { * @see #getTargetResolution() */ public float getTargetPixelUnitToMillimeter() { - return 25.4f / this.targetResolution; + return UnitConv.IN2MM / this.targetResolution; } /** diff --git a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java index ad0869ea1..161bd4a8f 100644 --- a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java +++ b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java @@ -33,6 +33,7 @@ import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.xmlgraphics.image.GraphicsConstants; import org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry; import org.apache.xmlgraphics.image.loader.util.Penalty; @@ -61,10 +62,10 @@ public class FopFactoryConfigurator { public static final String DEFAULT_PAGE_HEIGHT = "11in"; /** Defines the default source resolution (72dpi) for FOP */ - public static final float DEFAULT_SOURCE_RESOLUTION = 72.0f; //dpi + public static final float DEFAULT_SOURCE_RESOLUTION = GraphicsConstants.DEFAULT_DPI; //dpi /** Defines the default target resolution (72dpi) for FOP */ - public static final float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi + public static final float DEFAULT_TARGET_RESOLUTION = GraphicsConstants.DEFAULT_DPI; //dpi private static final String PREFER_RENDERER = "prefer-renderer"; @@ -159,7 +160,7 @@ public class FopFactoryConfigurator { lang = hyphPatConfig[i].getAttribute("lang", null); if (lang == null) { - addError("The lang attribute of a hyphenation-pattern configuration" + addError("The lang attribute of a hyphenation-pattern configuration" + " element must exist (" + location + ")", error); } else if (!lang.matches("[a-zA-Z]{2}")) { addError("The lang attribute of a hyphenation-pattern configuration" @@ -191,7 +192,7 @@ public class FopFactoryConfigurator { LogUtil.handleError(log, error.toString(), strict); continue; } - + String llccKey = HyphenationTreeCache.constructLlccKey(lang, country); hyphPatNames.put(llccKey, filename); if (log.isDebugEnabled()) { @@ -270,7 +271,7 @@ public class FopFactoryConfigurator { } error.append(message); } - + private void configureImageLoading(Configuration parent, boolean strict) throws FOPException { if (parent == null) { return; diff --git a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java index 9efc2aaf0..0b7989fb2 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java @@ -33,6 +33,7 @@ import org.apache.batik.gvt.GraphicsNode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.xmlgraphics.image.GraphicsConstants; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; @@ -72,7 +73,7 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter { } //Prepare - float pxToMillimeter = UnitConv.IN2MM / 72; //default: 72dpi + float pxToMillimeter = UnitConv.IN2MM / GraphicsConstants.DEFAULT_DPI; Number ptm = (Number)hints.get(ImageProcessingHints.SOURCE_RESOLUTION); if (ptm != null) { pxToMillimeter = (float)(UnitConv.IN2MM / ptm.doubleValue()); diff --git a/src/java/org/apache/fop/render/awt/AWTRenderer.java b/src/java/org/apache/fop/render/awt/AWTRenderer.java index 0128cf90e..99dece24a 100644 --- a/src/java/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/java/org/apache/fop/render/awt/AWTRenderer.java @@ -29,14 +29,16 @@ package org.apache.fop.render.awt; // Java import java.awt.Color; import java.awt.Dimension; -import java.awt.geom.Rectangle2D; import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; import java.awt.print.PageFormat; import java.awt.print.Pageable; import java.awt.print.Paper; import java.awt.print.Printable; import java.io.IOException; +import org.apache.xmlgraphics.util.UnitConv; + import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactoryConfigurator; @@ -46,8 +48,8 @@ import org.apache.fop.area.PageViewport; import org.apache.fop.render.awt.viewer.PreviewDialog; import org.apache.fop.render.awt.viewer.Renderable; import org.apache.fop.render.awt.viewer.StatusListener; -import org.apache.fop.render.java2d.Java2DRenderer; import org.apache.fop.render.extensions.prepress.PageScale; +import org.apache.fop.render.java2d.Java2DRenderer; /** * The AWTRender outputs the pages generated by the layout engine to a Swing @@ -152,10 +154,10 @@ public class AWTRenderer extends Java2DRenderer implements Pageable { pageWidth = (int) Math.round(bounds.getWidth() / 1000f); pageHeight = (int) Math.round(bounds.getHeight() / 1000f); double scaleX = scaleFactor - * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) + * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) / userAgent.getTargetPixelUnitToMillimeter(); double scaleY = scaleFactor - * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) + * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) / userAgent.getTargetPixelUnitToMillimeter(); if (getPageViewport(pageNum).getForeignAttributes() != null) { String scale = (String) getPageViewport(pageNum).getForeignAttributes().get( diff --git a/src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java index c29684118..4bdd52162 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java @@ -27,6 +27,7 @@ import java.awt.image.RenderedImage; import java.awt.image.WritableRaster; import java.io.IOException; +import org.apache.xmlgraphics.image.GraphicsConstants; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageInfo; @@ -76,7 +77,7 @@ public class Java2DImageHandlerRenderedImage implements ImageHandler { //scaling because of image resolution //float sourceResolution = java2dContext.getUserAgent().getSourceResolution(); //source resolution seems to be a bad idea, not sure why - float sourceResolution = 72; + float sourceResolution = GraphicsConstants.DEFAULT_DPI; sourceResolution *= 1000; //we're working in the millipoint area sx *= sourceResolution / info.getSize().getDpiHorizontal(); sy *= sourceResolution / info.getSize().getDpiVertical(); diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index 73af5c8be..353aefa25 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -53,6 +53,7 @@ import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; import org.apache.xmlgraphics.image.loader.util.ImageUtil; +import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.ResourceEventProducer; import org.apache.fop.apps.FOPException; @@ -317,10 +318,10 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem } scaleX = scaleX - * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) + * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) / userAgent.getTargetPixelUnitToMillimeter(); scaleY = scaleY - * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) + * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION) / userAgent.getTargetPixelUnitToMillimeter(); int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5); int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5); diff --git a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java index 33a2ff904..8540fcde3 100644 --- a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java +++ b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.FixedLength; +import org.apache.xmlgraphics.util.UnitConv; /** Converts XSL-FO units to RTF units @@ -43,8 +44,8 @@ final class FoUnitsConverter { public static final float POINT_TO_TWIPS = 20f; /** millimeters and centimeters to twips: , one point is 1/72 of an inch, one inch is 25.4 mm */ - public static final float IN_TO_TWIPS = 72f * POINT_TO_TWIPS; - public static final float MM_TO_TWIPS = IN_TO_TWIPS / 25.4f; + public static final float IN_TO_TWIPS = UnitConv.IN2PT * POINT_TO_TWIPS; + public static final float MM_TO_TWIPS = IN_TO_TWIPS / UnitConv.IN2MM; public static final float CM_TO_TWIPS = 10 * MM_TO_TWIPS; diff --git a/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java b/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java index aa8c5238c..01ef22efa 100644 --- a/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java +++ b/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java @@ -26,7 +26,6 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import org.w3c.dom.DOMImplementation; - import org.xml.sax.EntityResolver; import org.apache.avalon.framework.configuration.Configurable; @@ -48,10 +47,12 @@ import org.apache.batik.util.SVGConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.impl.SimpleLog; +import org.apache.xmlgraphics.image.GraphicsConstants; import org.apache.xmlgraphics.image.loader.ImageContext; import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext; +import org.apache.xmlgraphics.util.UnitConv; /** * This is the common base class of all of FOP's transcoders. @@ -226,7 +227,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder implem if (hints.containsKey(KEY_DEVICE_RESOLUTION)) { return ((Float)hints.get(KEY_DEVICE_RESOLUTION)).floatValue(); } else { - return 72; + return GraphicsConstants.DEFAULT_DPI; } } @@ -253,7 +254,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder implem protected void setupImageInfrastructure(final String baseURI) { final ImageContext imageContext = new ImageContext() { public float getSourceResolution() { - return 25.4f / userAgent.getPixelUnitToMillimeter(); + return UnitConv.IN2MM / userAgent.getPixelUnitToMillimeter(); } }; this.imageManager = new ImageManager(imageContext); @@ -372,7 +373,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder implem return ((Float)getTranscodingHints().get(key)).floatValue(); } else { // return 0.3528f; // 72 dpi - return 25.4f / 96; //96dpi = 0.2645833333333333333f; + return UnitConv.IN2MM / 96; //96dpi = 0.2645833333333333333f; } } diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java index 409b8dd9f..db1d9e2de 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java @@ -30,6 +30,8 @@ import java.io.IOException; import java.io.OutputStream; import java.io.StringWriter; +import org.apache.xmlgraphics.image.GraphicsConstants; + import org.apache.fop.Version; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontSetup; @@ -64,7 +66,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { /** Normal PDF resolution (72dpi) */ public static final int NORMAL_PDF_RESOLUTION = 72; /** Default device resolution (300dpi is a resonable quality for most purposes) */ - public static final int DEFAULT_NATIVE_DPI = 300; + public static final int DEFAULT_NATIVE_DPI = GraphicsConstants.DEFAULT_SAMPLE_DPI; /** * The device resolution may be different from the normal target resolution. See diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 45189133a..7c8d4a6b9 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -60,6 +60,7 @@ import org.apache.batik.ext.awt.RenderingHintsKeyExt; import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.gvt.PatternPaint; +import org.apache.xmlgraphics.image.GraphicsConstants; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageSize; import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; @@ -1270,7 +1271,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand private PDFXObject addRenderedImage(String key, RenderedImage img) { ImageInfo info = new ImageInfo(null, "image/unknown"); - ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), 72); + ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), + GraphicsConstants.DEFAULT_DPI); info.setSize(size); ImageRendered imgRend = new ImageRendered(info, img, null); ImageRenderedAdapter adapter = new ImageRenderedAdapter(imgRend, key); diff --git a/status.xml b/status.xml index b651ddf89..69aff4921 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Replaced magic numbers with constants from UnitConv and GraphicsConstants. + Added some support for break-before/-after for RTF output. -- cgit v1.2.3 From dbe01e0fa2bf8916be0d5d5f9a9bd83b2a726462 Mon Sep 17 00:00:00 2001 From: Simon Pepping Date: Fri, 26 Nov 2010 13:40:27 +0000 Subject: Partial application of patch 50245 by Mehdi Houshmand git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1039350 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/fonts/AbstractCodePointMapping.java | 14 +-- src/java/org/apache/fop/fonts/CIDSubset.java | 20 ++-- src/java/org/apache/fop/fonts/CustomFont.java | 24 ++--- .../org/apache/fop/fonts/CustomFontCollection.java | 8 +- src/java/org/apache/fop/fonts/EmbedFontInfo.java | 6 +- src/java/org/apache/fop/fonts/Font.java | 11 ++- src/java/org/apache/fop/fonts/FontCache.java | 31 +++--- src/java/org/apache/fop/fonts/FontDetector.java | 2 +- src/java/org/apache/fop/fonts/FontInfo.java | 107 ++++++++++----------- .../org/apache/fop/fonts/FontInfoConfigurator.java | 23 +++-- src/java/org/apache/fop/fonts/FontManager.java | 13 +-- .../apache/fop/fonts/FontManagerConfigurator.java | 12 +-- src/java/org/apache/fop/fonts/FontMetrics.java | 4 +- src/java/org/apache/fop/fonts/FontReader.java | 22 +++-- src/java/org/apache/fop/fonts/FontSetup.java | 13 ++- src/java/org/apache/fop/fonts/FontTriplet.java | 6 +- src/java/org/apache/fop/fonts/LazyFont.java | 4 +- src/java/org/apache/fop/fonts/MultiByteFont.java | 2 +- src/java/org/apache/fop/fonts/MutableFont.java | 4 +- .../apache/fop/fonts/SimpleSingleByteEncoding.java | 20 ++-- src/java/org/apache/fop/fonts/SingleByteFont.java | 37 +++---- src/java/org/apache/fop/fonts/Typeface.java | 5 +- .../apache/fop/fonts/autodetect/FontFinder.java | 2 +- .../org/apache/fop/fonts/truetype/TTFFile.java | 70 +++++++------- .../apache/fop/fonts/truetype/TTFFontLoader.java | 23 +++-- .../apache/fop/fonts/truetype/TTFSubSetFile.java | 4 +- .../fop/layoutmgr/inline/LineLayoutManager.java | 80 +++++++++------ src/java/org/apache/fop/pdf/PDFResources.java | 9 +- src/java/org/apache/fop/render/PrintRenderer.java | 9 +- .../fop/render/PrintRendererConfigurator.java | 11 ++- src/java/org/apache/fop/render/afp/AFPPainter.java | 32 ++++-- .../render/java2d/ConfiguredFontCollection.java | 2 +- .../fop/render/java2d/CustomFontMetricsMapper.java | 2 +- .../apache/fop/render/ps/FontResourceCache.java | 9 +- src/java/org/apache/fop/render/ps/PSFontUtils.java | 46 ++++----- .../org/apache/fop/tools/fontlist/FontSpec.java | 7 +- 36 files changed, 354 insertions(+), 340 deletions(-) (limited to 'src/java/org/apache/fop/render/java2d') diff --git a/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java b/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java index f03d4beab..71415faa3 100644 --- a/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java +++ b/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java @@ -20,24 +20,25 @@ package org.apache.fop.fonts; import java.util.Arrays; +import java.util.HashMap; import java.util.Map; -import org.apache.xmlgraphics.fonts.Glyphs; - import org.apache.fop.util.CharUtilities; +import org.apache.xmlgraphics.fonts.Glyphs; /** * Abstract base class for code point mapping classes (1-byte character encodings). */ public class AbstractCodePointMapping implements SingleByteEncoding { - private String name; + private final String name; private char[] latin1Map; private char[] characters; private char[] codepoints; private char[] unicodeMap; //code point to Unicode char private String[] charNameMap; //all character names in the encoding - private Map fallbackMap; //Here we accumulate all mappings we have found through substitution + //Here we accumulate all mappings we have found through substitution + private Map fallbackMap; /** * Main constructor. @@ -144,7 +145,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { //Fallback: using cache synchronized (this) { if (fallbackMap != null) { - Character fallback = (Character)fallbackMap.get(new Character(c)); + Character fallback = fallbackMap.get(new Character(c)); if (fallback != null) { return fallback.charValue(); } @@ -172,7 +173,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { private void putFallbackCharacter(char c, char mapTo) { synchronized (this) { if (this.fallbackMap == null) { - this.fallbackMap = new java.util.HashMap(); + this.fallbackMap = new HashMap(); } this.fallbackMap.put(new Character(c), new Character(mapTo)); } @@ -239,6 +240,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { } /** {@inheritDoc} */ + @Override public String toString() { return getName(); } diff --git a/src/java/org/apache/fop/fonts/CIDSubset.java b/src/java/org/apache/fop/fonts/CIDSubset.java index 778521517..b152ad38e 100644 --- a/src/java/org/apache/fop/fonts/CIDSubset.java +++ b/src/java/org/apache/fop/fonts/CIDSubset.java @@ -21,7 +21,7 @@ package org.apache.fop.fonts; import java.util.BitSet; import java.util.Collections; -import java.util.Iterator; +import java.util.HashMap; import java.util.Map; import org.apache.fop.util.CharUtilities; @@ -42,18 +42,18 @@ public class CIDSubset { /** * usedGlyphs contains orginal, new glyph index (glyph index -> char selector) */ - private Map/**/ usedGlyphs = new java.util.HashMap(); + private Map usedGlyphs = new HashMap(); /** * usedGlyphsIndex contains new glyph, original index (char selector -> glyph index) */ - private Map/**/ usedGlyphsIndex = new java.util.HashMap(); + private Map usedGlyphsIndex = new HashMap(); private int usedGlyphsCount = 0; /** * usedCharsIndex contains new glyph, original char (char selector -> Unicode) */ - private Map/**/ usedCharsIndex = new java.util.HashMap(); + private Map usedCharsIndex = new HashMap(); /** * Default constructor. @@ -84,7 +84,7 @@ public class CIDSubset { * @return the original index (or -1 if no glyph index is available for the subset index) */ public int getGlyphIndexForSubsetIndex(int subsetIndex) { - Integer glyphIndex = (Integer)usedGlyphsIndex.get(new Integer(subsetIndex)); + Integer glyphIndex = usedGlyphsIndex.get(new Integer(subsetIndex)); if (glyphIndex != null) { return glyphIndex.intValue(); } else { @@ -99,7 +99,7 @@ public class CIDSubset { * @return the Unicode value or "NOT A CHARACTER" (0xFFFF) */ public char getUnicodeForSubsetIndex(int subsetIndex) { - Character mapValue = (Character)usedCharsIndex.get(new Integer(subsetIndex)); + Character mapValue = usedCharsIndex.get(new Integer(subsetIndex)); if (mapValue != null) { return mapValue.charValue(); } else { @@ -118,7 +118,7 @@ public class CIDSubset { public int mapSubsetChar(int glyphIndex, char unicode) { // Reencode to a new subset font or get the reencoded value // IOW, accumulate the accessed characters and build a character map for them - Integer subsetCharSelector = (Integer)usedGlyphs.get(new Integer(glyphIndex)); + Integer subsetCharSelector = usedGlyphs.get(new Integer(glyphIndex)); if (subsetCharSelector == null) { int selector = usedGlyphsCount; usedGlyphs.put(new Integer(glyphIndex), @@ -139,7 +139,7 @@ public class CIDSubset { * character selector (i.e. the subset index in this case). * @return Map Map<Integer, Integer> of the font subset */ - public Map/**/ getSubsetGlyphs() { + public Map getSubsetGlyphs() { return Collections.unmodifiableMap(this.usedGlyphs); } @@ -169,9 +169,7 @@ public class CIDSubset { */ public BitSet getGlyphIndexBitSet() { BitSet bitset = new BitSet(); - Iterator iter = usedGlyphsIndex.keySet().iterator(); - while (iter.hasNext()) { - Integer cid = (Integer)iter.next(); + for (Integer cid : usedGlyphs.keySet()) { bitset.set(cid.intValue()); } return bitset; diff --git a/src/java/org/apache/fop/fonts/CustomFont.java b/src/java/org/apache/fop/fonts/CustomFont.java index 4cf24ae16..4432fccef 100644 --- a/src/java/org/apache/fop/fonts/CustomFont.java +++ b/src/java/org/apache/fop/fonts/CustomFont.java @@ -21,6 +21,8 @@ package org.apache.fop.fonts; import java.io.IOException; import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -35,7 +37,7 @@ public abstract class CustomFont extends Typeface private String fontName = null; private String fullName = null; - private Set familyNames = null; //Set + private Set familyNames = null; private String fontSubName = null; private String embedFileName = null; private String embedResourceName = null; @@ -55,7 +57,7 @@ public abstract class CustomFont extends Typeface private int firstChar = 0; private int lastChar = 255; - private Map kerning; + private Map> kerning; private boolean useKerning = true; @@ -78,7 +80,7 @@ public abstract class CustomFont extends Typeface * Returns the font family names. * @return the font family names (a Set of Strings) */ - public Set getFamilyNames() { + public Set getFamilyNames() { return Collections.unmodifiableSet(this.familyNames); } @@ -275,11 +277,11 @@ public abstract class CustomFont extends Typeface /** * {@inheritDoc} */ - public final Map getKerningInfo() { + public final Map> getKerningInfo() { if (hasKerningInfo()) { return kerning; } else { - return java.util.Collections.EMPTY_MAP; + return Collections.emptyMap(); } } @@ -296,8 +298,8 @@ public abstract class CustomFont extends Typeface } /** {@inheritDoc} */ - public void setFamilyNames(Set names) { - this.familyNames = new java.util.HashSet(names); + public void setFamilyNames(Set names) { + this.familyNames = new HashSet(names); } /** @@ -434,9 +436,9 @@ public abstract class CustomFont extends Typeface } /** {@inheritDoc} */ - public void putKerningEntry(Integer key, Map value) { + public void putKerningEntry(Integer key, Map value) { if (kerning == null) { - kerning = new java.util.HashMap(); + kerning = new HashMap>(); } this.kerning.put(key, value); } @@ -446,9 +448,9 @@ public abstract class CustomFont extends Typeface * @param kerningMap the kerning map (Map, the integers are * character codes) */ - public void replaceKerningMap(Map kerningMap) { + public void replaceKerningMap(Map> kerningMap) { if (kerningMap == null) { - this.kerning = Collections.EMPTY_MAP; + this.kerning = Collections.emptyMap(); } else { this.kerning = kerningMap; } diff --git a/src/java/org/apache/fop/fonts/CustomFontCollection.java b/src/java/org/apache/fop/fonts/CustomFontCollection.java index 5a0bba782..9f98814a3 100644 --- a/src/java/org/apache/fop/fonts/CustomFontCollection.java +++ b/src/java/org/apache/fop/fonts/CustomFontCollection.java @@ -27,7 +27,7 @@ import java.util.List; public class CustomFontCollection implements FontCollection { private FontResolver fontResolver; - private List/**/ embedFontInfoList; + private final List embedFontInfoList; /** * Main constructor. @@ -35,7 +35,7 @@ public class CustomFontCollection implements FontCollection { * @param customFonts the list of custom fonts */ public CustomFontCollection(FontResolver fontResolver, - List/**/ customFonts) { + List customFonts) { this.fontResolver = fontResolver; if (this.fontResolver == null) { //Ensure that we have minimal font resolution capabilities @@ -54,7 +54,7 @@ public class CustomFontCollection implements FontCollection { //FontReader reader = null; for (int i = 0; i < embedFontInfoList.size(); i++) { - EmbedFontInfo embedFontInfo = (EmbedFontInfo)embedFontInfoList.get(i); + EmbedFontInfo embedFontInfo = embedFontInfoList.get(i); //String metricsFile = configFontInfo.getMetricsFile(); internalName = "F" + num; @@ -69,7 +69,7 @@ public class CustomFontCollection implements FontCollection { LazyFont font = new LazyFont(embedFontInfo, this.fontResolver); fontInfo.addMetrics(internalName, font); - List triplets = embedFontInfo.getFontTriplets(); + List triplets = embedFontInfo.getFontTriplets(); for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) { FontTriplet triplet = (FontTriplet) triplets.get(tripletIndex); fontInfo.addFontProperties(internalName, triplet); diff --git a/src/java/org/apache/fop/fonts/EmbedFontInfo.java b/src/java/org/apache/fop/fonts/EmbedFontInfo.java index aa464c21d..b53cdfdd6 100644 --- a/src/java/org/apache/fop/fonts/EmbedFontInfo.java +++ b/src/java/org/apache/fop/fonts/EmbedFontInfo.java @@ -46,7 +46,7 @@ public class EmbedFontInfo implements Serializable { protected String subFontName = null; /** the list of associated font triplets */ - private List/**/ fontTriplets = null; + private List fontTriplets = null; private transient boolean embedded = true; @@ -59,7 +59,7 @@ public class EmbedFontInfo implements Serializable { * @param subFontName the sub-fontname used for TrueType Collections (null otherwise) */ public EmbedFontInfo(String metricsFile, boolean kerning, - List/**/ fontTriplets, String embedFile, String subFontName) { + List fontTriplets, String embedFile, String subFontName) { this.metricsFile = metricsFile; this.embedFile = embedFile; this.kerning = kerning; @@ -120,7 +120,7 @@ public class EmbedFontInfo implements Serializable { * Returns the list of font triplets associated with this font. * @return List of font triplets */ - public List/**/ getFontTriplets() { + public List getFontTriplets() { return fontTriplets; } diff --git a/src/java/org/apache/fop/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java index d0a87efbf..7d6004fa0 100644 --- a/src/java/org/apache/fop/fonts/Font.java +++ b/src/java/org/apache/fop/fonts/Font.java @@ -19,11 +19,11 @@ package org.apache.fop.fonts; +import java.util.Collections; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.fonts.CodePointMapping; /** * This class holds font state information and provides access to the font @@ -160,11 +160,11 @@ public class Font { * Returns the font's kerning table * @return the kerning table */ - public Map getKerning() { + public Map> getKerning() { if (metric.hasKerningInfo()) { return metric.getKerningInfo(); } else { - return java.util.Collections.EMPTY_MAP; + return Collections.emptyMap(); } } @@ -178,9 +178,9 @@ public class Font { * @return the distance to adjust for kerning, 0 if there's no kerning */ public int getKernValue(char ch1, char ch2) { - Map kernPair = (Map)getKerning().get(new Integer(ch1)); + Map kernPair = getKerning().get(new Integer(ch1)); if (kernPair != null) { - Integer width = (Integer)kernPair.get(new Integer(ch2)); + Integer width = kernPair.get(new Integer(ch2)); if (width != null) { return width.intValue() * getFontSize() / 1000; } @@ -239,6 +239,7 @@ public class Font { /** * {@inheritDoc} */ + @Override public String toString() { StringBuffer sbuf = new StringBuffer(); sbuf.append('('); diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index 61eca0963..87298a707 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.java @@ -31,6 +31,7 @@ import java.io.Serializable; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.util.HashMap; import java.util.Map; import org.apache.commons.io.FileUtils; @@ -71,13 +72,13 @@ public final class FontCache implements Serializable { * master mapping of font url -> font info. This needs to be a list, since a * TTC file may contain more than 1 font. */ - private Map/* */fontfileMap = null; + private Map fontfileMap = null; /** * mapping of font url -> file modified date (for all fonts that have failed * to load) */ - private Map failedFontMap/* */ = null; + private Map failedFontMap = null; /** * Default constructor @@ -304,9 +305,9 @@ public final class FontCache implements Serializable { return null; } - private Map/* */getFontFileMap() { + private Map getFontFileMap() { if (fontfileMap == null) { - fontfileMap = new java.util.HashMap/* */(); + fontfileMap = new HashMap(); } return fontfileMap; } @@ -322,8 +323,7 @@ public final class FontCache implements Serializable { synchronized (changeLock) { CachedFontFile cachedFontFile; if (containsFont(cacheKey)) { - cachedFontFile = (CachedFontFile) getFontFileMap() - .get(cacheKey); + cachedFontFile = getFontFileMap().get(cacheKey); if (!cachedFontFile.containsFont(fontInfo)) { cachedFontFile.put(fontInfo); } @@ -352,8 +352,7 @@ public final class FontCache implements Serializable { * @return CachedFontFile object */ public CachedFontFile getFontFile(String embedUrl) { - return containsFont(embedUrl) ? (CachedFontFile) getFontFileMap().get( - embedUrl) : null; + return containsFont(embedUrl) ? getFontFileMap().get(embedUrl) : null; } /** @@ -408,8 +407,8 @@ public final class FontCache implements Serializable { public boolean isFailedFont(String embedUrl, long lastModified) { synchronized (changeLock) { if (getFailedFontMap().containsKey(embedUrl)) { - long failedLastModified = ((Long) getFailedFontMap().get( - embedUrl)).longValue(); + long failedLastModified = getFailedFontMap().get( + embedUrl).longValue(); if (lastModified != failedLastModified) { // this font has been changed so lets remove it // from failed font map for now @@ -440,9 +439,9 @@ public final class FontCache implements Serializable { } } - private Map/* */getFailedFontMap() { + private Map getFailedFontMap() { if (failedFontMap == null) { - failedFontMap = new java.util.HashMap/* */(); + failedFontMap = new HashMap(); } return failedFontMap; } @@ -491,15 +490,15 @@ public final class FontCache implements Serializable { /** file modify date (if available) */ private long lastModified = -1; - private Map/* */filefontsMap = null; + private Map filefontsMap = null; public CachedFontFile(long lastModified) { setLastModified(lastModified); } - private Map/* */getFileFontsMap() { + private Map getFileFontsMap() { if (filefontsMap == null) { - filefontsMap = new java.util.HashMap/* */(); + filefontsMap = new HashMap(); } return filefontsMap; } @@ -514,7 +513,7 @@ public final class FontCache implements Serializable { } public EmbedFontInfo[] getEmbedFontInfos() { - return (EmbedFontInfo[]) getFileFontsMap().values().toArray( + return getFileFontsMap().values().toArray( new EmbedFontInfo[getFileFontsMap().size()]); } diff --git a/src/java/org/apache/fop/fonts/FontDetector.java b/src/java/org/apache/fop/fonts/FontDetector.java index 5450b4ff9..d69dfc9bd 100644 --- a/src/java/org/apache/fop/fonts/FontDetector.java +++ b/src/java/org/apache/fop/fonts/FontDetector.java @@ -63,7 +63,7 @@ public class FontDetector { * @param fontInfoList a list of fontinfo to populate * @throws FOPException thrown if a problem occurred during detection */ - public void detect(List/**/ fontInfoList) throws FOPException { + public void detect(List fontInfoList) throws FOPException { // search in font base if it is defined and // is a directory but don't recurse FontFileFinder fontFileFinder = new FontFileFinder(); diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index e36b5ff68..c0bf8db8d 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -19,12 +19,15 @@ package org.apache.fop.fonts; -import java.util.Collection; +import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,26 +47,26 @@ public class FontInfo { protected static final Log log = LogFactory.getLog(FontInfo.class); /** Map containing fonts that have been used */ - private Map/**/ usedFonts = null; //(String = font key) + private Map usedFonts = null; //(String = font key) /** look up a font-triplet to find a font-name */ - private Map/**/ triplets = null; //(String = font key) + private Map triplets = null; //(String = font key) /** look up a font-triplet to find its priority * (only used inside addFontProperties()) */ - private Map/**/ tripletPriorities = null; //Map + private Map tripletPriorities = null; //Map /** look up a font-name to get a font (that implements FontMetrics at least) */ - private Map/**/ fonts = null; //(String = font key) + private Map fonts = null; //(String = font key) /** * a collection of missing fonts; used to make sure the user gets * a warning for a missing font only once (not every time the font is used) */ - private Set/**/ loggedFontKeys = null; + private Set loggedFontKeys = null; /** Cache for Font instances. */ - private Map/**/ fontInstanceCache = null; + private Map> fontInstanceCache = null; /** Event listener for font events */ private FontEventListener eventListener = null; @@ -72,10 +75,10 @@ public class FontInfo { * Main constructor */ public FontInfo() { - this.triplets = new java.util.HashMap/**/(); - this.tripletPriorities = new java.util.HashMap/**/(); - this.fonts = new java.util.HashMap/**/(); - this.usedFonts = new java.util.HashMap/**/(); + this.triplets = new HashMap(); + this.tripletPriorities = new HashMap(); + this.fonts = new HashMap(); + this.usedFonts = new HashMap(); } /** @@ -135,10 +138,10 @@ public class FontInfo { if (log.isDebugEnabled()) { log.debug("Registering: " + triplet + " under " + internalFontKey); } - String oldName = (String)triplets.get(triplet); + String oldName = triplets.get(triplet); int newPriority = triplet.getPriority(); if (oldName != null) { - int oldPriority = ((Integer)tripletPriorities.get(triplet)).intValue(); + int oldPriority = tripletPriorities.get(triplet).intValue(); if (oldPriority < newPriority) { logDuplicateFont(triplet, false, oldName, oldPriority, internalFontKey, newPriority); @@ -168,9 +171,9 @@ public class FontInfo { if (log.isDebugEnabled()) { log.debug(triplet + (replacing ? ": Replacing " : ": Not replacing ") - + ((FontMetrics)fonts.get(triplets.get(triplet))).getFullName() + + fonts.get(triplets.get(triplet)).getFullName() + " (priority=" + oldPriority + ") by " - + ((FontMetrics)fonts.get(newKey)).getFullName() + + fonts.get(newKey).getFullName() + " (priority=" + newPriority + ")"); } } @@ -186,7 +189,7 @@ public class FontInfo { if (metrics instanceof Typeface) { ((Typeface)metrics).setEventListener(this.eventListener); } - this.fonts.put(internalFontKey, metrics); + this.fonts.put(internalFontKey, (Typeface)metrics); } /** @@ -292,9 +295,9 @@ public class FontInfo { usedFonts.put(internalName, fonts.get(internalName)); } - private Map/*>*/ getFontInstanceCache() { + private Map> getFontInstanceCache() { if (fontInstanceCache == null) { - fontInstanceCache = new java.util.HashMap/*>*/(); + fontInstanceCache = new HashMap>(); } return fontInstanceCache; } @@ -307,14 +310,14 @@ public class FontInfo { * @return the requested Font instance */ public Font getFontInstance(FontTriplet triplet, int fontSize) { - Map/**/ sizes - = (Map/**/)getFontInstanceCache().get(triplet); + Map sizes + = getFontInstanceCache().get(triplet); if (sizes == null) { - sizes = new java.util.HashMap/**/(); + sizes = new HashMap(); getFontInstanceCache().put(triplet, sizes); } Integer size = new Integer(fontSize); - Font font = (Font)sizes.get(size); + Font font = sizes.get(size); if (font == null) { String fontKey = getInternalFontKey(triplet); useFont(fontKey); @@ -325,11 +328,9 @@ public class FontInfo { return font; } - private List/**/ getTripletsForName(String fontName) { - List/**/ matchedTriplets = new java.util.ArrayList/**/(); - Iterator it = triplets.keySet().iterator(); - while (it.hasNext()) { - FontTriplet triplet = (FontTriplet)it.next(); + private List getTripletsForName(String fontName) { + List matchedTriplets = new ArrayList(); + for (FontTriplet triplet : triplets.keySet()) { String tripletName = triplet.getName(); if (tripletName.toLowerCase().equals(fontName.toLowerCase())) { matchedTriplets.add(triplet); @@ -351,11 +352,9 @@ public class FontInfo { int awtFontWeight = awtFont.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL; FontTriplet matchedTriplet = null; - List/**/ triplets = getTripletsForName(awtFontName); + List triplets = getTripletsForName(awtFontName); if (!triplets.isEmpty()) { - Iterator it = triplets.iterator(); - while (it.hasNext()) { - FontTriplet triplet = (FontTriplet)it.next(); + for (FontTriplet triplet : triplets) { boolean styleMatched = triplet.getStyle().equals(awtFontStyle); boolean weightMatched = triplet.getWeight() == awtFontWeight; if (styleMatched && weightMatched) { @@ -393,9 +392,9 @@ public class FontInfo { return fontLookup(family, style, weight, true); } - private List/**/ fontLookup(String[] families, String style, + private List fontLookup(String[] families, String style, int weight, boolean substitutable) { - List/**/ matchingTriplets = new java.util.ArrayList/**/(); + List matchingTriplets = new ArrayList(); FontTriplet triplet = null; for (int i = 0; i < families.length; i++) { triplet = fontLookup(families[i], style, weight, substitutable); @@ -426,7 +425,7 @@ public class FontInfo { } // try matching without substitutions - List/**/ matchedTriplets = fontLookup(families, style, weight, false); + List matchedTriplets = fontLookup(families, style, weight, false); // if there are no matching font triplets found try with substitutions if (matchedTriplets.size() == 0) { @@ -454,9 +453,9 @@ public class FontInfo { return fontTriplets; } - private Set/**/ getLoggedFontKeys() { + private Set getLoggedFontKeys() { if (loggedFontKeys == null) { - loggedFontKeys = new java.util.HashSet/**/(); + loggedFontKeys = new HashSet(); } return loggedFontKeys; } @@ -544,7 +543,7 @@ public class FontInfo { * @return the associated internal key or null, if not found */ public String getInternalFontKey(FontTriplet triplet) { - return (String)triplets.get(triplet); + return triplets.get(triplet); } /** @@ -563,15 +562,15 @@ public class FontInfo { * Gets a Map of all registered fonts. * @return a read-only Map with font key/FontMetrics pairs */ - public Map/**/ getFonts() { - return java.util.Collections.unmodifiableMap(this.fonts); + public Map getFonts() { + return Collections.unmodifiableMap(this.fonts); } /** * Gets a Map of all registered font triplets. * @return a Map with FontTriplet/font key pairs */ - public Map/**/ getFontTriplets() { + public Map getFontTriplets() { return this.triplets; } @@ -581,7 +580,7 @@ public class FontInfo { * This is for embedded font or creating a list of used fonts. * @return a read-only Map with font key/FontMetrics pairs */ - public Map/**/ getUsedFonts() { + public Map getUsedFonts() { return this.usedFonts; } @@ -591,7 +590,7 @@ public class FontInfo { * @return font metrics */ public FontMetrics getMetricsFor(String fontName) { - FontMetrics metrics = (FontMetrics)fonts.get(fontName); + Typeface metrics = fonts.get(fontName); usedFonts.put(fontName, metrics); return metrics; } @@ -601,10 +600,9 @@ public class FontInfo { * @param fontName The font name we are looking for * @return A list of matching font triplets */ - public List/**/ getTripletsFor(String fontName) { - List/**/ foundTriplets = new java.util.ArrayList(); - for (Iterator iter = triplets.entrySet().iterator(); iter.hasNext();) { - Map.Entry tripletEntry = (Map.Entry) iter.next(); + public List getTripletsFor(String fontName) { + List foundTriplets = new ArrayList (); + for (Map.Entry tripletEntry : triplets.entrySet()) { if (fontName.equals((tripletEntry.getValue()))) { foundTriplets.add(tripletEntry.getKey()); } @@ -620,10 +618,10 @@ public class FontInfo { * @return The first triplet for the given font name */ public FontTriplet getTripletFor(String fontName) { - List/**/ foundTriplets = getTripletsFor(fontName); + List foundTriplets = getTripletsFor(fontName); if (foundTriplets.size() > 0) { Collections.sort(foundTriplets); - return (FontTriplet)foundTriplets.get(0); + return foundTriplets.get(0); } return null; } @@ -672,18 +670,17 @@ public class FontInfo { /** * {@inheritDoc} */ + @Override public String toString() { - Collection entries = new java.util.TreeSet(); - Iterator iter = this.triplets.keySet().iterator(); - while (iter.hasNext()) { - FontTriplet triplet = (FontTriplet)iter.next(); + SortedSet entries = new TreeSet(); + for (FontTriplet triplet : this.triplets.keySet()) { String key = getInternalFontKey(triplet); FontMetrics metrics = getMetricsFor(key); entries.add(triplet.toString() + " -> " + key + " -> " + metrics.getFontName() + "\n"); } StringBuffer stringBuffer = new StringBuffer(); - for (iter = entries.iterator(); iter.hasNext();) { - stringBuffer.append(iter.next()); + for (String str : entries) { + stringBuffer.append(str); } return stringBuffer.toString(); } diff --git a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java index 911e57646..adbcd1260 100644 --- a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java @@ -33,7 +33,6 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.fop.apps.FOPException; import org.apache.fop.fonts.autodetect.FontFileFinder; import org.apache.fop.fonts.autodetect.FontInfoFinder; @@ -46,11 +45,11 @@ public class FontInfoConfigurator { /** logger instance */ protected static final Log log = LogFactory.getLog(FontInfoConfigurator.class); - private Configuration cfg; - private FontManager fontManager; - private FontResolver fontResolver; - private FontEventListener listener; - private boolean strict; + private final Configuration cfg; + private final FontManager fontManager; + private final FontResolver fontResolver; + private final FontEventListener listener; + private final boolean strict; /** * Main constructor @@ -74,7 +73,8 @@ public class FontInfoConfigurator { * @param fontInfoList a font info list * @throws FOPException if an exception occurs while processing the configuration */ - public void configure(List/**/ fontInfoList) throws FOPException { + public void configure(List fontInfoList) + throws FOPException { Configuration fontsCfg = cfg.getChild("fonts", false); if (fontsCfg != null) { long start = 0; @@ -120,7 +120,7 @@ public class FontInfoConfigurator { } private void addDirectories(Configuration fontsCfg, - FontAdder fontAdder, List/**/ fontInfoList) throws FOPException { + FontAdder fontAdder, List fontInfoList) throws FOPException { // directory (multiple font) configuration Configuration[] directories = fontsCfg.getChildren("directory"); for (int i = 0; i < directories.length; i++) { @@ -158,7 +158,7 @@ public class FontInfoConfigurator { * @throws FOPException if an exception occurs while processing the configuration */ protected void addFonts(Configuration fontsCfg, FontCache fontCache, - List/**/ fontInfoList) throws FOPException { + List fontInfoList) throws FOPException { // font file (singular) configuration Configuration[] font = fontsCfg.getChildren("font"); for (int i = 0; i < font.length; i++) { @@ -186,9 +186,8 @@ public class FontInfoConfigurator { * @return the embedded font info * @throws FOPException if something's wrong with the config data */ - protected EmbedFontInfo getFontInfo( - Configuration fontCfg, FontCache fontCache) - throws FOPException { + protected EmbedFontInfo getFontInfo(Configuration fontCfg, FontCache fontCache) + throws FOPException { String metricsUrl = fontCfg.getAttribute("metrics-url", null); String embedUrl = fontCfg.getAttribute("embed-url", null); String subFont = fontCfg.getAttribute("sub-font", null); diff --git a/src/java/org/apache/fop/fonts/FontManager.java b/src/java/org/apache/fop/fonts/FontManager.java index 44b2f030b..51516e231 100644 --- a/src/java/org/apache/fop/fonts/FontManager.java +++ b/src/java/org/apache/fop/fonts/FontManager.java @@ -21,7 +21,6 @@ package org.apache.fop.fonts; import java.io.File; import java.net.MalformedURLException; -import java.util.Iterator; import java.util.List; import javax.xml.transform.Source; @@ -260,7 +259,7 @@ public class FontManager { * ({@link #getReferencedFontsMatcher()}). * @param fontInfoList a font info list */ - public void updateReferencedFonts(List fontInfoList) { + public void updateReferencedFonts(List fontInfoList) { Matcher matcher = getReferencedFontsMatcher(); updateReferencedFonts(fontInfoList, matcher); } @@ -270,16 +269,12 @@ public class FontManager { * @param fontInfoList a font info list * @param matcher the font triplet matcher to use */ - public void updateReferencedFonts(List fontInfoList, Matcher matcher) { + public void updateReferencedFonts(List fontInfoList, Matcher matcher) { if (matcher == null) { return; //No referenced fonts } - Iterator iter = fontInfoList.iterator(); - while (iter.hasNext()) { - EmbedFontInfo fontInfo = (EmbedFontInfo)iter.next(); - Iterator triplets = fontInfo.getFontTriplets().iterator(); - while (triplets.hasNext()) { - FontTriplet triplet = (FontTriplet)triplets.next(); + for (EmbedFontInfo fontInfo : fontInfoList) { + for (FontTriplet triplet : fontInfo.getFontTriplets()) { if (matcher.matches(triplet)) { fontInfo.setEmbedded(false); break; diff --git a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java index b0a4aada0..421c99051 100644 --- a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java @@ -28,7 +28,6 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.fop.apps.FOPException; import org.apache.fop.fonts.substitute.FontSubstitutions; import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator; @@ -42,7 +41,7 @@ public class FontManagerConfigurator { /** logger instance */ private static Log log = LogFactory.getLog(FontManagerConfigurator.class); - private Configuration cfg; + private final Configuration cfg; /** * Main constructor @@ -114,7 +113,7 @@ public class FontManagerConfigurator { */ public static FontTriplet.Matcher createFontsMatcher( Configuration cfg, boolean strict) throws FOPException { - List matcherList = new java.util.ArrayList(); + List matcherList = new java.util.ArrayList(); Configuration[] matches = cfg.getChildren("match"); for (int i = 0; i < matches.length; i++) { try { @@ -126,14 +125,13 @@ public class FontManagerConfigurator { } } FontTriplet.Matcher orMatcher = new OrFontTripletMatcher( - (FontTriplet.Matcher[])matcherList.toArray( - new FontTriplet.Matcher[matcherList.size()])); + matcherList.toArray(new FontTriplet.Matcher[matcherList.size()])); return orMatcher; } private static class OrFontTripletMatcher implements FontTriplet.Matcher { - private FontTriplet.Matcher[] matchers; + private final FontTriplet.Matcher[] matchers; public OrFontTripletMatcher(FontTriplet.Matcher[] matchers) { this.matchers = matchers; @@ -153,7 +151,7 @@ public class FontManagerConfigurator { private static class FontFamilyRegExFontTripletMatcher implements FontTriplet.Matcher { - private Pattern regex; + private final Pattern regex; public FontFamilyRegExFontTripletMatcher(String regex) { this.regex = Pattern.compile(regex); diff --git a/src/java/org/apache/fop/fonts/FontMetrics.java b/src/java/org/apache/fop/fonts/FontMetrics.java index 29ade1ef3..ff32d7305 100644 --- a/src/java/org/apache/fop/fonts/FontMetrics.java +++ b/src/java/org/apache/fop/fonts/FontMetrics.java @@ -45,7 +45,7 @@ public interface FontMetrics { * Returns the font's family names as a Set of Strings (Example: "Helvetica"). * @return the font's family names (a Set of Strings) */ - Set getFamilyNames(); + Set getFamilyNames(); /** * Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT"). @@ -129,6 +129,6 @@ public interface FontMetrics { * Returns the kerning map for the font. * @return the kerning map */ - Map getKerningInfo(); + Map> getKerningInfo(); } diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java index 16da99baa..e9b88ec16 100644 --- a/src/java/org/apache/fop/fonts/FontReader.java +++ b/src/java/org/apache/fop/fonts/FontReader.java @@ -21,6 +21,9 @@ package org.apache.fop.fonts; //Java import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -56,12 +59,12 @@ public class FontReader extends DefaultHandler { private SingleByteFont singleFont = null; private StringBuffer text = new StringBuffer(); - private List cidWidths = null; + private List cidWidths = null; private int cidWidthIndex = 0; - private Map currentKerning = null; + private Map currentKerning = null; - private List bfranges = null; + private List bfranges = null; private void createFont(InputSource source) throws FOPException { XMLReader parser = null; @@ -181,13 +184,13 @@ public class FontReader extends DefaultHandler { returnFont.setEmbedResourceName(attributes.getValue("class")); } else if ("cid-widths".equals(localName)) { cidWidthIndex = getInt(attributes.getValue("start-index")); - cidWidths = new java.util.ArrayList(); + cidWidths = new ArrayList(); } else if ("kerning".equals(localName)) { - currentKerning = new java.util.HashMap(); + currentKerning = new HashMap(); returnFont.putKerningEntry(new Integer(attributes.getValue("kpx1")), currentKerning); } else if ("bfranges".equals(localName)) { - bfranges = new java.util.ArrayList(); + bfranges = new ArrayList(); } else if ("bf".equals(localName)) { BFEntry entry = new BFEntry(getInt(attributes.getValue("us")), getInt(attributes.getValue("ue")), @@ -231,7 +234,7 @@ public class FontReader extends DefaultHandler { } else if ("full-name".equals(localName)) { returnFont.setFullName(content); } else if ("family-name".equals(localName)) { - Set s = new java.util.HashSet(); + Set s = new HashSet(); s.add(content); returnFont.setFamilyNames(s); } else if ("ttc-name".equals(localName) && isCID) { @@ -284,15 +287,14 @@ public class FontReader extends DefaultHandler { int[] wds = new int[cidWidths.size()]; int j = 0; for (int count = 0; count < cidWidths.size(); count++) { - Integer i = (Integer)cidWidths.get(count); - wds[j++] = i.intValue(); + wds[j++] = cidWidths.get(count).intValue(); } //multiFont.addCIDWidthEntry(cidWidthIndex, wds); multiFont.setWidthArray(wds); } else if ("bfranges".equals(localName)) { - multiFont.setBFEntries((BFEntry[])bfranges.toArray(new BFEntry[0])); + multiFont.setBFEntries(bfranges.toArray(new BFEntry[0])); } text.setLength(0); //Reset text buffer (see characters()) } diff --git a/src/java/org/apache/fop/fonts/FontSetup.java b/src/java/org/apache/fop/fonts/FontSetup.java index 1f49f7bb5..935f695b1 100644 --- a/src/java/org/apache/fop/fonts/FontSetup.java +++ b/src/java/org/apache/fop/fonts/FontSetup.java @@ -72,7 +72,8 @@ public final class FontSetup { * @param embedFontInfoList a list of EmbedFontInfo objects * @param resolver the font resolver */ - public static void setup(FontInfo fontInfo, List embedFontInfoList, FontResolver resolver) { + public static void setup(FontInfo fontInfo, List embedFontInfoList, + FontResolver resolver) { final boolean base14Kerning = false; fontInfo.addMetrics("F1", new Helvetica(base14Kerning)); fontInfo.addMetrics("F2", new HelveticaOblique(base14Kerning)); @@ -190,7 +191,7 @@ public final class FontSetup { * @param resolver the font resolver */ private static void addConfiguredFonts(FontInfo fontInfo, - List/**/ embedFontInfoList, int num, FontResolver resolver) { + List embedFontInfoList, int num, FontResolver resolver) { if (embedFontInfoList == null) { return; //No fonts to process } @@ -202,18 +203,16 @@ public final class FontSetup { String internalName = null; - for (int i = 0; i < embedFontInfoList.size(); i++) { - EmbedFontInfo embedFontInfo = (EmbedFontInfo)embedFontInfoList.get(i); - + for (EmbedFontInfo embedFontInfo : embedFontInfoList) { internalName = "F" + num; num++; LazyFont font = new LazyFont(embedFontInfo, resolver); fontInfo.addMetrics(internalName, font); - List triplets = embedFontInfo.getFontTriplets(); + List triplets = embedFontInfo.getFontTriplets(); for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) { - FontTriplet triplet = (FontTriplet) triplets.get(tripletIndex); + FontTriplet triplet = triplets.get(tripletIndex); fontInfo.addFontProperties(internalName, triplet); } } diff --git a/src/java/org/apache/fop/fonts/FontTriplet.java b/src/java/org/apache/fop/fonts/FontTriplet.java index f5cfe442a..c14634460 100644 --- a/src/java/org/apache/fop/fonts/FontTriplet.java +++ b/src/java/org/apache/fop/fonts/FontTriplet.java @@ -25,7 +25,7 @@ import java.io.Serializable; /** * FontTriplet contains information on name, style and weight of one font */ -public class FontTriplet implements Comparable, Serializable { +public class FontTriplet implements Comparable, Serializable { /** serial version UID */ private static final long serialVersionUID = 1168991106658033508L; @@ -99,8 +99,8 @@ public class FontTriplet implements Comparable, Serializable { } /** {@inheritDoc} */ - public int compareTo(Object o) { - return getKey().compareTo(((FontTriplet)o).getKey()); + public int compareTo(FontTriplet o) { + return getKey().compareTo(o.getKey()); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java index e5d111d38..a8fd447c4 100644 --- a/src/java/org/apache/fop/fonts/LazyFont.java +++ b/src/java/org/apache/fop/fonts/LazyFont.java @@ -221,7 +221,7 @@ public class LazyFont extends Typeface implements FontDescriptor { } /** {@inheritDoc} */ - public Set getFamilyNames() { + public Set getFamilyNames() { load(true); return realFont.getFamilyNames(); } @@ -293,7 +293,7 @@ public class LazyFont extends Typeface implements FontDescriptor { /** * {@inheritDoc} */ - public Map getKerningInfo() { + public Map> getKerningInfo() { load(true); return realFont.getKerningInfo(); } diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java index b3b5d8639..afac21c1b 100644 --- a/src/java/org/apache/fop/fonts/MultiByteFont.java +++ b/src/java/org/apache/fop/fonts/MultiByteFont.java @@ -237,7 +237,7 @@ public class MultiByteFont extends CIDFont { * Returns a Map of used Glyphs. * @return Map Map of used Glyphs */ - public Map getUsedGlyphs() { + public Map getUsedGlyphs() { return subset.getSubsetGlyphs(); } diff --git a/src/java/org/apache/fop/fonts/MutableFont.java b/src/java/org/apache/fop/fonts/MutableFont.java index a5acf51b3..bcbcadbdc 100644 --- a/src/java/org/apache/fop/fonts/MutableFont.java +++ b/src/java/org/apache/fop/fonts/MutableFont.java @@ -46,7 +46,7 @@ public interface MutableFont { * Sets the font's family names (Example: "Helvetica"). * @param names the font's family names (a Set of Strings) */ - void setFamilyNames(Set names); + void setFamilyNames(Set names); /** * Sets the path to the embeddable font file. @@ -137,6 +137,6 @@ public interface MutableFont { * @param key Kerning key * @param value Kerning value */ - void putKerningEntry(Integer key, Map value); + void putKerningEntry(Integer key, Map value); } diff --git a/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java b/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java index d55529d58..cec39bfb9 100644 --- a/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java +++ b/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java @@ -19,13 +19,14 @@ package org.apache.fop.fonts; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.xmlgraphics.fonts.Glyphs; - import org.apache.fop.util.CharUtilities; +import org.apache.xmlgraphics.fonts.Glyphs; /** * A simple implementation of the OneByteEncoding mostly used for encodings that are constructed @@ -33,11 +34,9 @@ import org.apache.fop.util.CharUtilities; */ public class SimpleSingleByteEncoding implements SingleByteEncoding { - private String name; - private List mapping = new java.util.ArrayList(); - //List - private Map charMap = new java.util.HashMap(); - //Map + private final String name; + private final List mapping = new ArrayList(); + private final Map charMap = new HashMap(); /** * Main constructor. @@ -54,7 +53,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { /** {@inheritDoc} */ public char mapChar(char c) { - Character nc = (Character)charMap.get(new Character(c)); + Character nc = charMap.get(new Character(c)); if (nc != null) { return nc.charValue(); } @@ -66,7 +65,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { String[] map = new String[getSize()]; Arrays.fill(map, Glyphs.NOTDEF); for (int i = getFirstChar(); i <= getLastChar(); i++) { - NamedCharacter ch = (NamedCharacter)this.mapping.get(i - 1); + NamedCharacter ch = this.mapping.get(i - 1); map[i] = ch.getName(); } return map; @@ -133,7 +132,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { throw new IllegalArgumentException("codePoint must be between 0 and 255"); } if (codePoint <= getLastChar()) { - return (NamedCharacter)this.mapping.get(codePoint - 1); + return this.mapping.get(codePoint - 1); } else { return null; } @@ -152,6 +151,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { } /** {@inheritDoc} */ + @Override public String toString() { return getName() + " (" + getSize() + " chars)"; } diff --git a/src/java/org/apache/fop/fonts/SingleByteFont.java b/src/java/org/apache/fop/fonts/SingleByteFont.java index fb4725bd4..d798db1bb 100644 --- a/src/java/org/apache/fop/fonts/SingleByteFont.java +++ b/src/java/org/apache/fop/fonts/SingleByteFont.java @@ -19,10 +19,12 @@ package org.apache.fop.fonts; -import java.util.Iterator; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -40,9 +42,8 @@ public class SingleByteFont extends CustomFont { private int[] width = null; - private Map unencodedCharacters; - //Map - private List additionalEncodings; + private Map unencodedCharacters; + private List additionalEncodings; /** @@ -59,6 +60,7 @@ public class SingleByteFont extends CustomFont { } /** {@inheritDoc} */ + @Override public String getEncodingName() { return this.mapping.getName(); } @@ -84,8 +86,7 @@ public class SingleByteFont extends CustomFont { int codePoint = i % 256; NamedCharacter nc = encoding.getCharacterForIndex(codePoint); UnencodedCharacter uc - = (UnencodedCharacter)this.unencodedCharacters.get( - new Character(nc.getSingleUnicodeValue())); + = this.unencodedCharacters.get(new Character(nc.getSingleUnicodeValue())); return size * uc.getWidth(); } return 0; @@ -99,6 +100,7 @@ public class SingleByteFont extends CustomFont { } /** {@inheritDoc} */ + @Override public char mapChar(char c) { notifyMapOperation(); char d = mapping.mapChar(c); @@ -117,11 +119,10 @@ public class SingleByteFont extends CustomFont { private char mapUnencodedChar(char ch) { if (this.unencodedCharacters != null) { - UnencodedCharacter unencoded - = (UnencodedCharacter)this.unencodedCharacters.get(new Character(ch)); + UnencodedCharacter unencoded = this.unencodedCharacters.get(new Character(ch)); if (unencoded != null) { if (this.additionalEncodings == null) { - this.additionalEncodings = new java.util.ArrayList(); + this.additionalEncodings = new ArrayList(); } SimpleSingleByteEncoding encoding = null; char mappedStart = 0; @@ -150,6 +151,7 @@ public class SingleByteFont extends CustomFont { } /** {@inheritDoc} */ + @Override public boolean hasChar(char c) { char d = mapping.mapChar(c); if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { @@ -230,7 +232,7 @@ public class SingleByteFont extends CustomFont { */ public void addUnencodedCharacter(NamedCharacter ch, int width) { if (this.unencodedCharacters == null) { - this.unencodedCharacters = new java.util.HashMap(); + this.unencodedCharacters = new HashMap(); } if (ch.hasSingleUnicodeValue()) { UnencodedCharacter uc = new UnencodedCharacter(ch, width); @@ -248,10 +250,8 @@ public class SingleByteFont extends CustomFont { */ public void encodeAllUnencodedCharacters() { if (this.unencodedCharacters != null) { - Set sortedKeys = new java.util.TreeSet(this.unencodedCharacters.keySet()); - Iterator iter = sortedKeys.iterator(); - while (iter.hasNext()) { - Character ch = (Character)iter.next(); + Set sortedKeys = new TreeSet(this.unencodedCharacters.keySet()); + for (Character ch : sortedKeys) { char mapped = mapChar(ch.charValue()); assert mapped != Typeface.NOT_FOUND; } @@ -287,7 +287,7 @@ public class SingleByteFont extends CustomFont { public SimpleSingleByteEncoding getAdditionalEncoding(int index) throws IndexOutOfBoundsException { if (hasAdditionalEncodings()) { - return (SimpleSingleByteEncoding)this.additionalEncodings.get(index); + return this.additionalEncodings.get(index); } else { throw new IndexOutOfBoundsException("No additional encodings available"); } @@ -303,7 +303,7 @@ public class SingleByteFont extends CustomFont { int[] arr = new int[enc.getLastChar() - enc.getFirstChar() + 1]; for (int i = 0, c = arr.length; i < c; i++) { NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i); - UnencodedCharacter uc = (UnencodedCharacter)this.unencodedCharacters.get( + UnencodedCharacter uc = this.unencodedCharacters.get( new Character(nc.getSingleUnicodeValue())); arr[i] = uc.getWidth(); } @@ -312,8 +312,8 @@ public class SingleByteFont extends CustomFont { private static final class UnencodedCharacter { - private NamedCharacter character; - private int width; + private final NamedCharacter character; + private final int width; public UnencodedCharacter(NamedCharacter character, int width) { this.character = character; @@ -329,6 +329,7 @@ public class SingleByteFont extends CustomFont { } /** {@inheritDoc} */ + @Override public String toString() { return getCharacter().toString(); } diff --git a/src/java/org/apache/fop/fonts/Typeface.java b/src/java/org/apache/fop/fonts/Typeface.java index f0419464c..a0c1d99ec 100644 --- a/src/java/org/apache/fop/fonts/Typeface.java +++ b/src/java/org/apache/fop/fonts/Typeface.java @@ -19,6 +19,7 @@ package org.apache.fop.fonts; +import java.util.HashSet; import java.util.Set; import org.apache.commons.logging.Log; @@ -49,7 +50,7 @@ public abstract class Typeface implements FontMetrics { /** An optional event listener that receives events such as missing glyphs etc. */ protected FontEventListener eventListener; - private Set warnedChars; + private Set warnedChars; /** * Get the encoding of the font. @@ -120,7 +121,7 @@ public abstract class Typeface implements FontMetrics { // Give up, character is not available Character ch = new Character(c); if (warnedChars == null) { - warnedChars = new java.util.HashSet(); + warnedChars = new HashSet(); } if (warnedChars.size() < 8 && !warnedChars.contains(ch)) { warnedChars.add(ch); diff --git a/src/java/org/apache/fop/fonts/autodetect/FontFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontFinder.java index 0ab71daec..ee0d1e07f 100644 --- a/src/java/org/apache/fop/fonts/autodetect/FontFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontFinder.java @@ -37,6 +37,6 @@ public interface FontFinder { * @throws IOException * In case of an I/O problem */ - List/**/ find() throws IOException; + List find() throws IOException; } diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java index a049aaf04..11386299e 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java @@ -28,10 +28,8 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - -import org.apache.xmlgraphics.fonts.Glyphs; - import org.apache.fop.fonts.FontUtil; +import org.apache.xmlgraphics.fonts.Glyphs; /** * Reads a TrueType file or a TrueType Collection. @@ -48,17 +46,17 @@ public class TTFFile { /** Set to true to get even more debug output than with level DEBUG */ public static final boolean TRACE_ENABLED = false; - private String encoding = "WinAnsiEncoding"; // Default encoding + private final String encoding = "WinAnsiEncoding"; // Default encoding - private short firstChar = 0; + private final short firstChar = 0; private boolean isEmbeddable = true; private boolean hasSerifs = true; /** * Table directory */ protected Map dirTabs; - private Map kerningTab; // for CIDs - private Map ansiKerningTab; // For winAnsiEncoding + private Map> kerningTab; // for CIDs + private Map> ansiKerningTab; // For winAnsiEncoding private List cmaps; private List unicodeMapping; @@ -77,12 +75,12 @@ public class TTFFile { * Contains glyph data */ protected TTFMtxEntry[] mtxTab; // Contains glyph data - private int[] mtxEncoded = null; + private final int[] mtxEncoded = null; private String postScriptName = ""; private String fullName = ""; private String notice = ""; - private Set familyNames = new java.util.HashSet(); //Set + private final Set familyNames = new java.util.HashSet(); //Set private String subFamilyName = ""; private long italicAngle = 0; @@ -115,8 +113,8 @@ public class TTFFile { // internal mapping of glyph indexes to unicode indexes // used for quick mappings in this class - private Map glyphToUnicodeMap = new java.util.HashMap(); - private Map unicodeToGlyphMap = new java.util.HashMap(); + private final Map glyphToUnicodeMap = new java.util.HashMap(); + private final Map unicodeToGlyphMap = new java.util.HashMap(); private TTFDirTabEntry currentDirTab; @@ -132,8 +130,8 @@ public class TTFFile { */ class UnicodeMapping { - private int unicodeIndex; - private int glyphIndex; + private final int unicodeIndex; + private final int glyphIndex; UnicodeMapping(int glyphIndex, int unicodeIndex) { this.unicodeIndex = unicodeIndex; @@ -492,7 +490,7 @@ public class TTFFile { ansiIndex = new java.util.HashMap(); for (int i = 32; i < Glyphs.WINANSI_ENCODING.length; i++) { Integer ansi = new Integer(i); - Integer uni = new Integer((int)Glyphs.WINANSI_ENCODING[i]); + Integer uni = new Integer(Glyphs.WINANSI_ENCODING[i]); List v = (List)ansiIndex.get(uni); if (v == null) { @@ -641,7 +639,7 @@ public class TTFFile { * @return int The CapHeight */ public int getCapHeight() { - return (int)convertTTFUnit2PDFUnit(capHeight); + return convertTTFUnit2PDFUnit(capHeight); } /** @@ -649,7 +647,7 @@ public class TTFFile { * @return int The XHeight */ public int getXHeight() { - return (int)convertTTFUnit2PDFUnit(xHeight); + return convertTTFUnit2PDFUnit(xHeight); } /** @@ -708,10 +706,10 @@ public class TTFFile { */ public int[] getFontBBox() { final int[] fbb = new int[4]; - fbb[0] = (int)convertTTFUnit2PDFUnit(fontBBox1); - fbb[1] = (int)convertTTFUnit2PDFUnit(fontBBox2); - fbb[2] = (int)convertTTFUnit2PDFUnit(fontBBox3); - fbb[3] = (int)convertTTFUnit2PDFUnit(fontBBox4); + fbb[0] = convertTTFUnit2PDFUnit(fontBBox1); + fbb[1] = convertTTFUnit2PDFUnit(fontBBox2); + fbb[2] = convertTTFUnit2PDFUnit(fontBBox3); + fbb[3] = convertTTFUnit2PDFUnit(fontBBox4); return fbb; } @@ -721,7 +719,7 @@ public class TTFFile { * @return int The LowerCaseAscent */ public int getLowerCaseAscent() { - return (int)convertTTFUnit2PDFUnit(ascender); + return convertTTFUnit2PDFUnit(ascender); } /** @@ -729,7 +727,7 @@ public class TTFFile { * @return int The LowerCaseDescent */ public int getLowerCaseDescent() { - return (int)convertTTFUnit2PDFUnit(descender); + return convertTTFUnit2PDFUnit(descender); } /** @@ -756,7 +754,7 @@ public class TTFFile { public int[] getWidths() { int[] wx = new int[mtxTab.length]; for (int i = 0; i < wx.length; i++) { - wx[i] = (int)convertTTFUnit2PDFUnit(mtxTab[i].getWx()); + wx[i] = convertTTFUnit2PDFUnit(mtxTab[i].getWx()); } return wx; @@ -768,14 +766,14 @@ public class TTFFile { * @return int Standard width */ public int getCharWidth(int idx) { - return (int)convertTTFUnit2PDFUnit(ansiWidth[idx]); + return convertTTFUnit2PDFUnit(ansiWidth[idx]); } /** * Returns the kerning table. * @return Map The kerning table */ - public Map getKerning() { + public Map> getKerning() { return kerningTab; } @@ -783,7 +781,7 @@ public class TTFFile { * Returns the ANSI kerning table. * @return Map The ANSI kerning table */ - public Map getAnsiKerning() { + public Map> getAnsiKerning() { return ansiKerningTab; } @@ -1440,11 +1438,11 @@ public class TTFFile { log.debug("Ignoring kerning pair because Unicode index was" + " found for the second glyph " + i); } else { - Map adjTab = (Map)kerningTab.get(iObj); + Map adjTab = kerningTab.get(iObj); if (adjTab == null) { adjTab = new java.util.HashMap(); } - adjTab.put(u2, new Integer((int)convertTTFUnit2PDFUnit(kpx))); + adjTab.put(u2, new Integer(convertTTFUnit2PDFUnit(kpx))); kerningTab.put(iObj, adjTab); } } @@ -1458,8 +1456,8 @@ public class TTFFile { while (ae.hasNext()) { Integer unicodeKey1 = (Integer)ae.next(); Integer cidKey1 = unicodeToGlyph(unicodeKey1.intValue()); - Map akpx = new java.util.HashMap(); - Map ckpx = (Map)kerningTab.get(unicodeKey1); + Map akpx = new java.util.HashMap(); + Map ckpx = kerningTab.get(unicodeKey1); Iterator aee = ckpx.keySet().iterator(); while (aee.hasNext()) { @@ -1640,8 +1638,8 @@ public class TTFFile { System.out.println("Family name: " + familyNames); System.out.println("Subfamily name: " + subFamilyName); System.out.println("Notice: " + notice); - System.out.println("xHeight: " + (int)convertTTFUnit2PDFUnit(xHeight)); - System.out.println("capheight: " + (int)convertTTFUnit2PDFUnit(capHeight)); + System.out.println("xHeight: " + convertTTFUnit2PDFUnit(xHeight)); + System.out.println("capheight: " + convertTTFUnit2PDFUnit(capHeight)); int italic = (int)(italicAngle >> 16); System.out.println("Italic: " + italic); @@ -1654,10 +1652,10 @@ public class TTFFile { System.out.println(); System.out.println("Ascender: " + convertTTFUnit2PDFUnit(ascender)); System.out.println("Descender: " + convertTTFUnit2PDFUnit(descender)); - System.out.println("FontBBox: [" + (int)convertTTFUnit2PDFUnit(fontBBox1) - + " " + (int)convertTTFUnit2PDFUnit(fontBBox2) + " " - + (int)convertTTFUnit2PDFUnit(fontBBox3) + " " - + (int)convertTTFUnit2PDFUnit(fontBBox4) + "]"); + System.out.println("FontBBox: [" + convertTTFUnit2PDFUnit(fontBBox1) + + " " + convertTTFUnit2PDFUnit(fontBBox2) + " " + + convertTTFUnit2PDFUnit(fontBBox3) + " " + + convertTTFUnit2PDFUnit(fontBBox4) + "]"); } private String formatUnitsForDebug(int units) { diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java index 405a25f9e..8ee36ec1f 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java @@ -24,11 +24,9 @@ import java.io.InputStream; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.commons.io.IOUtils; - -import org.apache.xmlgraphics.fonts.Glyphs; - import org.apache.fop.fonts.BFEntry; import org.apache.fop.fonts.CIDFontType; import org.apache.fop.fonts.EncodingMode; @@ -38,6 +36,7 @@ import org.apache.fop.fonts.FontType; import org.apache.fop.fonts.MultiByteFont; import org.apache.fop.fonts.NamedCharacter; import org.apache.fop.fonts.SingleByteFont; +import org.apache.xmlgraphics.fonts.Glyphs; /** * Loads a TrueType font into memory directly from the original font file. @@ -46,7 +45,7 @@ public class TTFFontLoader extends FontLoader { private MultiByteFont multiFont; private SingleByteFont singleFont; - private String subFontName; + private final String subFontName; private EncodingMode encodingMode; /** @@ -80,6 +79,7 @@ public class TTFFontLoader extends FontLoader { } /** {@inheritDoc} */ + @Override protected void read() throws IOException { read(this.subFontName); } @@ -205,21 +205,20 @@ public class TTFFontLoader extends FontLoader { private void copyKerning(TTFFile ttf, boolean isCid) { // Get kerning - Iterator iter; + Set kerningSet; if (isCid) { - iter = ttf.getKerning().keySet().iterator(); + kerningSet = ttf.getKerning().keySet(); } else { - iter = ttf.getAnsiKerning().keySet().iterator(); + kerningSet = ttf.getAnsiKerning().keySet(); } - while (iter.hasNext()) { - Integer kpx1 = (Integer)iter.next(); + for (Integer kpx1 : kerningSet) { - Map h2; + Map h2; if (isCid) { - h2 = (Map)ttf.getKerning().get(kpx1); + h2 = ttf.getKerning().get(kpx1); } else { - h2 = (Map)ttf.getAnsiKerning().get(kpx1); + h2 = ttf.getAnsiKerning().get(kpx1); } returnFont.putKerningEntry(kpx1, h2); } diff --git a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java index 37e24836e..ee89d9303 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java @@ -645,7 +645,7 @@ public class TTFSubSetFile extends TTFFile { * @throws IOException in case of an I/O problem */ public byte[] readFont(FontFileReader in, String name, - Map glyphs) throws IOException { + Map glyphs) throws IOException { //Check if TrueType collection, and that the name exists in the collection if (!checkTTC(in, name)) { @@ -653,7 +653,7 @@ public class TTFSubSetFile extends TTFFile { } //Copy the Map as we're going to modify it - Map subsetGlyphs = new java.util.HashMap(glyphs); + Map subsetGlyphs = new java.util.HashMap(glyphs); output = new byte[in.getFileSize()]; diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index e41a8f272..43276b630 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -27,7 +27,6 @@ import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.fop.area.Area; import org.apache.fop.area.LineArea; import org.apache.fop.area.Trait; @@ -94,7 +93,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager */ private static Log log = LogFactory.getLog(LineLayoutManager.class); - private Block fobj; + private final Block fobj; private boolean isFirstInBlock; /** @@ -103,19 +102,19 @@ public class LineLayoutManager extends InlineStackingLayoutManager * inline break positions. */ private static class LineBreakPosition extends LeafPosition { - private int parIndex; // index of the Paragraph this Position refers to - private int startIndex; //index of the first element this Position refers to - private int availableShrink; - private int availableStretch; - private int difference; - private double dAdjust; // Percentage to adjust (stretch or shrink) - private double ipdAdjust; // Percentage to adjust (stretch or shrink) - private int startIndent; - private int lineHeight; - private int lineWidth; - private int spaceBefore; - private int spaceAfter; - private int baseline; + private final int parIndex; // index of the Paragraph this Position refers to + private final int startIndex; //index of the first element this Position refers to + private final int availableShrink; + private final int availableStretch; + private final int difference; + private final double dAdjust; // Percentage to adjust (stretch or shrink) + private final double ipdAdjust; // Percentage to adjust (stretch or shrink) + private final int startIndent; + private final int lineHeight; + private final int lineWidth; + private final int spaceBefore; + private final int spaceAfter; + private final int baseline; LineBreakPosition( // CSOK: ParameterNumber LayoutManager lm, int index, int startIndex, int breakIndex, @@ -151,9 +150,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager private int whiteSpaceTreament; //private LayoutProps layoutProps; - private Length lineHeight; - private int lead; - private int follow; + private final Length lineHeight; + private final int lead; + private final int follow; private AlignmentContext alignmentContext; private List knuthParagraphs; @@ -194,12 +193,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager // space at the end of the last line (in millipoints) private MinOptMax lineFiller; - private int textAlignment; - private int textAlignmentLast; - private int textIndent; - private int lastLineEndIndent; + private final int textAlignment; + private final int textAlignmentLast; + private final int textIndent; + private final int lastLineEndIndent; // the LM which created the paragraph - private LineLayoutManager layoutManager; + private final LineLayoutManager layoutManager; Paragraph(LineLayoutManager llm, int alignment, int alignmentLast, int indent, int endIndent) { @@ -211,6 +210,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager lastLineEndIndent = endIndent; } + @Override public void startSequence() { // set the minimum amount of empty space at the end of the // last line @@ -245,6 +245,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } + @Override public KnuthSequence endSequence() { if (this.size() > ignoreAtStart) { if (textAlignment == EN_CENTER @@ -294,14 +295,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager } private class LineBreakingAlgorithm extends BreakingAlgorithm { - private LineLayoutManager thisLLM; - private int pageAlignment; + private final LineLayoutManager thisLLM; + private final int pageAlignment; private int activePossibility; private int addedPositions; - private int textIndent; - private int lineHeight; - private int lead; - private int follow; + private final int textIndent; + private final int lineHeight; + private final int lead; + private final int follow; private static final double MAX_DEMERITS = 10e6; public LineBreakingAlgorithm( // CSOK: ParameterNumber @@ -317,6 +318,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager activePossibility = -1; } + @Override public void updateData1(int lineCount, double demerits) { lineLayouts.addPossibility(lineCount, demerits); if (log.isTraceEnabled()) { @@ -324,6 +326,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } + @Override public void updateData2(KnuthNode bestActiveNode, KnuthSequence par, int total) { @@ -466,6 +469,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } + @Override protected int filterActiveNodes() { KnuthNode bestActiveNode = null; @@ -537,6 +541,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } /** {@inheritDoc} */ + @Override public void initialize() { textAlignment = fobj.getTextAlign(); textAlignmentLast = fobj.getTextAlignLast(); @@ -560,6 +565,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } /** {@inheritDoc} */ + @Override public List getNextKnuthElements(LayoutContext context, int alignment) { if (alignmentContext == null) { FontInfo fi = fobj.getFOEventHandler().getFontInfo(); @@ -771,7 +777,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager // we only need an entry in lineLayoutsList. llPoss = new LineLayoutPossibilities(); } else { - llPoss = findOptimalBreakingPoints(alignment, (Paragraph) seq, !paragraphsIterator.hasNext()); + llPoss = findOptimalBreakingPoints(alignment, (Paragraph) seq, + !paragraphsIterator.hasNext()); } lineLayoutsList[i] = llPoss; } @@ -789,7 +796,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager * @param isLastPar flag indicating whether currPar is the last paragraph * @return the line layout possibilities for the paragraph */ - private LineLayoutPossibilities findOptimalBreakingPoints(int alignment, Paragraph currPar, boolean isLastPar) { + private LineLayoutPossibilities findOptimalBreakingPoints(int alignment, Paragraph currPar, + boolean isLastPar) { // use the member lineLayouts, which is read by LineBreakingAlgorithm.updateData1 and 2 lineLayouts = new LineLayoutPossibilities(); double maxAdjustment = 1; @@ -855,7 +863,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // use non-hyphenated breaks, when possible lineLayouts.restorePossibilities(); } - + return lineLayouts; } @@ -1158,6 +1166,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } /** {@inheritDoc} */ + @Override public List getChangedKnuthElements(List oldList, int alignment) { List returnList = new LinkedList(); for (int p = 0; p < knuthParagraphs.size(); p++) { @@ -1340,6 +1349,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager * @param isNotFirst ignored * @return always true */ + @Override protected boolean hasLeadingFence(boolean isNotFirst) { return true; } @@ -1349,6 +1359,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager * @param isNotLast ignored * @return always true */ + @Override protected boolean hasTrailingFence(boolean isNotLast) { return true; } @@ -1396,6 +1407,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager * @param parentIter the iterator of break positions * @param context the context for adding areas */ + @Override public void addAreas(PositionIterator parentIter, LayoutContext context) { while (parentIter.hasNext()) { @@ -1566,6 +1578,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } /** {@inheritDoc} */ + @Override public void addChildArea(Area childArea) { // Make sure childArea is inline area if (childArea instanceof InlineArea) { @@ -1581,16 +1594,19 @@ public class LineLayoutManager extends InlineStackingLayoutManager // --------- Property Resolution related functions --------- // /** {@inheritDoc} */ + @Override public boolean getGeneratesBlockArea() { return true; } /** {@inheritDoc} */ + @Override public boolean getGeneratesLineArea() { return true; } /** {@inheritDoc} */ + @Override public boolean isRestartable() { return true; } diff --git a/src/java/org/apache/fop/pdf/PDFResources.java b/src/java/org/apache/fop/pdf/PDFResources.java index cbfc9d53a..12eca75e4 100644 --- a/src/java/org/apache/fop/pdf/PDFResources.java +++ b/src/java/org/apache/fop/pdf/PDFResources.java @@ -98,11 +98,9 @@ public class PDFResources extends PDFObject { * @param fontInfo font info object to get font information from */ public void addFonts(PDFDocument doc, FontInfo fontInfo) { - Map usedFonts = fontInfo.getUsedFonts(); - Iterator e = usedFonts.keySet().iterator(); - while (e.hasNext()) { - String f = (String)e.next(); - Typeface font = (Typeface)usedFonts.get(f); + Map usedFonts = fontInfo.getUsedFonts(); + for (String f : usedFonts.keySet()) { + Typeface font = usedFonts.get(f); //Check if the font actually had any mapping operations. If not, it is an indication //that it has never actually been used and therefore doesn't have to be embedded. @@ -196,6 +194,7 @@ public class PDFResources extends PDFObject { * @return the PDF * {@inheritDoc} */ + @Override public String toPDFString() { StringBuffer p = new StringBuffer(128); p.append(getObjectID() + "<<\n"); diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java index 6e501c199..be3ace016 100644 --- a/src/java/org/apache/fop/render/PrintRenderer.java +++ b/src/java/org/apache/fop/render/PrintRenderer.java @@ -30,6 +30,7 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.area.Area; import org.apache.fop.area.Trait; import org.apache.fop.fonts.CustomFontCollection; +import org.apache.fop.fonts.EmbedFontInfo; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontCollection; import org.apache.fop.fonts.FontInfo; @@ -48,13 +49,13 @@ public abstract class PrintRenderer extends AbstractRenderer { protected FontResolver fontResolver = null; /** list of fonts */ - protected List/**/ embedFontInfoList = null; + protected List embedFontInfoList = null; /** * Adds a font list to current list of fonts * @param fontList a font info list */ - public void addFontList(List/**/ fontList) { + public void addFontList(List fontList) { if (embedFontInfoList == null) { setFontList(fontList); } else { @@ -65,14 +66,14 @@ public abstract class PrintRenderer extends AbstractRenderer { /** * @param embedFontInfoList list of available fonts */ - public void setFontList(List/**/ embedFontInfoList) { + public void setFontList(List embedFontInfoList) { this.embedFontInfoList = embedFontInfoList; } /** * @return list of available embedded fonts */ - public List/**/ getFontList() { + public List getFontList() { return this.embedFontInfoList; } diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java index 8f94684b2..90305ae03 100644 --- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java +++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java @@ -19,6 +19,7 @@ package org.apache.fop.render; +import java.util.ArrayList; import java.util.List; import org.apache.avalon.framework.configuration.Configuration; @@ -76,7 +77,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator FontEventListener listener = new FontEventAdapter( renderer.getUserAgent().getEventBroadcaster()); - List/**/ embedFontInfoList = buildFontList(cfg, fontResolver, listener); + List embedFontInfoList = buildFontList(cfg, fontResolver, listener); printRenderer.addFontList(embedFontInfoList); } @@ -88,7 +89,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator * @return the list of {@link EmbedFontInfo} objects * @throws FOPException if an error occurs while processing the configuration */ - protected List/**/ buildFontList(Configuration cfg, FontResolver fontResolver, + protected List buildFontList(Configuration cfg, FontResolver fontResolver, FontEventListener listener) throws FOPException { FopFactory factory = userAgent.getFactory(); FontManager fontManager = factory.getFontManager(); @@ -102,7 +103,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator //Read font configuration FontInfoConfigurator fontInfoConfigurator = new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict); - List/**/ fontInfoList = new java.util.ArrayList/**/(); + List fontInfoList = new ArrayList(); fontInfoConfigurator.configure(fontInfoList); return fontInfoList; } @@ -118,7 +119,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo) throws FOPException { FontManager fontManager = userAgent.getFactory().getFontManager(); - List fontCollections = new java.util.ArrayList(); + List fontCollections = new ArrayList(); fontCollections.add(new Base14FontCollection(fontManager.isBase14KerningEnabled())); Configuration cfg = super.getRendererConfig(documentHandler.getMimeType()); @@ -126,7 +127,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator FontResolver fontResolver = new DefaultFontResolver(userAgent); FontEventListener listener = new FontEventAdapter( userAgent.getEventBroadcaster()); - List fontList = buildFontList(cfg, fontResolver, listener); + List fontList = buildFontList(cfg, fontResolver, listener); fontCollections.add(new CustomFontCollection(fontResolver, fontList)); } diff --git a/src/java/org/apache/fop/render/afp/AFPPainter.java b/src/java/org/apache/fop/render/afp/AFPPainter.java index ed16a923b..28ca6c67f 100644 --- a/src/java/org/apache/fop/render/afp/AFPPainter.java +++ b/src/java/org/apache/fop/render/afp/AFPPainter.java @@ -30,11 +30,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Map; -import org.w3c.dom.Document; - -import org.apache.xmlgraphics.image.loader.ImageProcessingHints; -import org.apache.xmlgraphics.image.loader.ImageSessionContext; - import org.apache.fop.afp.AFPBorderPainter; import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPUnitConverter; @@ -55,6 +50,7 @@ import org.apache.fop.afp.util.ResourceAccessor; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; +import org.apache.fop.fonts.Typeface; import org.apache.fop.render.RenderingContext; import org.apache.fop.render.intermediate.AbstractIFPainter; import org.apache.fop.render.intermediate.BorderPainter; @@ -64,6 +60,9 @@ import org.apache.fop.render.intermediate.IFState; import org.apache.fop.traits.BorderProps; import org.apache.fop.traits.RuleStyle; import org.apache.fop.util.CharUtilities; +import org.apache.xmlgraphics.image.loader.ImageProcessingHints; +import org.apache.xmlgraphics.image.loader.ImageSessionContext; +import org.w3c.dom.Document; /** * IFPainter implementation that produces AFP (MO:DCA). @@ -76,12 +75,12 @@ public class AFPPainter extends AbstractIFPainter { private static final int X = 0; private static final int Y = 1; - private AFPDocumentHandler documentHandler; + private final AFPDocumentHandler documentHandler; /** the border painter */ - private AFPBorderPainterAdapter borderPainter; + private final AFPBorderPainterAdapter borderPainter; /** the rectangle painter */ - private AbstractAFPPainter rectanglePainter; + private final AbstractAFPPainter rectanglePainter; /** unit converter */ private final AFPUnitConverter unitConv; @@ -101,6 +100,7 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override protected IFContext getContext() { return this.documentHandler.getContext(); } @@ -165,6 +165,7 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override protected Map createDefaultImageProcessingHints(ImageSessionContext sessionContext) { Map hints = super.createDefaultImageProcessingHints(sessionContext); @@ -175,6 +176,7 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override protected RenderingContext createRenderingContext() { AFPRenderingContext psContext = new AFPRenderingContext( getUserAgent(), @@ -256,6 +258,7 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override public void drawBorderRect(Rectangle rect, BorderProps before, BorderProps after, BorderProps start, BorderProps end) throws IFException { if (before != null || after != null || start != null || end != null) { @@ -271,32 +274,38 @@ public class AFPPainter extends AbstractIFPainter { //and this one. Not done for now to avoid a lot of re-implementation and code duplication. private static class AFPBorderPainterAdapter extends BorderPainter { - private AFPBorderPainter delegate; + private final AFPBorderPainter delegate; public AFPBorderPainterAdapter(AFPBorderPainter borderPainter) { this.delegate = borderPainter; } + @Override protected void clip() throws IOException { //not supported by AFP } + @Override protected void closePath() throws IOException { //used for clipping only, so not implemented } + @Override protected void moveTo(int x, int y) throws IOException { //used for clipping only, so not implemented } + @Override protected void lineTo(int x, int y) throws IOException { //used for clipping only, so not implemented } + @Override protected void saveGraphicsState() throws IOException { //used for clipping only, so not implemented } + @Override protected void restoreGraphicsState() throws IOException { //used for clipping only, so not implemented } @@ -305,6 +314,7 @@ public class AFPPainter extends AbstractIFPainter { return mpt / 1000f; } + @Override protected void drawBorderLine( // CSOK: ParameterNumber int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, Color color) throws IOException { @@ -314,6 +324,7 @@ public class AFPPainter extends AbstractIFPainter { delegate.paint(borderPaintInfo); } + @Override public void drawLine(Point start, Point end, int width, Color color, RuleStyle style) throws IOException { if (start.y != end.y) { @@ -331,6 +342,7 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override public void drawLine(Point start, Point end, int width, Color color, RuleStyle style) throws IFException { try { @@ -357,7 +369,7 @@ public class AFPPainter extends AbstractIFPainter { } // register font as necessary - Map/**/ fontMetricMap = documentHandler.getFontInfo().getFonts(); + Map fontMetricMap = documentHandler.getFontInfo().getFonts(); final AFPFont afpFont = (AFPFont)fontMetricMap.get(fontKey); final Font font = getFontInfo().getFontInstance(triplet, fontSize); AFPPageFonts pageFonts = getPaintingState().getPageFonts(); diff --git a/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java b/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java index 29570e69f..fb88b8bce 100644 --- a/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java +++ b/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java @@ -95,7 +95,7 @@ public class ConfiguredFontCollection implements FontCollection { fontInfo.addMetrics(internalName, font); - List triplets = configFontInfo.getFontTriplets(); + List triplets = configFontInfo.getFontTriplets(); for (int c = 0; c < triplets.size(); c++) { FontTriplet triplet = (FontTriplet) triplets.get(c); diff --git a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java index 6394964ac..6540d6e37 100644 --- a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java +++ b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java @@ -161,7 +161,7 @@ public class CustomFontMetricsMapper extends Typeface implements FontMetricsMapp } /** {@inheritDoc} */ - public final Set getFamilyNames() { + public final Set getFamilyNames() { return typeface.getFamilyNames(); } diff --git a/src/java/org/apache/fop/render/ps/FontResourceCache.java b/src/java/org/apache/fop/render/ps/FontResourceCache.java index 7d6f076a7..086117536 100644 --- a/src/java/org/apache/fop/render/ps/FontResourceCache.java +++ b/src/java/org/apache/fop/render/ps/FontResourceCache.java @@ -21,18 +21,17 @@ package org.apache.fop.render.ps; import java.util.Map; -import org.apache.xmlgraphics.ps.PSResource; - import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.LazyFont; import org.apache.fop.fonts.Typeface; +import org.apache.xmlgraphics.ps.PSResource; /** * A cache for font resource objects. */ class FontResourceCache { - private FontInfo fontInfo; + private final FontInfo fontInfo; /** This is a map of PSResource instances of all fonts defined (key: font key) */ private Map fontResources = new java.util.HashMap(); @@ -67,8 +66,8 @@ class FontResourceCache { postFix = key.substring(pos); key = key.substring(0, pos); } - Map fonts = fontInfo.getFonts(); - Typeface tf = (Typeface)fonts.get(key); + Map fonts = fontInfo.getFonts(); + Typeface tf = fonts.get(key); if (tf instanceof LazyFont) { tf = ((LazyFont)tf).getRealFont(); } diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java index 0d0975045..b8d1b63e8 100644 --- a/src/java/org/apache/fop/render/ps/PSFontUtils.java +++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java @@ -23,7 +23,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; -import java.util.Iterator; import java.util.Map; import javax.xml.transform.Source; @@ -31,13 +30,6 @@ import javax.xml.transform.stream.StreamSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - -import org.apache.xmlgraphics.fonts.Glyphs; -import org.apache.xmlgraphics.ps.DSCConstants; -import org.apache.xmlgraphics.ps.PSGenerator; -import org.apache.xmlgraphics.ps.PSResource; -import org.apache.xmlgraphics.ps.dsc.ResourceTracker; - import org.apache.fop.fonts.Base14Font; import org.apache.fop.fonts.CustomFont; import org.apache.fop.fonts.Font; @@ -47,6 +39,11 @@ import org.apache.fop.fonts.LazyFont; import org.apache.fop.fonts.SingleByteEncoding; import org.apache.fop.fonts.SingleByteFont; import org.apache.fop.fonts.Typeface; +import org.apache.xmlgraphics.fonts.Glyphs; +import org.apache.xmlgraphics.ps.DSCConstants; +import org.apache.xmlgraphics.ps.PSGenerator; +import org.apache.xmlgraphics.ps.PSResource; +import org.apache.xmlgraphics.ps.dsc.ResourceTracker; /** * Utility code for font handling in PostScript. @@ -80,7 +77,8 @@ 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 { return writeFontDict(gen, fontInfo, fonts, false); } @@ -95,14 +93,12 @@ 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 */ - private static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts, - boolean encodeAllCharacters) throws IOException { + private static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, + Map fonts, boolean encodeAllCharacters) throws IOException { gen.commentln("%FOPBeginFontDict"); Map fontResources = new java.util.HashMap(); - Iterator iter = fonts.keySet().iterator(); - while (iter.hasNext()) { - String key = (String)iter.next(); + for (String key : fonts.keySet()) { Typeface tf = getTypeFace(fontInfo, fonts, key); PSResource fontRes = new PSResource(PSResource.TYPE_FONT, tf.getFontName()); fontResources.put(key, fontRes); @@ -130,7 +126,8 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { return fontResources; } - private static void reencodeFonts(PSGenerator gen, Map fonts) throws IOException { + private static void reencodeFonts(PSGenerator gen, Map fonts) + throws IOException { ResourceTracker tracker = gen.getResourceTracker(); if (!tracker.isResourceSupplied(WINANSI_ENCODING_RESOURCE)) { @@ -140,10 +137,8 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { gen.commentln("%FOPBeginFontReencode"); //Rewrite font encodings - Iterator iter = fonts.keySet().iterator(); - while (iter.hasNext()) { - String key = (String)iter.next(); - Typeface tf = (Typeface)fonts.get(key); + for (String key : fonts.keySet()) { + Typeface tf = fonts.get(key); if (tf instanceof LazyFont) { tf = ((LazyFont)tf).getRealFont(); if (tf == null) { @@ -172,8 +167,9 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { gen.commentln("%FOPEndFontReencode"); } - private static Typeface getTypeFace(FontInfo fontInfo, Map fonts, String key) { - Typeface tf = (Typeface)fonts.get(key); + private static Typeface getTypeFace(FontInfo fontInfo, Map fonts, + String key) { + Typeface tf = fonts.get(key); if (tf instanceof LazyFont) { tf = ((LazyFont)tf).getRealFont(); } @@ -181,7 +177,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { //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); - tf = (Typeface)fonts.get(fallbackKey); + tf = fonts.get(fallbackKey); } return tf; } @@ -271,11 +267,9 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { * @return a Map of PSResource instances representing all defined fonts (key: font key) */ public static Map determineSuppliedFonts(ResourceTracker resTracker, - FontInfo fontInfo, Map fonts) { + FontInfo fontInfo, Map fonts) { Map fontResources = new java.util.HashMap(); - Iterator iter = fonts.keySet().iterator(); - while (iter.hasNext()) { - String key = (String)iter.next(); + for (String key : fonts.keySet()) { Typeface tf = getTypeFace(fontInfo, fonts, key); PSResource fontRes = new PSResource("font", tf.getFontName()); fontResources.put(key, fontRes); diff --git a/src/java/org/apache/fop/tools/fontlist/FontSpec.java b/src/java/org/apache/fop/tools/fontlist/FontSpec.java index ce5c7a6c7..953175abc 100644 --- a/src/java/org/apache/fop/tools/fontlist/FontSpec.java +++ b/src/java/org/apache/fop/tools/fontlist/FontSpec.java @@ -22,6 +22,7 @@ package org.apache.fop.tools.fontlist; import java.util.Collection; import java.util.Collections; import java.util.SortedSet; +import java.util.TreeSet; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.fonts.FontTriplet; @@ -33,8 +34,8 @@ public class FontSpec implements Comparable { private String key; private FontMetrics metrics; - private SortedSet familyNames = new java.util.TreeSet(); - private Collection triplets = new java.util.TreeSet(); + private SortedSet familyNames = new TreeSet(); + private Collection triplets = new TreeSet(); /** * Creates a new font spec. @@ -50,7 +51,7 @@ public class FontSpec implements Comparable { * Adds font family names. * @param names the names */ - public void addFamilyNames(Collection names) { + public void addFamilyNames(Collection names) { this.familyNames.addAll(names); } -- cgit v1.2.3