diff options
author | Simon Steiner <ssteiner@apache.org> | 2015-12-04 12:18:50 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2015-12-04 12:18:50 +0000 |
commit | 86fb9989a551ff40a4c0512f550e4ece355939a1 (patch) | |
tree | 0afa3f581768b375a6128b01ac3c03e245d0d015 /src/java | |
parent | adce6da98782037c3802a76aad195c11fb9cb929 (diff) | |
download | xmlgraphics-fop-86fb9989a551ff40a4c0512f550e4ece355939a1.tar.gz xmlgraphics-fop-86fb9989a551ff40a4c0512f550e4ece355939a1.zip |
FOP-2548: Support Barcode4J page number
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1717946 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
7 files changed, 27 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java b/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java index 374fa5833..0c8b4bc0e 100644 --- a/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java +++ b/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java @@ -273,7 +273,7 @@ public abstract class AbstractBitmapDocumentHandler extends AbstractBinaryWritin } graphics2D.scale(scale / 1000f, scale / 1000f); - return new Java2DPainter(graphics2D, getContext(), getFontInfo()); + return new Java2DPainter(graphics2D, getContext(), getFontInfo(), this); } /** diff --git a/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java b/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java index 2c04a0714..929d786ea 100644 --- a/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java +++ b/src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java @@ -188,7 +188,7 @@ public abstract class AbstractIFPainter<T extends IFDocumentHandler> implements if (conversionMode != null) { hints.put(ImageHandlerUtil.CONVERSION_MODE, conversionMode); } - + hints.put("page-number", documentHandler.getContext().getPageNumber()); return hints; } diff --git a/src/java/org/apache/fop/render/intermediate/IFContext.java b/src/java/org/apache/fop/render/intermediate/IFContext.java index 7464e26e0..0edb94c4b 100644 --- a/src/java/org/apache/fop/render/intermediate/IFContext.java +++ b/src/java/org/apache/fop/render/intermediate/IFContext.java @@ -57,6 +57,8 @@ public class IFContext { private int pageIndex = -1; + private int pageNumber = -1; + /** * Main constructor. * @param ua the user agent @@ -234,4 +236,11 @@ public class IFContext { return this.pageIndex; } + public int getPageNumber() { + return pageNumber; + } + + public void setPageNumber(int pageNumber) { + this.pageNumber = pageNumber; + } } diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java index 3d0bfd32f..235e051f9 100644 --- a/src/java/org/apache/fop/render/intermediate/IFParser.java +++ b/src/java/org/apache/fop/render/intermediate/IFParser.java @@ -523,6 +523,7 @@ public class IFParser implements IFConstants { establishForeignAttributes(foreignAttributes); documentHandler.startPage(index, name, pageMasterName, new Dimension(width, height)); + documentHandler.getContext().setPageNumber(Integer.parseInt(name)); resetForeignAttributes(); } diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index e0843ef74..f2eae9ae1 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -573,6 +573,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { establishForeignAttributes(page.getForeignAttributes()); documentHandler.getContext().setPageIndex(page.getPageIndex()); + documentHandler.getContext().setPageNumber(page.getPageNumber()); documentHandler.startPage(page.getPageIndex(), page.getPageNumberString(), page.getSimplePageMasterName(), dim); resetForeignAttributes(); diff --git a/src/java/org/apache/fop/render/java2d/Java2DPainter.java b/src/java/org/apache/fop/render/java2d/Java2DPainter.java index 328d1a4f8..06f67e75b 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DPainter.java +++ b/src/java/org/apache/fop/render/java2d/Java2DPainter.java @@ -41,6 +41,7 @@ import org.apache.fop.render.intermediate.AbstractIFPainter; import org.apache.fop.render.intermediate.BorderPainter; import org.apache.fop.render.intermediate.GraphicsPainter; import org.apache.fop.render.intermediate.IFContext; +import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFException; import org.apache.fop.render.intermediate.IFState; import org.apache.fop.traits.BorderProps; @@ -51,7 +52,7 @@ import org.apache.fop.util.CharUtilities; * {@link org.apache.fop.render.intermediate.IFPainter} implementation that paints on a Graphics2D * instance. */ -public class Java2DPainter extends AbstractIFPainter<Java2DDocumentHandler> { +public class Java2DPainter extends AbstractIFPainter<IFDocumentHandler> { /** the IF context */ protected IFContext ifContext; @@ -74,7 +75,11 @@ public class Java2DPainter extends AbstractIFPainter<Java2DDocumentHandler> { * @param fontInfo the font information */ public Java2DPainter(Graphics2D g2d, IFContext context, FontInfo fontInfo) { - this(g2d, context, fontInfo, null); + this(g2d, context, fontInfo, new Java2DDocumentHandler()); + } + + public Java2DPainter(Graphics2D g2d, IFContext context, FontInfo fontInfo, IFDocumentHandler documentHandler) { + this(g2d, context, fontInfo, null, documentHandler); } /** @@ -86,7 +91,12 @@ public class Java2DPainter extends AbstractIFPainter<Java2DDocumentHandler> { * @param state the IF state object */ public Java2DPainter(Graphics2D g2d, IFContext context, FontInfo fontInfo, IFState state) { - super(new Java2DDocumentHandler()); + this(g2d, context, fontInfo, state, new Java2DDocumentHandler()); + } + + public Java2DPainter(Graphics2D g2d, IFContext context, FontInfo fontInfo, IFState state, + IFDocumentHandler documentHandler) { + super(documentHandler); this.ifContext = context; if (state != null) { this.state = state.push(); diff --git a/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java b/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java index 4d0efd8ed..1991295bd 100644 --- a/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java +++ b/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java @@ -251,7 +251,7 @@ public class PCLDocumentHandler extends AbstractBinaryWritingIFDocumentHandler graphics2D.scale(scale / 1000f, scale / 1000f); graphics2D.translate(-printArea.x, -printArea.y); - return new Java2DPainter(graphics2D, getContext(), getFontInfo()); + return new Java2DPainter(graphics2D, getContext(), getFontInfo(), this); } private BufferedImage createBufferedImage(int bitmapWidth, int bitmapHeight) { |