Example #1
0
 private void setBarColor(final double VALUE) {
   if (!sectionsVisible && !colorGradientEnabled) {
     bar.setStroke(barColor);
   } else if (colorGradientEnabled && noOfGradientStops > 1) {
     bar.setStroke(getSkinnable().getGradientLookup().getColorAt((VALUE - minValue) / range));
   } else {
     bar.setStroke(barColor);
     for (Section section : sections) {
       if (section.contains(VALUE)) {
         bar.setStroke(section.getColor());
         break;
       }
     }
   }
 }
Example #2
0
 private void handleEvents(final String EVENT_TYPE) {
   if ("RESIZE".equals(EVENT_TYPE)) {
     resize();
     redraw();
   } else if ("REDRAW".equals(EVENT_TYPE)) {
     redraw();
   } else if ("RECALC".equals(EVENT_TYPE)) {
     angleRange = Helper.clamp(90.0, 180.0, getSkinnable().getAngleRange());
     startAngle = getStartAngle();
     minValue = getSkinnable().getMinValue();
     range = getSkinnable().getRange();
     sections = getSkinnable().getSections();
     angleStep = angleRange / range;
     redraw();
   } else if ("FINISHED".equals(EVENT_TYPE)) {
     needleTooltip.setText(String.format(locale, formatString, getSkinnable().getValue()));
     double value = getSkinnable().getValue();
     if (getSkinnable().isValueVisible()) {
       Bounds bounds = pane.localToScreen(pane.getBoundsInLocal());
       double xFactor = value > getSkinnable().getRange() * 0.8 ? 0.0 : 0.25;
       double tooltipAngle = value * angleStep;
       double sinValue = Math.sin(Math.toRadians(180 + angleRange * 0.5 - tooltipAngle));
       double cosValue = Math.cos(Math.toRadians(180 + angleRange * 0.5 - tooltipAngle));
       double needleTipX =
           bounds.getMinX() + bounds.getWidth() * 0.5 + bounds.getHeight() * sinValue;
       double needleTipY =
           bounds.getMinY() + bounds.getHeight() * 0.72 + bounds.getHeight() * cosValue;
       needleTooltip.show(needle, needleTipX, needleTipY);
       needleTooltip.setAnchorX(needleTooltip.getX() - needleTooltip.getWidth() * xFactor);
     }
     if (sections.isEmpty() || sectionsAlwaysVisible) return;
     for (Section section : sections) {
       if (section.contains(value)) {
         barTooltip.setText(section.getText());
         break;
       }
     }
   } else if ("VISIBILITY".equals(EVENT_TYPE)) {
     Helper.enableNode(titleText, !getSkinnable().getTitle().isEmpty());
   }
 }
Example #3
0
 private void setBarColor(final double VALUE) {
   if (!getSkinnable().getAreasVisible() && !getSkinnable().isGradientBarEnabled()) {
     bar.setFill(getSkinnable().getBarColor());
   } else if (getSkinnable().isGradientBarEnabled()
       && getSkinnable().getGradientBarStops().size() > 1) {
     bar.setFill(
         getSkinnable()
             .getGradientLookup()
             .getColorAt((VALUE - getSkinnable().getMinValue()) / getSkinnable().getRange()));
   } else {
     bar.setFill(getSkinnable().getBarColor());
     int listSize = areas.size();
     for (int i = 0; i < listSize; i++) {
       Section area = areas.get(i);
       if (area.contains(VALUE)) {
         bar.setFill(area.getColor());
         break;
       }
     }
   }
 }
Example #4
0
 private void drawSections(final GraphicsContext CTX) {
   if (sections.isEmpty()) return;
   int listSize = sections.size();
   double minValue = getSkinnable().getMinValue();
   double minPosition;
   CTX.save();
   if (Orientation.VERTICAL == orientation) {
     minPosition =
         barBackground.getLayoutY() + barBackground.getLayoutBounds().getHeight() - size * 0.0035;
     double anchorX = barBackground.getLayoutX() - 0.079 * width;
     double sectionHeight;
     for (int i = 0; i < listSize; i++) {
       Section section = sections.get(i);
       sectionHeight = (section.getStop() - section.getStart()) * stepSize;
       CTX.setFill(section.getColor());
       CTX.fillRect(
           anchorX,
           minPosition - sectionHeight - (section.getStart() - minValue) * stepSize,
           0.057 * width,
           sectionHeight);
     }
   } else {
     minPosition = barBackground.getLayoutX();
     double anchorY = barBackground.getLayoutY() + barBackground.getHeight() + 0.021 * height;
     double sectionWidth;
     for (int i = 0; i < listSize; i++) {
       Section section = sections.get(i);
       sectionWidth = (section.getStop() - section.getStart()) * stepSize;
       CTX.setFill(section.getColor());
       CTX.fillRect(
           minPosition + (section.getStart() - minValue) * stepSize,
           anchorY,
           sectionWidth,
           0.059 * height);
     }
   }
   CTX.restore();
 }
