Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
text( font: "32pt", text: "This is Text")
button( font: "16pt Courier" text: "Push Here")

Paints/Colors

All color and paint attributes may be set with one of the JavaFX Paint or Color objects (javafx.scene.paint.LinearGradientjavafx.scene.paint.RadialGradient and javafx.scene.paint.Color). In addition, colors may be set using the pseudo color variables, such as red, green, blue, etc. Colors may also be defined as a web string such as "#333", "cyan", etc. Colors may also be defined using the JavaFX CSS styles for colors, linear, and radial gradients. (see [JavaFX CSS Reference Guide.|http://download.oracle.com/javafx/2.0/api/javafx/scene/javafx.scene/doc-files/cssref.html]) Also see SceneGraphBuilder - paint for more details.

Code Block

scene(fill: hsb(128, 0.5, 0.5, 0.5)

...

)
circle(centerX: 50, centerY: 50, radius: 25,

...

 fill: rgb(0, 0, 255))

...


rectangle(x: 100, y: 50, width: 50, height: 50, fill: red)

...


rectangle(x: 100, y: 50, width: 50, height: 50, fill: "#333")

...


rectangle(x: 100, y: 50, width: 50, height: 50, fill: "linear (0%,0%) to (0%,100%)

...

 stops (0%,gray)

...

 (100%,black)")
Code Block

Enumerated Values

Insets

Geometry

ToggleGroups

Enumerated Values

All Java Enumerations may be set using their string equivalents. For example, if an attribute field is of type javafx.geometry.Pos, then the value may be set with one of the string values, "center", "bottom_left", etc.

There are some special cases where Object instances are used rather than enumerations. For example the javafx.scene.Cursor class contains numerous singleton instances for the various cursors that may be set on the scene. Also, there are special pseudo variables for the Orientation enumeration, horizontal and vertical.

Code Block

scene(cursor: "OPEN_HAND")     // javafx.scene.Cursor static member.
sg.stage(style: "transparent") // javafx.stage.StageStyle enumeration
scrollBar(min: 0, max: 100, value: 50, orientation: horizontal) // javafx.geometry.Orientation enumeration

Insets

The javafx.geometry.Insets class may be instantiated by using the javafx class, or by using a Groovy number list. If a number list is used, it may contain, one, two, or four numbers. If one number is presented then all sides of the Insets will be set to that value. If two numbers are presented then the first number will be used to set the top and bottom side of the Inset, and the second number will be used to set the left and right side of the Inset. If four numbers are present in the list, the numbers will be assigned to the the top, right, bottom and left in order. An empty list or the String "empty" will map to the Insets.EMPTY object.

Code Block

stackPane(style: "-fx-background-color: burlywood", padding: 20) 
stackPane(style: "-fx-background-color: burlywood", padding: [10])

stackPane(style: "-fx-background-color: burlywood", padding: [50, 25])

stackPane(style: "-fx-background-color: burlywood", padding: [0, 50, 0, 0])

stackPane(style: "-fx-background-color: burlywood", padding: [])

stackPane(style: "-fx-background-color: burlywood", padding: "EMPTY")


Geometry

The Geometry objects in the javafx.geometry package, Point2D, Point3D, Dimension2D, Rectangle2D, and BoundingBox,  may be set using numbered lists. For the 2D classes, 2 numbers must be provided, and for the 3D classes, 3 numbers must be provided. BoundingBox may be either 2D, requiring 4 values, or 3D, requiring 6 values. A Rectangle2D may also take and empty list or the "EMPTY" string as shown in the previous section on Insets.

Code Block

rotate(angle: 90, axis: [1,1,0])
imageView(viewport: [0,0, 400, 400])

ToggleGroups

ToggleGroups are identified with an unique string across the SceneGraphBuilder context. To tie a toggle type button to a specific ToggleGroup, use the special attribute toggleGroup on the Toggle type button. Buttons with the same ToggleGroup names will be assigned the same ToggleGroup instance.

Code Block

scene(fill: hsb(128, 0.5, 0.5, 0.5), root: group()) {
            toggleButton (
                layoutX: 25,
                layoutY: 300,
                font: "16pt Courier",
                text: "One",
                selected: true,
                toggleGroup: "Group1"
            )
            toggleButton (
                layoutX: 125,
                layoutY: 300,
                font: "16pt Courier",
                text: "Two",
                selected: true,
                toggleGroup: "Group1"
            )