JFXtras Core 入門 - Shape (5)

シェイプの5回目です。

今回は残りの

  • ResizableRectangle
  • ReuleauxTriangle
  • RoundPin
  • RTriangle
  • Star2

です。


org.jfxtras.scene.shape.ResizableRectangle

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

Stage {
    title: "JFXtras Shape ResizableRectangle"
    width: 250
    height: 250
    scene: Scene {
        content: [
            ResizableRectangle {
                fill: Color.PALEVIOLETRED
                strokeWidth: 20
                stroke: Color.BLACK
            }
        ]
    }
}

特に設定の必要なプロパティはありません。デフォルトでは縦横サイズは 200, 200 になります。width, height を好みの大きさに設定することもできます。
その他のプロパティは javafx.scene.shape.Rectangle と同じの為、割愛します。
ResizableRectangle と通常の Rectangle との違いは、長方形を囲む線が長方形の width と height で指定した領域を超えて描かれるかどうかです。
ResizableRectangle の四辺は ResizableRectangle の width と height の領域の内側に描かれ、このサイズより大きくなることはありません。
一方 Rectangle の四辺は太くすると width と height の領域の内側・外側両方に描かれる為、異なる性質を持ちます。比較するとわかると思います。以下は通常の Rectangle の例です。

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;

Stage {
    title: "JavaFX Shape Rectangle"
    width: 250
    height: 250
    scene: Scene {
        content: [
            Rectangle {
                width: 200
                height: 200
                fill: Color.GREEN
                strokeWidth: 20
                stroke: Color.BLACK
            }
        ]
    }
}

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


org.jfxtras.scene.shape.ReuleauxTriangle

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

Stage {
    title: "JFXtras Shape ReuleauxTriangle"
    width: 150
    height: 150
    scene: Scene {
        content: [
            ReuleauxTriangle {
                centerX: 60
                centerY: 60
                radius: 50
                fill: Color.TOMATO
            }
        ]
    }
}

難しいプロパティはありませんので割愛します。

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


org.jfxtras.scene.shape.RoundPin

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

Stage {
    title: "JFXtras Shape RoundPin"
    width: 150
    height: 150
    scene: Scene {
        content: [
            RoundPin {
                centerX: 60
                centerY: 40
                radius: 30
                height: 70
                fill: Color.STEELBLUE
            }
        ]
    }
}


プロパティ 説明
centerX 半円部分の中心の X 座標
centerY 半円部分の中心の Y 座標
radius 半円部分の中心からの半径
height 半円を除いた錐状の部分の高さ

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


org.jfxtras.scene.shape.RTriangle

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

Stage {
    title: "JFXtras Shape RTriangle"
    width: 150
    height: 150
    scene: Scene {
        content: [
            RTriangle {
                x: 30
                y: 100
                width: 70
                height: 90
                anglePosition: RTriangle.ANGLE_AT_END
                fill: Color.INDIANRED
            }
        ]
    }
}


プロパティ 説明
anglePosition 90度の角の場所。定数 ANGLE_AT_START, ANGLE_AT_END, NONE で指定。デフォルトは ANGLE_AT_START

直角三角形です。anglePosition に ANGLE_AT_START を指定(又は省略)すると90度の角が左下に, ANGLE_AT_END を指定すると右下に来ます。NONE を指定すると二等辺三角形になります。

anglePosition: RTriangle.ANGLE_AT_START

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


org.jfxtras.scene.shape.Star2

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

Stage {
    title: "JFXtras Shape Star2"
    width: 150
    height: 150
    scene: Scene {
        content: [
            Star2 {
                centerX: 50
                centerY: 50
                outerRadius: 40
                innerRadius: 20
                count: 6
                fill: Color.INDIGO
            }
        ]
    }
}


プロパティ 説明
count 星の尖りの数
innerRadius 図形の中心から星の尖りの始まりまでの半径
outerRadius 図形の中心から星の尖りの先端までの半径

count: 5

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


以上で JFXtras Core 0.5 のシェイプを全て試してみました。
次回は最後にシェイプについて気付いたことを、まとめと言う程ではありませんが、書いてみたいと思います。