Java Code Examples for javafx.geometry.Bounds

The following examples show how to use javafx.geometry.Bounds. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: phoebus   Source File: TextUtils.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/** Compute the preferred size for a text
 *
 *  <p>Must be called on the UI thread,
 *  because it's using one shared text helper.
 *
 *  @param font Font
 *  @param text Text
 *  @return Width, height
 */
public static Dimension2D computeTextSize(final Font font, final String text)
{
    // com.sun.javafx.scene.control.skin.Utils contains related code,
    // but is private
    
    // Unclear if order of setting text, font, spacing matters;
    // copied from skin.Utils
    helper.setText(text);
    helper.setFont(font);
    // With default line spacing of 0.0,
    // height of multi-line text is too small...
    helper.setLineSpacing(3);

    final Bounds measure = helper.getLayoutBounds();
    return new Dimension2D(measure.getWidth(), measure.getHeight());
}
 
Example 2
Source Project: JFoenix   Source File: JFXTooltip.java    License: Apache License 2.0 6 votes vote down vote up
public void showOnAnchors(Node ownerNode, double anchorX, double anchorY) {
    hiding = false;
    final Bounds sceneBounds = ownerNode.localToScene(ownerNode.getBoundsInLocal());
    if (isShowing()) {
        animation.setOnFinished(null);
        animation.reverseAndContinue();
        anchorX += ownerX(ownerNode, sceneBounds);
        anchorY += ownerY(ownerNode, sceneBounds);
        setAnchorX(getUpdatedAnchorX(anchorX));
        setAnchorY(getUpdatedAnchorY(anchorY));
    } else {
        anchorX += ownerX(ownerNode, sceneBounds);
        anchorY += ownerY(ownerNode, sceneBounds);
        super.show(ownerNode, anchorX, anchorY);
    }
}
 
