Re: ScalarMapListener

Hi Donna,

> 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?

I just wrote a little test program and couldn't duplicate the
problem you are seeing (I only called addScalarMapListener()
for one ScalarMap, and only saw mapChanged() calls for that
ScalarMap even though mapChanged() called setRange() for another
ScalarMap). You might try putting this in your mapChanged to
filter out the problem calls:

  public void mapChanged(ScalarMapEvent e) {
    if (source.equals(e.getScalrMap())) {
      try {
        foo = source.getRange();
        destination.setRange(foo[0], foo[1])
      catch (...) {}

Good luck,

  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: