Re: setRange on IsoContour gives NullPointerException


"From: Bill Hibbard " wrote:
> 
> Hi John,
> 
> > when i try to call setRange on an IsoContour I get a
> > NullPointerException.  Specifically it happens at line 435 of
> > ScalarMap.java:
> >
> >       ((ContourControl) control).getMainContours(bvalues, values);
> >
> > It would seem that "control" is null at this point.  The general context
> > of this is that I am adding the ranges of Display objects to what is
> > saved by the SpreadSheet's save function.  When I try to open a
> > SpreadSheet file containing a cell which has data mapped to IsoContour,
> > when I get to the point in my code where I call setRange on that map, I
> > get the above exception.
> 
> First, we will add tests "if (control != null) {" around references
> to control in ScalarMap.setRange().  Thanks for pointing this out.
> 
> However, the deeper question regards calling ScalarMap.setRange()
> beofre the ScalarMap has been addMap()'ed to a DisplayImpl (this
> is what control == null means).
> 
> It sounds like you are pushing into new territory, mixing your
> own code with the SpreadSheet.  Are you doing it by writing new
> classes that are linked into formulas?  Or are you modifying
> the SpreadSheet source code?
> 
> If you are linking code into formulas, then I am unsure how you
> are getting access to ScalarMaps and the SpreadSheet's save
> function.  If you are modifying the SpreadSheet source code,
> then we'd be happy to hear more specifics about what you are
> doing.
> 

I guess I sort of took the SpreadSheet class itself to be a sort of
example of using the classes available in visad.ss, and so thought it
would be OK to change it's source.  

In order make it more useable I have had to change the source code of
SpreadSheet.java, as it does not lend itself to being easily extended. 
I am also extending FancySSCell - as such, i also needed to change the
source code of the SpreadSheet to allow a SSCell other than FancySSCell
to be used.  I had to make one other change to the VisAD source.  The
FormulaManager used by BasicSSCell, as it is written, must be the one
created by the createStandardManager() method of FormulaUtil.  The
FormulaManager created by this method is not suitable for my needs. 
Since there is no "accessor" for the FormulaManager I had to alter the
BasicSSCell source in order to allow a different one to be used. 
(Otherwise, unwieldy "link(packageName.className.method())" statements
have to be entered by the user in order for them to get at my methods.) 
Now I can use my own FormulaManager, which is aware of my formulae.

All in all, the changes i've made so far have been relatively
straightforward, if a little tedious - making "Save SpreadSheet" really
save the SpreadSheet, making formulae and frequently used mappings more
accessible.  One signifigant step that needs to be made is to make cell
resizing work correctly.  maybe this problem does not come up on
Solaris, but on NT the relationship between the locations yellow resize
tabs and the actual size of the cells quickly breaks down.  eventually,
cell resizing stops working altogether, especially if you try to use
many cells.  also, the cells do not redraw themselves when a resize
occurs, meaning the user has to go around and click in every cell in
order to force a resize.

There is another problem, and, again, maybe this is just on NT:  I can't
seem to get the cursor to "pan."  It should pan when you drag with the
middle mouse button, but instead, it rotates the scene with the cursor
on, as is supposed to happen when you hold down control when you are
draggin with the middle mouse button.

Anyway, your suggestion worked for me - I forgot to do the setRange()
until after I'd addMap()'ed it.  I came across this problem once before
and forgot about it.


> > Also, is there any way to get at the currently selected values of a
> > SelectRangeWidget (which i want to do for the same reason as above)?
> > I've tried to look into it, and it seems they are based on the value of
> > minValue and MaxValue in RangeSlider, which have no accessors.
> 
> A SelectRangeWidget is connected to a RangeControl, and you can
> invoke its getRange() method which returns a float[2] array
> containing the min and max of the currently selected range.
> 
> There is no way to get the RangeControl from the SelectRangeWidget,
> but I wonder if that's needed.  You can of course get the
> RangeControl from the ScalarMap via the getControl() method.
> 
> Please let us know if you need a method of SelectRangeWidget that
> returns its RangeControl.
> 

No - as long as I can get it form the ScalarMap, that's fine.  Haven't
tried this yet, but will do so shortly.


Thanks!

john