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;
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());
return (AbstractTextArea)findAreaType(AbstractTextArea.class);
}
- private Viewport getCurrentViewport() {
- return (Viewport)findAreaType(Viewport.class);
+ private InlineViewport getCurrentViewport() {
+ return (InlineViewport)findAreaType(InlineViewport.class);
}
/** {@inheritDoc} */
}
}
- 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);
}
public void endElement() {
- assertObjectOfClass(areaStack.pop(), Viewport.class);
+ assertObjectOfClass(areaStack.pop(), InlineViewport.class);
}
}
clip = cl;
}
+ /** {@inheritDoc} */
public boolean hasClip() {
return clip;
}
+ /** {@inheritDoc} */
public Rectangle getClipRectangle() {
if (clip) {
return new Rectangle(getIPD(), getBPD());
clip = c;
}
+ /** {@inheritDoc} */
public boolean hasClip() {
return this.clip;
}
+ /** {@inheritDoc} */
public Rectangle getClipRectangle() {
if (clip) {
return new Rectangle(getIPD(), getBPD());
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.
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);
--- /dev/null
+/*
+ * 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();
+ }
+
+}
+++ /dev/null
-/*
- * 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();
- }
-
-}
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;
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);
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;
*
* @return the viewport inline area
*/
- private Viewport getInlineArea() {
+ private InlineViewport getInlineArea() {
final AbstractGraphics fobj = (AbstractGraphics)this.fobj;
Dimension intrinsicSize = new Dimension(
fobj.getIntrinsicWidth(),
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);
/** {@inheritDoc} */
public List getNextKnuthElements(LayoutContext context,
int alignment) {
- Viewport areaCurrent = getInlineArea();
+ InlineViewport areaCurrent = getInlineArea();
setCurrentArea(areaCurrent);
return super.getNextKnuthElements(context, alignment);
}
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;
* 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;
clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height);
}
- super.renderViewport(viewport);
+ super.renderInlineViewport(viewport);
if (viewport.hasClip()) {
restoreGraphicsState();
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;
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);
}
* 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();
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;
}
/** {@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();
}
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;
* {@inheritDoc}
*/
@Override
- protected void renderViewport(Viewport viewport) {
+ protected void renderInlineViewport(InlineViewport viewport) {
atts.clear();
addAreaAttributes(viewport);
addTraitAttributes(viewport);
addAttribute("clip", "true");
}
startElement("viewport", atts);
- super.renderViewport(viewport);
+ super.renderInlineViewport(viewport);
endElement("viewport");
}
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);