Esempio n. 1
0
 // REMOVE ME
 public static Node createIconContent() {
   Path path = new Path();
   path.getElements()
       .addAll(new MoveTo(25, 25), new HLineTo(45), new ArcTo(20, 20, 0, 80, 25, true, true));
   path.setStroke(Color.web("#b9c0c5"));
   path.setStrokeWidth(5);
   path.getStrokeDashArray().addAll(15d, 15d);
   path.setFill(null);
   javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
   effect.setOffsetX(1);
   effect.setOffsetY(1);
   effect.setRadius(3);
   effect.setColor(Color.rgb(0, 0, 0, 0.6));
   path.setEffect(effect);
   return path;
 }
Esempio n. 2
0
  public VBox drawSlot(int width, int height, Color color) {

    VBox box = new VBox();
    box.setEffect(new DropShadow());

    Rectangle rect = new Rectangle();

    // Size
    rect.setWidth(50);
    rect.setHeight(50);

    // Properties
    rect.setFill(color);
    rect.setOpacity(1.0);

    box.getChildren().add(rect);

    box.setOnMouseEntered(
        event -> {
          InnerShadow is = new InnerShadow();
          is.setChoke(1.0);
          is.setRadius(5);
          is.setColor(Color.BLACK);

          // ((VBox)event.getSource()).setEffect(is);
          ((Rectangle) ((VBox) event.getSource()).getChildren().get(0)).setEffect(is);
        });

    box.setOnMouseExited(
        event -> {
          // ((VBox)event.getSource()).setEffect(null);
          ((Rectangle) ((VBox) event.getSource()).getChildren().get(0)).setEffect(null);
        });

    return box;
  }
