forked from tabulapdf/tabula-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.java
More file actions
62 lines (51 loc) · 1.46 KB
/
Cell.java
File metadata and controls
62 lines (51 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package technology.tabula;
import java.awt.geom.Point2D;
import java.util.Collections;
@SuppressWarnings("serial")
public class Cell extends RectangularTextContainer<TextChunk> {
public Cell(float top, float left, float width, float height) {
super(top, left, width, height);
this.setPlaceholder(false);
this.setSpanning(false);
}
public Cell(Point2D topLeft, Point2D bottomRight) {
super((float) topLeft.getY(), (float) topLeft.getX(), (float) (bottomRight.getX() - topLeft.getX()), (float) (bottomRight.getY() - topLeft.getY()));
this.setPlaceholder(false);
this.setSpanning(false);
}
private boolean spanning;
private boolean placeholder;
@Override
public String getText(boolean useLineReturns) {
if (this.textElements.size() == 0) {
return "";
}
StringBuilder sb = new StringBuilder();
this.textElements.sort(Rectangle.ILL_DEFINED_ORDER);
double curTop = this.textElements.get(0).getTop();
for (TextChunk tc : this.textElements) {
if (useLineReturns && tc.getTop() > curTop) {
sb.append('\r');
}
sb.append(tc.getText());
curTop = tc.getTop();
}
return sb.toString().trim();
}
@Override
public String getText() {
return getText(true);
}
public boolean isSpanning() {
return spanning;
}
public void setSpanning(boolean spanning) {
this.spanning = spanning;
}
public boolean isPlaceholder() {
return placeholder;
}
public void setPlaceholder(boolean placeholder) {
this.placeholder = placeholder;
}
}