当前位置: 首页>>代码示例>>Java>>正文


Java Polygon.getPoints方法代码示例

本文整理汇总了Java中javafx.scene.shape.Polygon.getPoints方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.getPoints方法的具体用法?Java Polygon.getPoints怎么用?Java Polygon.getPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.shape.Polygon的用法示例。


在下文中一共展示了Polygon.getPoints方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isInPolygon

import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
public static final boolean isInPolygon(final double X, final double Y, final Polygon POLYGON) {
    List<Double> points              = POLYGON.getPoints();
    int          noOfPointsInPolygon = POLYGON.getPoints().size() / 2;
    double[]     pointsX             = new double[noOfPointsInPolygon];
    double[]     pointsY             = new double[noOfPointsInPolygon];
    int          pointCounter        = 0;
    for (int i = 0 ; i < points.size() ; i++) {
        if (i % 2 == 0) {
            pointsX[i] = points.get(pointCounter);
        } else {
            pointsY[i] = points.get(pointCounter);
            pointCounter++;
        }
    }
    return isInPolygon(X, Y, noOfPointsInPolygon, pointsX, pointsY);
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:17,代码来源:Helper.java

示例2: convertPolygon

import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
public static String convertPolygon(final Polygon POLYGON) {
	final StringBuilder fxPath = new StringBuilder();
	final int size = POLYGON.getPoints().size();
	if (size % 2 == 0) {
		List<Double> coordinates = POLYGON.getPoints();
		for (int i = 0; i < size; i += 2) {
			fxPath
					.append(i == 0 ? "M " : "L ")
					.append(coordinates.get(i))
					.append(" ")
					.append(coordinates.get(i + 1))
					.append(" ");
		}
		fxPath.append("Z");
	}
	return fxPath.toString();
}
 
开发者ID:stefaneidelloth,项目名称:JavaFxNodeToSvg,代码行数:18,代码来源:ShapeConverter.java

示例3: convertPolygon

import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
public static String convertPolygon(final Polygon POLYGON) {
    final StringBuilder fxPath = new StringBuilder();
    final int           size   = POLYGON.getPoints().size();
    if (size % 2 == 0) {
        List<Double> coordinates     = POLYGON.getPoints();
        for (int i = 0 ; i < size ; i += 2) {
            fxPath.append(i == 0 ? "M " : "L ")
                  .append(coordinates.get(i)).append(" ").append(coordinates.get(i + 1)).append(" ");
        }
        fxPath.append("Z");
    }
    return fxPath.toString();
}
 
开发者ID:Simego,项目名称:FXImgurUploader,代码行数:14,代码来源:ShapeConverter.java

示例4: drawTriangle

import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
/** 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);
}
 
开发者ID:jsquared21,项目名称:Intro-to-Java-Programming,代码行数:13,代码来源:Exercise_15_20.java

示例5: start

import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
@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
}
 
开发者ID:jsquared21,项目名称:Intro-to-Java-Programming,代码行数:29,代码来源:Exercise_15_14.java

示例6: start

import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a stack pane
	StackPane stackPane = new StackPane();

	// Create a polygon and set its properties
	Polygon polygon = new Polygon();
	stackPane.getChildren().add(polygon);
	polygon.setFill(Color.RED);
	polygon.setRotate(20);
	ObservableList<Double> list = polygon.getPoints();

	final double WIDTH = 200, HEIGHT = 200;
	double centerX = WIDTH / 2, centerY = HEIGHT / 2;
	double radius = Math.min(WIDTH, HEIGHT) * 0.4;

	// Add points to polygon list
	for (int i = 0; i < 8; i++) {
	 	list.add(centerX + radius * Math.cos(2 * i * Math.PI / 8));
	 	list.add(centerY - radius * Math.sin(2 * i * Math.PI / 8));
	}

	// Create a text and set its properties
	Text text = new Text("STOP");
	text.setFont(Font.font("Times new Roman", FontWeight.BOLD, 40));
	text.setFill(Color.WHITE);
	stackPane.getChildren().add(text);

	// Create a scene and place it in the stage
	Scene scene = new Scene(stackPane, WIDTH, HEIGHT);
	primaryStage.setTitle("Exercise_14_15"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
开发者ID:jsquared21,项目名称:Intro-to-Java-Programming,代码行数:35,代码来源:Exercise_14_15.java

示例7: start

import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
@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
}
 
开发者ID:jsquared21,项目名称:Intro-to-Java-Programming,代码行数:42,代码来源:Exercise_14_24.java

示例8: start

import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
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 
}
 
开发者ID:jsquared21,项目名称:Intro-to-Java-Programming,代码行数:45,代码来源:Exercise_14_25.java


注:本文中的javafx.scene.shape.Polygon.getPoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。