use of javax.media.j3d.TransformGroup in project ffx by mjschnie.
the class MouseOrbit method setTransformGroups.
/**
* <p>
* setTransformGroups</p>
*
* @param tg a {@link javax.media.j3d.TransformGroup} object.
* @param VPTG a {@link javax.media.j3d.TransformGroup} object.
*/
public void setTransformGroups(TransformGroup tg, TransformGroup VPTG) {
super.ViewerTG = VPTG;
tg_ghost = new TransformGroup();
Transform3D tgT3D = new Transform3D();
tg.getTransform(tgT3D);
// Make a ghost TG since no transform on
tg_ghost.setTransform(tgT3D);
// object is to occur
}
use of javax.media.j3d.TransformGroup in project ffx by mjschnie.
the class PickSelectionBehavior method updateScene.
/*
* Update the scene to manipulate any nodes.
* @param xpos Current mouse X pos. @param ypos Current mouse Y pos.
*/
/**
* {@inheritDoc}
*/
public void updateScene(int xpos, int ypos) {
TransformGroup tg = null;
if ((mevent.getModifiersEx() & MouseEvent.BUTTON1) == MouseEvent.BUTTON1) {
pickCanvas.setShapeLocation(xpos, ypos);
PickResult r = pickCanvas.pickClosest();
if (r != null) {
tg = (TransformGroup) r.getNode(PickResult.TRANSFORM_GROUP);
if ((tg != null) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))) {
drag.wakeup();
currentTG = tg;
if (callback != null) {
callback.transformClicked(PickingCallback.SELECTION, currentTG);
}
}
} else if (callback != null) {
callback.transformClicked(PickingCallback.NO_PICK, null);
}
}
}
use of javax.media.j3d.TransformGroup in project ffx by mjschnie.
the class PickZoomBehavior method updateScene.
/*
* Update the scene to manipulate any nodes. This is not meant to be called
* by users. Behavior automatically calls this. You can call this only if
* you know what you are doing.
* @param xpos Current mouse X pos. @param ypos Current mouse Y pos.
*/
/**
* {@inheritDoc}
*/
public void updateScene(int xpos, int ypos) {
TransformGroup tg = null;
if ((mevent.getModifiersEx() & MouseEvent.BUTTON3) == MouseEvent.BUTTON3) {
pickCanvas.setShapeLocation(xpos, ypos);
PickResult r = pickCanvas.pickClosest();
if (r != null) {
tg = (TransformGroup) r.getNode(PickResult.TRANSFORM_GROUP);
if ((tg != null) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))) {
zoom.setTransformGroup(tg);
zoom.wakeup();
currentTG = tg;
if (callback != null) {
callback.transformClicked(PickingCallback.ZOOM, currentTG);
}
} else if (callback != null) {
callback.transformChanged(PickingCallback.NO_PICK, null);
}
}
}
}
use of javax.media.j3d.TransformGroup in project ffx by mjschnie.
the class MolecularAssembly method recurseVRML.
private void recurseVRML(Node node) {
if (node instanceof Shape3D) {
Shape3D s3d = (Shape3D) node;
PickTool.setCapabilities(s3d, PickTool.INTERSECT_COORD);
return;
} else if (node instanceof SharedGroup) {
SharedGroup sg = (SharedGroup) node;
for (Enumeration<Node> e = sg.getAllChildren(); e.hasMoreElements(); ) {
recurseVRML(e.nextElement());
}
return;
} else if (node instanceof BranchGroup) {
BranchGroup bg = (BranchGroup) node;
for (Enumeration<Node> e = bg.getAllChildren(); e.hasMoreElements(); ) {
recurseVRML(e.nextElement());
}
return;
} else if (node instanceof TransformGroup) {
TransformGroup vrmlTG1 = (TransformGroup) node;
for (Enumeration<Node> e = vrmlTG1.getAllChildren(); e.hasMoreElements(); ) {
node = e.nextElement();
recurseVRML(node);
}
return;
} else if (node instanceof Link) {
Link link = (Link) node;
recurseVRML(link.getSharedGroup());
return;
} else if (node instanceof Group) {
Group group = (Group) node;
for (Enumeration<Node> e = group.getAllChildren(); e.hasMoreElements(); ) {
Node n = e.nextElement();
recurseVRML(n);
}
}
}
use of javax.media.j3d.TransformGroup in project ffx by mjschnie.
the class RendererCache method doubleCylinderFactory.
/**
* <p>
* doubleCylinderFactory</p>
*
* @param a1 a {@link ffx.potential.bonded.Atom} object.
* @param a2 a {@link ffx.potential.bonded.Atom} object.
* @param div a int.
* @return a {@link javax.media.j3d.BranchGroup} object.
*/
public static final BranchGroup doubleCylinderFactory(Atom a1, Atom a2, int div) {
BranchGroup branchGroup;
if (doubleCylinderPool.size() > 0) {
branchGroup = doubleCylinderPool.remove(0);
if (branchGroup != null) {
TransformGroup cy1tg = (TransformGroup) branchGroup.getChild(0);
Shape3D cy1 = (Shape3D) cy1tg.getChild(0);
cy1.setAppearance(a1.getAtomAppearance());
cy1.setUserData(a1);
TransformGroup cy2tg = (TransformGroup) branchGroup.getChild(1);
Shape3D cy2 = (Shape3D) cy2tg.getChild(0);
cy2.setUserData(a2);
cy2.setAppearance(a2.getAtomAppearance());
return branchGroup;
}
}
branchGroup = new BranchGroup();
branchGroup.setCapability(BranchGroup.ALLOW_DETACH);
branchGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
branchGroup.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
TransformGroup cy1tg = createTransformGroup(null);
Shape3D cy1 = createCylinder(a1.getAtomAppearance(), div);
cy1.setUserData(a1);
cy1tg.addChild(cy1);
branchGroup.addChild(cy1tg);
TransformGroup cy2tg = createTransformGroup(null);
Shape3D cy2 = createCylinder(a2.getAtomAppearance(), div);
cy2.setUserData(a2);
cy2tg.addChild(cy2);
branchGroup.addChild(cy2tg);
branchGroup.compile();
return branchGroup;
}
Aggregations