Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2020 Neil C Smith.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 only, as
* published by the Free Software Foundation.
*
* 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 3 for more details.
*
* You should have received a copy of the GNU General Public License version 3
* along with this work; if not, see http://www.gnu.org/licenses/
*
*
* Please visit https://www.praxislive.org if you need additional information or
* have any questions.
*/
package org.praxislive.ide.pxr.gui;
import java.awt.Component;
import java.awt.Rectangle;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;
import net.miginfocom.layout.CC;
import net.miginfocom.layout.IDEUtil;
import org.praxislive.core.ComponentAddress;
import org.praxislive.gui.Keys;
import org.praxislive.ide.model.ComponentProxy;
import org.praxislive.ide.model.ContainerProxy;
import org.praxislive.ide.model.RootProxy;
/**
*
*/
class Utils {
private final static Logger LOG = Logger.getLogger(Utils.class.getName());
private Utils() {
}
static void enableAll(JComponent component) {
component.setEnabled(true);
for (Component cmp : component.getComponents()) {
if (cmp instanceof JComponent) {
enableAll((JComponent) cmp);
}
}
}
static void disableAll(JComponent component) {
component.setEnabled(false);
for (Component cmp : component.getComponents()) {
if (cmp instanceof JComponent) {
disableAll((JComponent) cmp);
}
}
}
static ComponentProxy findComponentProxy(RootProxy root, ComponentAddress address) {
if (address.rootID().equals(root.getAddress().rootID())) {
ComponentProxy comp = root;
for (int i = 1; i < address.depth(); i++) {
if (comp instanceof ContainerProxy) {
comp = ((ContainerProxy) comp).getChild(address.componentID(i));
} else {
return null;
}
}
return comp;
}
return null;
}
static ComponentProxy findComponentProxy(RootProxy root, JComponent cmp) {
Object o = cmp.getClientProperty(Keys.Address);
if (o instanceof ComponentAddress) {
return findComponentProxy(root, (ComponentAddress) o);
}
return null;
}
static JComponent findAddressedComponent(Component cmp) {
do {
if (cmp instanceof JComponent
&& ((JComponent) cmp).getClientProperty(Keys.Address) != null) {
return (JComponent) cmp;
}
cmp = cmp.getParent();
} while (cmp != null);
return null;
}
static ComponentAddress getComponentAddress(Component cmp) {
if (cmp instanceof JComponent) {
Object ad = ((JComponent) cmp).getClientProperty(Keys.Address);
if (ad instanceof ComponentAddress) {
return (ComponentAddress) ad;
}
}
return null;
}
static JComponent findContainerComponent(RootProxy root, Component cmp) {
ComponentProxy pxy;
do {
cmp = findAddressedComponent(cmp);
if (cmp instanceof JComponent) {
pxy = findComponentProxy(root, (JComponent) cmp);
if (pxy instanceof ContainerProxy) {
return (JComponent) cmp;
}
}
cmp = cmp.getParent();
} while (cmp != null);
return null;
}
static int[] getGridPosition(JComponent container, JComponent component) {
HashMap