javafx.geometry.Bounds Java Examples

The following examples show how to use javafx.geometry.Bounds. 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 check out the related API usage on the sidebar.
Example #1
Source File: OpenDialogMenu.java    From paintera with GNU General Public License v2.0 7 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 #2
Source File: TargetView.java    From ShootOFF with 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 #3
Source File: Zoomer.java    From chart-fx with 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 File: RFXComponentTest.java    From marathonv5 with 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 File: JFXTooltip.java    From JFoenix with 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 #6
Source File: CanvasManager.java    From ShootOFF with 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 #7
Source File: PerspectiveManager.java    From ShootOFF with 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 #8
Source File: InfiniteCanvas.java    From gef with 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 #9
Source File: TextUtils.java    From phoebus with 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 #10
Source File: MouseUtilsTests.java    From chart-fx with 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 #11
Source File: DividerPeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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 #12
Source File: ParagraphText.java    From RichTextFX with 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 #13
Source File: Undecorator.java    From DevToolBox with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #14
Source File: ShotDetectionTestor.java    From ShootOFF with 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 #15
Source File: ClickAndDragTests.java    From RichTextFX with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 #16
Source File: GraphLayoutBehavior.java    From gef with 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 #17
Source File: Story.java    From mars-sim with 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 #18
Source File: JFXSnackbar.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void refreshPopup() {
    if (snackbarContainer == null) {
        return;
    }
    Bounds contentBound = this.getLayoutBounds();
    double offsetX = Math.ceil(snackbarContainer.getWidth() / 2) - Math.ceil(contentBound.getWidth() / 2);
    double offsetY = snackbarContainer.getHeight() - contentBound.getHeight();
    this.setLayoutX(offsetX);
    this.setLayoutY(offsetY);

}
 
Example #19
Source File: FXEventQueueDevice.java    From marathonv5 with 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);
        }
    }
}
 
Example #20
Source File: GraphicsContextImpl.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public java.awt.Dimension getBounds(String s)
{
    Font currentFont = ctx.getFont();
    Text t = new Text(s);
    t.setFont(currentFont);
    Bounds b = t.getLayoutBounds();
    java.awt.Dimension bounds = new java.awt.Dimension((int)b.getWidth(), (int)b.getHeight());
    return bounds;
}
 
Example #21
Source File: DotRecordBasedJavaFxNode.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Applies CSS and returns the calculated bounds for the FX Pane
 *
 * @return Bounds of the JavaFX pane after CSS/layout run.
 */
public Bounds getBounds() {
	Group fxElement = new Group(getFxElement());
	Scene scene = new Scene(fxElement);
	scene.getStylesheets().add(ZestFxRootPart.STYLES_CSS_FILE);
	fxElement.applyCss();
	fxElement.layout();
	return fxElement.getBoundsInParent();
}
 
Example #22
Source File: MyBoxController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public void locateImage(Node region, boolean right) {
    if (!imageCheck.isSelected()) {
        imagePop.hide();
        return;
    }
    Bounds bounds = region.localToScreen(region.getBoundsInLocal());
    double x = right ? (bounds.getMaxX() + 200) : (bounds.getMinX() - 550);
    imagePop.show(region, x, bounds.getMinY() - 50);
    FxmlControl.refreshStyle(imagePop.getOwnerNode().getParent());
}
 
Example #23
Source File: JavaFXTableCellElement.java    From marathonv5 with 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 File: ViewSingleShape.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private Paint getHatchingsFillingPaint(final FillingStyle style) {
	final Bounds bounds = border.getBoundsInParent();

	if(bounds.getWidth() <= 0d || bounds.getHeight() <= 0d) {
		return null;
	}

	final Group hatchings = new Group();
	final double hAngle = model.getHatchingsAngle();

	hatchings.getChildren().add(new Rectangle(bounds.getWidth(), bounds.getHeight(), style.isFilled() ? model.getFillingCol().toJFX() : null));

	final double angle = hAngle > 0d ? hAngle - Math.PI / 2d : hAngle + Math.PI / 2d;

	switch(style) {
		case VLINES, VLINES_PLAIN -> computeHatchings(hatchings, hAngle, bounds.getWidth(), bounds.getHeight());
		case HLINES, HLINES_PLAIN -> computeHatchings(hatchings, angle, bounds.getWidth(), bounds.getHeight());
		case CLINES, CLINES_PLAIN -> {
			computeHatchings(hatchings, hAngle, bounds.getWidth(), bounds.getHeight());
			computeHatchings(hatchings, angle, bounds.getWidth(), bounds.getHeight());
		}
	}

	final WritableImage image = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
	hatchings.snapshot(new SnapshotParameters(), image);
	return new ImagePattern(image, 0, 0, 1, 1, true);
}
 
