/** * Copyright 2023 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. 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. * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR * 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. * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ package com.jogamp.graph.ui; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.ui.layout.Padding; import com.jogamp.graph.ui.shapes.Rectangle; import com.jogamp.math.Vec3f; import com.jogamp.math.Vec4f; import com.jogamp.math.geom.AABBox; import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; import jogamp.graph.ui.TreeTool; /** * Group of {@link Shape}s, optionally utilizing a {@link Group.Layout}. * @see Scene * @see Shape * @see Group.Layout */ public class Group extends Shape implements Container { /** Layout for the GraphUI {@link Group}, called @ {@link Shape#validate(GL2ES2)} or {@link Shape#validate(GLProfile)}. */ public static interface Layout { /** Prepare given {@link Shape} before {@link Shape#validate(GL2ES2) validation}, e.g. {@link Shape#setPaddding(Padding)}. */ void preValidate(final Shape s); /** * Performing the layout of {@link Group#getShapes()}, called @ {@link Shape#validate(GL2ES2)} or {@link Shape#validate(GLProfile)}. *
* According to the implemented layout, method * - may scale the {@Link Shape}s * - may move the {@Link Shape}s * - may reuse the given {@link PMVMatrix4f} `pmv` * - must update the given {@link AABBox} `box` *
* @param g the {@link Group} to layout * @param box the bounding box of {@link Group} to be updated by this method. * @param pmv a {@link PMVMatrix4f} which can be reused. */ void layout(final Group g, final AABBox box, final PMVMatrix4f pmv); } private final List* Default is non-interactive, see {@link #setInteractive(boolean)}. *
*/ public Group() { this(null); } /** * Create a group of {@link Shape}s w/ given {@link Group.Layout}. ** Default is non-interactive, see {@link #setInteractive(boolean)}. *
* @param l optional {@link Layout}, maybe {@code null} */ public Group(final Layout l) { super(); this.layouter = l; this.setInteractive(false); } /** Return current {@link Group.Layout}. */ public Layout getLayout() { return layouter; } /** Set {@link Group.Layout}. */ public Group setLayout(final Layout l) { layouter = l; return this; } @Override public int getShapeCount() { return shapes.size(); } @Override public List