Skip to content

Commit

Permalink
Light cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzido committed Apr 8, 2021
1 parent e49d860 commit 14b3d26
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/main/java/technology/tabula/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public String getText(boolean useLineReturns) {
return "";
}
StringBuilder sb = new StringBuilder();
Collections.sort(this.textElements, Rectangle.ILL_DEFINED_ORDER);
this.textElements.sort(Rectangle.ILL_DEFINED_ORDER);
double curTop = this.textElements.get(0).getTop();
for (TextChunk tc : this.textElements) {
if (useLineReturns && tc.getTop() > curTop) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/technology/tabula/RectangleSpatialIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public List<T> contains(Rectangle r) {
}

public List<T> intersects(Rectangle r) {
List rv = si.query(new Envelope(r.getLeft(), r.getRight(), r.getTop(), r.getBottom()));
return rv;
return si.query(new Envelope(r.getLeft(), r.getRight(), r.getTop(), r.getBottom()));
}

/**
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/technology/tabula/Ruling.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ public void normalize() {
else if (Utils.within(angle, 90, 1) || Utils.within(angle, 270, 1)) { // almost vertical
this.setLine(this.x1, this.y1, this.x1, this.y2);
}
// else {
// System.out.println("oblique: " + this + " ("+ this.getAngle() + ")");
// }
}

public boolean vertical() {
Expand Down Expand Up @@ -231,11 +228,6 @@ public boolean equals(Object other) {
return this.getP1().equals(o.getP1()) && this.getP2().equals(o.getP2());
}

@Override
public int hashCode() {
return super.hashCode();
}

public float getTop() {
return this.y1;
}
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/technology/tabula/TextChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,10 @@ public TextChunk[] splitAt(int i) {
throw new IllegalArgumentException();
}

TextChunk[] rv = new TextChunk[]{
new TextChunk(this.getTextElements().subList(0, i)),
new TextChunk(this.getTextElements().subList(i, this.getTextElements().size()))
};
return rv;
return new TextChunk[]{
new TextChunk(this.getTextElements().subList(0, i)),
new TextChunk(this.getTextElements().subList(i, this.getTextElements().size()))
};
}

/**
Expand Down Expand Up @@ -293,11 +292,8 @@ public boolean equals(Object obj) {
return false;
TextChunk other = (TextChunk) obj;
if (textElements == null) {
if (other.textElements != null)
return false;
} else if (!textElements.equals(other.textElements))
return false;
return true;
return other.textElements == null;
} else return textElements.equals(other.textElements);
}

public static boolean allSameChar(List<TextChunk> textChunks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public int compare(Ruling arg0, Ruling arg1) {

@Override
public int compare(TextChunk o1, TextChunk o2) {
return new java.lang.Float(o1.getLeft()).compareTo(o2.getLeft());
return Float.compare(o1.getLeft(), o2.getLeft());
}
});

Expand Down

0 comments on commit 14b3d26

Please sign in to comment.