diff --git a/src/org/nschmidt/ldparteditor/data/GDataCSG.java b/src/org/nschmidt/ldparteditor/data/GDataCSG.java index 2d1fdf976..5b30e24fe 100644 --- a/src/org/nschmidt/ldparteditor/data/GDataCSG.java +++ b/src/org/nschmidt/ldparteditor/data/GDataCSG.java @@ -402,11 +402,11 @@ public String inlinedString(final byte bfc, final GColour colour) { final StringBuilder sb = new StringBuilder(); try { - new ProgressMonitorDialog(Editor3DWindow.getWindow().getShell()).run(true, false, new IRunnableWithProgress() { + new ProgressMonitorDialog(Editor3DWindow.getWindow().getShell()).run(false, false, new IRunnableWithProgress() { @Override public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - + Editor3DWindow.getWindow().getShell().getDisplay().readAndDispatch(); Object[] messageArguments = {getNiceString()}; MessageFormat formatter = new MessageFormat(""); //$NON-NLS-1$ formatter.setLocale(MyLanguage.LOCALE); diff --git a/src/org/nschmidt/ldparteditor/text/StringHelper.java b/src/org/nschmidt/ldparteditor/text/StringHelper.java index dbaa84f10..7bfe8a164 100644 --- a/src/org/nschmidt/ldparteditor/text/StringHelper.java +++ b/src/org/nschmidt/ldparteditor/text/StringHelper.java @@ -16,10 +16,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of package org.nschmidt.ldparteditor.text; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; -import java.util.List; -import java.util.Map; /** * @author nils @@ -90,80 +87,25 @@ public static String getLineDelimiter() { * @param uncompressed * @return */ + // FIXME IMPORTANT: Needs a complete rewrite, due to algrithm errors!!! public static int[] compress(String uncompressed) { - // Build the dictionary. + int[] result2 = new int[uncompressed.length()]; + int i = 0; for (char c : uncompressed.toCharArray()) { - if (!dictSet.contains(c)) { - dictSet.add(c); - dictList.add(c); - } - } - Map dictionary = new HashMap(); - int dictSize = dictList.size(); - for (int i = 0; i < dictSize; i++) { - dictionary.put("" + dictList.get(i), i); //$NON-NLS-1$ - } - String w = ""; //$NON-NLS-1$ - List result = new ArrayList(); - for (char c : uncompressed.toCharArray()) { - String wc = w + c; - if (dictionary.containsKey(wc)) - w = wc; - else { - Integer di = dictionary.get(w); - if (di == null) { - dictionary.put(w, dictSize++); - } - result.add(di); - // Add wc to the dictionary. - dictionary.put(wc, dictSize++); - w = "" + c; //$NON-NLS-1$ - } - } - - // Output the code for w. - if (!w.equals("")) //$NON-NLS-1$ - result.add(dictionary.get(w)); - - int[] result2 = new int[result.size()]; - for (int i = 0; i < result2.length; i++) { - int j = result.get(i); - result2[i] = j; + result2[i] = c; + i++; } return result2; } /** Decompress a list of output ks to a string. */ + // FIXME IMPORTANT: Needs a complete rewrite, due to algrithm errors!!! public static String decompress(int[] compressed) { - // Build the dictionary. - int dictSize = dictList.size(); - Map dictionary = new HashMap(); - for (int i = 0; i < dictSize; i++) { - dictionary.put(i, "" + dictList.get(i)); //$NON-NLS-1$ - } - String w = "" + (char) compressed[0]; //$NON-NLS-1$ - StringBuffer result = new StringBuffer(w); - final int size = compressed.length; - for (int i = 1; i < size; i++) { - int k = compressed[i]; - String entry; - if (dictionary.containsKey(k)) - entry = dictionary.get(k); - else if (k == dictSize) - entry = w + w.charAt(0); - else { - dictionary.put(dictSize++, w); - result.append(w); - continue; + StringBuilder result = new StringBuilder(); + for (int c : compressed) { + for (char ch : Character.toChars(c)) { + result.append(ch); } - - - result.append(entry); - - // Add w+entry[0] to the dictionary. - dictionary.put(dictSize++, w + entry.charAt(0)); - - w = entry; } return result.toString(); }