My answer to intraday segmentedtimeline problems

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Carl Manaster
Posts: 35
Joined: Tue Mar 28, 2006 1:10 am
Location: La Jolla
Contact:

Post by Carl Manaster » Thu Aug 30, 2007 7:19 pm

Hi, clam,
clam61 wrote:awesome...but does it work now?!

did you ever find out the problem with it?
The only test I ran was to ensure that the results you get from main() are identical to the unmodified version. I'm reasonably certain that the behavior is identical to the original - which means whatever problems were in the original are still there. I just made it (I hope) a little easier to understand, and therefore, I hope, easier to fix. I didn't have time to look at it for the bug, but I hope that without the duplication, the bug will be easier to spot. If I get a chance, I'll try to look at it, but I haven't had a chance yet. My first step in tracking down bugs is often to clean up the code, because I really have trouble making sense of the code otherwise - and without the understanding that comes from that, it's really hard (for me, at least) to figure out what's wrong.

Here, by the way, is my test class; I recommend JUnit (and, for that matter, test-driven development):

Code: Select all

import java.util.TimeZone;

import junit.framework.TestCase;

public class IntradayMarketTimelineTest extends TestCase {
	private IntradayMarketTimeline	timeline;

	protected void setUp() throws Exception {
		TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
		timeline = new IntradayMarketTimeline(0L, 0L, 34200000L, 57600000L, 34200000L, 57600000L, 34200000L, 57600000L, 34200000L, 57600000L, 34200000L,
				57600000L, 0L, 0L);
	}

	public void testTimeline() throws Exception {
		assertEquals(730080000, IntradayMarketTimeline.MILLIS_PER_DAY + IntradayMarketTimeline.MILLIS_PER_WEEK + 38880000L);
		assertEquals(145080000, timeline.toTimelineValue(IntradayMarketTimeline.MILLIS_PER_DAY + IntradayMarketTimeline.MILLIS_PER_WEEK + 38880000L));
		assertEquals(730080000, timeline.toMillisecond(145080000L));
	}

}
Peace,
--Carl

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Re: My answer to intraday segmentedtimeline problems

Post by develop » Mon Mar 16, 2009 8:11 pm

does any one has success using this code ??

I am trying to use this one with real data, and its giving me nullpointer exception. see below trace ..
this is what happens.
in method toMillisecond(...) in while loop some how day value becomes 8 (which is greater than 7 ...) due to this getActiveTimePerDay(...) throws exception.

Code: Select all

java.lang.NullPointerException
        at com.xxx.IntradayMarketTimeline.getActiveTimePerDay(IntradayMarketTimeline.java:280)
        at com.xxx.IntradayMarketTimeline.toMillisecond(IntradayMarketTimeline.java:194)
        at org.jfree.chart.axis.DateAxis.autoAdjustRange(DateAxis.java:1311)
        at org.jfree.chart.axis.DateAxis.configure(DateAxis.java:709)
        at org.jfree.chart.plot.CombinedDomainXYPlot.add(CombinedDomainXYPlot.java:282)

gregory
Posts: 4
Joined: Thu Dec 17, 2009 1:07 pm
antibot: No, of course not.

Re:

Post by gregory » Thu Dec 17, 2009 2:31 pm

david.gilbert wrote:Thanks for posting this.

The segmented date axis code is pretty complex and I wonder whether a completely new approach might be worth trying. ...
I had an idea to simplify the whole approach to segemented timelines. Normally, at least I wouldn't need such a complex feature, if there was a possibilty to show the shapes just one by one equi-distantly, and draw the appropriate tick marks on the axis.
More on this:
http://www.jfree.org/phpBB2/viewtopic.p ... 630#p81630

If you gave a hint where to start implemetation, Timeline or Axis, I could try to make it and post it.

Locked