Scaling up problem for displaying points
Posted: Thu 9. Feb 2012, 02:43
I am trying to display a (relatively) large (209) set of groups of points. I took some code from geom tutorials and then tried on a simple set of groups of points.
It worked fine - the visualization shows all points along with labels. When I tried the same program with 209 points (single group), the same program shows no points or labels. I tried with the disabled labels. The result is the same.
Here is the code I created from "geom" tutorials.
1. I took each group of points from the set of groups of points and then created PointSetFactory for that group.
2. Then I set up appearance and labels for this group of points
Here,
ps: PointSet
cmp: SceneGraphComponent
Here the label() method is:
3. Then I added this SceneGraphComponent as a child to a root (SceneGraphComponent)
4. Then I tried to display the root SceneGraphComponent
Please help me to find where the problem is for the large set of points. My program works fine on small sets.
Thanks,
Karuna
Code: Select all
double [][] vertices1 = new double[][] {
{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
double [][] vertices2 = new double[][] {
{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}};
double [][] vertices3 = new double[][] {
{0, 0, 0}, {0, 3, 0}, {3, 0, 0}, {3, 3, 0}};
double[][][] vertices = new double[3][][];
vertices[0] = vertices1;
vertices[1] = vertices2;
vertices[2] = vertices3;
Here is the code I created from "geom" tutorials.
1. I took each group of points from the set of groups of points and then created PointSetFactory for that group.
Code: Select all
factory = new PointSetFactory();
factory.setVertexCount(vertexCount);
factory.setVertexCoordinates(points);
factory.update();
2. Then I set up appearance and labels for this group of points
Here,
ps: PointSet
cmp: SceneGraphComponent
Code: Select all
label(ps, points);
Appearance a = new Appearance();
cmp.setAppearance(a);
cmp.setGeometry(ps);
DefaultGeometryShader dgs = ShaderUtility.createDefaultGeometryShader(
a, false);
DefaultPointShader dps = (DefaultPointShader) dgs.getPointShader();
dps.setDiffuseColor(color);
dgs.setShowFaces(false);
dgs.setShowLines(false);
dgs.setShowPoints(true);
DefaultTextShader pts = (DefaultTextShader) dps.getTextShader();
pts.setDiffuseColor(Color.blue);
Double scale = new Double(0.01);
pts.setScale(.75 * scale);
double[] offset = new double[] { -.1, 0, 0.3 };
pts.setOffset(offset);
pts.setAlignment(SwingConstants.NORTH_WEST);
Font f = new Font("SansSerif", Font.PLAIN, 20);
pts.setFont(f);
Here the label() method is:
Code: Select all
int n = ps.getNumPoints();
ps.getVertexAttributes(Attribute.COORDINATES).toDoubleArrayArray();
String[] labels = new String[n];
for (int i = 0; i < n; i++)
labels[i] = "[" + points[i][0] + ", " + points[i][1] + ", " + points[i][2] + "]";
ps.setVertexAttributes(Attribute.LABELS,
StorageModel.STRING_ARRAY.createReadOnly(labels));
Code: Select all
root.addChild(node);
Code: Select all
JRViewer.display(root);
Thanks,
Karuna