コード例 #1
0
 private Candle(String seriesStyleClass, String dataStyleClass) {
   setAutoSizeChildren(false);
   getChildren().addAll(highLowLine, bar);
   this.seriesStyleClass = seriesStyleClass;
   this.dataStyleClass = dataStyleClass;
   updateStyleClasses();
   tooltip.setGraphic(new TooltipContent());
   Tooltip.install(bar, tooltip);
 }
コード例 #2
0
  @FXML
  void onMouseEnterGameStatus() {
    if (playerInfoBean.getGameStatus() == GameStatus.NONE) {
      return;
    }

    GameStatusTooltipController gameStatusTooltipController =
        applicationContext.getBean(GameStatusTooltipController.class);
    gameStatusTooltipController.setGameInfoBean(gameService.getByUid(playerInfoBean.getGameUid()));

    Tooltip statusTooltip = new Tooltip();
    statusTooltip.setGraphic(gameStatusTooltipController.getRoot());
    Tooltip.install(statusImageView, statusTooltip);
  }
コード例 #3
0
 /**
  * @param graphic
  * @param node
  * @return
  */
 public static Tooltip create(Node graphic, Node node) {
   Tooltip tooltip = new Tooltip();
   tooltip.setGraphic(graphic);
   node.setOnMouseEntered(
       (MouseEvent event) -> {
         Point2D p =
             node.localToScreen(
                 node.getLayoutBounds().getMaxX(),
                 node.getLayoutBounds()
                     .getMaxY()); // I position the tooltip at bottom right of the node (see below
         // for explanation)
         tooltip.show(node, p.getX(), p.getY());
       });
   node.setOnMouseExited(
       (MouseEvent event) -> {
         tooltip.hide();
       });
   return tooltip;
 }
コード例 #4
0
  @Override
  protected void updateItem(IlliquidMainSalesStatusBean item, boolean empty) {
    super.updateItem(item, empty);
    if ((!isEmpty()) && (item != null)) {
      StringBuilder tooltext = new StringBuilder();
      HBox hb = new HBox();
      hb.setAlignment(Pos.CENTER);
      VBox vb = new VBox();
      vb.setAlignment(Pos.CENTER);

      double totalCount =
          item.getCountTvr() + item.getDays30sale() + item.getDays60sale() + item.getDays90sale();
      double proc30;
      double proc60;
      double proc90;
      if (totalCount > 0) {
        proc30 = item.getDays30sale() / totalCount;
        proc60 = item.getDays60sale() / totalCount;
        proc90 = item.getDays90sale() / totalCount;
      } else {
        proc30 = 1;
        proc60 = 1;
        proc90 = 1;
      }

      if (proc30 == 0) {
        hb.getChildren().add(new ImageView(imEmpty));
        vb.getChildren().add(new ImageView(imEmpty));
      } else if (proc30 < 0.10) {
        hb.getChildren().add(new ImageView(imRed));
        vb.getChildren().add(new ImageView(imRed));
      } else if (proc30 >= 0.10 && proc30 < 0.30) {
        hb.getChildren().add(new ImageView(imYelow));
        vb.getChildren().add(new ImageView(imYelow));
      } else if (proc30 >= 0.30) {
        hb.getChildren().add(new ImageView(imGreen));
        vb.getChildren().add(new ImageView(imGreen));
      }
      tooltext
          .append("1 міс. {")
          .append(DateConverters.getDateToStr(per30From))
          .append(" - ")
          .append(DateConverters.getDateToStr(now))
          .append("}:  ")
          .append(String.format("%.2f", proc30 * 100))
          .append("%\n");

      if (proc60 == 0) {
        hb.getChildren().add(new ImageView(imEmpty));
        vb.getChildren().add(new ImageView(imEmpty));
      } else if (proc60 < 0.10) {
        hb.getChildren().add(new ImageView(imRed));
        vb.getChildren().add(new ImageView(imRed));
      } else if (proc60 >= 0.10 && proc60 < 0.30) {
        hb.getChildren().add(new ImageView(imYelow));
        vb.getChildren().add(new ImageView(imYelow));
      } else if (proc60 >= 0.30) {
        hb.getChildren().add(new ImageView(imGreen));
        vb.getChildren().add(new ImageView(imGreen));
      }
      tooltext
          .append("2 міс. {")
          .append(DateConverters.getDateToStr(per60From))
          .append(" - ")
          .append(DateConverters.getDateToStr(per30From))
          .append("}:  ")
          .append(String.format("%.2f", proc60 * 100))
          .append("%\n");

      if (proc90 == 0) {
        hb.getChildren().add(new ImageView(imEmpty));
        vb.getChildren().add(new ImageView(imEmpty));
      } else if (proc90 < 0.10) {
        hb.getChildren().add(new ImageView(imRed));
        vb.getChildren().add(new ImageView(imRed));
      } else if (proc90 >= 0.10 && proc90 < 0.30) {
        hb.getChildren().add(new ImageView(imYelow));
        vb.getChildren().add(new ImageView(imYelow));
      } else if (proc90 >= 0.30) {
        hb.getChildren().add(new ImageView(imGreen));
        vb.getChildren().add(new ImageView(imGreen));
      }
      tooltext
          .append("3 міс. {")
          .append(DateConverters.getDateToStr(per90From))
          .append(" - ")
          .append(DateConverters.getDateToStr(per60From))
          .append("}:  ")
          .append(String.format("%.2f", proc90 * 100))
          .append("%");
      tooltip.setText(tooltext.toString());
      tooltip.setGraphic(vb);
      setTooltip(tooltip);
      setGraphic(hb);
    } else {
      setGraphic(null);
    }
  }