#771 Timeseris key should be Comparable not String

closed-fixed
General (896)
5
2007-06-29
2007-06-29
Matija Mazi
No

There seems to be no reason why the Timeseries constructors should accept only String name arguments (instead of Comparable), since name is only passed to super() which accepts Comparable.

This is quite inconvenitent and can be changed extremely simply, by just changing the three Timeseries constructor signatures.

Discussion

  • Matija Mazi

    Matija Mazi - 2007-06-29
    • labels: --> General
     
  • David Gilbert

    David Gilbert - 2007-06-29

    Logged In: YES
    user_id=112975
    Originator: NO

    Thanks for the report. I've fixed this in Subversion for the upcoming 1.2.0 release. If you can explain the inconvenience the String type causes, I'll consider whether or not it is worthwhile to copy this change back into the 1.0.x version sources.

     
  • David Gilbert

    David Gilbert - 2007-06-29
    • status: open --> closed
     
  • David Gilbert

    David Gilbert - 2007-06-29
    • assigned_to: nobody --> mungady
    • status: closed --> closed-fixed
     
  • Matija Mazi

    Matija Mazi - 2007-06-29

    Logged In: YES
    user_id=981472
    Originator: YES

    I've checked out the source from SVN and tried it and now it works nicely for me. Thanks!

    The incovenience was rather application-specific so I won't go into details; generally, one might want to use some domain object as a series key so that eg. series renderers can be customized according to the data in the key only. (By the way, in TimeSeries(Comparable name, ...) the 'name' parameter should probably be renamed to 'key'.) Eg., in my code the key is a domain object called DataSource:

    for (int i = 0; i < dataset.getSeriesCount(); i++) {
    XYItemRenderer seriesRenderer = plot.getRenderer();
    TimeSeries series = timeSeriesCollection.getSeries(i);
    DataSource dataSource = (DataSource)series.getKey();
    // format tooltip data according to DataSource
    seriesRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
    "{2} \n{1} \n{0}", DateFormat.getDateInstance(), new DecimalFormat(dataSource.getFormatPattern())));
    // apply some other DataSource-dependent formatting rules to seriesRenderer
    // ...
    }

     
  • Matija Mazi

    Matija Mazi - 2007-06-29

    Logged In: YES
    user_id=981472
    Originator: YES

    Oh, there's one more thing to be fixed: the method TimeSeriesCollection.getSeries(String key) should also accept a Comparable. There may be more..

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks