Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow zero time lag values in a filter (#131) #133

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Parameterize filter creation by value constraint predicate (#131)
  • Loading branch information
episarenko committed Dec 16, 2024
commit 3156711dc226161c3684f51fdac57828d8104a65
16 changes: 13 additions & 3 deletions src/main/java/com/ugcs/gprvisualizer/app/OptionPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.function.Predicate;

import com.ugcs.gprvisualizer.event.FileOpenedEvent;
import com.ugcs.gprvisualizer.event.GriddingParamsSetted;
Expand Down Expand Up @@ -164,11 +165,19 @@ private void prepareCsvTab(Tab tab) {
t3.setSpacing(5);

StackPane lowPassOptions = createFilterOptions(Filter.lowpass,"Enter cutoff wavelength (fiducials)",
i -> {
int value = Integer.parseInt(i);
return value != 0 && value < 10000;
},
i -> applyLowPassFilter(Integer.parseInt(i)),
i -> applyLowPassFilterToAll(Integer.parseInt(i))
);

StackPane timeLagOptions = createFilterOptions(Filter.timelag,"Enter time-lag (fiducials)",
i -> {
int value = Integer.parseInt(i);
return value < 10000;
},
i -> applyGnssTimeLag(Integer.parseInt(i)),
i -> applyGnssTimeLagToAll(Integer.parseInt(i))
);
Expand Down Expand Up @@ -366,7 +375,8 @@ public void griddingProgress(boolean inProgress) {
griddingProgressIndicator.setManaged(inProgress);
}

private @NotNull StackPane createFilterOptions(Filter filter, String promptText, Consumer<String> applyAction, Consumer<String> applyAllAction) {
private @NotNull StackPane createFilterOptions(Filter filter, String promptText, Predicate<String> valueConstraint,
Consumer<String> applyAction, Consumer<String> applyAllAction) {
VBox filterOptions = new VBox(5);
filterOptions.setPadding(new Insets(10, 0, 10, 0));

Expand All @@ -382,8 +392,8 @@ public void griddingProgress(boolean inProgress) {
applyButton.setDisable(true);
return;
}
int value = Integer.parseInt(newValue);
boolean isValid = !newValue.isEmpty() && value < 10000;
boolean isValid = !newValue.isEmpty()
&& (valueConstraint == null || valueConstraint.test(newValue));
applyButton.setDisable(!isValid);
} catch (NumberFormatException e) {
applyButton.setDisable(true);
Expand Down
Loading