當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。