Re: reAutoScale

Hi Doug-

Since Bill hasn't chimed in, I'll take a stab at this.  He can correct
me if I'm off base.

Doug Lindholm wrote:
 
> Are you saying that the correct behavior is that toggle(false) NOT
> affect the auto scaling?

Visibility toggling should not affect the auto scaling.  It would be
akin to calling setVisible on a JSlider.  Unless the values that the
slider is linked to (max, min, value) are changing, the JSlider 
would look the same before and after toggling the visibility.
Autoscaling should only occur at an addReference or a setData call when
the values linked to the ScalarMap are changed.  The toggle does
not remove and re-add the data or reference.

> I want to be able to turn data visibility on and off and have the axes
> scaled to fit the visible data. I could write some code to enforce this,
> but I thought that toggling the data off should have the same effect. I
> could add/remove the DataReferences but that is less efficient.

Does the data change in the reference between the time that the
reference is toggled off and on?

> If toggle(false) won't do what I want, what is the best way to determine
> min/max ranges of Fields?

It would be useful to have a method in DataUtility that does this (
e.g., public static float[][] getRangeRange(FlatField input)).  Right
now, we just loop through all the values and pick the max and min:

    /**
     * Find min and max of range data in any VisAD FlatField
     *
     * @param field a VisAD FlatField
     */
    private double[] fieldMinMax(visad.FlatField field)
        throws VisADException, RemoteException
    {
        double pMin, pMax;
        double [] mm = new double[2]; // to hold and return results
        double values[][] = field.getValues(false);
        pMin = Double.NaN;
        pMax = Double.NaN;
        for (int i = 0; i < values[0].length; i++)
            {
                double value = values[0][i];
                if (value != Double.NaN)
                    {
                        if (new Double(pMax).isNaN()) // first time
through
                            {
                                pMax = value;
                                pMin = value;                       }
                        else
                            {
                                pMax = (pMax < value) ? value : pMax;
                                pMin = (pMin > value) ? value : pMin;
                            }
                    }
            }
        mm[0] = pMin;
        mm[1] = pMax;
        return mm;
    }

(This should probably just use floats to save on memory.  It also only
does the first Range parameter.) 

>Does VisAD have a convenient method for doing this? 

No.  But it could be added as above (with a better name).  There
is a DataRenderer.getRanges() method that returns a double[], but
I don't know what that returns, since there is no Javadoc explaining
it's function.

>Would I be better off going back to add/removing DataReferences?

doesn't setData() work to do this?

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
*************************************************************


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