📅  最后修改于: 2020-10-14 01:12:02             🧑  作者: Mango
通常,圆弧是圆或椭圆的圆周的一部分。需要在某些JavaFX应用程序中创建它。 JavaFX允许我们通过实例化javafx.scene.shape.Arc类来在GUI上创建Arc。只需将类的属性设置为适当的值即可按照应用程序的要求显示弧线。
下表列出了JavaFX Arc属性及其设置方法。
Property | Description | Method |
---|---|---|
CenterX | X coordinate of the centre point | serCenterX(Double value) |
CenterY | Y coordinate of the centre point | setCenterY(Double value) |
Length | Angular extent of the arc in degrees | setLength(Double value) |
RadiousX | Full width of the ellipse of which, Arc is a part. | setRadiusX(Double value) |
RadiousY | Full height of the ellipse of which, Arc is a part | setRadiusY(Double value) |
StartAngle | Angle of the arc in degrees | setStartAngle(Double value) |
type | Type of Arc : OPEN, CHORD, ROUND | setType(Double value) |
package application;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.stage.Stage;
public class Shape_Example extends Application{
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
primaryStage.setTitle("Arc Example");
Group group = new Group();
Arc arc = new Arc();
arc.setCenterX(100);
arc.setCenterY(100);
arc.setRadiusX(50);
arc.setRadiusY(80);
arc.setStartAngle(30);
arc.setLength(70);
arc.setType(ArcType.ROUND);
arc.setFill(Color.RED);
group.getChildren().addAll(arc);
Scene scene = new Scene(group,200,300,Color.GRAY);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
输出: