Java Code Examples for javafx.scene.shape.Rectangle#setOpacity()

The following examples show how to use javafx.scene.shape.Rectangle#setOpacity() . 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: TranslateSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 20, 20);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(29);
    polygon.setLayoutY(21);
    polygon.setRotate(135);
    

    Rectangle r2 = new Rectangle (50, 50, 20, 20);
    r2.setArcHeight(4);
    r2.setArcWidth(4);
    r2.setFill(Color.web("#ed4b00"));
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
 
Example 2
Source File: RotateSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 64, 64);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(65);
    polygon.setLayoutY(5);
    polygon.setRotate(165);
    

    Rectangle r2 = new Rectangle (0, 0, 64, 64);
    r2.setArcHeight(15);
    r2.setArcWidth(15);
    r2.setFill(Color.web("#ed4b00"));
    r2.setRotate(60);
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
 
Example 3
Source File: TranslateSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 20, 20);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(29);
    polygon.setLayoutY(21);
    polygon.setRotate(135);
    

    Rectangle r2 = new Rectangle (50, 50, 20, 20);
    r2.setArcHeight(4);
    r2.setArcWidth(4);
    r2.setFill(Color.web("#ed4b00"));
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
 
Example 4
Source File: RotateSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (0, 0, 64, 64);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(65);
    polygon.setLayoutY(5);
    polygon.setRotate(165);
    

    Rectangle r2 = new Rectangle (0, 0, 64, 64);
    r2.setArcHeight(15);
    r2.setArcWidth(15);
    r2.setFill(Color.web("#ed4b00"));
    r2.setRotate(60);
    r2.setOpacity(0.5);
    javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
    return new javafx.scene.Group(g);
}
 
Example 5
Source File: JFXChartUtil.java    From jfxutils with Apache License 2.0 6 votes vote down vote up
/**
 * Convenience method for simple and default setup of zooming on an {@link XYChart} via a
 * {@link ChartZoomManager}. Wraps the chart in the components required to implement zooming. The
 * current implementation wraps the chart in a StackPane, which has the chart and a blue
 * translucent rectangle as children. Returns the top level of the created components.
 * <p>
 * If the chart already has a parent, that parent must be a {@link Pane}, and the chart is
 * replaced with the wrapping region, and the return value could be ignored. If the chart does
 * not have a parent, the same wrapping node is returned, which will need to be added to some
 * parent.
 * <p>
 * The chart's axes must both be a type of ValueAxis.
 * <p>
 * The wrapping logic does not seem to be perfect, in fact there is a special case to handle
 * {@link BorderPane}s. If it's not found to be reliable, then create the wrapping components
 * yourself (such as in the FXML), or setup zooming before adding it to a parent.
 *
 * @param mouseFilter EventHandler that consumes events that should not trigger a zoom action
 *
 * @return The top-level Region
 */
public static Region setupZooming( XYChart<?, ?> chart,
                                   EventHandler<? super MouseEvent> mouseFilter ) {
	StackPane chartPane = new StackPane();

	if ( chart.getParent() != null )
		JFXUtil.replaceComponent( chart, chartPane );

	Rectangle selectRect = new Rectangle( 0, 0, 0, 0 );
	selectRect.setFill( Color.DODGERBLUE );
	selectRect.setMouseTransparent( true );
	selectRect.setOpacity( 0.3 );
	selectRect.setStroke( Color.rgb( 0, 0x29, 0x66 ) );
	selectRect.setStrokeType( StrokeType.INSIDE );
	selectRect.setStrokeWidth( 3.0 );
	StackPane.setAlignment( selectRect, Pos.TOP_LEFT );

	chartPane.getChildren().addAll( chart, selectRect );

	ChartZoomManager zoomManager = new ChartZoomManager( chartPane, selectRect, chart );
	zoomManager.setMouseFilter( mouseFilter );
	zoomManager.start();
	return chartPane;
}
 
Example 6
Source File: TimelineChart.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method that creates a selection rectangle.
 *
 * @return A newly created rectangle to be used for selections.
 */
private Rectangle createSelectionRectange() {
    final Rectangle newSelection = new Rectangle(0, 0, 0, 0);
    newSelection.heightProperty().bind(yAxis.heightProperty());
    newSelection.layoutYProperty().bind(yAxis.layoutYProperty());
    newSelection.setFill(Color.WHITE);
    newSelection.setStroke(Color.BLACK);
    newSelection.setOpacity(0.4);
    newSelection.setMouseTransparent(true);
    newSelection.toBack();

    return newSelection;
}
 
