Windows Fixes Pt. 1

This commit is contained in:
Marcel Michael Kapfer 2015-07-29 18:00:10 +02:00
parent fab340487c
commit ea2b9efaae
17 changed files with 446 additions and 405 deletions

0
.gitignore vendored Normal file → Executable file
View file

0
LICENSE Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

6
src/META-INF/MANIFEST.MF Normal file → Executable file
View file

@ -1,3 +1,3 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Main-Class: de.marcelkapfer.c.morseconverter.Main Main-Class: de.marcelkapfer.c.morseconverter.Main

2
src/de/marcelkapfer/c/morseconverter/Main.form Normal file → Executable file
View file

@ -122,7 +122,7 @@
<properties/> <properties/>
<border type="none"/> <border type="none"/>
<children> <children>
<component id="c0dac" class="javax.swing.JTextPane" default-binding="true"> <component id="c0dac" class="javax.swing.JTextPane" binding="aboutText">
<constraints/> <constraints/>
<properties> <properties>
<contentType value="text/html"/> <contentType value="text/html"/>

308
src/de/marcelkapfer/c/morseconverter/Main.java Normal file → Executable file
View file

@ -1,145 +1,163 @@
package de.marcelkapfer.c.morseconverter; package de.marcelkapfer.c.morseconverter;
/* /*
This is a Java application for converting writtenMorse and normal morse code. This is a Java application for converting writtenMorse and normal morse code.
Copyright (C) 2014-2015 Marcel Michael Kapfer Copyright (C) 2014-2015 Marcel Michael Kapfer
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
Marcel Michael Kapfer Marcel Michael Kapfer
marcelmichaelkapfer@yahoo.co.nz marcelmichaelkapfer@yahoo.co.nz
*/ */
import de.marcelkapfer.c.morseconverter.engine.DecodeNormalMorseManager; import de.marcelkapfer.c.morseconverter.engine.DecodeNormalMorseManager;
import de.marcelkapfer.c.morseconverter.engine.DecodeWrittenMorseManager; import de.marcelkapfer.c.morseconverter.engine.DecodeWrittenMorseManager;
import de.marcelkapfer.c.morseconverter.engine.EncodeNormalMorseManager; import de.marcelkapfer.c.morseconverter.engine.EncodeNormalMorseManager;
import de.marcelkapfer.c.morseconverter.engine.EncodeWrittenMorseManager; import de.marcelkapfer.c.morseconverter.engine.EncodeWrittenMorseManager;
import de.marcelkapfer.c.morseconverter.intelligentCodeRecognization.NormalMorseCodeRecognization; import de.marcelkapfer.c.morseconverter.intelligentCodeRecognization.NormalMorseCodeRecognization;
import de.marcelkapfer.c.morseconverter.intelligentCodeRecognization.WrittenMorseCodeRecognization; import de.marcelkapfer.c.morseconverter.intelligentCodeRecognization.WrittenMorseCodeRecognization;
import de.marcelkapfer.c.morseconverter.update.Update; import de.marcelkapfer.c.morseconverter.update.Update;
import de.marcelkapfer.c.morseconverter.update.UpdateDialog; import de.marcelkapfer.c.morseconverter.update.UpdateDialog;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import javax.swing.text.BadLocationException;
import java.awt.event.ActionEvent; import javax.swing.text.Element;
import java.awt.event.ActionListener; import javax.swing.text.html.HTMLDocument;
import java.awt.event.KeyAdapter; import javax.swing.text.html.HTMLEditorKit;
import java.awt.event.KeyEvent; import java.awt.*;
import java.util.ResourceBundle; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main extends JFrame { import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
// Version numbers for update check import java.io.IOException;
public static final int currentVersion = 190; import java.util.ResourceBundle;
public static int latestVersion = currentVersion;
public class Main extends JFrame {
public static ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
public JTabbedPane morseConverterPane; // Version numbers for update check
private JPanel panel1; public static final int currentVersion = 191;
private JTextArea inputAreaWrittenMorse; public static int latestVersion = currentVersion;
private JTextArea outputAreaWrittenMorse;
private JTextArea inputAreaNormalMorse; public static ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
private JTextArea outputAreaNormalMorse; public JTabbedPane morseConverterPane;
private JButton updateDialogButton; private JPanel panel1;
private JLabel updateAvailable; private JTextArea inputAreaWrittenMorse;
private JTextArea outputAreaWrittenMorse;
// Contains mainly listeners private JTextArea inputAreaNormalMorse;
public Main() { private JTextArea outputAreaNormalMorse;
// Listener for the writtenMorse input field private JButton updateDialogButton;
inputAreaWrittenMorse.addKeyListener(new KeyAdapter() { private JLabel updateAvailable;
@Override private JTextPane aboutText;
public void keyReleased(KeyEvent e) {
instantWrittenMorseConvert(); // Contains mainly listeners
} public Main() {
}); HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
// Listener for the normal Morse input field HTMLDocument htmlDocument = (HTMLDocument) htmlEditorKit.createDefaultDocument();
inputAreaNormalMorse.addKeyListener(new KeyAdapter() { Element element = htmlDocument.getDefaultRootElement();
@Override try {
public void keyReleased(KeyEvent e) { htmlDocument.setInnerHTML(element, resourceBundle.getString("about"));
instantNormalMorseConvert(); } catch (BadLocationException e) {
} e.printStackTrace();
}); } catch (IOException e) {
e.printStackTrace();
// Trying to read a file from a server }
latestVersion = Update.getLatestVersion("http://lab.marcel-kapfer.de/writtenmorse/desktop/version.txt", currentVersion); aboutText.setDocument(htmlDocument);
// Listener for the writtenMorse input field
if (currentVersion < latestVersion){ inputAreaWrittenMorse.addKeyListener(new KeyAdapter() {
JOptionPane.showMessageDialog(null, resourceBundle.getString("updateAvailable")); @Override
updateAvailable.setVisible(true); public void keyReleased(KeyEvent e) {
updateDialogButton.setText(resourceBundle.getString("aboutUpdateAvailableButton")); instantWrittenMorseConvert();
} }
});
updateDialogButton.addActionListener(new ActionListener() { // Listener for the normal Morse input field
@Override inputAreaNormalMorse.addKeyListener(new KeyAdapter() {
public void actionPerformed(ActionEvent e) { @Override
updateDialog(); public void keyReleased(KeyEvent e) {
} instantNormalMorseConvert();
}
}); });
}
// The holy main method // Trying to read a file from a server
public static void main(String[] args){ latestVersion = Update.getLatestVersion("http://lab.marcel-kapfer.de/writtenmorse/desktop/version.txt", currentVersion);
// Tries to present the app in an native look
try{ if (currentVersion < latestVersion){
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); JOptionPane.showMessageDialog(null, resourceBundle.getString("updateAvailable"));
} catch (Exception e){ updateAvailable.setVisible(true);
e.printStackTrace(); updateDialogButton.setText(resourceBundle.getString("aboutUpdateAvailableButton"));
} }
// Starting the application
JFrame main = new JFrame("Main"); updateDialogButton.addActionListener(new ActionListener() {
main.setContentPane(new Main().morseConverterPane); @Override
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); public void actionPerformed(ActionEvent e) {
// Title updateDialog();
main.setTitle(resourceBundle.getString("title")); }
main.pack();
// Window position and Size });
main.setBounds(100, 100, 800, 400); }
main.setIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/res/icon-xxxhdpi.png"))); // The holy main method
// MAKE IT HAPPEN :D public static void main(String[] args){
main.setVisible(true); // Tries to present the app in an native look
} try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// Method for converting writtenMorse } catch (Exception e){
private void instantWrittenMorseConvert(){ e.printStackTrace();
// Gets the text from the input field }
String input = inputAreaWrittenMorse.getText(); // Starting the application
// checks if the code is a writtenMorse code JFrame main = new JFrame("Main");
if(WrittenMorseCodeRecognization.isCode(input)) { main.setContentPane(new Main().morseConverterPane);
// converts the code into normal letters main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
outputAreaWrittenMorse.setText(EncodeWrittenMorseManager.getEncodedString(input)); // Title
} else { main.setTitle(resourceBundle.getString("title"));
// converts the code into writtenMorse main.pack();
outputAreaWrittenMorse.setText(DecodeWrittenMorseManager.getDecodedString(input)); // Window position and Size
} main.setBounds(100, 100, 800, 400);
} main.setIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/res/icon-xxxhdpi.png")));
// MAKE IT HAPPEN :D
// Method for converting normal Morse main.setVisible(true);
private void instantNormalMorseConvert(){ System.out.print(System.lineSeparator());
// Gets the text from the input field }
String input = inputAreaNormalMorse.getText();
// checks if the code is a normal Morse code // Method for converting writtenMorse
if(NormalMorseCodeRecognization.isCode(input)){ private void instantWrittenMorseConvert(){
// converts the code into normal letters // Gets the text from the input field
outputAreaNormalMorse.setText(EncodeNormalMorseManager.getEncodedString(input)); String input = inputAreaWrittenMorse.getText();
} else { // checks if the code is a writtenMorse code
// converts the code into writtenMorse if(WrittenMorseCodeRecognization.isCode(input)) {
outputAreaNormalMorse.setText(DecodeNormalMorseManager.getDecodedString(input)); // converts the code into normal letters
} outputAreaWrittenMorse.setText(EncodeWrittenMorseManager.getEncodedString(input));
} } else {
// converts the code into writtenMorse
private void updateDialog() { outputAreaWrittenMorse.setText(DecodeWrittenMorseManager.getDecodedString(input));
UpdateDialog.main(null); }
} }
} // Method for converting normal Morse
private void instantNormalMorseConvert(){
// Gets the text from the input field
String input = inputAreaNormalMorse.getText();
// checks if the code is a normal Morse code
if(NormalMorseCodeRecognization.isCode(input)){
// converts the code into normal letters
outputAreaNormalMorse.setText(EncodeNormalMorseManager.getEncodedString(input));
} else {
// converts the code into writtenMorse
outputAreaNormalMorse.setText(DecodeNormalMorseManager.getDecodedString(input));
}
}
private void updateDialog() {
UpdateDialog.main(null);
}
}

