Search in sources :

Example 6 with Section

use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.

the class RadialSkin method drawAreas.

private final void drawAreas(final GraphicsContext CTX) {
    final double xy = (size - 0.7925 * size) / 2;
    final double wh = size * 0.7925;
    final double MIN_VALUE = getSkinnable().getMinValue();
    final double MAX_VALUE = getSkinnable().getMaxValue();
    final double OFFSET = 90 - getSkinnable().getStartAngle();
    IntStream.range(0, getSkinnable().getAreas().size()).parallel().forEachOrdered(i -> {
        final Section AREA = getSkinnable().getAreas().get(i);
        final double AREA_START_ANGLE;
        if (Double.compare(AREA.getStart(), MAX_VALUE) <= 0 && Double.compare(AREA.getStop(), MIN_VALUE) >= 0) {
            if (AREA.getStart() < MIN_VALUE && AREA.getStop() < MAX_VALUE) {
                AREA_START_ANGLE = MIN_VALUE * angleStep;
            } else {
                AREA_START_ANGLE = (AREA.getStart() - MIN_VALUE) * angleStep;
            }
            final double AREA_ANGLE_EXTEND;
            if (AREA.getStop() > MAX_VALUE) {
                AREA_ANGLE_EXTEND = (MAX_VALUE - AREA.getStart()) * angleStep;
            } else {
                AREA_ANGLE_EXTEND = (AREA.getStop() - AREA.getStart()) * angleStep;
            }
            CTX.save();
            switch(i) {
                case 0:
                    CTX.setFill(getSkinnable().getAreaFill0());
                    break;
                case 1:
                    CTX.setFill(getSkinnable().getAreaFill1());
                    break;
                case 2:
                    CTX.setFill(getSkinnable().getAreaFill2());
                    break;
                case 3:
                    CTX.setFill(getSkinnable().getAreaFill3());
                    break;
                case 4:
                    CTX.setFill(getSkinnable().getAreaFill4());
                    break;
                case 5:
                    CTX.setFill(getSkinnable().getAreaFill5());
                    break;
                case 6:
                    CTX.setFill(getSkinnable().getAreaFill6());
                    break;
                case 7:
                    CTX.setFill(getSkinnable().getAreaFill7());
                    break;
                case 8:
                    CTX.setFill(getSkinnable().getAreaFill8());
                    break;
                case 9:
                    CTX.setFill(getSkinnable().getAreaFill9());
                    break;
            }
            CTX.fillArc(xy, xy, wh, wh, -(OFFSET + AREA_START_ANGLE), -AREA_ANGLE_EXTEND, ArcType.ROUND);
            CTX.restore();
        }
    });
}
Also used : Section(eu.hansolo.enzo.common.Section)

Example 7 with Section

use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.

the class DemoGauge method init.

@Override
public void init() {
    control = GaugeBuilder.create().prefSize(400, 400).animated(false).startAngle(330).angleRange(300).minValue(0).maxValue(100).sectionsVisible(true).sections(new Section(0, 15), new Section(15, 25), new Section(25, 35)).areas(new Section(25, 35, Color.rgb(255, 0, 0, 0.5))).majorTickSpace(10).plainValue(false).tickLabelOrientation(Gauge.TickLabelOrientation.HORIZONTAL).threshold(70).thresholdVisible(true).minMeasuredValueVisible(true).maxMeasuredValueVisible(true).title("Title").unit("Unit").build();
    // control.setStyle("-tick-label-fill: blue;");
    // control.setMinorTickSpaceOne(2);
    // control.setHistogramEnabled(true);
    // control.setOnThresholdExceeded(observable -> System.out.println("Threshold exceeded") );
    // control.setOnThresholdUnderrun(observable -> System.out.println("Threshold underrun"));
    marker0 = new Marker(25);
    // marker0.setOnMarkerExceeded(observable -> System.out.println("Marker exceeded"));
    // marker0.setOnMarkerUnderrun(observable -> System.out.println("Marker underrun"));
    control.addMarker(marker0);
    control.setMarkerFill0(Color.RED);
    lastTimerCall = System.nanoTime() + 3_000_000_000l;
    timer = new AnimationTimer() {

        @Override
        public void handle(long now) {
            if (now > lastTimerCall + 2_000_000_000l) {
                control.setValue(RND.nextDouble() * (control.getMaxValue() - control.getMinValue()) + control.getMinValue());
                System.out.println(control.getValue());
                lastTimerCall = now;
            }
        }
    };
}
Also used : AnimationTimer(javafx.animation.AnimationTimer) Marker(eu.hansolo.enzo.common.Marker) Section(eu.hansolo.enzo.common.Section)