Example 3
Source Project: chart-fx   Source File: Zoomer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * take a snapshot of present view (needed for scroll zoom interactor
 */
private void makeSnapshotOfView() {
    final Bounds bounds = getChart().getBoundsInLocal();
    final double minX = bounds.getMinX();
    final double minY = bounds.getMinY();
    final double maxX = bounds.getMaxX();
    final double maxY = bounds.getMaxY();

    zoomRectangle.setX(bounds.getMinX());
    zoomRectangle.setY(bounds.getMinY());
    zoomRectangle.setWidth(maxX - minX);
    zoomRectangle.setHeight(maxY - minY);

    pushCurrentZoomWindows();
    performZoom(getZoomDataWindows(), true);
    zoomRectangle.setVisible(false);
}
 
Example 4
Source Project: marathonv5   Source File: RFXComponentTest.java    License: Apache License 2.0 6 votes vote down vote up
protected Point2D getPoint(TreeTableView<?> treeTableView, int rowIndex, int columnIndex) {
    Set<Node> treeTableRowCell = treeTableView.lookupAll(".tree-table-row-cell");
    TreeTableRow<?> row = null;
    for (Node tableRow : treeTableRowCell) {
        TreeTableRow<?> r = (TreeTableRow<?>) tableRow;
        if (r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".tree-table-cell");
    for (Node node : cells) {
        TreeTableCell<?, ?> cell = (TreeTableCell<?, ?>) node;
        if (treeTableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
Example 5
Source Project: ShootOFF   Source File: CanvasManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Bounds translateCameraToCanvas(Bounds bounds) {
	if (config.getDisplayWidth() == cameraManager.getFeedWidth()
			&& config.getDisplayHeight() == cameraManager.getFeedHeight())
		return bounds;

	final double scaleX = (double) config.getDisplayWidth() / (double) cameraManager.getFeedWidth();
	final double scaleY = (double) config.getDisplayHeight() / (double) cameraManager.getFeedHeight();

	final double minX = (bounds.getMinX() * scaleX);
	final double minY = (bounds.getMinY() * scaleY);
	final double width = (bounds.getWidth() * scaleX);
	final double height = (bounds.getHeight() * scaleY);

	logger.trace("translateCameraToCanvas {} {} {} {} - {} {} {} {}", bounds.getMinX(), bounds.getMinY(),
			bounds.getWidth(), bounds.getHeight(), minX, minY, width, height);

	return new BoundingBox(minX, minY, width, height);
}
 
Example 6
Source Project: ShootOFF   Source File: PerspectiveManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
public PerspectiveManager(Bounds arenaBounds, Dimension2D feedDims, Dimension2D paperBounds,
		Dimension2D projectorRes) {
	this(arenaBounds);
	setCameraFeedSize((int) feedDims.getWidth(), (int) feedDims.getHeight());
	this.setProjectorResolution(projectorRes);

	setProjectionSizeFromLetterPaperPixels(paperBounds);

	if (cameraDistance == -1)
		cameraDistance = DEFAULT_SHOOTER_DISTANCE;
	if (shooterDistance == -1)
		shooterDistance = DEFAULT_SHOOTER_DISTANCE;

	calculateRealWorldSize();

}
 
Example 7
Source Project: gef   Source File: InfiniteCanvas.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Ensures that the specified child {@link Node} is visible to the user by
 * scrolling to its position. The effect and style of the node are taken
 * into consideration. After revealing a node, it will be fully visible if
 * it fits within the current viewport bounds.
 * <p>
 * When the child node's left side is left to the viewport, it will touch
 * the left border of the viewport after revealing. When the child node's
 * right side is right to the viewport, it will touch the right border of
 * the viewport after revealing. When the child node's top side is above the
 * viewport, it will touch the top border of the viewport after revealing.
 * When the child node's bottom side is below the viewport, it will touch
 * the bottom border of the viewport after revealing.
 * <p>
 * The top and left sides have preference over the bottom and right sides,
 * i.e. when the top side is aligned with the viewport, the bottom side will
 * not be aligned, and when the left side is aligned with the viewport, the
 * right side will not be aligned.
 *
 * @param child
 *            The child {@link Node} to reveal.
 */
public void reveal(Node child) {
	Bounds bounds = sceneToLocal(
			child.localToScene(child.getBoundsInLocal()));
	if (bounds.getHeight() <= getHeight()) {
		if (bounds.getMinY() < 0) {
			setVerticalScrollOffset(
					getVerticalScrollOffset() - bounds.getMinY());
		} else if (bounds.getMaxY() > getHeight()) {
			setVerticalScrollOffset(getVerticalScrollOffset() + getHeight()
					- bounds.getMaxY());
		}
	}
	if (bounds.getWidth() <= getWidth()) {
		if (bounds.getMinX() < 0) {
			setHorizontalScrollOffset(
					getHorizontalScrollOffset() - bounds.getMinX());
		} else if (bounds.getMaxX() > getWidth()) {
			setHorizontalScrollOffset(getHorizontalScrollOffset()
					+ getWidth() - bounds.getMaxX());
		}
	}
}
 
Example 8
Source Project: chart-fx   Source File: MouseUtilsTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void mouseOutsideBoundaryBoxDistanceTests() {
    final Bounds screenBounds = new BoundingBox(/* minX */ 0.0, /* minY */ 0.0, /* width */ 10.0, /* height */ 5.0);

    // mouse inside
    assertEquals(0, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(1, 1)));
    assertEquals(0, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(0, 0)));
    assertEquals(0, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(10, 5)));

    // mouse outside
    assertEquals(2, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(-2.0, 0)));
    assertEquals(2, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(12.0, 0)));
    assertEquals(2, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(0.0, -2)));
    assertEquals(2, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(0.0, 7)));

    // test Manhattan-Norm
    assertEquals(4, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(-2.0, 9)));
    assertEquals(4, MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, new Point2D(-4.0, 7)));
}
 
