tresholdProperty can not be used with binding
Closed this issue · 11 comments
Given following code:
DoubleProperty temperature = new SimpleDoubleProperty();
DoubleProperty temperatureTarget = new SimpleDoubleProperty();
var tempTile = TileBuilder.create()
.skinType(Tile.SkinType.GAUGE)
.prefSize(200, 200)
.title("Temperature")
.unit("°C")
.maxValue(150)
.build();
tempTile.valueProperty().bind(temperature);
tempTile.tresholdProperty().bind(temperatureTarget);
Any change in temperature is showing as expected in the tile.
But the tresholdProperty throws:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: Tile.threshold : A bound value cannot be set.
at javafx.base/javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:144)
at eu.hansolo.tilesfx.Tile.setThreshold(Tile.java:1363)
at eu.hansolo.tilesfx.Tile.setMaxValue(Tile.java:1283)
at eu.hansolo.tilesfx.Tile.calcAutoScale(Tile.java:4240)
at eu.hansolo.tilesfx.skins.GaugeTileSkin.initGraphics(GaugeTileSkin.java:95)
at eu.hansolo.tilesfx.skins.TileSkin.<init>(TileSkin.java:132)
at eu.hansolo.tilesfx.skins.GaugeTileSkin.<init>(GaugeTileSkin.java:86)
at eu.hansolo.tilesfx.Tile.createDefaultSkin(Tile.java:6200)
Can you check with the current code in the repository? Should be fixed so far.
wow that is fast! can I use a snapshot-build of the dependency?
I’ll create a new release later today
you're a hero!
fixed with version 11.46
Sorry to say, but seems the problem is still there... I'm using the new version (thanks for the typo fix ;-))
Exception in thread "WebSocketConnectReadThread-33" java.lang.RuntimeException: Tile.threshold : A bound value cannot be set.
at javafx.base/javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:144)
at eu.hansolo.tilesfx.Tile$7.invalidated(Tile.java:1381)
at javafx.base/javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:113)
at javafx.base/javafx.beans.property.DoublePropertyBase$Listener.invalidated(DoublePropertyBase.java:261)
at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:136)
at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
at javafx.base/javafx.beans.property.DoublePropertyBase.fireValueChangedEvent(DoublePropertyBase.java:107)
at javafx.base/javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:114)
at javafx.base/javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:148)
Exception in thread "WebSocketConnectReadThread-33" java.lang.IllegalStateException: Not on FX application thread; currentThread = WebSocketConnectReadThread-33
at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:292)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:446)
at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:474)
at javafx.base/com.sun.javafx.collections.VetoableListDecorator.clear(VetoableListDecorator.java:293)
at eu.hansolo.tilesfx.skins.GaugeTileSkin.drawSections(GaugeTileSkin.java:243)
at eu.hansolo.tilesfx.skins.GaugeTileSkin.redraw(GaugeTileSkin.java:589)
at eu.hansolo.tilesfx.skins.TileSkin.handleEvents(TileSkin.java:201)
at eu.hansolo.tilesfx.skins.GaugeTileSkin.handleEvents(GaugeTileSkin.java:195)
at eu.hansolo.tilesfx.skins.TileSkin.lambda$new$1(TileSkin.java:127)
at eu.hansolo.tilesfx.Tile.fireTileEvent(Tile.java:6416)
at eu.hansolo.tilesfx.Tile$7.invalidated(Tile.java:1382)
Seems problem is on this line in Tile.java:
this.referenceValue = new DoublePropertyBase(this._referenceValue) {
Oh I thought you tested the fix before I’ve released the new version...will take another look at it.
no sorry, my fault, let me see if I can dive into the code myself. should be unit testable I presume :-)
I simply added checks for isBound() to the setters which worked when I’ve tested it yesterday. Maybe I’ve missed a ‘!’ somewhere.
Aha, can confirm, also happens in unit test when adding double property for the threshold. Which is nice of course, as I can now check more in detail ... :-)
fixed, see pull request