diff --git a/org.eclipse.emf.cdo.threedee.common/src/org/eclipse/emf/cdo/threedee/common/descriptors/_INIT_.java b/org.eclipse.emf.cdo.threedee.common/src/org/eclipse/emf/cdo/threedee/common/descriptors/_INIT_.java
index 04c1c8d..cb57332 100644
--- a/org.eclipse.emf.cdo.threedee.common/src/org/eclipse/emf/cdo/threedee/common/descriptors/_INIT_.java
+++ b/org.eclipse.emf.cdo.threedee.common/src/org/eclipse/emf/cdo/threedee/common/descriptors/_INIT_.java
@@ -15,6 +15,7 @@
import org.eclipse.emf.cdo.threedee.common.descriptors.cdoclient._INIT_CDO_CLIENT_;
import org.eclipse.emf.cdo.threedee.common.descriptors.cdoserver._INIT_CDO_SERVER_;
import org.eclipse.emf.cdo.threedee.common.descriptors.net4j._INIT_NET4J_;
+import org.eclipse.emf.cdo.threedee.common.descriptors.net4jdb._INIT_NET4J_DB_;
import java.awt.Color;
@@ -30,7 +31,7 @@
_INIT_CDO_CLIENT_.init(registry);
_INIT_CDO_SERVER_.init(registry);
_INIT_NET4J_.init(registry);
- // _INIT_NET4J_DB_.init(registry);
+ _INIT_NET4J_DB_.init(registry);
Color color = Color.white;
registry.register(new ManagedContainerDescriptor(), color, 0.8f);
diff --git a/org.eclipse.emf.cdo.threedee.ui/src/org/eclipse/emf/cdo/threedee/ui/ThreeDeeWorld.java b/org.eclipse.emf.cdo.threedee.ui/src/org/eclipse/emf/cdo/threedee/ui/ThreeDeeWorld.java
index a10cece..c5a8928 100644
--- a/org.eclipse.emf.cdo.threedee.ui/src/org/eclipse/emf/cdo/threedee/ui/ThreeDeeWorld.java
+++ b/org.eclipse.emf.cdo.threedee.ui/src/org/eclipse/emf/cdo/threedee/ui/ThreeDeeWorld.java
@@ -709,7 +709,7 @@
ElementGroup elementGroup = elementGroups.get(object);
if (elementGroup != null)
{
- elementGroup.select(select);
+ elementGroup.setSelected(select);
}
}
}
diff --git a/org.eclipse.emf.cdo.threedee.ui/src/org/eclipse/emf/cdo/threedee/ui/nodes/ElementGroup.java b/org.eclipse.emf.cdo.threedee.ui/src/org/eclipse/emf/cdo/threedee/ui/nodes/ElementGroup.java
index 1279bf7..6d416fd 100644
--- a/org.eclipse.emf.cdo.threedee.ui/src/org/eclipse/emf/cdo/threedee/ui/nodes/ElementGroup.java
+++ b/org.eclipse.emf.cdo.threedee.ui/src/org/eclipse/emf/cdo/threedee/ui/nodes/ElementGroup.java
@@ -24,6 +24,7 @@
import javax.media.j3d.Canvas3D;
import javax.media.j3d.Node;
import javax.media.j3d.RenderingAttributes;
+import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransparencyAttributes;
import javax.vecmath.AxisAngle4d;
@@ -50,8 +51,6 @@
private static SelectionThread selectionThread;
- private BranchGroup selection;
-
public ElementGroup(Element element, Canvas3D canvas)
{
super(element, createAppearance(element, canvas));
@@ -63,7 +62,12 @@
return (ElementSphere)super.getShape();
}
- public void select(boolean selected)
+ public boolean isSelected()
+ {
+ return getSelectionThread().isSelected(this);
+ }
+
+ public void setSelected(boolean selected)
{
if (selected)
{
@@ -78,21 +82,11 @@
float radius = ElementSphere.RADIUS * 1.4f;
Sphere selectionShape = new Sphere(radius, Primitive.GENERATE_NORMALS, 32, appearance);
- selection = new BranchGroup();
- selection.setCapability(ALLOW_DETACH);
- selection.addChild(selectionShape);
-
- addChild(selection);
- getSelectionThread().add(selection, transparencyAttributes);
+ getSelectionThread().add(this, selectionShape);
}
else
{
- if (selection != null)
- {
- getSelectionThread().remove(selection);
- selection.detach();
- selection = null;
- }
+ getSelectionThread().remove(this);
}
}
@@ -173,7 +167,7 @@
public final class ElementSphere extends Sphere
{
public static final float RADIUS = .1f;
-
+
public ElementSphere(Appearance appearance)
{
super(RADIUS, Primitive.GENERATE_NORMALS, 32, appearance);
@@ -185,7 +179,7 @@
*/
private static final class SelectionThread extends Thread
{
- private Map<BranchGroup, TransparencyAttributes> selections = new HashMap<BranchGroup, TransparencyAttributes>();
+ private Map<ElementGroup, Node> selectionShapes = new HashMap<ElementGroup, Node>();
private double theta;
@@ -194,19 +188,30 @@
setDaemon(true);
}
- public synchronized TransparencyAttributes[] getSelections()
+ public synchronized boolean isSelected(ElementGroup elementGroup)
{
- return selections.values().toArray(new TransparencyAttributes[selections.size()]);
+ return selectionShapes.containsKey(elementGroup);
}
- public synchronized void add(BranchGroup selection, TransparencyAttributes transparencyAttributes)
+ public synchronized void add(ElementGroup elementGroup, Node selectionShape)
{
- selections.put(selection, transparencyAttributes);
+ BranchGroup branchGroup = new BranchGroup();
+ branchGroup.setCapability(ALLOW_DETACH);
+ branchGroup.addChild(selectionShape);
+
+ elementGroup.addChild(branchGroup);
+ selectionShapes.put(elementGroup, selectionShape);
}
- public synchronized void remove(BranchGroup selection)
+ public synchronized void remove(ElementGroup elementGroup)
{
- selections.remove(selection);
+ Node selectionShape = selectionShapes.remove(elementGroup);
+ if (selectionShape != null)
+ {
+ BranchGroup branchGroup = (BranchGroup)selectionShape.getParent();
+ branchGroup.detach();
+ }
+
}
@Override
@@ -215,9 +220,22 @@
while (!interrupted())
{
float alpha = (float)Math.abs(Math.cos(theta));
- for (TransparencyAttributes transparencyAttributes : getSelections())
+
+ for (Node node : getSelections())
{
- transparencyAttributes.setTransparency(alpha);
+ Appearance appearance;
+ if (node instanceof Shape3D)
+ {
+ Shape3D selectionShape = (Shape3D)node;
+ appearance = selectionShape.getAppearance();
+ }
+ else
+ {
+ Primitive selectionShape = (Primitive)node;
+ appearance = selectionShape.getAppearance();
+ }
+
+ appearance.getTransparencyAttributes().setTransparency(alpha);
}
theta += 0.02f;
@@ -229,5 +247,10 @@
ConcurrencyUtil.sleep(5);
}
}
+
+ private synchronized Node[] getSelections()
+ {
+ return selectionShapes.values().toArray(new Node[selectionShapes.size()]);
+ }
}
}