View file

@ -65,7 +65,12 @@ public class DecodeNormalMorseManager {
input.delete(0, 1); input.delete(0, 1);
} else if(input.toString().startsWith(System.lineSeparator())) { } else if(input.toString().startsWith(System.lineSeparator())) {
output.append(System.lineSeparator()); output.append(System.lineSeparator());
input.deleteCharAt(input.indexOf(System.lineSeparator())); int indexLineSeparator = input.indexOf(System.lineSeparator());
input.delete(indexLineSeparator, indexLineSeparator + System.lineSeparator().length());
} else if (input.toString().startsWith("\n")) {
output.append(System.lineSeparator());
int indexLineSeparator = input.indexOf("\n");
input.deleteCharAt(indexLineSeparator);
} else if (input.toString().startsWith("A")) { } else if (input.toString().startsWith("A")) {
output.append(".- "); output.append(".- ");
input.delete(0, 1); input.delete(0, 1);
@ -235,7 +240,7 @@ public class DecodeNormalMorseManager {
output.append("...-..- "); output.append("...-..- ");
input.delete(0, 1); input.delete(0, 1);
} else { } else {
output.replace(0, output.length(), "Code not listed or wrong."); return "Code not listed or wrong.";
} }
} }
if (output.toString().endsWith(" ")) { if (output.toString().endsWith(" ")) {

View file

@ -1,249 +1,254 @@
package de.marcelkapfer.c.morseconverter.engine; package de.marcelkapfer.c.morseconverter.engine;
/* /*
This is a Java application for converting writtenMorse and normal morse code. This is a Java application for converting writtenMorse and normal morse code.
Copyright (C) 2014-2015 Marcel Michael Kapfer Copyright (C) 2014-2015 Marcel Michael Kapfer
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
Marcel Michael Kapfer Marcel Michael Kapfer
marcelmichaelkapfer@yahoo.co.nz marcelmichaelkapfer@yahoo.co.nz
*/ */
public class DecodeWrittenMorseManager { public class DecodeWrittenMorseManager {
public static String getDecodedString(String inputMessage) { public static String getDecodedString(String inputMessage) {
if(inputMessage.equals("")){ if(inputMessage.equals("")){
return "Please enter at least one character"; return "Please enter at least one character";
} else { } else {
StringBuffer message = new StringBuffer(inputMessage); StringBuffer message = new StringBuffer(inputMessage);
if (message.toString().endsWith(" ")) { if (message.toString().endsWith(" ")) {
message = message.deleteCharAt(message.length() - 1); message = message.deleteCharAt(message.length() - 1);
} }
// Variables // Variables
StringBuffer input = new StringBuffer(); StringBuffer input = new StringBuffer();
input = input.replace(0, input.length(), message.toString().toUpperCase()); input = input.replace(0, input.length(), message.toString().toUpperCase());
StringBuffer output = new StringBuffer(); StringBuffer output = new StringBuffer();
if (input.toString().equals("LETTERSPACE")) { if (input.toString().equals("LETTERSPACE")) {
output.replace(0, output.length(), "#"); output.replace(0, output.length(), "#");
} else if (input.toString().equals("END OF WORK")) { } else if (input.toString().equals("END OF WORK")) {
output.replace(0, output.length(), "000101"); output.replace(0, output.length(), "000101");
} else if (input.toString().equals("ERROR")) { } else if (input.toString().equals("ERROR")) {
output.replace(0, output.length(), "00000000"); output.replace(0, output.length(), "00000000");
} else if (input.toString().equals("STARTING SIGNAL")) { } else if (input.toString().equals("STARTING SIGNAL")) {
output.replace(0, output.length(), "10101"); output.replace(0, output.length(), "10101");
} else if (input.toString().equals("ENDING SIGNAL")) { } else if (input.toString().equals("ENDING SIGNAL")) {
output.replace(0, output.length(), "01010"); output.replace(0, output.length(), "01010");
} else if (input.toString().equals("UNDERSTOOD")) { } else if (input.toString().equals("UNDERSTOOD")) {
output.replace(0, output.length(), "00010"); output.replace(0, output.length(), "00010");
} else if (input.toString().equals("WAIT")) { } else if (input.toString().equals("WAIT")) {
output.replace(0, output.length(), "01000"); output.replace(0, output.length(), "01000");
} else if (input.toString().equals("SOS")) { } else if (input.toString().equals("SOS")) {
output.replace(0, output.length(), "000111000"); output.replace(0, output.length(), "000111000");
} else if (input.toString().equals("LETTER SPACE")) { } else if (input.toString().equals("LETTER SPACE")) {
output.replace(0, output.length(), "##"); output.replace(0, output.length(), "##");
} else if (input.toString().equals("WORD SPACE")) { } else if (input.toString().equals("WORD SPACE")) {
output.replace(0, output.length(), "+"); output.replace(0, output.length(), "+");
} else { } else {
while (input.length() > 0) { while (input.length() > 0) {
if (input.toString().startsWith(" ")) { if (input.toString().startsWith(" ")) {
if (output.toString().endsWith("#")) { if (output.toString().endsWith("#")) {
output.delete(output.length() - 1, output.length()); output.delete(output.length() - 1, output.length());
} }
output.append("+"); output.append("+");
input.delete(0, 1); input.delete(0, 1);
} else if(input.toString().startsWith(System.lineSeparator())) { } else if (input.toString().startsWith(System.lineSeparator())) {
output.append(System.lineSeparator()); output.append(System.lineSeparator());
input.deleteCharAt(input.indexOf(System.lineSeparator())); int indexLineSeparator = input.indexOf(System.lineSeparator());
} else if (input.toString().startsWith("A")) { input.delete(indexLineSeparator, indexLineSeparator + System.lineSeparator().length());
output.append("01#"); } else if (input.toString().startsWith("\n")) {
input.delete(0, 1); output.append(System.lineSeparator());
} else if (input.toString().startsWith("B")) { int indexLineSeparator = input.indexOf("\n");
output.append("1000#"); input.deleteCharAt(indexLineSeparator);
input.delete(0, 1); } else if (input.toString().startsWith("A")) {
} else if (input.toString().startsWith("C")) { output.append("01#");
output.append("1010#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("B")) {
} else if (input.toString().startsWith("D")) { output.append("1000#");
output.append("100#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("C")) {
} else if (input.toString().startsWith("E")) { output.append("1010#");
output.append("0#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("D")) {
} else if (input.toString().startsWith("F")) { output.append("100#");
output.append("0010#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("E")) {
} else if (input.toString().startsWith("G")) { output.append("0#");
output.append("110#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("F")) {
} else if (input.toString().startsWith("H")) { output.append("0010#");
output.append("0000#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("G")) {
} else if (input.toString().startsWith("I")) { output.append("110#");
output.append("00#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("H")) {
} else if (input.toString().startsWith("J")) { output.append("0000#");
output.append("0111#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("I")) {
} else if (input.toString().startsWith("K")) { output.append("00#");
output.append("101#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("J")) {
} else if (input.toString().startsWith("L")) { output.append("0111#");
output.append("0100#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("K")) {
} else if (input.toString().startsWith("M")) { output.append("101#");
output.append("11#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("L")) {
} else if (input.toString().startsWith("N")) { output.append("0100#");
output.append("10#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("M")) {
} else if (input.toString().startsWith("O")) { output.append("11#");
output.append("111#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("N")) {
} else if (input.toString().startsWith("P")) { output.append("10#");
output.append("0110#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("O")) {
} else if (input.toString().startsWith("Q")) { output.append("111#");
output.append("1101#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("P")) {
} else if (input.toString().startsWith("R")) { output.append("0110#");
output.append("010#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("Q")) {
} else if (input.toString().startsWith("S")) { output.append("1101#");
output.append("000#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("R")) {
} else if (input.toString().startsWith("T")) { output.append("010#");
output.append("1#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("S")) {
} else if (input.toString().startsWith("U")) { output.append("000#");
output.append("001#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("T")) {
} else if (input.toString().startsWith("V")) { output.append("1#");
output.append("0001#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("U")) {
} else if (input.toString().startsWith("W")) { output.append("001#");
output.append("011#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("V")) {
} else if (input.toString().startsWith("X")) { output.append("0001#");
output.append("1001#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("W")) {
} else if (input.toString().startsWith("Y")) { output.append("011#");
output.append("1011#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("X")) {
} else if (input.toString().startsWith("Z")) { output.append("1001#");
output.append("1100#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("Y")) {
} else if (input.toString().startsWith("0")) { output.append("1011#");
output.append("11111#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("Z")) {
} else if (input.toString().startsWith("1")) { output.append("1100#");
output.append("01111#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("0")) {
} else if (input.toString().startsWith("2")) { output.append("11111#");
output.append("00111#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("1")) {
} else if (input.toString().startsWith("3")) { output.append("01111#");
output.append("00011#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("2")) {
} else if (input.toString().startsWith("4")) { output.append("00111#");
output.append("00001#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("3")) {
} else if (input.toString().startsWith("5")) { output.append("00011#");
output.append("00000#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("4")) {
} else if (input.toString().startsWith("6")) { output.append("00001#");
output.append("10000#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("5")) {
} else if (input.toString().startsWith("7")) { output.append("00000#");
output.append("11000#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("6")) {
} else if (input.toString().startsWith("8")) { output.append("10000#");
output.append("11100#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("7")) {
} else if (input.toString().startsWith("9")) { output.append("11000#");
output.append("11110#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("8")) {
} else if (input.toString().startsWith("Ä")) { output.append("11100#");
output.append("0101#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("9")) {
} else if (input.toString().startsWith("Ö")) { output.append("11110#");
output.append("1110#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("Ä")) {
} else if (input.toString().startsWith("Ü")) { output.append("0101#");
output.append("0011#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("Ö")) {
} else if (input.toString().startsWith("ß")) { output.append("1110#");
output.append("00011000#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("Ü")) {
} else if (input.toString().startsWith(".")) { output.append("0011#");
output.append("010101#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("ß")) {
} else if (input.toString().startsWith(",")) { output.append("00011000#");
output.append("110011#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith(".")) {
} else if (input.toString().startsWith(":")) { output.append("010101#");
output.append("111000#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith(",")) {
} else if (input.toString().startsWith(";")) { output.append("110011#");
output.append("101010#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith(":")) {
} else if (input.toString().startsWith("?")) { output.append("111000#");
output.append("001100#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith(";")) {
} else if (input.toString().startsWith("!")) { output.append("101010#");
output.append("101011#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("?")) {
} else if (input.toString().startsWith("-")) { output.append("001100#");
output.append("100001#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("!")) {
} else if (input.toString().startsWith("_")) { output.append("101011#");
output.append("001101#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("-")) {
} else if (input.toString().startsWith("(")) { output.append("100001#");
output.append("10110#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("_")) {
} else if (input.toString().startsWith(")")) { output.append("001101#");
output.append("101101#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("(")) {
} else if (input.toString().startsWith("=")) { output.append("10110#");
output.append("10001#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith(")")) {
} else if (input.toString().startsWith("+")) { output.append("101101#");
output.append("01010#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("=")) {
} else if (input.toString().startsWith("/")) { output.append("10001#");
output.append("10010#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("+")) {
} else if (input.toString().startsWith("@")) { output.append("01010#");
output.append("011010#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("/")) {
} else if (input.toString().startsWith("'")) { output.append("10010#");
output.append("011110#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("@")) {
} else if (input.toString().startsWith("$")) { output.append("011010#");
output.append("0001001#"); input.delete(0, 1);
input.delete(0, 1); } else if (input.toString().startsWith("'")) {
} else { output.append("011110#");
output.replace(0, output.length(), "Code not listed or wrong."); input.delete(0, 1);
} } else if (input.toString().startsWith("$")) {
} output.append("0001001#");
if (output.toString().endsWith("#")) { input.delete(0, 1);
output.delete(output.length() - 1, output.length()); } else {
} return "Code not listed or wrong.";
} }
return output.toString(); }
} if (output.toString().endsWith("#")) {
} output.delete(output.length() - 1, output.length());
}
}
return output.toString();
}
}
} }

View file

@ -51,7 +51,11 @@ public class EncodeNormalMorseManager {
inputToSign.delete(d, d + 7); inputToSign.delete(d, d + 7);
} else if(inputToSign.toString().startsWith(System.lineSeparator())){ } else if(inputToSign.toString().startsWith(System.lineSeparator())){
output.append(System.lineSeparator()); output.append(System.lineSeparator());
inputToSign.deleteCharAt(0); inputToSign.delete(0, System.lineSeparator().length());
} else if (input.toString().startsWith("\n")) {
output.append(System.lineSeparator());
int indexLineSeparator = input.indexOf("\n");
inputToSign.deleteCharAt(indexLineSeparator);
} else if (inputToSign.toString().substring(d, d + 3).equals(" ")) { } else if (inputToSign.toString().substring(d, d + 3).equals(" ")) {
if (d == 0) { if (d == 0) {
inputToSign.delete(0, 3); inputToSign.delete(0, 3);
@ -190,7 +194,7 @@ public class EncodeNormalMorseManager {
} else if (sign.toString().equals("........")) { } else if (sign.toString().equals("........")) {
output.append("Error"); output.append("Error");
} else { } else {
output.replace(0, output.length(), "Code not listed or wrong."); return "Code not listed or wrong.";
} }
} }
return output.toString(); return output.toString();

View file

@ -51,11 +51,20 @@ public class EncodeWrittenMorseManager {
if (d == 0) { if (d == 0) {
if (inputToSign.toString().startsWith("+")) { if (inputToSign.toString().startsWith("+")) {
output.append(" "); output.append(" ");
inputToSign.deleteCharAt(0);
} }
if (inputToSign.toString().startsWith(System.lineSeparator())){ if (inputToSign.toString().startsWith(System.lineSeparator())){
output.append(System.lineSeparator()); output.append(System.lineSeparator());
inputToSign.delete(0, System.lineSeparator().length());
}
if (inputToSign.toString().startsWith("#")){
inputToSign.deleteCharAt(0);
}
if (input.toString().startsWith("\n")) {
output.append(System.lineSeparator());
int indexLineSeparator = input.indexOf("\n");
inputToSign.deleteCharAt(indexLineSeparator);
} }
inputToSign.deleteCharAt(0);
} else { } else {
sign.replace(0, sign.length(), inputToSign sign.replace(0, sign.length(), inputToSign
.toString().substring(0, d)); .toString().substring(0, d));
@ -191,7 +200,7 @@ public class EncodeWrittenMorseManager {
} else if (sign.toString().equals("00000000")) { } else if (sign.toString().equals("00000000")) {
output.append("Error"); output.append("Error");
} else { } else {
output.replace(0, output.length(), "Code not listed or wrong."); return "Code not listed or wrong.";
} }
} }
return output.toString(); return output.toString();

2
src/de/marcelkapfer/c/morseconverter/text.properties Normal file → Executable file
View file

@ -1,4 +1,4 @@
about=<html>\n<head>\n</head>\n<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.0 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Developer</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Contact</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>License</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Bug</b><br>If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>You can find a detailed guide on marcel-kapfer.de/writtenmorse/\#howto_desktop\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Missing Code</b><br>If you discovered, that a code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.\n</p>\n</p>\n</body>\n</html> about=<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.1 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Developer</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Contact</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>License</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Bug</b><br>If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>You can find a detailed guide on marcel-kapfer.de/writtenmorse/\#howto_desktop\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Missing Code</b><br>If you discovered, that a code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.\n</p>\n</p>\n</body>
aboutUpdateAvailable=Update available aboutUpdateAvailable=Update available
aboutUpdateAvailableButton=Install Update aboutUpdateAvailableButton=Install Update
inputText=Enter your text inputText=Enter your text

View file

@ -1,4 +1,4 @@
about=<html>\n<head>\n</head>\n<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.0 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Entwickler</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Kontakt</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Lizenz</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehler</b><br>Wenn Du einen Fehler gefunden hast, schreibe mir bitte ein E-Mail an marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>Du kannst eine ausführliche Anleitung auf marcel-kapfer.de/writtenmorse/\#howto_android finden.\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehlender Code</b><br>Wenn Du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine E-Mail an marcelmichaelkapfer@yahoo.co.nz.\n</p>\n</p>\n</body>\n</html> about=<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.1 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Entwickler</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Kontakt</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Lizenz</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehler</b><br>Wenn Du einen Fehler gefunden hast, schreibe mir bitte ein E-Mail an marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>Du kannst eine ausführliche Anleitung auf marcel-kapfer.de/writtenmorse/\#howto_android finden.\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehlender Code</b><br>Wenn Du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine E-Mail an marcelmichaelkapfer@yahoo.co.nz.\n</p>\n</p>\n</body>
aboutUpdateAvailable=Update verfügbar aboutUpdateAvailable=Update verfügbar
aboutUpdateAvailableButton=Update installieren aboutUpdateAvailableButton=Update installieren
inputText=Geben Sie einen Text ein inputText=Geben Sie einen Text ein

View file

View file

View file