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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/editors/tab/layout/TrackSpacing.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.editors.tab.layout;
2
 
 
3
 
public class TrackSpacing {             
4
 
        public static final int SCORE = 0x01; 
5
 
        public static final int TABLATURE = 0x02;
6
 
        
7
 
        public static final int POSITION_TOP = 0;
8
 
        public static final int POSITION_SCORE_UP_LINES = 1;
9
 
        public static final int POSITION_SCORE_MIDDLE_LINES = 2;
10
 
        public static final int POSITION_SCORE_DOWN_LINES = 3;  
11
 
        public static final int POSITION_TUPLETO = 4;
12
 
        public static final int POSITION_ACCENTUATED_EFFECT = 5;
13
 
        public static final int POSITION_HARMONIC_EFFEC = 6;
14
 
        public static final int POSITION_TAPPING_EFFEC = 7;
15
 
        public static final int POSITION_PALM_MUTE_EFFEC = 8;
16
 
        public static final int POSITION_VIBRATO_EFFEC = 9;     
17
 
        public static final int POSITION_FADE_IN = 10;
18
 
        public static final int POSITION_TABLATURE_TOP_SEPARATOR = 11;
19
 
        public static final int POSITION_TABLATURE = 12;
20
 
        public static final int POSITION_LYRIC = 13;
21
 
        public static final int POSITION_BOTTOM = 14;
22
 
        
23
 
        private static final int[][] POSITIONS = new int[][]{
24
 
                /** SCORE **/
25
 
                new int[]{
26
 
                                0, //POSITION_TOP
27
 
                                1, //POSITION_SCORE_UP_LINES
28
 
                                2, //POSITION_SCORE_MIDDLE_LINES
29
 
                                3, //POSITION_SCORE_DOWN_LINES  
30
 
                                4, //POSITION_TUPLETO
31
 
                                5, //POSITION_ACCENTUATED_EFFECT
32
 
                                6, //POSITION_HARMONIC_EFFEC
33
 
                                7, //POSITION_TAPPING_EFFEC
34
 
                                8, //POSITION_PALM_MUTE_EFFEC
35
 
                                9, //POSITION_VIBRATO_EFFEC
36
 
                                10, //POSITION_FADE_IN
37
 
                                11, //POSITION_TABLATURE_TOP_SEPARATOR
38
 
                                12, //POSITION_TABLATURE
39
 
                                13, //POSITION_LYRIC
40
 
                                14, //POSITION_BOTTOM                                   
41
 
                        },
42
 
 
43
 
                /** TABLATURE **/
44
 
                new int[]{
45
 
                                0, //POSITION_TOP
46
 
                                12, //POSITION_SCORE_UP_LINES
47
 
                                13, //POSITION_SCORE_MIDDLE_LINES
48
 
                                14, //POSITION_SCORE_DOWN_LINES 
49
 
                                9, //POSITION_TUPLETO
50
 
                                6, //POSITION_FADE_IN                           
51
 
                                2, //POSITION_HARMONIC_EFFEC
52
 
                                3, //POSITION_TAPPING_EFFEC
53
 
                                4, //POSITION_PALM_MUTE_EFFEC
54
 
                                5, //POSITION_VIBRATO_EFFEC
55
 
                                1, //POSITION_ACCENTUATED_EFFECT
56
 
                                7, //POSITION_TABLATURE_TOP_SEPARATOR
57
 
                                8, //POSITION_TABLATURE
58
 
                                10, //POSITION_LYRIC
59
 
                                11, //POSITION_BOTTOM                                   
60
 
                        },      
61
 
                        
62
 
                /** SCORE & TABLATURE **/
63
 
                new int[]{
64
 
                                0, //POSITION_TOP
65
 
                                1, //POSITION_SCORE_UP_LINES
66
 
                                2, //POSITION_SCORE_MIDDLE_LINES
67
 
                                3, //POSITION_SCORE_DOWN_LINES  
68
 
                                4, //POSITION_TUPLETO
69
 
                                5, //POSITION_ACCENTUATED_EFFECT
70
 
                                6, //POSITION_HARMONIC_EFFEC
71
 
                                7, //POSITION_TAPPING_EFFEC
72
 
                                8, //POSITION_PALM_MUTE_EFFEC
73
 
                                9, //POSITION_VIBRATO_EFFEC
74
 
                                10, //POSITION_FADE_IN
75
 
                                11, //POSITION_TABLATURE_TOP_SEPARATOR
76
 
                                12, //POSITION_TABLATURE
77
 
                                13, //POSITION_LYRIC
78
 
                                14, //POSITION_BOTTOM                                           
79
 
                        },
80
 
        };
81
 
 
82
 
        private int flags;
83
 
        private int[] spacing;
84
 
        
85
 
        public TrackSpacing(ViewLayout layout){
86
 
                this.flags = 0;
87
 
                this.flags |= (layout.isScoreEnabled()?SCORE:0);
88
 
                this.flags |= (layout.isTablatureEnabled()?TABLATURE:0);
89
 
                this.spacing = new int[15];
90
 
        }               
91
 
        
92
 
        public void setSize(int index,int size){
93
 
                this.spacing[ POSITIONS [this.flags -1] [index] ] = size;
94
 
        }
95
 
        
96
 
        public int getSize(){
97
 
                int span = 0;           
98
 
                for(int i = 0;i < this.spacing.length; i ++){
99
 
                        span += this.spacing[i];
100
 
                }                                                       
101
 
                return span;
102
 
        }
103
 
        
104
 
        public int getPosition(int index){                              
105
 
                int span = 0;
106
 
                for(int i = 0;i < POSITIONS[this.flags -1][index]; i ++){
107
 
                        span += this.spacing[i];
108
 
                }
109
 
                return span;
110
 
        }  
111
 
 
112
 
}