use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class DemoSimpleLineChart method init.
@Override
public void init() {
XYChart.Series series = new XYChart.Series();
series.setName("temperature");
series.getData().add(new XYChart.Data("7:00", 27.3));
series.getData().add(new XYChart.Data("8:00", 28.2));
series.getData().add(new XYChart.Data("9:00", 28.5));
series.getData().add(new XYChart.Data("10:00", 29.2));
series.getData().add(new XYChart.Data("11:00", 29.6));
series.getData().add(new XYChart.Data("12:00", 31.5));
series.getData().add(new XYChart.Data("13:00", 32.0));
series.getData().add(new XYChart.Data("14:00", 31.2));
series.getData().add(new XYChart.Data("15:00", 30.2));
series.getData().add(new XYChart.Data("16:00", 29.68));
series.getData().add(new XYChart.Data("17:00", 30.05));
series.getData().add(new XYChart.Data("18:00", 31.25));
chart = new SimpleLineChart();
chart.setSections(new Section[] { new Section(0, 10), new Section(10, 15), new Section(15, 25), new Section(25, 30), new Section(30, 40) });
chart.getStyleClass().addAll(SimpleLineChart.STYLE_CLASS_BLUE_TO_RED_5);
chart.setSectionRangeVisible(true);
chart.setUnit("°C");
chart.setSeries(series);
}
use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class SimpleLineChartBuilder method build.
public final SimpleLineChart build() {
final SimpleLineChart CONTROL = new SimpleLineChart();
for (String key : properties.keySet()) {
if ("prefSize".equals(key)) {
Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
CONTROL.setPrefSize(dim.getWidth(), dim.getHeight());
} else if ("minSize".equals(key)) {
Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
CONTROL.setPrefSize(dim.getWidth(), dim.getHeight());
} else if ("maxSize".equals(key)) {
Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
CONTROL.setPrefSize(dim.getWidth(), dim.getHeight());
} else if ("prefWidth".equals(key)) {
CONTROL.setPrefWidth(((DoubleProperty) properties.get(key)).get());
} else if ("prefHeight".equals(key)) {
CONTROL.setPrefHeight(((DoubleProperty) properties.get(key)).get());
} else if ("minWidth".equals(key)) {
CONTROL.setMinWidth(((DoubleProperty) properties.get(key)).get());
} else if ("minHeight".equals(key)) {
CONTROL.setMinHeight(((DoubleProperty) properties.get(key)).get());
} else if ("maxWidth".equals(key)) {
CONTROL.setMaxWidth(((DoubleProperty) properties.get(key)).get());
} else if ("maxHeight".equals(key)) {
CONTROL.setMaxHeight(((DoubleProperty) properties.get(key)).get());
} else if ("scaleX".equals(key)) {
CONTROL.setScaleX(((DoubleProperty) properties.get(key)).get());
} else if ("scaleY".equals(key)) {
CONTROL.setScaleY(((DoubleProperty) properties.get(key)).get());
} else if ("layoutX".equals(key)) {
CONTROL.setLayoutX(((DoubleProperty) properties.get(key)).get());
} else if ("layoutY".equals(key)) {
CONTROL.setLayoutY(((DoubleProperty) properties.get(key)).get());
} else if ("translateX".equals(key)) {
CONTROL.setTranslateX(((DoubleProperty) properties.get(key)).get());
} else if ("translateY".equals(key)) {
CONTROL.setTranslateY(((DoubleProperty) properties.get(key)).get());
} else if ("styleClass".equals(key)) {
CONTROL.getStyleClass().setAll("simple-line-chart", ((StringProperty) properties.get(key)).get());
} else if ("series".equals(key)) {
CONTROL.setSeries(((ObjectProperty<XYChart.Series>) properties.get(key)).get());
} else if ("sectionRangeVisible".equals(key)) {
CONTROL.setSectionRangeVisible(((BooleanProperty) properties.get(key)).get());
} else if ("sectionsArray".equals(key)) {
CONTROL.setSections(((ObjectProperty<Section[]>) properties.get(key)).get());
} else if ("sectionsList".equals(key)) {
CONTROL.setSections(((ObjectProperty<List<Section>>) properties.get(key)).get());
}
}
return CONTROL;
}
use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class SimpleLineChartSkin method drawBackground.
private void drawBackground() {
ctxBkg.clearRect(0, 0, width, height);
sectionMinimum = Double.MAX_VALUE;
sectionMaximum = -Double.MAX_VALUE;
double lowestSection = Double.MAX_VALUE;
for (Section section : getSkinnable().getSections()) {
sectionMinimum = Math.min(sectionMinimum, section.getStart());
sectionMaximum = Math.max(sectionMaximum, section.getStop());
lowestSection = Math.min(lowestSection, Math.abs(section.getStop() - section.getStart()));
}
ctxBkg.setStroke(Color.BLACK);
ctxBkg.strokeRect(0, 0, width, height);
heightFactor = height / (sectionMaximum - sectionMinimum);
ctxBkg.save();
ctxBkg.translate(0, sectionMinimum * heightFactor);
ctxBkg.setFont(Fonts.robotoRegular(lowestSection * 0.8 * heightFactor));
IntStream.range(0, getSkinnable().getSections().size()).forEach(i -> {
final Section SECTION = getSkinnable().getSections().get(i);
ctxBkg.save();
switch(i) {
case 0:
ctxBkg.setFill(getSkinnable().getSectionFill0());
break;
case 1:
ctxBkg.setFill(getSkinnable().getSectionFill1());
break;
case 2:
ctxBkg.setFill(getSkinnable().getSectionFill2());
break;
case 3:
ctxBkg.setFill(getSkinnable().getSectionFill3());
break;
case 4:
ctxBkg.setFill(getSkinnable().getSectionFill4());
break;
case 5:
ctxBkg.setFill(getSkinnable().getSectionFill5());
break;
case 6:
ctxBkg.setFill(getSkinnable().getSectionFill6());
break;
case 7:
ctxBkg.setFill(getSkinnable().getSectionFill7());
break;
case 8:
ctxBkg.setFill(getSkinnable().getSectionFill8());
break;
case 9:
ctxBkg.setFill(getSkinnable().getSectionFill9());
break;
}
ctxBkg.fillRect(0, height - SECTION.getStop() * heightFactor, width, Math.abs(SECTION.getStop() - SECTION.getStart()) * heightFactor);
ctxBkg.restore();
});
if (getSkinnable().isSectionRangeVisible()) {
IntStream.range(0, getSkinnable().getSections().size()).forEach(i -> {
final Section SECTION = getSkinnable().getSections().get(i);
ctxBkg.setFill(getSkinnable().getSeriesStroke());
ctxBkg.setTextBaseline(VPos.CENTER);
ctxBkg.fillText(SECTION.getStop() + getSkinnable().getUnit(), 0.02 * height, height - SECTION.getStop() * heightFactor);
});
}
ctxBkg.restore();
}
use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class VuMeterSkin method handleControlPropertyChanged.
// ******************** Methods *******************************************
protected void handleControlPropertyChanged(final String PROPERTY) {
if ("RESIZE".equals(PROPERTY)) {
resize();
} else if ("STYLE".equals(PROPERTY)) {
resize();
} else if ("VALUE".equals(PROPERTY)) {
int currentLedPeakIndex;
if (Orientation.HORIZONTAL == getSkinnable().getOrientation()) {
// HORIZONTAL
currentLedPeakIndex = 0;
for (int i = 0; i < leds.size(); i++) {
leds.get(i).getStyleClass().remove("led-on");
if (Double.compare(i * stepSize.doubleValue(), getSkinnable().getValue()) <= 0) {
leds.get(i).getStyleClass().add("led-on");
currentLedPeakIndex = i;
}
}
if (getSkinnable().isPeakValueVisible()) {
if (currentLedPeakIndex > peakLedIndex) {
timer.stop();
leds.get(peakLedIndex).getStyleClass().remove("led-peak");
leds.get(currentLedPeakIndex).getStyleClass().add("led-peak");
peakLedIndex = currentLedPeakIndex;
lastTimerCall = System.nanoTime();
timer.start();
}
}
} else {
// VERTICAL
currentLedPeakIndex = leds.size() - 1;
for (int i = 0; i < leds.size(); i++) {
if (i != peakLedIndex)
leds.get(i).getStyleClass().remove("led-on");
if (Double.compare((leds.size() - i - 1) * stepSize.doubleValue(), getSkinnable().getValue()) <= 0) {
leds.get(i).getStyleClass().add("led-on");
} else {
currentLedPeakIndex = i;
}
}
if (getSkinnable().isPeakValueVisible()) {
if (currentLedPeakIndex < peakLedIndex) {
timer.stop();
leds.get(peakLedIndex).getStyleClass().remove("led-peak");
leds.get(currentLedPeakIndex).getStyleClass().add("led-peak");
peakLedIndex = currentLedPeakIndex;
lastTimerCall = System.nanoTime();
timer.start();
}
}
}
} else if ("ORIENTATION".equals(PROPERTY)) {
hBox.getChildren().clear();
vBox.getChildren().clear();
if (Orientation.HORIZONTAL == getSkinnable().getOrientation()) {
vBox.setManaged(false);
vBox.setVisible(false);
hBox.getChildren().setAll(leds);
} else {
hBox.setManaged(false);
hBox.setVisible(false);
vBox.getChildren().setAll(leds);
}
} else if ("NO_OF_LEDS".equals(PROPERTY)) {
leds.clear();
hBox.getChildren().clear();
vBox.getChildren().clear();
for (int i = 0; i < getSkinnable().getNoOfLeds(); i++) {
Region led = new Region();
led.setPrefSize(10, 20);
if (getSkinnable().getSections().isEmpty()) {
led.getStyleClass().setAll("led");
} else {
for (Section section : getSkinnable().getSections()) {
if (section.contains(i * stepSize.doubleValue())) {
led.getStyleClass().setAll("led", section.getStyleClass());
}
}
}
leds.add(led);
}
if (Orientation.HORIZONTAL == getSkinnable().getOrientation()) {
hBox.getChildren().setAll(leds);
} else {
vBox.getChildren().setAll(leds);
}
} else if ("SECTIONS".equals(PROPERTY)) {
for (int i = 0; i < getSkinnable().getNoOfLeds(); i++) {
Region led = new Region();
led.setPrefSize(10, 20);
if (getSkinnable().getSections().isEmpty()) {
led.getStyleClass().setAll("led");
} else {
for (Section section : getSkinnable().getSections()) {
if (section.contains(i * stepSize.doubleValue())) {
led.getStyleClass().setAll("led", section.getStyleClass());
}
}
}
leds.add(led);
}
}
}
use of eu.hansolo.enzo.common.Section in project Board-Instrumentation-Framework by intel.
the class DoubleRadialGaugeSkin 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_ONE = getSkinnable().getMinValueOne();
final double MAX_VALUE_ONE = getSkinnable().getMaxValueOne();
final double OFFSET_ONE = 90 - getSkinnable().getStartAngleOne();
IntStream.range(0, getSkinnable().getAreasOne().size()).parallel().forEachOrdered(i -> {
final Section AREA = getSkinnable().getAreasOne().get(i);
final double AREA_START_ANGLE;
if (Double.compare(AREA.getStart(), MAX_VALUE_ONE) <= 0 && Double.compare(AREA.getStop(), MIN_VALUE_ONE) >= 0) {
if (AREA.getStart() < MIN_VALUE_ONE && AREA.getStop() < MAX_VALUE_ONE) {
AREA_START_ANGLE = MIN_VALUE_ONE * angleStepOne;
} else {
AREA_START_ANGLE = (AREA.getStart() - MIN_VALUE_ONE) * angleStepOne;
}
final double AREA_ANGLE_EXTEND;
if (AREA.getStop() > MAX_VALUE_ONE) {
AREA_ANGLE_EXTEND = (MAX_VALUE_ONE - AREA.getStart()) * angleStepOne;
} else {
AREA_ANGLE_EXTEND = (AREA.getStop() - AREA.getStart()) * angleStepOne;
}
CTX.save();
switch(i) {
case 0:
CTX.setFill(getSkinnable().getAreaFill0One());
break;
case 1:
CTX.setFill(getSkinnable().getAreaFill1One());
break;
case 2:
CTX.setFill(getSkinnable().getAreaFill2One());
break;
case 3:
CTX.setFill(getSkinnable().getAreaFill3One());
break;
case 4:
CTX.setFill(getSkinnable().getAreaFill4One());
break;
}
CTX.fillArc(xy, xy, wh, wh, -(OFFSET_ONE + AREA_START_ANGLE), -AREA_ANGLE_EXTEND, ArcType.ROUND);
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().getAreasTwo().size()).parallel().forEachOrdered(i -> {
final Section AREA = getSkinnable().getAreasTwo().get(i);
final double AREA_START_ANGLE;
if (Double.compare(AREA.getStart(), MAX_VALUE_TWO) <= 0 && Double.compare(AREA.getStop(), MIN_VALUE_TWO) >= 0) {
if (AREA.getStart() < MIN_VALUE_TWO && AREA.getStop() < MAX_VALUE_TWO) {
AREA_START_ANGLE = MIN_VALUE_TWO * angleStepTwo;
} else {
AREA_START_ANGLE = (AREA.getStart() - MIN_VALUE_TWO) * angleStepTwo;
}
final double AREA_ANGLE_EXTEND;
if (AREA.getStop() > MAX_VALUE_TWO) {
AREA_ANGLE_EXTEND = (MAX_VALUE_TWO - AREA.getStart()) * angleStepTwo;
} else {
AREA_ANGLE_EXTEND = (AREA.getStop() - AREA.getStart()) * angleStepTwo;
}
CTX.save();
switch(i) {
case 0:
CTX.setFill(getSkinnable().getAreaFill0Two());
break;
case 1:
CTX.setFill(getSkinnable().getAreaFill1Two());
break;
case 2:
CTX.setFill(getSkinnable().getAreaFill2Two());
break;
case 3:
CTX.setFill(getSkinnable().getAreaFill3Two());
break;
case 4:
CTX.setFill(getSkinnable().getAreaFill4Two());
break;
}
CTX.fillArc(xy, xy, wh, wh, -(OFFSET_TWO + AREA_START_ANGLE), -AREA_ANGLE_EXTEND, ArcType.ROUND);
CTX.restore();
}
});
}
Aggregations