use of javafx.scene.shape.Rectangle in project JFoenix by jfoenixadmin.
the class JFXRippler method getMask.
// methods that can be changed by extending the rippler class
/**
* generate the clipping mask
*
* @return the mask node
*/
protected Node getMask() {
double borderWidth = ripplerPane.getBorder() != null ? ripplerPane.getBorder().getInsets().getTop() : 0;
Bounds bounds = control.getBoundsInParent();
double width = control.getLayoutBounds().getWidth();
double height = control.getLayoutBounds().getHeight();
double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX());
double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY());
double diffMaxX = Math.abs(control.getBoundsInLocal().getMaxX() - control.getLayoutBounds().getMaxX());
double diffMaxY = Math.abs(control.getBoundsInLocal().getMaxY() - control.getLayoutBounds().getMaxY());
Node mask;
switch(getMaskType()) {
case RECT:
mask = new Rectangle(bounds.getMinX() + diffMinX - snappedLeftInset(), bounds.getMinY() + diffMinY - snappedTopInset(), width - 2 * borderWidth, // -0.1 to prevent resizing the anchor pane
height - 2 * borderWidth);
break;
case CIRCLE:
double radius = Math.min((width / 2) - 2 * borderWidth, (height / 2) - 2 * borderWidth);
mask = new Circle((bounds.getMinX() + diffMinX + bounds.getMaxX() - diffMaxX) / 2 - snappedLeftInset(), (bounds.getMinY() + diffMinY + bounds.getMaxY() - diffMaxY) / 2 - snappedTopInset(), radius, Color.BLUE);
break;
case FIT:
mask = new Region();
if (control instanceof Shape) {
((Region) mask).setShape((Shape) control);
} else if (control instanceof Region) {
((Region) mask).setShape(((Region) control).getShape());
JFXNodeUtils.updateBackground(((Region) control).getBackground(), (Region) mask);
}
mask.resize(width, height);
mask.relocate(bounds.getMinX() + diffMinX, bounds.getMinY() + diffMinY);
break;
default:
mask = new Rectangle(bounds.getMinX() + diffMinX - snappedLeftInset(), bounds.getMinY() + diffMinY - snappedTopInset(), width - 2 * borderWidth, // -0.1 to prevent resizing the anchor pane
height - 2 * borderWidth);
break;
}
return mask;
}
use of javafx.scene.shape.Rectangle in project latexdraw by arnobl.
the class ViewShape method getActivatedGroupNodes.
private static Collection<javafx.scene.shape.Shape> getActivatedGroupNodes(final Group gp) {
// Adding all the shape children
final Collection<javafx.scene.shape.Shape> shapes = gp.getChildren().stream().filter(node -> node instanceof javafx.scene.shape.Shape && node.isVisible() && !node.isDisable()).map(node -> (javafx.scene.shape.Shape) node).collect(Collectors.toList());
// Adding all the view shape children
shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ViewShape<?> && node.isVisible() && !node.isDisable()).map(vs -> ((ViewShape<?>) vs).getActivatedShapes()).flatMap(st -> st.stream()).collect(Collectors.toList()));
// Adding the shapes contained in groups that are not view shapes
shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof Group && !(node instanceof ViewShape<?>)).map(node -> getActivatedGroupNodes((Group) node)).flatMap(st -> st.stream()).collect(Collectors.toList()));
// Adding the images contained in the group
shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ImageView && node.isVisible() && !node.isDisable()).map(node -> {
final Bounds bounds = node.getBoundsInParent();
final Rectangle rec = new Rectangle(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
rec.setFill(Color.WHITE);
rec.getTransforms().setAll(gp.getLocalToSceneTransform());
return rec;
}).collect(Collectors.toList()));
return shapes;
}
use of javafx.scene.shape.Rectangle in project latexdraw by arnobl.
the class Canvas method setVisibleSelectionBorder.
private void setVisibleSelectionBorder(final double x, final double y, final double w, final double h, final boolean ongoing) {
final Rectangle rec = ongoing ? ongoingSelectionBorder : selectionBorder;
rec.setLayoutX(x);
rec.setLayoutY(y);
rec.setWidth(w);
rec.setHeight(h);
rec.setVisible(true);
}
use of javafx.scene.shape.Rectangle in project sis by apache.
the class ColorCell method createRectangle.
/**
* Creates the graphic to draw in a table cell or combo box cell for showing color(s).
* This method is invoked for building an editor in {@link #showControlButton()} or for
* rendering the {@link ColorRamp} in the table.
*
* @param adjust amount of space (in pixels) to add on the right size.
* Can be a negative number for removing space.
* @return graphic to draw in a table cell or combo box cell.
*
* @see #setColorItem(ColorRamp)
*/
private Rectangle createRectangle(final double adjust) {
final Rectangle gr = new Rectangle();
gr.setHeight(HEIGHT);
gr.widthProperty().bind(widthProperty().add(adjust));
return gr;
}
use of javafx.scene.shape.Rectangle in project sis by apache.
the class ColorCell method setColorItem.
/**
* Sets the color representation when no editing is under way. It is caller responsibility to ensure
* that the current graphic is not a combo box, or that it is safe to remove that combo box from the
* scene (i.e. that combo box does not have focus anymore).
*
* @param colors current value of {@link #getItem()}.
*/
private void setColorItem(final ColorRamp colors) {
assert controlNotFocused();
Rectangle view = null;
if (colors != null) {
final Paint paint = colors.paint();
if (paint != null) {
if (colorView == null) {
colorView = createRectangle(WIDTH_ADJUST);
}
view = colorView;
view.setFill(paint);
}
}
setGraphic(view);
}
Aggregations