Ejemplo n.º 1
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))));
  }
Ejemplo n.º 2
0
  private void redraw() {
    formatString =
        new StringBuilder("%.")
            .append(Integer.toString(getSkinnable().getDecimals()))
            .append("f")
            .toString();
    tickLabelFormatString =
        new StringBuilder("%.")
            .append(Integer.toString(getSkinnable().getTickLabelDecimals()))
            .append("f")
            .toString();

    // Background stroke and fill
    pane.setBorder(
        new Border(
            new BorderStroke(
                getSkinnable().getBorderPaint(),
                BorderStrokeStyle.SOLID,
                CornerRadii.EMPTY,
                new BorderWidths(
                    Orientation.HORIZONTAL == orientation
                        ? getSkinnable().getBorderWidth() / preferredHeight * height
                        : getSkinnable().getBorderWidth() / preferredWidth * width))));
    pane.setBackground(
        new Background(
            new BackgroundFill(
                getSkinnable().getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    Color barColor = getSkinnable().getBarColor();
    bar.setFill(barColor);
    if (Orientation.VERTICAL == orientation) {
      barHighlight.setFill(
          new LinearGradient(
              barHighlight.getLayoutX(),
              0,
              barHighlight.getLayoutX() + barHighlight.getWidth(),
              0,
              false,
              CycleMethod.NO_CYCLE,
              new Stop(0.0, Color.rgb(255, 255, 255, 0.65)),
              new Stop(0.92, Color.TRANSPARENT),
              new Stop(1.0, Color.rgb(0, 0, 0, 0.2))));
    } else {
      barHighlight.setFill(
          new LinearGradient(
              0,
              barHighlight.getLayoutY(),
              0,
              barHighlight.getLayoutY() + barHighlight.getHeight(),
              false,
              CycleMethod.NO_CYCLE,
              new Stop(0.0, Color.rgb(255, 255, 255, 0.65)),
              new Stop(0.92, Color.TRANSPARENT),
              new Stop(1.0, Color.rgb(0, 0, 0, 0.2))));
    }

    // LED
    if (getSkinnable().isLedVisible()) {
      final Color LED_COLOR = getSkinnable().getLedColor();
      switch (getSkinnable().getLedType()) {
        case FLAT:
          ledFramePaint = Color.WHITE;
          ledOnPaint =
              new LinearGradient(
                  0,
                  0.25 * ledSize,
                  0,
                  0.74 * ledSize,
                  false,
                  CycleMethod.NO_CYCLE,
                  new Stop(0.0, LED_COLOR),
                  new Stop(1.0, LED_COLOR.deriveColor(0d, 1d, 0.5, 1d)));
          ledOffPaint =
              new LinearGradient(
                  0,
                  0.25 * ledSize,
                  0,
                  0.74 * ledSize,
                  false,
                  CycleMethod.NO_CYCLE,
                  new Stop(0.0, LED_COLOR.deriveColor(0d, 1d, 0.5, 1d)),
                  new Stop(1.0, LED_COLOR.deriveColor(0d, 1d, 0.13, 1d)));
          ledHighlightPaint = Color.TRANSPARENT;
          break;
        case STANDARD:
        default:
          ledFramePaint =
              new LinearGradient(
                  0.14 * ledSize,
                  0.14 * ledSize,
                  0.84 * ledSize,
                  0.84 * ledSize,
                  false,
                  CycleMethod.NO_CYCLE,
                  new Stop(0.0, Color.rgb(20, 20, 20, 0.65)),
                  new Stop(0.15, Color.rgb(20, 20, 20, 0.65)),
                  new Stop(0.26, Color.rgb(41, 41, 41, 0.65)),
                  new Stop(0.26, Color.rgb(41, 41, 41, 0.64)),
                  new Stop(0.85, Color.rgb(200, 200, 200, 0.41)),
                  new Stop(1.0, Color.rgb(200, 200, 200, 0.35)));
          ledOnPaint =
              new LinearGradient(
                  0.25 * ledSize,
                  0.25 * ledSize,
                  0.74 * ledSize,
                  0.74 * ledSize,
                  false,
                  CycleMethod.NO_CYCLE,
                  new Stop(0.0, LED_COLOR.deriveColor(0d, 1d, 0.77, 1d)),
                  new Stop(0.49, LED_COLOR.deriveColor(0d, 1d, 0.5, 1d)),
                  new Stop(1.0, LED_COLOR));
          ledOffPaint =
              new LinearGradient(
                  0.25 * ledSize,
                  0.25 * ledSize,
                  0.74 * ledSize,
                  0.74 * ledSize,
                  false,
                  CycleMethod.NO_CYCLE,
                  new Stop(0.0, LED_COLOR.deriveColor(0d, 1d, 0.20, 1d)),
                  new Stop(0.49, LED_COLOR.deriveColor(0d, 1d, 0.13, 1d)),
                  new Stop(1.0, LED_COLOR.deriveColor(0d, 1d, 0.2, 1d)));
          ledHighlightPaint =
              new RadialGradient(
                  0,
                  0,
                  0.3 * ledSize,
                  0.3 * ledSize,
                  0.29 * ledSize,
                  false,
                  CycleMethod.NO_CYCLE,
                  new Stop(0.0, Color.WHITE),
                  new Stop(1.0, Color.TRANSPARENT));
          break;
      }
      drawLed();
    }

    // LCD
    LcdDesign lcdDesign = getSkinnable().getLcdDesign();
    Color[] lcdColors = lcdDesign.getColors();
    if (getSkinnable().isLcdVisible() && getSkinnable().isValueVisible()) {
      LinearGradient lcdGradient =
          new LinearGradient(
              0,
              1,
              0,
              lcd.getHeight() - 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]));
      Paint lcdFramePaint;
      if (LcdDesign.FLAT_CUSTOM == lcdDesign) {
        lcdFramePaint = lcdDesign.lcdForegroundColor;
      } else {
        lcdFramePaint =
            new LinearGradient(
                0,
                0,
                0,
                lcd.getHeight(),
                false,
                CycleMethod.NO_CYCLE,
                new Stop(0.0, Color.rgb(26, 26, 26)),
                new Stop(0.01, Color.rgb(77, 77, 77)),
                new Stop(0.99, Color.rgb(77, 77, 77)),
                new Stop(1.0, Color.rgb(221, 221, 221)));
      }
      lcd.setFill(lcdGradient);
      lcd.setStroke(lcdFramePaint);
    }

    // Text
    titleText.setText(getSkinnable().getTitle());
    titleText.setFill(getSkinnable().getTitleColor());
    unitText.setFill(getSkinnable().getUnitColor());
    unitText.setText(getSkinnable().getUnit());
    valueText.setFill(
        getSkinnable().isLcdVisible() ? lcdColors[5] : getSkinnable().getValueColor());
    resizeText();
  }