Skip to content

Commit 06fc51a

Browse files
committedJan 2, 2014
Have state machine recognize # sign in strokes
1 parent 938ebab commit 06fc51a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed
 

‎StenoTray.class

-12 Bytes
Binary file not shown.

‎StenoTray.jar

-6 Bytes
Binary file not shown.

‎StenoTray.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ String colorSteno(String text)
9292
// Let's make this a neat little state machine. Now if only it were fast...
9393
StringBuilder sb = new StringBuilder("<html>");
9494
int state = 0;
95+
String s0 = "/#";
9596
String s1 = "STPHKWR1234";
9697
String s2 = "AO5";
9798
String s3 = "*-0";
9899
String s4 = "EU";
99100
String s5 = "FPLTDRBGSZ6789";
100-
String ss = "/";
101101
for (char c : text.toCharArray()) {
102102
switch (state) {
103103
case 0 : if (s1.indexOf(c) != -1) {
@@ -112,8 +112,8 @@ String colorSteno(String text)
112112
} else if (s4.indexOf(c) != -1) {
113113
state = 4;
114114
sb.append(" <font color=\"white\" bgcolor=\"blue\">");
115-
} else {
116-
throw new IllegalArgumentException("Stroke with impossible values");
115+
} else if (s0.indexOf(c) != -1) {
116+
sb.append(" ");
117117
}
118118
break;
119119
case 1 : if (s2.indexOf(c) != -1) {
@@ -125,7 +125,7 @@ String colorSteno(String text)
125125
} else if (s4.indexOf(c) != -1) {
126126
state = 4;
127127
sb.append("</font><font color=\"white\" bgcolor=\"blue\">");
128-
} else if (ss.indexOf(c) != -1) {
128+
} else if (s0.indexOf(c) != -1) {
129129
state = 0;
130130
sb.append("</font> ");
131131
}
@@ -139,7 +139,7 @@ String colorSteno(String text)
139139
} else if (s5.indexOf(c) != -1) {
140140
state = 5;
141141
sb.append("</font><font color=\"blue\">");
142-
} else if (ss.indexOf(c) != -1) {
142+
} else if (s0.indexOf(c) != -1) {
143143
state = 0;
144144
sb.append("</font> ");
145145
}
@@ -150,20 +150,20 @@ String colorSteno(String text)
150150
} else if (s5.indexOf(c) != -1) {
151151
state = 5;
152152
sb.append("<font color=\"blue\">");
153-
} else if (ss.indexOf(c) != -1) {
153+
} else if (s0.indexOf(c) != -1) {
154154
state = 0;
155155
sb.append(" ");
156156
}
157157
break;
158158
case 4 : if (s5.indexOf(c) != -1) {
159159
state = 5;
160160
sb.append("</font><font color=\"blue\">");
161-
} else if (ss.indexOf(c) != -1) {
161+
} else if (s0.indexOf(c) != -1) {
162162
state = 0;
163163
sb.append("</font> ");
164164
}
165165
break;
166-
case 5 : if (ss.indexOf(c) != -1) {
166+
case 5 : if (s0.indexOf(c) != -1) {
167167
state = 0;
168168
sb.append("</font> ");
169169
}

0 commit comments

Comments
 (0)