use of javafx.scene.shape.Rectangle in project jphp by jphp-compiler.
the class GamePane method scrollTo.
public void scrollTo(double x, double y) {
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
if (y > area.getPrefHeight() - getPrefHeight()) {
y = area.getPrefHeight() - getPrefHeight();
}
if (x > area.getPrefWidth() - getPrefWidth()) {
x = area.getWidth() - getPrefWidth();
}
area.setClip(new Rectangle(x, y, getPrefWidth(), getPrefHeight()));
area.setLayoutX(-x);
area.setLayoutY(-y);
if (getOnScrollScene() != null) {
getOnScrollScene().handle(new ActionEvent(this, this));
}
}
use of javafx.scene.shape.Rectangle in project JFoenix by jfoenixadmin.
the class JFXListCell method layoutChildren.
@Override
protected void layoutChildren() {
super.layoutChildren();
cellRippler.resizeRelocate(0, 0, getWidth(), getHeight());
double gap = getGap();
if (clip == null) {
clip = new Rectangle(0, gap / 2, getWidth(), getHeight() - gap);
setClip(clip);
} else {
if (gap != 0) {
if (playExpandAnimation || selectionChanged) {
// fake list collapse state
if (playExpandAnimation) {
this.setTranslateY(-gap / 2 + (-gap * (getIndex())));
clip.setY(gap / 2);
clip.setHeight(getHeight() - gap);
gapAnimation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(this.translateYProperty(), 0, Interpolator.EASE_BOTH)));
playExpandAnimation = false;
} else if (selectionChanged) {
clip.setY(0);
clip.setHeight(getHeight());
gapAnimation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(clip.yProperty(), gap / 2, Interpolator.EASE_BOTH), new KeyValue(clip.heightProperty(), getHeight() - gap, Interpolator.EASE_BOTH)));
}
playExpandAnimation = false;
selectionChanged = false;
gapAnimation.play();
} else {
if (gapAnimation != null) {
gapAnimation.stop();
}
this.setTranslateY(0);
clip.setY(gap / 2);
clip.setHeight(getHeight() - gap);
}
} else {
this.setTranslateY(0);
clip.setY(0);
clip.setHeight(getHeight());
}
clip.setX(0);
clip.setWidth(getWidth());
}
if (!getChildren().contains(cellRippler)) {
makeChildrenTransparent();
getChildren().add(0, cellRippler);
cellRippler.rippler.clear();
}
// refresh sublist style class
if (this.getGraphic() != null && this.getGraphic().getStyleClass().contains("sublist-container")) {
this.getStyleClass().add("sublist-item");
} else {
this.getStyleClass().remove("sublist-item");
}
}
use of javafx.scene.shape.Rectangle in project JFoenix by jfoenixadmin.
the class JFXDecorator method initializeContainers.
private void initializeContainers(Node node, boolean fullScreen, boolean max, boolean min) {
buttonsContainer = new HBox();
buttonsContainer.getStyleClass().add("jfx-decorator-buttons-container");
buttonsContainer.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
// BINDING
buttonsContainer.setPadding(new Insets(4));
buttonsContainer.setAlignment(Pos.CENTER_RIGHT);
// customize decorator buttons
List<JFXButton> btns = new ArrayList<>();
if (fullScreen) {
btns.add(btnFull);
}
if (min) {
btns.add(btnMin);
}
if (max) {
btns.add(btnMax);
// maximize/restore the window on header double click
buttonsContainer.addEventHandler(MouseEvent.MOUSE_CLICKED, (mouseEvent) -> {
if (mouseEvent.getClickCount() == 2) {
btnMax.fire();
}
});
}
btns.add(btnClose);
text = new Text();
text.getStyleClass().addAll("jfx-decorator-text", "title", "jfx-decorator-title");
text.setFill(Color.WHITE);
// binds the Text's text to title
text.textProperty().bind(title);
// binds title to the primaryStage's title
title.bind(primaryStage.titleProperty());
graphicContainer = new HBox();
graphicContainer.setPickOnBounds(false);
graphicContainer.setAlignment(Pos.CENTER_LEFT);
graphicContainer.getChildren().setAll(text);
HBox graphicTextContainer = new HBox(graphicContainer, text);
graphicTextContainer.getStyleClass().add("jfx-decorator-title-container");
graphicTextContainer.setAlignment(Pos.CENTER_LEFT);
graphicTextContainer.setPickOnBounds(false);
HBox.setHgrow(graphicTextContainer, Priority.ALWAYS);
HBox.setMargin(graphicContainer, new Insets(0, 8, 0, 8));
buttonsContainer.getChildren().setAll(graphicTextContainer);
buttonsContainer.getChildren().addAll(btns);
buttonsContainer.addEventHandler(MouseEvent.MOUSE_ENTERED, (enter) -> allowMove = true);
buttonsContainer.addEventHandler(MouseEvent.MOUSE_EXITED, (enter) -> {
if (!isDragging) {
allowMove = false;
}
});
buttonsContainer.setMinWidth(180);
contentPlaceHolder.getStyleClass().add("jfx-decorator-content-container");
contentPlaceHolder.setMinSize(0, 0);
StackPane clippedContainer = new StackPane(node);
contentPlaceHolder.getChildren().add(clippedContainer);
((Region) node).setMinSize(0, 0);
VBox.setVgrow(contentPlaceHolder, Priority.ALWAYS);
contentPlaceHolder.getStyleClass().add("resize-border");
contentPlaceHolder.setBorder(new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(0, 4, 4, 4))));
// BINDING
Rectangle clip = new Rectangle();
clip.widthProperty().bind(clippedContainer.widthProperty());
clip.heightProperty().bind(clippedContainer.heightProperty());
clippedContainer.setClip(clip);
this.getChildren().addAll(buttonsContainer, contentPlaceHolder);
}
use of javafx.scene.shape.Rectangle in project JFoenix by jfoenixadmin.
the class JFXHighlighter method highlight.
/**
* highlights the matching text in the specified pane
* @param pane node to search into its text
* @param query search text
*/
public synchronized void highlight(Parent pane, String query) {
if (this.parent != null && !boxes.isEmpty()) {
clear();
}
if (query == null || query.isEmpty())
return;
this.parent = pane;
Set<Node> nodes = getTextNodes(pane);
ArrayList<Rectangle> allRectangles = new ArrayList<>();
for (Node node : nodes) {
Text text = ((Text) node);
final int beginIndex = text.getText().toLowerCase().indexOf(query.toLowerCase());
if (beginIndex > -1 && node.impl_isTreeVisible()) {
ArrayList<Bounds> boundingBoxes = getMatchingBounds(query, text);
ArrayList<Rectangle> rectangles = new ArrayList<>();
for (Bounds boundingBox : boundingBoxes) {
HighLightRectangle rect = new HighLightRectangle(text);
rect.setCacheHint(CacheHint.SPEED);
rect.setCache(true);
rect.setMouseTransparent(true);
rect.setBlendMode(BlendMode.MULTIPLY);
rect.fillProperty().bind(paintProperty());
rect.setManaged(false);
rect.setX(boundingBox.getMinX());
rect.setY(boundingBox.getMinY());
rect.setWidth(boundingBox.getWidth());
rect.setHeight(boundingBox.getHeight());
rectangles.add(rect);
allRectangles.add(rect);
}
boxes.put(node, rectangles);
}
}
JFXUtilities.runInFXAndWait(() -> getParentChildren(pane).addAll(allRectangles));
}
use of javafx.scene.shape.Rectangle in project Malai by arnobl.
the class MoveShape method testCanCancelDnDWithObsList.
@Test
public void testCanCancelDnDWithObsList(final FxRobot robot) {
new NodeBinder<>(new DnD(true, true), i -> new MoveShape((Rectangle) i.getSrcObject().get()), instrument).on(widget1.getChildren()).first((i, c) -> Platform.runLater(() -> i.getSrcObject().get().requestFocus())).then((i, c) -> c.setCoord(((Rectangle) i.getSrcObject().get()).getX() + (i.getTgtScenePoint().getX() - i.getSrcScenePoint().getX()), ((Rectangle) i.getSrcObject().get()).getY() + (i.getTgtScenePoint().getY() - i.getSrcScenePoint().getY()))).end((i, c) -> fail("")).exec().bind();
final Rectangle rec2 = new Rectangle(200d, 200d, 70d, 50d);
Platform.runLater(() -> widget1.getChildren().addAll(rec2));
WaitForAsyncUtils.waitForFxEvents();
robot.drag(rec2).moveBy(100, 100).type(KeyCode.ESCAPE).sleep(50L);
assertEquals(0, instrument.exec.get());
}
Aggregations