Java Code Examples for javafx.scene.shape.Line#getStartY()
The following examples show how to use
javafx.scene.shape.Line#getStartY() .
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: ImageManufacture.java From MyBox with Apache License 2.0 | 5 votes |
public static boolean inLine(Line line, int x, int y) { double d = (x - line.getStartX()) * (line.getStartY() - line.getEndY()) - ((line.getStartX() - line.getEndX()) * (y - line.getStartY())); return Math.abs(d) < 0.0001 && (x >= Math.min(line.getStartX(), line.getEndX()) && x <= Math.max(line.getStartX(), line.getEndX())) && (y >= Math.min(line.getStartY(), line.getEndY())) && (y <= Math.max(line.getStartY(), line.getEndY())); }
Example 2
Source File: Exercise_14_21.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 two circles Circle circle1 = new Circle(Math.random() * 201, Math.random() * 201, 15); Circle circle2 = new Circle(Math.random() * 201, Math.random() * 201, 15); // Create a line Line line = new Line(circle1.getCenterX(), circle1.getCenterY(), circle2.getCenterX(), circle2.getCenterY()); // Calculate distane between the two centers of the circles double distance = Math.sqrt(Math.pow(line.getEndX() - line.getStartX(), 2) + Math.pow(line.getEndY() - line.getStartY(), 2)); // Create a text double x = (line.getStartX() + line.getEndX()) / 2; double y = (line.getStartY() + line.getEndY()) / 2; Text text = new Text(x, y, String.valueOf(distance)); // Add nodes to pane pane.getChildren().addAll(circle1, circle2, line, text); // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("Exercise_14_21"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 3
Source File: Shape2Geometry.java From gef with Eclipse Public License 2.0 | 2 votes |
/** * Converts the given JavaFX {@link Line} to a * {@link org.eclipse.gef.geometry.planar.Line}. * * @param line * The JavaFX {@link Line} to convert. * @return The newly created {@link org.eclipse.gef.geometry.planar.Line} * that describes the given {@link Line}. */ public static org.eclipse.gef.geometry.planar.Line toLine(Line line) { return new org.eclipse.gef.geometry.planar.Line(line.getStartX(), line.getStartY(), line.getEndX(), line.getEndY()); }