Esempio n. 3
0
  private void resize() {
    width =
        getSkinnable().getWidth()
            - getSkinnable().getInsets().getLeft()
            - getSkinnable().getInsets().getRight();
    height =
        getSkinnable().getHeight()
            - getSkinnable().getInsets().getTop()
            - getSkinnable().getInsets().getBottom();

    if (aspectRatio * width > height) {
      width = 1 / (aspectRatio / height);
    } else if (1 / (aspectRatio / height) > width) {
      height = aspectRatio * width;
    }

    if (width > 0 && height > 0) {
      pane.setMaxSize(width, height);
      pane.relocate(
          (getSkinnable().getWidth() - width) * 0.5, (getSkinnable().getHeight() - height) * 0.5);

      updateLcdDesign(height);

      mainInnerShadow0.setRadius(0.0625 * height);
      mainInnerShadow1.setRadius(0.04166667 * height);

      if (crystalOverlay.isVisible()) {
        crystalClip.setWidth(width);
        crystalClip.setHeight(height);
        crystalOverlay.setImage(
            Helper.createNoiseImage(width, height, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8));
        crystalOverlay.setCache(true);
      }

      double tSize = 0.2 * height;
      threshold.getElements().clear();
      threshold.getElements().add(new MoveTo(0.41666667 * tSize, 0.75 * tSize));
      threshold.getElements().add(new LineTo(0.583333333333333 * tSize, 0.75 * tSize));
      threshold.getElements().add(new LineTo(0.583333333333333 * tSize, 0.916666666666667 * tSize));
      threshold.getElements().add(new LineTo(0.416666666666667 * tSize, 0.916666666666667 * tSize));
      threshold.getElements().add(new LineTo(0.416666666666667 * tSize, 0.75 * tSize));
      threshold.getElements().add(new ClosePath());
      threshold.getElements().add(new MoveTo(0.416666666666667 * tSize, 0.333333333333333 * tSize));
      threshold.getElements().add(new LineTo(0.583333333333333 * tSize, 0.333333333333333 * tSize));
      threshold.getElements().add(new LineTo(0.583333333333333 * tSize, 0.666666666666667 * tSize));
      threshold.getElements().add(new LineTo(0.416666666666667 * tSize, 0.666666666666667 * tSize));
      threshold.getElements().add(new LineTo(0.416666666666667 * tSize, 0.333333333333333 * tSize));
      threshold.getElements().add(new ClosePath());
      threshold.getElements().add(new MoveTo(tSize, tSize));
      threshold.getElements().add(new LineTo(0.5 * tSize, 0));
      threshold.getElements().add(new LineTo(0, tSize));
      threshold.getElements().add(new LineTo(tSize, tSize));
      threshold.getElements().add(new ClosePath());
      threshold.relocate(0.027961994662429348 * width, 0.75 * height - 2);

      updateFonts();

      // Setup the lcd unit
      unitText.setFont(unitFont);
      unitText.setTextOrigin(VPos.BASELINE);
      unitText.setTextAlignment(TextAlignment.RIGHT);

      unitText.setText(getSkinnable().getUnit());
      if (unitText.visibleProperty().isBound()) {
        unitText.visibleProperty().unbind();
      }

      valueOffsetLeft = height * 0.04;

      if (getSkinnable().getUnit().isEmpty()) {
        valueOffsetRight = height * 0.0833333333;
        valueText.setX((width - valueText.getLayoutBounds().getWidth()) - valueOffsetRight);
      } else {
        unitText.setX((width - unitText.getLayoutBounds().getWidth()) - height * 0.04);
        unitText.setY(
            height - (valueText.getLayoutBounds().getHeight() * digitalFontSizeFactor) * 0.5);
        valueOffsetRight =
            (unitText.getLayoutBounds().getWidth()
                + height * 0.0833333333); // distance between value and unit
        valueText.setX(width - 2 - valueText.getLayoutBounds().getWidth() - valueOffsetRight);
      }
      valueText.setY(
          height - (valueText.getLayoutBounds().getHeight() * digitalFontSizeFactor) * 0.5);

      // Visualize the lcd semitransparent background text
      updateBackgroundText();

      if (getSkinnable().getUnit().isEmpty()) {
        backgroundText.setX(
            (width - backgroundText.getLayoutBounds().getWidth()) - valueOffsetRight);
      } else {
        backgroundText.setX(
            width - 2 - backgroundText.getLayoutBounds().getWidth() - valueOffsetRight);
      }
      backgroundText.setY(
          height - (backgroundText.getLayoutBounds().getHeight() * digitalFontSizeFactor) * 0.5);

      // Setup the font for the lcd title, number system, min measured, max measure and former value
      // Title
      title.setFont(titleFont);
      title.setTextOrigin(VPos.BASELINE);
      title.setTextAlignment(TextAlignment.CENTER);
      title.setText(getSkinnable().getTitle());
      title.setX((width - title.getLayoutBounds().getWidth()) * 0.5);
      title.setY(
          pane.getLayoutBounds().getMinY()
              + title.getLayoutBounds().getHeight()
              - 0.04 * height
              + 4);

      // Info Text
      lowerRightText.setFont(smallFont);
      lowerRightText.setTextOrigin(VPos.BASELINE);
      lowerRightText.setTextAlignment(TextAlignment.RIGHT);
      lowerRightText.setText(getSkinnable().getSubTitle());
      lowerRightText.setX(
          pane.getLayoutBounds().getMinX()
              + (pane.getLayoutBounds().getWidth() - lowerRightText.getLayoutBounds().getWidth())
                  * 0.5);
      lowerRightText.setY(pane.getLayoutBounds().getMinY() + height - 4 - 0.0416666667 * height);

      // Min measured value
      upperLeftText.setFont(smallFont);
      upperLeftText.setTextOrigin(VPos.BASELINE);
      upperLeftText.setTextAlignment(TextAlignment.RIGHT);
      upperLeftText.setX(pane.getLayoutBounds().getMinX() + 0.0416666667 * height);
      upperLeftText.setY(
          pane.getLayoutBounds().getMinY()
              + upperLeftText.getLayoutBounds().getHeight()
              - 0.04 * height
              + 4);

      // Max measured value
      upperRightText.setFont(smallFont);
      upperRightText.setTextOrigin(VPos.BASELINE);
      upperRightText.setTextAlignment(TextAlignment.RIGHT);
      upperRightText.setY(
          pane.getLayoutBounds().getMinY()
              + upperRightText.getLayoutBounds().getHeight()
              - 0.04 * height
              + 4);

      // Former value
      lowerCenterText.setFont(smallFont);
      lowerCenterText.setTextOrigin(VPos.BASELINE);
      lowerCenterText.setTextAlignment(TextAlignment.CENTER);
      lowerCenterText.setX((width - lowerCenterText.getLayoutBounds().getWidth()) * 0.5);
      lowerCenterText.setY(pane.getLayoutBounds().getMinY() + height - 4 - 0.0416666667 * height);
    }
  }
