Skip to content

Commit 22d4cdf

Browse files
committed
Add settings tests, fix minimum prediction score setting update from config.
1 parent f4a60f2 commit 22d4cdf

File tree

7 files changed

+370
-16
lines changed

7 files changed

+370
-16
lines changed

src/main/java/com/github/mfl28/boundingboxeditor/model/io/BoundingBoxPredictorConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public class BoundingBoxPredictorConfig {
66
private final BooleanProperty inferenceEnabled = new SimpleBooleanProperty(false);
77
private final DoubleProperty minimumScore = new SimpleDoubleProperty(0.5);
88
private final BooleanProperty resizeImages = new SimpleBooleanProperty(true);
9-
private final IntegerProperty maxImageWidth = new SimpleIntegerProperty(400);
10-
private final IntegerProperty maxImageHeight = new SimpleIntegerProperty(400);
9+
private final IntegerProperty maxImageWidth = new SimpleIntegerProperty(600);
10+
private final IntegerProperty maxImageHeight = new SimpleIntegerProperty(600);
1111
private final BooleanProperty keepImageRatio = new SimpleBooleanProperty(true);
1212
private final BooleanProperty mergeCategories = new SimpleBooleanProperty(true);
1313

src/main/java/com/github/mfl28/boundingboxeditor/ui/MenuBarView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class MenuBarView extends MenuBar implements View {
6666
private static final String JSON_IMPORT_MENU_ITEM_ID = "json-import-menu-item";
6767
private static final String SETTINGS_TEXT = "Se_ttings";
6868
private static final String SETTINGS_ICON_ID = "settings-icon";
69+
private static final String FILE_SETTINGS_MENU_ITEM_ID = "file-settings-menu-item";
6970

7071
private final MenuItem fileOpenFolderItem = new MenuItem(OPEN_FOLDER_TEXT, createIconRegion(OPEN_FOLDER_ICON_ID));
7172
private final Menu fileExportAnnotationsMenu = new Menu(SAVE_TEXT, createIconRegion(SAVE_ICON_ID));
@@ -176,6 +177,7 @@ private Menu createFileMenu() {
176177
fileOpenFolderItem.setId(FILE_OPEN_FOLDER_MENU_ITEM_ID);
177178
fileExportAnnotationsMenu.setId(FILE_EXPORT_ANNOTATIONS_MENU_ID);
178179
fileImportAnnotationsMenu.setId(FILE_IMPORT_ANNOTATIONS_MENU_ID);
180+
settingsMenuItem.setId(FILE_SETTINGS_MENU_ITEM_ID);
179181
fileExitItem.setId(FILE_EXIT_MENU_ITEM_ID);
180182

181183
return fileMenu;

src/main/java/com/github/mfl28/boundingboxeditor/ui/settings/InferenceSettingsView.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class InferenceSettingsView extends GridPane implements View, ApplyButton
3232
private static final String MERGE_CATEGORIES_LABEL_TEXT = "Merge Categories";
3333
private static final String SUBGROUP_TITLE_LABEL_ID = "subgroup-title-label";
3434
private static final String SETTINGS_SUBGROUP_BOX_ID = "settings-subgroup-box";
35+
private static final String SERVERS_SUBGROUP_TITLE = "Torch serve";
36+
private static final String PREDICTION_SUBGROUP_TITLE = "Prediction";
37+
private static final String PREPROCESSING_SUBGROUP_TITLE = "Preprocessing";
3538
private final Button selectModelButton = new Button("Select");
3639
private final Label selectedModelLabel = new Label(NO_MODEL_SELECTED_TEXT);
3740
private final ToggleSwitch inferenceEnabledControl = new ToggleSwitch();
@@ -91,7 +94,7 @@ public void applyDisplayedSettingsToPredictorConfig(BoundingBoxPredictorConfig c
9194
}
9295

9396
public void setDisplayedSettingsFromPredictorConfig(BoundingBoxPredictorConfig config) {
94-
minimumScoreControl.getEditor().setText(Double.toString(config.getMinimumScore()));
97+
minimumScoreControl.getValueFactory().setValue(config.getMinimumScore());
9598
inferenceEnabledControl.setSelected(config.isInferenceEnabled());
9699
resizeImagesControl.setSelected(config.isResizeImages());
97100
maxImageWidthField.setText(Integer.toString(config.getMaxImageWidth()));
@@ -165,18 +168,38 @@ public Spinner<Double> getMinimumScoreControl() {
165168
return minimumScoreControl;
166169
}
167170

171+
public CheckBox getResizeImagesControl() {
172+
return resizeImagesControl;
173+
}
174+
175+
public TextField getMaxImageWidthField() {
176+
return maxImageWidthField;
177+
}
178+
179+
public TextField getMaxImageHeightField() {
180+
return maxImageHeightField;
181+
}
182+
183+
public CheckBox getKeepImageRatioControl() {
184+
return keepImageRatioControl;
185+
}
186+
187+
public CheckBox getMergeCategoriesControl() {
188+
return mergeCategoriesControl;
189+
}
190+
168191
private void setUpContent() {
169192
int rowIndex = -1;
170193

171194
addInferenceControlRow(++rowIndex);
172-
addSubgroupTitleRow("Servers", ++rowIndex);
195+
addSubgroupTitleRow(SERVERS_SUBGROUP_TITLE, ++rowIndex);
173196
addInferenceAddressRow(++rowIndex);
174197
addManagementAddressRow(++rowIndex);
175198
addModelSelectionRow(++rowIndex);
176-
addSubgroupTitleRow("Prediction", ++rowIndex);
199+
addSubgroupTitleRow(PREDICTION_SUBGROUP_TITLE, ++rowIndex);
177200
addMinimumPredictionScoreRow(++rowIndex);
178201
addPredictionMergeCategoryChoiceRow(++rowIndex);
179-
addSubgroupTitleRow("Preprocessing", ++rowIndex);
202+
addSubgroupTitleRow(PREPROCESSING_SUBGROUP_TITLE, ++rowIndex);
180203
addImageResizePreprocessingSetupRow(++rowIndex);
181204
}
182205

src/main/java/com/github/mfl28/boundingboxeditor/ui/settings/UISettingsView.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class UISettingsView extends GridPane implements ApplyButtonChangeProvider {
1212
private static final String GRID_PANE_STYLE_CLASS = "grid-pane";
13-
private final CheckBox showObjectPopover = new CheckBox();
13+
private final CheckBox showObjectPopoverControl = new CheckBox();
1414

1515
public UISettingsView() {
1616
getStyleClass().add(GRID_PANE_STYLE_CLASS);
@@ -21,20 +21,24 @@ public UISettingsView() {
2121
}
2222

2323
public void setDisplayedSettingsFromUISettingsConfig(UISettingsConfig config) {
24-
showObjectPopover.setSelected(config.isShowObjectPopover());
24+
showObjectPopoverControl.setSelected(config.isShowObjectPopover());
2525
}
2626

2727
public void applyDisplayedSettingsToUISettingsConfig(UISettingsConfig config) {
28-
config.setShowObjectPopover(showObjectPopover.isSelected());
28+
config.setShowObjectPopover(showObjectPopoverControl.isSelected());
2929
}
3030

3131
@Override
3232
public void registerPropertyListeners(Button applyButton) {
33-
showObjectPopover.selectedProperty()
34-
.addListener((observable, oldValue, newValue) -> applyButton.setDisable(false));
33+
showObjectPopoverControl.selectedProperty()
34+
.addListener((observable, oldValue, newValue) -> applyButton.setDisable(false));
35+
}
36+
37+
public CheckBox getShowObjectPopoverControl() {
38+
return showObjectPopoverControl;
3539
}
3640

3741
private void setUpContent() {
38-
addRow(0, new Label("Show object popover"), showObjectPopover);
42+
addRow(0, new Label("Show object popover"), showObjectPopoverControl);
3943
}
4044
}

src/test/java/com/github/mfl28/boundingboxeditor/BoundingBoxEditorTestBase.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
import javafx.scene.Node;
3333
import javafx.scene.Parent;
3434
import javafx.scene.Scene;
35-
import javafx.scene.control.DialogPane;
36-
import javafx.scene.control.Menu;
37-
import javafx.scene.control.MenuBar;
38-
import javafx.scene.control.MenuItem;
35+
import javafx.scene.control.*;
3936
import javafx.scene.image.ImageView;
4037
import javafx.scene.input.MouseButton;
4138
import javafx.stage.Modality;
@@ -253,6 +250,13 @@ protected void timeOutLookUpInStageAndClickOn(FxRobot robot, Stage stage, String
253250
robot.targetWindow(stage).clickOn(id);
254251
}
255252

253+
protected void clickOnButtonInDialogStage(FxRobot robot, Stage stage, ButtonType buttonType, TestInfo testinfo) {
254+
verifyThat(stage.getScene().getRoot(), Matchers.instanceOf(DialogPane.class), saveScreenshot(testinfo));
255+
256+
robot.clickOn(((DialogPane)stage.getScene().getRoot()).lookupButton(buttonType));
257+
WaitForAsyncUtils.waitForFxEvents();
258+
}
259+
256260
protected void timeOutLookUp(FxRobot robot, String id, TestInfo testinfo) {
257261
Assertions.assertDoesNotThrow(() -> WaitForAsyncUtils.waitFor(TIMEOUT_DURATION_IN_SEC, TimeUnit.SECONDS,
258262
() -> nodePresentAndVisible(robot, id)),

0 commit comments

Comments
 (0)