View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Example Code

MTS code

I have written a java widget that is a timeline that is painted with events representing a capture stream (say video) and associated events (say keyword locations). The widget is called the Multi-Scale Timeline Widget (MTS). The widget provides infinite zooming and control. It is a very dumb, general widget meant to run with any set of streams, events, etc. Thus, it requires a driver program to create the data and control MTS and get events from MTS.

Please see for a better explanation of the widget as well as an example program using it.

You can run another example at

My current work is in (thus, this is likely to be volatile and not working occasionally)

(I've only ever tested these on a Windows95 and Windows98 machine in Netscape, they also require the RealPlayer)

You can get the code at ~hrichter/public/MTS. All the java and class files are there. I don't currently have a driver program there.

The widget consists of:

The data classes MTS uses are in the following:

Thus, the main file is This contains all the code for drawing and maintaining what you see on the screen.

My first question: how do you test such a thing along the refactoring lines with simple tests? What kind of driver program would be necessary? How do you return "okay" for things like resizing and repainting properly. (My main bugs previously were blinking, wrong colored backgrounds, etc) Performance is an issue in this widget as well. The whole drawing scheme is done so as to eliminate blinking.

So, this was meant to be a VERY general widget. As such, I'd like to be able to customize and add bits and pieces. Thus, it would be nice to have MTS as a parent and be able to subclass off of it maybe. Or just make things easier to add and remove. I'm still the only person using it though so my interfaces are unpublished, but would still like to minimize changes to already existing examples.

As examples of the changes I will be making in order of importance (the top two will be done this week - albeit hacked into the code messily):

  • Need to alert the driver program when MTS expands, so it in turn can keep the window can as big as needed and expand or become smaller as needed.

  • Want to add "tooltipping" ability. When you hover over events or the stream, a little box appears with the name of the stream or event or whatever.

  • Want to add little arrow buttons on each side of the sliders for fine control of the scrub.

  • Want to add logging - need to keep track of what user is playing and looking at. This might be better done at the driver program level.

  • Want to add "marking" The widget will keep track of where the user has been before and show this as a little line under the timeline. I attempted to make this change but it turned out to be HUGE because of the way MTS is designed. I gave up and removed the code since it wasn't necessary for current