문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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);

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top