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

« back to all changes in this revision

Viewing changes to TuxGuitar-ascii/src/org/herac/tuxguitar/io/ascii/ASCIIOutputStream.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.io.ascii;
 
2
 
 
3
import java.io.PrintStream;
 
4
import java.io.PrintWriter;
 
5
 
 
6
public class ASCIIOutputStream {
 
7
        private PrintWriter writer;
 
8
        private int x;
 
9
        private int y;
 
10
        
 
11
        public ASCIIOutputStream(PrintStream stream){
 
12
                this.writer = new PrintWriter(stream);
 
13
        }
 
14
        
 
15
        public void drawNote(int fret){
 
16
                movePoint(getPosX() + ((fret >=10 )?2:1),getPosY());
 
17
                this.writer.print(fret);
 
18
        }
 
19
        
 
20
        public void drawStringSegments(int count){
 
21
                movePoint(getPosX() + count,getPosY());
 
22
                for(int i = 0; i < count;i ++){
 
23
                        this.writer.print("-");
 
24
                }
 
25
        }
 
26
        
 
27
        public void drawTuneSegment(String tune,int maxLength){
 
28
                for(int i = tune.length();i < maxLength;i ++){
 
29
                        drawSpace();
 
30
                }
 
31
                movePoint(getPosX() + tune.length(),getPosY());
 
32
                this.writer.print(tune);
 
33
        }
 
34
        
 
35
        public void drawBarSegment(){
 
36
                movePoint(getPosX() + 1,getPosY());
 
37
                this.writer.print("|");
 
38
        }
 
39
        
 
40
        public void nextLine(){
 
41
                movePoint(0,getPosY() + 1);
 
42
                this.writer.println("");
 
43
        }
 
44
        
 
45
        public void drawStringLine(String s){
 
46
                movePoint(0,getPosY() + 1);
 
47
                this.writer.println(s);
 
48
        }
 
49
        
 
50
        public void drawSpace(){
 
51
                movePoint(getPosX() + 1,getPosY());
 
52
                this.writer.print(" ");
 
53
        }
 
54
        
 
55
        private void movePoint(int x,int y){
 
56
                this.x = x;
 
57
                this.y = y;
 
58
        }
 
59
        
 
60
        public int getPosX(){
 
61
                return this.x;
 
62
        }
 
63
        
 
64
        public int getPosY(){
 
65
                return this.y;
 
66
        }
 
67
        
 
68
        public void flush(){
 
69
                this.writer.flush();
 
70
        }
 
71
        
 
72
        public void close(){
 
73
                this.writer.close();
 
74
        }
 
75
}