You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ac...@apache.org on 2008/07/10 12:59:41 UTC

svn commit: r675507 [1/3] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./ src/java/org/apache/fop/pdf/ src/java/org/apache/fop/render/ src/java/org/apache/fop/render/afp/ src/java/org/apache/fop/render/afp/modca/ src/java/org/apache/fop/render...

Author: acumiskey
Date: Thu Jul 10 03:59:39 2008
New Revision: 675507

URL: http://svn.apache.org/viewvc?rev=675507&view=rev
Log:
* Created new AbstractState class that shares common properties and stack popping/pushing behaviour of and is now extended by AFPState and PDFState.
* color, resolution and bitsPerPixel moved from AFPInfo to AFPState/AbstractState resulting in a more simplified AFPInfo and AFPSVGHandler.
* Changed AFPRenderer, AFPDataStream, PresentationTextObject and PresentationTextData to use encapsulated AFPTextDataInfo instead of a chain of long parameter passing between objects.  Also provided some formatting cleanup in PresentationTextData.
* Use of X and Y offsets no longer used by AFPDataStream, setOffsets() is now deprecated and added setOrientation() accessor (which still remains relevant).
* AFPRenderer no longer uses its own bespoke ViewPortPos mechanism and now uses the more standard state stack and AffineTransform mechanism enjoyed by the postscript and PDF Renderers.  This means that there is now a proper implementation for startVParea(), endVParea(), saveGraphicsState(), restoreGraphicsState(), breakOutOfStateStack() and restoreStateStackAfterBreakOut() and it is no longer necessary to have a copy/pasted/tweaked renderBlockViewport() or renderRegionViewport(). As a result of this AFPRenderer is now much more compact (by some 500 lines) - similar work needs to be done in the PCL Renderer, any volunteers?
* Added lots of helpful toString() methods for those mere mortals wishing to step through with a debugger :).

Added:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractState.java   (with props)
Modified:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/pdf/PDFState.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPState.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRenderer.java

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml?rev=675507&r1=675506&r2=675507&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml Thu Jul 10 03:59:39 2008
@@ -593,6 +593,7 @@
       <exclude name="org/apache/fop/render/pdf/PDFRenderer.class"/>
       <exclude name="org/apache/fop/render/pdf/PDFXMLHandler*"/>
       <include name="org/apache/fop/render/*RendererConfigurator**"/>
+      <include name="org/apache/fop/render/*State*"/>
       <include name="org/apache/fop/pdf/**"/>
     </patternset>
 <!-- PS transcoder -->

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/pdf/PDFState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/pdf/PDFState.java?rev=675507&r1=675506&r2=675507&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/pdf/PDFState.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/pdf/PDFState.java Thu Jul 10 03:59:39 2008
@@ -19,14 +19,9 @@
  
 package org.apache.fop.pdf;
 
-import java.io.Serializable;
-import java.util.List;
 import java.util.Iterator;
-
-import java.awt.Color;
 import java.awt.Paint;
 import java.awt.Shape;
-import java.awt.geom.AffineTransform;
 import java.awt.geom.Area;
 import java.awt.geom.GeneralPath;
 
@@ -47,144 +42,12 @@
  * It is impossible to optimise the result without analysing the all
  * the possible combinations after completing.
  */
