8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.scene.layout;
27
28 import javafx.beans.DefaultProperty;
29 import javafx.collections.ObservableList;
30 import javafx.scene.Node;
31
32 /**
33 * Base class for layout panes which need to expose the children list as public
34 * so that users of the subclass can freely add/remove children.
35 * <p>
36 * This class may be used directly in cases where absolute positioning of children
37 * is required since it does not perform layout beyond resizing resizable children
38 * to their preferred sizes. It is the application's responsibility to position the
39 * children since the pane leaves the positions alone during layout.
40 * For example:
41 * <pre><code>
42 * Pane canvas = new Pane();
43 * canvas.setStyle("-fx-background-color: black;");
44 * canvas.setPrefSize(200,200);
45 * Circle circle = new Circle(50,Color.BLUE);
46 * circle.relocate(20, 20);
47 * Rectangle rectangle = new Rectangle(100,100,Color.RED);
78 * A pane's unbounded maximum width and height are an indication to the parent that
79 * it may be resized beyond its preferred size to fill whatever space is assigned to it.
80 * <p>
81 * Pane provides properties for setting the size range directly. These
82 * properties default to the sentinel value Region.USE_COMPUTED_SIZE, however the
83 * application may set them to other values as needed:
84 * <pre><code>
85 * <b>pane.setPrefSize(500,400);</b>
86 * </code></pre>
87 * Applications may restore the computed values by setting these properties back
88 * to Region.USE_COMPUTED_SIZE.
89 * <p>
90 * Pane does not clip its content by default, so it is possible that childrens'
91 * bounds may extend outside its own bounds, either if children are positioned
92 * at negative coordinates or the pane is resized smaller than its preferred size.</p>
93 *
94 * @since JavaFX 2.0
95 */
96 @DefaultProperty("children")
97 public class Pane extends Region {
98
99 static void setConstraint(Node node, Object key, Object value) {
100 if (value == null) {
101 node.getProperties().remove(key);
102 } else {
103 node.getProperties().put(key, value);
104 }
105 if (node.getParent() != null) {
106 node.getParent().requestLayout();
107 }
108 }
109
110 static Object getConstraint(Node node, Object key) {
111 if (node.hasProperties()) {
112 Object value = node.getProperties().get(key);
113 if (value != null) {
114 return value;
115 }
116 }
117 return null;
118 }
119
120 /**
121 * Creates a Pane layout.
122 */
123 public Pane() {
124 super();
125 }
126
127 /**
128 * Creates a Pane layout.
129 * @param children The initial set of children for this pane.
130 * @since JavaFX 8.0
131 */
132 public Pane(Node... children) {
133 super();
134 getChildren().addAll(children);
135 }
136
137 /**
138 *
139 * @return modifiable list of children.
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.scene.layout;
27
28 import com.sun.javafx.scene.layout.PaneHelper;
29 import javafx.beans.DefaultProperty;
30 import javafx.collections.ObservableList;
31 import javafx.scene.Node;
32
33 /**
34 * Base class for layout panes which need to expose the children list as public
35 * so that users of the subclass can freely add/remove children.
36 * <p>
37 * This class may be used directly in cases where absolute positioning of children
38 * is required since it does not perform layout beyond resizing resizable children
39 * to their preferred sizes. It is the application's responsibility to position the
40 * children since the pane leaves the positions alone during layout.
41 * For example:
42 * <pre><code>
43 * Pane canvas = new Pane();
44 * canvas.setStyle("-fx-background-color: black;");
45 * canvas.setPrefSize(200,200);
46 * Circle circle = new Circle(50,Color.BLUE);
47 * circle.relocate(20, 20);
48 * Rectangle rectangle = new Rectangle(100,100,Color.RED);
79 * A pane's unbounded maximum width and height are an indication to the parent that
80 * it may be resized beyond its preferred size to fill whatever space is assigned to it.
81 * <p>
82 * Pane provides properties for setting the size range directly. These
83 * properties default to the sentinel value Region.USE_COMPUTED_SIZE, however the
84 * application may set them to other values as needed:
85 * <pre><code>
86 * <b>pane.setPrefSize(500,400);</b>
87 * </code></pre>
88 * Applications may restore the computed values by setting these properties back
89 * to Region.USE_COMPUTED_SIZE.
90 * <p>
91 * Pane does not clip its content by default, so it is possible that childrens'
92 * bounds may extend outside its own bounds, either if children are positioned
93 * at negative coordinates or the pane is resized smaller than its preferred size.</p>
94 *
95 * @since JavaFX 2.0
96 */
97 @DefaultProperty("children")
98 public class Pane extends Region {
99 static {
100 PaneHelper.setPaneAccessor(new PaneHelper.PaneAccessor() {
101 });
102 }
103
104 static void setConstraint(Node node, Object key, Object value) {
105 if (value == null) {
106 node.getProperties().remove(key);
107 } else {
108 node.getProperties().put(key, value);
109 }
110 if (node.getParent() != null) {
111 node.getParent().requestLayout();
112 }
113 }
114
115 static Object getConstraint(Node node, Object key) {
116 if (node.hasProperties()) {
117 Object value = node.getProperties().get(key);
118 if (value != null) {
119 return value;
120 }
121 }
122 return null;
123 }
124
125 {
126 // To initialize the class helper at the begining each constructor of this class
127 PaneHelper.initHelper(this);
128 }
129 /**
130 * Creates a Pane layout.
131 */
132 public Pane() {
133 super();
134 }
135
136 /**
137 * Creates a Pane layout.
138 * @param children The initial set of children for this pane.
139 * @since JavaFX 8.0
140 */
141 public Pane(Node... children) {
142 super();
143 getChildren().addAll(children);
144 }
145
146 /**
147 *
148 * @return modifiable list of children.
|