Skip to content

Commit

Permalink
Merge pull request #116 from FDelporte/feature/114_treshold_bound_error
Browse files Browse the repository at this point in the history
#114 extra bound check needed
  • Loading branch information
HanSolo authored Jan 7, 2021
2 parents 584e657 + 59802fd commit ec2a02e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/eu/hansolo/tilesfx/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,9 @@ public DoubleProperty thresholdProperty() {
threshold = new DoublePropertyBase(_threshold) {
@Override protected void invalidated() {
final double THRESHOLD = get();
if (THRESHOLD < getMinValue() || THRESHOLD > getMaxValue()) set(clamp(getMinValue(), getMaxValue(), THRESHOLD));
if (!isBound() && (THRESHOLD < getMinValue() || THRESHOLD > getMaxValue())) {
set(clamp(getMinValue(), getMaxValue(), THRESHOLD));
}
fireTileEvent(RESIZE_EVENT);
}
@Override public Object getBean() { return Tile.this; }
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/eu/hansolo/tilesfx/TilesFXTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import eu.hansolo.tilesfx.Tile.SkinType;
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.collections.ObservableList;
import javafx.event.EventType;
import javafx.scene.Node;
Expand All @@ -46,6 +48,8 @@ public class TilesFXTest extends Application {
private AnimationTimer timer;

@Override public void init() {
DoubleProperty testTresholdProperty = new SimpleDoubleProperty(0);

tile = TileBuilder.create()
.skinType(SkinType.GAUGE)
.prefSize(400, 400)
Expand All @@ -65,6 +69,7 @@ public class TilesFXTest extends Application {

tile.showNotifyRegion(true);
tile.showInfoRegion(true);
tile.thresholdProperty().bind(testTresholdProperty);

/*
tile = TileBuilder.create()
Expand All @@ -82,6 +87,7 @@ public class TilesFXTest extends Application {
@Override public void handle(final long now) {
if (now > lastTimerCall + 1_000_000_000l) {
tile.setValue(RND.nextDouble() * 25 + 5);
testTresholdProperty.set(RND.nextDouble() * 100);
lastTimerCall = now;
}
}
Expand Down

0 comments on commit ec2a02e

Please sign in to comment.