aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorKelly Campbell <kellyc@apache.org>2001-03-29 07:34:57 +0000
committerKelly Campbell <kellyc@apache.org>2001-03-29 07:34:57 +0000
commit4805c63fb1a1fd0c075dbf872cf1e07ae119a934 (patch)
treeb5fddf0df53ca4b2fc1a1683ade45bfdd4e72c13 /src/org
parent86284c5b1d29aac3415887b81147fa1f61a6ff6a (diff)
downloadxmlgraphics-fop-4805c63fb1a1fd0c075dbf872cf1e07ae119a934.tar.gz
xmlgraphics-fop-4805c63fb1a1fd0c075dbf872cf1e07ae119a934.zip
Fixed basic-link horizontal position with justification turned on.
PR: 953 Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194179 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r--src/org/apache/fop/layout/LineArea.java31
-rw-r--r--src/org/apache/fop/layout/LinkSet.java10
-rw-r--r--src/org/apache/fop/layout/LinkedRectangle.java19
-rw-r--r--src/org/apache/fop/layout/inline/InlineArea.java11
4 files changed, 55 insertions, 16 deletions
diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java
index 1c0a94f3f..6425330da 100644
--- a/src/org/apache/fop/layout/LineArea.java
+++ b/src/org/apache/fop/layout/LineArea.java
@@ -244,7 +244,7 @@ public class LineArea extends Area {
((InlineArea) box).
getContentWidth(),
fontState.getFontSize());
- ls.addRect(lr, this);
+ ls.addRect(lr, this, (InlineArea)box);
}
}
addChild(box);
@@ -277,7 +277,7 @@ public class LineArea extends Area {
Rectangle lr = new Rectangle(finalWidth, 0,
ia.getContentWidth(),
fontState.getFontSize());
- ls.addRect(lr, this);
+ ls.addRect(lr, this, ia);
}
finalWidth += wordWidth;
@@ -419,7 +419,7 @@ public class LineArea extends Area {
Rectangle lr = new Rectangle(finalWidth + spaceWidth +
embeddedLinkStart, spaceWidth,
pia.getContentWidth(), fontState.getFontSize());
- ls.addRect(lr, this);
+ ls.addRect(lr, this, pia);
}
embeddedLinkStart += wordWidth;
@@ -606,8 +606,7 @@ public class LineArea extends Area {
endIndent += padding;
break;
case TextAlign.JUSTIFY: // justify
- Vector spaceList = new Vector();
-
+ // first pass - count the spaces
int spaceCount = 0;
Enumeration e = children.elements();
while (e.hasMoreElements()) {
@@ -615,7 +614,6 @@ public class LineArea extends Area {
if (b instanceof InlineSpace) {
InlineSpace space = (InlineSpace) b;
if (space.getResizeable()) {
- spaceList.addElement(space);
spaceCount++;
}
}
@@ -626,11 +624,22 @@ public class LineArea extends Area {
} else { // no spaces
padding = 0;
}
- Enumeration f = spaceList.elements();
- while (f.hasMoreElements()) {
- InlineSpace space2 = (InlineSpace) f.nextElement();
- int i = space2.getSize();
- space2.setSize(i + padding);
+ // second pass - add additional space
+ spaceCount = 0;
+ e = children.elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box) e.nextElement();
+ if (b instanceof InlineSpace) {
+ InlineSpace space = (InlineSpace) b;
+ if (space.getResizeable()) {
+ space.setSize(space.getSize() + padding);
+ spaceCount++;
+ }
+ }
+ else if (b instanceof InlineArea) {
+ ((InlineArea)b).setXOffset(spaceCount * padding);
+ }
+
}
}
}
diff --git a/src/org/apache/fop/layout/LinkSet.java b/src/org/apache/fop/layout/LinkSet.java
index 771ce4486..bce16ff59 100644
--- a/src/org/apache/fop/layout/LinkSet.java
+++ b/src/org/apache/fop/layout/LinkSet.java
@@ -59,6 +59,8 @@ import java.util.Vector;
import java.util.Enumeration;
import java.awt.Rectangle;
+import org.apache.fop.layout.inline.InlineArea;
+
import org.apache.fop.fo.properties.WrapOption; // for enumerated
// values
// import org.apache.fop.fo.properties.WhiteSpaceCollapse; // for
@@ -105,8 +107,8 @@ public class LinkSet {
this.linkType = linkType;
}
- public void addRect(Rectangle r, LineArea lineArea) {
- LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea);
+ public void addRect(Rectangle r, LineArea lineArea, InlineArea inlineArea) {
+ LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea, inlineArea);
linkedRectangle.setY(this.yoffset);
if (this.yoffset > maxY) {
maxY = this.yoffset;
@@ -171,7 +173,9 @@ public class LinkSet {
Enumeration re = rects.elements();
while (re.hasMoreElements()) {
LinkedRectangle r = (LinkedRectangle) re.nextElement();
- r.setX(r.getX() + r.getLineArea().getStartIndent());
+ r.setX(r.getX() +
+ r.getLineArea().getStartIndent() +
+ r.getInlineArea().getXOffset());
}
}
diff --git a/src/org/apache/fop/layout/LinkedRectangle.java b/src/org/apache/fop/layout/LinkedRectangle.java
index b23b763da..9956e3a80 100644
--- a/src/org/apache/fop/layout/LinkedRectangle.java
+++ b/src/org/apache/fop/layout/LinkedRectangle.java
@@ -57,6 +57,8 @@ package org.apache.fop.layout;
// Java
import java.awt.Rectangle;
+import org.apache.fop.layout.inline.InlineArea;
+
/**
* an object that stores a rectangle that is linked, and the LineArea
* that it is logically associated with
@@ -69,14 +71,19 @@ public class LinkedRectangle {
/** the associated LineArea */
protected LineArea lineArea;
- public LinkedRectangle(Rectangle link, LineArea lineArea) {
+ /** the associated InlineArea */
+ protected InlineArea inlineArea;
+
+ public LinkedRectangle(Rectangle link, LineArea lineArea, InlineArea inlineArea) {
this.link = link;
this.lineArea = lineArea;
+ this.inlineArea = inlineArea;
}
public LinkedRectangle(LinkedRectangle lr) {
this.link = new Rectangle( lr.getRectangle() );
this.lineArea = lr.getLineArea();
+ this.inlineArea = lr.getInlineArea();
}
public void setRectangle(Rectangle link) {
@@ -91,9 +98,17 @@ public class LinkedRectangle {
return this.lineArea;
}
- public void setLineArea() {
+ public void setLineArea(LineArea lineArea) {
this.lineArea = lineArea;
}
+
+ public InlineArea getInlineArea() {
+ return this.inlineArea;
+ }
+
+ public void setLineArea(InlineArea inlineArea) {
+ this.inlineArea = inlineArea;
+ }
public void setX(int x) {
this.link.x = x;
diff --git a/src/org/apache/fop/layout/inline/InlineArea.java b/src/org/apache/fop/layout/inline/InlineArea.java
index c0dedb4b4..6f202bdae 100644
--- a/src/org/apache/fop/layout/inline/InlineArea.java
+++ b/src/org/apache/fop/layout/inline/InlineArea.java
@@ -58,6 +58,9 @@ import org.apache.fop.layout.*;
public abstract class InlineArea extends Area {
private int yOffset = 0;
+
+ /** amount of space added since the original layout - needed by links */
+ private int xOffset = 0;
protected int height = 0;
private int verticalAlign = 0;
protected String pageNumberId = null;
@@ -114,6 +117,14 @@ public abstract class InlineArea extends Area {
return this.yOffset;
}
+ public void setXOffset(int xOffset) {
+ this.xOffset = xOffset;
+ }
+
+ public int getXOffset() {
+ return this.xOffset;
+ }
+
public String getPageNumberID() {
return pageNumberId;
}