aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/layoutmgr
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-08-08 17:52:35 +0000
committerGlen Mazza <gmazza@apache.org>2004-08-08 17:52:35 +0000
commit0b09e52cd836a838e3140ef8113532d3033433a1 (patch)
tree7ed951d2e11ac51ac14ebc6ea830ab4fe360d6be /src/java/org/apache/fop/layoutmgr
parentc578ceae802518be510f14b2bc9023f1be0ad21a (diff)
downloadxmlgraphics-fop-0b09e52cd836a838e3140ef8113532d3033433a1.tar.gz
xmlgraphics-fop-0b09e52cd836a838e3140ef8113532d3033433a1.zip
Moved fo:page-number layout code from AddLMVisitor to new PageNumberLayoutManager class.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197860 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr')
-rw-r--r--src/java/org/apache/fop/layoutmgr/AddLMVisitor.java39
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java68
2 files changed, 68 insertions, 39 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
index 5411a4d18..a3bb2ecf0 100644
--- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
+++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
@@ -32,7 +32,6 @@ import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.InlineParent;
import org.apache.fop.area.inline.Space;
-import org.apache.fop.area.inline.UnresolvedPageNumber;
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.datatypes.Length;
@@ -45,7 +44,6 @@ import org.apache.fop.fo.flow.Character;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.InstreamForeignObject;
import org.apache.fop.fo.flow.Leader;
-import org.apache.fop.fo.flow.PageNumber;
import org.apache.fop.fo.flow.RetrieveMarker;
import org.apache.fop.fo.flow.Table;
import org.apache.fop.fo.flow.TableAndCaption;
@@ -417,43 +415,6 @@ public class AddLMVisitor {
return areaCurrent;
}
- /**
- * Overridden from FObj
- * @param lms the list to which the layout manager(s) should be added
- */
- public void servePageNumber(final PageNumber node) {
- LayoutManager lm;
- lm = new LeafNodeLayoutManager(node) {
- public InlineArea get(LayoutContext context) {
- // get page string from parent, build area
- TextArea inline = new TextArea();
- String str = parentLM.getCurrentPageNumber();
- int width = 0;
- for (int count = 0; count < str.length(); count++) {
- width += node.getFontState().getCharWidth(
- str.charAt(count));
- }
- inline.setTextArea(str);
- inline.setIPD(width);
- inline.setHeight(node.getFontState().getAscender()
- - node.getFontState().getDescender());
- inline.setOffset(node.getFontState().getAscender());
-
- inline.addTrait(Trait.FONT_NAME,
- node.getFontState().getFontName());
- inline.addTrait(Trait.FONT_SIZE,
- new Integer(node.getFontState().getFontSize()));
-
- return inline;
- }
-
- protected void offsetArea(LayoutContext context) {
- curArea.setOffset(context.getBaseline());
- }
- };
- currentLMList.add(lm);
- }
-
public void serveTable(Table node) {
TableLayoutManager tlm = new TableLayoutManager(node);
ArrayList columns = node.getColumns();
diff --git a/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java
new file mode 100644
index 000000000..b5bfc8462
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.layoutmgr;
+
+import org.apache.fop.fo.flow.PageNumber;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.Trait;
+import org.apache.fop.fonts.Font;
+
+/**
+ * LayoutManager for the fo:basic-link formatting object
+ */
+public class PageNumberLayoutManager extends LeafNodeLayoutManager {
+
+ Font font = null;
+
+ /**
+ * Constructor
+ *
+ * @param node the fo:page-number formatting object that creates the area
+ * @todo better null checking of node, font
+ */
+ public PageNumberLayoutManager(PageNumber node) {
+ super(node);
+ font = node.getFontState();
+ }
+
+ public InlineArea get(LayoutContext context) {
+ // get page string from parent, build area
+ TextArea inline = new TextArea();
+ String str = parentLM.getCurrentPageNumber();
+ int width = 0;
+ for (int count = 0; count < str.length(); count++) {
+ width += font.getCharWidth(str.charAt(count));
+ }
+ inline.setTextArea(str);
+ inline.setIPD(width);
+ inline.setHeight(font.getAscender() - font.getDescender());
+ inline.setOffset(font.getAscender());
+ inline.addTrait(Trait.FONT_NAME, font.getFontName());
+ inline.addTrait(Trait.FONT_SIZE,
+ new Integer(font.getFontSize()));
+
+ return inline;
+ }
+
+ protected void offsetArea(LayoutContext context) {
+ curArea.setOffset(context.getBaseline());
+ }
+}
+