Added line break support

This commit is contained in:
mmk2410 2015-06-04 10:39:07 +02:00
parent 2aeadf10ee
commit fb49b73b7e
6 changed files with 39 additions and 7 deletions

View file

@ -120,11 +120,30 @@
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</hspacer> </hspacer>
<vspacer id="44230"> <scrollpane id="ba62c">
<constraints> <constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</vspacer> <properties/>
<border type="none"/>
<children>
<component id="c0dac" class="javax.swing.JTextPane" default-binding="true">
<constraints/>
<properties>
<contentType value="text/html"/>
<editable value="false"/>
<enabled value="true"/>
<font/>
<text value="&lt;html&gt;&#10; &lt;head&gt;&#10; &#10; &lt;/head&gt;&#10; &lt;body&gt;&#10; &lt;p style=&quot;margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px&quot;&gt;&#10; &lt;b&gt;Developer&lt;/b&gt;&lt;br&gt;Marcel Kapfer&#10; &lt;/p&gt;&#10; &lt;p style=&quot;margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px&quot;&gt;&#10; &lt;b&gt;Version&lt;/b&gt;&lt;br&gt;2.0.0 dev&#10; &lt;/p&gt;&#10; &lt;/body&gt;&#10;&lt;/html&gt;&#10;"/>
</properties>
<clientProperties>
<JEditorPane.honorDisplayProperties class="java.lang.Boolean" value="false"/>
<charset class="java.lang.String" value="UTF-8"/>
<html.disable class="java.lang.Boolean" value="false"/>
</clientProperties>
</component>
</children>
</scrollpane>
</children> </children>
</grid> </grid>
</children> </children>

View file

@ -73,7 +73,7 @@ public class Main extends JFrame {
//TODO To be also shown in the about view //TODO To be also shown in the about view
if (currentVersion < latestVersion){ if (currentVersion < latestVersion){
JOptionPane.showMessageDialog(null, "An Update is available!"); JOptionPane.showMessageDialog(null, "An Update is available!\nGo to the 'About' section for more.");
} }
updateDialogButton.addActionListener(new ActionListener() { updateDialogButton.addActionListener(new ActionListener() {

View file

@ -63,6 +63,9 @@ public class DecodeNormalMorseManager {
} }
output.append(" "); output.append(" ");
input.delete(0, 1); input.delete(0, 1);
} else if(input.toString().startsWith(System.lineSeparator())) {
output.append(System.lineSeparator());
input.deleteCharAt(input.indexOf(System.lineSeparator()));
} else if (input.toString().startsWith("A")) { } else if (input.toString().startsWith("A")) {
output.append(".- "); output.append(".- ");
input.delete(0, 1); input.delete(0, 1);

View file

@ -56,7 +56,7 @@ public class DecodeWrittenMorseManager {
} 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 {
for (int c = input.length(); c > 0; c--) { while (input.length() > 0) {
if (input.toString().startsWith(" ")) { if (input.toString().startsWith(" ")) {
if (output.toString().endsWith("#")) { if (output.toString().endsWith("#")) {
@ -64,6 +64,9 @@ public class DecodeWrittenMorseManager {
} }
output.append("+"); output.append("+");
input.delete(0, 1); input.delete(0, 1);
} else if(input.toString().startsWith(System.lineSeparator())) {
output.append(System.lineSeparator());
input.deleteCharAt(input.indexOf(System.lineSeparator()));
} else if (input.toString().startsWith("A")) { } else if (input.toString().startsWith("A")) {
output.append("01#"); output.append("01#");
input.delete(0, 1); input.delete(0, 1);

View file

@ -49,6 +49,9 @@ public class EncodeNormalMorseManager {
if (inputToSign.toString().startsWith(" ")) { if (inputToSign.toString().startsWith(" ")) {
output.append(" "); output.append(" ");
inputToSign.delete(d, d + 7); inputToSign.delete(d, d + 7);
} else if(inputToSign.toString().startsWith(System.lineSeparator())){
output.append(System.lineSeparator());
inputToSign.deleteCharAt(0);
} 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);

View file

@ -46,11 +46,15 @@ public class EncodeWrittenMorseManager {
StringBuffer sign = new StringBuffer(); StringBuffer sign = new StringBuffer();
while (signFull) { while (signFull) {
if (inputToSign.toString().charAt(d) == '+' if (inputToSign.toString().charAt(d) == '+'
|| inputToSign.toString().charAt(d) == '#') { || inputToSign.toString().charAt(d) == '#'
|| inputToSign.toString().startsWith(System.lineSeparator())) {
if (d == 0) { if (d == 0) {
if (inputToSign.toString().startsWith("+")) { if (inputToSign.toString().startsWith("+")) {
output.append(" "); output.append(" ");
} }
if (inputToSign.toString().startsWith(System.lineSeparator())){
output.append(System.lineSeparator());
}
inputToSign.deleteCharAt(0); inputToSign.deleteCharAt(0);
} else { } else {
sign.replace(0, sign.length(), inputToSign sign.replace(0, sign.length(), inputToSign