From: Vincent Hennebert Date: Tue, 15 Mar 2011 15:56:01 +0000 (+0000) Subject: Renamed Viewport into InlineViewport X-Git-Tag: fop-1_1rc1old~261 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b8ac4207fe239a3433870691c79018b0137a30f6;p=xmlgraphics-fop.git Renamed Viewport into InlineViewport Added {@inheritDoc} comments to make Checkstyle happy git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1081822 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index 6c82257f3..d2f52f991 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -73,7 +73,7 @@ import org.apache.fop.area.inline.Leader; import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.SpaceArea; import org.apache.fop.area.inline.TextArea; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.area.inline.WordArea; import org.apache.fop.fo.ElementMappingRegistry; import org.apache.fop.fo.expr.PropertyException; @@ -217,7 +217,7 @@ public class AreaTreeParser { makers.put("word", new WordMaker()); makers.put("space", new SpaceMaker()); makers.put("leader", new LeaderMaker()); - makers.put("viewport", new ViewportMaker()); + makers.put("viewport", new InlineViewportMaker()); makers.put("image", new ImageMaker()); makers.put("foreignObject", new ForeignObjectMaker()); makers.put("bookmarkTree", new BookmarkTreeMaker()); @@ -265,8 +265,8 @@ public class AreaTreeParser { return (AbstractTextArea)findAreaType(AbstractTextArea.class); } - private Viewport getCurrentViewport() { - return (Viewport)findAreaType(Viewport.class); + private InlineViewport getCurrentViewport() { + return (InlineViewport)findAreaType(InlineViewport.class); } /** {@inheritDoc} */ @@ -902,10 +902,10 @@ public class AreaTreeParser { } } - private class ViewportMaker extends AbstractMaker { + private class InlineViewportMaker extends AbstractMaker { public void startElement(Attributes attributes) { - Viewport viewport = new Viewport(null); + InlineViewport viewport = new InlineViewport(null); transferForeignObjects(attributes, viewport); setAreaAttributes(attributes, viewport); setTraits(attributes, viewport, SUBSET_COMMON); @@ -921,7 +921,7 @@ public class AreaTreeParser { } public void endElement() { - assertObjectOfClass(areaStack.pop(), Viewport.class); + assertObjectOfClass(areaStack.pop(), InlineViewport.class); } } diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java index 770ff31fb..066f2f9e8 100644 --- a/src/java/org/apache/fop/area/BlockViewport.java +++ b/src/java/org/apache/fop/area/BlockViewport.java @@ -80,10 +80,12 @@ public class BlockViewport extends Block implements Viewport { clip = cl; } + /** {@inheritDoc} */ public boolean hasClip() { return clip; } + /** {@inheritDoc} */ public Rectangle getClipRectangle() { if (clip) { return new Rectangle(getIPD(), getBPD()); diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java index 305dc5c10..6cc700a7b 100644 --- a/src/java/org/apache/fop/area/RegionViewport.java +++ b/src/java/org/apache/fop/area/RegionViewport.java @@ -76,10 +76,12 @@ public class RegionViewport extends Area implements Cloneable, Viewport { clip = c; } + /** {@inheritDoc} */ public boolean hasClip() { return this.clip; } + /** {@inheritDoc} */ public Rectangle getClipRectangle() { if (clip) { return new Rectangle(getIPD(), getBPD()); diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java index 858951f75..e0207ada6 100644 --- a/src/java/org/apache/fop/area/inline/FilledArea.java +++ b/src/java/org/apache/fop/area/inline/FilledArea.java @@ -19,10 +19,10 @@ package org.apache.fop.area.inline; -import java.util.List; -import java.util.ListIterator; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; /** * Filled area. @@ -60,7 +60,7 @@ public class FilledArea extends InlineParent { InlineArea child = (InlineArea) childrenIterator.next(); if (child instanceof InlineParent) { setChildOffset(((InlineParent) child).getChildAreas().listIterator(), v); - } else if (child instanceof org.apache.fop.area.inline.Viewport) { + } else if (child instanceof InlineViewport) { // nothing } else { child.setOffset(v); diff --git a/src/java/org/apache/fop/area/inline/InlineViewport.java b/src/java/org/apache/fop/area/inline/InlineViewport.java new file mode 100644 index 000000000..68cc9a797 --- /dev/null +++ b/src/java/org/apache/fop/area/inline/InlineViewport.java @@ -0,0 +1,141 @@ +/* + * 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 java.awt.Rectangle; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.util.HashMap; + +import org.apache.fop.area.Area; +import org.apache.fop.area.Viewport; + +/** + * 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 InlineViewport extends InlineArea implements Viewport { + + private static final long serialVersionUID = 813338534627918689L; + + // contents could be container, foreign object or image + private Area content; + // clipping for the viewport + private boolean clip = false; + // position of the child area relative to this area + private Rectangle2D contentPosition; + + /** + * Create a new viewport area with the content area. + * + * @param child the child content area of this viewport + */ + public InlineViewport(Area child) { + this.content = child; + } + + /** + * Set the clip of this viewport. + * + * @param c true if this viewport should clip + */ + public void setClip(boolean c) { + this.clip = c; + } + + /** {@inheritDoc} */ + public boolean hasClip() { + return this.clip; + } + + /** {@inheritDoc} */ + public Rectangle getClipRectangle() { + if (clip) { + return new Rectangle(getIPD(), getBPD()); + } else { + return null; + } + } + + /** + * Set the position and size of the content of this viewport. + * + * @param cp the position and size to place the content + */ + public void setContentPosition(Rectangle2D cp) { + this.contentPosition = cp; + } + + /** + * Get the position and size of the content of this viewport. + * + * @return the position and size to place the content + */ + public Rectangle2D getContentPosition() { + return this.contentPosition; + } + + /** + * Sets the content area. + * @param content the content area + */ + public void setContent(Area content) { + this.content = content; + } + + /** + * Get the content area for this viewport. + * + * @return the content area + */ + public Area getContent() { + return this.content; + } + + private void writeObject(java.io.ObjectOutputStream out) + throws IOException { + out.writeBoolean(contentPosition != null); + if (contentPosition != null) { + out.writeFloat((float) contentPosition.getX()); + out.writeFloat((float) contentPosition.getY()); + out.writeFloat((float) contentPosition.getWidth()); + out.writeFloat((float) contentPosition.getHeight()); + } + out.writeBoolean(clip); + out.writeObject(props); + out.writeObject(content); + } + + private void readObject(java.io.ObjectInputStream in) + throws IOException, ClassNotFoundException { + if (in.readBoolean()) { + contentPosition = new Rectangle2D.Float(in.readFloat(), + in.readFloat(), + in.readFloat(), + in.readFloat()); + } + this.clip = in.readBoolean(); + this.props = (HashMap) in.readObject(); + this.content = (Area) in.readObject(); + } + +} diff --git a/src/java/org/apache/fop/area/inline/Viewport.java b/src/java/org/apache/fop/area/inline/Viewport.java deleted file mode 100644 index 610697c36..000000000 --- a/src/java/org/apache/fop/area/inline/Viewport.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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 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 implements org.apache.fop.area.Viewport { - - private static final long serialVersionUID = 813338534627918689L; - - // contents could be container, foreign object or image - private Area content; - // clipping for the viewport - private boolean clip = false; - // position of the child area relative to this area - private Rectangle2D contentPosition; - - /** - * Create a new viewport area with the content area. - * - * @param child the child content area of this viewport - */ - public Viewport(Area child) { - this.content = child; - } - - /** - * Set the clip of this viewport. - * - * @param c true if this viewport should clip - */ - public void setClip(boolean c) { - this.clip = c; - } - - 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. - * - * @param cp the position and size to place the content - */ - public void setContentPosition(Rectangle2D cp) { - this.contentPosition = cp; - } - - /** - * Get the position and size of the content of this viewport. - * - * @return the position and size to place the content - */ - public Rectangle2D getContentPosition() { - return this.contentPosition; - } - - /** - * Sets the content area. - * @param content the content area - */ - public void setContent(Area content) { - this.content = content; - } - - /** - * Get the content area for this viewport. - * - * @return the content area - */ - public Area getContent() { - return this.content; - } - - private void writeObject(java.io.ObjectOutputStream out) - throws IOException { - out.writeBoolean(contentPosition != null); - if (contentPosition != null) { - out.writeFloat((float) contentPosition.getX()); - out.writeFloat((float) contentPosition.getY()); - out.writeFloat((float) contentPosition.getWidth()); - out.writeFloat((float) contentPosition.getHeight()); - } - out.writeBoolean(clip); - out.writeObject(props); - out.writeObject(content); - } - - private void readObject(java.io.ObjectInputStream in) - throws IOException, ClassNotFoundException { - if (in.readBoolean()) { - contentPosition = new Rectangle2D.Float(in.readFloat(), - in.readFloat(), - in.readFloat(), - in.readFloat()); - } - this.clip = in.readBoolean(); - this.props = (HashMap) in.readObject(); - this.content = (Area) in.readObject(); - } - -} diff --git a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java index d807aee2d..9fb832da3 100644 --- a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java @@ -45,7 +45,7 @@ import org.apache.fop.area.PageSequence; import org.apache.fop.area.PageViewport; import org.apache.fop.area.RegionViewport; import org.apache.fop.area.inline.Image; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.datatypes.FODimension; import org.apache.fop.datatypes.URISpecification; import org.apache.fop.fo.Constants; @@ -184,7 +184,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan TraitSetter.setProducerID(imageArea, fobj.getId()); transferForeignAttributes(imageArea); - Viewport vp = new Viewport(imageArea); + InlineViewport vp = new InlineViewport(imageArea); TraitSetter.setProducerID(vp, fobj.getId()); vp.setIPD(imageSize.width); vp.setBPD(imageSize.height); diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java index fd4d803af..218497a53 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java @@ -24,7 +24,7 @@ import java.awt.Rectangle; import java.util.List; import org.apache.fop.area.Area; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.datatypes.LengthBase; import org.apache.fop.fo.FObj; import org.apache.fop.fo.flow.AbstractGraphics; @@ -54,7 +54,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage * * @return the viewport inline area */ - private Viewport getInlineArea() { + private InlineViewport getInlineArea() { final AbstractGraphics fobj = (AbstractGraphics)this.fobj; Dimension intrinsicSize = new Dimension( fobj.getIntrinsicWidth(), @@ -84,7 +84,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage TraitSetter.setProducerID(viewportArea, fobj.getId()); transferForeignAttributes(viewportArea); - Viewport vp = new Viewport(viewportArea); + InlineViewport vp = new InlineViewport(viewportArea); TraitSetter.addPtr(vp, fobj.getPtr()); // used for accessibility TraitSetter.setProducerID(vp, fobj.getId()); vp.setIPD(imageLayout.getViewportSize().width); @@ -106,7 +106,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - Viewport areaCurrent = getInlineArea(); + InlineViewport areaCurrent = getInlineArea(); setCurrentArea(areaCurrent); return super.getNextKnuthElements(context, alignment); } diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index 50a95b09a..45a02a977 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -44,7 +44,7 @@ import org.apache.fop.area.RegionViewport; import org.apache.fop.area.Trait; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.fo.Constants; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fonts.FontMetrics; @@ -685,7 +685,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * This renders an inline viewport by clipping if necessary. * @param viewport the viewport to handle */ - public void renderViewport(Viewport viewport) { + public void renderInlineViewport(InlineViewport viewport) { float x = currentIPPosition / 1000f; float y = (currentBPPosition + viewport.getOffset()) / 1000f; @@ -706,7 +706,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height); } - super.renderViewport(viewport); + super.renderInlineViewport(viewport); if (viewport.hasClip()) { restoreGraphicsState(); diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 4e0b13c56..7ff236d16 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -65,7 +65,7 @@ import org.apache.fop.area.inline.Leader; import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.SpaceArea; import org.apache.fop.area.inline.TextArea; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.area.inline.WordArea; import org.apache.fop.fo.Constants; import org.apache.fop.fonts.FontInfo; @@ -632,8 +632,8 @@ public abstract class AbstractRenderer renderInlineBlockParent((InlineBlockParent) inlineArea); } else if (inlineArea instanceof Space) { renderInlineSpace((Space) inlineArea); - } else if (inlineArea instanceof Viewport) { - renderViewport((Viewport) inlineArea); + } else if (inlineArea instanceof InlineViewport) { + renderInlineViewport((InlineViewport) inlineArea); } else if (inlineArea instanceof Leader) { renderLeader((Leader) inlineArea); } @@ -734,7 +734,7 @@ public abstract class AbstractRenderer * Render the given Viewport. * @param viewport the viewport to render */ - protected void renderViewport(Viewport viewport) { + protected void renderInlineViewport(InlineViewport viewport) { Area content = viewport.getContent(); int saveBP = currentBPPosition; currentBPPosition += viewport.getOffset(); diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index dfa2477b6..c81a5cae9 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -73,7 +73,7 @@ import org.apache.fop.area.inline.InlineParent; import org.apache.fop.area.inline.Leader; import org.apache.fop.area.inline.SpaceArea; import org.apache.fop.area.inline.TextArea; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.area.inline.WordArea; import org.apache.fop.datatypes.URISpecification; import org.apache.fop.fo.extensions.ExtensionAttachment; @@ -838,12 +838,12 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - public void renderViewport(Viewport viewport) { + public void renderInlineViewport(InlineViewport viewport) { String ptr = (String) viewport.getTrait(Trait.PTR); establishStructurePointer(ptr); Dimension dim = new Dimension(viewport.getIPD(), viewport.getBPD()); viewportDimensionStack.push(dim); - super.renderViewport(viewport); + super.renderInlineViewport(viewport); viewportDimensionStack.pop(); resetStructurePointer(); } diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index a7f085d7f..21d28042d 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -79,7 +79,7 @@ import org.apache.fop.area.inline.Leader; import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.SpaceArea; import org.apache.fop.area.inline.TextArea; -import org.apache.fop.area.inline.Viewport; +import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.area.inline.WordArea; import org.apache.fop.fo.Constants; import org.apache.fop.fo.extensions.ExtensionAttachment; @@ -743,7 +743,7 @@ public class XMLRenderer extends AbstractXMLRenderer { * {@inheritDoc} */ @Override - protected void renderViewport(Viewport viewport) { + protected void renderInlineViewport(InlineViewport viewport) { atts.clear(); addAreaAttributes(viewport); addTraitAttributes(viewport); @@ -753,7 +753,7 @@ public class XMLRenderer extends AbstractXMLRenderer { addAttribute("clip", "true"); } startElement("viewport", atts); - super.renderViewport(viewport); + super.renderInlineViewport(viewport); endElement("viewport"); } diff --git a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java index ccd866d64..811158273 100644 --- a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java +++ b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java @@ -22,19 +22,19 @@ package org.apache.fop.area.inline; import org.apache.fop.area.ViewportTestCase; /** - * Tests the {@linkplain Viewport} class. + * Tests the {@linkplain InlineViewport} class. */ public class InlineViewportTestCase extends ViewportTestCase { public void testNonClip() throws Exception { - Viewport v = new Viewport(null); + InlineViewport v = new InlineViewport(null); v.setIPD(50); v.setBPD(25); checkNonClip(v); } public void testClip() throws Exception { - Viewport v = new Viewport(null); + InlineViewport v = new InlineViewport(null); int ipd = 50; int bpd = 25; v.setIPD(ipd);