Esempio n. 4
0
  private void initGraphics() {
    mainInnerShadow0 = new InnerShadow();
    mainInnerShadow0.setOffsetX(0.0);
    mainInnerShadow0.setOffsetY(0.0);
    mainInnerShadow0.setRadius(0.0625 * PREFERRED_HEIGHT);
    mainInnerShadow0.setColor(Color.rgb(255, 255, 255, 0.5));
    mainInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);

    mainInnerShadow1 = new InnerShadow();
    mainInnerShadow1.setOffsetX(0.0);
    mainInnerShadow1.setOffsetY(1.0);
    mainInnerShadow1.setRadius(0.04166667 * PREFERRED_HEIGHT);
    mainInnerShadow1.setColor(Color.rgb(0, 0, 0, 0.65));
    mainInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    mainInnerShadow1.setInput(mainInnerShadow0);

    crystalClip = new Rectangle(0, 0, width, height);
    crystalClip.setArcWidth(5);
    crystalClip.setArcHeight(5);

    crystalImage =
        Helper.createNoiseImage(
            PREFERRED_WIDTH, PREFERRED_HEIGHT, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8);
    crystalOverlay = new ImageView(crystalImage);
    crystalOverlay.setClip(crystalClip);
    boolean crystalEnabled = getSkinnable().isLcdCrystalEnabled();
    crystalOverlay.setManaged(crystalEnabled);
    crystalOverlay.setVisible(crystalEnabled);

    threshold = new Path();
    threshold.setManaged(getSkinnable().isThresholdVisible());
    threshold.setVisible(getSkinnable().isThresholdVisible());
    threshold.setStroke(null);

    backgroundText =
        new Text(String.format(Locale.US, valueFormatString, getSkinnable().getCurrentValue()));
    backgroundText.setFill(getSkinnable().getLcdDesign().lcdBackgroundColor);
    backgroundText.setOpacity(
        (LcdFont.LCD == getSkinnable().getLcdFont()
                || LcdFont.ELEKTRA == getSkinnable().getLcdFont())
            ? 1
            : 0);

    valueText =
        new Text(String.format(Locale.US, valueFormatString, getSkinnable().getCurrentValue()));
    valueText.setFill(getSkinnable().getLcdDesign().lcdForegroundColor);

    unitText = new Text(getSkinnable().getUnit());
    unitText.setFill(getSkinnable().getLcdDesign().lcdForegroundColor);
    unitText.setManaged(!getSkinnable().getUnit().isEmpty());
    unitText.setVisible(!getSkinnable().getUnit().isEmpty());

    title = new Text(getSkinnable().getTitle());
    title.setFill(getSkinnable().getLcdDesign().lcdForegroundColor);
    title.setManaged(!getSkinnable().getTitle().isEmpty());
    title.setVisible(!getSkinnable().getTitle().isEmpty());

    lowerRightText = new Text(getSkinnable().getSubTitle());
    lowerRightText.setFill(getSkinnable().getLcdDesign().lcdForegroundColor);
    lowerRightText.setManaged(!getSkinnable().getSubTitle().isEmpty());
    lowerRightText.setVisible(!getSkinnable().getSubTitle().isEmpty());

    upperLeftText =
        new Text(String.format(Locale.US, otherFormatString, getSkinnable().getMinMeasuredValue()));
    upperLeftText.setFill(getSkinnable().getLcdDesign().lcdForegroundColor);
    upperLeftText.setManaged(getSkinnable().isMinMeasuredValueVisible());
    upperLeftText.setVisible(getSkinnable().isMinMeasuredValueVisible());

    upperRightText =
        new Text(String.format(Locale.US, otherFormatString, getSkinnable().getMaxMeasuredValue()));
    upperRightText.setFill(getSkinnable().getLcdDesign().lcdForegroundColor);
    upperRightText.setManaged(getSkinnable().isMaxMeasuredValueVisible());
    upperRightText.setVisible(getSkinnable().isMaxMeasuredValueVisible());

    lowerCenterText =
        new Text(String.format(Locale.US, otherFormatString, getSkinnable().getOldValue()));
    lowerCenterText.setFill(getSkinnable().getLcdDesign().lcdForegroundColor);
    lowerCenterText.setManaged(getSkinnable().isOldValueVisible());
    lowerCenterText.setVisible(getSkinnable().isOldValueVisible());

    shadowGroup = new Group();
    shadowGroup.setEffect(getSkinnable().isShadowsEnabled() ? FOREGROUND_SHADOW : null);
    shadowGroup
        .getChildren()
        .setAll(
            threshold,
            valueText,
            unitText,
            title,
            lowerRightText,
            upperLeftText,
            upperRightText,
            lowerCenterText);

    pane = new Pane(crystalOverlay, backgroundText, shadowGroup);
    pane.setEffect(getSkinnable().isShadowsEnabled() ? mainInnerShadow1 : null);
    getChildren().setAll(pane);
  }
