Changing appearance on live objects, can't figure out the proper capability
843799Oct 25 2006 — edited Oct 18 2010I've been trying to change the appearance of given objects in my scene graph (Box objects) in response to being picked. However, I keep getting a:
Shape3D: no capability to set appearance
error, and can't seem to figure out what capability I must set the Box objects to allow. Here is the pertinent code so far,
(within the class that creates a Box)
box.setCapability(Box.ALLOW_PICKABLE_READ);
box.setCapability(Box.ALLOW_PICKABLE_WRITE);
box.setCapability(Box.ENABLE_APPEARANCE_MODIFY);
box.setCapability(Box.ENABLE_PICK_REPORTING);
(within the picking class)
public class PickingListener extends MouseAdapter {
private PickCanvas pickCanvas;
private Box p;
public PickingListener(PickCanvas pickCanvasArg) {
pickCanvas = pickCanvasArg;
}
public void mouseClicked(MouseEvent e) {
pickCanvas.setShapeLocation(e);
PickResult result = pickCanvas.pickClosest();
if (result == null) {
System.out.println("Nothing picked");
} else {
p = (Box)result.getNode(PickResult.PRIMITIVE);
if (p != null) {
setSelectedColor();
System.out.println(p.getClass().getName());
System.out.println((((BarInformation)p.getUserData()).toString()));
} else{
System.out.println("null");
}
}
}
private void setSelectedColor() {
Appearance barAppearance = new Appearance();
ColoringAttributes barCA = new ColoringAttributes();
barCA.setColor(ColorConstants.SELECTED);
barAppearance.setColoringAttributes(barCA);
p.setAppearance(barAppearance);
}
Being unable to set the objects color/appearance after going live has been very frustrating. Any help offered will be greatly appreciated!
-Adrian