javafx.scene.shape.Polygon#setStroke ( )源码实例Demo

下面列出了javafx.scene.shape.Polygon#setStroke ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: fxgraph   文件: TriangleCell.java
@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;
}
 
源代码2 项目: marathonv5   文件: PolygonSample.java
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;
}
 
源代码3 项目: marathonv5   文件: PolygonSample.java
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;
}
 
源代码4 项目: gef   文件: PolygonLayoutBoundsBug.java
@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();
}
 
源代码5 项目: gef   文件: CreationMenuOnClickHandler.java
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;
}
 
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);
	}
}
 
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.BLACK);

		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);
	}
}
 
源代码8 项目: marathonv5   文件: PolygonSample.java
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
}
 
源代码9 项目: marathonv5   文件: CustomNodeSample.java
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;
}
 
源代码10 项目: marathonv5   文件: PolygonSample.java
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
}
 
源代码11 项目: marathonv5   文件: CustomNodeSample.java
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;
}
 
源代码12 项目: mars-sim   文件: MenuItem.java
public MenuItem(String name, int width) {
    	int n = name.length();
//        Polygon bg = new Polygon(
//                0, 0,
//                220, 0,
//                245, 25,
//                220, 50,
//                0, 50
//        );
        Polygon bg = new Polygon(
                0, 0,
                width - 20 , 0,
                width, 25,
                width - 20, 50,
                0, 50
        );

        bg.setStroke(Color.color(1, 1, 1, 0.1));//75));
        //bg.setEffect(new GaussianBlur());
        bg.fillProperty().bind(
                Bindings.when(pressedProperty())
                        .then(Color.color(1, 1, 1, 0.35))//Color.color(139D/255D, 69D/255D, 19D/255D, 0.35))
                        .otherwise(Color.color(1, 1, 1, 0.15))
        );

        text = new Text(name);
        text.setTranslateX((18 - n) * 6.5);
        text.setTranslateY(34);
        text.setFont(Font.loadFont(MenuApp.class.getResource("/fonts/Penumbra-HalfSerif-Std_35114.ttf").toExternalForm(), 22));
        text.setFill(Color.LIGHTGOLDENRODYELLOW);//.CORAL);//.WHITE);
        text.effectProperty().bind(
                Bindings.when(hoverProperty())
                        .then(shadow)
                        .otherwise(blur)
        );

        getChildren().addAll(bg, text);
    }
 
源代码13 项目: FXTutorials   文件: Civ6MenuItem.java
public Civ6MenuItem(String name) {
    Polygon bg = new Polygon(
            0, 0,
            200, 0,
            215, 15,
            200, 30,
            0, 30
    );
    bg.setStroke(Color.color(1, 1, 1, 0.75));
    bg.setEffect(new GaussianBlur());

    bg.fillProperty().bind(
            Bindings.when(pressedProperty())
                    .then(Color.color(0, 0, 0, 0.75))
                    .otherwise(Color.color(0, 0, 0, 0.25))
    );

    text = new Text(name);
    text.setTranslateX(5);
    text.setTranslateY(20);
    text.setFont(Font.loadFont(Civ6MenuApp.class.getResource("res/Penumbra-HalfSerif-Std_35114.ttf").toExternalForm(), 14));
    text.setFill(Color.WHITE);

    text.effectProperty().bind(
            Bindings.when(hoverProperty())
                    .then(shadow)
                    .otherwise(blur)
    );

    getChildren().addAll(bg, text);
}
 
源代码14 项目: Intro-to-Java-Programming   文件: Exercise_15_20.java
/** Create a polygon */
private void drawTriangle(Pane pane, ArrayList<Circle> p) {
	Polygon polygon = new Polygon();
	pane.getChildren().add(polygon);
	ObservableList<Double> points = polygon.getPoints();
	for (int i = 0; i < p.size(); i++) {
		points.add(p.get(i).getCenterX());
		points.add(p.get(i).getCenterY());
	}
	polygon.setFill(Color.WHITE);
	polygon.setStroke(Color.BLACK);
}
 
源代码15 项目: Intro-to-Java-Programming   文件: Exercise_15_14.java
@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
}
 
源代码16 项目: Intro-to-Java-Programming   文件: Exercise_14_11.java
/** Return a Polygon of specified properties */
private Polygon getPolygon(Circle c) {
	double length = c.getRadius() / 4;
	Polygon p = new Polygon(c.getCenterX(), c.getCenterY() - length,
		c.getCenterX() - length, c.getCenterY() + length, c.getCenterX() + length, 
		c.getCenterY() + length);
	p.setFill(Color.WHITE);
	p.setStroke(Color.BLACK);
	return p;
}
 
源代码17 项目: Intro-to-Java-Programming   文件: Exercise_14_24.java
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a scanner
	Scanner input = new Scanner(System.in);

	// Create a pane
	Pane pane = new Pane();

	// Create a polygon
	Polygon polygon = new Polygon();
	polygon.setFill(Color.WHITE);
	polygon.setStroke(Color.BLACK);
	pane.getChildren().add(polygon);
	ObservableList<Double> list = polygon.getPoints();

	// Prompt the user to enter the coordinates of five points
	System.out.print("Enter five points: ");
	for (int i = 0; i < 8; i++) {
		list.add(input.nextDouble());
	}
	double x = input.nextDouble();
	double y = input.nextDouble();

	// Create a circle
	Circle circle = new Circle(x, y, 5);
	pane.getChildren().add(circle);

	// Create a Text
	Text text = new Text("        The point is " + 
		(polygon.contains(x, y) ? "" : "not ") + "inside the polygon  ");

	// Create a vbox
	VBox vbox = new VBox(5);
	vbox.getChildren().addAll(pane, text);

	// Create a Scene and place it in the stage
	Scene scene = new Scene(vbox);
	primaryStage.setTitle("Exercise_14_24"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
源代码18 项目: Intro-to-Java-Programming   文件: Exercise_14_25.java
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 
}