-public class PDFState {
-
-    private Data data = new Data();
-    
-    private List stateStack = new java.util.ArrayList();
+public class PDFState extends org.apache.fop.render.AbstractState {
 
     /**
      * PDF State for storing graphics state.
      */
     public PDFState() {
-
-    }
-
-    /**
-     * Push the current state onto the stack.
-     * This call should be used when the q operator is used
-     * so that the state is known when popped.
-     */
-    public void push() {
-        Data copy;
-        try {
-            copy = (Data)getData().clone();
-            getData().resetTransform();
-        } catch (CloneNotSupportedException e) {
-            throw new RuntimeException(e.getMessage());
-        }
-        stateStack.add(copy);
-    }
-
-    /**
-     * @return the currently valid state
-     */
-    public Data getData() {
-        return data;
-    }
-    
-    /**
-     * Pop the state from the stack and set current values to popped state.
-     * This should be called when a Q operator is used so
-     * the state is restored to the correct values.
-     * @return the restored state, null if the stack is empty
-     */
-    public Data pop() {
-        if (getStackLevel() > 0) {
-            Data popped = (Data)stateStack.remove(stateStack.size() - 1);
-
-            data = popped;
-            return popped;
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Get the current stack level.
-     *
-     * @return the current stack level
-     */
-    public int getStackLevel() {
-        return stateStack.size();
-    }
-
-    /**
-     * Restore the state to a particular level.
-     * this can be used to restore to a known level without making
-     * multiple pop calls.
-     *
-     * @param stack the level to restore to
-     */
-    /*
-    public void restoreLevel(int stack) {
-        int pos = stack;
-        while (stateStack.size() > pos + 1) {
-            stateStack.remove(stateStack.size() - 1);
-        }
-        if (stateStack.size() > pos) {
-            pop();
-        }
-    }*/
-
-    /**
-     * Set the current line dash.
-     * Check if setting the line dash to the given values
-     * will make a change and then set the state to the new values.
-     *
-     * @param array the line dash array
-     * @param offset the line dash start offset
-     * @return true if the line dash has changed
-     */
-    /*
-    public boolean setLineDash(int[] array, int offset) {
-        return false;
-    }*/
-
-    /**
-     * Set the current line width.
-     * @param width the line width in points
-     * @return true if the line width has changed
-     */
-    public boolean setLineWidth(float width) {
-        if (getData().lineWidth != width) {
-            getData().lineWidth = width;
-            return true;
-        } else {
-            return false;
-        }
-    }
-    
-    /**
-     * Set the current color.
-     * Check if the new color is a change and then set the current color.
-     *
-     * @param col the color to set
-     * @return true if the color has changed
-     */
-    public boolean setColor(Color col) {
-        if (!col.equals(getData().color)) {
-            getData().color = col;
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * Set the current background color.
-     * Check if the background color will change and then set the new color.
-     *
-     * @param col the new background color
-     * @return true if the background color has changed
-     */
-    public boolean setBackColor(Color col) {
-        if (!col.equals(getData().backcolor)) {
-            getData().backcolor = col;
-            return true;
-        } else {
-            return false;
-        }
     }
 
     /**
@@ -195,13 +58,14 @@
      * @return true if the new paint changes the current paint
      */
     public boolean setPaint(Paint p) {
-        if (getData().paint == null) {
+        Paint paint = ((PDFData)getData()).paint; 
+        if (paint == null) {
             if (p != null) {
-                getData().paint = p;
+                ((PDFData)getData()).paint = p;
                 return true;
             }
-        } else if (!data.paint.equals(p)) {
-            getData().paint = p;
+        } else if (!paint.equals(p)) {
+            ((PDFData)getData()).paint = p;
             return true;
         }
         return false;
@@ -220,11 +84,12 @@
      * @return true if the clip will change the current clip.
      */
     public boolean checkClip(Shape cl) {
-        if (getData().clip == null) {
+        Shape clip = ((PDFData)getData()).clip; 
+        if (clip == null) {
             if (cl != null) {
                 return true;
             }
-        } else if (!new Area(getData().clip).equals(new Area(cl))) {
+        } else if (!new Area(clip).equals(new Area(cl))) {
             return true;
         }
         //TODO check for clips that are larger than the current
@@ -239,80 +104,23 @@
      * @param cl the new clip in the current state
      */
     public void setClip(Shape cl) {
-        if (getData().clip != null) {
-            Area newClip = new Area(getData().clip);
+        Shape clip = ((PDFData)getData()).clip; 
+        if (clip != null) {
+            Area newClip = new Area(clip);
             newClip.intersect(new Area(cl));
-            getData().clip = new GeneralPath(newClip);
+            ((PDFData)getData()).clip = new GeneralPath(newClip);
         } else {
-            getData().clip = cl;
+            ((PDFData)getData()).clip = cl;
         }
     }
 
     /**
-     * Check the current transform.
-     * The transform for the current state is the combination of all
-     * transforms in the current state. The parameter is compared
-     * against this current transform.
-     *
-     * @param tf the transform the check against
-     * @return true if the new transform is different then the current transform
-     */
-    public boolean checkTransform(AffineTransform tf) {
-        return !tf.equals(getData().transform);
-    }
-
-    /**
-     * Set a new transform.
-     * This transform is appended to the transform of
-     * the current graphic state.
-     *
-     * @param tf the transform to concatonate to the current level transform
-     * @deprecated This method name is misleading. Use concatenate(AffineTransform) instead!
-     */
-    public void setTransform(AffineTransform tf) {
-        concatenate(tf);
-    }
-    
-    /**
-     * Concatenates the given AffineTransform to the current one.
-     * @param tf the transform to concatenate to the current level transform
-     */
-    public void concatenate(AffineTransform tf) {
-        getData().concatenate(tf);
-    }
-
-    /**
-     * Get the current transform.
-     * This gets the combination of all transforms in the
-     * current state.
-     *
-     * @return the calculate combined transform for the current state
-     */
-    public AffineTransform getTransform() {
-       AffineTransform tf;
-       AffineTransform at = new AffineTransform();
-       for (Iterator iter = stateStack.iterator(); iter.hasNext();) {
-           Data d = (Data)iter.next();
-           tf = d.transform;
-           at.concatenate(tf);
-       }
-       at.concatenate(getData().transform);
-       return at;
-    }
-
-    /**
-     * Get a copy of the base transform for the page. Used to translate
-     * IPP/BPP values into X,Y positions when positioning is "fixed".
+     * Get the current stack level.
      *
-     * @return the base transform, or null if the state stack is empty
+     * @return the current stack level
      */
-    public AffineTransform getBaseTransform() {
-       if (stateStack.size() == 0) {
-           return null;
-       } else {
-           Data baseData = (Data) stateStack.get(0);
-           return (AffineTransform) baseData.transform.clone();
-       }
+    public int getStackLevel() {
+        return getStateStack().size();
     }
 
     /**
@@ -328,90 +136,67 @@
         PDFGState defaultState = PDFGState.DEFAULT;
 
         PDFGState state;
-        PDFGState newstate = new PDFGState();
-        newstate.addValues(defaultState);
-        for (Iterator iter = stateStack.iterator(); iter.hasNext();) {
-            Data d = (Data)iter.next();
+        PDFGState newState = new PDFGState();
+        newState.addValues(defaultState);
+        for (Iterator iter = getStateStack().iterator(); iter.hasNext();) {
+            PDFData d = (PDFData)iter.next();
             state = d.gstate;
             if (state != null) {
-                newstate.addValues(state);
+                newState.addValues(state);
             }
         }
-        if (getData().gstate != null) {
-            newstate.addValues(getData().gstate);
+        if (((PDFData)getData()).gstate != null) {
+            newState.addValues(((PDFData)getData()).gstate);
         }
-
-        return newstate;
+        return newState;
     }
     
-    public class Data implements Cloneable, Serializable {
+    private class PDFData extends org.apache.fop.render.AbstractState.AbstractData {
         
-        public Color color = Color.black;
-        public Color backcolor = Color.black;
-        public Paint paint = null;
-        public Paint backPaint = null;
-        public int lineCap = 0;
-        public int lineJoin = 0;
-        public float lineWidth = 1;
-        public float miterLimit = 0;
-        public boolean text = false;
-        public int dashOffset = 0;
-        public int[] dashArray = new int[0];
-        public AffineTransform transform = new AffineTransform();
-        public float fontSize = 0;
-        public String fontName = "";
-        public Shape clip = null;
-        public PDFGState gstate = null;
+        private static final long serialVersionUID = 3527950647293177764L;
 
+        private Paint paint = null;
+        private Paint backPaint = null;
+        private int lineCap = 0;
+        private int lineJoin = 0;
+        private float miterLimit = 0;
+        private boolean text = false;
+        private int dashOffset = 0;
+        private Shape clip = null;
+        private PDFGState gstate = null;
         
         /** {@inheritDoc} */
         public Object clone() throws CloneNotSupportedException {
-            Data obj = new Data();
-            obj.color = this.color;
-            obj.backcolor = this.backcolor;
+            PDFData obj = (PDFData)super.clone();
             obj.paint = this.paint;
             obj.backPaint = this.paint;
             obj.lineCap = this.lineCap;
             obj.lineJoin = this.lineJoin;
-            obj.lineWidth = this.lineWidth;
             obj.miterLimit = this.miterLimit;
             obj.text = this.text;
             obj.dashOffset = this.dashOffset;
-            obj.dashArray = this.dashArray;
-            obj.transform = new AffineTransform(this.transform);
-            obj.fontSize = this.fontSize;
-            obj.fontName = this.fontName;
             obj.clip = this.clip;
             obj.gstate = this.gstate;
             return obj;
         }
         
-        /**
-         * Get the current Transform.
-         */
-        public AffineTransform getTransform() {
-            return transform;
-        }
-
-        public void resetTransform() {
-            transform = new AffineTransform();
-        }
-
-        /**
-         * Concatenate the given AffineTransform with the current thus creating
-         * a new viewport. Note that all concatenation operations are logged
-         * so they can be replayed if necessary (ex. for block-containers with
-         * "fixed" positioning.
-         * @param at Transformation to perform
-         */
-        public void concatenate(AffineTransform at) {
-            transform.concatenate(at);
-        }
-        
         /** {@inheritDoc} */
         public String toString() {
-            return super.toString() + ", " + this.transform;
+            return super.toString()
+                + ", paint=" + paint
+                + ", backPaint=" + backPaint
+                + ", lineCap=" + lineCap
+                + ", miterLimit=" + miterLimit
+                + ", text=" + text
+                + ", dashOffset=" + dashOffset
+                + ", clip=" + clip
+                + ", gstate=" + gstate;
         }
     }
+
+    /** {@inheritDoc} */
+    protected AbstractData instantiateData() {
+        return new PDFData();
+    }
 }
 

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractState.java?rev=675507&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractState.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractState.java Thu Jul 10 03:59:39 2008
@@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render;
+
+import java.awt.Color;
+import java.awt.geom.AffineTransform;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Stack;
+
+/**
+ * A base class which holds information about the current rendering state.
+ */
+public abstract class AbstractState {
+    private AbstractData currentData = null;
+    private Stack/*<AbstractData>*/ stateStack = null;
+
+    /**
+     * Instantiates a new state data object
+     * @return a new state data object
+     */
+    protected abstract AbstractData instantiateData();
+    
+    /**
+     * @return the currently valid state
+     */
+    public AbstractData getData() {
+        if (currentData == null) {
+            currentData = instantiateData();
+        }
+        return currentData;
+    }
+
+    /**
+     * Set the current color.
+     * Check if the new color is a change and then set the current color.
+     *
+     * @param col the color to set
+     * @return true if the color has changed
+     */
+    public boolean setColor(Color col) {
+        if (!col.equals(getData().color)) {
+            getData().color = col;
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Get the color.
+     * @return the color
+     */
+    public Color getColor() {
+        if (getData().color == null) {
+            getData().color = Color.black;
+        }
+        return getData().color;
+    }
+
+    /**
+     * Get the background color.
+     * @return the background color
+     */
+    public Color getBackColor() {
+        if (getData().backColor == null) {
+            getData().backColor = Color.white;
+        }
+        return getData().backColor;
+    }
+
+    /**
+     * Set the current background color.
+     * Check if the new background color is a change and then set the current background color.
+     *
+     * @param col the background color to set
+     * @return true if the color has changed
+     */
+    public boolean setBackColor(Color col) {
+        if (!col.equals(getData().backColor)) {
+            getData().backColor = col;
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Set the current font name
+     * @param internalFontName the internal font name
+     * @return true if the font name has changed
+     */
+    public boolean setFontName(String internalFontName) {
+        if (!internalFontName.equals(getData().fontName)) {
+            getData().fontName = internalFontName;
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Gets the current font name
+     * @return the current font name
+     */
+    public String getFontName() {
+        return getData().fontName;
+    }
+    
+    /**
+     * Gets the current font size
+     * @return the current font size
+     */
+    public int getFontSize() {
+        return getData().fontSize;
+    }
+
+    /**
+     * Set the current font size.
+     * Check if the font size is a change and then set the current font size.
+     *
+     * @param size the font size to set
+     * @return true if the font size has changed
+     */
+    public boolean setFontSize(int size) {
+        if (size != getData().fontSize) {
+            getData().fontSize = size;
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Set the current line width.
+     * @param width the line width in points
+     * @return true if the line width has changed
+     */
+    public boolean setLineWidth(float width) {
+        if (getData().lineWidth != width) {
+            getData().lineWidth = width;
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Gets the current line width
+     * @return the current line width
+     */
+    public float getLineWidth() {
+        return getData().lineWidth;
+    }
+
+    /**
+     * Sets the dash array (line type) for the current basic stroke
+     * @param dash the line dash array
+     * @return true if the dash array has changed
+     */
+    public boolean setDashArray(float[] dash) {
+        if (!Arrays.equals(dash, getData().dashArray)) {
+            getData().dashArray = dash;
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Get the current transform.
+     * This gets the combination of all transforms in the
+     * current state.
+     *
+     * @return the calculate combined transform for the current state
+     */
+    public AffineTransform getTransform() {
+       AffineTransform at = new AffineTransform();
+       for (Iterator iter = getStateStack().iterator(); iter.hasNext();) {
+           AbstractData data = (AbstractData)iter.next();
+           AffineTransform stackTrans = data.getTransform();
+           at.concatenate(stackTrans);
+       }
+       AffineTransform currentTrans = getData().getTransform();
+       at.concatenate(currentTrans);
+       return at;
+    }
+
+    /**
+     * Check the current transform.
+     * The transform for the current state is the combination of all
+     * transforms in the current state. The parameter is compared
+     * against this current transform.
+     *
+     * @param tf the transform the check against
+     * @return true if the new transform is different then the current transform
+     */
+    public boolean checkTransform(AffineTransform tf) {
+        return !tf.equals(getData().getTransform());
+    }
+
+    /**
+     * Get a copy of the base transform for the page. Used to translate
+     * IPP/BPP values into X,Y positions when positioning is "fixed".
+     *
+     * @return the base transform, or null if the state stack is empty
+     */
+    public AffineTransform getBaseTransform() {
+       if (getStateStack().isEmpty()) {
+           return null;
+       } else {
+           AbstractData baseData = (AbstractData)getStateStack().get(0);
+           return (AffineTransform) baseData.getTransform().clone();
+       }
+    }
+    
+    /**
+     * Concatenates the given AffineTransform to the current one.
+     * @param tf the transform to concatenate to the current level transform
+     */
+    public void concatenate(AffineTransform tf) {
+        getData().concatenate(tf);
+    }
+
+    /**
+     * Resets the current AffineTransform.
+     */
+    public void resetTransform() {
+        getData().resetTransform();
+    }
+
+    /**
+     * Push the current state onto the stack.
+     * This call should be used when the Q operator is used
+     * so that the state is known when popped.
+     */
+    public void push() {
+        AbstractData copy;
+        try {
+            copy = (AbstractData)getData().clone();
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+        getStateStack().push(copy);
+    }
+    
+    /**
+     * Pop the state from the stack and set current values to popped state.
+     * This should be called when a Q operator is used so
+     * the state is restored to the correct values.
+     * @return the restored state, null if the stack is empty
+     */
+    public AbstractData pop() {
+        if (!getStateStack().isEmpty()) {
+            this.currentData = (AbstractData)getStateStack().pop();
+            return this.currentData;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Clears the state stack
+     */    
+    public void clear() {
+        getStateStack().clear();
+        currentData = null;
+    }
+
+    /**
+     * @return the state stack
+     */
+    protected Stack/*<AbstractData>*/ getStateStack() {
+        if (stateStack == null) {
+            stateStack = new java.util.Stack/*<AbstractData>*/();
+        }
+        return stateStack;
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "stateStack=" + stateStack
+        + ", currentData=" + currentData;
+    }
+
+    /**
+     * A base state data holding object 
+     */
+    public abstract class AbstractData implements Cloneable, Serializable {
+        /** The current color */
+        private Color color = null;
+
+        /** The current background color */
+        private Color backColor = null;
+
+        /** The current font name */
+        private String fontName = null;
+
+        /** The current font size */
+        private int fontSize = 0;
+
+        /** The current line width */
+        private float lineWidth = 0;
+
+        /** The dash array for the current basic stroke (line type) */
+        private float[] dashArray = null;
+
+        /** The current transform */
+        private AffineTransform transform = null;
+
+        /**
+         * Concatenate the given AffineTransform with the current thus creating
+         * a new viewport. Note that all concatenation operations are logged
+         * so they can be replayed if necessary (ex. for block-containers with
+         * "fixed" positioning.
+         * @param at Transformation to perform
+         */
+        public void concatenate(AffineTransform at) {
+            getTransform().concatenate(at);
+        }
+
+        /**
+         * Get the current AffineTransform.
+         * @return the current transform
+         */
+        public AffineTransform getTransform() {
+            if (transform == null) {
+                transform = new AffineTransform();
+            }
+            return transform;
+        }
+
+        /**
+         * Resets the current AffineTransform.
+         */
+        public void resetTransform() {
+            transform = new AffineTransform();
+        }
+
+        /** {@inheritDoc} */
+        public Object clone() throws CloneNotSupportedException {
+            AbstractData obj = instantiateData();
+            obj.color = this.color;
+            obj.backColor = this.backColor;
+            obj.fontName = this.fontName;
+            obj.fontSize = this.fontSize;
+            obj.lineWidth = this.lineWidth;
+            obj.dashArray = this.dashArray;
+            obj.transform = new AffineTransform(this.transform);
+            return obj;
+        }
+        
+        /** {@inheritDoc} */
+        public String toString() {
+            return "color=" + color
+                + ", backColor=" + backColor
+                + ", fontName=" + fontName
+                + ", fontSize=" + fontSize
+                + ", lineWidth=" + lineWidth
+                + ", dashArray=" + dashArray
+                + ", transform=" + transform;
+        }
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractState.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java?rev=675507&r1=675506&r2=675507&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java Thu Jul 10 03:59:39 2008
@@ -29,27 +29,27 @@
 public final class AFPInfo {
     /** see WIDTH */
     private int width;
+
     /** see HEIGHT */
     private int height;
+
     /** see XPOS */
     private int x;
+
     /** see YPOS */
     private int y;
+
     /** see HANDLER_CONFIGURATION */
     private Configuration cfg;
 
     /** see AFP_FONT_INFO */
     private FontInfo fontInfo;
+
     /** See AFP_DATASTREAM */
     private AFPDataStream afpDataStream;
+
     /** See AFP_STATE */
     private AFPState afpState;
-    /** see AFP_GRAYSCALE */
-    private boolean color;
-    /** see AFP_RESOLUTION */
-    private int resolution;
-    /** see AFP_BITS_PER_PIXEL */
-    private int bitsPerPixel;
 
     /**
      * Returns the width.
@@ -123,7 +123,7 @@
      * @return true if supports color
      */
     public boolean isColorSupported() {
-        return this.color;
+        return getState().isColorImages();
     }
 
     /**
@@ -144,14 +144,14 @@
      * @return the resolution
      */
     protected int getResolution() {
-        return resolution;
+        return getState().getResolution();
     }
 
     /**
      * @return the number of bits per pixel to use
      */
     protected int getBitsPerPixel() {
-        return bitsPerPixel;
+        return getState().getBitsPerPixel();
     }
 
     /**
@@ -171,14 +171,6 @@
     }
 
     /**
-     * Sets the current resolution
-     * @param resolution the current resolution
-     */
-    protected void setResolution(int resolution) {
-        this.resolution = resolution;
-    }
-
-    /**
      * Sets the current font info
      * @param fontInfo the current font info
      */
@@ -196,25 +188,21 @@
     
     /**
      * Sets the AFP datastream
-     * @param afpDataStream the AFP datastream
-     */
-    public void setAFPDataStream(AFPDataStream afpDataStream) {
-        this.afpDataStream = afpDataStream;
-    }
-
-    /**
-     * Sets if we are supporing color 
-     * @param color true if color is supported
+     * @param dataStream the AFP datastream
      */
-    public void setColor(boolean color) {
-        this.color = color;
+    public void setAFPDataStream(AFPDataStream dataStream) {
+        this.afpDataStream = dataStream;
     }
 
-    /**
-     * Sets the number of bits per pixel
-     * @param bitsPerPixel the number of bits per pixel 
-     */
-    public void setBitsPerPixel(int bitsPerPixel) {
-        this.bitsPerPixel = bitsPerPixel;
+    /** {@inheritDoc} */
+    public String toString() {
+        return "width=" + width
+            + ",height=" + height
+            + ",x=" + x
+            + ",y=" + y
+            + ",cfg=" + cfg
+            + ",fontInfo=" + fontInfo
+            + ",afpDatastream=" + afpDataStream
+            + ",afpState=" + afpState;
     }
 }
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org