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 bc...@apache.org on 2004/10/20 15:37:49 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr ExternalGraphicLayoutManager.java InstreamForeignObjectLM.java LeaderLayoutManager.java PageSequenceLayoutManager.java

bckfnn      2004/10/20 06:37:49

  Modified:    src/java/org/apache/fop/layoutmgr
                        ExternalGraphicLayoutManager.java
                        InstreamForeignObjectLM.java
                        LeaderLayoutManager.java
                        PageSequenceLayoutManager.java
  Log:
  Fourth phase of performance improvement.
  - Consistent naming of the fobj.
  
  PR: 31699
  
  Revision  Changes    Path
  1.10      +21 -23    xml-fop/src/java/org/apache/fop/layoutmgr/ExternalGraphicLayoutManager.java
  
  Index: ExternalGraphicLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/ExternalGraphicLayoutManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ExternalGraphicLayoutManager.java	20 Oct 2004 13:19:24 -0000	1.9
  +++ ExternalGraphicLayoutManager.java	20 Oct 2004 13:37:48 -0000	1.10
  @@ -34,8 +34,7 @@
    * 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 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 @@
        * @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 @@
   
           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 @@
               } 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 @@
               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 @@
           }
   
           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 @@
   
           int xoffset = 0;
           int yoffset = 0;
  -        switch(graphic.getDisplayAlign()) {
  +        switch(fobj.getDisplayAlign()) {
               case DisplayAlign.BEFORE:
               break;
               case DisplayAlign.AFTER:
  @@ -188,7 +186,7 @@
               break;
           }
   
  -        switch(graphic.getTextAlign()) {
  +        switch(fobj.getTextAlign()) {
               case TextAlign.CENTER:
                   xoffset = (viewWidth - cwidth) / 2;
               break;
  @@ -211,7 +209,7 @@
         * @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 @@
            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());
        }
   }
   
  
  
  
  1.8       +18 -19    xml-fop/src/java/org/apache/fop/layoutmgr/InstreamForeignObjectLM.java
  
  Index: InstreamForeignObjectLM.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/InstreamForeignObjectLM.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InstreamForeignObjectLM.java	20 Oct 2004 13:19:24 -0000	1.7
  +++ InstreamForeignObjectLM.java	20 Oct 2004 13:37:48 -0000	1.8
  @@ -33,8 +33,7 @@
    * LayoutManager for the fo:basic-link formatting object
    */
   public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
  -
  -    InstreamForeignObject ifoNode;
  +    private InstreamForeignObject fobj;
       
       /**
        * Constructor
  @@ -42,7 +41,7 @@
        */
       public InstreamForeignObjectLM(InstreamForeignObject node) {
           super(node);
  -        ifoNode = node;
  +        fobj = node;
           Viewport areaCurrent = getInlineArea();
           setCurrentArea(areaCurrent);
           setAlignment(node.getVerticalAlign());
  @@ -55,7 +54,7 @@
        * @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 @@
           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 @@
           // 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 @@
               } else {*/
               cwidth = len.getValue();
           }
  -        len = ifoNode.getContentHeight();
  +        len = fobj.getContentHeight();
           if (!len.isAuto()) {
               /*if(len.scaleToFit()) {
                   if(bpd != -1) {
  @@ -134,7 +133,7 @@
           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 @@
   
           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 @@
       }
       
       protected void addId() {
  -        addID(ifoNode.getId());
  +        addID(fobj.getId());
       }
   }
   
  
  
  
  1.9       +23 -24    xml-fop/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java
  
  Index: LeaderLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LeaderLayoutManager.java	20 Oct 2004 13:19:24 -0000	1.8
  +++ LeaderLayoutManager.java	20 Oct 2004 13:37:48 -0000	1.9
  @@ -35,8 +35,7 @@
    * 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 LeaderLayoutManager(Leader node) {
           super(node);
  -        ldrNode = node;
  +        fobj = node;
           font = node.getFontState();
           setAlignment(node.getLeaderAlignment());
       }
  @@ -63,24 +62,24 @@
       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 @@
               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 @@
               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 @@
               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 @@
       }
   
       protected void addId() {
  -        addID(ldrNode.getId());
  +        addID(fobj.getId());
       }
   }
  
  
  
  1.9       +17 -18    xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
  
  Index: PageSequenceLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PageSequenceLayoutManager.java	20 Oct 2004 13:19:24 -0000	1.8
  +++ PageSequenceLayoutManager.java	20 Oct 2004 13:37:48 -0000	1.9
  @@ -67,6 +67,7 @@
    * 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 @@
        */
       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 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 @@
        * 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 @@
           if (region == null) {
               return;
           }
  -        StaticContent flow = pageSequence.getStaticContent(region.getRegionName());
  +        StaticContent flow = fobj.getStaticContent(region.getRegionName());
           if (flow == null) {
               return;
           }
  @@ -744,8 +744,8 @@
                                      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 @@
   
       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 @@
           if (lm != null) {
               return lm;
           }
  -        lm = new StaticContentLayoutManager();
  -        lm.setFObj(sc);
  +        lm = new StaticContentLayoutManager(sc);
           staticContentLMs.put(sc.getFlowName(), lm);
           return lm;
       }
  
  
  

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