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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/editors/tab/TGTrackImpl.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
/*
 
2
 * Created on 29-nov-2005
 
3
 *
 
4
 * TODO To change the template for this generated file go to
 
5
 * Window - Preferences - Java - Code Style - Code Templates
 
6
 */
 
7
package org.herac.tuxguitar.gui.editors.tab;
 
8
 
 
9
import java.util.Iterator;
 
10
 
 
11
import org.herac.tuxguitar.gui.editors.tab.layout.ViewLayout;
 
12
import org.herac.tuxguitar.song.factory.TGFactory;
 
13
import org.herac.tuxguitar.song.models.TGTrack;
 
14
 
 
15
/**
 
16
 * @author julian
 
17
 * 
 
18
 * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
 
19
 */
 
20
public class TGTrackImpl extends TGTrack{
 
21
        
 
22
        private int tabHeight;
 
23
        private int scoreHeight;
 
24
        
 
25
        public TGTrackImpl(TGFactory factory) {
 
26
                super(factory);
 
27
        }
 
28
        
 
29
        public void update(ViewLayout layout){
 
30
                this.calculateTabHeight(layout);
 
31
                this.calculateScoreHeight(layout);
 
32
        }
 
33
        /**
 
34
         * Calcula el el ancho de la tablatura
 
35
         */
 
36
        public void calculateTabHeight(ViewLayout layout) {
 
37
                this.tabHeight = ((layout.getStyle() & ViewLayout.DISPLAY_TABLATURE) != 0 ?((stringCount() - 1) * layout.getStringSpacing()):0);
 
38
        }
 
39
        
 
40
        /**
 
41
         * Calcula el el ancho de la partitura
 
42
         */
 
43
        public void calculateScoreHeight(ViewLayout layout) {
 
44
                this.scoreHeight = ((layout.getStyle() & ViewLayout.DISPLAY_SCORE) != 0 ?(layout.getScoreLineSpacing() * 5):0);
 
45
        }
 
46
        
 
47
        public boolean hasCaret(ViewLayout layout){
 
48
                return (this.equals(layout.getTablature().getCaret().getTrack()));
 
49
        }
 
50
        
 
51
        public int getTabHeight() {
 
52
                return this.tabHeight;
 
53
        }
 
54
        
 
55
        public int getScoreHeight() {
 
56
                return this.scoreHeight;
 
57
        }
 
58
        
 
59
        public void setTabHeight(int tabHeight) {
 
60
                this.tabHeight = tabHeight;
 
61
        }
 
62
        
 
63
        public void clear(){
 
64
                Iterator measures = getMeasures();
 
65
                while(measures.hasNext()){
 
66
                        TGMeasureImpl measure = (TGMeasureImpl)measures.next();
 
67
                        if(!measure.isDisposed()){
 
68
                                measure.dispose();
 
69
                        }
 
70
                }
 
71
                super.clear();
 
72
        }
 
73
        
 
74
        public void removeMeasure(int index){
 
75
                TGMeasureImpl measure = (TGMeasureImpl)getMeasure(index);
 
76
                if(!measure.isDisposed()){
 
77
                        measure.dispose();
 
78
                }
 
79
                super.removeMeasure(index);
 
80
        }
 
81
}
 
 
b'\\ No newline at end of file'