1 51 package org.apache.fop.layout; 52 53 import java.util.List ; 55 import java.awt.Rectangle ; 56 57 import org.apache.fop.layout.inline.InlineArea; 59 60 64 public class LinkSet { 65 66 69 private String destination; 70 71 74 private List rects = new java.util.ArrayList (); 75 76 private int xoffset = 0; 77 private int yoffset = 0; 78 79 80 private int maxY = 0; 81 82 protected int startIndent; 83 protected int endIndent; 84 85 private int linkType; 86 87 private Area area; 88 89 public static final int INTERNAL = 0; public static final int EXTERNAL = 1; 92 private int contentRectangleWidth = 0; 94 95 public LinkSet(String destination, Area area, int linkType) { 96 this.destination = destination; 97 this.area = area; 98 this.linkType = linkType; 99 } 100 101 public void addRect(Rectangle r, LineArea lineArea, 102 InlineArea inlineArea) { 103 LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea, 104 inlineArea); 105 linkedRectangle.setY(this.yoffset); 106 if (this.yoffset > maxY) { 107 maxY = this.yoffset; 108 } 109 rects.add(linkedRectangle); 110 } 111 112 public void setYOffset(int y) { 113 this.yoffset = y; 114 } 115 116 public void setXOffset(int x) { 117 this.xoffset = x; 118 } 119 120 public void setContentRectangleWidth(int contentRectangleWidth) { 121 this.contentRectangleWidth = contentRectangleWidth; 122 } 123 124 public void applyAreaContainerOffsets(AreaContainer ac, Area area) { 125 int height = area.getAbsoluteHeight(); 126 BlockArea ba = (BlockArea)area; 127 for (int i = 0; i < rects.size(); i++ ) { 128 LinkedRectangle r = (LinkedRectangle)rects.get(i); 129 r.setX(r.getX() + ac.getXPosition() + area.getTableCellXOffset()); 130 r.setY(ac.getYPosition() - height + (maxY - r.getY()) 131 - ba.getHalfLeading()); 132 } 133 } 134 135 public void mergeLinks() { 137 int numRects = rects.size(); 138 if (numRects <= 1) return; 139 140 LinkedRectangle curRect = 141 new LinkedRectangle((LinkedRectangle)rects.get(0)); 142 List nv = new java.util.ArrayList (); 143 144 for (int ri = 1; ri < numRects; ri++) { 145 LinkedRectangle r = (LinkedRectangle)rects.get(ri); 146 147 if (r.getLineArea() == curRect.getLineArea()) { 149 curRect.setWidth(r.getX() + r.getWidth() - curRect.getX()); 150 } else { 151 nv.add(curRect); 152 curRect = new LinkedRectangle(r); 153 } 154 155 if (ri == numRects - 1) { 156 nv.add(curRect); 157 } 158 } 159 160 rects = nv; 161 } 162 163 public void align() { 164 for (int i = 0; i < rects.size(); i++ ) { 165 LinkedRectangle r = (LinkedRectangle)rects.get(i); 166 r.setX(r.getX() + r.getLineArea().getStartIndent() 167 + r.getInlineArea().getXOffset()); 168 } 169 } 170 171 public String getDest() { 172 return this.destination; 173 } 174 175 public List getRects() { 176 return this.rects; 177 } 178 179 public int getEndIndent() { 180 return endIndent; 181 } 182 183 public int getStartIndent() { 184 return startIndent; 185 } 186 187 public Area getArea() { 188 return area; 189 } 190 191 public int getLinkType() { 192 return linkType; 193 } 194 195 } 196 | Popular Tags |