示例#1
0
  /**
   * Returns the {@link InfiniteCanvas} that is managed by this {@link FXViewer} .
   *
   * @return The {@link InfiniteCanvas} that is managed by this {@link FXViewer} .
   */
  public InfiniteCanvas getCanvas() {
    if (infiniteCanvas == null) {
      IRootPart<Node, ? extends Node> rootPart = getRootPart();
      if (rootPart != null) {
        infiniteCanvas = new InfiniteCanvas();
        infiniteCanvas.setStyle(DEFAULT_STYLE);

        // register root visual
        infiniteCanvas.getContentGroup().getChildren().addAll((Parent) rootPart.getVisual());

        // ensure we can properly react to scene and focus owner changes
        infiniteCanvas
            .sceneProperty()
            .addListener(
                new ChangeListener<Scene>() {
                  @Override
                  public void changed(
                      ObservableValue<? extends Scene> observable, Scene oldValue, Scene newValue) {
                    onSceneChanged(oldValue, newValue);
                  }
                });
        if (infiniteCanvas.getScene() != null) {
          onSceneChanged(null, infiniteCanvas.getScene());
        }
      }
    }
    return infiniteCanvas;
  }
示例#2
0
 /**
  * Returns the {@link Scene} in which the {@link InfiniteCanvas} of this {@link FXViewer} is
  * displayed.
  *
  * @return The {@link Scene} in which the {@link InfiniteCanvas} of this {@link FXViewer} is
  *     displayed.
  */
 public Scene getScene() {
   return infiniteCanvas.getScene();
 }