Re: DisplayRealType

Luke-

Bill Hibbard wrote:

> Sorry to say your can't do this. RealTypes and DisplayRealTypes are
> immutable (and for a good reason - tracking the events for all the
> consequences of a RealTyoe change would be prohibitively complex).
> 
> You can deal with changing DisplayRealType bounds esily enough by a
> calculation of appropriate new arguments to ScalarMap.setRange().
> But if you want to change the CoordinateSystem then you need to
> create completely new DisplayRealTypes (with new unique String
> names), new DisplayTupleType, completely clear your Display, and
> rebuild your Display. By rebuilding your Display you are essentially
> tracking the event consequences of your DisplayRealType changes.

If you look at the ucar.unidata.view.geoloc.MapProjectionDisplay,
you will see that every time I switch projections, I have to
create a new DisplayRealTupleType (in the setDisplayTypes 
method).  I do this by creating a new DisplayRealType with
a name base and an appended incremented counter:

            instance++;
            displayLatitudeType
                new DisplayRealType(
                    "ProjectionLat" + instance,
                    true, -90.0, 90.0, 0.0,
                    CommonUnit.degree);
            displayLongitudeType
                new DisplayRealType(
                    "ProjectionLon" + instance,
                    true, -180.0, 180.0, 0.0,
                    CommonUnit.degree);
            displayAltitudeType
                new DisplayRealType(
                    "ProjectionAlt" + instance,
                    true, -1.0, 1.0, -1.0, null);
            displayTupleType
                new DisplayTupleType(
                    new DisplayRealType[] {
                        displayLatitudeType,
                        displayLongitudeType,
                        displayAltitudeType},
                        coordinateSystem);

After that, you have to remap latitude to the new displayLatitudeType,
RealType.Longitude to the new displayLongitudeType and
(if 3D) RealType.Altitude to the new displayAltitudeType.  Note in
this class displayAltitudeType is really a passthrough to 
Display.ZAxis (bounds -1.0 to 1.0) and the coordinateSystem
just passes through the values directly.

Since DisplayRealTypes can't occur in more than one 
DisplayRealTupleType, this was all necessary.

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