aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/area
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/area')
-rw-r--r--src/java/org/apache/fop/area/AreaTreeParser.java23
-rw-r--r--src/java/org/apache/fop/area/inline/Character.java3
-rw-r--r--src/java/org/apache/fop/area/inline/SpaceArea.java19
-rw-r--r--src/java/org/apache/fop/area/inline/TextArea.java12
-rw-r--r--src/java/org/apache/fop/area/inline/WordArea.java21
5 files changed, 51 insertions, 27 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java
index e4f1292d2..e3a291eee 100644
--- a/src/java/org/apache/fop/area/AreaTreeParser.java
+++ b/src/java/org/apache/fop/area/AreaTreeParser.java
@@ -19,6 +19,7 @@
package org.apache.fop.area;
import java.awt.geom.Rectangle2D;
+import java.util.List;
import java.util.Map;
import java.util.Stack;
import java.util.StringTokenizer;
@@ -674,10 +675,27 @@ public class AreaTreeParser {
private class WordMaker extends AbstractMaker {
+ private int[] toIntArray(String s) {
+ if (s == null || s.length() == 0) {
+ return null;
+ }
+ StringTokenizer tokenizer = new StringTokenizer(s, " ");
+ List values = new java.util.ArrayList();
+ while (tokenizer.hasMoreTokens()) {
+ values.add(new Integer(tokenizer.nextToken()));
+ }
+ int[] res = new int[values.size()];
+ for (int i = 0, c = res.length; i < c; i++) {
+ res[i] = ((Integer)values.get(i)).intValue();
+ }
+ return res;
+ }
+
public void endElement() {
int offset = getAttributeAsInteger(lastAttributes, "offset", 0);
+ int[] letterAdjust = toIntArray(lastAttributes.getValue("letter-adjust"));
String txt = content.toString();
- WordArea word = new WordArea(txt, offset);
+ WordArea word = new WordArea(txt, offset, letterAdjust);
AbstractTextArea text = getCurrentText();
word.setParentArea(text);
text.addChildArea(word);
@@ -691,7 +709,8 @@ public class AreaTreeParser {
String txt = content.toString();
//TODO the isAdjustable parameter is currently not used/implemented
if (txt.length() > 0) {
- SpaceArea space = new SpaceArea(txt.charAt(0), offset, false);
+ boolean adjustable = getAttributeAsBoolean(lastAttributes, "adj", true);
+ SpaceArea space = new SpaceArea(txt.charAt(0), offset, adjustable);
AbstractTextArea text = getCurrentText();
space.setParentArea(text);
text.addChildArea(space);
diff --git a/src/java/org/apache/fop/area/inline/Character.java b/src/java/org/apache/fop/area/inline/Character.java
index f672e3632..04f73aa86 100644
--- a/src/java/org/apache/fop/area/inline/Character.java
+++ b/src/java/org/apache/fop/area/inline/Character.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 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.
@@ -21,6 +21,7 @@ package org.apache.fop.area.inline;
/**
* Single character inline area.
* This inline area holds a single character.
+ * @deprecated A TextArea with a single WordArea as its child should be used instead.
*/
public class Character extends AbstractTextArea {
// use a String instead of a character because if this character
diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java
index 6ec573107..193553464 100644
--- a/src/java/org/apache/fop/area/inline/SpaceArea.java
+++ b/src/java/org/apache/fop/area/inline/SpaceArea.java
@@ -28,11 +28,6 @@ public class SpaceArea extends InlineArea {
protected String space;
/**
- * The correction offset for the next area
- */
- protected int offset = 0;
-
- /**
* Is this space adjustable?
*/
protected boolean isAdjustable;
@@ -56,16 +51,8 @@ public class SpaceArea extends InlineArea {
return new String(space);
}
- /**
- * @return Returns the offset.
- */
- public int getOffset() {
- return offset;
- }
- /**
- * @param o The offset to set.
- */
- public void setOffset(int o) {
- offset = o;
+ /** @return true if the space is adjustable (WRT word-space processing) */
+ public boolean isAdjustable() {
+ return this.isAdjustable;
}
}
diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java
index 3bee4254f..a3962f457 100644
--- a/src/java/org/apache/fop/area/inline/TextArea.java
+++ b/src/java/org/apache/fop/area/inline/TextArea.java
@@ -54,7 +54,17 @@ public class TextArea extends AbstractTextArea {
* @param offset the offset for the next area
*/
public void addWord(String word, int offset) {
- WordArea wordArea = new WordArea(word, offset);
+ addWord(word, offset, null);
+ }
+
+ /**
+ * Create and add a WordArea child to this TextArea.
+ *
+ * @param word the word string
+ * @param offset the offset for the next area
+ */
+ public void addWord(String word, int offset, int[] letterAdjust) {
+ WordArea wordArea = new WordArea(word, offset, letterAdjust);
addChildArea(wordArea);
wordArea.setParentArea(this);
}
diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java
index b998b819e..f62dc499f 100644
--- a/src/java/org/apache/fop/area/inline/WordArea.java
+++ b/src/java/org/apache/fop/area/inline/WordArea.java
@@ -22,24 +22,25 @@ package org.apache.fop.area.inline;
*/
public class WordArea extends InlineArea {
- /**
- * The text for this word area
- */
+ /** The text for this word area */
protected String word;
- /**
- * The correction offset for the next area
- */
+ /** The correction offset for the next area */
protected int offset = 0;
+
+ /** An array of width for adjusting the individual letters (optional) */
+ protected int[] letterAdjust;
/**
* Create a word area
* @param w the word string
* @param o the offset for the next area
+ * @param la the letter adjust array (may be null)
*/
- public WordArea(String w, int o) {
+ public WordArea(String w, int o, int[] la) {
word = w;
offset = o;
+ this.letterAdjust = la;
}
/**
@@ -61,4 +62,10 @@ public class WordArea extends InlineArea {
public void setOffset(int o) {
offset = o;
}
+
+ /** @return the array of letter adjust widths */
+ public int[] getLetterAdjustArray() {
+ return this.letterAdjust;
+ }
+
}