Example #25
Source File: QueleaProperties.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get the custom projector co-ordinates.
 * <p>
 *
 * @return the co-ordinates.
 */
public Bounds getProjectorCoords() {
    String[] prop = getProperty(projectorCoordsKey, "0,0,0,0").trim().split(",");
    return new BoundingBox(Integer.parseInt(prop[0]),
            Integer.parseInt(prop[1]),
            Integer.parseInt(prop[2]),
            Integer.parseInt(prop[3]));
}
 
Example #26
Source File: CalibrationManager.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
private void configureArenaCamera(CalibrationOption option, Bounds bounds) {
	final Bounds translatedToCameraBounds = calibratingCanvasManager.translateCanvasToCamera(bounds);

	calibratingCanvasManager.setProjectorArena(arenaPane, bounds);
	configureArenaCamera(option);
	calibratingCameraManager.setProjectionBounds(translatedToCameraBounds);
}
 
Example #27
Source File: PolygonItem.java    From OpenLabeler with 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 #28
Source File: CanvasManager.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateBackground(BufferedImage frame, Optional<Bounds> projectionBounds) {
	updateCanvasGroup();

	if (frame == null) {
		background.setX(0);
		background.setY(0);
		background.setImage(null);
		return;
	}

	// Prevent the webcam feed from being refreshed faster than some maximum
	// FPS otherwise we waste CPU cycles converting a frames to show the
	// user and these are cycles we could spend detecting shots. A lower
	// FPS (e.g. ~15) looks perfect fine to a person
	if (System.currentTimeMillis() - lastFrameTime < MINIMUM_FRAME_DELTA)
		return;
	else
		lastFrameTime = System.currentTimeMillis();

	Image img;
	if (projectionBounds.isPresent()) {
		final Bounds translatedBounds = translateCameraToCanvas(projectionBounds.get());
		background.setX(translatedBounds.getMinX());
		background.setY(translatedBounds.getMinY());

		img = SwingFXUtils.toFXImage(
				resize(frame, (int) translatedBounds.getWidth(), (int) translatedBounds.getHeight()), null);
	} else {
		background.setX(0);
		background.setY(0);

		img = SwingFXUtils.toFXImage(resize(frame, config.getDisplayWidth(), config.getDisplayHeight()), null);
	}

	Platform.runLater(() -> background.setImage(img));
}
 
Example #29
Source File: StringTable.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Prompt for column name
 *  @param name Suggested name
 *  @return Name entered by user or <code>null</code>
 */
private String getColumnName(final String name)
{
    final TextInputDialog dialog = new TextInputDialog(name);
    // Position dialog near table
    final Bounds absolute = localToScreen(getBoundsInLocal());
    dialog.setX(absolute.getMinX() + 10);
    dialog.setY(absolute.getMinY() + 10);
    dialog.setTitle(Messages.RenameColumnTitle);
    dialog.setHeaderText(Messages.RenameColumnInfo);
    return dialog.showAndWait().orElse(null);
}
 
Example #30
Source File: InputMethodRequestsObject.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Point2D getTextLocation(int offset) {
    // Method for supporting Pinyin input on Mac.
    // TODO: Apparently only tested on MacOS, so might need more testing.
    //  Doesn't seem to affect any other language input as far as I can tell.
    Optional<Bounds> caretPositionBounds = textArea.getCaretBounds();
    if (caretPositionBounds.isPresent()) {
        Bounds bounds = caretPositionBounds.get();
        return new Point2D(bounds.getMaxX() - 5, bounds.getMaxY());
    }

    throw new NullPointerException();
}