JFXtras Core 入門 - Shape (2)
シェイプの2回目です。前回は Arrow で矢印を描いてみました。JFXtras Core 0.5 の org.jfxtras.scene.shape パッケージには他にも沢山のシェイプがあります。
org.jfxtras.scene.shape パッケージのクラス
- Almond
- Arrow
- Asterisk
- Astroid
- Balloon
- Cross
- Donut
- ETriangle
- ITriangle
- Lauburu
- MultiRoundRectangle
- Rays
- RegularPolygon
- ResizableEllipse
- ResizableRectangle
- ReuleauxTriangle
- RoundPin
- RTriangle
- Star2
今回はこれらのうち
を描いてみようと思います。
org.jfxtras.scene.shape.Almond
import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.paint.Color; import org.jfxtras.scene.shape.Almond; Stage { title: "JFXtras Shape Almond" width: 150 height: 150 scene: Scene { content: [ Almond { centerX: 50 centerY: 50 width: 50 fill: Color.ORANGE } ] } }
プロパティ | 説明 |
---|---|
centerX | シェイプの中心の X 座標 |
centerY | シェイプの中心の X 座標 |
width | アーモンドの一番太い部分の幅 |
org.jfxtras.scene.shape.Asterisk
import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.paint.Color; import org.jfxtras.scene.shape.Asterisk; Stage { title: "JFXtras Shape Asterisk" width: 150 height: 150 scene: Scene { content: [ Asterisk { centerX: 50 centerY: 50 radius: 30 width: 10 beams: 6 roundness: 0.5 fill: Color.BLUE } ] } }
プロパティ | 説明 |
---|---|
beams | 中心から外側へ放射状に伸びる柱の数 |
radius | 中心から柱の先端までの半径 |
roundness | 柱の先端の丸み。0.0 から 1.0 までの範囲で 1.0 が一番丸い |
width | 柱一本の幅 |
radius: 50, width: 20, beams: 3, roundness: 0
org.jfxtras.scene.shape.Astroid
import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.paint.Color; import org.jfxtras.scene.shape.Astroid; Stage { title: "JFXtras Shape Astroid" width: 150 height: 150 scene: Scene { content: [ Astroid { centerX: 50 centerY: 50 radius: 40 fill: Color.RED } ] } }
プロパティの意味は他のシェイプと同様なので割愛します。
org.jfxtras.scene.shape.Balloon
import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.paint.Color; import org.jfxtras.scene.shape.Balloon; Stage { title: "JFXtras Shape Balloon" width: 150 height: 150 scene: Scene { content: [ Balloon { x: 30 y: 30 width: 50 height: 50 arc: 20 tabWidth: 20 tabHeight: 10 tabDisplacement: 0.5 tabLocation: Balloon.TAB_AT_LEFT anglePosition: Balloon.NONE fill: Color.YELLOW } ] } }
プロパティ | 説明 |
---|---|
anglePosition | タブ(耳?正式名称がわかりません)の向き |
arc | 角の丸み |
tabDisplacement | タブ(耳?)の一辺上の位置。0.0 から 1.0 までの値で 0.5 が中央 |
tabHeight | タブ(耳?)の高さ(長さ) |
tabLocation | タブ(耳?)を配置する位置 |
tabWidth | タブ(耳?)の幅(太さ) |
anglePosition と tabDisplacement には設定する定数が定義されているので詳しくは API のドキュメントを参照してください。
anglePosition: Balloon.ANGLE_AT_START, arc: 30, tabDisplacement: 1.0, tabHeight: 40, tabLocation: Balloon.TAB_AT_RIGHT, tabWidth: 10