From 005e36da82c0bb31c6f906d4052dd6f00d810798 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Thu, 20 Nov 2008 17:52:34 +0000 Subject: [PATCH] Improved plumbing :) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@719307 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/afp/AFPResourceManager.java | 10 +++++++--- src/java/org/apache/fop/afp/AFPStreamer.java | 19 ++++++++----------- .../apache/fop/render/afp/AFPRenderer.java | 4 +--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java index ec5890e39..9a521dbe7 100644 --- a/src/java/org/apache/fop/afp/AFPResourceManager.java +++ b/src/java/org/apache/fop/afp/AFPResourceManager.java @@ -62,12 +62,16 @@ public class AFPResourceManager { /** * Sets the outputstream * - * @param state the AFP painting state + * @param paintingState the AFP painting state * @param outputStream the outputstream + * @return a new AFP DataStream + * @throws IOException thrown if an I/O exception of some sort has occurred */ - public void createDataStream(AFPPaintingState state, OutputStream outputStream) { - this.dataStream = streamer.createDataStream(state); + public DataStream createDataStream(AFPPaintingState paintingState, OutputStream outputStream) + throws IOException { + this.dataStream = streamer.createDataStream(paintingState); streamer.setOutputStream(outputStream); + return this.dataStream; } /** diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java index 007259cd4..7e208bb6e 100644 --- a/src/java/org/apache/fop/afp/AFPStreamer.java +++ b/src/java/org/apache/fop/afp/AFPStreamer.java @@ -83,19 +83,16 @@ public class AFPStreamer implements Streamable { /** * Creates a new DataStream * - * @param state the AFP painting state + * @param paintingState the AFP painting state * @return a new {@link DataStream} + * @throws IOException thrown if an I/O exception of some sort has occurred */ - public DataStream createDataStream(AFPPaintingState state) { - try { - this.tempFile = File.createTempFile(AFPDATASTREAM_TEMP_FILE_PREFIX, null); - this.documentFile = new RandomAccessFile(tempFile, "rw"); - this.documentOutputStream = new BufferedOutputStream( - new FileOutputStream(documentFile.getFD())); - this.dataStream = factory.createDataStream(state, documentOutputStream); - } catch (IOException e) { - log.error(e.getMessage()); - } + public DataStream createDataStream(AFPPaintingState paintingState) throws IOException { + this.tempFile = File.createTempFile(AFPDATASTREAM_TEMP_FILE_PREFIX, null); + this.documentFile = new RandomAccessFile(tempFile, "rw"); + this.documentOutputStream = new BufferedOutputStream( + new FileOutputStream(documentFile.getFD())); + this.dataStream = factory.createDataStream(paintingState, documentOutputStream); return dataStream; } diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 918c67e33..edc8f7662 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -196,9 +196,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { public void startRenderer(OutputStream outputStream) throws IOException { paintingState.setColor(Color.WHITE); - resourceManager.createDataStream(paintingState, outputStream); - - this.dataStream = resourceManager.getDataStream(); + this.dataStream = resourceManager.createDataStream(paintingState, outputStream); this.borderPainter = new AFPBorderPainter(paintingState, dataStream); this.rectanglePainter = new AFPRectanglePainter(paintingState, dataStream); -- 2.39.5