Example 7
Source File: NodeDetailPaneInfo.java    From scenic-view with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void createDetails() {
    nodeClassName = addDetail("className", "className:");
    styleClassDetail = addDetail("styleClass", "styleClass:");
    pseudoClassStateDetail = addDetail(null, "pseudoClassState:");
    visibleDetail = addDetail("visible", "visible:");
    managedDetail = addDetail("managed", "managed:");
    layoutBoundsDetail = addDetail("layoutBounds", "layoutBounds:", LabelType.LAYOUT_BOUNDS);
    effectDetail = addDetail("effect", "effect:");
    opacityDetail = addDetail("opacity", "opacity:");
    clipDetail = addDetail("clip", "clip:");
    transformsDetail = addDetail("transforms", "transforms:");
    scaleXYDetail = addDetail("scaleX", "scaleX/Y:");
    rotateDetail = addDetail("rotate", "rotate:");
    layoutXYDetail = addDetail("layoutX", "layoutX/Y:");
    translateXYDetail = addDetail("translateX", "translateX/Y:");
    final Rectangle boundsInParentIcon = new Rectangle(12, 12);
    boundsInParentIcon.setFill(Color.YELLOW);
    boundsInParentIcon.setOpacity(.5);
    boundsInParentDetail = addDetail("boundsInParent", "boundsInParent:", LabelType.BOUNDS_PARENT);
    resizableDetail = addDetail(null, "resizable:");
    contentBiasDetail = addDetail(null, "contentBias:");

    baselineDetail = addDetail(null, "baselineOffset:", LabelType.BASELINE);
    minSizeDetail = addDetail(null, "minWidth(h)/Height(w):");
    prefSizeDetail = addDetail(null, "prefWidth(h)/Height(w):");
    maxSizeDetail = addDetail(null, "maxWidth(h)/Height(w):");
    constraintsDetail = addDetail(null, "layout constraints:", ValueType.CONSTRAINTS);
}
 
Example 8
Source File: NodePropertiesSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public NodePropertiesSample() {
    super(300,100);
    //X position of node = X + LayoutX + TranslateX
    rectA = new Rectangle(50, 50, Color.LIGHTSALMON);
    //set position of node temporary (can be changed after)
    rectA.setTranslateX(10);

    rectB = new Rectangle(50, 50, Color.LIGHTGREEN);
    //set position of node when addinf to some layout
    rectB.setLayoutX(20);
    rectB.setLayoutY(10);

    rectC = new Rectangle(50, 50, Color.DODGERBLUE);
    //last posibility of setting X position of node
    rectC.setX(30);
    rectC.setY(20);

    //opacity of node can be set
    rectC.setOpacity(0.8);

    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Rectangle A translate X", rectA.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle B translate X", rectB.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle C translate X", rectC.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle A Opacity", rectA.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle B Opacity", rectB.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle C Opacity", rectC.opacityProperty(), 0d, 1d)
            );

    getChildren().add(createRadioButtons());
    // END REMOVE ME

    Group g = new Group(rectA, rectB, rectC);
    g.setLayoutX(160 + 35);
    getChildren().addAll(g);
}
 
Example 9
Source File: NodePropertiesSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public NodePropertiesSample() {
    super(300,100);
    //X position of node = X + LayoutX + TranslateX
    rectA = new Rectangle(50, 50, Color.LIGHTSALMON);
    //set position of node temporary (can be changed after)
    rectA.setTranslateX(10);

    rectB = new Rectangle(50, 50, Color.LIGHTGREEN);
    //set position of node when addinf to some layout
    rectB.setLayoutX(20);
    rectB.setLayoutY(10);

    rectC = new Rectangle(50, 50, Color.DODGERBLUE);
    //last posibility of setting X position of node
    rectC.setX(30);
    rectC.setY(20);

    //opacity of node can be set
    rectC.setOpacity(0.8);

    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Rectangle A translate X", rectA.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle B translate X", rectB.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle C translate X", rectC.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle A Opacity", rectA.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle B Opacity", rectB.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle C Opacity", rectC.opacityProperty(), 0d, 1d)
            );

    getChildren().add(createRadioButtons());
    // END REMOVE ME

    Group g = new Group(rectA, rectB, rectC);
    g.setLayoutX(160 + 35);
    getChildren().addAll(g);
}
 
Example 10
Source File: GameMenuDemo.java    From FXTutorials with MIT License 5 votes vote down vote up
public MenuButton(String name) {
    text = new Text(name);
    text.setFont(text.getFont().font(20));
    text.setFill(Color.WHITE);

    Rectangle bg = new Rectangle(250, 30);
    bg.setOpacity(0.6);
    bg.setFill(Color.BLACK);
    bg.setEffect(new GaussianBlur(3.5));

    setAlignment(Pos.CENTER_LEFT);
    setRotate(-0.5);
    getChildren().addAll(bg, text);

    setOnMouseEntered(event -> {
        bg.setTranslateX(10);
        text.setTranslateX(10);
        bg.setFill(Color.WHITE);
        text.setFill(Color.BLACK);
    });

    setOnMouseExited(event -> {
        bg.setTranslateX(0);
        text.setTranslateX(0);
        bg.setFill(Color.BLACK);
        text.setFill(Color.WHITE);
    });

    DropShadow drop = new DropShadow(50, Color.WHITE);
    drop.setInput(new Glow());

    setOnMousePressed(event -> setEffect(drop));
    setOnMouseReleased(event -> setEffect(null));
}
 
