HanSolo / medusa

A JavaFX library for Gauges
Apache License 2.0
694 stars 131 forks source link

GaugeBuilder for half skin ignores tick space #200

Closed kahgoh closed 4 years ago

kahgoh commented 4 years ago

The tick space settings are ignored when I set them in the builder. For example:

gauge = GaugeBuilder.create()
        .skinType(Gauge.SkinType.HORIZONTAL)
        .autoScale(false)
        .angleRange(60)
        .majorTickSpace(25).minorTickSpace(5).build();

Gives me a gauge that looks like this: wrong_tick_space

I was expecting the ticks to more spaced out, like this: image

I get the expected result if I set the tick space AFTER building the gauge, like this:

gauge = GaugeBuilder.create()
        .skinType(Gauge.SkinType.HORIZONTAL)
        .autoScale(false)
        .angleRange(60)
        .majorTickSpace(25).minorTickSpace(5).build();

gauge.setMajorTickSpace(25);
gauge.setMinorTickSpace(5);
kahgoh commented 4 years ago

Even though autoScale is being set in the builder, it is being overridden because setting the angleRange property triggers an auto-scale. Setting autoScale to false isn't having an effect because the builder sets it while looping through the properties in a HashMap (it is setting autoScale AFTER angleRange).

I have raised #201 to fix this.