private static SubScene createSubScene(
      String title, Node node, Paint fillPaint, Camera camera, boolean msaa) {
    Group root = new Group();

    PointLight light = new PointLight(Color.WHITE);
    light.setTranslateX(50);
    light.setTranslateY(-300);
    light.setTranslateZ(-400);
    PointLight light2 = new PointLight(Color.color(0.6, 0.3, 0.4));
    light2.setTranslateX(400);
    light2.setTranslateY(0);
    light2.setTranslateZ(-400);

    AmbientLight ambientLight = new AmbientLight(Color.color(0.2, 0.2, 0.2));
    node.setRotationAxis(new Point3D(2, 1, 0).normalize());
    node.setTranslateX(180);
    node.setTranslateY(180);
    root.getChildren().addAll(setTitle(title), ambientLight, light, light2, node);

    SubScene subScene =
        new SubScene(
            root, 500, 400, true, msaa ? SceneAntialiasing.BALANCED : SceneAntialiasing.DISABLED);
    subScene.setFill(fillPaint);
    subScene.setCamera(camera);

    return subScene;
  }
  public OptionalEditor(PropertySheet.Item parameter) {

    if (!(parameter instanceof OptionalParameter)) throw new IllegalArgumentException();

    optionalParameter = (OptionalParameter<?>) parameter;
    embeddedParameter = optionalParameter.getEmbeddedParameter();

    // The checkbox
    checkBox = new CheckBox();

    setLeft(checkBox);

    // Add embedded editor
    try {
      Class<? extends PropertyEditor<?>> embeddedEditorClass =
          embeddedParameter.getPropertyEditorClass().get();
      embeddedEditor =
          embeddedEditorClass
              .getDeclaredConstructor(PropertySheet.Item.class)
              .newInstance(embeddedParameter);
      Node embeddedNode = embeddedEditor.getEditor();
      Boolean value = optionalParameter.getValue();
      if (value == null) value = false;
      embeddedNode.setDisable(!value);
      checkBox.setOnAction(
          e -> {
            embeddedNode.setDisable(!checkBox.isSelected());
          });

      setCenter(embeddedNode);
    } catch (Exception e) {
      throw (new IllegalStateException(e));
    }
  }
  @Override
  public void updatePage(IServiceModel model) {
    if (getPager() == null) { // maybe null during init
      return;
    }
    if (model instanceof Song) {
      Song song = (Song) model;
      if (album.getActiveSong() == null) {
        updateBlink(null);
      }
      if (song.isActive()) {
        Node container = getNodeForSong(song);
        updateBlink(container);
      }

      if (lastSongSelection != null) {
        lastSongSelection.setStyle(STYLE_INACTIVE);
      }

      if (songBox != null) {
        final ObservableList<Node> children = songBox.getChildren();
        for (Node node : children) {
          String id = node.getId();
          if (getPager().getActiveModel() instanceof Song) {
            if (id.equals(String.valueOf(((Song) getPager().getActiveModel()).getMID()))) {
              lastSongSelection = node;
              lastSongSelection.setStyle(STYLE_ACTIVE);
            }
          }
        }
      }
    }
  }
  @Override
  public void initialize(URL url, ResourceBundle resourceBundle) {
    Random random = new Random();
    random.setSeed(System.currentTimeMillis());

    Singleton.INSTANCE.magicNumber = random.nextLong();
    Singleton.INSTANCE.rightPairs = new ArrayList<String>();

    Singleton.INSTANCE.balloons = FXCollections.observableArrayList();

    Singleton.INSTANCE.pontosPlayer1 = 0;
    Singleton.INSTANCE.pontosPlayer2 = 0;

    this.imagesGridPane.setDisable(true);
    this.messagesListView.setDisable(true);
    this.messageInputField.setDisable(true);
    this.enviarButton.setDisable(true);

    for (Node node : this.imagesGridPane.getChildren()) {
      node.getStyleClass().addAll("imageview", "imageview:hover");
    }

    this.messagesListView.setItems(Singleton.INSTANCE.balloons);
    this.ipAddressLabel.setText(
        String.format(
            "Endereço IP: %s:%d",
            Singleton.INSTANCE.localIPAddress, Singleton.INSTANCE.localIMServerPort));
  }
  public final void addDragListeners(final Node n) {

    n.setOnMousePressed(
        new EventHandler<MouseEvent>() {

          @Override
          public void handle(MouseEvent me) {

            startDragX = me.getSceneX();
            startDragY = me.getSceneY();
            root.setStyle("-fx-opacity:.7;");
          }
        });
    n.setOnMouseReleased(
        new EventHandler<MouseEvent>() {

          @Override
          public void handle(MouseEvent me) {

            root.setStyle("-fx-opacity:1;");
          }
        });
    n.setOnMouseDragged(
        new EventHandler<MouseEvent>() {

          @Override
          public void handle(MouseEvent me) {

            stage.setX(me.getScreenX() - startDragX);
            stage.setY(me.getScreenY() - startDragY);
          }
        });
  }
  private static Bounds computeUnclippedBounds(Node node) {
    final Bounds layoutBounds;
    double minX, minY, maxX, maxY, minZ, maxZ;

    assert node != null;
    assert node.getLayoutBounds().isEmpty() == false;

    layoutBounds = node.getLayoutBounds();
    minX = layoutBounds.getMinX();
    minY = layoutBounds.getMinY();
    maxX = layoutBounds.getMaxX();
    maxY = layoutBounds.getMaxY();
    minZ = layoutBounds.getMinZ();
    maxZ = layoutBounds.getMaxZ();

    if (node instanceof Parent) {
      final Parent parent = (Parent) node;

      for (Node child : parent.getChildrenUnmodifiable()) {
        final Bounds childBounds = child.getBoundsInParent();
        minX = Math.min(minX, childBounds.getMinX());
        minY = Math.min(minY, childBounds.getMinY());
        maxX = Math.max(maxX, childBounds.getMaxX());
        maxY = Math.max(maxY, childBounds.getMaxY());
        minZ = Math.min(minZ, childBounds.getMinZ());
        maxZ = Math.max(maxZ, childBounds.getMaxZ());
      }
    }

    assert minX <= maxX;
    assert minY <= maxY;
    assert minZ <= maxZ;

    return new BoundingBox(minX, minY, minZ, maxX - minX, maxY - minY, maxZ - minZ);
  }
  /**
   * Creates DisplacementMap effect for the bend
   *
   * @param node target node
   * @param path path that is used to draw the opposite side of a bend Its fill is updated with
   *     linear gradient.
   * @param shadow path that is used to draw the shadow of a bend Its fill is updated with linear
   *     gradient.
   * @param clip path that is used to clip the content of the page either for mouse operations or
   *     for visuals
   */
  public BookBend(final Node node, Path path, Path shadow, Path clip) {
    this.node = node;
    this.p = path;
    this.shadow = shadow;
    this.clip = clip;

    node.setEffect(new DisplacementMap(map));
    node.layoutBoundsProperty()
        .addListener(
            new InvalidationListener() {

              @Override
              public void invalidated(Observable arg0) {
                newWidth = (int) Math.round(node.getLayoutBounds().getWidth());
                newHeight = (int) Math.round(node.getLayoutBounds().getHeight());
                if (newWidth != map.getWidth() || newHeight != map.getHeight()) {
                  setUpdateNeeded(true);
                }
              }
            });
    node.sceneProperty()
        .addListener(
            new ChangeListener<Scene>() {

              @Override
              public void changed(
                  ObservableValue<? extends Scene> ov, Scene oldValue, Scene newValue) {
                if (newValue == null) {
                  stopAnimationTimer();
                }
              }
            });
    newWidth = (int) Math.round(node.getLayoutBounds().getWidth());
    newHeight = (int) Math.round(node.getLayoutBounds().getHeight());
  }
 protected void validateCreateButton() {
   if (itemName.getText().isEmpty()) {
     btnCreate.setDisable(true);
   } else {
     btnCreate.setDisable(false);
   }
 }