Example 8 with Section

use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.

the class DemoRadialBargraph method init.

@Override
public void init() {
    control = RadialBargraphBuilder.create().title("Enzo").unit("°C").markers(new Marker(40)).threshold(25).sections(new Section(60, 80, Color.rgb(255, 255, 0, 0.5))).thresholdVisible(true).build();
    control.setBarGradientEnabled(true);
    List<Stop> stops = new ArrayList<>();
    stops.add(new Stop(0.0, Color.BLUE));
    // stops.add(new Stop(0.31, Color.CYAN));
    // stops.add(new Stop(0.5, Color.LIME));
    // stops.add(new Stop(0.69, Color.YELLOW));
    stops.add(new Stop(1.0, Color.RED));
    control.setBarGradient(stops);
    lastTimerCall = System.nanoTime() + 2_000_000_000l;
    timer = new AnimationTimer() {

        @Override
        public void handle(long now) {
            if (now > lastTimerCall + 5_000_000_000l) {
                control.setValue(RND.nextDouble() * 100);
                lastTimerCall = now;
            }
        }
    };
}
Also used : AnimationTimer(javafx.animation.AnimationTimer) Stop(javafx.scene.paint.Stop) ArrayList(java.util.ArrayList) Marker(eu.hansolo.enzo.common.Marker) Section(eu.hansolo.enzo.common.Section)

Example 9 with Section

use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.

the class DemoRadialGauge method init.

@Override
public void init() {
    leftControl = RadialGaugeBuilder.create().title("Bright").unit("Bright").sections(new Section(35, 50, Color.LIME)).areas(new Section(80, 100, Color.rgb(255, 0, 0, 0.5))).ledVisible(true).ledColor(Color.CYAN).build();
    rightControl = RadialGaugeBuilder.create().title("Dark").unit("Dark").style("-body: black; -tick-mark-fill: white; -tick-label-fill: white;").build();
    lastTimerCall = System.nanoTime() + 50_000_000l;
    timer = new AnimationTimer() {

        @Override
        public void handle(long now) {
            if (now > lastTimerCall + 2_000_000_000l) {
                leftControl.setValue(RND.nextDouble() * 100);
                rightControl.setValue(RND.nextDouble() * 100);
                leftControl.setBlinking(leftControl.getValue() > 50);
                lastTimerCall = now;
            }
        }
    };
}
Also used : AnimationTimer(javafx.animation.AnimationTimer) Section(eu.hansolo.enzo.common.Section)

Example 10 with Section

use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.

the class DemoRectangularGauge method init.

@Override
public void init() {
    control = RectangularGaugeBuilder.create().title("Temperature").unit("°C").tickLabelOrientation(TickLabelOrientation.ORTHOGONAL).ledVisible(true).sections(new Section(0, 25, Color.rgb(0, 0, 255, 0.5)), new Section(25, 50, Color.rgb(0, 255, 255, 0.5)), new Section(50, 75, Color.rgb(0, 255, 0, 0.5)), new Section(75, 100, Color.rgb(255, 255, 0, 0.5))).sectionsVisible(true).decimals(2).build();
    lastTimerCall = System.nanoTime() + 50_000_000l;
    timer = new AnimationTimer() {

        @Override
        public void handle(long now) {
            if (now > lastTimerCall + 2_000_000_000l) {
                control.setValue(RND.nextDouble() * 100);
                control.setBlinking(control.getValue() > 50);
                lastTimerCall = now;
            }
        }
    };
}
Also used : AnimationTimer(javafx.animation.AnimationTimer) Section(eu.hansolo.enzo.common.Section)

Aggregations

Section (eu.hansolo.enzo.common.Section)31 AnimationTimer (javafx.animation.AnimationTimer)10 DoubleProperty (javafx.beans.property.DoubleProperty)8 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)8 Marker (eu.hansolo.enzo.common.Marker)6 IntStream (java.util.stream.IntStream)6 BooleanProperty (javafx.beans.property.BooleanProperty)6 ObjectProperty (javafx.beans.property.ObjectProperty)6 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)6 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)6 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)6 StringProperty (javafx.beans.property.StringProperty)6 ListChangeListener (javafx.collections.ListChangeListener)6 Skin (javafx.scene.control.Skin)6 Color (javafx.scene.paint.Color)6 ArrayList (java.util.ArrayList)5 FXCollections (javafx.collections.FXCollections)5 ObservableList (javafx.collections.ObservableList)5 List (java.util.List)4 Locale (java.util.Locale)4