Windows Fixes Pt. 2: Engine Fixes
This commit is contained in:
parent
f8121441eb
commit
5854c86ca3
5 changed files with 220 additions and 417 deletions
src/de/marcelkapfer/c/morseconverter
|
@ -67,9 +67,7 @@ public class Main extends JFrame {
|
|||
Element element = htmlDocument.getDefaultRootElement();
|
||||
try {
|
||||
htmlDocument.setInnerHTML(element, resourceBundle.getString("about"));
|
||||
} catch (BadLocationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
} catch (BadLocationException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
aboutText.setDocument(htmlDocument);
|
||||
|
|
|
@ -49,14 +49,13 @@ public class EncodeNormalMorseManager {
|
|||
if (inputToSign.toString().startsWith(" ")) {
|
||||
output.append(" ");
|
||||
inputToSign.delete(d, d + 7);
|
||||
} else if(inputToSign.toString().startsWith(System.lineSeparator())){
|
||||
}
|
||||
if (inputToSign.toString().startsWith("\n")) {
|
||||
output.append(System.lineSeparator());
|
||||
inputToSign.delete(0, System.lineSeparator().length());
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append(System.lineSeparator());
|
||||
int indexLineSeparator = input.indexOf("\n");
|
||||
int indexLineSeparator = inputToSign.indexOf("\n");
|
||||
inputToSign.deleteCharAt(indexLineSeparator);
|
||||
} else if (inputToSign.toString().substring(d, d + 3).equals(" ")) {
|
||||
}
|
||||
if (inputToSign.toString().substring(d, d + 3).equals(" ")) {
|
||||
if (d == 0) {
|
||||
inputToSign.delete(0, 3);
|
||||
} else {
|
||||
|
@ -122,9 +121,9 @@ public class EncodeNormalMorseManager {
|
|||
} else if (sign.toString().equals("--..")) {
|
||||
output.append("Z");
|
||||
} else if (sign.toString().equals("-----")) {
|
||||
output.append(". (zero)");
|
||||
output.append("0");
|
||||
} else if (sign.toString().equals(".----")) {
|
||||
output.append("-");
|
||||
output.append("1");
|
||||
} else if (sign.toString().equals("..---")) {
|
||||
output.append("2");
|
||||
} else if (sign.toString().equals("...--")) {
|
||||
|
|
|
@ -39,6 +39,9 @@ public class EncodeWrittenMorseManager {
|
|||
String input;
|
||||
StringBuffer output = new StringBuffer();
|
||||
input = message.toString().toUpperCase() + "#";
|
||||
input.replace(System.lineSeparator(), "\n");
|
||||
input.replace("\r", "\n");
|
||||
input.replace("\r\n", "\n");
|
||||
StringBuffer inputToSign = new StringBuffer(input);
|
||||
while (!inputToSign.toString().equals("#")) {
|
||||
int d = 0;
|
||||
|
@ -47,22 +50,18 @@ public class EncodeWrittenMorseManager {
|
|||
while (signFull) {
|
||||
if (inputToSign.toString().charAt(d) == '+'
|
||||
|| inputToSign.toString().charAt(d) == '#'
|
||||
|| inputToSign.toString().startsWith(System.lineSeparator())) {
|
||||
|| inputToSign.toString().startsWith("\n")) {
|
||||
if (d == 0) {
|
||||
if (inputToSign.toString().startsWith("+")) {
|
||||
output.append(" ");
|
||||
inputToSign.deleteCharAt(0);
|
||||
}
|
||||
if (inputToSign.toString().startsWith(System.lineSeparator())){
|
||||
output.append(System.lineSeparator());
|
||||
inputToSign.delete(0, System.lineSeparator().length());
|
||||
}
|
||||
if (inputToSign.toString().startsWith("#")){
|
||||
inputToSign.deleteCharAt(0);
|
||||
}
|
||||
if (input.toString().startsWith("\n")) {
|
||||
if (inputToSign.toString().startsWith("\n")) {
|
||||
output.append(System.lineSeparator());
|
||||
int indexLineSeparator = input.indexOf("\n");
|
||||
int indexLineSeparator = inputToSign.indexOf("\n");
|
||||
inputToSign.deleteCharAt(indexLineSeparator);
|
||||
}
|
||||
} else {
|
||||
|
@ -128,7 +127,7 @@ public class EncodeWrittenMorseManager {
|
|||
} else if (sign.toString().equals("1100")) {
|
||||
output.append("Z");
|
||||
} else if (sign.toString().equals("11111")) {
|
||||
output.append("0 (zero)");
|
||||
output.append("0");
|
||||
} else if (sign.toString().equals("01111")) {
|
||||
output.append("1");
|
||||
} else if (sign.toString().equals("00111")) {
|
||||
|
|
Reference in a new issue