Hi Bill,
Thanks a lot for your kind suggestions.
This time i tried something like this to create a
geometry. I used the RubberBandLineRendererJ3D class
to get the intial and final points for the line, and
from that i have constructed a Gridded2DSet and also
the two end points are created as tuples and then
added the references to the display. So, everytime a
user drags on the display a line with 2 end points is
formed.
1. Inspite of using the ConstantMaps while adding the
references of the RealTuples, we are not able to
increase the size of them. Is there any other way out?
Please suggest.
2. In the doAction() method we are creating the
giddedsets and the real tuples and adding the
references to the dispay but, in your previous mail
you mentioned to add the references outside the
doAction() method. We want to update the display with
the user actions. To create arrays we need to give the
array length initially and we do not know how many
lines a user can generate to create the geometry. Is
there any other way to give references outside and
then update. Please suggest.
I am new to VisAD and i dont find any other way, other
than approaching you. Sir, Please dont mind in helping
me in this matter.
Thanks a lot again,
Karan.
=====================================================
import visad.*;
import visad.java2d.DisplayImplJ2D;
import visad.java3d.DisplayImplJ3D;
import java.rmi.RemoteException;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import visad.java2d.*;
import visad.Set.*;
import visad.java3d.DirectManipulationRendererJ3D;
import visad.bom.PointManipulationRendererJ3D;
import visad.bom.*;
public class MyGeom1 extends Object {
RealType row, column, index;
RealTupleType r_tuple;
FunctionType func_type;
Integer2DSet integer_set;
FlatField field;
DataReferenceImpl data_ref;
DisplayImpl display;
ScalarMap rowmap, columnmap;
DisplayRenderer dr;
UnionSet us;
float[][] samples;
private static final int N = 64;
float f1[][] = new float[2][2];
RealTuple[] rt = new RealTuple[2];
DataReferenceImpl[] drt = new
DataReferenceImpl[2];
public MyGeom1() {
}
public void displayGeometry() throws
VisADException, RemoteException {
row = new RealType("X");
column = new RealType("Y");
r_tuple = new RealTupleType(row, column);
index = new RealType("index");
func_type = new FunctionType(r_tuple, index);
integer_set = new Integer2DSet(r_tuple, N, N);
field = new FlatField(func_type, integer_set);
data_ref = new DataReferenceImpl("field");
display = new DisplayImplJ3D("display1");
rowmap = new ScalarMap(row, Display.XAxis);
columnmap = new ScalarMap(column,
Display.YAxis);
display.addMap(rowmap);
display.addMap(columnmap);
rowmap.setRange(0, 10);
columnmap.setRange(0, 10);
dr = display.getDisplayRenderer();
GraphicsModeControl dispGMC
(GraphicsModeControl)
display.getGraphicsModeControl();
dispGMC.setPointMode(false);
dispGMC.setPointSize(5.0f);
dr.setBoxOn(false);
dr.setBackgroundColor(0.0f, 0.0f, 0.0f);
final ConstantMap[] pointsCol = { new
ConstantMap( 1.0f, Display.Red),
new
ConstantMap( 0.0f, Display.Green),
new
ConstantMap( 0.0f, Display.Blue),
new
ConstantMap( 10.0f, Display.PointSize)};
Gridded2DSet dummy_set = new
Gridded2DSet(r_tuple, null, 1);
final DataReferenceImpl ref = new
DataReferenceImpl("set");
ref.setData(dummy_set);
display.addReferences(new
RubberBandLineRendererJ3D(row, column, 0, 0), ref);
CellImpl cell = new CellImpl() {
public void doAction() throws
VisADException, RemoteException {
Gridded2DSet set_data
(Gridded2DSet)ref.getData();
samples = set_data.getSamples();
if (samples != null) {
f1[0][0] = samples[0][0];
f1[1][0] = samples[1][0];
f1[0][1] = samples[0][1];
f1[1][1] = samples[1][1];
Gridded2DSet d_set = new
Gridded2DSet(r_tuple, f1, 2);
Gridded2DSet[] gs = { d_set };
us = new UnionSet(gs);
DataReferenceImpl df = new
DataReferenceImpl("df");
df.setData(us);
display.addReference(df);
Real[] r1 = new Real[] {new
Real(row, f1[0][0]), new Real(column, f1[1][0])};
Real[] r2 = new Real[] {new
Real(row, f1[0][1]), new Real(column, f1[1][1])};
rt[0] = new RealTuple(r1);
rt[1] = new RealTuple(r2);
drt[0] = new
DataReferenceImpl("drt1");
drt[1] = new
DataReferenceImpl("drt2");
drt[0].setData(rt[0]);
drt[1].setData(rt[1]);
display.addReference(drt[0],
pointsCol);
display.addReference(drt[1],
pointsCol);
}
}
};
cell.addReference(ref);
JFrame frame = new JFrame("Geometry");
frame.getContentPane().add(display.getComponent());
frame.setSize(400, 400);
frame.setVisible(true);
frame.addWindowListener(new
java.awt.event.WindowAdapter() {
public void
windowClosing(java.awt.event.WindowEvent e)
{System.exit(0);}
});
}
public static void main(String args[]) throws
RemoteException, VisADException {
MyGeom1 mg = new MyGeom1();
try {
mg.displayGeometry();
}catch(Exception e) {
e.printStackTrace();
}
}
}
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/