Search in sources :

Example 1 with Section

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

the class DoubleRadialGaugeSkin method drawSections.

private final void drawSections(final GraphicsContext CTX) {
    final double xy = (size - 0.83425 * size) / 2;
    final double wh = size * 0.83425;
    final double MIN_VALUE_ONE = getSkinnable().getMinValueOne();
    final double MAX_VALUE_ONE = getSkinnable().getMaxValueOne();
    final double OFFSET_ONE = 90 - getSkinnable().getStartAngleOne();
    IntStream.range(0, getSkinnable().getSectionsOne().size()).parallel().forEachOrdered(i -> {
        final Section SECTION = getSkinnable().getSectionsOne().get(i);
        final double SECTION_START_ANGLE;
        if (Double.compare(SECTION.getStart(), MAX_VALUE_ONE) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE_ONE) >= 0) {
            if (SECTION.getStart() < MIN_VALUE_ONE && SECTION.getStop() < MAX_VALUE_ONE) {
                SECTION_START_ANGLE = MIN_VALUE_ONE * angleStepOne;
            } else {
                SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE_ONE) * angleStepOne;
            }
            final double SECTION_ANGLE_EXTEND;
            if (SECTION.getStop() > MAX_VALUE_ONE) {
                SECTION_ANGLE_EXTEND = (MAX_VALUE_ONE - SECTION.getStart()) * angleStepOne;
            } else {
                SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStepOne;
            }
            CTX.save();
            switch(i) {
                case 0:
                    CTX.setStroke(getSkinnable().getSectionFill0One());
                    break;
                case 1:
                    CTX.setStroke(getSkinnable().getSectionFill1One());
                    break;
                case 2:
                    CTX.setStroke(getSkinnable().getSectionFill2One());
                    break;
                case 3:
                    CTX.setStroke(getSkinnable().getSectionFill3One());
                    break;
                case 4:
                    CTX.setStroke(getSkinnable().getSectionFill4One());
                    break;
            }
            CTX.setLineWidth(size * 0.0415);
            CTX.setLineCap(StrokeLineCap.BUTT);
            CTX.strokeArc(xy, xy, wh, wh, -(OFFSET_ONE + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
            CTX.restore();
        }
    });
    final double MIN_VALUE_TWO = getSkinnable().getMinValueTwo();
    final double MAX_VALUE_TWO = getSkinnable().getMaxValueTwo();
    final double OFFSET_TWO = 90 - getSkinnable().getStartAngleTwo();
    IntStream.range(0, getSkinnable().getSectionsTwo().size()).parallel().forEachOrdered(i -> {
        final Section SECTION = getSkinnable().getSectionsTwo().get(i);
        final double SECTION_START_ANGLE;
        if (Double.compare(SECTION.getStart(), MAX_VALUE_TWO) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE_TWO) >= 0) {
            if (SECTION.getStart() < MIN_VALUE_TWO && SECTION.getStop() < MAX_VALUE_TWO) {
                SECTION_START_ANGLE = MIN_VALUE_TWO * angleStepTwo;
            } else {
                SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE_TWO) * angleStepTwo;
            }
            final double SECTION_ANGLE_EXTEND;
            if (SECTION.getStop() > MAX_VALUE_TWO) {
                SECTION_ANGLE_EXTEND = (MAX_VALUE_TWO - SECTION.getStart()) * angleStepTwo;
            } else {
                SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStepTwo;
            }
            CTX.save();
            switch(i) {
                case 0:
                    CTX.setStroke(getSkinnable().getSectionFill0Two());
                    break;
                case 1:
                    CTX.setStroke(getSkinnable().getSectionFill1Two());
                    break;
                case 2:
                    CTX.setStroke(getSkinnable().getSectionFill2Two());
                    break;
                case 3:
                    CTX.setStroke(getSkinnable().getSectionFill3Two());
                    break;
                case 4:
                    CTX.setStroke(getSkinnable().getSectionFill4Two());
                    break;
            }
            CTX.setLineWidth(size * 0.0415);
            CTX.setLineCap(StrokeLineCap.BUTT);
            CTX.strokeArc(xy, xy, wh, wh, -(OFFSET_TWO + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
            CTX.restore();
        }
    });
}
Also used : Section(eu.hansolo.enzo.common.Section)