Exemple #9
0
  public void parseItems(List<Node> nodes, Pattern pattern, int defaultGroup) {
    List<Node> newNodes = new ArrayList<>();

    for (Node node : nodes) {
      if (node.getClass() != Text.class) {
        newNodes.add(node);
        continue;
      }

      String str = ((Text) node).getText();
      Matcher matcher = pattern.matcher(str);
      int lastIndex = 0;
      while (matcher.find()) {
        newNodes.add(new Text(str.substring(lastIndex, matcher.start())));
        SelectableMember sm = SelectableMember.fromMatcher(this, matcher);
        if (sm != null) {
          newNodes.add(sm);
        } else {
          newNodes.add(new Text(StringHelper.unqualify(matcher.group(defaultGroup))));
        }
        lastIndex = matcher.end();
      }
      newNodes.add(new Text(str.substring(lastIndex)));
    }

    nodes.clear();
    nodes.addAll(newNodes);
  }
  public static void addMarker(final XYChart<?, ?> chart, final StackPane chartWrap) {
    final Line valueMarker = new Line();
    final Node chartArea = chart.lookup(".chart-plot-background");

    chartArea.setOnMouseMoved(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            Point2D scenePoint = chart.localToScene(event.getSceneX(), event.getSceneY());
            Point2D position = chartWrap.sceneToLocal(scenePoint.getX(), scenePoint.getY());

            Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());
            valueMarker.setStartY(0);
            valueMarker.setEndY(
                chartWrap.sceneToLocal(chartAreaBounds).getMaxY()
                    - chartWrap.sceneToLocal(chartAreaBounds).getMinY());

            valueMarker.setStartX(0);
            valueMarker.setEndX(0);
            valueMarker.setTranslateX(position.getX() - chartWrap.getWidth() / 2);

            double ydelta =
                chartArea.localToScene(0, 0).getY() - chartWrap.localToScene(0, 0).getY();
            valueMarker.setTranslateY(-ydelta * 2);
          }
        });

    chartWrap.getChildren().add(valueMarker);
  }
 private boolean laevasidAlles() {
   for (Node ruut : laud.getChildren()) {
     if (ruut.getId().equals("laev")) {
       return true;
     }
   }
   return false;
 }
