Exemplo n.º 1
0
 /**
  * Adjusts the visualization to reflect the fisheye state of the node. If the node is in fisheye
  * state, its label will be reduced to the first letter.
  *
  * @param visual The visual of this {@link NodeContentPart}.
  * @param attrs The attributes map that stores the fisheye state of this {@link NodeContentPart}.
  * @param str The label of this {@link NodeContentPart}.
  * @return The adjusted label for this {@link NodeContentPart}.
  */
 protected String refreshFisheye(Group visual, Map<String, Object> attrs, String str) {
   // limit label to first letter when in fisheye mode (and not hovered)
   Object fisheye = attrs.get(ZestProperties.NODE_FISHEYE);
   if (fisheye instanceof Boolean && (Boolean) fisheye) {
     // register mouse event listeners
     visual.addEventHandler(MouseEvent.ANY, mouseHandler);
     if (!visual.isHover()) {
       // limit label to first letter
       // TODO: hide image, hide children/graph icon
       str = str.substring(0, 1);
       restoreZOrder();
     } else {
       if (originalBounds == null) {
         originalBounds = visual.localToScene(visual.getLayoutBounds());
       }
       // TODO: show image, show children/graph icon
       // highlight this node by moving it to the front
       List<IVisualPart<Node, ? extends Node>> children = getParent().getChildren();
       originalIndex = children.indexOf(this); // restore later
       getParent().reorderChild(this, children.size() - 1);
       visual.toFront();
     }
   } else {
     // TODO: show image, show children/graph icon
     restoreZOrder();
     visual.removeEventHandler(MouseEvent.ANY, mouseHandler);
   }
   return str;
 }
  private void adjustWorkspace() {
    final Bounds backgroundBounds, extensionBounds;

    final Object userSceneGraph;
    if (fxomDocument == null) {
      userSceneGraph = null;
    } else {
      userSceneGraph = fxomDocument.getSceneGraphRoot();
    }
    if ((userSceneGraph instanceof Node) && (layoutException == null)) {
      final Node rootNode = (Node) userSceneGraph;

      final Bounds rootBounds = rootNode.getLayoutBounds();

      if (rootBounds.isEmpty()
          || (rootBounds.getWidth() == 0.0)
          || (rootBounds.getHeight() == 0.0)) {
        backgroundBounds = new BoundingBox(0.0, 0.0, 0.0, 0.0);
        extensionBounds = new BoundingBox(0.0, 0.0, 0.0, 0.0);
      } else {
        final double scale;
        if ((rootBounds.getDepth() > 0) && autoResize3DContent) {
          // Content is 3D
          final double scaleX = AUTORESIZE_SIZE / rootBounds.getWidth();
          final double scaleY = AUTORESIZE_SIZE / rootBounds.getHeight();
          final double scaleZ = AUTORESIZE_SIZE / rootBounds.getDepth();
          scale = Math.min(scaleX, Math.min(scaleY, scaleZ));
        } else {
          scale = 1.0;
        }
        contentGroup.setScaleX(scale);
        contentGroup.setScaleY(scale);
        contentGroup.setScaleZ(scale);

        final Bounds contentBounds = rootNode.localToParent(rootBounds);
        backgroundBounds =
            new BoundingBox(
                0.0,
                0.0,
                contentBounds.getMinX() + contentBounds.getWidth(),
                contentBounds.getMinY() + contentBounds.getHeight());

        final Bounds unclippedRootBounds = computeUnclippedBounds(rootNode);
        assert unclippedRootBounds.getHeight() != 0.0;
        assert unclippedRootBounds.getWidth() != 0.0;
        assert rootNode.getParent() == contentGroup;

        final Bounds unclippedContentBounds = rootNode.localToParent(unclippedRootBounds);
        extensionBounds = computeExtensionBounds(backgroundBounds, unclippedContentBounds);
      }
    } else {
      backgroundBounds = new BoundingBox(0.0, 0.0, 320.0, 150.0);
      extensionBounds = new BoundingBox(0.0, 0.0, 0.0, 0.0);
    }

    backgroundPane.setPrefWidth(backgroundBounds.getWidth());
    backgroundPane.setPrefHeight(backgroundBounds.getHeight());
    extensionRect.setX(extensionBounds.getMinX());
    extensionRect.setY(extensionBounds.getMinY());
    extensionRect.setWidth(extensionBounds.getWidth());
    extensionRect.setHeight(extensionBounds.getHeight());

    contentSubScene.setWidth(contentGroup.getLayoutBounds().getWidth());
    contentSubScene.setHeight(contentGroup.getLayoutBounds().getHeight());
  }