JFxtas Lcd Gauge max value

461 views Asked by At

I'm trying to use the LCD gauges in Jfxtras. Here's the code that I have to create the gauge:

    final Gauge lcd = GaugeBuilder.create()
            .gaugeType(GaugeBuilder.GaugeType.LCD)
            .lcdDesign(LcdDesign.DARKAMBER)
            .prefWidth(200)
            .prefHeight(85)
            .maxValue(9999)
            .build();

I'm then setting the value of the gauge like this:

    Platform.runLater( new Runnable() {

        @Override
        public void run() {
            lcd.setValue(245);
        }
    });

No matter what I do, the maximum value displayed seems to always be 100. Is there any way for me to override this and display a different max value?

2

There are 2 answers

0
eak12913 On BEST ANSWER

Ok - I had given up on this initially and made my own very ugly looking display, but just couldn't keep from digging further.

I checked out and built the jfxtras-labs source and found my issue.

In the constructor of: jfxtras.labs.scene.control.gauge.GaugeModel there is a private and unmodifiable scale property:

private ObjectProperty<LinearScale> scale;

It is hard coded to be initialized to have a min of 0 and a max of 100 in the default constructor.

scale = new SimpleObjectProperty<LinearScale>(new LinearScale(0, 100));

This constructor is used by both Gauge and Lcd.

At the moment, I haven't found any way to modify this property other than to change the source code.

Here's what I modified the above line to to resolve my issues:

scale = new SimpleObjectProperty<LinearScale>(new LinearScale(Integer.MIN_VALUE, Integer.MAX_VALUE));

The only down stream side-effect I observed from this is that after doing this, you'll need to set the min/max property when building the gauges otherwise the radial gauges become useless as their scale is unreadable.

I haven't seen any other issues, but that doesn't mean that I haven't introduced any. So use at your own risk.

0
jaimebl On

I had the same problem as you. The problem is that GaugeBuilder changes the model max value, but doesn't change the VIEW's max value.

You don't need to override the sources.

All you need is:
final Gauge lcd = GaugeBuilder.create().gaugeType(GaugeBuilder.GaugeType.LCD).lcdDesign(LcdDesign.DARKAMBER).prefWidth(200).prefHeight(85).maxValue(9999).build();

//CODE BELOW IS SUPER IMPORTANT

lcd.setMaxValue(9999);