use of javafx.scene.shape.Rectangle in project blue by kunstmusik.
the class BSBObjectViewHolder method resizeDown.
protected void resizeDown(MouseEvent evt) {
Rectangle r = (Rectangle) evt.getSource();
Point2D curPoint = r.localToParent(evt.getX(), evt.getY());
curPoint = localToParent(curPoint);
GridSettings grid = selection.getGridSettings();
int diff = (int) (curPoint.getY() - mouseOrigin.getY());
int newHeight = (int) originBounds.getHeight() + diff;
if (grid.isSnapEnabled()) {
double top = getLayoutY();
double bottom = top + newHeight;
int h = grid.getHeight();
newHeight = (int) ((Math.round(bottom / h) * h) - top);
}
newHeight = Math.max(newHeight, rView.getWidgetMinimumHeight());
if (newHeight != rView.getWidgetHeight()) {
rView.setWidgetHeight(newHeight);
}
evt.consume();
}
use of javafx.scene.shape.Rectangle in project blue by kunstmusik.
the class BSBObjectViewHolder method setupResizeHandles.
private void setupResizeHandles(Rectangle rect, BSBEditSelection selection) {
if (!(bsbObjectView instanceof ResizeableView)) {
return;
}
BooleanBinding visibleBinding = Bindings.createBooleanBinding(() -> rect.isVisible() && selection.selection.size() == 1, rect.visibleProperty(), selection.selection);
rView = (ResizeableView) bsbObjectView;
if (rView.canResizeWidgetWidth()) {
Rectangle resizeLeftHandle = new Rectangle(5, 5);
resizeLeftHandle.setManaged(false);
resizeLeftHandle.setFill(Color.rgb(0, 255, 0));
resizeLeftHandle.setLayoutX(-2);
resizeLeftHandle.yProperty().bind(rect.heightProperty().divide(2).subtract(2));
resizeLeftHandle.visibleProperty().bind(visibleBinding);
resizeLeftHandle.setCursor(Cursor.W_RESIZE);
resizeLeftHandle.setOnMousePressed(evt -> recordMouseOrigin(evt));
resizeLeftHandle.setOnMouseDragged(evt -> resizeLeft(evt));
Rectangle resizeRightHandle = new Rectangle(5, 5);
resizeRightHandle.setManaged(false);
resizeRightHandle.setFill(Color.rgb(0, 255, 0));
resizeRightHandle.xProperty().bind(rect.widthProperty().subtract(2));
resizeRightHandle.yProperty().bind(rect.heightProperty().divide(2).subtract(2));
resizeRightHandle.visibleProperty().bind(visibleBinding);
resizeRightHandle.setCursor(Cursor.E_RESIZE);
resizeRightHandle.setOnMousePressed(evt -> recordMouseOrigin(evt));
resizeRightHandle.setOnMouseDragged(evt -> resizeRight(evt));
getChildren().addAll(resizeLeftHandle, resizeRightHandle);
}
if (rView.canResizeWidgetHeight()) {
Rectangle resizeTopHandle = new Rectangle(5, 5);
resizeTopHandle.setManaged(false);
resizeTopHandle.setFill(Color.rgb(0, 255, 0));
resizeTopHandle.setLayoutY(-2);
resizeTopHandle.xProperty().bind(rect.widthProperty().divide(2).subtract(2));
resizeTopHandle.visibleProperty().bind(visibleBinding);
resizeTopHandle.setCursor(Cursor.N_RESIZE);
resizeTopHandle.setOnMousePressed(evt -> recordMouseOrigin(evt));
resizeTopHandle.setOnMouseDragged(evt -> resizeUp(evt));
Rectangle resizeBottomHandle = new Rectangle(5, 5);
resizeBottomHandle.setManaged(false);
resizeBottomHandle.setFill(Color.rgb(0, 255, 0));
resizeBottomHandle.yProperty().bind(rect.heightProperty().subtract(2));
resizeBottomHandle.xProperty().bind(rect.widthProperty().divide(2).subtract(2));
resizeBottomHandle.visibleProperty().bind(visibleBinding);
resizeBottomHandle.setCursor(Cursor.S_RESIZE);
resizeBottomHandle.setOnMousePressed(evt -> recordMouseOrigin(evt));
resizeBottomHandle.setOnMouseDragged(evt -> resizeDown(evt));
getChildren().addAll(resizeTopHandle, resizeBottomHandle);
}
}
use of javafx.scene.shape.Rectangle in project contentment by GeePawHill.
the class AnimationTimerExperiment method start.
@Override
public void start(final Stage primaryStage) {
for (int i = 0; i < STAR_COUNT; i++) {
nodes[i] = new Rectangle(1, 1, Color.WHITE);
angles[i] = 2.0 * Math.PI * random.nextDouble();
start[i] = random.nextInt(2000000000);
}
final Scene scene = new Scene(new Group(nodes), 800, 600, Color.BLACK);
primaryStage.setScene(scene);
primaryStage.show();
new AnimationTimer() {
@Override
public void handle(long now) {
final double width = 0.5 * primaryStage.getWidth();
final double height = 0.5 * primaryStage.getHeight();
final double radius = Math.sqrt(2) * Math.max(width, height);
for (int i = 0; i < STAR_COUNT; i++) {
final Node node = nodes[i];
final double angle = angles[i];
final long t = (now - start[i]) % 2000000000;
final double d = t * radius / 2000000000.0;
node.setTranslateX(Math.cos(angle) * d + width);
node.setTranslateY(Math.sin(angle) * d + height);
}
}
}.start();
}
use of javafx.scene.shape.Rectangle in project honest-profiler by jvm-profiling-tools.
the class GraphicalShareTableCell method updateItem.
@Override
protected void updateItem(Double share, boolean empty) {
super.updateItem(share, empty);
if (empty || share == null) {
setText(null);
setGraphic(null);
return;
}
setGraphic(new Rectangle(share * getWidth(), HEIGHT, COLOR));
}
use of javafx.scene.shape.Rectangle in project Malai by arnobl.
the class MoveShape method testCanCancelDnDWithObsList.
@Test
public void testCanCancelDnDWithObsList() {
new NodeBinder<>(MoveShape.class, new DnD(true, true), instrument).map(i -> new MoveShape((Rectangle) i.getSrcObject().get())).on(widget1.getChildren()).first((c, i) -> Platform.runLater(() -> i.getSrcObject().get().requestFocus())).then((c, i) -> c.setCoord(((Rectangle) i.getSrcObject().get()).getX() + (i.getEndScenePt().getX() - i.getSrcScenePoint().getX()), ((Rectangle) i.getSrcObject().get()).getY() + (i.getEndScenePt().getY() - i.getSrcScenePoint().getY()))).end((c, i) -> fail("")).exec().bind();
Rectangle rec2 = new Rectangle(200d, 200d, 70d, 50d);
Platform.runLater(() -> widget1.getChildren().addAll(rec2));
WaitForAsyncUtils.waitForFxEvents();
drag(rec2).moveBy(100, 100).type(KeyCode.ESCAPE).sleep(50L);
assertEquals(0, instrument.exec.get());
}
Aggregations