startSelection.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
try {
MovieController mc = getMovieController();
if (mc != null) {
TimeRecord ts = mc.getSelectionBegin();
TimeRecord td = mc.getSelectionDuration();
System.out.println("Begin ts="+ts);
System.out.println("Begin td="+td);
long diff = mc.getCurrentTime();
System.out.println("Begin current="+diff);
ts.setValue(diff);
ts = new TimeRecord(ts.getScale(),diff);
td = new TimeRecord(td.getScale(),0L);
long winbase=34359738368L;
// td.setValue(10000L);
/*
diff -= ts.getValue();
if (diff > 0) {
if (diff > td.getValue()) {
td.setValue(0);
} else {
td.setValue(td.getValue()-diff);
}
} else {
td.setValue(td.getValue()-diff);
}
ts.setValue( mc.getCurrentTime());
*/
mc.setSelectionBegin(ts);
mc.setSelectionDuration(td);
gd.setRate(1.0);
gd.requestFocus();
}
} catch (QTException e) {
// if (e.errorCode() != Errors.userCanceledErr)
e.printStackTrace();
}
}
});
Button endSelection = new Button("End");
endSelection.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
try {
MovieController mc = getMovieController();
if (mc != null) {
gd.setRate(0);
TimeRecord ts = mc.getSelectionBegin();
TimeRecord td = mc.getSelectionDuration();
long diff = mc.getCurrentTime();
System.out.println("End ts="+ts);
System.out.println("End td="+td);
System.out.println("End diff="+diff);
long tsx = ts.getValue();
if (tsx >= winbase) tsx -= winbase;
if (diff < tsx) {
ts.setValue(diff);
td.setValue(tsx - diff);
} else {
td.setValue(diff-tsx);
}
/*
ts.setValue(diff);
td.setValue(0L);
diff -= ts.getValue();
if (diff > 0) {
td.setValue(diff);
} else {
td.setValue(10);
ts.setValue(mc.getCurrentTime());
}
*/
mc.setSelectionBegin(ts); // clears selection and sets start point
mc.setSelectionDuration(td);
if (true) {
// transcript.addItem(mc, ts, td); // mc to set icon
transcript.addItem(ts, td); // mc to set icon
transcript.lastComponentVisible();
}
gd.requestFocus();
}
} catch (QTException e) {
if (e.errorCode() != Errors.userCanceledErr)
e.printStackTrace();
}
}
});
Button noSelection = new Button("Clear Selection");
noSelection.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
try {
MovieController mc = getMovieController();
if (mc != null) {
TimeRecord ts = mc.getSelectionBegin();
TimeRecord td = mc.getSelectionDuration();
ts.setValue(mc.getCurrentTime());
td.setValue(0);
mc.setSelectionBegin(ts);
mc.setSelectionDuration(td);
gd.requestFocus();
}