*
* @param model the time line model
*/
public TimeLine(TimeLineModel model) {
super();
Time start = model.getStartTime();
Time end = model.getEndTime();
int intervals = model.getIntervalCount();
MouseInputListener msListener = new MouseInputAdapter() {
public void mousePressed(MouseEvent e) {
setCursor(e);
}
public void mouseReleased(MouseEvent e) {
setCursor(e);
}
public void mouseMoved(MouseEvent e) {
setCursor(e);
}
private void setCursor(MouseEvent e) {
Cursor cursor = DEFAULT_CURSOR;
for (TimeLineNode node : _nodes) {
if (node.containsPoint(e.getPoint())) {
cursor = node.getCursor(e);
break;
}
}
TimeLine.this.setCursor(cursor);
}
};
this.addMouseListener(msListener);
this.addMouseMotionListener(msListener);
setToolTipText("TimeLine");
ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
_displayStart = start;
_displayEnd = end;
_model = model;
//_model.addPropertyChangeListener(_myModelListener);
_intervalCount = intervals;
double intervalsInTime = (end.getValue(Time.SECOND) - start.getValue(Time.SECOND)) /
(double) _intervalCount;
_intervalInTime = new Time(intervalsInTime, Time.SECOND);
addMouseListener(_mouseListener);
addMouseMotionListener(_mouseDragListener);
addKeyListener(_keyListener);