Exemple #12
0
  private void showFinishingPage() {
    getChildren().remove(finishingPage);
    for (Node child : getChildren()) child.setVisible(false);

    finishingPage.setVisible(true);
    getChildren().add(finishingPage);
    finishingPage.requestFocus();
  }
Exemple #13
0
 protected void onEval() {
   Node control = getSrcControl();
   if (hasErrors.get()) {
     if (!control.getStyleClass().contains(errorStyleClass.get()))
       control.getStyleClass().add(errorStyleClass.get());
   } else {
     control.getStyleClass().remove(errorStyleClass.get());
   }
 }
Exemple #14
0
 /* This code has been taken from:
  * https://community.oracle.com/thread/2534556?tstart=0
  * AND WAS MODIFIED!*/
 public static final Point2D getNodeLocation(Node node) {
   double x = 0, y = 0;
   for (Node n = node; n != null; n = n.getParent()) {
     Bounds parentBounds = n.getBoundsInParent();
     x += parentBounds.getMinX();
     y += parentBounds.getMinY();
   }
   return new Point2D(x, y);
 }
Exemple #15
0
  /**
   * Traverse the scene graph for all open stages and pick an event target for a dock event based on
   * the location. Once the event target is chosen run the event task with the target and the
   * previous target of the last dock event if one is cached. If an event target is not found fire
   * the explicit dock event on the stage root if one is provided.
   *
   * @param location The location of the dock event in screen coordinates.
   * @param eventTask The event task to be run when the event target is found.
   * @param explicit The explicit event to be fired on the stage root when no event target is found.
   */
  private void pickEventTarget(Point2D location, EventTask eventTask, Event explicit) {
    // RFE for public scene graph traversal API filed but closed:
    // https://bugs.openjdk.java.net/browse/JDK-8133331

    ObservableList<Stage> stages =
        FXCollections.unmodifiableObservableList(StageHelper.getStages());
    // fire the dock over event for the active stages
    for (Stage targetStage : stages) {
      // obviously this title bar does not need to receive its own events
      // though users of this library may want to know when their
      // dock node is being dragged by subclassing it or attaching
      // an event listener in which case a new event can be defined or
      // this continue behavior can be removed
      if (targetStage == this.dockNode.getStage()) continue;

      eventTask.reset();

      Node dragNode = dragNodes.get(targetStage);

      Parent root = targetStage.getScene().getRoot();
      Stack<Parent> stack = new Stack<Parent>();
      if (root.contains(root.screenToLocal(location.getX(), location.getY()))
          && !root.isMouseTransparent()) {
        stack.push(root);
      }
      // depth first traversal to find the deepest node or parent with no children
      // that intersects the point of interest
      while (!stack.isEmpty()) {
        Parent parent = stack.pop();
        // if this parent contains the mouse click in screen coordinates in its local bounds
        // then traverse its children
        boolean notFired = true;
        for (Node node : parent.getChildrenUnmodifiable()) {
          if (node.contains(node.screenToLocal(location.getX(), location.getY()))
              && !node.isMouseTransparent()) {
            if (node instanceof Parent) {
              stack.push((Parent) node);
            } else {
              eventTask.run(node, dragNode);
            }
            notFired = false;
            break;
          }
        }
        // if none of the children fired the event or there were no children
        // fire it with the parent as the target to receive the event
        if (notFired) {
          eventTask.run(parent, dragNode);
        }
      }

      if (explicit != null && dragNode != null && eventTask.getExecutions() < 1) {
        Event.fireEvent(dragNode, explicit.copyFor(this, dragNode));
        dragNodes.put(targetStage, null);
      }
    }
  }
