From 5ef950add63630dc4ca0c6b0bbf0c850a6df764c Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Sun, 23 May 2004 10:43:24 +0000 Subject: [PATCH] Flailing about with the requirements for Java 2D layout git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197617 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FONode.java | 11 ----- src/java/org/apache/fop/fo/FOTree.java | 46 +++++++++++++++---- .../apache/fop/fo/flow/FoPageSequence.java | 35 +++++--------- src/java/org/apache/fop/fo/flow/FoPcdata.java | 6 ++- 4 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index d0aba6029..70517d50c 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -18,7 +18,6 @@ */ package org.apache.fop.fo; -import java.awt.GraphicsEnvironment; import java.awt.geom.Rectangle2D; import java.util.BitSet; import java.util.HashMap; @@ -191,10 +190,6 @@ public class FONode extends SyncedNode implements AreaListener { /** The number of markers on this FO. */ protected int numMarkers = 0; - private GraphicsEnvironment gEnv = null; - protected GraphicsEnvironment getGraphicsEnvironment() { - return gEnv; - } /** * @param foTree an FOTree to which this node belongs * @param type the fo type of this FONode. @@ -230,12 +225,6 @@ public class FONode extends SyncedNode implements AreaListener { exprParser = foTree.exprParser; propertySet = new PropertyValue[PropNames.LAST_PROPERTY_INDEX + 1]; foAttributes = new FOAttributes(event, this); - if (parent == null) { - // Setup the graphics environment - gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment(); - } else { - gEnv = parent.getGraphicsEnvironment(); - } if ((stateFlags & MC_MARKER) == 0) { processAttributes(); } diff --git a/src/java/org/apache/fop/fo/FOTree.java b/src/java/org/apache/fop/fo/FOTree.java index dc9671d20..058cab5df 100644 --- a/src/java/org/apache/fop/fo/FOTree.java +++ b/src/java/org/apache/fop/fo/FOTree.java @@ -18,6 +18,9 @@ */ package org.apache.fop.fo; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.font.FontRenderContext; import java.util.logging.Level; import java.util.logging.Logger; @@ -92,17 +95,40 @@ public class FOTree extends Tree implements Runnable { PropertyConsts.pconsts.getInitialValue(PropNames.FONT_SIZE); if ( ! (prop instanceof Numeric) || ! ((Numeric)prop).isLength()) throw new PropertyException("Initial font-size is not a Length"); + // Set up the rendering context + } - - /* - for (int i = 1; i <= PropNames.LAST_PROPERTY_INDEX; i++) { - if (i == PropNames.FONT_SIZE) continue; - // Set up the initial values for each property - PropertyConsts.pconsts.getInitialValue(i); - //System.out.println("....Setting initial value for " + i); - } - */ - + /** The graphics environment in which FOP is operating */ + private GraphicsEnvironment gEnv = null; + /** + * Gets the FOP GraphicsEnvironment + * @return the environment + */ + protected GraphicsEnvironment getGraphicsEnvironment() { + return gEnv; + } + /** The object which controls drawing and text rendering in the page spread + */ + private Graphics2D g2D = null; + /** + * Gets the Graphics2D rendering and drawing control object + * for area layout + * @return + */ + public Graphics2D getGraphics2D() { + return g2D; + } + /** The FontRenderContext object garnered from the + * Graphics2D control object for area layout + */ + private FontRenderContext frcontext = null; + /** + * Gets the FontRenderContext derived from the graphics + * control object + * @return + */ + public FontRenderContext getFontRenderContext() { + return frcontext; } /** diff --git a/src/java/org/apache/fop/fo/flow/FoPageSequence.java b/src/java/org/apache/fop/fo/flow/FoPageSequence.java index 6a5040377..14d35f92d 100644 --- a/src/java/org/apache/fop/fo/flow/FoPageSequence.java +++ b/src/java/org/apache/fop/fo/flow/FoPageSequence.java @@ -20,10 +20,6 @@ package org.apache.fop.fo.flow; -// FOP -import java.awt.Graphics2D; -import java.awt.GraphicsEnvironment; -import java.awt.font.FontRenderContext; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Arrays; @@ -186,6 +182,18 @@ public class FoPageSequence extends FONode { } return (Page)firstPage; } + + /** An image on which to draw areas */ + private BufferedImage pageSpread = null; + /** + * Gets the page spread image from which the Graphics2D and + * FontRenderContext have been derived. + * @return the page spread + */ + public BufferedImage getPageSpread() { + return pageSpread; + } + /** * @param foTree the FO tree being built * @param parent the parent FONode of this node @@ -202,8 +210,6 @@ public class FoPageSequence extends FONode { // Set up the graphics environment pageSpread = new BufferedImage(20*72, 12*72, BufferedImage.TYPE_INT_RGB); - g2D = pageSpread.createGraphics(); - frcontext = g2D.getFontRenderContext(); XmlEvent ev; // Look for optional title @@ -303,23 +309,6 @@ public class FoPageSequence extends FONode { makeSparsePropsSet(); } - private GraphicsEnvironment gEnv = null; - public GraphicsEnvironment getGraphicsEnvironment() { - return gEnv; - } - private BufferedImage pageSpread = null; - public BufferedImage getPageSpread() { - return pageSpread; - } - private Graphics2D g2D = null; - public Graphics2D getGraphics2D() { - return g2D; - } - private FontRenderContext frcontext = null; - public FontRenderContext getFontRenderContext() { - return frcontext; - } - public Area getReferenceRectangle() throws FOPException { // TODO Reference rectangle is assumed to be equivalent to the // "auto" value on "page-height" and "page-width". The diff --git a/src/java/org/apache/fop/fo/flow/FoPcdata.java b/src/java/org/apache/fop/fo/flow/FoPcdata.java index 1136a4a9c..63041d8c8 100644 --- a/src/java/org/apache/fop/fo/flow/FoPcdata.java +++ b/src/java/org/apache/fop/fo/flow/FoPcdata.java @@ -147,10 +147,12 @@ public class FoPcdata extends FOPageSeqNode { // parent block area. // Generate a text-layout for the PCDATA. /** - * Generate a + * Generates a TextMeasurer from the PCDATA text. The font and text + * attributes of the text are applied. */ private void processText() { - + // Get the font + // } } -- 2.39.5