Example 11
Source File: EventDetectionUI.java    From SONDY with GNU General Public License v3.0 5 votes vote down vote up
public final void detectedEventsUI(){
    // Detected events
    HBox detectedEventsBOTH = new HBox(0);
    initializeEventTable();
    initializeFrequencyChart();
    VBox detectedEventsRIGHT = new VBox(3);
    filterEventsField = new TextField();
    filterEventsField.setPromptText("Filter events");
    UIUtils.setSize(filterEventsField, Main.columnWidthRIGHT, 24);
    final EventHandler<KeyEvent> enterPressed =
        new EventHandler<KeyEvent>() {
            @Override
            public void handle(final KeyEvent keyEvent) {
                if(keyEvent.getCode()==KeyCode.ENTER){
                    eventTable.getItems().clear();
                    selectedMethod.events.filterList(filterEventsField.getText());
                    eventTable.setItems(selectedMethod.events.observableList);
                }
            }
        };
    filterEventsField.setOnKeyReleased(enterPressed);
    detectedEventsRIGHT.getChildren().addAll(filterEventsField,eventTable,createTimelineButton());
    detectedEventsBOTH.getChildren().addAll(frequencyChart,detectedEventsRIGHT);
    grid.add(detectedEventsBOTH,0,5);
    rectangleSelection = new Rectangle(0,240);
    rectangleSelection.setOpacity(0.22);
    rectangleSelection.setTranslateY(-28);
    grid.add(rectangleSelection,0,5);
}
 
Example 12
Source File: Fallout4MenuApp.java    From FXTutorials with MIT License 4 votes vote down vote up
private Parent createContent() {
    Pane root = new Pane();

    ImageView imageView = new ImageView(new Image(getClass()
            .getResource("res/Fallout4_bg.jpg").toExternalForm()));

    imageView.setFitWidth(1280);
    imageView.setFitHeight(720);

    SepiaTone tone = new SepiaTone(0.85);
    imageView.setEffect(tone);

    Rectangle masker = new Rectangle(1280, 720);
    masker.setOpacity(0);
    masker.setMouseTransparent(true);

    MenuBox menuBox = new MenuBox(250, 350);
    menuBox.setTranslateX(250);
    menuBox.setTranslateY(230);

    MenuBox menuBox2 = new MenuBox(510, 350);
    menuBox2.setTranslateX(250 + 20 + 250);
    menuBox2.setTranslateY(230);

    menuBox.addItem(new MenuItem("CONTINUE", 250));

    MenuItem itemNew = new MenuItem("NEW", 250);
    itemNew.setOnAction(() -> {
        FadeTransition ft = new FadeTransition(Duration.seconds(1.5), masker);
        ft.setToValue(1);

        ft.setOnFinished(e -> {
            root.getChildren().setAll(new LoadingScreen(1280, 720, () -> {
                masker.setOpacity(0);
                root.getChildren().setAll(imageView, menuBox, menuBox2, masker);
            }));
        });

        ft.play();
    });
    menuBox.addItem(itemNew);
    menuBox.addItem(new MenuItem("LOAD", 250));

    MenuItem itemSettings = new MenuItem("SETTINGS", 250);
    itemSettings.setOnAction(() -> {
        menuBox2.addItems(
                new MenuItem("GAMEPLAY", 510),
                new MenuItem("CONTROLS", 510),
                new MenuItem("DISPLAY", 510),
                new MenuItem("AUDIO", 510));
    });

    menuBox.addItem(itemSettings);
    menuBox.addItem(new MenuItem("CREW", 250));

    MenuItem itemExit = new MenuItem("EXIT", 250);
    itemExit.setOnAction(() -> System.exit(0));
    menuBox.addItem(itemExit);

    root.getChildren().addAll(imageView, menuBox, menuBox2, masker);
    return root;
}
 
Example 13
Source File: DockZones.java    From AnchorFX with GNU Lesser General Public License v3.0 3 votes vote down vote up
private void createRectangleForPreview() {
    rectanglePreview = new Rectangle(0, 0, 50, 50);
    rectanglePreview.getStyleClass().add("dockzone-rectangle-preview");
    rectanglePreview.setOpacity(0);

    opacityAnimationPreview = new Timeline(new KeyFrame(Duration.seconds(0.5), new KeyValue(rectanglePreview.opacityProperty(), 0.5, Interpolator.LINEAR)));

    opacityAnimationPreview.setAutoReverse(true);
    opacityAnimationPreview.setCycleCount(-1);

    mainRoot.getChildren().add(rectanglePreview);

}