Example #5
0
  private void drawSections() {
    if (sections.isEmpty()) return;
    sectionLayer.getChildren().clear();

    double centerX = width * 0.5;
    double centerY = height * 0.85;
    double barRadius = height * 0.54210526;
    double barWidth = width * 0.28472222;

    for (Section section : sections) {
      Arc sectionBar =
          new Arc(
              centerX,
              centerY,
              barRadius,
              barRadius,
              angleRange * 0.5 + 90 - (section.getStart() * angleStep),
              -((section.getStop() - section.getStart()) - minValue) * angleStep);
      sectionBar.setType(ArcType.OPEN);
      sectionBar.setStroke(section.getColor());
      sectionBar.setStrokeWidth(barWidth);
      sectionBar.setStrokeLineCap(StrokeLineCap.BUTT);
      sectionBar.setFill(null);
      Tooltip sectionTooltip =
          new Tooltip(
              new StringBuilder(section.getText())
                  .append("\n")
                  .append(String.format(Locale.US, "%.2f", section.getStart()))
                  .append(" - ")
                  .append(String.format(Locale.US, "%.2f", section.getStop()))
                  .toString());
      sectionTooltip.setTextAlignment(TextAlignment.CENTER);
      Tooltip.install(sectionBar, sectionTooltip);
      sectionLayer.getChildren().add(sectionBar);
    }
  }
Example #6
0
  private void updateLcdDesign(final double HEIGHT) {
    LcdDesign lcdDesign = getSkinnable().getLcdDesign();
    Color[] lcdColors = lcdDesign.getColors();

    if (LcdDesign.SECTIONS == lcdDesign) {
      double currentValue = getSkinnable().getCurrentValue();
      int listSize = sections.size();
      for (int i = 0; i < listSize; i++) {
        Section section = sections.get(i);
        if (section.contains(currentValue)) {
          lcdColors = sectionColorMap.get(section);
          break;
        }
      }
    }

    lcdPaint =
        new LinearGradient(
            0,
            1,
            0,
            HEIGHT - 1,
            false,
            CycleMethod.NO_CYCLE,
            new Stop(0, lcdColors[0]),
            new Stop(0.03, lcdColors[1]),
            new Stop(0.5, lcdColors[2]),
            new Stop(0.5, lcdColors[3]),
            new Stop(1.0, lcdColors[4]));
    if (lcdDesign.name().startsWith("FLAT")) {
      lcdFramePaint = getSkinnable().getBorderPaint();

      lcdPaint = getSkinnable().getBackgroundPaint();

      Color lcdForegroundColor = (Color) getSkinnable().getForegroundPaint();
      backgroundText.setFill(
          Color.color(
              lcdForegroundColor.getRed(),
              lcdForegroundColor.getGreen(),
              lcdForegroundColor.getBlue(),
              0.1));
      valueText.setFill(lcdForegroundColor);
      upperLeftText.setFill(lcdForegroundColor);
      title.setFill(lcdForegroundColor);
      upperRightText.setFill(lcdForegroundColor);
      unitText.setFill(lcdForegroundColor);
      lowerRightText.setFill(lcdForegroundColor);
      lowerCenterText.setFill(lcdForegroundColor);
      threshold.setFill(lcdForegroundColor);
    } else {
      lcdFramePaint =
          new LinearGradient(
              0,
              0.02083333 * height,
              0,
              HEIGHT - 0.02083333 * HEIGHT,
              false,
              CycleMethod.NO_CYCLE,
              new Stop(0.0, Color.rgb(26, 26, 26)),
              new Stop(0.015, Color.rgb(77, 77, 77)),
              new Stop(0.985, Color.rgb(77, 77, 77)),
              new Stop(1.0, Color.rgb(221, 221, 221)));

      lcdPaint =
          new LinearGradient(
              0,
              1,
              0,
              HEIGHT - 1,
              false,
              CycleMethod.NO_CYCLE,
              new Stop(0, lcdColors[0]),
              new Stop(0.03, lcdColors[1]),
              new Stop(0.5, lcdColors[2]),
              new Stop(0.5, lcdColors[3]),
              new Stop(1.0, lcdColors[4]));

      backgroundText.setFill(lcdDesign.lcdBackgroundColor);
      valueText.setFill(lcdDesign.lcdForegroundColor);
      upperLeftText.setFill(lcdDesign.lcdForegroundColor);
      title.setFill(lcdDesign.lcdForegroundColor);
      upperRightText.setFill(lcdDesign.lcdForegroundColor);
      unitText.setFill(lcdDesign.lcdForegroundColor);
      lowerRightText.setFill(lcdDesign.lcdForegroundColor);
      lowerCenterText.setFill(lcdDesign.lcdForegroundColor);
      threshold.setFill(lcdDesign.lcdForegroundColor);
    }

    pane.setBackground(
        new Background(
            new BackgroundFill(lcdPaint, new CornerRadii(0.10416667 * HEIGHT), Insets.EMPTY)));
    pane.setBorder(
        new Border(
            new BorderStroke(
                lcdFramePaint,
                BorderStrokeStyle.SOLID,
                new CornerRadii(0.05 * HEIGHT),
                new BorderWidths(0.02083333 * HEIGHT))));
  }