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/02/21 11:02:52 UTC

svn commit: r629729 [1/2] - in /xmlgraphics/fop/branches/Temp_AFPAffineTransform: ./ src/java/org/apache/fop/area/ 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...

Author: acumiskey
Date: Thu Feb 21 02:02:32 2008
New Revision: 629729

URL: http://svn.apache.org/viewvc?rev=629729&view=rev
Log:
work in progress

Modified:
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/build.xml
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/area/Trait.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/pdf/PDFState.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractRenderer.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPPageFonts.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPRenderer.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPState.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/pdf/PDFRenderer.java
    xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/traits/BorderProps.java

Modified: xmlgraphics/fop/branches/Temp_AFPAffineTransform/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPAffineTransform/build.xml?rev=629729&r1=629728&r2=629729&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPAffineTransform/build.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPAffineTransform/build.xml Thu Feb 21 02:02:32 2008
@@ -622,6 +622,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/AbstractState*"/>
       <include name="org/apache/fop/pdf/**"/>
     </patternset>
     <!-- PS transcoder -->

Modified: xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/area/Trait.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/area/Trait.java?rev=629729&r1=629728&r2=629729&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/area/Trait.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/area/Trait.java Thu Feb 21 02:02:32 2008
@@ -36,6 +36,8 @@
  */
 public class Trait implements Serializable {
 
+    private static final long serialVersionUID = -7613709600372824471L;
+
     /**
      * Id reference line, not resolved.
      * not sure if this is needed.
@@ -418,6 +420,8 @@
      */
     public static class InternalLink implements Serializable {
 
+        private static final long serialVersionUID = -6395526777690537059L;
+
         /** The unique key of the PageViewport. */
         private String pvKey;
 
@@ -552,6 +556,8 @@
      * Used for storing back trait information which are related.
      */
     public static class Background implements Serializable {
+
+        private static final long serialVersionUID = 8452078676273242870L;
 
         /** The background color if any. */
         private Color color = null;

Modified: xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/pdf/PDFState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/pdf/PDFState.java?rev=629729&r1=629728&r2=629729&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/pdf/PDFState.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/pdf/PDFState.java Thu Feb 21 02:02:32 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,67 +42,62 @@
  * 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();
-    }
+//    /**
+//     * 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() {
+//        PDFData copy;
+//        try {
+//            copy = (PDFData)getData().clone();
+//            getData().resetTransform();
+//        } catch (CloneNotSupportedException e) {
+//            throw new RuntimeException(e.getMessage());
+//        }
+//        stateStack.add(copy);
+//    }
+//
+//    /**
+//     * @return the currently valid state
+//     */
+//    public PDFData 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 PDFData pop() {
+//        if (getStackLevel() > 0) {
+//            PDFData popped = (PDFData)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.
@@ -141,51 +131,51 @@
         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;
-        }
-    }
+//    /**
+//     * 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;
+//        }
+//    }
 
     /**
      * Set the current paint.
@@ -195,13 +185,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 +211,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,81 +231,54 @@
      * @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".
-     *
-     * @return the base transform, or null if the state stack is empty
-     */
-    public AffineTransform getBaseTransform() {
-       if (stateStack.size() == 0) {
-           return null;
-       } else {
-           Data baseData = (Data) stateStack.get(0);
-           return (AffineTransform) baseData.transform.clone();
-       }
-    }
+//    /**
+//     * 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();) {
+//           PDFData d = (PDFData)iter.next();
+//           tf = d.getTransform();
+//           at.concatenate(tf);
+//       }
+//       at.concatenate(getData().getTransform());
+//       return at;
+//    }
 
     /**
      * Get the graphics state.
@@ -328,90 +293,54 @@
         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;
-        }
+    /** {@inheritDoc} */
+    protected AbstractData instantiateData() {
+        return new PDFData();
     }
 }
 

Modified: xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=629729&r1=629728&r2=629729&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Thu Feb 21 02:02:32 2008
@@ -34,6 +34,7 @@
 
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
+import org.apache.fop.area.BlockParent;
 import org.apache.fop.area.BlockViewport;
 import org.apache.fop.area.CTM;
 import org.apache.fop.area.RegionViewport;
