Re: 20000928: RealType.Time, and an exception

Hi Paul,

> 
> > >1. What Unit is RealType.Time?
> >
> >  CommonUnit.secondsSinceTheEpoch (seconds since Jan 1, 1970, 00:00:00).
> 
>   If I use RealType.Time for my domain, the axis labels are in
> human-readable form.  If I make my own RealType using the above unit, I
> get axis labels displayed in seconds (I presume).  Why is that?  I
> looked at the source (should have done that before I asked my question)
> and see RealType.Time uses a constructor that I can't use.  Would that
> be why?
> 

If you mean you want to have your axes labeled with a proper date
format, rather than with seconds, then the following code might help:
        // construct a real type from Time and a RealTType from it
    RealType[] time = {RealType.Time};
    RealTupleType tdays = new RealTupleType(time);

        // use VisAD's DateTime class to convert a date into double
    DateTime staDate, stoDate;
    staDate = new DateTime(1998, 1, 57060);     // start date
    stoDate = new DateTime(1998, 1+nDays, 57060);       // end date

        // optional: set date's format to your favourite one; see JDK Docs
java.util.GregorianCalendar
    String dp = "dd.MM.yyyy";
    staDate.setFormatPattern( dp );
    stoDate.setFormatPattern( dp );
    
        // convert date to doubles
    double startAt, stopAt;
            
    startAt = staDate.getValue();
    stopAt = stoDate.getValue();

        // create a domain set with the doubles   
    Set tdaySet =  new Linear1DSet(tdays, startAt, stopAt, nDays); 
    
        // create a map
    xMap6    = new  ScalarMap( RealType.Time, Display.XAxis );

    xMap6.setRange( startAt, stopAt);   // optional ;-)

add it to the display.

You might also want to know about the methods:

ScalarType.alias(java.lang.String alias)

and

ScalarMap.setScalarName(java.lang.String name) 

to set an alternative name for a ScalarType (i.e. RealType) and to set a
name for the ScalarMap, respectively. The latter should allow you to
have an axis label with blank spaces and all.

Hope it helps.

Cheers,

Ugo