Skip to content

Commit 85fbaa0

Browse files
committed
Add parallel JSON deserialization, perform refactorings, improve tests.
1 parent de4db6f commit 85fbaa0

File tree

15 files changed

+263
-251
lines changed

15 files changed

+263
-251
lines changed

src/main/java/boundingboxeditor/controller/Controller.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ public Controller(final Stage mainStage) {
144144
setUpModelListeners();
145145
}
146146

147-
IoMetaData getIoMetaData() {
148-
return ioMetaData;
149-
}
150-
151147
/**
152148
* Handles the event of the user requesting to open a new image folder.
153149
*/
@@ -528,6 +524,10 @@ public Model getModel() {
528524
return model;
529525
}
530526

527+
IoMetaData getIoMetaData() {
528+
return ioMetaData;
529+
}
530+
531531
Stage getStage() {
532532
return stage;
533533
}

src/main/java/boundingboxeditor/model/ImageMetaData.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@ public boolean equals(Object obj) {
110110
return false;
111111
}
112112

113-
@Override
114-
public String toString() {
115-
return "ImageMetaData[fileName=" + getFileName() + ", folderName=" + getFolderName()
116-
+ ", image-width=" + getImageWidth() + ", image-height=" + getImageHeight() + ", image-depth=" +
117-
getImageDepth();
118-
}
119-
120113
public String getDimensionsString() {
121114
if(details == null) {
122115
return "[]";

src/main/java/boundingboxeditor/model/io/BoundingBoxData.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ public <T> T accept(BoundingShapeDataVisitor<T> visitor) {
123123
return visitor.visit(this);
124124
}
125125

126+
@Override
127+
public int hashCode() {
128+
return Objects.hash(super.hashCode(), relativeBoundsInImage);
129+
}
130+
126131
@Override
127132
public boolean equals(Object o) {
128133
if(this == o) {
@@ -145,11 +150,6 @@ public boolean equals(Object o) {
145150
MathUtils.doubleAlmostEqual(relativeBoundsInImage.getMaxX(), that.relativeBoundsInImage.getMaxX()) &&
146151
MathUtils.doubleAlmostEqual(relativeBoundsInImage.getMaxY(), that.relativeBoundsInImage.getMaxY());
147152
}
148-
149-
@Override
150-
public int hashCode() {
151-
return Objects.hash(super.hashCode(), relativeBoundsInImage);
152-
}
153153
}
154154

155155

src/main/java/boundingboxeditor/model/io/IoMetaData.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class IoMetaData {
1212

1313
/**
1414
* Get the currently set default directory for image loading.
15+
*
1516
* @return the directory
1617
*/
1718
public File getDefaultImageLoadingDirectory() {
@@ -20,6 +21,7 @@ public File getDefaultImageLoadingDirectory() {
2021

2122
/**
2223
* Set the current default directory for image loading.
24+
*
2325
* @param defaultImageLoadingDirectory the directory
2426
*/
2527
public void setDefaultImageLoadingDirectory(File defaultImageLoadingDirectory) {
@@ -28,6 +30,7 @@ public void setDefaultImageLoadingDirectory(File defaultImageLoadingDirectory) {
2830

2931
/**
3032
* Get the currently set default directory for annotation saving.
33+
*
3134
* @return the directory
3235
*/
3336
public File getDefaultAnnotationSavingDirectory() {
@@ -36,6 +39,7 @@ public File getDefaultAnnotationSavingDirectory() {
3639

3740
/**
3841
* Set the current default directory for annotation saving.
42+
*
3943
* @param defaultAnnotationSavingDirectory the directory
4044
*/
4145
public void setDefaultAnnotationSavingDirectory(File defaultAnnotationSavingDirectory) {
@@ -44,6 +48,7 @@ public void setDefaultAnnotationSavingDirectory(File defaultAnnotationSavingDire
4448

4549
/**
4650
* Get the currently set default directory for annotation loading.
51+
*
4752
* @return the directory
4853
*/
4954
public File getDefaultAnnotationLoadingDirectory() {
@@ -52,6 +57,7 @@ public File getDefaultAnnotationLoadingDirectory() {
5257

5358
/**
5459
* Set the current default directory for annotation loading.
60+
*
5561
* @param defaultAnnotationLoadingDirectory the directory
5662
*/
5763
public void setDefaultAnnotationLoadingDirectory(File defaultAnnotationLoadingDirectory) {

src/main/java/boundingboxeditor/model/io/JSONLoadStrategy.java

Lines changed: 109 additions & 111 deletions
Large diffs are not rendered by default.

src/main/java/boundingboxeditor/ui/BoundingBoxView.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,6 @@ public boolean equals(Object obj) {
140140
MathUtils.doubleAlmostEqual(getHeight(), other.getHeight());
141141
}
142142

143-
@Override
144-
public String toString() {
145-
return "BoundingBoxView[x=" + getX() + ", y=" + getY() + ", width=" + getWidth() + ", height=" + getHeight()
146-
+ ", fill=" + getFill() + ", category=" + boundingShapeViewData.getObjectCategory()
147-
+ ", image-metadata=" + boundingShapeViewData.getImageMetaData() + "]";
148-
}
149-
150143
/**
151144
* Returns the associated {@link ObjectCategory} object.
152145
*

src/main/java/boundingboxeditor/ui/DragAnchor.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ public class DragAnchor {
1515
DragAnchor() {
1616
}
1717

18-
@Override
19-
public String toString() {
20-
return "DragAnchor " + "[x = " + getX() + ", y = " + getY() + "]";
21-
}
22-
2318
/**
2419
* Convenience method to set both coordinates from
2520
* a {@link MouseEvent} object's position relative to the event's source.
@@ -40,15 +35,6 @@ public void setFromMouseEvent(MouseEvent event) {
4035
return x;
4136
}
4237

43-
/**
44-
* Sets the x-coordinate.
45-
*
46-
* @param x the value to set
47-
*/
48-
void setX(double x) {
49-
this.x = x;
50-
}
51-
5238
/**
5339
* Returns the y-coordinate.
5440
*
@@ -58,15 +44,6 @@ void setX(double x) {
5844
return y;
5945
}
6046

61-
/**
62-
* Sets the y-coordinate.
63-
*
64-
* @param y the value to set
65-
*/
66-
void setY(double y) {
67-
this.y = y;
68-
}
69-
7047
/**
7148
* Convenience method to set both coordinates.
7249
*

src/main/java/boundingboxeditor/ui/TagScrollPaneView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @see View
2121
*/
2222
class TagScrollPaneView extends ScrollPane implements View {
23-
private static final String TEXT_FIELD_PROMPT_TEXT = "New tag";
23+
private static final String TEXT_FIELD_PROMPT_TEXT = "New Tag";
2424
private static final String TAG_INPUT_FIELD_ID = "tag-input-field";
2525
private static final String TAG_EDITOR_SCROLL_PANE_ID = "tag-editor-scroll-pane";
2626
private static final int FLOW_PANE_GAP_SIZE = 8;

src/main/java/boundingboxeditor/utils/MathUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,16 @@ public static double clamp(double val, double min, double max) {
5757
public static boolean doubleAlmostEqual(double a, double b) {
5858
return Math.abs(a - b) < DOUBLE_EQUAL_THRESHOLD;
5959
}
60+
61+
/**
62+
* Checks whether a double value is an element of a given closed interval.
63+
*
64+
* @param x the value to check
65+
* @param a the lower bound of the interval
66+
* @param b the upper bound of the interval
67+
* @return true if x is within [a, b], false otherwise
68+
*/
69+
public static boolean isWithin(double x, double a, double b) {
70+
return Double.compare(x, a) >= 0 && Double.compare(x, b) <= 0.0;
71+
}
6072
}

src/test/java/boundingboxeditor/BoundingBoxEditorTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ protected Stage timeOutAssertDialogOpenedAndGetStage(FxRobot robot, String title
311311
return getTopModalStage(robot, title);
312312
}
313313

314-
protected Stage timeoutGetTopModalStage(FxRobot robot, String stageTitle) {
314+
protected Stage timeOutGetTopModalStage(FxRobot robot, String stageTitle) {
315315
Assertions.assertDoesNotThrow(() -> WaitForAsyncUtils.waitFor(TIMEOUT_DURATION_IN_SEC, TimeUnit.SECONDS,
316316
() -> getTopModalStage(robot, stageTitle) !=
317317
null),

0 commit comments

Comments
 (0)