@@ -62,29 +63,20 @@
      * @param block the block to render the traits
      */
     protected void handleBlockTraits(Block block) {
-        int borderPaddingStart = block.getBorderAndPaddingWidthStart();
-        int borderPaddingBefore = block.getBorderAndPaddingWidthBefore();
-        
-        float startx = currentIPPosition / 1000f;
-        float starty = currentBPPosition / 1000f;
-        float width = block.getIPD() / 1000f;
-        float height = block.getBPD() / 1000f;
-
         /* using start-indent now
         Integer spaceStart = (Integer) block.getTrait(Trait.SPACE_START);
         if (spaceStart != null) {
             startx += spaceStart.floatValue() / 1000f;
         }*/
-        startx += block.getStartIndent() / 1000f;
-        startx -= block.getBorderAndPaddingWidthStart() / 1000f;
-
-        width += borderPaddingStart / 1000f;
-        width += block.getBorderAndPaddingWidthEnd() / 1000f;
-        height += borderPaddingBefore / 1000f;
-        height += block.getBorderAndPaddingWidthAfter() / 1000f;
-
-        drawBackAndBorders(block, startx, starty,
-            width, height);
+        float startx = getBlockTraitsStartX(block);
+        float starty = getBlockTraitsStartY(block);
+        float width = (block.getIPD()
+                + block.getBorderAndPaddingWidthStart()
+                + block.getBorderAndPaddingWidthEnd()) / 1000f;
+        float height = (block.getBPD()
+                + block.getBorderAndPaddingWidthBefore()
+                + block.getBorderAndPaddingWidthAfter()) / 1000f;
+        drawBackAndBorders(block, startx, starty, width, height);
     }
 
     /**
@@ -95,19 +87,17 @@
      */
     protected void handleRegionTraits(RegionViewport region) {
         Rectangle2D viewArea = region.getViewArea();
-        float startx = (float)(viewArea.getX() / 1000f);
-        float starty = (float)(viewArea.getY() / 1000f);
-        float width = (float)(viewArea.getWidth() / 1000f);
-        float height = (float)(viewArea.getHeight() / 1000f);
-
         if (region.getRegionReference().getRegionClass() == FO_REGION_BODY) {
             currentBPPosition = region.getBorderAndPaddingWidthBefore();
             currentIPPosition = region.getBorderAndPaddingWidthStart();
         }
+        float startx = (float)(viewArea.getX() / 1000f);
+        float starty = (float)(viewArea.getY() / 1000f);
+        float width = (float)(viewArea.getWidth() / 1000f);
+        float height = (float)(viewArea.getHeight() / 1000f);
         drawBackAndBorders(region, startx, starty, width, height);
     }
 
