Re: ScalarMapListener

If the setRange only needs to be done once, you could define and
check a boolean to see if it's been done.  Otherwise, you'll need
to see if the 'foo' values are changing, if not skip the setRange().


Donna L Gresh wrote:

> I'm back with another question;
> My fundamental need is to combine a "marker" (which might be a line) in a
> three-dimensional view. My basic data object is a surface which is mapped
> like xy->data, where x->Display.XAxis, y->Display.YAxis, and
> data->Display.ZAxis. So I have created a "line object" (which is just two
> points: {x, y, zmin} and {x, y, zmax} which marks a particular xy location
> with a vertical line. So I have another math type which is {x2,y2,z2} and I
> set up scalar maps for x2->Display.XAxis, y2->Display.YAxis, and
> z2->Display.ZAxis. I found however that I need to explicitly set the range
> for the scalar maps for my marker line to match the range of the surface.
> The only problem is one that's been mentioned in the archive, that it takes
> some amount of time for the autoscaling to occur. I inserted a short wait,
> and that resulted in the right picture, so then I went ahead and created a
> new class that implements ScalarMapListener as suggested in the archives.
> The constructor for the class gets two scalarmaps: the "source" scalar map
> and the "destination" scalar map, so that in the mapChanged method I can do
> something like
> foo = source.getRange();
> destination.setRange(foo[0], foo[1])
> The only problem is, the mapChanged method seems to be causing itself to be
> called again in an infinite loop. Although I only do
> source.addScalarMapListener(myclass); I don't put a listener on the
> destination map.
> Am I doing something backwards? Is there a simpler way to do what I want?
> Thanks for any help
> Donna
> Donna L. Gresh, Ph.D.
> Optimization and Mathematical Software Group
> IBM T.J. Watson Research Center
> (914) 945-2472
> gresh@xxxxxxxxxx