Пример #1
0
 public final SectionBuilder color(final String COLOR) {
   properties.put("color", new SimpleObjectProperty<Color>(Util.webColorToColor(COLOR)));
   return this;
 }
Пример #2
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);
  }