TimeSeries , problem getting the name

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
JoshRountree
Posts: 14
Joined: Thu Mar 02, 2006 9:00 pm

TimeSeries , problem getting the name

Post by JoshRountree » Wed May 03, 2006 6:18 pm

I would like to grab a subset of a TimeSeries, (I know I can do this using createCopy, but I couldn't get it work exactly right).

I can create the copy by my self, but I can't the name out. The constructor takes a string, but is converted into a Comparable in the super class. Is it possible to get the name as a string back out? Or, must I use the create copy?

*** Edit ***
I just tried using createCopy again, and was reminded why I couldn't get it to work. I get a run time exception:

Code: Select all

java.lang.IllegalArgumentException: Null 'period' argument.
	at org.jfree.data.time.TimeSeries.getIndex TimeSeries.java:422)
	at org.jfree.data.time.TimeSeries.createCopy TimeSeries.java:884)
Josh

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: TimeSeries , problem getting the name

Post by david.gilbert » Thu May 04, 2006 2:36 pm

JoshRountree wrote:I can create the copy by my self, but I can't the name out. The constructor takes a string, but is converted into a Comparable in the super class. Is it possible to get the name as a string back out? Or, must I use the create copy?
You can use series.getKey().toString().

For the exception you mentioned, can you supply a small test program that reproduces the error? I wasn't able to.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

JoshRountree
Posts: 14
Joined: Thu Mar 02, 2006 9:00 pm

Post by JoshRountree » Thu May 04, 2006 3:58 pm

Code: Select all

	    TreeLocation activePeriod = (TreeLocation) nodeInfo;
	    
	    RegularTimePeriod start;
	    RegularTimePeriod end;

	    start = RegularTimePeriod.createInstance(FixedMillisecond.class,
						     new Date(activePeriod.getStart()),
						     TimeZone.getDefault());

	    end   = RegularTimePeriod.createInstance(FixedMillisecond.class,
						     new Date(activePeriod.getEnd()),
						     TimeZone.getDefault());
	    
	    TimeSeries activeSeries;
	    
	    TimeSeries[] seriesToAdd;
	    
	    RegularTimePeriod time;
	    Double metric;
	    
	    // Clear out previous series
	    dataSet.removeAllSeries();
	    
	    // All the file change events
	    ArrayList<TimeSeries[]> allFileSeries = project.getFileChangeSeries();
	    
	    // All packages in a project
	    for (int i = 0; i < allFileSeries.size(); i++) {
		
		seriesToAdd = allFileSeries.get(i);
		
		// All files in a package
		for (int j = 0; j < seriesToAdd.length; j++) {
		    try {
                                      activeSeries = seriesToAdd[j].createCopy(start, end);


			if (activeSeries.getItemCount() > 0) {
			    
			    dataSet.addSeries(activeSeries);
			}
		    } catch (CloneNotSupportedException exp) {

		    }
		}
	    }
	}

I hope this makes sense. I have a tree that has active periods of time in the tree, when a users clicks a specific time interval it shows only that on the graph.

I'll try the toString method (I thought there was one).

Thanks!

Locked