JFXtras Core 入門 - Shape (4)

シェイプの4回目です。

今回は

  • MultiRoundRectangle
  • Rays
  • RegularPolygon
  • ResizableEllipse

を描いてみようと思います。


org.jfxtras.scene.shape.MultiRoundRectangle

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import org.jfxtras.scene.shape.MultiRoundRectangle;

Stage {
    title: "JFXtras Shape MultiRoundRectangle"
    width: 150
    height: 150
    scene: Scene {
        content: [
            MultiRoundRectangle {
                x: 10
                y: 10
                width: 80
                height: 80
                topLeftWidth: 10
                topLeftHeight: 10
                bottomLeftWidth: 20
                bottomLeftHeight: 20
                topRightWidth: 30
                topRightHeight: 30
                bottomRightWidth: 0
                bottomRightHeight: 0
                fill: Color.BLUEVIOLET
            }
        ]
    }
}


プロパティ 説明
topLeftWidth 左上角の弧の横方向の半径
topLeftHeight 左上角の弧の縦方向の半径
bottomLeftWidth 左下角の弧の横方向の半径
bottomLeftHeight 左下角の弧の縦方向の半径
topRightWidth 右上角の弧の横方向の半径
topRightHeight 右上角の弧の縦方向の半径
bottomRightWidth 右下角の弧の横方向の半径
bottomRightHeight 右下角の弧の縦方向の半径

http://jfxtras.googlecode.com/svn/site/javadoc/release-0.5/org.jfxtras.scene.shape/org.jfxtras.scene.shape.MultiRoundRectangle.html


org.jfxtras.scene.shape.Rays

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import org.jfxtras.scene.shape.Rays;

Stage {
    title: "JFXtras Shape Rays"
    width: 150
    height: 150
    scene: Scene {
        content: [
            Rays {
                rounded: false
                extent: 0.7
                centerX: 60
                centerY: 60
                radius: 50
                rays: 5
                fill: Color.DARKGOLDENROD
            }
        ]
    }
}


プロパティ 説明
extent Rayの先端の拡がり。0.0 から 1.0 までの範囲で 1.0 が一番拡がりが大きい
rays Rayの数
rounded Rayの先端を丸めるかどうか。true にすると丸める

extent: 0.4, rays: 4

Asterisk にも似ていると思います。

http://jfxtras.googlecode.com/svn/site/javadoc/release-0.5/org.jfxtras.scene.shape/org.jfxtras.scene.shape.Rays.html


org.jfxtras.scene.shape.RegularPolygon

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import org.jfxtras.scene.shape.RegularPolygon;

Stage {
    title: "JFXtras Shape RegularPolygon"
    width: 150
    height: 150
    scene: Scene {
        content: [
            RegularPolygon {
                centerX: 50
                centerY: 50
                radius: 40
                sides: 6
                fill: Color.HOTPINK
            }
        ]
    }
}


プロパティ 説明
sides 辺の数

sides: 8

正○角形なわけですね。
http://jfxtras.googlecode.com/svn/site/javadoc/release-0.5/org.jfxtras.scene.shape/org.jfxtras.scene.shape.RegularPolygon.html


org.jfxtras.scene.shape.ResizableEllipse

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import org.jfxtras.scene.shape.ResizableEllipse;

Stage {
    title: "JFXtras Shape ResizableEllipse"
    width: 150
    height: 150
    scene: Scene {
        content: [
            ResizableEllipse {
                fill: Color.PALEVIOLETRED
            }
        ]
    }
}

特に設定の必要なプロパティはありません。デフォルトではコンテナノードの縦横サイズから自分のサイズを決定します。縦横 200, 200 になります。width, height を好みの大きさに設定することもできます。(使いどころがよくわかりませんけど。。。)

http://jfxtras.googlecode.com/svn/site/javadoc/release-0.5/org.jfxtras.scene.shape/org.jfxtras.scene.shape.ResizableEllipse.html


今日はここまで。シェイプは次回が最終回です。


追記
ResizableEllipse のデフォルトのサイズについて修正しました。