Hi everyone,
The problem arises when two or more Universes are working together, then
if the ColoringAttributes from one shape is changed (under some
circumstances) the following message is showed:
---------------------------------------------------------------------------------------------------------------
java.lang.IndexOutOfBoundsException: Index: -1, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java, Compiled Code)
at java.util.ArrayList.remove(ArrayList.java:372)
at
javax.media.j3d.RenderMolecule.addRenderAtom(RenderMolecule.java:851)
at
javax.media.j3d.RenderBin.findRenderMolecule(RenderBin.java:3115)
at
javax.media.j3d.RenderBin.reInsertRenderAtom(RenderBin.java:2627)
at
javax.media.j3d.RenderBin.processRenderMoleculeNodeComponentChanged(RenderBin.java:1000)
at javax.media.j3d.RenderBin.processMessages(RenderBin.java:759)
at
javax.media.j3d.StructureUpdateThread.doWork(StructureUpdateThread.java:79)
at javax.media.j3d.J3dThread.run(J3dThread.java:256)
---------------------------------------------------------------------------------------------------------------
This code reproduces the bug pressing two times the "Change Color"
Button: (only tested for W98 and Java3D 1.2 Beta1).
kind regards
Dani del Rio.
---------------------------------------------
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
import javax.vecmath.Color3f;
import com.sun.j3d.utils.geometry.Box;
import com.sun.j3d.utils.universe.*;
public class TestBug {
private Appearance app;
private ColoringAttributes ca;
private PolygonAttributes pa;
private Box box;
public TestBug() {
createAppearance();
box = new Box(0.2f, 0.2f, 0.2f, app);
BranchGroup root = new BranchGroup();
root.addChild(box);
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
canvas.setSize(new Dimension(400, 300));
SimpleUniverse universe = new SimpleUniverse(canvas);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(root);
JButton b1 = new JButton("Change Color");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ca.setColor(1.0f, 1.0f, 0.0f);
}
});
JFrame frame = new JFrame("Frame 1");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container pane1 = frame.getContentPane();
pane1.add(canvas, BorderLayout.CENTER);
pane1.add(b1, BorderLayout.SOUTH);
frame.setSize(new Dimension(400, 300));
frame.pack();
frame.setVisible(true);
// ***************************************
// ***************************************
Canvas3D c = new Canvas3D(config);
c.setSize(new Dimension(400, 300));
SimpleUniverse uni = new SimpleUniverse(c);
uni.getViewingPlatform().setNominalViewingTransform();
JButton button = new JButton("Change Color");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ca.setColor(0.0f, 1.0f, 1.0f);
}
});
JFrame f = new JFrame("Frame 2");
Container pane = f.getContentPane();
pane.add(c, BorderLayout.CENTER);
pane.add(button, BorderLayout.SOUTH);
f.setSize(new Dimension(400, 300));
f.pack();
f.setVisible(true);
}
private void createAppearance() {
app = new Appearance();
app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
pa = new PolygonAttributes();
pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
pa.setCullFace(PolygonAttributes.CULL_NONE);
app.setPolygonAttributes(pa);
ca = new ColoringAttributes();
ca.setCapability(ColoringAttributes.ALLOW_COLOR_READ);
ca.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE);
app.setColoringAttributes(ca);
}
public static void main(String[] args) {
TestBug test = new TestBug();
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".