Example 9
@Override
public void paint(GraphicsContext graphics, CircuitState circuitState) {
	GuiUtils.drawName(graphics, this, getProperties().getValue(Properties.LABEL_LOCATION));
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	GuiUtils.drawShape(graphics::fillRect, this);
	GuiUtils.drawShape(graphics::strokeRect, this);
	
	graphics.setFont(GuiUtils.getFont(16, true));
	Bounds bounds = GuiUtils.getBounds(graphics.getFont(), "÷");
	graphics.setFill(Color.BLACK);
	graphics.fillText("÷",
	                  getScreenX() + (getScreenWidth() - bounds.getWidth()) * 0.5,
	                  getScreenY() + (getScreenHeight() + bounds.getHeight()) * 0.45);
}
 
Example 10
Source Project: ShootOFF   Source File: TargetView.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void addResizeAnchors() {
	final Bounds localBounds = getTargetGroup().getBoundsInLocal();
	final double horizontalMiddle = localBounds.getMinX() + (localBounds.getWidth() / 2) - (ANCHOR_WIDTH / 2);
	final double verticleMiddle = localBounds.getMinY() + (localBounds.getHeight() / 2) - (ANCHOR_HEIGHT / 2);

	// Top left
	addAnchor(localBounds.getMinX(), localBounds.getMinY());
	// Top middle
	addAnchor(horizontalMiddle, localBounds.getMinY());
	// Top right
	addAnchor(localBounds.getMaxX() - ANCHOR_WIDTH, localBounds.getMinY());
	// Middle left
	addAnchor(localBounds.getMinX(), verticleMiddle);
	// Middle right
	addAnchor(localBounds.getMaxX() - ANCHOR_WIDTH, verticleMiddle);
	// Bottom left
	addAnchor(localBounds.getMinX(), localBounds.getMaxY() - ANCHOR_HEIGHT);
	// Bottom middle
	addAnchor(horizontalMiddle, localBounds.getMaxY() - ANCHOR_HEIGHT);
	// Bottom right
	addAnchor(localBounds.getMaxX() - ANCHOR_WIDTH, localBounds.getMaxY() - ANCHOR_HEIGHT);
}
 
