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