Java Code Examples for javafx.scene.shape.Polygon#setFill()
The following examples show how to use
javafx.scene.shape.Polygon#setFill() .
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: Exercise_18_19.java From Intro-to-Java-Programming with MIT License | 6 votes |
private void displayTriangles(int order, Point2D p1, Point2D p2, Point2D p3) { if (order == 0) { // Draw a triangle to connect three points Polygon triangle = new Polygon(); triangle.getPoints().addAll(p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY()); triangle.setStroke(Color.BLACK); triangle.setFill(Color.WHITE); this.getChildren().add(triangle); } else { //Get the midpoint on each edge in the triangle Point2D p12= p1.midpoint(p2); Point2D p23= p2.midpoint(p3); Point2D p31= p3.midpoint(p1); // Recursively display three triangles displayTriangles(order - 1, p1, p12, p31); displayTriangles(order - 1, p12, p2, p23); displayTriangles(order - 1, p31, p23, p3); } }
Example 2
Source File: Pin.java From BlockMap with MIT License | 6 votes |
@Override protected Node initBottomGui() { Polygon shape = new Polygon(); shape.getPoints().setAll(chunkPositions.stream().flatMap(v -> Stream.of(v.x(), v.y())).map(d -> (d + 1) * 16.0).collect(Collectors.toList())); shape.setFill(new ImagePattern(image, 0, 0, 16, 16, false)); getTopGui().hoverProperty().addListener(e -> { if (getTopGui().isHover()) shape.setOpacity(0.6); else shape.setOpacity(0.2); }); shape.setOpacity(0.2); shape.setMouseTransparent(true); shape.setCache(true); shape.setCacheHint(CacheHint.SCALE); shape.setViewOrder(1); return shape; }
Example 3
Source File: TriangleCell.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@Override public Region getGraphic(Graph graph) { final double width = 50; final double height = 50; final Polygon view = new Polygon(width / 2, 0, width, height, 0, height); view.setStroke(Color.RED); view.setFill(Color.RED); final Pane pane = new Pane(view); pane.setPrefSize(50, 50); final Scale scale = new Scale(1, 1); view.getTransforms().add(scale); scale.xProperty().bind(pane.widthProperty().divide(50)); scale.yProperty().bind(pane.heightProperty().divide(50)); CellGestures.makeResizable(pane); return pane; }
Example 4
Source File: PolygonSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public static Node createIconContent() { Polygon polygon = new Polygon(new double[]{ 45 , 10 , 10 , 80 , 80 , 80 , }); polygon.setStroke(Color.web("#b9c0c5")); polygon.setStrokeWidth(5); polygon.getStrokeDashArray().addAll(15d,15d); polygon.setFill(null); javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow(); effect.setOffsetX(1); effect.setOffsetY(1); effect.setRadius(3); effect.setColor(Color.rgb(0,0,0,0.6)); polygon.setEffect(effect); return polygon; }
Example 5
Source File: PolygonLayoutBoundsBug.java From gef with Eclipse Public License 2.0 | 6 votes |
@Override public void start(Stage primaryStage) throws Exception { final Polygon p = new Polygon(10, 30, 20, 20, 20, 40); p.setFill(Color.RED); p.setStroke(Color.BLACK); final Rectangle r = new Rectangle(); r.setFill(new Color(0, 0, 1, 0.5)); r.setX(p.getLayoutBounds().getMinX()); r.setY(p.getLayoutBounds().getMinY()); r.setWidth(p.getLayoutBounds().getWidth()); r.setHeight(p.getLayoutBounds().getHeight()); Group g = new Group(r, p); g.getTransforms().add(new Scale(10, 10)); Scene scene = new Scene(g, 500, 500); primaryStage.setScene(scene); primaryStage.sizeToScene(); primaryStage.show(); }
Example 6
Source File: PolygonSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public static Node createIconContent() { Polygon polygon = new Polygon(new double[]{ 45 , 10 , 10 , 80 , 80 , 80 , }); polygon.setStroke(Color.web("#b9c0c5")); polygon.setStrokeWidth(5); polygon.getStrokeDashArray().addAll(15d,15d); polygon.setFill(null); javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow(); effect.setOffsetX(1); effect.setOffsetY(1); effect.setRadius(3); effect.setColor(Color.rgb(0,0,0,0.6)); polygon.setEffect(effect); return polygon; }
Example 7
Source File: CreationMenuOnClickHandler.java From gef with Eclipse Public License 2.0 | 6 votes |
private Node createArrow(final boolean left) { // shape final Polygon arrow = new Polygon(); arrow.getPoints().addAll(left ? LEFT_ARROW_POINTS : RIGHT_ARROW_POINTS); // style arrow.setStrokeWidth(ARROW_STROKE_WIDTH); arrow.setStroke(ARROW_STROKE); arrow.setFill(ARROW_FILL); // effect effectOnHover(arrow, new DropShadow(DROP_SHADOW_RADIUS, getHighlightColor())); // action arrow.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { traverse(left); } }); return arrow; }
Example 8
Source File: EditorPane.java From Recaf with MIT License | 5 votes |
@Override public Node apply(int lineNo) { Polygon poly = new Polygon(shape); poly.getStyleClass().add("cursor-pointer"); poly.setFill(Color.RED); if(hasError(lineNo)) { String msg = getLineComment(lineNo); if(msg != null) { Tooltip.install(poly, new Tooltip(msg)); } } else { poly.setVisible(false); } return poly; }
Example 9
Source File: CustomNodeSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Polygon createUMLArrow() { Polygon polygon = new Polygon(new double[]{ 7.5, 0, 15, 15, 7.51, 15, 7.51, 40, 7.49, 40, 7.49, 15, 0, 15 }); polygon.setFill(Color.WHITE); polygon.setStroke(Color.BLACK); return polygon; }
Example 10
Source File: PolygonSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public PolygonSample() { super(180,90); // Simple red filled triangle Polygon polygon1 = new Polygon(new double[]{ 45 , 10 , 10 , 80 , 80 , 80 , }); polygon1.setFill(Color.RED); // Blue stroked polygon Polygon polygon2 = new Polygon(new double[]{ 135, 15, 160, 30, 160, 60, 135, 75, 110, 60, 110, 30 }); polygon2.setStroke(Color.DODGERBLUE); polygon2.setStrokeWidth(2); polygon2.setFill(null); // Create a group to show all the polygons); getChildren().add(new Group(polygon1, polygon2)); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Polygon 1 Fill", polygon1.fillProperty()), new SimplePropertySheet.PropDesc("Polygon 2 Stroke", polygon2.strokeProperty()) ); // END REMOVE ME }
Example 11
Source File: ScaleSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Polygon createArrow() { Polygon polygon = new Polygon(new double[]{ 7.5, 0, 15, 15, 10, 15, 10, 30, 5, 30, 5, 15, 0, 15 }); polygon.setFill(Color.web("#ff0900")); return polygon; }
Example 12
Source File: RotateSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Polygon createArrow() { Polygon polygon = new Polygon(new double[]{ 7.5, 0, 15, 15, 10, 15, 10, 30, 5, 30, 5, 15, 0, 15 }); polygon.setFill(Color.web("#ff0900")); return polygon; }
Example 13
Source File: CameraIcon.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 5 votes |
public CameraIcon(ObservableEntity oe) { super(oe); int w = W/2; int h = H/2; shape = new Polygon(-w, -h, w, -h, w, h, -w, h); shape.setFill(Color.TRANSPARENT); shape.setStrokeWidth(20); shape.strokeProperty().bind(getPlayerColor()); shape.translateXProperty().bind(getMapX().subtract(W/2)); shape.translateYProperty().bind(getMapY().subtract(H)); }
Example 14
Source File: PolygonSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public PolygonSample() { super(180,90); // Simple red filled triangle Polygon polygon1 = new Polygon(new double[]{ 45 , 10 , 10 , 80 , 80 , 80 , }); polygon1.setFill(Color.RED); // Blue stroked polygon Polygon polygon2 = new Polygon(new double[]{ 135, 15, 160, 30, 160, 60, 135, 75, 110, 60, 110, 30 }); polygon2.setStroke(Color.DODGERBLUE); polygon2.setStrokeWidth(2); polygon2.setFill(null); // Create a group to show all the polygons); getChildren().add(new Group(polygon1, polygon2)); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Polygon 1 Fill", polygon1.fillProperty()), new SimplePropertySheet.PropDesc("Polygon 2 Stroke", polygon2.strokeProperty()) ); // END REMOVE ME }
Example 15
Source File: RotateSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Polygon createArrow() { Polygon polygon = new Polygon(new double[]{ 7.5, 0, 15, 15, 10, 15, 10, 30, 5, 30, 5, 15, 0, 15 }); polygon.setFill(Color.web("#ff0900")); return polygon; }
Example 16
Source File: Exercise_15_14.java From Intro-to-Java-Programming with MIT License | 5 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create a polygon and set it properties Polygon polygon = new Polygon(); pane.getChildren().add(polygon); ObservableList<Double> list = polygon.getPoints(); list.addAll(40.0, 20.0, 70.0, 40.0, 60.0, 80.0, 45.0, 45.0, 20.0, 60.0); polygon.setFill(Color.WHITE); polygon.setStroke(Color.BLACK); // Create and register the handle pane.setOnMouseMoved(e -> { pane.getChildren().clear(); Text text = new Text(e.getX(), e.getY(), "Mouse point is " + (polygon.contains(e.getX(), e.getY()) ? "inside " : "outside ") + "the polygon"); pane.getChildren().addAll(polygon, text); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 300, 150); primaryStage.setTitle("Exercise_15_14"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 17
Source File: TranslateSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Polygon createArrow() { Polygon polygon = new Polygon(new double[]{ 7.5, 0, 15, 15, 10, 15, 10, 30, 5, 30, 5, 15, 0, 15 }); polygon.setFill(Color.web("#ff0900")); return polygon; }
Example 18
Source File: Exercise_14_25.java From Intro-to-Java-Programming with MIT License | 4 votes |
public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); pane.setPadding(new Insets(10, 10, 10, 10)); // Create a circle Circle circle = new Circle(60, 60, 40); circle.setFill(Color.WHITE); circle.setStroke(Color.BLACK); pane.getChildren().addAll(circle); // Create a polygon Polygon polygon = new Polygon(); pane.getChildren().add(polygon); polygon.setFill(Color.WHITE); polygon.setStroke(Color.BLACK); ObservableList<Double> list = polygon.getPoints(); // Generate random angles in radians between 0 and 2PI ArrayList<Double> angles = new ArrayList<>(); for (int i = 0; angles.size() < 5; i++) { double angle = (Math.random() * (2 * Math.PI)); if (!angles.contains(angle)) { angles.add(angle); } } // Sort angles clockwise java.util.Collections.sort(angles); // Get 5 points on the circle for (int i = 0; i < angles.size(); i++) { list.add(circle.getCenterX() + circle.getRadius() * Math.cos(angles.get(i))); list.add(circle.getCenterY() - circle.getRadius() * Math.sin(angles.get(i))); } // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("Exercise_14_25"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 19
Source File: MessageItemLeft.java From oim-fx with MIT License | 4 votes |
private void initComponent() { this.getChildren().add(rootPane); rootPane.setTop(timePane); rootPane.setLeft(heahBox); rootPane.setCenter(centerPane); rootPane.setRight(rightBox); rightBox.setPrefWidth(40); heahBox.setPrefHeight(20); timeLabel.setStyle("-fx-text-fill:#fff;" + "-fx-background-color:#dadada;\r\n" + " -fx-background-radius:2;-fx-padding: 0 6px;"); nameLabel.setStyle("-fx-text-fill:rgba(120, 120, 120, 1)"); double value=38; Rectangle clip = new Rectangle(); clip.setWidth(value); clip.setHeight(value); clip.setArcHeight(value); clip.setArcWidth(value); StackPane heahPane = new StackPane(); heahPane.setClip(clip); heahPane.getChildren().add(headImageView); timePane.getChildren().add(timeLabel); heahBox.getChildren().add(heahPane); headImageView.setFitWidth(40); headImageView.setFitHeight(40); Polygon polygon = new Polygon(new double[] { 0, 10, 10, 0, 10, 20, }); polygon.setFill(Color.web("rgba(220, 220, 220, 1.0)")); //polygon.setStroke(Color.BLUE); //polygon.setStyle("-fx-background-color:rgba(245, 245, 245, 1);"); VBox arrowBox = new VBox(); arrowBox.setPadding(new Insets(3, 0, 0, 0)); arrowBox.setAlignment(Pos.TOP_LEFT); arrowBox.getChildren().add(polygon); contentBox.setStyle("-fx-background-color:rgba(220, 220, 220, 1);-fx-background-radius:3;"); centerBox.getChildren().add(arrowBox); centerBox.getChildren().add(contentBox); HBox nameBox=new HBox(); nameBox.setAlignment(Pos.TOP_LEFT); nameBox.setPadding(new Insets(0, 10, 0, 10)); nameBox.getChildren().add(nameLabel); centerPane.setTop(nameBox); centerPane.setCenter(centerBox); }
Example 20
Source File: MessageItemRight.java From oim-fx with MIT License | 4 votes |
private void initComponent() { this.getChildren().add(rootPane); rootPane.setTop(timePane); rootPane.setLeft(leftBox); rootPane.setCenter(centerPane); rootPane.setRight(heahBox); leftBox.setPrefWidth(40); heahBox.setPrefHeight(20); timeLabel.setStyle("-fx-text-fill:#fff;" + "-fx-background-color:#dadada;\r\n" + " -fx-background-radius:2;-fx-padding: 0 6px;"); nameLabel.setStyle("-fx-text-fill:rgba(120, 120, 120, 1)"); double value=38; Rectangle clip = new Rectangle(); clip.setWidth(value); clip.setHeight(value); clip.setArcHeight(value); clip.setArcWidth(value); StackPane heahPane = new StackPane(); heahPane.setClip(clip); heahPane.getChildren().add(headImageView); timePane.getChildren().add(timeLabel); heahBox.getChildren().add(heahPane); headImageView.setFitWidth(40); headImageView.setFitHeight(40); Polygon polygon = new Polygon(new double[] { 0, 0, 10, 10, 0, 20, }); polygon.setFill(Color.web("rgba(44, 217, 44, 1)")); //polygon.setStroke(Color.BLUE); //polygon.setStyle("-fx-background-color:rgba(245, 245, 245, 1);"); VBox arrowBox = new VBox(); arrowBox.setPadding(new Insets(3, 0, 0, 0)); arrowBox.setAlignment(Pos.TOP_RIGHT); arrowBox.getChildren().add(polygon); contentBox.setStyle("-fx-background-color:rgba(44, 217, 44, 1);-fx-background-radius:3;"); centerBox.setAlignment(Pos.CENTER_RIGHT); centerBox.getChildren().add(contentBox); centerBox.getChildren().add(arrowBox); HBox nameBox=new HBox(); nameBox.setAlignment(Pos.TOP_RIGHT); nameBox.setPadding(new Insets(0, 10, 0, 10)); nameBox.getChildren().add(nameLabel); centerPane.setTop(nameBox); centerPane.setCenter(centerBox); }