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

« back to all changes in this revision

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