Hi all,
I’m working on a project for organising notes, photos, logbook/journal entrys, etc on a timeline.
This is an mockup of what I want to create:
I’m haveing a problem normalising my binary-tree indexes (int timestamps) into the pixle-width of the timeline.
For example, My first node, 1234567890 should be drawn at 0px. my last, 2345678901 at say 800px (or the width of the timeline control).
all the nodes inbetween should be spaced along the x axis of the control reletive to the first and last node.
This is handled by the method:
private int getTimelinePosition(BinaryTreeNode n)
{
int l = this.ctree.GetLowest().getKey(); // the lowest timestamp
int h = this.ctree.GetHighest().getKey(); // the highest timestamp
int tWidth = h - l; // the tine difference (in ms) between high and low
double dtWidth = (double)this.getWidth()/tWidth; // the pixle width of one milisecond
int xPos = (int)(n.getKey() * dtWidth); // get the position on the line
return xPos;
}
for some reason, I’m getting negative numbers anywhere between -400 and -3500-ish.
I’ve been staring at this code for hours now, and have got myself totaly confised by it all, so i thought some fresh eyes might see where the error lies. :-\
If anyone can shed any light on this I would be much obliged.
Matt
(if its something realy simple, feel free to call me a muppet. I seriously have been stuck for hours on this highschool math ;D )

