Java Code Examples for javafx.scene.shape.Rectangle#setStroke()
The following examples show how to use
javafx.scene.shape.Rectangle#setStroke() .
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: MenuBox.java From FXTutorials with MIT License | 14 votes |
public MenuBox(int width, int height) { Rectangle bg = new Rectangle(width, height); bg.setFill(Colors.MENU_BG); Rectangle lineTop = new Rectangle(width, 2); lineTop.setFill(Colors.MENU_BORDER); lineTop.setStroke(Color.BLACK); Rectangle lineBot = new Rectangle(width, 2); lineBot.setTranslateY(height - 2); lineBot.setFill(Colors.MENU_BORDER); lineBot.setStroke(Color.BLACK); box = new VBox(5); box.setTranslateX(25); box.setTranslateY(25); getChildren().addAll(bg, lineTop, lineBot, box); }
Example 2
Source File: StrokeTransitionSample.java From marathonv5 with Apache License 2.0 | 8 votes |
public StrokeTransitionSample() { super(150,150); Rectangle rect = new Rectangle(0, 0, 150, 150); rect.setArcHeight(20); rect.setArcWidth(20); rect.setFill(null); rect.setStroke(Color.DODGERBLUE); rect.setStrokeWidth(10); getChildren().add(rect); strokeTransition = StrokeTransitionBuilder.create() .duration(Duration.seconds(3)) .shape(rect) .fromValue(Color.RED) .toValue(Color.DODGERBLUE) .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .build(); }
Example 3
Source File: AnchorPaneSample.java From marathonv5 with Apache License 2.0 | 8 votes |
public static Node createIconContent() { StackPane sp = new StackPane(); AnchorPane anchorPane = new AnchorPane(); Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY); rectangle.setStroke(Color.BLACK); anchorPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight()); Rectangle r1 = new Rectangle(14, 14, Color.web("#1c89f4")); Rectangle r2 = new Rectangle(45, 10, Color.web("#349b00")); Rectangle r3 = new Rectangle(35, 14, Color.web("#349b00")); anchorPane.getChildren().addAll(r1, r2, r3); AnchorPane.setTopAnchor(r1, Double.valueOf(1)); AnchorPane.setLeftAnchor(r1, Double.valueOf(1)); AnchorPane.setTopAnchor(r2, Double.valueOf(20)); AnchorPane.setLeftAnchor(r2, Double.valueOf(1)); AnchorPane.setBottomAnchor(r3, Double.valueOf(1)); AnchorPane.setRightAnchor(r3, Double.valueOf(5)); sp.getChildren().addAll(rectangle, anchorPane); return new Group(sp); }
Example 4
Source File: GeometryNodeOpacitySnippet.java From gef with Eclipse Public License 2.0 | 8 votes |
@Override public Scene createScene() { Pane root = new Pane(); Scene scene = new Scene(root, 300, 500); GeometryNode<RoundedRectangle> geometryNode = new GeometryNode<>( new RoundedRectangle(100, 100, 100, 100, 30, 30)); geometryNode.setStroke(Color.TRANSPARENT); geometryNode.setStyle("-fx-fill: red; -fx-opacity: 0.5;"); Rectangle rectangle = new Rectangle(100, 300, 100, 100); rectangle.setArcHeight(30); rectangle.setArcWidth(30); rectangle.setStroke(Color.TRANSPARENT); rectangle.setStyle("-fx-fill: red; -fx-opacity: 0.5;"); root.getChildren().addAll(geometryNode, rectangle); return scene; }
Example 5
Source File: RectangleSample.java From marathonv5 with Apache License 2.0 | 7 votes |
public RectangleSample() { super(180,90); // Simple red filled rectangle Rectangle rect1 = new Rectangle(25,25,40,40); rect1.setFill(Color.RED); // Blue stroked rectangle Rectangle rect2 = new Rectangle(135,25,40,40); rect2.setStroke(Color.DODGERBLUE); rect2.setFill(null); // Create a group to show all the rectangles); getChildren().add(new Group(rect1,rect2)); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Rectangle 1 Fill", rect1.fillProperty()), new SimplePropertySheet.PropDesc("Rectangle 1 Width", rect1.widthProperty(), 10d, 50d), new SimplePropertySheet.PropDesc("Rectangle 1 Height", rect1.heightProperty(), 10d, 50d), new SimplePropertySheet.PropDesc("Rectangle 1 Arc Width", rect1.arcWidthProperty(), 0d, 50d), new SimplePropertySheet.PropDesc("Rectangle 1 Arc Height", rect1.arcHeightProperty(), 0d, 50d), new SimplePropertySheet.PropDesc("Rectangle 2 Stroke", rect2.strokeProperty()), new SimplePropertySheet.PropDesc("Rectangle 2 Stroke Width", rect2.strokeWidthProperty(), 1d, 5d), new SimplePropertySheet.PropDesc("Rectangle 2 Width", rect2.widthProperty(), 10d, 50d), new SimplePropertySheet.PropDesc("Rectangle 2 Height", rect2.heightProperty(), 10d, 50d), new SimplePropertySheet.PropDesc("Rectangle 2 Arc Width", rect2.arcWidthProperty(), 0d, 50d), new SimplePropertySheet.PropDesc("Rectangle 2 Arc Height", rect2.arcHeightProperty(), 0d, 50d) ); // END REMOVE ME }
Example 6
Source File: ColorAttributeInteraction.java From constellation with Apache License 2.0 | 7 votes |
@Override public List<Node> getDisplayNodes(final Object attrVal, final double width, final double height) { ConstellationColor colorValue = (ConstellationColor) attrVal; final double rectWidth = width == -1 ? height == -1 ? DEFAULT_NODE_SIZE : height : width; final double rectHeight = height == -1 ? rectWidth : height; final Rectangle rect = new Rectangle(rectWidth, rectHeight); rect.setFill(colorValue.getJavaFXColor()); rect.setStroke(Color.LIGHTGREY); return Arrays.asList(rect); }
Example 7
Source File: StopWatchSample.java From marathonv5 with Apache License 2.0 | 7 votes |
private Rectangle createBackground(Color stroke, Color fill) { Rectangle background = new Rectangle(14, 17, fill); background.setStroke(stroke); background.setStrokeWidth(2); background.setEffect(new Lighting()); background.setCache(true); return background; }
Example 8
Source File: Chess.java From games_oop_javafx with Apache License 2.0 | 5 votes |
private Rectangle buildRectangle(int x, int y, int size, boolean white) { Rectangle rect = new Rectangle(); rect.setX(x * size); rect.setY(y * size); rect.setHeight(size); rect.setWidth(size); if (white) { rect.setFill(Color.WHITE); } else { rect.setFill(Color.GRAY); } rect.setStroke(Color.BLACK); return rect; }
Example 9
Source File: SpaceLevel.java From FXGLGames with MIT License | 5 votes |
public SpaceLevel() { Rectangle bg = new Rectangle(getAppWidth() - 20, 200, Color.color(0, 0, 0, 0.6)); bg.setArcWidth(25); bg.setArcHeight(25); bg.setStroke(Color.color(0.1, 0.2, 0.86, 0.76)); bg.setStrokeWidth(3); storyPane.setTranslateX(10); storyPane.setTranslateY(25); rootPane = new Pane(bg, storyPane); rootPane.setTranslateX(10); rootPane.setTranslateY(getAppHeight() - 200); }
Example 10
Source File: Puzzle.java From games_oop_javafx with Apache License 2.0 | 5 votes |
private Rectangle buildRectangle(int x, int y, int size) { Rectangle rect = new Rectangle(); rect.setX(x * size); rect.setY(y * size); rect.setHeight(size); rect.setWidth(size); rect.setFill(Color.WHITE); rect.setStroke(Color.BLACK); return rect; }
Example 11
Source File: ParallelCoordinatesChart.java From charts with Apache License 2.0 | 5 votes |
private void initGraphics() { if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) { if (getPrefWidth() > 0 && getPrefHeight() > 0) { setPrefSize(getPrefWidth(), getPrefHeight()); } else { setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } axisCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); axisCtx = axisCanvas.getGraphicsContext2D(); Color selectionRectColor = getSelectionRectColor(); rect = new Rectangle(); rect.setMouseTransparent(true); rect.setVisible(false); rect.setStroke(Helper.getColorWithOpacity(selectionRectColor, 0.5)); rect.setFill(Helper.getColorWithOpacity(selectionRectColor, 0.25)); connectionCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); connectionCanvas.setMouseTransparent(true); connectionCtx = connectionCanvas.getGraphicsContext2D(); connectionCtx.setTextAlign(TextAlignment.LEFT); connectionCtx.setTextBaseline(VPos.CENTER); dragText = new Text(""); dragText.setVisible(false); dragText.setTextOrigin(VPos.CENTER); dragText.setFill(Helper.getColorWithOpacity(getHeaderColor(), 0.5)); getChildren().setAll(axisCanvas, rect, connectionCanvas, dragText); }
Example 12
Source File: StopWatchSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private Rectangle createBackground(Color stroke, Color fill) { Rectangle background = new Rectangle(14, 17, fill); background.setStroke(stroke); background.setStrokeWidth(2); background.setEffect(new Lighting()); background.setCache(true); return background; }
Example 13
Source File: SeaBattle.java From games_oop_javafx with Apache License 2.0 | 5 votes |
private Rectangle buildRectangle(int x, int y, int size) { Rectangle rect = new Rectangle(); rect.setX(x * size); rect.setY(y * size); rect.setHeight(size); rect.setWidth(size); rect.setFill(Color.WHITE); rect.setStroke(Color.BLACK); return rect; }
Example 14
Source File: IOSApp.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public ToggleSwitch() { Rectangle background = new Rectangle(100, 50); background.setArcWidth(50); background.setArcHeight(50); background.setFill(Color.WHITE); background.setStroke(Color.LIGHTGRAY); Circle trigger = new Circle(25); trigger.setCenterX(25); trigger.setCenterY(25); trigger.setFill(Color.WHITE); trigger.setStroke(Color.LIGHTGRAY); DropShadow shadow = new DropShadow(); shadow.setRadius(2); trigger.setEffect(shadow); translateAnimation.setNode(trigger); fillAnimation.setShape(background); getChildren().addAll(background, trigger); switchedOn.addListener((obs, oldState, newState) -> { boolean isOn = newState.booleanValue(); translateAnimation.setToX(isOn ? 100 - 50 : 0); fillAnimation.setFromValue(isOn ? Color.WHITE : Color.LIGHTGREEN); fillAnimation.setToValue(isOn ? Color.LIGHTGREEN : Color.WHITE); animation.play(); }); setOnMouseClicked(event -> { switchedOn.set(!switchedOn.get()); }); }
Example 15
Source File: ScaleSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public ScaleSample() { super(180,180); // simple rectangle Rectangle rect1 = new Rectangle(0, 25, 25, 25); rect1.setArcHeight(15); rect1.setArcWidth(15); rect1.setFill(Color.WHITE); rect1.setStroke(Color.DODGERBLUE); rect1.setStrokeWidth(3); Polygon arrow = createArrow(); arrow.setLayoutX(46); arrow.setLayoutY(22); arrow.setRotate(90); // simple rectangle with scale 2 in X axis and 0.5 in Y Rectangle rect2 = new Rectangle(95, 25, 25, 25); rect2.setArcHeight(15); rect2.setArcWidth(15); rect2.setFill(Color.WHITE); rect2.setStroke(Color.DODGERBLUE); rect2.setStrokeWidth(3); rect2.setScaleX(2); rect2.setScaleY(0.5); // rectangle with adjustable scale Rectangle rect3 = new Rectangle(40, 130, 25, 25); rect3.setArcHeight(15); rect3.setArcWidth(15); rect3.setFill(Color.WHITE); rect3.setStroke(Color.DODGERBLUE); rect3.setStrokeWidth(3); rect3.setScaleX(6); rect3.setScaleY(0.5); rect3.setTranslateX(rect3.getTranslateX()+30); //getChildren().addAll(rect1, rect2, rect3); getChildren().addAll(rect1, arrow, rect2, rect3); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Scale X", rect3.scaleXProperty(), 0.1d, 16d), new SimplePropertySheet.PropDesc("Scale Y", rect3.scaleYProperty(), 0.1d, 4d) ); // END REMOVE ME }
Example 16
Source File: TimerControlTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); currentValueListener = o -> { if (tile.isRunning()) { return; } // Update time only if clock is not already running updateTime(ZonedDateTime.ofInstant(Instant.ofEpochSecond(tile.getCurrentTime()), ZoneId.of(ZoneId.systemDefault().getId()))); }; timeListener = o -> updateTime(tile.getTime()); dateFormatter = DateTimeFormatter.ofPattern("EE d", tile.getLocale()); sectionMap = new HashMap<>(tile.getTimeSections().size()); for (TimeSection section : tile.getTimeSections()) { sectionMap.put(section, new Arc()); } minuteRotate = new Rotate(); hourRotate = new Rotate(); secondRotate = new Rotate(); sectionsPane = new Pane(); sectionsPane.getChildren().addAll(sectionMap.values()); Helper.enableNode(sectionsPane, tile.getSectionsVisible()); minuteTickMarks = new Path(); minuteTickMarks.setFillRule(FillRule.EVEN_ODD); minuteTickMarks.setFill(null); minuteTickMarks.setStroke(tile.getMinuteColor()); minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND); hourTickMarks = new Path(); hourTickMarks.setFillRule(FillRule.EVEN_ODD); hourTickMarks.setFill(null); hourTickMarks.setStroke(tile.getHourColor()); hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND); hour = new Rectangle(3, 60); hour.setArcHeight(3); hour.setArcWidth(3); hour.setStroke(tile.getHourColor()); hour.getTransforms().setAll(hourRotate); minute = new Rectangle(3, 96); minute.setArcHeight(3); minute.setArcWidth(3); minute.setStroke(tile.getMinuteColor()); minute.getTransforms().setAll(minuteRotate); second = new Rectangle(1, 96); second.setArcHeight(1); second.setArcWidth(1); second.setStroke(tile.getSecondColor()); second.getTransforms().setAll(secondRotate); second.setVisible(tile.isSecondsVisible()); second.setManaged(tile.isSecondsVisible()); knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5); knob.setStroke(Color.web("#282a3280")); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); shadowGroupHour = new Group(hour); shadowGroupMinute = new Group(minute); shadowGroupSecond = new Group(second, knob); shadowGroupHour.setEffect(tile.isShadowsEnabled() ? dropShadow : null); shadowGroupMinute.setEffect(tile.isShadowsEnabled() ? dropShadow : null); shadowGroupSecond.setEffect(tile.isShadowsEnabled() ? dropShadow : null); titleText = new Text(""); titleText.setTextOrigin(VPos.TOP); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); amPmText = new Text(tile.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM"); dateText = new Text(""); Helper.enableNode(dateText, tile.isDateVisible()); text = new Text(""); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(sectionsPane, hourTickMarks, minuteTickMarks, titleText, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond); }
Example 17
Source File: TileTextKpiSkin.java From Medusa with Apache License 2.0 | 4 votes |
private void initGraphics() { // Set initial size if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 || Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) { if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) { gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight()); } else { gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } barBackground = new Region(); barBackground.setBackground(new Background(new BackgroundFill(gauge.getBarBackgroundColor(), new CornerRadii(0.0, 0.0, 0.025, 0.025, true), Insets.EMPTY))); barClip = new Rectangle(); bar = new Rectangle(); bar.setFill(gauge.getBarColor()); bar.setStroke(null); bar.setClip(barClip); titleText = new Text(); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); valueText = new Text(); valueText.setFill(gauge.getValueColor()); Helper.enableNode(valueText, gauge.isValueVisible()); unitText = new Text(gauge.getUnit()); unitText.setFill(gauge.getUnitColor()); Helper.enableNode(unitText, !gauge.getUnit().isEmpty()); percentageText = new Text(); percentageText.setFill(gauge.getBarColor()); percentageUnitText = new Text("%"); percentageUnitText.setFill(gauge.getBarColor()); maxValueRect = new Rectangle(); maxValueRect.setFill(gauge.getThresholdColor()); maxValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMaxValue())); maxValueText.setFill(gauge.getBackgroundPaint()); maxValueUnitText = new Text(gauge.getUnit()); maxValueUnitText.setFill(gauge.getBackgroundPaint()); pane = new Pane(barBackground, bar, titleText, valueText, unitText, percentageText, percentageUnitText, maxValueRect, maxValueText, maxValueUnitText); pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(gauge.getBorderWidth())))); pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY))); getChildren().setAll(pane); }
Example 18
Source File: TransactionGraphLabelsEditorFactory.java From constellation with Apache License 2.0 | 4 votes |
LabelEntry(final List<LabelEntry> host, final Pane visualHost, final String attributeName, final ConstellationColor color, final float size) { attrCombo = new ComboBox<>(FXCollections.observableList(attributeNames)); attrCombo.setPrefWidth(150); attrCombo.getSelectionModel().select(attributeName); attrCombo.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> { update(); }); colorRect = new Rectangle(20, 20); this.color = color.getJavaFXColor(); colorRect.setFill(this.color); colorRect.setStroke(Color.LIGHTGREY); colorRect.setOnMouseClicked(getChooseColorEventHandler()); sizeText = new TextField(String.valueOf(size)); sizeText.setPrefWidth(50); sizeText.textProperty().addListener((o, n, v) -> { update(); }); final Button upButton = new Button("", new ImageView(UserInterfaceIconProvider.CHEVRON_UP.buildImage(16))); upButton.setOnAction(e -> { moveUp(); update(); }); final Button downButton = new Button("", new ImageView(UserInterfaceIconProvider.CHEVRON_DOWN.buildImage(16))); downButton.setOnAction(e -> { moveDown(); update(); }); final Button removeButton = new Button("", new ImageView(UserInterfaceIconProvider.CROSS.buildImage(16))); removeButton.setOnAction(e -> { remove(); update(); }); entry = new HBox(10); entry.getChildren().addAll(attrCombo, colorRect, sizeText, upButton, downButton, removeButton); this.host = host; this.host.add(this); this.visualHost = visualHost; this.visualHost.getChildren().add(entry); }
Example 19
Source File: SymbolRepresentation.java From phoebus with Eclipse Public License 1.0 | 3 votes |
DefaultSymbolNode() { setManaged(true); int w = 100; int h = 100; r = new Rectangle(0, 0, w, h); r.setFill(null); r.setArcHeight(0); r.setArcWidth(0); r.setStroke(Color.BLACK); r.setStrokeType(StrokeType.INSIDE); l1 = new Line(0.5, 0.5, w - 0.5, h - 0.5); l1.setStroke(Color.BLACK); l1.setStrokeLineCap(StrokeLineCap.BUTT); l2 = new Line(0.5, h - 0.5, w - 0.5, 0.5); l2.setStroke(Color.BLACK); l2.setStrokeLineCap(StrokeLineCap.BUTT); getChildren().add(r); getChildren().add(l1); getChildren().add(l2); }
Example 20
Source File: FarCry4Loading.java From FXTutorials with MIT License | 2 votes |
public LoadingArc() { Arc arc = new Arc(); arc.setCenterX(25); arc.setCenterY(25); arc.setRadiusX(25.0f); arc.setRadiusY(25.0f); arc.setLength(30.0f); arc.setStrokeWidth(5); Stop[] stops = new Stop[] { new Stop(0, Color.WHITE), new Stop(1, Color.BLUE)}; LinearGradient lg1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops); arc.setStroke(lg1); Rectangle rect = new Rectangle(50, 50); rect.setFill(null); rect.setStroke(Color.RED); getChildren().addAll(rect, arc); double time = 0.75; Rotate r = new Rotate(0, 25, 25); arc.getTransforms().add(r); //arc.getTransforms().add(new Scale(-1, 1, 25, 25)); Timeline timeline = new Timeline(); KeyFrame kf2 = new KeyFrame(Duration.seconds(time), new KeyValue(r.angleProperty(), 270)); timeline.getKeyFrames().addAll(kf2); Timeline timeline3 = new Timeline(new KeyFrame(Duration.seconds(time), new KeyValue(r.angleProperty(), 360))); SequentialTransition st = new SequentialTransition(timeline, timeline3); st.setCycleCount(Timeline.INDEFINITE); st.setInterpolator(Interpolator.EASE_BOTH); st.play(); ////////// Timeline timeline2 = new Timeline(); timeline2.setAutoReverse(true); timeline2.setCycleCount(Timeline.INDEFINITE); KeyFrame kf = new KeyFrame(Duration.seconds(time), new KeyValue(arc.lengthProperty(), 270, Interpolator.EASE_BOTH)); timeline2.getKeyFrames().add(kf); timeline2.play(); }