public void layoutContent(boolean applyCSS) {
   if (scrollPane != null) {
     try {
       if (applyCSS) {
         contentSubScene.getRoot().applyCss();
       }
       scrollPane.layout();
       layoutException = null;
     } catch (RuntimeException x) {
       layoutException = x;
     }
   }
 }
Exemplo n.º 2
0
  public Cutaway(SubScene scene, double width, double height) {
    // Make sure "world" is a group
    assert scene.getRoot().getClass().equals(Group.class);

    setFillWidth(true);
    setPrefSize(width, height + controlSize);
    setMaxSize(width, height + controlSize);
    this.setBorder(
        new Border(
            new BorderStroke(
                Color.DARKKHAKI,
                BorderStrokeStyle.SOLID,
                new CornerRadii(25),
                new BorderWidths(5))));

    Rectangle closeSquare = new Rectangle(controlSize, controlSize, Color.LIGHTCORAL);
    closeSquare.setOnMouseClicked(
        (MouseEvent me) -> {
          this.fireEvent(new CloseCutawayEvent(this));
        });
    Circle dragCircle = new Circle(controlSize / 2, Color.STEELBLUE);

    HBox top = new HBox(20, closeSquare, dragCircle);
    dragCircle.setVisible(false);
    StackPane.setAlignment(closeSquare, Pos.TOP_RIGHT);
    StackPane.setMargin(closeSquare, new Insets(50));

    top.setBackground(
        new Background(
            new BackgroundFill(Color.KHAKI, new CornerRadii(20, 20, 0, 0, false), Insets.EMPTY)));

    top.setAlignment(Pos.TOP_RIGHT);

    top.setOnMousePressed(
        (MouseEvent me) -> {
          cutawayPosX = me.getSceneX();
          cutawayPosY = me.getSceneY();
          cutawayOldX = me.getSceneX();
          cutawayOldY = me.getSceneY();
        });
    top.setOnMouseDragged(
        (MouseEvent me) -> {
          cutawayOldX = cutawayPosX;
          cutawayOldY = cutawayPosY;
          cutawayPosX = me.getSceneX();
          cutawayPosY = me.getSceneY();
          cutawayDeltaX = (cutawayPosX - cutawayOldX);
          cutawayDeltaY = (cutawayPosY - cutawayOldY);
          setTranslateX(getTranslateX() + cutawayDeltaX);
          setTranslateY(getTranslateY() + cutawayDeltaY);
        });

    getChildren().addAll(top, imageView);

    worldToView = (Group) scene.getRoot();

    camera.setNearClip(0.1);
    camera.setFarClip(15000.0);
    camera.setTranslateZ(-1500);
    params.setCamera(camera);

    params.setDepthBuffer(true);
    params.setFill(Color.rgb(0, 0, 0, 0.5));

    viewTimer =
        new AnimationTimer() {
          @Override
          public void handle(long now) {
            redraw();
          }
        };
    setOnMouseEntered(
        e -> {
          requestFocus();
        });
  }