Esempio n. 5
0
  // ******************** Drawing related ***********************************
  public final void drawLed() {
    final double SIZE =
        control.getPrefWidth() < control.getPrefHeight()
            ? control.getPrefWidth()
            : control.getPrefHeight();
    final double WIDTH = SIZE;
    final double HEIGHT = SIZE;

    led.setStyle("-fx-led: " + Util.colorToCssColor(control.getColor()));

    final Shape IBOUNDS = new Rectangle(0, 0, WIDTH, HEIGHT);
    IBOUNDS.setOpacity(0.0);

    final Shape LED_FRAME;
    final Shape LED_OFF;
    final Shape HIGHLIGHT;

    switch (control.getType()) {
      case SQUARE:
        LED_FRAME = new Rectangle(0.0625 * WIDTH, 0.0625 * HEIGHT, 0.875 * WIDTH, 0.875 * HEIGHT);
        LED_OFF = new Rectangle(0.1875 * WIDTH, 0.1875 * HEIGHT, 0.625 * WIDTH, 0.625 * HEIGHT);
        ledOn = new Rectangle(0.1875 * WIDTH, 0.1875 * HEIGHT, 0.625 * WIDTH, 0.625 * HEIGHT);
        HIGHLIGHT = new Rectangle(0.25 * WIDTH, 0.25 * HEIGHT, 0.5 * WIDTH, 0.1875 * HEIGHT);
        break;
      case VERTICAL:
        LED_FRAME = new Rectangle(0.25 * WIDTH, 0.0625 * HEIGHT, 0.5 * WIDTH, 0.875 * HEIGHT);
        LED_OFF = new Rectangle(0.3125 * WIDTH, 0.125 * HEIGHT, 0.375 * WIDTH, 0.75 * HEIGHT);
        ledOn = new Rectangle(0.3125 * WIDTH, 0.125 * HEIGHT, 0.375 * WIDTH, 0.75 * HEIGHT);
        HIGHLIGHT = new Rectangle(0.3125 * WIDTH, 0.125 * HEIGHT, 0.375 * WIDTH, 0.375 * HEIGHT);
        break;
      case HORIZONTAL:
        LED_FRAME = new Rectangle(0.0625 * WIDTH, 0.25 * HEIGHT, 0.875 * WIDTH, 0.5 * HEIGHT);
        LED_OFF = new Rectangle(0.125 * WIDTH, 0.3125 * HEIGHT, 0.75 * WIDTH, 0.375 * HEIGHT);
        ledOn = new Rectangle(0.125 * WIDTH, 0.3125 * HEIGHT, 0.75 * WIDTH, 0.375 * HEIGHT);
        HIGHLIGHT = new Rectangle(0.125 * WIDTH, 0.3125 * HEIGHT, 0.75 * WIDTH, 0.1875 * HEIGHT);
        break;
      case ROUND:
      default:
        LED_FRAME = new Circle(0.5 * WIDTH, 0.5 * HEIGHT, 0.4375 * WIDTH);
        LED_OFF = new Circle(0.5 * WIDTH, 0.5 * HEIGHT, 0.3125 * WIDTH);
        ledOn = new Circle(0.5 * WIDTH, 0.5 * HEIGHT, 0.3125 * WIDTH);
        HIGHLIGHT = new Circle(0.5 * WIDTH, 0.5 * HEIGHT, 0.2 * WIDTH);
        break;
    }

    LED_FRAME.getStyleClass().add("frame");

    LED_OFF.getStyleClass().clear();
    LED_OFF.getStyleClass().add("off");
    LED_OFF.setStyle("-fx-led: " + Util.colorToCssColor(control.getColor()));

    ledOn.getStyleClass().clear();
    ledOn.getStyleClass().add("on");
    ledOn.setStyle("-fx-led: " + Util.colorToCssColor(control.getColor()));
    ledOn.setVisible(control.isOn());

    HIGHLIGHT.getStyleClass().add("highlight");

    if (LED_FRAME.visibleProperty().isBound()) {
      LED_FRAME.visibleProperty().unbind();
    }
    LED_FRAME.visibleProperty().bind(control.frameVisibleProperty());

    final InnerShadow INNER_SHADOW = new InnerShadow();
    INNER_SHADOW.setWidth(0.180 * SIZE);
    INNER_SHADOW.setHeight(0.180 * SIZE);
    INNER_SHADOW.setRadius(0.15 * SIZE);
    INNER_SHADOW.setColor(Color.BLACK);
    INNER_SHADOW.setBlurType(BlurType.GAUSSIAN);
    LED_OFF.setEffect(INNER_SHADOW);

    final DropShadow GLOW = new DropShadow();
    GLOW.setSpread(0.35);
    GLOW.setRadius(0.16 * ledOn.getLayoutBounds().getWidth());
    GLOW.setColor(control.getColor());
    GLOW.setBlurType(BlurType.GAUSSIAN);
    GLOW.setInput(INNER_SHADOW);
    ledOn.setEffect(GLOW);

    led.getChildren().setAll(IBOUNDS, LED_FRAME, LED_OFF, ledOn, HIGHLIGHT);

    led.setCache(true);
  }