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 2009/03/24 16:39:20 UTC

svn commit: r757852 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java

Author: acumiskey
Date: Tue Mar 24 15:39:15 2009
New Revision: 757852

URL: http://svn.apache.org/viewvc?rev=757852&view=rev
Log:
Added some nice bean methods for pageSequenceMaster and simplePageMaster, this also makes startOfNode() easier to read too.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java?rev=757852&r1=757851&r2=757852&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java Tue Mar 24 15:39:15 2009
@@ -24,8 +24,10 @@
 
 import org.xml.sax.Locator;
 
+import org.apache.batik.css.engine.value.svg.OpacityManager;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 
@@ -48,7 +50,7 @@
     // the set of flows includes StaticContent flows also
 
     /** Map of flows to their flow name (flow-name, Flow) */
-    private Map flowMap;
+    private Map/*<String, Flow>*/ flowMap;
 
     /**
      * The currentSimplePageMaster is either the page master for the
@@ -93,21 +95,52 @@
         }
     }
 
+    /**
+     * Returns the simple page master related to this page sequence
+     * @return the simple page master related to this page sequence
+     */
+    public SimplePageMaster getSimplePageMaster() {
+        return getRoot().getLayoutMasterSet().getSimplePageMaster(masterReference);
+    }
+
+    /**
+     * Returns true if this page sequence has a simple page master
+     * @return true if this page sequence has a simple page master
+     */
+    public boolean hasSimplePageMaster() {
+        return getSimplePageMaster() != null;
+    }
+
+    /**
+     * Returns the page sequence master related to this page sequence
+     * @return the page sequence master related to this page sequence
+     */
+    public PageSequenceMaster getPageSequenceMaster() {
+        return getRoot().getLayoutMasterSet().getPageSequenceMaster(masterReference);
+    }
+
+    /**
+     * Returns true if this page sequence has a page sequence master
+     * @return true if this page sequence has a page sequence master
+     */
+    public boolean hasPageSequenceMaster() {
+        return getPageSequenceMaster() != null;
+    }
+
     /** {@inheritDoc} */
     protected void startOfNode() throws FOPException {
         super.startOfNode();
-        flowMap = new java.util.HashMap();
+        flowMap = new java.util.HashMap/*<String, Flow>*/();
 
-        this.simplePageMaster = getRoot().getLayoutMasterSet().getSimplePageMaster(masterReference);
-        if (this.simplePageMaster == null) {
-            this.pageSequenceMaster
-                    = getRoot().getLayoutMasterSet().getPageSequenceMaster(masterReference);
-            if (this.pageSequenceMaster == null) {
-                getFOValidationEventProducer().masterNotFound(this, getName(),
-                        masterReference, getLocator());
-            }
+        if (hasSimplePageMaster()) {
+            this.simplePageMaster = getSimplePageMaster();
+        } else if (hasPageSequenceMaster()) {
+            this.pageSequenceMaster = getPageSequenceMaster();
+        } else {
+            getFOValidationEventProducer().masterNotFound(this, getName(),
+                    masterReference, getLocator());
         }
-
+        
         getFOEventHandler().startPageSequence(this);
     }
 



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


Re: svn commit: r757852 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java

Posted by Adrian Cumiskey <de...@cumiskey.com>.
Hi Vincent,

Yes you are right it should be hidden (although it is still accessible 
through pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster()).
I just added these methods for convenience, but I have now found a 
better way to do this.  I will revert my changes.

Adrian.

Vincent Hennebert wrote:
> Hi Adrian,
>
>   
>> Author: acumiskey
>> Date: Tue Mar 24 15:39:15 2009
>> New Revision: 757852
>>
>> URL: http://svn.apache.org/viewvc?rev=757852&view=rev
>> Log:
>> Added some nice bean methods for pageSequenceMaster and simplePageMaster, this also makes startOfNode() easier to read too.
>>
>> Modified:
>>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java
>>     
> <snip/>
>
> I’m not sure I like this change. I tend to think that a class should not
> expose public methods unless they are of immediate necessity. That helps
> to reduce complexity and confusion for newcomers. If they prove to be
> necessary they can always be added later on.
>
> Also, in this case I don’t think any external object needs to know
> whether the page masters for this page sequence were declared using
> a single simple-page-master or a page-sequence-master. That knowledge
> should be kept encapsulated inside the PageSequence class.
>
> Finally, in the startOfNode method the get*Master method will be called
> twice: once by has*Master to see if the master exists, and once to
> actually get it. This is slightly overkill.
>
> I think those new methods should at least be made private. Although the
> original code simply looks fine to me...
>
> WDYT?
> Thanks,
> Vincent
>
>   


Re: svn commit: r757852 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java

Posted by Vincent Hennebert <vh...@gmail.com>.
Hi Adrian,

> Author: acumiskey
> Date: Tue Mar 24 15:39:15 2009
> New Revision: 757852
> 
> URL: http://svn.apache.org/viewvc?rev=757852&view=rev
> Log:
> Added some nice bean methods for pageSequenceMaster and simplePageMaster, this also makes startOfNode() easier to read too.
> 
> Modified:
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java
<snip/>

I’m not sure I like this change. I tend to think that a class should not
expose public methods unless they are of immediate necessity. That helps
to reduce complexity and confusion for newcomers. If they prove to be
necessary they can always be added later on.

Also, in this case I don’t think any external object needs to know
whether the page masters for this page sequence were declared using
a single simple-page-master or a page-sequence-master. That knowledge
should be kept encapsulated inside the PageSequence class.

Finally, in the startOfNode method the get*Master method will be called
twice: once by has*Master to see if the master exists, and once to
actually get it. This is slightly overkill.

I think those new methods should at least be made private. Although the
original code simply looks fine to me...

WDYT?
Thanks,
Vincent