On 14/03/11 21:03, Glenn Adams wrote:
> This commit introduces a new findbugs warning. See attached.
> 
> Glenn

I did notice the identical naming, I wasn’t too sure what to do about
it. Naming the interface ViewportArea just because there already is
a Viewport class in the inline package doesn’t make sense. The Viewport
interface is already in the area package, so it’s obvious that we’re
talking about areas. But same could be said about inline/Viewport and
inline areas.

AFter sleeping it through, I decided to rename inline/Viewport into
inline/InlineViewport.

Vincent


> On Mon, Mar 14, 2011 at 2:46 PM, <vhenneb...@apache.org> wrote:
> 
>> Author: vhennebert
>> Date: Mon Mar 14 20:46:03 2011
>> New Revision: 1081554
>>
>> URL: http://svn.apache.org/viewvc?rev=1081554&view=rev
>> Log:
>> Bugzilla #49910: clipping rectangle is wrong on side-regions
>> Partial fix that works only when the reference-orientation property is set
>> to 0 or 180 on side-regions
>>
>> Added:
>>    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Viewport.java   (with
>> props)
>>    xmlgraphics/fop/trunk/test/java/org/apache/fop/area/
>>
>>  
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/BlockViewportTestCase.java
>>   (with props)
>>
>>  
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/RegionViewportTestCase.java
>>   (with props)
>>
>>  xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestCase.java
>> (with props)
>>
>>  xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestSuite.java
>>   (with props)
>>    xmlgraphics/fop/trunk/test/java/org/apache/fop/area/inline/
>>
>>  
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
>>   (with props)
>> Modified:
>>    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/BlockViewport.java
>>    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/RegionViewport.java
>>    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/Viewport.java
>>
>>  
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
>>
>>  xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java
>>
>>  
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java
>>
>>  
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
>>
>>  xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java
>>
>>  xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
>>    xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/area/BlockViewport.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/BlockViewport.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/BlockViewport.java
>> (original)
>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/BlockViewport.java
>> Mon Mar 14 20:46:03 2011
>> @@ -19,12 +19,14 @@
>>
>>  package org.apache.fop.area;
>>
>> +import java.awt.Rectangle;
>> +
>>  /**
>>  * A BlockViewport.
>>  * This is used for block level Viewport/reference pairs.
>>  * The block-container creates this area.
>>  */
>> -public class BlockViewport extends Block {
>> +public class BlockViewport extends Block implements Viewport  {
>>
>>     private static final long serialVersionUID = -7840580922580735157L;
>>
>> @@ -78,14 +80,16 @@ public class BlockViewport extends Block
>>         clip = cl;
>>     }
>>
>> -    /**
>> -     * Get the clipping for this viewport.
>> -     *
>> -     * @return the clipping for the viewport
>> -     *         true if the contents should be clipped for this viewport
>> -     */
>> -    public boolean getClip() {
>> +    public boolean hasClip() {
>>         return clip;
>>     }
>> +
>> +    public Rectangle getClipRectangle() {
>> +        if (clip) {
>> +            return new Rectangle(getIPD(), getBPD());
>> +        } else {
>> +            return null;
>> +        }
>> +    }
>>  }
>>
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/area/RegionViewport.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/RegionViewport.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/RegionViewport.java
>> (original)
>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/RegionViewport.java
>> Mon Mar 14 20:46:03 2011
>> @@ -19,6 +19,7 @@
>>
>>  package org.apache.fop.area;
>>
>> +import java.awt.Rectangle;
>>  import java.awt.geom.Rectangle2D;
>>  import java.io.IOException;
>>  import java.util.HashMap;
>> @@ -29,7 +30,7 @@ import java.util.HashMap;
>>  * region-reference-area as its child.  These areas are described
>>  * in the fo:region-body description in the XSL Recommendation.
>>  */
>> -public class RegionViewport extends Area implements Cloneable {
>> +public class RegionViewport extends Area implements Cloneable, Viewport {
>>
>>     private static final long serialVersionUID = 505781815165102572L;
>>
>> @@ -75,11 +76,18 @@ public class RegionViewport extends Area
>>         clip = c;
>>     }
>>
>> -    /** @return true if the viewport should be clipped. */
>> -    public boolean isClip() {
>> +    public boolean hasClip() {
>>         return this.clip;
>>     }
>>
>> +    public Rectangle getClipRectangle() {
>> +        if (clip) {
>> +            return new Rectangle(getIPD(), getBPD());
>> +        } else {
>> +            return null;
>> +        }
>> +    }
>> +
>>     /**
>>      * Get the view area of this viewport.
>>      *
>>
>> Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Viewport.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Viewport.java?rev=1081554&view=auto
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Viewport.java
>> (added)
>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Viewport.java Mon
>> Mar 14 20:46:03 2011
>> @@ -0,0 +1,44 @@
>> +/*
>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>> + * contributor license agreements.  See the NOTICE file distributed with
>> + * this work for additional information regarding copyright ownership.
>> + * The ASF licenses this file to You under the Apache License, Version 2.0
>> + * (the "License"); you may not use this file except in compliance with
>> + * the License.  You may obtain a copy of the License at
>> + *
>> + *      http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing, software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + * See the License for the specific language governing permissions and
>> + * limitations under the License.
>> + */
>> +
>> +/* $Id$ */
>> +
>> +package org.apache.fop.area;
>> +
>> +import java.awt.Rectangle;
>> +
>> +/**
>> + * A viewport-area that may clip its content.
>> + */
>> +public interface Viewport {
>> +
>> +    /**
>> +     * Returns true if this area will clip overflowing content.
>> +     *
>> +     * @return {@code true} if the overflow trait has the value "hidden",
>> "scroll" or
>> +     * "error-if-overflow"
>> +     */
>> +    boolean hasClip();
>> +
>> +    /**
>> +     * Returns the clipping rectangle of this viewport area.
>> +     *
>> +     * @return the clipping rectangle expressed in the viewport's
>> coordinate system, or
>> +     * null if clipping is disabled
>> +     */
>> +    Rectangle getClipRectangle();
>> +}
>>
>> Propchange:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Viewport.java
>>
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Viewport.java
>>
>> ------------------------------------------------------------------------------
>>    svn:keywords = Revision Id
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/Viewport.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/Viewport.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/Viewport.java
>> (original)
>> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/Viewport.java
>> Mon Mar 14 20:46:03 2011
>> @@ -19,19 +19,20 @@
>>
>>  package org.apache.fop.area.inline;
>>
>> -import org.apache.fop.area.Area;
>> -
>> -import java.io.IOException;
>> +import java.awt.Rectangle;
>>  import java.awt.geom.Rectangle2D;
>> +import java.io.IOException;
>>  import java.util.HashMap;
>>
>> +import org.apache.fop.area.Area;
>> +
>>  /**
>>  * Inline viewport area.
>>  * This is an inline-level viewport area for inline container,
>>  * external graphic and instream foreign object. This viewport
>>  * holds the area and positions it.
>>  */
>> -public class Viewport extends InlineArea {
>> +public class Viewport extends InlineArea implements
>> org.apache.fop.area.Viewport {
>>
>>     private static final long serialVersionUID = 813338534627918689L;
>>
>> @@ -60,15 +61,18 @@ public class Viewport extends InlineArea
>>         this.clip = c;
>>     }
>>
>> -    /**
>> -     * Get the clip of this viewport.
>> -     *
>> -     * @return true if this viewport should clip
>> -     */
>> -    public boolean getClip() {
>> +    public boolean hasClip() {
>>         return this.clip;
>>     }
>>
>> +    public Rectangle getClipRectangle() {
>> +        if (clip) {
>> +            return new Rectangle(getIPD(), getBPD());
>> +        } else {
>> +            return null;
>> +        }
>> +    }
>> +
>>     /**
>>      * Set the position and size of the content of this viewport.
>>      *
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
>> Mon Mar 14 20:46:03 2011
>> @@ -542,7 +542,7 @@ public abstract class AbstractPathOrient
>>             }
>>
>>             //Clipping
>> -            if (bv.getClip()) {
>> +            if (bv.hasClip()) {
>>                 clipRect(0f, 0f, width, height);
>>             }
>>
>> @@ -593,8 +593,8 @@ public abstract class AbstractPathOrient
>>             //Now adjust for border/padding
>>             currentBPPosition += borderPaddingBefore;
>>
>> -            Rectangle2D clippingRect = null;
>> -            if (bv.getClip()) {
>> +            Rectangle clippingRect = null;
>> +            if (bv.hasClip()) {
>>                 clippingRect = new Rectangle(currentIPPosition,
>> currentBPPosition,
>>                         bv.getIPD(), bv.getBPD());
>>             }
>> @@ -701,14 +701,14 @@ public abstract class AbstractPathOrient
>>
>>         drawBackAndBorders(viewport, x, y, width + bpwidth, height +
>> bpheight);
>>
>> -        if (viewport.getClip()) {
>> +        if (viewport.hasClip()) {
>>             saveGraphicsState();
>>
>>             clipRect(x + borderPaddingStart, y + borderPaddingBefore,
>> width, height);
>>         }
>>         super.renderViewport(viewport);
>>
>> -        if (viewport.getClip()) {
>> +        if (viewport.hasClip()) {
>>             restoreGraphicsState();
>>         }
>>     }
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java
>> Mon Mar 14 20:46:03 2011
>> @@ -278,7 +278,6 @@ public abstract class AbstractRenderer
>>      * @param port  The region viewport to be rendered
>>      */
>>     protected void renderRegionViewport(RegionViewport port) {
>> -        Rectangle2D view = port.getViewArea();
>>         // The CTM will transform coordinates relative to
>>         // this region-reference area into page coords, so
>>         // set origin for the region to 0,0.
>> @@ -289,7 +288,7 @@ public abstract class AbstractRenderer
>>         handleRegionTraits(port);
>>
>>         //  shouldn't the viewport have the CTM
>> -        startVParea(regionReference.getCTM(), port.isClip() ? view :
>> null);
>> +        startVParea(regionReference.getCTM(), port.getClipRectangle());
>>         // do after starting viewport area
>>         if (regionReference.getRegionClass() == FO_REGION_BODY) {
>>             renderBodyRegion((BodyRegion) regionReference);
>> @@ -306,7 +305,7 @@ public abstract class AbstractRenderer
>>      * @param clippingRect the clipping rectangle if the viewport should be
>> clipping,
>>      *                     null if no clipping is performed.
>>      */
>> -    protected abstract void startVParea(CTM ctm, Rectangle2D
>> clippingRect);
>> +    protected abstract void startVParea(CTM ctm, Rectangle clippingRect);
>>
>>     /**
>>      * Signals exit from a viewport area. Subclasses can restore
>> transformation matrices
>> @@ -461,8 +460,8 @@ public abstract class AbstractRenderer
>>             int saveIP = currentIPPosition;
>>             int saveBP = currentBPPosition;
>>
>> -            Rectangle2D clippingRect = null;
>> -            if (bv.getClip()) {
>> +            Rectangle clippingRect = null;
>> +            if (bv.hasClip()) {
>>                 clippingRect = new Rectangle(saveIP, saveBP, bv.getIPD(),
>> bv.getBPD());
>>             }
>>
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java
>> Mon Mar 14 20:46:03 2011
>> @@ -37,7 +37,6 @@ import java.util.Stack;
>>  import javax.xml.transform.stream.StreamResult;
>>
>>  import org.w3c.dom.Document;
>> -
>>  import org.xml.sax.SAXException;
>>
>>  import org.apache.batik.parser.AWTTransformProducer;
>> @@ -788,18 +787,11 @@ public class IFRenderer extends Abstract
>>             contentRectTransform.translate(borderPaddingStart,
>> borderPaddingBefore);
>>             concatenateTransformationMatrixMpt(contentRectTransform,
>> false);
>>
>> -            //Clipping
>> -            Rectangle clipRect = null;
>> -            if (bv.getClip()) {
>> -                clipRect = new Rectangle(0, 0, dim.width, dim.height);
>> -                //clipRect(0f, 0f, width, height);
>> -            }
>> -
>>             //saveGraphicsState();
>>             //Set up coordinate system for content rectangle
>>             AffineTransform contentTransform = ctm.toAffineTransform();
>>             //concatenateTransformationMatrixMpt(contentTransform);
>> -            startViewport(contentTransform, clipRect);
>> +            startViewport(contentTransform, bv.getClipRectangle());
>>
>>             currentIPPosition = 0;
>>             currentBPPosition = 0;
>> @@ -831,13 +823,7 @@ public class IFRenderer extends Abstract
>>             //Now adjust for border/padding
>>             currentBPPosition += borderPaddingBefore;
>>
>> -            Rectangle2D clippingRect = null;
>> -            if (bv.getClip()) {
>> -                clippingRect = new Rectangle(currentIPPosition,
>> currentBPPosition,
>> -                        bv.getIPD(), bv.getBPD());
>> -            }
>> -
>> -            startVParea(ctm, clippingRect);
>> +            startVParea(ctm, bv.getClipRectangle());
>>             currentIPPosition = 0;
>>             currentBPPosition = 0;
>>             renderBlocks(bv, children);
>> @@ -863,19 +849,12 @@ public class IFRenderer extends Abstract
>>     }
>>
>>     /** {@inheritDoc} */
>> -    protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
>> +    protected void startVParea(CTM ctm, Rectangle clippingRect) {
>>         if (log.isTraceEnabled()) {
>>             log.trace("startVParea() ctm=" + ctm + ", clippingRect=" +
>> clippingRect);
>>         }
>>         AffineTransform at = new AffineTransform(ctm.toArray());
>> -        Rectangle clipRect = null;
>> -        if (clippingRect != null) {
>> -            clipRect = new Rectangle(
>> -                    (int)clippingRect.getMinX() - currentIPPosition,
>> -                    (int)clippingRect.getMinY() - currentBPPosition,
>> -                    (int)clippingRect.getWidth(),
>> (int)clippingRect.getHeight());
>> -        }
>> -        startViewport(at, clipRect);
>> +        startViewport(at, clippingRect);
>>         if (log.isTraceEnabled()) {
>>             log.trace("startVPArea: " + at + " --> " +
>> graphicContext.getTransform());
>>         }
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
>> Mon Mar 14 20:46:03 2011
>> @@ -445,7 +445,7 @@ public abstract class Java2DRenderer ext
>>     }
>>
>>     /** {@inheritDoc} */
>> -    protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
>> +    protected void startVParea(CTM ctm, Rectangle clippingRect) {
>>
>>         saveGraphicsState();
>>
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java
>> Mon Mar 14 20:46:03 2011
>> @@ -21,6 +21,7 @@ package org.apache.fop.render.txt;
>>
>>  import java.awt.Color;
>>  import java.awt.Point;
>> +import java.awt.Rectangle;
>>  import java.awt.geom.AffineTransform;
>>  import java.awt.geom.Rectangle2D;
>>  import java.io.IOException;
>> @@ -560,7 +561,7 @@ public class TXTRenderer extends Abstrac
>>     /**
>>      * {@inheritDoc}
>>      */
>> -    protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
>> +    protected void startVParea(CTM ctm, Rectangle clippingRect) {
>>         currentState.push(ctm);
>>     }
>>
>>
>> Modified:
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
>> (original)
>> +++
>> xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
>> Mon Mar 14 20:46:03 2011
>> @@ -21,6 +21,7 @@ package org.apache.fop.render.xml;
>>
>>  // Java
>>  import java.awt.Color;
>> +import java.awt.Rectangle;
>>  import java.awt.geom.Rectangle2D;
>>  import java.io.IOException;
>>  import java.io.OutputStream;
>> @@ -518,7 +519,7 @@ public class XMLRenderer extends Abstrac
>>             addAreaAttributes(port);
>>             addTraitAttributes(port);
>>             addAttribute("rect", port.getViewArea());
>> -            if (port.isClip()) {
>> +            if (port.hasClip()) {
>>                 addAttribute("clipped", "true");
>>             }
>>             startElement("regionViewport", atts);
>> @@ -558,9 +559,8 @@ public class XMLRenderer extends Abstrac
>>         }
>>     }
>>
>> -    /** {@inheritDoc} */
>>     @Override
>> -    protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
>> +    protected void startVParea(CTM ctm, Rectangle clippingRect) {
>>         //only necessary for graphical output
>>     }
>>
>> @@ -679,7 +679,7 @@ public class XMLRenderer extends Abstrac
>>                 addAttribute("top-position", bvp.getYOffset());
>>             }
>>             addAttribute("ctm", bvp.getCTM().toString());
>> -            if (bvp.getClip()) {
>> +            if (bvp.hasClip()) {
>>                 addAttribute("clipped", "true");
>>             }
>>         } else {
>> @@ -749,7 +749,7 @@ public class XMLRenderer extends Abstrac
>>         addTraitAttributes(viewport);
>>         addAttribute("offset", viewport.getOffset());
>>         addAttribute("pos", viewport.getContentPosition());
>> -        if (viewport.getClip()) {
>> +        if (viewport.hasClip()) {
>>             addAttribute("clip", "true");
>>         }
>>         startElement("viewport", atts);
>>
>> Modified:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java?rev=1081554&r1=1081553&r2=1081554&view=diff
>>
>> ==============================================================================
>> --- xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java
>> (original)
>> +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java
>> Mon Mar 14 20:46:03 2011
>> @@ -22,6 +22,7 @@ package org.apache.fop;
>>  import junit.framework.Test;
>>  import junit.framework.TestSuite;
>>
>> +import org.apache.fop.area.ViewportTestSuite;
>>  import org.apache.fop.fonts.DejaVuLGCSerifTest;
>>  import org.apache.fop.image.loader.batik.ImageLoaderTestCase;
>>  import org.apache.fop.image.loader.batik.ImagePreloaderTestCase;
>> @@ -65,6 +66,7 @@ public class StandardTestSuite {
>>         suite.addTest(new TestSuite(PageBoundariesTest.class));
>>         suite.addTest(new TestSuite(PageScaleTest.class));
>>         suite.addTest(new TestSuite(MinOptMaxTest.class));
>> +        suite.addTest(ViewportTestSuite.suite());
>>         //$JUnit-END$
>>         return suite;
>>     }
>>
>> Added:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/BlockViewportTestCase.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/area/BlockViewportTestCase.java?rev=1081554&view=auto
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/BlockViewportTestCase.java
>> (added)
>> +++
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/BlockViewportTestCase.java
>> Mon Mar 14 20:46:03 2011
>> @@ -0,0 +1,44 @@
>> +/*
>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>> + * contributor license agreements.  See the NOTICE file distributed with
>> + * this work for additional information regarding copyright ownership.
>> + * The ASF licenses this file to You under the Apache License, Version 2.0
>> + * (the "License"); you may not use this file except in compliance with
>> + * the License.  You may obtain a copy of the License at
>> + *
>> + *      http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing, software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + * See the License for the specific language governing permissions and
>> + * limitations under the License.
>> + */
>> +
>> +/* $Id$ */
>> +
>> +package org.apache.fop.area;
>> +
>> +
>> +/**
>> + * Tests the {@linkplain BlockViewport} class.
>> + */
>> +public class BlockViewportTestCase extends ViewportTestCase {
>> +
>> +    public void testNonClip() throws Exception {
>> +        BlockViewport bv = new BlockViewport();
>> +        bv.setIPD(100);
>> +        bv.setBPD(50);
>> +        checkNonClip(bv);
>> +    }
>> +
>> +    public void testClip() throws Exception {
>> +        BlockViewport bv = new BlockViewport();
>> +        int ipd = 100;
>> +        int bpd = 50;
>> +        bv.setIPD(ipd);
>> +        bv.setBPD(bpd);
>> +        bv.setClip(true);
>> +        checkClip(bv, ipd, bpd);
>> +    }
>> +}
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/BlockViewportTestCase.java
>>
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/BlockViewportTestCase.java
>>
>> ------------------------------------------------------------------------------
>>    svn:keywords = Revision Id
>>
>> Added:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/RegionViewportTestCase.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/area/RegionViewportTestCase.java?rev=1081554&view=auto
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/RegionViewportTestCase.java
>> (added)
>> +++
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/RegionViewportTestCase.java
>> Mon Mar 14 20:46:03 2011
>> @@ -0,0 +1,50 @@
>> +/*
>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>> + * contributor license agreements.  See the NOTICE file distributed with
>> + * this work for additional information regarding copyright ownership.
>> + * The ASF licenses this file to You under the Apache License, Version 2.0
>> + * (the "License"); you may not use this file except in compliance with
>> + * the License.  You may obtain a copy of the License at
>> + *
>> + *      http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing, software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + * See the License for the specific language governing permissions and
>> + * limitations under the License.
>> + */
>> +
>> +/* $Id$ */
>> +
>> +package org.apache.fop.area;
>> +
>> +import java.awt.Rectangle;
>> +import java.awt.geom.Rectangle2D;
>> +
>> +/**
>> + * Tests the {@linkplain RegionViewport} class.
>> + */
>> +public class RegionViewportTestCase extends ViewportTestCase {
>> +
>> +    private RegionViewport createRegionViewport(int x, int y, int ipd, int
>> bpd) {
>> +        Rectangle2D v = new Rectangle(x, y, ipd, bpd);
>> +        RegionViewport viewport = new RegionViewport(v);
>> +        viewport.setIPD(ipd);
>> +        viewport.setBPD(bpd);
>> +        return viewport;
>> +    }
>> +
>> +    public void testNonClip() throws Exception {
>> +        RegionViewport viewport = createRegionViewport(10, 10, 100, 20);
>> +        checkNonClip(viewport);
>> +    }
>> +
>> +    public void testClip() throws Exception {
>> +        int ipd = 150;
>> +        int bpd = 20;
>> +        RegionViewport viewport = createRegionViewport(10, 10, ipd, bpd);
>> +        viewport.setClip(true);
>> +        checkClip(viewport, ipd, bpd);
>> +    }
>> +}
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/RegionViewportTestCase.java
>>
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/RegionViewportTestCase.java
>>
>> ------------------------------------------------------------------------------
>>    svn:keywords = Revision Id
>>
>> Added:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestCase.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestCase.java?rev=1081554&view=auto
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestCase.java
>> (added)
>> +++
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestCase.java
>> Mon Mar 14 20:46:03 2011
>> @@ -0,0 +1,40 @@
>> +/*
>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>> + * contributor license agreements.  See the NOTICE file distributed with
>> + * this work for additional information regarding copyright ownership.
>> + * The ASF licenses this file to You under the Apache License, Version 2.0
>> + * (the "License"); you may not use this file except in compliance with
>> + * the License.  You may obtain a copy of the License at
>> + *
>> + *      http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing, software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + * See the License for the specific language governing permissions and
>> + * limitations under the License.
>> + */
>> +
>> +/* $Id$ */
>> +
>> +package org.apache.fop.area;
>> +
>> +import java.awt.Rectangle;
>> +
>> +import junit.framework.TestCase;
>> +
>> +/**
>> + * Tests implementations of the {@linkplain Viewport} interface.
>> + */
>> +public abstract class ViewportTestCase extends TestCase {
>> +
>> +    protected void checkNonClip(Viewport v) throws Exception {
>> +        assertFalse(v.hasClip());
>> +        assertNull(v.getClipRectangle());
>> +    }
>> +
>> +    protected void checkClip(Viewport v, int expectedWidth, int
>> expectedHeight) throws Exception {
>> +        assertTrue(v.hasClip());
>> +        assertEquals(new Rectangle(0, 0, expectedWidth, expectedHeight),
>> v.getClipRectangle());
>> +    }
>> +}
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestCase.java
>>
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestCase.java
>>
>> ------------------------------------------------------------------------------
>>    svn:keywords = Revision Id
>>
>> Added:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestSuite.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestSuite.java?rev=1081554&view=auto
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestSuite.java
>> (added)
>> +++
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestSuite.java
>> Mon Mar 14 20:46:03 2011
>> @@ -0,0 +1,47 @@
>> +/*
>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>> + * contributor license agreements.  See the NOTICE file distributed with
>> + * this work for additional information regarding copyright ownership.
>> + * The ASF licenses this file to You under the Apache License, Version 2.0
>> + * (the "License"); you may not use this file except in compliance with
>> + * the License.  You may obtain a copy of the License at
>> + *
>> + *      http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing, software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + * See the License for the specific language governing permissions and
>> + * limitations under the License.
>> + */
>> +
>> +/* $Id$ */
>> +
>> +package org.apache.fop.area;
>> +
>> +import junit.framework.Test;
>> +import junit.framework.TestSuite;
>> +
>> +import org.apache.fop.area.inline.InlineViewportTestCase;
>> +
>> +/**
>> + * A suite of all the tests relating to the {@linkplain Viewport}
>> interface.
>> + */
>> +public final class ViewportTestSuite {
>> +
>> +    private ViewportTestSuite() { }
>> +
>> +    /**
>> +     * Returns the suite of {@linkplain Viewport} implementation tests.
>> +     *
>> +     * @return the tests
>> +     */
>> +    public static Test suite() {
>> +        TestSuite suite = new TestSuite("Tests for viewport-areas");
>> +        suite.addTestSuite(RegionViewportTestCase.class);
>> +        suite.addTestSuite(BlockViewportTestCase.class);
>> +        suite.addTestSuite(InlineViewportTestCase.class);
>> +        return suite;
>> +    }
>> +
>> +}
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestSuite.java
>>
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/ViewportTestSuite.java
>>
>> ------------------------------------------------------------------------------
>>    svn:keywords = Revision Id
>>
>> Added:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
>> URL:
>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java?rev=1081554&view=auto
>>
>> ==============================================================================
>> ---
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
>> (added)
>> +++
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
>> Mon Mar 14 20:46:03 2011
>> @@ -0,0 +1,46 @@
>> +/*
>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>> + * contributor license agreements.  See the NOTICE file distributed with
>> + * this work for additional information regarding copyright ownership.
>> + * The ASF licenses this file to You under the Apache License, Version 2.0
>> + * (the "License"); you may not use this file except in compliance with
>> + * the License.  You may obtain a copy of the License at
>> + *
>> + *      http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing, software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> + * See the License for the specific language governing permissions and
>> + * limitations under the License.
>> + */
>> +
>> +/* $Id$ */
>> +
>> +package org.apache.fop.area.inline;
>> +
>> +import org.apache.fop.area.ViewportTestCase;
>> +
>> +/**
>> + * Tests the {@linkplain Viewport} class.
>> + */
>> +public class InlineViewportTestCase extends ViewportTestCase {
>> +
>> +    public void testNonClip() throws Exception {
>> +        Viewport v = new Viewport(null);
>> +        v.setIPD(50);
>> +        v.setBPD(25);
>> +        checkNonClip(v);
>> +    }
>> +
>> +    public void testClip() throws Exception {
>> +        Viewport v = new Viewport(null);
>> +        int ipd = 50;
>> +        int bpd = 25;
>> +        v.setIPD(ipd);
>> +        v.setBPD(bpd);
>> +        v.setClip(true);
>> +        checkClip(v, ipd, bpd);
>> +    }
>> +
>> +}
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
>>
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange:
>> xmlgraphics/fop/trunk/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
>>
>> ------------------------------------------------------------------------------
>>    svn:keywords = Revision Id
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org
>>
>>
> 

Reply via email to