📜  JavaFX 圆柱体

📅  最后修改于: 2020-10-14 05:33:50             🧑  作者: Mango

JavaFX圆柱体

通常,圆柱体可以定义为三维立体物体,其具有通过曲面连接的两个平行的圆形基础。有两个描述圆柱的主要参数,即曲面的高度和圆形底座的半径。

下图显示了圆柱体的半径和高度。

在JavaFX中,类javafx.scene.shape.Cylinder表示一个圆柱体。我们只需要实例化此类即可创建圆柱体。

物产

下表描述了该类的属性以及setter方法。

Property Property Setter Methods
height It is a double type property. It represents the Z dimension of the Cylinder. setHeight(double value)
radius It is a double type property. It represents the radius of the Cylinder. setRadius(double value)

建设者

该类中有三个构造函数。

    • public Cylinder():使用默认参数创建新实例。
    • public Cylinder(double radius,double height):创建具有指定半径和高度的新实例。
    • public Cylinder(双半径,双高度,整数除法):创建具有指定半径,高度和除法的新实例。

打包申请;导入javafx.application.Application;导入javafx.scene.Group;导入javafx.scene.PerspectiveCamera;导入javafx.scene.Scene;导入javafx.scene.paint.Color;导入javafx.scene.shape.Cylinder;导入javafx.stage.Stage;公共类CylinderExample扩展应用程序{@Override public void start(Stage primaryStage)throws Exception {// TODO自动生成的方法stub //创建圆柱体Cyninder = new Cylinder(); //设置圆柱体的半径和高度cyn.setRadius(80); cyn.setHeight(200); cyn.setTranslateX(300); cyn.setTranslateY(250); //设置相机PerspectiveCamera camera = new PerspectiveCamera(); camera.setTranslateX(100); camera.setTranslateY(100); camera.setTranslateZ(0); //设置组和阶段组root = new Group(); root.getChildren()。addAll(cyn);场景=新场景(root,450,300,Color.LIMEGREEN); scene.setCamera(camera); primaryStage.setScene(scene); primaryStage.setTitle(“ Cylinder Example”); primaryStage.show(); } public static void main(String [] args){launch(args); }}

JavaFX圆柱体

下一主题JavaFX Sphere