]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fourth phase of performance improvement.
authorFinn Bock <bckfnn@apache.org>
Wed, 20 Oct 2004 13:37:48 +0000 (13:37 +0000)
committerFinn Bock <bckfnn@apache.org>
Wed, 20 Oct 2004 13:37:48 +0000 (13:37 +0000)
- Consistent naming of the fobj.

PR: 31699

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198087 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/ExternalGraphicLayoutManager.java
src/java/org/apache/fop/layoutmgr/InstreamForeignObjectLM.java
src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java

index adaa19bbda7a73ccc620cc202ec701efbdba6831..2ea2e56a17cca590f083591bf41c2ad5c53721ae 100644 (file)
@@ -34,8 +34,7 @@ import org.apache.fop.image.ImageFactory;
  * LayoutManager for the fo:external-graphic formatting object
  */
 public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
-
-    ExternalGraphic graphic = null;
+    private ExternalGraphic fobj;
 
     private String url;
     private int breakAfter;
@@ -57,12 +56,11 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
      */
     public ExternalGraphicLayoutManager(ExternalGraphic node) {
         super(node);
-
-        graphic = node;
+        fobj = node;
         setup();
         InlineArea area = getExternalGraphicInlineArea();
         setCurrentArea(area);
-        setAlignment(graphic.getVerticalAlign());
+        setAlignment(fobj.getVerticalAlign());
         setLead(viewHeight);
     }
 
@@ -72,24 +70,24 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
      * @todo see if can simplify property handling logic
      */
     private void setup() {
-        url = ImageFactory.getURL(graphic.getSrc());
+        url = ImageFactory.getURL(fobj.getSrc());
 
         // assume lr-tb for now and just use the .optimum value of the range
-        Length ipd = graphic.getPropertyList().get(PR_INLINE_PROGRESSION_DIMENSION).
+        Length ipd = fobj.getPropertyList().get(PR_INLINE_PROGRESSION_DIMENSION).
                                     getLengthRange().getOptimum().getLength();
         if (!ipd.isAuto()) {
             viewWidth = ipd.getValue();
         } else {
-            ipd = graphic.getPropertyList().get(PR_WIDTH).getLength();
+            ipd = fobj.getPropertyList().get(PR_WIDTH).getLength();
             if (!ipd.isAuto()) {
                 viewWidth = ipd.getValue();
             }
         }
-        Length bpd = graphic.getPropertyList().get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange().getOptimum().getLength();
+        Length bpd = fobj.getPropertyList().get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange().getOptimum().getLength();
         if (!bpd.isAuto()) {
             viewHeight = bpd.getValue();
         } else {
-            bpd = graphic.getPropertyList().get(PR_HEIGHT).getLength();
+            bpd = fobj.getPropertyList().get(PR_HEIGHT).getLength();
             if (!bpd.isAuto()) {
                 viewHeight = bpd.getValue();
             }
@@ -100,7 +98,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
 
         int cwidth = -1;
         int cheight = -1;
-        Length ch = graphic.getPropertyList().get(PR_CONTENT_HEIGHT).getLength();
+        Length ch = fobj.getPropertyList().get(PR_CONTENT_HEIGHT).getLength();
         if (!ch.isAuto()) {
             /*if (ch.scaleToFit()) {
                 if (viewHeight != -1) {
@@ -109,7 +107,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
             } else {*/
             cheight = ch.getValue();
         }
-        Length cw = graphic.getPropertyList().get(PR_CONTENT_WIDTH).getLength();
+        Length cw = fobj.getPropertyList().get(PR_CONTENT_WIDTH).getLength();
         if (!cw.isAuto()) {
             /*if (cw.scaleToFit()) {
                 if (viewWidth != -1) {
@@ -119,10 +117,10 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
             cwidth = cw.getValue();
         }
 
-        int scaling = graphic.getScaling();
+        int scaling = fobj.getScaling();
         if ((scaling == Scaling.UNIFORM) || (cwidth == -1) || cheight == -1) {
             ImageFactory fact = ImageFactory.getInstance();
-            fopimage = fact.getImage(url, graphic.getUserAgent());
+            fopimage = fact.getImage(url, fobj.getUserAgent());
             if (fopimage == null) {
                 // error
                 url = null;
@@ -162,11 +160,11 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
         }
 
         if (cwidth > viewWidth || cheight > viewHeight) {
-            int overflow = graphic.getOverflow();
+            int overflow = fobj.getOverflow();
             if (overflow == Overflow.HIDDEN) {
                 clip = true;
             } else if (overflow == Overflow.ERROR_IF_OVERFLOW) {
-                graphic.getLogger().error("Image: " + url
+                fobj.getLogger().error("Image: " + url
                                   + " overflows the viewport, clipping to viewport");
                 clip = true;
             }
@@ -174,7 +172,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
 
         int xoffset = 0;
         int yoffset = 0;
-        switch(graphic.getDisplayAlign()) {
+        switch(fobj.getDisplayAlign()) {
             case DisplayAlign.BEFORE:
             break;
             case DisplayAlign.AFTER:
@@ -188,7 +186,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
             break;
         }
 
-        switch(graphic.getTextAlign()) {
+        switch(fobj.getTextAlign()) {
             case TextAlign.CENTER:
                 xoffset = (viewWidth - cwidth) / 2;
             break;
@@ -211,7 +209,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
       * @return the viewport containing the image area
       */
      public InlineArea getExternalGraphicInlineArea() {
-         Image imArea = new Image(graphic.getSrc());
+         Image imArea = new Image(fobj.getSrc());
          Viewport vp = new Viewport(imArea);
          vp.setIPD(viewWidth);
          vp.setBPD(viewHeight);
@@ -220,14 +218,14 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
          vp.setOffset(0);
 
          // Common Border, Padding, and Background Properties
-         TraitSetter.addBorders(vp, graphic.getCommonBorderPaddingBackground());
-         TraitSetter.addBackground(vp, graphic.getCommonBorderPaddingBackground());
+         TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground());
+         TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground());
 
          return vp;
      }
      
      protected void addId() {
-         addID(graphic.getId());
+         addID(fobj.getId());
      }
 }
 