Example 11
Source Project: ShootOFF   Source File: ShotDetectionTestor.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected List<DisplayShot> findShots(String videoPath, Optional<Bounds> projectionBounds, MockCanvasManager mockManager,
		Configuration config, boolean[][] sectorStatuses) {
	
	File videoFile = new File(ShotDetectionTestor.class.getResource(videoPath).getFile());
	MockCameraManager cameraManager = new MockCameraManager(new MockCamera(videoFile), mockManager, 
			sectorStatuses, projectionBounds, this);
	
	cameraManager.start();

	try {
		synchronized (processingLock) {
			processingLock.wait();
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	return mockManager.getShots();
}
 
Example 12
@Test
public void single_clicking_outside_of_selected_text_does_not_trigger_new_selection_finished()
        throws InterruptedException, ExecutionException {
    // setup
    interact(() -> {
        area.replaceText(firstParagraph + "\n" + "this is the selected text");
        area.selectRange(1, 0, 2, -1);
    });

    SimpleIntegerProperty i = new SimpleIntegerProperty(0);
    area.setOnNewSelectionDragFinished(e -> i.set(1));

    Bounds bounds = asyncFx(
            () -> area.getCharacterBoundsOnScreen(firstWord.length(), firstWord.length() + 1).get())
            .get();

    moveTo(bounds).clickOn(PRIMARY);

    assertEquals(0, i.get());
}
 
Example 13
Source Project: gef   Source File: GraphLayoutBehavior.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Determines the layout bounds for the graph.
 *
 * @return The bounds used to layout the graph.
 */
protected Rectangle computeLayoutBounds() {
	Rectangle newBounds = new Rectangle();
	if (nestingVisual != null) {
		// nested graph uses layout bounds of nesting node
		Bounds layoutBounds = nestingVisual.getLayoutBounds();
		newBounds = new Rectangle(0, 0, layoutBounds.getWidth() / NodePart.DEFAULT_NESTED_CHILDREN_ZOOM_FACTOR,
				layoutBounds.getHeight() / NodePart.DEFAULT_NESTED_CHILDREN_ZOOM_FACTOR);
	} else {
		// root graph uses infinite canvas bounds
		InfiniteCanvas canvas = getInfiniteCanvas();
		// XXX: Use minimum of window size and canvas size, because the
		// canvas size is invalid when its scene is changed.
		double windowWidth = canvas.getScene().getWindow().getWidth();
		double windowHeight = canvas.getScene().getWindow().getHeight();
		newBounds = new Rectangle(0, 0,
				Double.isFinite(windowWidth) ? Math.min(canvas.getWidth(), windowWidth) : canvas.getWidth(),
				Double.isFinite(windowHeight) ? Math.min(canvas.getHeight(), windowHeight) : canvas.getHeight());
	}
	return newBounds;
}
 
Example 14
/**
 * Compute the needed clip for stage's shadow border
 *
 * @param newBounds
 * @param shadowVisible
 */
void setShadowClip(Bounds newBounds) {
    external.relocate(
            newBounds.getMinX() - SHADOW_WIDTH,
            newBounds.getMinY() - SHADOW_WIDTH
    );
    internal.setX(SHADOW_WIDTH);
    internal.setY(SHADOW_WIDTH);
    internal.setWidth(newBounds.getWidth());
    internal.setHeight(newBounds.getHeight());
    internal.setArcWidth(shadowRectangle.getArcWidth());    // shadowRectangle CSS cannot be applied on this
    internal.setArcHeight(shadowRectangle.getArcHeight());

    external.setWidth(newBounds.getWidth() + SHADOW_WIDTH * 2);
    external.setHeight(newBounds.getHeight() + SHADOW_WIDTH * 2);
    Shape clip = Shape.subtract(external, internal);
    shadowRectangle.setClip(clip);

}
 
Example 15
Source Project: RichTextFX   Source File: ParagraphText.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Bounds getRangeBoundsOnScreen(int from, int to) {
    layout(); // ensure layout, is a no-op if not dirty
    PathElement[] rangeShape = getRangeShapeSafely(from, to);

    Path p = new Path();
    p.setManaged(false);
    p.setLayoutX(getInsets().getLeft());
    p.setLayoutY(getInsets().getTop());

    getChildren().add(p);

    p.getElements().setAll(rangeShape);
    Bounds localBounds = p.getBoundsInLocal();
    Bounds rangeBoundsOnScreen = p.localToScreen(localBounds);

    getChildren().remove(p);

    return rangeBoundsOnScreen;
}
 
Example 16
Source Project: paintera   Source File: OpenDialogMenu.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static EventHandler<KeyEvent> keyPressedHandler(
		final PainteraGateway gateway,
		final Node target,
		Consumer<Exception> exceptionHandler,
		Predicate<KeyEvent> check,
		final String menuText,
		final PainteraBaseView viewer,
		final Supplier<String> projectDirectory,
		final DoubleSupplier x,
		final DoubleSupplier y)
{

	return event -> {
		if (check.test(event))
		{
			event.consume();
			OpenDialogMenu m = gateway.openDialogMenu();
			Optional<ContextMenu> cm = m.getContextMenu(menuText, viewer, projectDirectory, exceptionHandler);
			Bounds bounds = target.localToScreen(target.getBoundsInLocal());
			cm.ifPresent(menu -> menu.show(target, x.getAsDouble() + bounds.getMinX(), y.getAsDouble() + bounds.getMinY()));
		}
	};

}
 
Example 17
Source Project: OpenLabeler   Source File: PolygonItem.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ReadOnlyDoubleProperty getMinXProperty() {
   if (minXProperty == null) {
      minXProperty = new SimpleDoubleProperty();
      minXProperty.bind(EasyBind.map(boundsInLocalProperty(), Bounds::getMinX));
   }
   return minXProperty;
}
 
Example 18
Source Project: RichTextFX   Source File: HitTests.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void clicking_character_should_move_caret_to_that_position()
        throws InterruptedException, ExecutionException {
    int start = area.getAbsolutePosition(3, 8);
    Bounds b = asyncFx(
            () -> area.getCharacterBoundsOnScreen(start, start + 1).get())
            .get();
    moveTo(b).clickOn(PRIMARY);
    assertEquals(start, area.getCaretPosition());
}
 
Example 19
Source Project: OpenLabeler   Source File: PolygonItem.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ReadOnlyDoubleProperty getMaxXProperty() {
   if (maxXProperty == null) {
      maxXProperty = new SimpleDoubleProperty();
      maxXProperty.bind(EasyBind.map(boundsInLocalProperty(), Bounds::getMaxX));
   }
   return maxXProperty;
}
 
Example 20
Source Project: OpenLabeler   Source File: PolygonItem.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ReadOnlyDoubleProperty getMaxYProperty() {
   if (maxYProperty == null) {
      maxYProperty = new SimpleDoubleProperty();
      maxYProperty.bind(EasyBind.map(boundsInLocalProperty(), Bounds::getMaxY));
   }
   return maxYProperty;
}
 
Example 21
Source Project: gef   Source File: NodeUtils.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the layout-bounds of the given {@link Node}, which might be
 * adjusted to ensure that it exactly fits the visualization.
 *
 * @param node
 *            The {@link Node} to retrieve the (corrected) layout-bounds of.
 * @return A {@link Rectangle} representing the (corrected) layout-bounds.
 */
public static Rectangle getShapeBounds(Node node) {
	Bounds layoutBounds = node.getLayoutBounds();
	// XXX: Polygons don't paint exactly to their layout bounds but remain
	// 0.5 pixels short in case they have a stroke and stroke type is
	// CENTERED or OUTSIDE (see
	// https://bugs.openjdk.java.net/browse/JDK-8145499).
	double offset = 0;
	if (node instanceof Polygon && ((Polygon) node).getStroke() != null
			&& ((Polygon) node).getStrokeType() != StrokeType.INSIDE) {
		offset = 0.5;
	}
	return FX2Geometry.toRectangle(layoutBounds).shrink(offset, offset,
			offset, offset);
}
 
Example 22
Source Project: OpenLabeler   Source File: AppUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Bounds insetBounds(Bounds bounds, double amount) {
   return new BoundingBox(
         bounds.getMinX() + amount,
         bounds.getMinY() + amount,
         bounds.getMaxX() - amount,
         bounds.getMaxY() - amount);
}
 
Example 23
Source Project: marathonv5   Source File: JavaFXTreeTableViewCellElement.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Point2D _getMidpoint() {
    Node cell = getPseudoComponent();
    Bounds boundsInParent = cell.getBoundsInParent();
    double x = boundsInParent.getWidth() / 2;
    double y = boundsInParent.getHeight() / 2;
    return cell.getParent().localToParent(cell.localToParent(x, y));
}
 
Example 24
Source Project: JFoenix   Source File: JFXTooltip.java    License: Apache License 2.0 5 votes vote down vote up
private double getHPosForNode(Bounds sceneBounds) {
    double hx = -margin;
    switch (pos.getHpos()) {
        case CENTER:
            hx = (sceneBounds.getWidth() / 2);
            break;
        case RIGHT:
            hx = sceneBounds.getWidth() + margin;
            break;
    }
    return hx;
}
 
Example 25
Source Project: gef   Source File: NodeLabelPart.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Point computeLabelPosition() {
	IVisualPart<? extends javafx.scene.Node> firstAnchorage = getFirstAnchorage();
	// determine bounds of anchorage visual
	Rectangle anchorageBounds = NodeUtils
			.sceneToLocal(getVisual().getParent(), NodeUtils.localToScene(firstAnchorage.getVisual(),
					FX2Geometry.toRectangle(firstAnchorage.getVisual().getLayoutBounds())))
			.getBounds();
	// determine text bounds
	Bounds textBounds = getVisual().getLayoutBounds();
	// TODO: compute better label position
	return new Point(anchorageBounds.getX() + anchorageBounds.getWidth() / 2 - textBounds.getWidth() / 2,
			anchorageBounds.getY() + anchorageBounds.getHeight());
}
 
Example 26
Source Project: latexdraw   Source File: TestViewTriangle.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
@Override
public void testOnTranslateX() {
	final Bounds before = view.getBorder().getBoundsInParent();
	model.translate(17d, 0d);
	view.getBorder().setTranslateX(-17d);
	assertEquals(before, view.getBorder().getBoundsInParent());
}
 
Example 27
@Override
protected void layoutLayer() {
    for (Pair<MapPoint, Node> candidate : points) {
        MapPoint point = candidate.getKey();
        Node icon = candidate.getValue();
        Bounds bounds = icon.getBoundsInParent();
        Point2D mapPoint = baseMap.getMapPoint(point.getLatitude(), point.getLongitude());
        // translate icon so marker base point is at the center
        icon.setTranslateX(mapPoint.getX() - bounds.getWidth() / 2);
        icon.setTranslateY(mapPoint.getY() - bounds.getHeight() / 2 - 10);
    }
}
 
Example 28
Source Project: mars-sim   Source File: Story.java    License: GNU General Public License v3.0 5 votes vote down vote up
/** @return content wrapped in a vertical, pannable scroll pane. */
private ScrollPane makeScrollable(final Control content) {
  final ScrollPane scroll = new ScrollPane();
  scroll.setContent(content);
  scroll.setPannable(true);
  scroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
  scroll.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() {
    @Override public void changed(ObservableValue<? extends Bounds> observableValue, Bounds oldBounds, Bounds newBounds) {
      content.setPrefWidth(newBounds.getWidth() - 10);
    }
  });

  return scroll;
}
 
Example 29
Source Project: gef   Source File: LayeredRootPart.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Group doCreateVisual() {
	contentLayer = createContentLayer();
	/*
	 * XXX: The following is a workaround to ensure that visuals do not
	 * disappear when the content layer is scaled (zooming). This is,
	 * because computeBounds() on the (lazy) bounds-in-local property of the
	 * content layer is not performed when the property is invalidated.
	 *
	 * We could register an invalidation listener that explicitly triggers
	 * computeBounds() (by calling get() on the bounds-in-local property),
	 * to fix the problems. However, this would be invoked too often.
	 *
	 * Instead, we register a dummy change listener (that actually does not
	 * do anything) to fix the problem by means of a side effect. This is
	 * sufficient to fix the problems, because the JavaFX ExpressionHelper
	 * (which is responsible of firing the change events) calls getValue()
	 * on the observable when a change event is to be fired (which is
	 * triggered when at least one change listener is registered). The
	 * getValue() call will in turn recompute the bounds (by calling get()
	 * on the bounds-in-local property, which triggers a call to
	 * computeBounds()). If no listener is registered, the bounds-in-local
	 * value will not be recomputed (computeBounds() will not be called)
	 * even if invalidated.
	 */
	contentLayer.boundsInLocalProperty()
			.addListener(new ChangeListener<Bounds>() {
				@Override
				public void changed(
						ObservableValue<? extends Bounds> observable,
						Bounds oldValue, Bounds newValue) {
				}
			});

	feedbackLayer = createFeedbackLayer();

	handleLayer = createHandleLayer();

	return new Group(contentLayer, feedbackLayer, handleLayer);
}
 
Example 30
Source Project: marathonv5   Source File: FXEventQueueDevice.java    License: Apache License 2.0 5 votes vote down vote up
private void checkHit(Node child, double x, double y, List<Node> hits, String indent) {
    Bounds boundsInParent = child.getBoundsInParent();
    if (boundsInParent.contains(x, y)) {
        hits.add(child);
        if (!(child instanceof Parent)) {
            return;
        }
        ObservableList<Node> childrenUnmodifiable = ((Parent) child).getChildrenUnmodifiable();
        for (Node node : childrenUnmodifiable) {
            checkHit(node, x, y, hits, "    " + indent);
        }
    }
}