Exemple #16
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Group root = new Group();
    Group circles = new Group();
    for (int i = 0; i < 30; i++) {
      Circle circle = new Circle(150, Color.web("white", 0.05));
      circle.setStrokeType(StrokeType.OUTSIDE);
      circle.setStroke(Color.web("white", 0.16));
      circle.setStrokeWidth(4);
      circles.getChildren().add(circle);
    }
    root.getChildren().add(circles);
    Scene scene = new Scene(root, 800, 600, Color.BLACK);
    Rectangle colors =
        new Rectangle(
            scene.getWidth(),
            scene.getHeight(),
            new LinearGradient(
                0f,
                1f,
                1f,
                0f,
                true,
                CycleMethod.NO_CYCLE,
                new Stop[] {
                  new Stop(0, Color.web("#f8bd55")),
                  new Stop(0.14, Color.web("#c0fe56")),
                  new Stop(0.28, Color.web("#5dfbc1")),
                  new Stop(0.43, Color.web("#64c2f8")),
                  new Stop(0.57, Color.web("#be4af7")),
                  new Stop(0.71, Color.web("#ed5fc2")),
                  new Stop(0.85, Color.web("#ef504c")),
                  new Stop(1, Color.web("#f2660f")),
                }));
    colors.widthProperty().bind(scene.widthProperty());
    colors.heightProperty().bind(scene.heightProperty());
    root.getChildren().add(colors);

    Timeline timeline = new Timeline();
    for (Node circle : circles.getChildren()) {
      timeline
          .getKeyFrames()
          .addAll(
              new KeyFrame(
                  Duration.ZERO, // set start position at 0
                  new KeyValue(circle.translateXProperty(), random() * 800),
                  new KeyValue(circle.translateYProperty(), random() * 600)),
              new KeyFrame(
                  new Duration(40000), // set end position at 40s
                  new KeyValue(circle.translateXProperty(), random() * 800),
                  new KeyValue(circle.translateYProperty(), random() * 600)));
    }
    timeline.play();
    primaryStage.setScene(scene);
    primaryStage.show();
  }
  private void setUpDragAndDrop() {
    getToolBar().getItems().forEach(this::addDragHandlers);

    getToolBar()
        .getItems()
        .addListener(
            (ListChangeListener<Node>)
                c -> {
                  c.next();
                  c.getAddedSubList().forEach(this::addDragHandlers);
                });

    getToolBar()
        .setOnDragDropped(
            event -> {
              if (currentlyDraggingNode != null
                  && !getToolBar().getItems().contains(currentlyDraggingNode)) {
                getToolBar().getItems().add(currentlyDraggingNode);
              }
              event.setDropCompleted(true);
            });

    getToolBar().setOnDragDone(event -> currentlyDraggingNode = null);

    getToolBar()
        .setOnDragOver(
            event -> {
              if (currentlyDraggingNode != null) {
                getToolBar().getItems().remove(currentlyDraggingNode);
                event.acceptTransferModes(TransferMode.MOVE);
                event.consume();

                Node closestNode = null;
                double closestNodePosition = Double.MAX_VALUE;
                double cursorPosition = event.getX();

                for (Node node : getToolBar().getItems()) {
                  // If cursor position falls within x bounds of node then check if should appear to
                  // left or right of node
                  double thisNodeX = node.localToScene(Point2D.ZERO).getX();
                  if (Math.abs(thisNodeX - cursorPosition) < closestNodePosition) {
                    closestNode = node;
                    closestNodePosition = Math.abs(thisNodeX - cursorPosition);
                  }
                }
                if (closestNode != null
                    && cursorPosition <= closestNode.localToScene(Point2D.ZERO).getX()) {
                  // Then the dragged node should appear to left of closest node
                  moveNode(currentlyDraggingNode, getToolBar().getItems().indexOf(closestNode));
                } else {
                  // Then the dragged node should appear to right of closest node
                  moveNode(currentlyDraggingNode, getToolBar().getItems().indexOf(closestNode) + 1);
                }
              }
            });
  }
 // as of JDK 1.6: @Override
 public int getScreenLocationY() {
   // this code is never called?
   Bounds lBoundsInScenenode = node.localToScene(node.getBoundsInLocal());
   int v =
       (int)
           Math.ceil(
               node.getScene().getY() + node.getScene().getY() + lBoundsInScenenode.getMinY());
   // for debugging System.out.println(getComponent() + " getScreenLocationX =" + v);
   return v;
 }
 /**
  * Returns the row for the given song.
  *
  * @param song
  * @return
  */
 private Node getNodeForSong(Song song) {
   final ObservableList<Node> children = songBox.getChildren();
   for (Node node : children) {
     String id = node.getId();
     if (id.equals(String.valueOf(song.getMID()))) {
       return node;
     }
   }
   return null;
 }
  @Test
  public void testConceptNewJump() {
    // given
    Set<Node> newButtons = conceptMapView.lookupAll(".newBtnTop");
    Node firstNewButton = newButtons.iterator().next();

    moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY);
    Node concept = conceptMapView.lookup(".concept");

    double expectedX = concept.getLayoutX() + concept.getTranslateX();
    double expectedY = concept.getLayoutY() + concept.getTranslateY();

    // when

    super.interact(
        () -> {
          stage.setFullScreen(false);
          stage.setWidth(stage.getWidth() - 40);
          stage.setHeight(stage.getHeight() - 40);
        });

    // then

    double actualX = concept.getLayoutX() + concept.getTranslateX();
    double actualY = concept.getLayoutY() + concept.getTranslateY();

    assertEquals(expectedX, actualX, 50);
    assertEquals(expectedY, actualY, 50);
  }
  /**
   * Update background, tick and gridline colors
   *
   * @param cfg cfg[0] Background, cfg[1] Chart background, cfg[2] y cfg[3] gridline
   */
  public void updateChartColors(String[] cfg) {
    strBackgroundColor = cfg[0];
    for (Node le : legendFrame.getChildren()) {
      if (le instanceof LegendAxis) {
        le.setStyle("-fx-background-color:" + strBackgroundColor);
        ((LegendAxis) le).selected = false;
      }
    }
    chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)));
    chartPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(
                scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)))));
    chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)));

    legendFrame.setStyle("marco: " + strBackgroundColor + ";-fx-background-color: marco;");

    strChartBackgroundColor = cfg[1];
    ;
    plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor)));

    for (Node le : legendFrame.getChildren()) {
      if (le instanceof LegendAxis) {
        le.setStyle("-fx-background-color:" + strBackgroundColor);
        ((LegendAxis) le).selected = false;
        for (Node nn : ((LegendAxis) le).getChildren()) {
          if (nn instanceof Label) {
            ((Label) nn)
                .setStyle(
                    "fondo: "
                        + strChartBackgroundColor
                        + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                        + String.valueOf(fontSize)
                        + "px");
          }
        }
      }
    }

    strGridlineColor = cfg[2];
    ;
    plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor)));
    plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor)));

    strTickColor = cfg[3];
    ;
    abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
    abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
    for (NumberAxis ejeOrdenada : AxesList) {
      ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
      ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
    }
  }
 /**
  * Method loadTableScene calls if login and password is correct, and do more beautiful change
  * scene.
  */
 public void loadTableScene() {
   stage = (Stage) userField.getScene().getWindow();
   Node node = root.lookup("#table");
   node.setOpacity(0);
   FadeTransition fadeTransition = new FadeTransition(Duration.seconds(2), node);
   fadeTransition.setToValue(1);
   fadeTransition.play();
   Scene scene = new Scene(root);
   stage.setScene(scene);
   stage.show();
 }
  private List<Run> getRuns(double maxRunLength) {
    if (runs == null || maxRunLength != lastMaxRunLength) {
      computingRuns = true;
      lastMaxRunLength = maxRunLength;
      runs = new ArrayList();
      double runLength = 0;
      double runOffset = 0;
      Run run = new Run();
      double vgap = snapSpace(this.getVgap());
      double hgap = snapSpace(this.getHgap());

      final List<Node> children = getChildren();
      for (int i = 0, size = children.size(); i < size; i++) {
        Node child = children.get(i);
        if (child.isManaged()) {
          LayoutRect nodeRect = new LayoutRect();
          nodeRect.node = child;
          Insets margin = getMargin(child);
          nodeRect.width = computeChildPrefAreaWidth(child, margin);
          nodeRect.height = computeChildPrefAreaHeight(child, margin);
          double nodeLength = getOrientation() == HORIZONTAL ? nodeRect.width : nodeRect.height;
          if (runLength + nodeLength > maxRunLength && runLength > 0) {
            // wrap to next run *unless* its the only node in the run
            normalizeRun(run, runOffset);
            if (getOrientation() == HORIZONTAL) {
              // horizontal
              runOffset += run.height + vgap;
            } else {
              // vertical
              runOffset += run.width + hgap;
            }
            runs.add(run);
            runLength = 0;
            run = new Run();
          }
          if (getOrientation() == HORIZONTAL) {
            // horizontal
            nodeRect.x = runLength;
            runLength += nodeRect.width + hgap;
          } else {
            // vertical
            nodeRect.y = runLength;
            runLength += nodeRect.height + vgap;
          }
          run.rects.add(nodeRect);
        }
      }
      // insert last run
      normalizeRun(run, runOffset);
      runs.add(run);
      computingRuns = false;
    }
    return runs;
  }
  /**
   * TODO To complete.
   *
   * @param nextSlide the next slide
   */
  private void performStepAnimation(final Node nextSlide) {

    this.subSlideTransition =
        ParallelTransitionBuilder.create()
            .onFinished(
                new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(final ActionEvent event) {
                    AbstractBaseView.this.currentSubSlide = nextSlide;
                  }
                })
            .children(
                SequentialTransitionBuilder.create()
                    .node(this.currentSubSlide)
                    .children(
                        TranslateTransitionBuilder.create()
                            .duration(Duration.millis(400))
                            .fromY(0)
                            .toY(-700)
                            // .fromZ(-10)
                            .build(),
                        TimelineBuilder.create()
                            .keyFrames(
                                new KeyFrame(
                                    Duration.millis(0),
                                    new KeyValue(this.currentSubSlide.visibleProperty(), true)),
                                new KeyFrame(
                                    Duration.millis(1),
                                    new KeyValue(this.currentSubSlide.visibleProperty(), false)))
                            .build())
                    .build(),
                SequentialTransitionBuilder.create()
                    .node(nextSlide)
                    .children(
                        TimelineBuilder.create()
                            .keyFrames(
                                new KeyFrame(
                                    Duration.millis(0),
                                    new KeyValue(nextSlide.visibleProperty(), false)),
                                new KeyFrame(
                                    Duration.millis(1),
                                    new KeyValue(nextSlide.visibleProperty(), true)))
                            .build(),
                        TranslateTransitionBuilder.create()
                            .duration(Duration.millis(400))
                            .fromY(700)
                            .toY(0)
                            // .fromZ(-10)
                            .build())
                    .build())
            .build();
    this.subSlideTransition.play();
  }
