forked from tabulapdf/tabula-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangularTextContainer.java
More file actions
51 lines (40 loc) · 1.3 KB
/
RectangularTextContainer.java
File metadata and controls
51 lines (40 loc) · 1.3 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
package technology.tabula;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("serial")
public class RectangularTextContainer<T extends Rectangle & HasText> extends Rectangle implements HasText {
protected List<T> textElements = new ArrayList<>();
protected RectangularTextContainer(float top, float left, float width, float height) {
super(top, left, width, height);
}
public RectangularTextContainer<T> merge(RectangularTextContainer<T> other) {
if (compareTo(other) < 0) {
this.getTextElements().addAll(other.getTextElements());
} else {
this.getTextElements().addAll(0, other.getTextElements());
}
super.merge(other);
return this;
}
public List<T> getTextElements() {
return textElements;
}
public void setTextElements(List<T> textElements) {
this.textElements = textElements;
}
@Override
public String getText() {
throw new UnsupportedOperationException();
}
@Override
public String getText(boolean useLineReturns) {
throw new UnsupportedOperationException();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
String s = super.toString();
sb.append(s.substring(0, s.length() - 1));
sb.append(String.format(",text=%s]", this.getText() == null ? "null" : "\"" + this.getText() + "\""));
return sb.toString();
}
}