예제 #1
0
파일: FXViewer.java 프로젝트: tao-tao/gef4
  /**
   * 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
파일: FXViewer.java 프로젝트: rhajamor/gef4
 @Override
 public void setRootPart(IRootPart<Node> editpart) {
   super.setRootPart(editpart);
   if (editpart != null) {
     canvas.setScene(createScene((Parent) editpart.getVisual()));
   } else {
     canvas.setScene(null);
   }
 }