Exemple #25
0
 /**
  * determine if the {@code Node} is the ancestorNode of another {@code Node} or the same.
  *
  * @param node the node
  * @param ancestorNode the possible ancestorNode node
  * @return true of the ancestorNode is an ancestor of the node, or the same.
  */
 public static boolean isAncestor(Node node, Node ancestorNode) {
   if (node != null && ancestorNode != null) {
     Node parent = ancestorNode;
     while (parent != null) {
       if (parent == node) {
         return true;
       }
       parent = parent.getParent();
     }
   }
   return false;
 }
 protected void refreshHandleLocation(Node hostVisual) {
   // position vbox top-right next to the host
   Bounds hostBounds = hostVisual.getBoundsInParent();
   Parent parent = hostVisual.getParent();
   if (parent != null) {
     hostBounds = parent.localToScene(hostBounds);
   }
   Point2D location =
       getVisual().getParent().sceneToLocal(hostBounds.getMaxX(), hostBounds.getMinY());
   getVisual().setLayoutX(location.getX());
   getVisual().setLayoutY(location.getY());
 }
  private void performTermination() {
    eventTarget.setOnDragDetected(null);
    eventTarget.setOnMouseReleased(null);
    eventTarget.setOnMouseExited(null);

    try {
      observer.gestureDidTerminate(this);
    } finally {
      observer = null;
      eventTarget = null;
    }
  }
 public static void addListenerDeeply(final Node node, final EventHandler<MouseEvent> listener) {
   node.addEventHandler(MouseEvent.MOUSE_MOVED, listener);
   node.addEventHandler(MouseEvent.MOUSE_PRESSED, listener);
   node.addEventHandler(MouseEvent.MOUSE_DRAGGED, listener);
   if (node instanceof Parent) {
     final Parent parent = (Parent) node;
     final ObservableList<Node> children = parent.getChildrenUnmodifiable();
     for (final Node child : children) {
       ResizeAndMoveHelper.addListenerDeeply(child, listener);
     }
   }
 }
  @Override
  public void drag(MouseEvent e, Dimension delta) {
    if (invalidGesture) {
      return;
    }

    if (selectionBounds == null) {
      return;
    }

    Rectangle sel = updateSelectionBounds(e);
    for (IContentPart<Node, ? extends Node> targetPart : targetParts) {
      // compute initial and new bounds for this target
      Bounds initialBounds = getBounds(selectionBounds, targetPart);
      Bounds newBounds = getBounds(sel, targetPart);

      // compute translation in scene coordinates
      double dx = newBounds.getMinX() - initialBounds.getMinX();
      double dy = newBounds.getMinY() - initialBounds.getMinY();

      // transform translation to parent coordinates
      Node visual = targetPart.getVisual();
      Point2D originInParent = visual.getParent().sceneToLocal(0, 0);
      Point2D deltaInParent = visual.getParent().sceneToLocal(dx, dy);
      dx = deltaInParent.getX() - originInParent.getX();
      dy = deltaInParent.getY() - originInParent.getY();

      // apply translation
      getTransformPolicy(targetPart).setPostTranslate(translateIndices.get(targetPart), dx, dy);

      // check if we can resize the part
      AffineTransform affineTransform = getTransformPolicy(targetPart).getCurrentNodeTransform();
      if (affineTransform.getRotation().equals(Angle.fromDeg(0))) {
        // no rotation => resize possible
        // TODO: special case 90 degree rotations
        double dw = newBounds.getWidth() - initialBounds.getWidth();
        double dh = newBounds.getHeight() - initialBounds.getHeight();
        Point2D originInLocal = visual.sceneToLocal(newBounds.getMinX(), newBounds.getMinY());
        Point2D dstInLocal =
            visual.sceneToLocal(newBounds.getMinX() + dw, newBounds.getMinY() + dh);
        dw = dstInLocal.getX() - originInLocal.getX();
        dh = dstInLocal.getY() - originInLocal.getY();
        getResizePolicy(targetPart).resize(dw, dh);
      } else {
        // compute scaling based on bounds change
        double sx = newBounds.getWidth() / initialBounds.getWidth();
        double sy = newBounds.getHeight() / initialBounds.getHeight();
        // apply scaling
        getTransformPolicy(targetPart).setPostScale(scaleIndices.get(targetPart), sx, sy);
      }
    }
  }
