/* * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javafx.scene; import com.sun.javafx.scene.GroupHelper; import javafx.beans.DefaultProperty; import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanPropertyBase; import javafx.collections.ObservableList; import javafx.geometry.Bounds; import java.util.Collection; /** * A {@code Group} node contains an ObservableList of children that * are rendered in order whenever this node is rendered. *
* A {@code Group} will take on the collective bounds of its children and is * not directly resizable. *
* Any transform, effect, or state applied to a {@code Group} will be applied * to all children of that group. Such transforms and effects will NOT be included * in this Group's layout bounds, however if transforms and effects are set * directly on children of this Group, those will be included in this Group's layout bounds. *
* By default, a {@code Group} will "auto-size" its managed resizable * children to their preferred sizes during the layout pass to ensure that Regions * and Controls are sized properly as their state changes. If an application * needs to disable this auto-sizing behavior, then it should set * {@link #autoSizeChildrenProperty() autoSizeChildren} to {@code false} and understand that if the preferred size of * the children change, they will not automatically resize (so buyer beware!). * *
Group Example:
*import javafx.scene.*; import javafx.scene.paint.*; import javafx.scene.shape.*; import java.lang.Math; Group g = new Group(); for (int i = 0; i < 5; i++) { Rectangle r = new Rectangle(); r.setY(i * 20); r.setWidth(100); r.setHeight(10); r.setFill(Color.RED); g.getChildren().add(r); }* @since JavaFX 2.0 */ @DefaultProperty("children") public class Group extends Parent { static { // This is used by classes in different packages to get access to // private and package private methods. GroupHelper.setGroupAccessor(new GroupHelper.GroupAccessor() { @Override public Bounds doComputeLayoutBounds(Node node) { return ((Group) node).doComputeLayoutBounds(); } }); } { // To initialize the class helper at the begining each constructor of this class GroupHelper.initHelper(this); } /** * Constructs a group. */ public Group() { } /** * Constructs a group consisting of children. * * @param children children. */ public Group(Node... children) { getChildren().addAll(children); } /** * Constructs a group consisting of the given children. * * @param children children of the group * @throws NullPointerException if the specified collection is null * @since JavaFX 8.0 */ public Group(Collection