-    
     /**
      * Draw the background and borders.
      * This draws the background and border traits for an area given
@@ -123,7 +113,6 @@
                     float startx, float starty,
                     float width, float height) {
         // draw background then border
-
         BorderProps bpsBefore = (BorderProps)area.getTrait(Trait.BORDER_BEFORE);
         BorderProps bpsAfter = (BorderProps)area.getTrait(Trait.BORDER_AFTER);
         BorderProps bpsStart = (BorderProps)area.getTrait(Trait.BORDER_START);
@@ -197,14 +186,22 @@
                         drawImage(back.getURL(), pos);
                     }
                 }
-                
                 restoreGraphicsState();
             }
         }
 
         Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height);
-        drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
+        boolean hasBorder = (bpsBefore != null || bpsAfter != null
+                || bpsStart != null || bpsEnd != null);
+        if (hasBorder) {
+            drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);            
+        }
     }
+        
+    private static final int BEFORE = 0;
+    private static final int END = 1;
+    private static final int AFTER = 2;
+    private static final int START = 3;
 
     /**
      * Draws borders.
@@ -213,48 +210,50 @@
      * @param bpsAfter the border specification on the after side
      * @param bpsStart the border specification on the start side
      * @param bpsEnd the border specification on the end side
+     * 
+     * TODO: generalize each of the four conditions into using a parameterized drawBorder()
      */
     protected void drawBorders(Rectangle2D.Float borderRect, 
             BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) {
+        boolean[] border = new boolean[] {
+                (bpsBefore != null), (bpsEnd != null), 
+                (bpsAfter != null), (bpsStart != null)};
         float startx = borderRect.x;
         float starty = borderRect.y;
         float width = borderRect.width;
         float height = borderRect.height;
-        boolean[] b = new boolean[] {
-            (bpsBefore != null), (bpsEnd != null), 
-            (bpsAfter != null), (bpsStart != null)};
-        if (!b[0] && !b[1] && !b[2] && !b[3]) {
-            return;
-        }
-        float[] bw = new float[] {
-            (b[0] ? bpsBefore.width / 1000f : 0.0f),
-            (b[1] ? bpsEnd.width / 1000f : 0.0f),
-            (b[2] ? bpsAfter.width / 1000f : 0.0f),
-            (b[3] ? bpsStart.width / 1000f : 0.0f)};
+        float[] borderWidth = new float[] {
+            (border[BEFORE] ? bpsBefore.width / 1000f : 0.0f),
+            (border[END] ? bpsEnd.width / 1000f : 0.0f),
+            (border[AFTER] ? bpsAfter.width / 1000f : 0.0f),
+            (border[START] ? bpsStart.width / 1000f : 0.0f)};
         float[] clipw = new float[] {
             BorderProps.getClippedWidth(bpsBefore) / 1000f,    
             BorderProps.getClippedWidth(bpsEnd) / 1000f,    
             BorderProps.getClippedWidth(bpsAfter) / 1000f,    
             BorderProps.getClippedWidth(bpsStart) / 1000f};
-        starty += clipw[0];
-        height -= clipw[0];
-        height -= clipw[2];
-        startx += clipw[3];
-        width -= clipw[3];
-        width -= clipw[1];
+        starty += clipw[BEFORE];
+        height -= clipw[BEFORE];
+        height -= clipw[AFTER];
+        startx += clipw[START];
+        width -= clipw[START];
+        width -= clipw[END];
         
         boolean[] slant = new boolean[] {
-            (b[3] && b[0]), (b[0] && b[1]), (b[1] && b[2]), (b[2] && b[3])};
+            (border[START] && border[BEFORE]),
+            (border[BEFORE] && border[END]),
+            (border[END] && border[AFTER]),
+            (border[AFTER] && border[START])};
         if (bpsBefore != null) {
             endTextObject();
 
             float sx1 = startx;
-            float sx2 = (slant[0] ? sx1 + bw[3] - clipw[3] : sx1);
+            float sx2 = (slant[BEFORE] ? sx1 + borderWidth[START] - clipw[START] : sx1);
             float ex1 = startx + width;
-            float ex2 = (slant[1] ? ex1 - bw[1] + clipw[1] : ex1);
-            float outery = starty - clipw[0];
-            float clipy = outery + clipw[0];
-            float innery = outery + bw[0];
+            float ex2 = (slant[END] ? ex1 - borderWidth[END] + clipw[END] : ex1);
+            float outery = starty - clipw[BEFORE];
+            float clipy = outery + clipw[BEFORE];
+            float innery = outery + borderWidth[BEFORE];
 
             saveGraphicsState();
             moveTo(sx1, clipy);
@@ -262,10 +261,10 @@
             float ex1a = ex1;
             if (bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
                 if (bpsStart != null && bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
-                    sx1a -= clipw[3];
+                    sx1a -= clipw[START];
                 }
                 if (bpsEnd != null && bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
-                    ex1a += clipw[1];
+                    ex1a += clipw[END];
                 }
                 lineTo(sx1a, outery);
                 lineTo(ex1a, outery);
@@ -283,12 +282,12 @@
             endTextObject();
 
             float sy1 = starty;
-            float sy2 = (slant[1] ? sy1 + bw[0] - clipw[0] : sy1);
+            float sy2 = (slant[END] ? sy1 + borderWidth[BEFORE] - clipw[BEFORE] : sy1);
             float ey1 = starty + height;
-            float ey2 = (slant[2] ? ey1 - bw[2] + clipw[2] : ey1);
-            float outerx = startx + width + clipw[1];
-            float clipx = outerx - clipw[1];
-            float innerx = outerx - bw[1];
+            float ey2 = (slant[AFTER] ? ey1 - borderWidth[AFTER] + clipw[AFTER] : ey1);
+            float outerx = startx + width + clipw[END];
+            float clipx = outerx - clipw[END];
+            float innerx = outerx - borderWidth[END];
             
             saveGraphicsState();
             moveTo(clipx, sy1);
@@ -296,10 +295,10 @@
             float ey1a = ey1;
             if (bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
                 if (bpsBefore != null && bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
-                    sy1a -= clipw[0];
+                    sy1a -= clipw[BEFORE];
                 }
                 if (bpsAfter != null && bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
-                    ey1a += clipw[2];
+                    ey1a += clipw[AFTER];
                 }
                 lineTo(outerx, sy1a);
                 lineTo(outerx, ey1a);
@@ -316,12 +315,12 @@
             endTextObject();
 
             float sx1 = startx;
-            float sx2 = (slant[3] ? sx1 + bw[3] - clipw[3] : sx1);
+            float sx2 = (slant[START] ? sx1 + borderWidth[AFTER] - clipw[AFTER] : sx1);
             float ex1 = startx + width;
-            float ex2 = (slant[2] ? ex1 - bw[1] + clipw[1] : ex1);
-            float outery = starty + height + clipw[2];
-            float clipy = outery - clipw[2];
-            float innery = outery - bw[2];
+            float ex2 = (slant[AFTER] ? ex1 - borderWidth[END] + clipw[END] : ex1);
+            float outery = starty + height + clipw[AFTER];
+            float clipy = outery - clipw[AFTER];
+            float innery = outery - borderWidth[AFTER];
 
             saveGraphicsState();
             moveTo(ex1, clipy);
@@ -329,10 +328,10 @@
             float ex1a = ex1;
             if (bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
                 if (bpsStart != null && bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
-                    sx1a -= clipw[3];
+                    sx1a -= clipw[START];
                 }
                 if (bpsEnd != null && bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
-                    ex1a += clipw[1];
+                    ex1a += clipw[END];
                 }
                 lineTo(ex1a, outery);
                 lineTo(sx1a, outery);
@@ -349,12 +348,12 @@
             endTextObject();
 
             float sy1 = starty;
-            float sy2 = (slant[0] ? sy1 + bw[0] - clipw[0] : sy1);
+            float sy2 = (slant[START] ? sy1 + borderWidth[BEFORE] - clipw[BEFORE] : sy1);
             float ey1 = sy1 + height;
-            float ey2 = (slant[3] ? ey1 - bw[2] + clipw[2] : ey1);
-            float outerx = startx - clipw[3];
-            float clipx = outerx + clipw[3];
-            float innerx = outerx + bw[3];
+            float ey2 = (slant[START] ? ey1 - borderWidth[AFTER] + clipw[AFTER] : ey1);
+            float outerx = startx - clipw[START];
+            float clipx = outerx + clipw[START];
+            float innerx = outerx + borderWidth[START];
 
             saveGraphicsState();
             moveTo(clipx, ey1);
@@ -362,10 +361,10 @@
             float ey1a = ey1;
             if (bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
                 if (bpsBefore != null && bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
-                    sy1a -= clipw[0];
+                    sy1a -= clipw[BEFORE];
                 }
                 if (bpsAfter != null && bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
-                    ey1a += clipw[2];
+                    ey1a += clipw[AFTER];
                 }
                 lineTo(outerx, ey1a);
                 lineTo(outerx, sy1a);
@@ -380,6 +379,22 @@
         }
     }
     
+    protected java.awt.geom.Point2D getInlineAreaPoint(InlineArea area) {
+        float startx = currentIPPosition / 1000f;
+        float starty = (currentBPPosition + area.getOffset()
+                + area.getBorderAndPaddingWidthBefore()) / 1000f;
+        return new java.awt.geom.Point2D.Float(startx, starty);
+    }
+    
+//    protected float getInlineAreaStartX(InlineArea area) {
+//        return currentIPPosition / 1000f;
+//    }
+//
+//    protected float getInlineAreaStartY(InlineArea area) {
+//        return (currentBPPosition + area.getOffset()
+//                + area.getBorderAndPaddingWidthBefore()) / 1000f;
+//    }
+
     /** 
      * Common method to render the background and borders for any inline area.
      * The all borders and padding are drawn outside the specified area.
@@ -387,29 +402,75 @@
      * rendered
      */
     protected void renderInlineAreaBackAndBorders(InlineArea area) {
-        float x = currentIPPosition / 1000f;
-        float y = (currentBPPosition + area.getOffset()) / 1000f;
+        java.awt.geom.Point2D p = getInlineAreaPoint(area);
+//        float startx = (float)p.getX();
+//        float starty = (float)p.getY();
+        float startx = currentIPPosition / 1000f;
+        float starty = (currentBPPosition + area.getOffset()
+                + area.getBorderAndPaddingWidthBefore()) / 1000f;
         float width = area.getIPD() / 1000f;
         float height = area.getBPD() / 1000f;
         float borderPaddingStart = area.getBorderAndPaddingWidthStart() / 1000f;
-        float borderPaddingBefore = area.getBorderAndPaddingWidthBefore() / 1000f;
         float bpwidth = borderPaddingStart 
                 + (area.getBorderAndPaddingWidthEnd() / 1000f);
-        float bpheight = borderPaddingBefore
+        float bpheight = starty
                 + (area.getBorderAndPaddingWidthAfter() / 1000f);
         
         if (height != 0.0f || bpheight != 0.0f && bpwidth != 0.0f) {
-            drawBackAndBorders(area, x, y - borderPaddingBefore
-                                , width + bpwidth
-                                , height + bpheight);
+            drawBackAndBorders(area, startx, starty, width + bpwidth, height + bpheight);
         }
-        
     }
     
+    /**
+     * Returns the position transform.
+     * @param bp        The block parent
+     * @return the position transform
+     */
+    protected AffineTransform getPositionTransform(BlockParent bp) {
+        AffineTransform transform = new AffineTransform();
+        transform.translate(bp.getXOffset(), bp.getYOffset());
+        
+        //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle
+        transform.translate(
+                -bp.getBorderAndPaddingWidthStart(),
+                -bp.getBorderAndPaddingWidthBefore());
+        return transform;
+    }
+
+    protected float getBlockTraitsStartX(Block block) {
+        return (currentIPPosition + block.getStartIndent()
+                - block.getBorderAndPaddingWidthStart() ) / 1000f;
+    }
+
+    protected float getBlockTraitsStartY(Block block) {
+        return currentBPPosition / 1000f;
+    }
+
+
+    /**
+     * Returns the starting X position for back and borders
+     * @param bv        The block viewport
+     * @return the starting X position
+     */
+    protected float getBackAndBordersStartX(BlockViewport bv) {
+        return 0;
+    }
+
+    /**
+     * Returns the starting Y position for back and borders
+     * @param bv        The block viewport
+     * @return the starting Y position
+     */
+    protected float getBackAndBordersStartY(BlockViewport bv) {
+        return 0;
+    }
+
     private static final QName FOX_TRANSFORM
-            = new QName(ExtensionElementMapping.URI, "fox:transform");
-    
-    /** {@inheritDoc} */
+        = new QName(ExtensionElementMapping.URI, "fox:transform");
+
+    /**
+     * {@inheritDoc}
+     */
     protected void renderBlockViewport(BlockViewport bv, List children) {
         // clip and position viewport if necessary
 
@@ -417,13 +478,6 @@
         int saveIP = currentIPPosition;
         int saveBP = currentBPPosition;
 
-        CTM ctm = bv.getCTM();
-        int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
-        int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
-        //This is the content-rect
-        float width = (float)bv.getIPD() / 1000f;
-        float height = (float)bv.getBPD() / 1000f;
-
         if (bv.getPositioning() == Block.ABSOLUTE
                 || bv.getPositioning() == Block.FIXED) {
 
@@ -435,15 +489,10 @@
                 breakOutList = breakOutOfStateStack();
             }
             
-            AffineTransform positionTransform = new AffineTransform();
-            positionTransform.translate(bv.getXOffset(), bv.getYOffset());
+            AffineTransform positionTransform = getPositionTransform(bv);
             
-            //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle
-            positionTransform.translate(-borderPaddingStart, -borderPaddingBefore);
-
             //Free transformation for the block-container viewport
-            String transf;
-            transf = bv.getForeignAttributeValue(FOX_TRANSFORM);
+            String transf = bv.getForeignAttributeValue(FOX_TRANSFORM);
             if (transf != null) {
                 AffineTransform freeTransform = AWTTransformProducer.createAffineTransform(transf);
                 positionTransform.concatenate(freeTransform);
@@ -452,15 +501,27 @@
             saveGraphicsState();
             //Viewport position
             concatenateTransformationMatrix(mptToPt(positionTransform));
-            
+                    
+            //This is the content-rect
+            float width = (float)bv.getIPD() / 1000f;
+            float height = (float)bv.getBPD() / 1000f;
+
             //Background and borders
-            float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
-            float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f;
-            drawBackAndBorders(bv, 0, 0, width + bpwidth, height + bpheight);
+            float bpwidth
+                = (bv.getBorderAndPaddingWidthStart()
+                        + bv.getBorderAndPaddingWidthEnd()) / 1000f;
+            float bpheight
+                = (bv.getBorderAndPaddingWidthBefore()
+                        + bv.getBorderAndPaddingWidthAfter()) / 1000f;
+
+            drawBackAndBorders(bv, 0/*getBackAndBordersStartX(bv)*/, /*getBackAndBordersStartY(bv)*/0,
+                    width + bpwidth, height + bpheight);
 
             //Shift to content rectangle after border painting
             AffineTransform contentRectTransform = new AffineTransform();
-            contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
+            contentRectTransform.translate(
+                    bv.getBorderAndPaddingWidthStart(),
+                    bv.getBorderAndPaddingWidthBefore());
             concatenateTransformationMatrix(mptToPt(contentRectTransform));
             
             //Clipping
@@ -470,7 +531,7 @@
 
             saveGraphicsState();
             //Set up coordinate system for content rectangle
-            AffineTransform contentTransform = ctm.toAffineTransform();
+            AffineTransform contentTransform = bv.getCTM().toAffineTransform();
             concatenateTransformationMatrix(mptToPt(contentTransform));
             
             currentIPPosition = 0;
@@ -479,7 +540,7 @@
 
             restoreGraphicsState();
             restoreGraphicsState();
-            
+
             if (breakOutList != null) {
                 restoreStateStackAfterBreakOut(breakOutList);
             }
@@ -487,6 +548,8 @@
             currentIPPosition = saveIP;
             currentBPPosition = saveBP;
         } else {
+            // bv.getPositioning() == Block.STACK ||
+            // by.getPositioning() == Block.RELATIVE
 
             currentBPPosition += bv.getSpaceBefore();
 
@@ -497,10 +560,10 @@
             currentIPPosition += bv.getStartIndent();
 
             CTM tempctm = new CTM(containingIPPosition, currentBPPosition);
-            ctm = tempctm.multiply(ctm);
+            CTM ctm = tempctm.multiply(bv.getCTM());
             
             //Now adjust for border/padding
-            currentBPPosition += borderPaddingBefore;
+            currentBPPosition += bv.getBorderAndPaddingWidthBefore();
 
             Rectangle2D clippingRect = null;
             if (bv.getClip()) {
@@ -534,7 +597,6 @@
      * @param viewport the viewport to handle
      */
     public void renderViewport(Viewport viewport) {
-
         float x = currentIPPosition / 1000f;
         float y = (currentBPPosition + viewport.getOffset()) / 1000f;
         float width = viewport.getIPD() / 1000f;

Modified: xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractRenderer.java?rev=629729&r1=629728&r2=629729&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/AbstractRenderer.java Thu Feb 21 02:02:32 2008
@@ -276,7 +276,7 @@
             handleRegionTraits(port);
 
             //  shouldn't the viewport have the CTM
-            startVParea(regionReference.getCTM(), port.isClip() ? view : null);
+            startVParea(regionReference.getCTM(), getRegionViewportViewArea(port));
             // do after starting viewport area
             if (regionReference.getRegionClass() == FO_REGION_BODY) {
                 renderBodyRegion((BodyRegion) regionReference);
@@ -287,6 +287,10 @@
         }
     }
 
+    protected Rectangle2D getRegionViewportViewArea(RegionViewport port) {
+        return port.isClip() ? port.getViewArea() : null;
+    }
+    
     /**
      * Establishes a new viewport area.
      *

Modified: xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPPageFonts.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPPageFonts.java?rev=629729&r1=629728&r2=629729&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPPageFonts.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPAffineTransform/src/java/org/apache/fop/render/afp/AFPPageFonts.java Thu Feb 21 02:02:32 2008
@@ -36,13 +36,15 @@
      */
     public AFPFontAttributes registerFont(String fontName, AFPFont font, int fontSize) {
         String pageFontKey = fontName + "_" + fontSize;
-        AFPFontAttributes afpFontAttributes = (AFPFontAttributes)super.get(pageFontKey);
-        // Add to page font mapping if not already present
-        if (afpFontAttributes == null) {
-            afpFontAttributes = new AFPFontAttributes(fontName, font, fontSize);
-            super.put(pageFontKey, afpFontAttributes);
-            afpFontAttributes.setFontReference(super.size());
+        if (!super.containsKey(pageFontKey)) {
+            AFPFontAttributes afpFontAttributes = (AFPFontAttributes)super.get(pageFontKey);
+            // Add to page font mapping if not already present
+            if (afpFontAttributes == null) {
+                afpFontAttributes = new AFPFontAttributes(fontName, font, fontSize);
+                super.put(pageFontKey, afpFontAttributes);
+                afpFontAttributes.setFontReference(super.size());
+            }
         }
-        return afpFontAttributes;
+        return (AFPFontAttributes)super.get(pageFontKey);
     }
 }



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