Exemplo n.º 1
0
  private Node createAxisOptions() {
    final Button btn = new Button("Axis", GlyphRegistry.get(AwesomeIcon.CARET_DOWN));
    btn.getStyleClass().add("flat-button");

    final ContextMenu menu = new ContextMenu();
    btn.setOnMousePressed(
        new EventHandler<Event>() {
          @Override
          public void handle(Event event) {
            menu.show(btn, Side.BOTTOM, 0, 0);
          }
        });

    MenuItem item = new MenuItem("Y linear", GlyphRegistry.get(AwesomeIcon.CHECK));
    item.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            _chart.axisMode().set(CyclistAxis.Mode.LINEAR);
          }
        });
    item.getGraphic()
        .visibleProperty()
        .bind(Bindings.equal(_chart.axisMode(), CyclistAxis.Mode.LINEAR));
    menu.getItems().add(item);

    item = new MenuItem("Y log", GlyphRegistry.get(AwesomeIcon.CHECK));
    item.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            _chart.axisMode().set(CyclistAxis.Mode.LOG);
          }
        });
    item.getGraphic()
        .visibleProperty()
        .bind(Bindings.equal(_chart.axisMode(), CyclistAxis.Mode.LOG));
    item.disableProperty().bind(Bindings.equal(_chart.getMode(), InventoryChart.ChartMode.STACKED));
    menu.getItems().add(item);

    item = new MenuItem("Y force zero", GlyphRegistry.get(AwesomeIcon.CHECK));
    item.getGraphic().visibleProperty().bind(_chart.forceZero());
    item.disableProperty().bind(Bindings.equal(_chart.getMode(), InventoryChart.ChartMode.STACKED));
    menu.getItems().add(item);
    item.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            _chart.forceZero().set(!_chart.forceZero().get());
          }
        });

    return btn;
  }
Exemplo n.º 2
0
  private Node createExportActions() {
    final Button button = new Button("Export", GlyphRegistry.get(AwesomeIcon.CARET_DOWN));
    button.getStyleClass().add("flat-button");

    // create menu
    final ContextMenu contextMenu = new ContextMenu();

    // csv chart
    MenuItem item = new MenuItem("Graph");
    item.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            export();
          }
        });
    contextMenu.getItems().add(item);
    button.setOnMousePressed(
        new EventHandler<Event>() {
          @Override
          public void handle(Event event) {
            contextMenu.show(button, Side.BOTTOM, 0, 0);
          }
        });

    return button;
  }
Exemplo n.º 3
0
    public Status() {
      super();
      _icon = GlyphRegistry.get(AwesomeIcon.REFRESH, "10px");
      getChildren().add(_icon);

      _animation = new RotateTransition(Duration.millis(500), _icon);
      _animation.setFromAngle(0);
      _animation.setByAngle(360);
      _animation.setCycleCount(Animation.INDEFINITE);
      _animation.setInterpolator(Interpolator.LINEAR);
      setVisible(false);
      setOnMouseClicked(e -> _task.cancel());
    }
Exemplo n.º 4
0
    public AgentEntry(final AgentInfo info) {
      super();
      this.info = info;

      getStyleClass().add("agent");
      Label text = new Label(info.value);
      text.setStyle("-fx-background-color:" + ColorUtil.toString(info.color));

      Node button = GlyphRegistry.get(AwesomeIcon.TIMES, "10px");
      button.setVisible(false);

      _status = new Status();
      getChildren().addAll(text, new Spring(), _status, button);

      info.taskProperty.addListener(o -> _status.setTask(info.getTask()));
      setOnMouseEntered(
          e -> {
            button.setVisible(true);
            getStyleClass().add("hover");
          });

      setOnMouseExited(
          e -> {
            button.setVisible(false);
            getStyleClass().remove("hover");
          });

      setOnMouseClicked(
          e -> {
            info.active = !info.active;
            text.setDisable(!info.active);
            if (info.active) {
              _chart.add(info);
            } else {
              _chart.remove(info);
            }
          });

      button.setOnMouseClicked(
          e -> {
            if (_onClose != null) {
              _onClose.accept(this);
            }
            e.consume();
          });

      HBox.setHgrow(text, Priority.ALWAYS);
    }
Exemplo n.º 5
0
  private Node createModeActions() {
    final Button button = new Button("Options", GlyphRegistry.get(AwesomeIcon.CARET_DOWN));
    button.getStyleClass().add("flat-button");

    // create menu
    final ContextMenu contextMenu = new ContextMenu();

    // line chart
    MenuItem item = new MenuItem("Line chart", GlyphRegistry.get(AwesomeIcon.CHECK));
    item.getGraphic()
        .visibleProperty()
        .bind(Bindings.equal(_chart.getMode(), InventoryChart.ChartMode.LINE));
    item.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            _chart.setMode(InventoryChart.ChartMode.LINE);
            if (!_lastForceZero) _chart.forceZero().set(false);
            if (_saveAxisMode == CyclistAxis.Mode.LOG) _chart.axisMode().set(CyclistAxis.Mode.LOG);
          }
        });
    contextMenu.getItems().add(item);

    //		// area chart
    //		item = new MenuItem("Area chart");
    //		item.setOnAction(new EventHandler<ActionEvent>() {
    //			@Override
    //			public void handle(ActionEvent event) {
    //				_chart.setMode(InventoryChart.ChartMode.AREA);
    //			}
    //		});
    //		contextMenu.getItems().add(item);

    // stacked chart
    item = new MenuItem("Stacked chart", GlyphRegistry.get(AwesomeIcon.CHECK));
    item.getGraphic()
        .visibleProperty()
        .bind(Bindings.equal(_chart.getMode(), InventoryChart.ChartMode.STACKED));
    item.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            _lastForceZero = _chart.forceZero().get();
            if (!_lastForceZero) _chart.forceZero().set(true);
            _saveAxisMode = _chart.axisMode().get();
            _chart.setMode(InventoryChart.ChartMode.STACKED);
          }
        });
    contextMenu.getItems().add(item);

    contextMenu.getItems().add(new SeparatorMenuItem());

    MenuItem checked = new MenuItem("Show total", GlyphRegistry.get(AwesomeIcon.CHECK));
    checked.getGraphic().visibleProperty().bind(_chart.getShowTotal());
    checked.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            _chart.setShowTotal(!_chart.getShowTotal().getValue());
          }
        });
    contextMenu.getItems().add(checked);

    button.setOnMousePressed(
        new EventHandler<Event>() {
          @Override
          public void handle(Event event) {
            contextMenu.show(button, Side.BOTTOM, 0, 0);
          }
        });

    return button;
  }