JavaFXの2D形状のストロークマイター制限プロパティを説明する
Stroke Mitre Limitプロパティは、StrokeLineJoin.MITERスタイルのストローク線結合の制限を指定/定義します。この値は、 setStrokeMiterLimit()を使用して設定できます。 javafx.scene.shape.Shapeのメソッド クラス。
このメソッドはdouble値を受け入れ、ストロークマイター制限を指定された値に制限します。指定された値が1.0未満の場合。 1.0と見なされます。
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.StrokeLineJoin;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class StrokeMiterExample extends Application {
public void start(Stage stage) {
Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 12);
Text label2 = new Text("Miter Limit: 3");
label2.setFont(font);
label2.setX(50.0);
label2.setY(275.0);
Polygon shape1 = new Polygon(100.0, 50.0, 50.0, 200.0, 150.0, 200.0);
shape1.setStroke(Color.BLUE);
shape1.setStrokeWidth(20);
shape1.setStrokeLineJoin(StrokeLineJoin.MITER);
shape1.setStrokeMiterLimit(3);
Text label3 = new Text("Miter Limit: 4");
label3.setFont(font);
label3.setX(250.0);
label3.setY(275.0);
Polygon shape2 = new Polygon(300.0, 50.0, 250.0, 200.0, 350.0, 200.0);
shape2.setStroke(Color.BLUE);
shape2.setStrokeWidth(20.0);
shape2.setStrokeLineJoin(StrokeLineJoin.MITER);
shape2.setStrokeMiterLimit(4);
Text label4 = new Text("Miter Limit: 0.4");
label4.setFont(font);
label4.setX(430.0);
label4.setY(275.0);
Polygon shape3 = new Polygon(490.0, 50.0, 440, 200.0, 540.0, 200.0);
shape3.setStroke(Color.BLUE);
shape3.setStrokeWidth(20.0);
shape3.setStrokeLineJoin(StrokeLineJoin.MITER);
shape3.setStrokeMiterLimit(0.4);
//Creating a Group object
Group root = new Group(label2, label3, label4, shape1, shape2, shape3);
//Creating a scene object
Scene scene = new Scene(root, 595, 310);
//Setting title to the Stage
stage.setTitle("Stroke Miter Limit");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents of the stage
stage.show();
}
public static void main(String args[]){
launch(args);
}
} 出力
-
JavaFXアプリケーションの構造を説明する
一般に、JavaFXアプリケーションには、次の図に示すように、ステージ、シーン、ノードの3つの主要なコンポーネントがあります。 ステージ ステージ(ウィンドウ)には、JavaFXアプリケーションのすべてのオブジェクトが含まれています。パッケージjavafx.stageのStageクラスで表されます。 。 show()を呼び出す必要があります ステージの内容を表示する方法。 シーングラフ シーングラフはツリーに似たデータ構造であり、最新のグラフィカルアプリケーションでは、ノードのコレクションです。 JavaFXアプリケーションでは、javafx.scene.thesceneクラスはシ
-
JavaFXシーングラフの説明
JavaFXでは、GUIアプリケーションはシーングラフを使用して構築されていました。シーングラフは、最新のグラフィカルアプリケーションにおけるツリーに似たデータ構造です。これはアプリケーションの開始点であり、ノードのコレクションです JavaFXで何かを表示するにはノードを使用してシーングラフを作成し、それをJavaFXアプリケーションの最上位コンテナであるStageクラスのオブジェクトに設定する必要があります。 ノードは、JavaFXアプリケーションの視覚的/グラフィカルなプリミティブオブジェクトです。 シーングラフの各ノードには単一の親があり、親を含まないノードはルートノードと呼