HanSolo / medusa

A JavaFX library for Gauges
Apache License 2.0
688 stars 129 forks source link

FXML LCD gauge #162

Closed markpiazza closed 5 years ago

markpiazza commented 5 years ago

I've been porting a Java 7 JavaFX app using JFXtras-labs to Java 8 with Medusa 8.2. When initializing the LCD gauge from FXML like this: <Gauge fx:id="xLcd" skinType="LCD" title="Title" unit="mm" decimals="3" subTitle="Subtitle" minWidth="200" prefWidth="200" maxWidth="200" minHeight="75" prefHeight="75" maxHeight="75" oldValueVisible="false" minMeasuredValueVisible="false" maxMeasuredValueVisible="false" onMousePressed="#handleDroMouseClick">

I get this: https://drive.google.com/open?id=1T-GM9sCIIDnrwcGPD16dW98wlJr3WxMV

It seems to be ignoring the visibility settings and the subtitle for some reason.

I walked back versions and found that something changed between 5.9 and 6.0

In 5.9, this is the way it looks: https://drive.google.com/open?id=1WtouIOdVH13fynH2K9QzcfW9w2NIXyJp Obviously it's not quite right in 5.9 either,

It looks correct when being defined in java-land: Gauge root = new Gauge(Gauge.SkinType.LCD); root.setMaxMeasuredValueVisible(false); root.setMinMeasuredValueVisible(false); root.setOldValueVisible(false); root.setTitle("A Axis Position"); root.setSubTitle("mm/min"); stage.setScene(new Scene(root,200,75)); stage.show(); https://drive.google.com/open?id=1x6T7D-QVzmWV937o3Ji6bbsaC9LgvZko

markpiazza commented 5 years ago

I've done some digging and I think it's down to Gauge#setSkinType inside the switch where it sets the visibility of those fields. setMinMeasuredValueVisible(true); setMaxMeasuredValueVisible(true); setOldValueVisible(true); Stepping through the code visibility is set twice. Once on initialization using my own values, and then again when it sets the skinType, which overrides my values. Commenting out these lines works for me, but I didn't want to presume to make a PR not knowing why they are there.

As a workaround, I'm able to use the properties to set them after the fact, but this needs to be done outside of my controller's init and I haven't thought of a good way to do that.

Thanks

HanSolo commented 5 years ago

Sorry for the late reply but I was too busy. So the problem was related to a missing constructor that supports all or nearly all properties. This is needed to initialize a control properly via FXML. I've added one for the Gauge control and it looks like it fixes your issue. Could you please try the latest version from the repo?

markpiazza commented 5 years ago

No need to apologize. I appreciate you taking a look. Your fix looks to have solved my problem. Thanks so much.

HanSolo commented 5 years ago

That's good news :)