Browse Source

align() method introduced


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193292 13f79535-47bb-0310-9956-ffa450edef68
tags/pre-columns
arved 24 years ago
parent
commit
df42d59606
1 changed files with 48 additions and 4 deletions
  1. 48
    4
      src/org/apache/fop/layout/LinkSet.java

+ 48
- 4
src/org/apache/fop/layout/LinkSet.java View File

@@ -59,6 +59,15 @@ import java.util.Vector;
import java.util.Enumeration;
import java.awt.Rectangle;

import org.apache.fop.fo.properties.WrapOption; // for enumerated
// values
import org.apache.fop.fo.properties.WhiteSpaceTreatment; // for
// enumerated values
import org.apache.fop.fo.properties.TextAlign; // for enumerated
// values
import org.apache.fop.fo.properties.TextAlignLast; // for enumerated
// values

/**
* a set of rectangles on a page that are linked to a common
* destination
@@ -71,16 +80,18 @@ public class LinkSet {
/** the set of rectangles */
Vector rects = new Vector();

int xoffset = 0;
private int xoffset = 0;
private int yoffset = 0;
// property required for alignment adjustments
int contentRectangleWidth = 0;

int yoffset = 0;
public LinkSet(String externalDest) {
this.externalDestination = externalDest;
}
public void addRect(Rectangle r) {
r.y = yoffset;
r.y = this.yoffset;
rects.addElement(r);
}
@@ -88,6 +99,14 @@ public class LinkSet {
this.yoffset = y;
}
public void setXOffset(int x) {
this.xoffset = x;
}
public void setContentRectangleWidth(int contentRectangleWidth) {
this.contentRectangleWidth = contentRectangleWidth;
}
public void applyAreaContainerOffsets(AreaContainer ac) {
Enumeration re = rects.elements();
while (re.hasMoreElements()) {
@@ -122,6 +141,31 @@ public class LinkSet {
rects = nv;
}
public void align(int type, int padding) {
int offset = 0;

switch (type) {
case TextAlign.START: // left
offset = 0;
break;
case TextAlign.END: // right
offset = padding / 2;
break;
case TextAlign.CENTERED: // center
offset = padding;
break;
case TextAlign.JUSTIFIED: // justify
// not yet implemented
break;
}

Enumeration re = rects.elements();
while (re.hasMoreElements()) {
Rectangle r = (Rectangle)re.nextElement();
r.x += offset;
}
}

public String getDest() {
return this.externalDestination;
}

Loading…
Cancel
Save