-
Notifications
You must be signed in to change notification settings - Fork 68
/
SubScene.scala
169 lines (148 loc) · 7.42 KB
/
SubScene.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* Copyright (c) 2011-2014, ScalaFX Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the ScalaFX Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE SCALAFX PROJECT OR ITS CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package scalafx.scene
import javafx.scene.{layout => jfxsl, paint => jfxsp}
import javafx.{collections => jfxc, scene => jfxs}
import scala.language.implicitConversions
import scalafx.Includes._
import scalafx.beans.property.{DoubleProperty, ObjectProperty}
import scalafx.collections._
import scalafx.delegate.SFXDelegate
import scalafx.scene.paint.Paint
object SubScene {
implicit def sfxSubScene2jfx(v: SubScene): jfxs.SubScene = if (v != null) v.delegate else null
}
/** Wraps [[http://docs.oracle.com/javafx/8/api/javafx/scene/SubScene.html]]. */
class SubScene(override val delegate: jfxs.SubScene)
extends Node(delegate)
with SFXDelegate[jfxs.SubScene] {
// TODO Combine common features with Scene in a trait used by both.
/** Creates a SubScene with a [[http://docs.oracle.com/javafx/8/api/javafx/scene/Group.html Group]]
* as root Node with a specified size.
*
* @param width The width of the scene
* @param height The height of the scene
*/
def this(width: Double, height: Double) = this(new jfxs.SubScene(new jfxs.Group(), width, height))
/** Constructs a SubScene with a [[http://docs.oracle.com/javafx/8/api/javafx/scene/Group.html Group]]
* as root Node, with a dimension of width and height,
* specifies whether a depth buffer is created for this scene and specifies the level of antialiasing required.
*/
def this(width: Double, height: Double, depthBuffer: Boolean, antiAliasing: SceneAntialiasing) =
this(new jfxs.SubScene(new jfxs.Group(), width, height, depthBuffer, antiAliasing))
/** Creates a SubScene for a specific root Node with a specific size. */
def this(root: Parent, width: Double, height: Double) = this(new jfxs.SubScene(root, width, height))
/** Constructs a SubScene consisting of a root, with a dimension of width and height,
* specifies whether a depth buffer is created for this scene and specifies the level of antialiasing required.
*/
def this(root: Parent, width: Double, height: Double, depthBuffer: Boolean, antiAliasing: SceneAntialiasing) =
this(new jfxs.SubScene(root, width, height, depthBuffer, antiAliasing))
/** Defines the root Node of the SubScene scene graph. */
def root: ObjectProperty[jfxs.Parent] = delegate.rootProperty
def root_=(v: Parent) {
ObjectProperty.fillProperty[jfxs.Parent](this.root, v)
}
/**
* Returns Nodes children from this Scene's `root`.
*/
def getChildren = root.value match {
case group: jfxs.Group => group.getChildren
case pane: jfxsl.Pane => pane.getChildren
case _ => throw new IllegalStateException("Cannot access children of root: " + root +
"\nUse a class that extends Group or Pane, or override the getChildren method.")
}
/**
* Returns Content's Node children from this Scene's `root`.
*/
def content: jfxc.ObservableList[jfxs.Node] = getChildren
/**
* Sets the list of Nodes children from this Scene's `root`, replacing the prior content. If you want append to
* current content, use `add` or similar.
*
* @param c list of Nodes children from this Scene's `root` to replace prior content.
*/
def content_=(c: Iterable[Node]) {
fillSFXCollection(this.content, c)
}
/**
* Sets a Node child, replacing the prior content. If you want append to current content, use `add` or similar.
*
* @param n Node child to replace prior content.
*/
def content_=(n: Node) {
fillSFXCollectionWithOne(this.content, n)
}
/** Specifies the type of camera use for rendering this SubScene. */
def camera: ObjectProperty[jfxs.Camera] = delegate.cameraProperty
def camera_=(v: Camera) {
ObjectProperty.fillProperty[jfxs.Camera](this.camera, v)
}
/** Defines the background fill of this SubScene. */
def fill: ObjectProperty[jfxsp.Paint] = delegate.fillProperty
def fill_=(v: Paint) {
ObjectProperty.fillProperty[jfxsp.Paint](this.fill, v)
}
/** Defines the height of this SubScene. */
def height: DoubleProperty = delegate.heightProperty
def height_=(v: Double) {
height() = v
}
/**
* The URL of the user-agent stylesheet that will be used by this Scene in place of the the platform-default
* user-agent stylesheet. If the URL does not resolve to a valid location, the platform-default user-agent
* stylesheet will be used.
*
* For additional information about using CSS with the scene graph, see the
* [[http://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html CSS Reference Guide]].
*
* @return The URL of the user-agent stylesheet that will be used by this SubScene, or null if has not been set.
*/
def userAgentStylesheet: ObjectProperty[String] = delegate.userAgentStylesheetProperty
/**
* Set the URL of the user-agent stylesheet that will be used by this Scene in place of the the platform-default
* user-agent stylesheet. If the URL does not resolve to a valid location, the platform-default user-agent
* stylesheet will be used.
*
* For additional information about using CSS with the scene graph, see the
* [[http://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html CSS Reference Guide]].
*
* @param url The URL is a hierarchical URI of the form `[scheme:][//authority][path]`.
* If the URL does not have a `[scheme:]` component, the URL is considered to be the `[path]`
* component only. Any leading '/' character of the `[path]` is ignored and the `[path]` is
* treated as a path relative to the root of the application's classpath.
*/
def userAgentStylesheet_=(url: String) {
ObjectProperty.fillProperty[String](userAgentStylesheet, url)
}
/** Defines the width of this SubScene. */
def width: DoubleProperty = delegate.widthProperty
def width_=(v: Double) {
width() = v
}
/** Return true if this SubScene is anti-aliased otherwise false. */
def isAntiAliasing: Boolean = delegate.isAntiAliasing
}