Java Code Examples for javafx.scene.layout.Region#prefHeightProperty()

The following examples show how to use javafx.scene.layout.Region#prefHeightProperty() . 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: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();
	final DoubleBinding halfHeightProperty = heightProperty.divide(2);

	final Rectangle resizeHandleE = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2));
	resizeHandleE.yProperty().bind(yProperty.add(halfHeightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleE, mouseLocation, Cursor.E_RESIZE);

	resizeHandleE.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragEast(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleE;
}
 
Example 2
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleSE = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2));
	resizeHandleSE.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSE, mouseLocation, Cursor.SE_RESIZE);

	resizeHandleSE.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragEast(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSE;
}
 
Example 3
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty();
	final DoubleBinding halfWidthProperty = widthProperty.divide(2);
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleS = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleS.xProperty().bind(xProperty.add(halfWidthProperty).subtract(handleRadius / 2));
	resizeHandleS.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleS, mouseLocation, Cursor.S_RESIZE);

	resizeHandleS.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleS;
}
 
Example 4
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleSW = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSW.xProperty().bind(xProperty.subtract(handleRadius / 2));
	resizeHandleSW.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSW, mouseLocation, Cursor.SW_RESIZE);

	resizeHandleSW.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragWest(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSW;
}
 
Example 5
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();
	final DoubleBinding halfHeightProperty = heightProperty.divide(2);

	final Rectangle resizeHandleW = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleW.xProperty().bind(xProperty.subtract(handleRadius / 2));
	resizeHandleW.yProperty().bind(yProperty.add(halfHeightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleW, mouseLocation, Cursor.W_RESIZE);

	resizeHandleW.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragWest(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleW;
}