~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/undo/undoables/UndoableCaretHelper.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.gui.undo.undoables;
 
2
 
 
3
import org.herac.tuxguitar.gui.TuxGuitar;
 
4
import org.herac.tuxguitar.gui.editors.tab.Caret;
 
5
import org.herac.tuxguitar.song.models.TGDuration;
 
6
import org.herac.tuxguitar.song.models.TGString;
 
7
 
 
8
public class UndoableCaretHelper {
 
9
        private long position;
 
10
        private int track;
 
11
        private int string;
 
12
        private int velocity;
 
13
        private TGDuration duration;
 
14
        
 
15
        public UndoableCaretHelper(){
 
16
                Caret caret = getCaret();
 
17
                this.track = caret.getTrack().getNumber();
 
18
                this.position = caret.getPosition();
 
19
                this.velocity = caret.getVelocity();
 
20
                this.duration = caret.getDuration().clone(TuxGuitar.instance().getSongManager().getFactory());
 
21
                this.string = 1;
 
22
                TGString instrumentString = caret.getSelectedString();
 
23
                if(instrumentString != null){
 
24
                        this.string = instrumentString.getNumber();
 
25
                }
 
26
        }
 
27
        
 
28
        public void update(){
 
29
                getCaret().update(this.track,this.position,this.string,this.velocity);
 
30
                getCaret().setSelectedDuration(this.duration.clone(TuxGuitar.instance().getSongManager().getFactory()));
 
31
        }
 
32
        
 
33
        private static Caret getCaret(){
 
34
                return TuxGuitar.instance().getTablatureEditor().getTablature().getCaret();
 
35
        }
 
36
        
 
37
}