Example 2 with Section

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

the class GaugeSkin method drawAreas.

private final void drawAreas(final GraphicsContext CTX) {
    final double xy = (size - 0.7916 * size) / 2;
    final double wh = size * 0.7916;
    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 3 with Section

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

the class GaugeSkin method drawSections.

private final void drawSections(final GraphicsContext CTX) {
    final double xy = (size - 0.83 * size) / 2;
    final double wh = size * 0.83;
    final double MIN_VALUE = getSkinnable().getMinValue();
    final double MAX_VALUE = getSkinnable().getMaxValue();
    final double OFFSET = 90 - getSkinnable().getStartAngle();
    IntStream.range(0, getSkinnable().getSections().size()).parallel().forEachOrdered(i -> {
        final Section SECTION = getSkinnable().getSections().get(i);
        final double SECTION_START_ANGLE;
        if (Double.compare(SECTION.getStart(), MAX_VALUE) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE) >= 0) {
            if (SECTION.getStart() < MIN_VALUE && SECTION.getStop() < MAX_VALUE) {
                SECTION_START_ANGLE = MIN_VALUE * angleStep;
            } else {
                SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE) * angleStep;
            }
            final double SECTION_ANGLE_EXTEND;
            if (SECTION.getStop() > MAX_VALUE) {
                SECTION_ANGLE_EXTEND = (MAX_VALUE - SECTION.getStart()) * angleStep;
            } else {
                SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep;
            }
            CTX.save();
            switch(i) {
                case 0:
                    CTX.setStroke(getSkinnable().getSectionFill0());
                    break;
                case 1:
                    CTX.setStroke(getSkinnable().getSectionFill1());
                    break;
                case 2:
                    CTX.setStroke(getSkinnable().getSectionFill2());
                    break;
                case 3:
                    CTX.setStroke(getSkinnable().getSectionFill3());
                    break;
                case 4:
                    CTX.setStroke(getSkinnable().getSectionFill4());
                    break;
                case 5:
                    CTX.setStroke(getSkinnable().getSectionFill5());
                    break;
                case 6:
                    CTX.setStroke(getSkinnable().getSectionFill6());
                    break;
                case 7:
                    CTX.setStroke(getSkinnable().getSectionFill7());
                    break;
                case 8:
                    CTX.setStroke(getSkinnable().getSectionFill8());
                    break;
                case 9:
                    CTX.setStroke(getSkinnable().getSectionFill9());
                    break;
            }
            CTX.setLineWidth(size * 0.037);
            CTX.setLineCap(StrokeLineCap.BUTT);
            CTX.strokeArc(xy, xy, wh, wh, -(OFFSET + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
            CTX.restore();
        }
    });
}
Also used : Section(eu.hansolo.enzo.common.Section)

Example 4 with Section

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

the class RadialGaugeSkin method drawSections.

private final void drawSections(final GraphicsContext CTX) {
    final double xy = (size - 0.83425 * size) / 2;
    final double wh = size * 0.83425;
    final double MIN_VALUE = getSkinnable().getMinValue();
    final double MAX_VALUE = getSkinnable().getMaxValue();
    final double OFFSET = 90 - getSkinnable().getStartAngle();
    IntStream.range(0, getSkinnable().getSections().size()).parallel().forEachOrdered(i -> {
        final Section SECTION = getSkinnable().getSections().get(i);
        final double SECTION_START_ANGLE;
        if (Double.compare(SECTION.getStart(), MAX_VALUE) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE) >= 0) {
            if (SECTION.getStart() < MIN_VALUE && SECTION.getStop() < MAX_VALUE) {
                SECTION_START_ANGLE = MIN_VALUE * angleStep;
            } else {
                SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE) * angleStep;
            }
            final double SECTION_ANGLE_EXTEND;
            if (SECTION.getStop() > MAX_VALUE) {
                SECTION_ANGLE_EXTEND = (MAX_VALUE - SECTION.getStart()) * angleStep;
            } else {
                SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep;
            }
            CTX.save();
            switch(i) {
                case 0:
                    CTX.setStroke(getSkinnable().getSectionFill0());
                    break;
                case 1:
                    CTX.setStroke(getSkinnable().getSectionFill1());
                    break;
                case 2:
                    CTX.setStroke(getSkinnable().getSectionFill2());
                    break;
                case 3:
                    CTX.setStroke(getSkinnable().getSectionFill3());
                    break;
                case 4:
                    CTX.setStroke(getSkinnable().getSectionFill4());
                    break;
                case 5:
                    CTX.setStroke(getSkinnable().getSectionFill5());
                    break;
                case 6:
                    CTX.setStroke(getSkinnable().getSectionFill6());
                    break;
                case 7:
                    CTX.setStroke(getSkinnable().getSectionFill7());
                    break;
                case 8:
                    CTX.setStroke(getSkinnable().getSectionFill8());
                    break;
                case 9:
                    CTX.setStroke(getSkinnable().getSectionFill9());
                    break;
            }
            CTX.setLineWidth(size * 0.0415);
            CTX.setLineCap(StrokeLineCap.BUTT);
            CTX.strokeArc(xy, xy, wh, wh, -(OFFSET + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
            CTX.restore();
        }
    });
}
Also used : Section(eu.hansolo.enzo.common.Section)

Example 5 with Section

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

the class RadialSkin method drawSections.

private final void drawSections(final GraphicsContext CTX) {
    final double xy = (size - 0.75 * size) / 2;
    final double wh = size * 0.75;
    final double MIN_VALUE = getSkinnable().getMinValue();
    final double MAX_VALUE = getSkinnable().getMaxValue();
    final double OFFSET = 90 - getSkinnable().getStartAngle();
    IntStream.range(0, getSkinnable().getSections().size()).parallel().forEachOrdered(i -> {
        final Section SECTION = getSkinnable().getSections().get(i);
        final double SECTION_START_ANGLE;
        if (Double.compare(SECTION.getStart(), MAX_VALUE) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE) >= 0) {
            if (SECTION.getStart() < MIN_VALUE && SECTION.getStop() < MAX_VALUE) {
                SECTION_START_ANGLE = MIN_VALUE * angleStep;
            } else {
                SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE) * angleStep;
            }
            final double SECTION_ANGLE_EXTEND;
            if (SECTION.getStop() > MAX_VALUE) {
                SECTION_ANGLE_EXTEND = (MAX_VALUE - SECTION.getStart()) * angleStep;
            } else {
                SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep;
            }
            CTX.save();
            switch(i) {
                case 0:
                    CTX.setStroke(getSkinnable().getSectionFill0());
                    break;
                case 1:
                    CTX.setStroke(getSkinnable().getSectionFill1());
                    break;
                case 2:
                    CTX.setStroke(getSkinnable().getSectionFill2());
                    break;
                case 3:
                    CTX.setStroke(getSkinnable().getSectionFill3());
                    break;
                case 4:
                    CTX.setStroke(getSkinnable().getSectionFill4());
                    break;
                case 5:
                    CTX.setStroke(getSkinnable().getSectionFill5());
                    break;
                case 6:
                    CTX.setStroke(getSkinnable().getSectionFill6());
                    break;
                case 7:
                    CTX.setStroke(getSkinnable().getSectionFill7());
                    break;
                case 8:
                    CTX.setStroke(getSkinnable().getSectionFill8());
                    break;
                case 9:
                    CTX.setStroke(getSkinnable().getSectionFill9());
                    break;
            }
            CTX.setLineWidth(size * 0.037);
            CTX.setLineCap(StrokeLineCap.BUTT);
            CTX.strokeArc(xy, xy, wh, wh, -(OFFSET + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
            CTX.restore();
        }
    });
}
Also used : 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