Java Code Examples for javafx.scene.layout.Pane#setTranslateX()

The following examples show how to use javafx.scene.layout.Pane#setTranslateX() . 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: SpaceLevel.java    From FXGLGames with MIT License 5 votes vote down vote up
public SpaceLevel() {
    Rectangle bg = new Rectangle(getAppWidth() - 20, 200, Color.color(0, 0, 0, 0.6));
    bg.setArcWidth(25);
    bg.setArcHeight(25);
    bg.setStroke(Color.color(0.1, 0.2, 0.86, 0.76));
    bg.setStrokeWidth(3);

    storyPane.setTranslateX(10);
    storyPane.setTranslateY(25);

    rootPane = new Pane(bg, storyPane);
    rootPane.setTranslateX(10);
    rootPane.setTranslateY(getAppHeight() - 200);
}
 
Example 2
Source File: WikiProgressBar.java    From pattypan with MIT License 5 votes vote down vote up
private Pane createDot(double number, int translateX) {
  Circle c = new Circle(5);
  c.getStyleClass().add("mw-ui-progressbar-dot" + (isActive(number) ? "-active" : ""));

  Pane p = new Pane(c);
  p.setTranslateX(translateX);
  p.setTranslateY(-2);
  return p;
}
 
Example 3
Source File: SpaceLevel.java    From FXGLGames with MIT License 5 votes vote down vote up
public SpaceLevel() {
    Rectangle bg = new Rectangle(getAppWidth() - 20, 200, Color.color(0, 0, 0, 0.6));
    bg.setArcWidth(25);
    bg.setArcHeight(25);
    bg.setStroke(Color.color(0.1, 0.2, 0.86, 0.76));
    bg.setStrokeWidth(3);

    storyPane.setTranslateX(10);
    storyPane.setTranslateY(25);

    rootPane = new Pane(bg, storyPane);
    rootPane.setTranslateX(10);
    rootPane.setTranslateY(getAppHeight() - 200);
}
 
Example 4
Source File: ShootOFFController.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addNonCameraView(String name, Pane content, CanvasManager canvasManager, boolean select,
		boolean maximizeView) {
	final Tab viewTab = new Tab(name, content);
	cameraTabPane.getTabs().add(viewTab);
	installDebugCoordDisplay(canvasManager);

	if (select) {
		cameraTabPane.getSelectionModel().selectLast();
	}

	// Keep aspect ratio but always match size to the width of the tab
	if (maximizeView) {
		final Runnable translateTabContents = () -> {
			final double widthScale = cameraTabPane.getBoundsInLocal().getWidth()
					/ content.getBoundsInLocal().getWidth();
			content.setScaleX(widthScale);
			content.setScaleY(widthScale);

			// If the arena content is hanging off the bottom of the tab
			// this means the arena is tall and we should scale off the
			// height instead
			if (content.getBoundsInParent().getHeight() > cameraTabPane.getHeight()) {
				final double heightScale = cameraTabPane.getBoundsInLocal().getHeight()
						/ content.getBoundsInLocal().getHeight();
				content.setScaleX(heightScale);
				content.setScaleY(heightScale);
			}

			content.setTranslateX(
					(content.getBoundsInParent().getWidth() - content.getBoundsInLocal().getWidth()) / 2);
			content.setTranslateY(
					(content.getBoundsInParent().getHeight() - content.getBoundsInLocal().getHeight()) / 2);
		};

		// Delay to give auto-placement and calibration a chance to finish
		TimerPool.schedule(translateTabContents, 2000);

		final ChangeListener<? super Number> widthListener = (observable, oldValue, newValue) -> {
			translateTabContents.run();
		};

		content.widthProperty().addListener(widthListener);
		content.heightProperty().addListener(widthListener);

		cameraTabPane.widthProperty().addListener(widthListener);
		cameraTabPane.heightProperty().addListener(widthListener);
	}
}