Exemple #30
0
  private String showCreateOrRenameDialog(
      final String title,
      final String headerText,
      final File parent,
      final String name,
      final NameVerifier nameVerifier) {
    final Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(title);
    alert.setHeaderText(headerText);

    final GridPane contentContainer = new GridPane();
    contentContainer.setPadding(new Insets(8));
    contentContainer.setHgap(8);
    contentContainer.setVgap(8);

    contentContainer.add(new Label("Parent:"), 0, 0);
    final TextField parentTextField = new TextField();
    parentTextField.setEditable(false);

    parentTextField.setText(parent.getAbsolutePath());
    contentContainer.add(parentTextField, 1, 0);

    contentContainer.add(new Label("Name:"), 0, 1);

    final TextField dirNameTextField = new TextField();
    dirNameTextField.setText(name);
    GridPane.setHgrow(dirNameTextField, Priority.ALWAYS);
    contentContainer.add(dirNameTextField, 1, 1);

    final InvalidationListener updateDisableInvalidationListener =
        (observable) -> {
          final String dirName = dirNameTextField.getText();
          final Node okButton = alert.getDialogPane().lookupButton(ButtonType.OK);
          if (isEmpty(dirName)) okButton.setDisable(true);
          else {
            final boolean nameAcceptable = nameVerifier.isNameAcceptable(dirName);
            okButton.setDisable(!nameAcceptable);
          }
        };
    dirNameTextField.textProperty().addListener(updateDisableInvalidationListener);

    alert.getDialogPane().setContent(contentContainer);
    alert.setOnShowing(
        (event) -> {
          dirNameTextField.requestFocus();
          dirNameTextField.selectAll();
          updateDisableInvalidationListener.invalidated(null);
        });

    if (alert.showAndWait().get() == ButtonType.OK) return dirNameTextField.getText();
    else return null;
  }