index bfd6960edca00648143e7781d9ea0adf829dea2c..2cdfbb2dfe67885bb4745f82dd29fd7f5659a572 100644 (file)
@@ -33,8 +33,7 @@ import org.apache.fop.area.inline.Viewport;
  * LayoutManager for the fo:basic-link formatting object
  */
 public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
-
-    InstreamForeignObject ifoNode;
+    private InstreamForeignObject fobj;
     
     /**
      * Constructor
@@ -42,7 +41,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
      */
     public InstreamForeignObjectLM(InstreamForeignObject node) {
         super(node);
-        ifoNode = node;
+        fobj = node;
         Viewport areaCurrent = getInlineArea();
         setCurrentArea(areaCurrent);
         setAlignment(node.getVerticalAlign());
@@ -55,7 +54,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
      * @return the viewport inline area
      */
     private Viewport getInlineArea() {
-        XMLObj child = (XMLObj) ifoNode.childNodes.get(0);
+        XMLObj child = (XMLObj) fobj.childNodes.get(0);
 
         // viewport size is determined by block-progression-dimension
         // and inline-progression-dimension
@@ -72,27 +71,27 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         int ipd = -1;
         boolean bpdauto = false;
         if (hasLH) {
-            bpd = ifoNode.getLineHeight().getValue();
+            bpd = fobj.getLineHeight().getValue();
         } else {
             // this property does not apply when the line-height applies
             // isn't the block-progression-dimension always in the same
             // direction as the line height?
-            len = ifoNode.getBlockProgressionDimension().getOptimum().getLength();
+            len = fobj.getBlockProgressionDimension().getOptimum().getLength();
             if (!len.isAuto()) {
                 bpd = len.getValue();
             } else {
-                len = ifoNode.getHeight();
+                len = fobj.getHeight();
                 if (!len.isAuto()) {
                     bpd = len.getValue();
                 }
             }
         }
 
-        len = ifoNode.getInlineProgressionDimension().getOptimum().getLength();
+        len = fobj.getInlineProgressionDimension().getOptimum().getLength();
         if (!len.isAuto()) {
             ipd = len.getValue();
         } else {
-            len = ifoNode.getWidth();
+            len = fobj.getWidth();
             if (!len.isAuto()) {
                 ipd = len.getValue();
             }
@@ -102,7 +101,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         // to the content-height and content-width
         int cwidth = -1;
         int cheight = -1;
-        len = ifoNode.getContentWidth();
+        len = fobj.getContentWidth();
         if (!len.isAuto()) {
             /*if(len.scaleToFit()) {
                 if(ipd != -1) {
@@ -111,7 +110,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
             } else {*/
             cwidth = len.getValue();
         }
-        len = ifoNode.getContentHeight();
+        len = fobj.getContentHeight();
         if (!len.isAuto()) {
             /*if(len.scaleToFit()) {
                 if(bpd != -1) {
@@ -134,7 +133,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         if (cheight == -1) {
             cheight = (int)size.getY() * 1000;
         }
-        int scaling = ifoNode.getScaling();
+        int scaling = fobj.getScaling();
         if (scaling == Scaling.UNIFORM) {
             // adjust the larger
             double rat1 = cwidth / (size.getX() * 1000f);
@@ -156,24 +155,24 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
 
         boolean clip = false;
         if (cwidth > ipd || cheight > bpd) {
-            int overflow = ifoNode.getOverflow();
+            int overflow = fobj.getOverflow();
             if (overflow == Overflow.HIDDEN) {
                 clip = true;
             } else if (overflow == Overflow.ERROR_IF_OVERFLOW) {
-                ifoNode.getLogger().error("Instream foreign object overflows the viewport: clipping");
+                fobj.getLogger().error("Instream foreign object overflows the viewport: clipping");
                 clip = true;
             }
         }
 
-        int xoffset = ifoNode.computeXOffset(ipd, cwidth);
-        int yoffset = ifoNode.computeYOffset(bpd, cheight);
+        int xoffset = fobj.computeXOffset(ipd, cwidth);
+        int yoffset = fobj.computeYOffset(bpd, cheight);
 
         Rectangle2D placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
 
         org.w3c.dom.Document doc = child.getDOMDocument();
         String ns = child.getDocumentNamespace();
 
-        ifoNode.childNodes = null;
+        fobj.childNodes = null;
         ForeignObject foreign = new ForeignObject(doc, ns);
 
         Viewport areaCurrent = new Viewport(foreign);
@@ -187,7 +186,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
     }
     
     protected void addId() {
-        addID(ifoNode.getId());
+        addID(fobj.getId());
     }
 }
 
index 195cb18aafdeed3ca5b1c985f8582859f7787b21..eedbd568c412eb4c7275e992b47154a522900fc3 100644 (file)
@@ -35,8 +35,7 @@ import java.util.LinkedList;
  * LayoutManager for the fo:leader formatting object
  */
 public class LeaderLayoutManager extends LeafNodeLayoutManager {
-
-    Leader ldrNode;
+    private Leader fobj;
     Font font = null;
     
     /**
@@ -47,7 +46,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
      */
     public LeaderLayoutManager(Leader node) {
         super(node);
-        ldrNode = node;
+        fobj = node;
         font = node.getFontState();
         setAlignment(node.getLeaderAlignment());
     }
@@ -63,24 +62,24 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
     private MinOptMax getLeaderAllocIPD(int ipd) {
         // length of the leader
         fobj.setLayoutDimension(PercentBase.BLOCK_IPD, ipd);
-        int opt = ldrNode.getLeaderLength().getOptimum().getLength().getValue();
-        int min = ldrNode.getLeaderLength().getMinimum().getLength().getValue();
-        int max = ldrNode.getLeaderLength().getMaximum().getLength().getValue();
+        int opt = fobj.getLeaderLength().getOptimum().getLength().getValue();
+        int min = fobj.getLeaderLength().getMinimum().getLength().getValue();
+        int max = fobj.getLeaderLength().getMaximum().getLength().getValue();
         return new MinOptMax(min, opt, max);
     }
 
     private InlineArea getLeaderInlineArea() {
         InlineArea leaderArea = null;
 
-        if (ldrNode.getLeaderPattern() == LeaderPattern.RULE) {
+        if (fobj.getLeaderPattern() == LeaderPattern.RULE) {
             org.apache.fop.area.inline.Leader leader = 
                 new org.apache.fop.area.inline.Leader();
-            leader.setRuleStyle(ldrNode.getRuleStyle());
-            leader.setRuleThickness(ldrNode.getRuleThickness());
+            leader.setRuleStyle(fobj.getRuleStyle());
+            leader.setRuleThickness(fobj.getRuleThickness());
             leaderArea = leader;
-        } else if (ldrNode.getLeaderPattern() == LeaderPattern.SPACE) {
+        } else if (fobj.getLeaderPattern() == LeaderPattern.SPACE) {
             leaderArea = new Space();
-        } else if (ldrNode.getLeaderPattern() == LeaderPattern.DOTS) {
+        } else if (fobj.getLeaderPattern() == LeaderPattern.DOTS) {
             TextArea t = new TextArea();
             char dot = '.'; // userAgent.getLeaderDotCharacter();
 
@@ -91,10 +90,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
             t.setOffset(font.getAscender());
             int width = font.getCharWidth(dot);
             Space spacer = null;
-            if (ldrNode.getPatternWidth() > width) {
+            if (fobj.getPatternWidth() > width) {
                 spacer = new Space();
-                spacer.setIPD(ldrNode.getPatternWidth() - width);
-                width = ldrNode.getPatternWidth();
+                spacer.setIPD(fobj.getPatternWidth() - width);
+                width = fobj.getPatternWidth();
             }
             FilledArea fa = new FilledArea();
             fa.setUnitWidth(width);
@@ -105,9 +104,9 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
             fa.setBPD(font.getAscender());
 
             leaderArea = fa;
-        } else if (ldrNode.getLeaderPattern() == LeaderPattern.USECONTENT) {
-            if (ldrNode.getChildNodes() == null) {
-                ldrNode.getLogger().error("Leader use-content with no content");
+        } else if (fobj.getLeaderPattern() == LeaderPattern.USECONTENT) {
+            if (fobj.getChildNodes() == null) {
+                fobj.getLogger().error("Leader use-content with no content");
                 return null;
             }
 
@@ -118,20 +117,20 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
             FilledArea fa = new FilledArea();
 
             ContentLayoutManager clm = new ContentLayoutManager(fa);
-            clm.setUserAgent(ldrNode.getUserAgent());
+            clm.setUserAgent(fobj.getUserAgent());
             addChildLM(clm);
 
             InlineStackingLayoutManager lm;
-            lm = new InlineStackingLayoutManager(ldrNode);
+            lm = new InlineStackingLayoutManager(fobj);
             clm.addChildLM(lm);
 
             clm.fillArea(lm);
             int width = clm.getStackingSize();
             Space spacer = null;
-            if (ldrNode.getPatternWidth() > width) {
+            if (fobj.getPatternWidth() > width) {
                 spacer = new Space();
-                spacer.setIPD(ldrNode.getPatternWidth() - width);
-                width = ldrNode.getPatternWidth();
+                spacer.setIPD(fobj.getPatternWidth() - width);
+                width = fobj.getPatternWidth();
             }
             fa.setUnitWidth(width);
             if (spacer != null) {
@@ -241,6 +240,6 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
     }
 
     protected void addId() {
-        addID(ldrNode.getId());
+        addID(fobj.getId());
     }
 }
index 65b75ca1c3fe1ca07dc55424d56092c17d3d323f..c8b09cd67b700de46c05c6b975320a9737d025b0 100644 (file)
@@ -67,6 +67,7 @@ import org.apache.fop.traits.MinOptMax;
  * It manages all page-related layout.
  */
 public class PageSequenceLayoutManager extends AbstractLayoutManager implements Runnable {
+    private PageSequence fobj;
 
     private static class BlockBreakPosition extends LeafPosition {
         protected BreakPoss breakps;
@@ -108,7 +109,6 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
      */
     private AreaTreeHandler areaTreeHandler;
     private AreaTreeModel areaTreeModel;
-    private PageSequence pageSequence;
 
     /**
      * This is the SimplePageMaster that should be used to create the page. It
@@ -133,11 +133,11 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
      */
     public PageSequenceLayoutManager(AreaTreeHandler areaTreeHandler, PageSequence pageseq) {
         super(pageseq);
+        fobj = pageseq;
         this.areaTreeHandler = areaTreeHandler;
         areaTreeModel = areaTreeHandler.getAreaTreeModel();
-        pageSequence = pageseq;
-        if (pageSequence.getPageSequenceMaster() != null) {
-            pageSequence.getPageSequenceMaster().reset();
+        if (fobj.getPageSequenceMaster() != null) {
+            fobj.getPageSequenceMaster().reset();
         }
     }
 
@@ -164,13 +164,13 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
      * rendering process can also run in a parallel thread.
      */
     public void run() {
-        pageSequence.initPageNumber();
-        setPageCounting(pageSequence.getCurrentPageNumber(),
-            pageSequence.getPageNumberGenerator());
+        fobj.initPageNumber();
+        setPageCounting(fobj.getCurrentPageNumber(),
+                fobj.getPageNumberGenerator());
 
         LineArea title = null;
-        if (pageSequence.getTitleFO() != null) {
-            title = getTitleArea(pageSequence.getTitleFO());
+        if (fobj.getTitleFO() != null) {
+            title = getTitleArea(fobj.getTitleFO());
         }
 
         areaTreeModel.startPageSequence(title);
@@ -488,7 +488,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
         if (region == null) {
             return;
         }
-        StaticContent flow = pageSequence.getStaticContent(region.getRegionName());
+        StaticContent flow = fobj.getStaticContent(region.getRegionName());
         if (flow == null) {
             return;
         }
@@ -744,8 +744,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
                                    throws FOPException {
         currentSimplePageMaster = getSimplePageMasterToUse(bIsBlank);
         Region body = currentSimplePageMaster.getRegion(FO_REGION_BODY);
-        if (!pageSequence.getMainFlow().getFlowName().equals(body.getRegionName())) {
-          throw new FOPException("Flow '" + pageSequence.getMainFlow().getFlowName()
+        if (!fobj.getMainFlow().getFlowName().equals(body.getRegionName())) {
+          throw new FOPException("Flow '" + fobj.getMainFlow().getFlowName()
                                  + "' does not map to the region-body in page-master '"
                                  + currentSimplePageMaster.getMasterName() + "'");
         }
@@ -765,11 +765,11 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
 
     private SimplePageMaster getSimplePageMasterToUse(boolean bIsBlank)
             throws FOPException {
-        if (pageSequence.getPageSequenceMaster() == null) {
-            return pageSequence.getSimplePageMaster();
+        if (fobj.getPageSequenceMaster() == null) {
+            return fobj.getSimplePageMaster();
         }
         boolean isOddPage = ((pageCount % 2) == 1);
-        return pageSequence.getPageSequenceMaster()
+        return fobj.getPageSequenceMaster()
               .getNextSimplePageMaster(isOddPage, isFirstPage, bIsBlank);
     }
 
@@ -909,8 +909,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
         if (lm != null) {
             return lm;
         }
-        lm = new StaticContentLayoutManager();
-        lm.setFObj(sc);
+        lm = new StaticContentLayoutManager(sc);
         staticContentLMs.put(sc.getFlowName(), lm);
         return lm;
     }