Timur Sağlam 5 лет назад
Родитель
Сommit
60e49c0b36
27 измененных файлов с 3135 добавлено и 3326 удалено
  1. 70 86
      jplag/src/main/java/jplag/CLI.java
  2. 38 37
      jplag/src/main/java/jplag/ExitException.java
  3. 6 6
      jplag/src/main/java/jplag/GreedyStringTiling.java
  4. 482 522
      jplag/src/main/java/jplag/JPlag.java
  5. 4 4
      jplag/src/main/java/jplag/JPlagBaseCodeComparison.java
  6. 290 290
      jplag/src/main/java/jplag/JPlagComparison.java
  7. 282 285
      jplag/src/main/java/jplag/JPlagOptions.java
  8. 42 43
      jplag/src/main/java/jplag/Match.java
  9. 44 48
      jplag/src/main/java/jplag/Matches.java
  10. 24 24
      jplag/src/main/java/jplag/SortedVector.java
  11. 218 236
      jplag/src/main/java/jplag/Submission.java
  12. 164 172
      jplag/src/main/java/jplag/clustering/Cluster.java
  13. 66 66
      jplag/src/main/java/jplag/clustering/Clusters.java
  14. 52 52
      jplag/src/main/java/jplag/clustering/SimilarityMatrix.java
  15. 4 4
      jplag/src/main/java/jplag/options/ClusterType.java
  16. 35 35
      jplag/src/main/java/jplag/options/LanguageOption.java
  17. 3 3
      jplag/src/main/java/jplag/options/SimilarityMetric.java
  18. 17 12
      jplag/src/main/java/jplag/options/Verbosity.java
  19. 41 42
      jplag/src/main/java/jplag/reporting/BufferedCounter.java
  20. 405 413
      jplag/src/main/java/jplag/reporting/Colors.java
  21. 21 25
      jplag/src/main/java/jplag/reporting/HTMLFile.java
  22. 16 17
      jplag/src/main/java/jplag/reporting/MarkupText.java
  23. 14 14
      jplag/src/main/java/jplag/reporting/Messages.java
  24. 763 855
      jplag/src/main/java/jplag/reporting/Report.java
  25. 28 29
      jplag/src/main/java/jplag/reporting/TagParser.java
  26. 4 4
      jplag/src/main/java/jplag/strategy/ComparisonMode.java
  27. 2 2
      jplag/src/main/java/jplag/strategy/SpecialComparisonStrategy.java

+ 70 - 86
jplag/src/main/java/jplag/CLI.java

@@ -14,91 +14,75 @@ import net.sourceforge.argparse4j.inf.Namespace;
 
 public class CLI {
 
-  public static void main(String[] args) {
-    ArgumentParser parser = ArgumentParsers.newFor("jplag").build()
-        .defaultHelp(true)
-        .description("JPlag - Detecting Software Plagiarism");
-
-    String[] languageOptions = {"java_1_1", "java_1_2", "java_1_5", "java_1_5_dm", "java_1_7", "java_1_9", "python_3", "c_cpp", "c_sharp", "char", "text", "scheme"};
-    String[] verbosityOptions = {"parser", "quiet", "long", "details"};
-
-    parser.addArgument("rootDir")
-        .help("The root-directory that contains all submissions");
-    parser.addArgument("-l")
-        .choices(languageOptions).setDefault("java_1_9")
-        .help("Select the language to parse the submissions");
-    parser.addArgument("-bc")
-        .help("Name of the directory which contains the base code (common framework)");
-    parser.addArgument("-v")
-        .choices(verbosityOptions).setDefault("quiet")
-        .help("Verbosity");
-    parser.addArgument("-d")
-        .help("(Debug) parser. Non-parsable files will be stored")
-        .action(storeTrue());
-    parser.addArgument("-S")
-        .help("Look in directories <root-dir>/*/<dir> for programs");
-    parser.addArgument("-p")
-        .help("comma-separated list of all filename suffixes that are included");
-    parser.addArgument("-x")
-        .help("All files named in <file> will be ignored");
-    parser.addArgument("-t")
-        .help("Tune the sensitivity of the comparison. A smaller <n> increases the sensitivity");
-    parser.addArgument("-s")
-        .help("Similarity Threshold: all matches above this threshold will be saved");
-    parser.addArgument("-r")
-        .setDefault("result")
-        .help("Name of directory in which the web pages will be stored");
-
-    Namespace ns = null;
-
-    try {
-      ns = parser.parseArgs(args);
-    } catch (ArgumentParserException e) {
-      parser.handleError(e);
-      System.exit(1);
+    public static void main(String[] args) {
+        ArgumentParser parser = ArgumentParsers.newFor("jplag").build().defaultHelp(true).description("JPlag - Detecting Software Plagiarism");
+
+        String[] languageOptions = {"java_1_1", "java_1_2", "java_1_5", "java_1_5_dm", "java_1_7", "java_1_9", "python_3", "c_cpp", "c_sharp", "char",
+                "text", "scheme"};
+        String[] verbosityOptions = {"parser", "quiet", "long", "details"};
+
+        parser.addArgument("rootDir").help("The root-directory that contains all submissions");
+        parser.addArgument("-l").choices(languageOptions).setDefault("java_1_9").help("Select the language to parse the submissions");
+        parser.addArgument("-bc").help("Name of the directory which contains the base code (common framework)");
+        parser.addArgument("-v").choices(verbosityOptions).setDefault("quiet").help("Verbosity");
+        parser.addArgument("-d").help("(Debug) parser. Non-parsable files will be stored").action(storeTrue());
+        parser.addArgument("-S").help("Look in directories <root-dir>/*/<dir> for programs");
+        parser.addArgument("-p").help("comma-separated list of all filename suffixes that are included");
+        parser.addArgument("-x").help("All files named in <file> will be ignored");
+        parser.addArgument("-t").help("Tune the sensitivity of the comparison. A smaller <n> increases the sensitivity");
+        parser.addArgument("-s").help("Similarity Threshold: all matches above this threshold will be saved");
+        parser.addArgument("-r").setDefault("result").help("Name of directory in which the web pages will be stored");
+
+        Namespace ns = null;
+
+        try {
+            ns = parser.parseArgs(args);
+        } catch (ArgumentParserException e) {
+            parser.handleError(e);
+            System.exit(1);
+        }
+
+        String rootDir = ns.getString("rootDir");
+        String languageOption = ns.getString("l");
+        String verbosityOption = ns.getString("v");
+        String subDirName = ns.getString("S");
+        String fileSuffixString = ns.getString("p");
+        String[] fileSuffixes = new String[] {};
+        if (fileSuffixString != null) {
+            fileSuffixes = fileSuffixString.replaceAll("\\s+", "").split(",");
+        }
+        String exclusionFile = ns.getString("x");
+        String reportDirName = ns.getString("r");
+        float similarityThreshold = ns.getFloat("s");
+        int minTokenMatch = ns.getInt("t");
+        boolean useDebugParser = ns.getBoolean("d");
+
+        LanguageOption language = LanguageOption.fromOption(languageOption);
+        Verbosity verbosity = Verbosity.fromOption(verbosityOption);
+
+        try {
+            JPlagOptions options = new JPlagOptions(rootDir, language);
+            options.setBaseCodeSubmissionName("base-code");
+            options.setVerbosity(verbosity);
+            options.setDebugParser(useDebugParser);
+            options.setSubdirectoryName(subDirName);
+            options.setFileSuffixes(fileSuffixes);
+            options.setExclusionFileName(exclusionFile);
+            options.setMinTokenMatch(minTokenMatch);
+            options.setSimilarityThreshold(similarityThreshold);
+
+            JPlag program = new JPlag(options);
+
+            System.out.println("JPlag initialized");
+            JPlagResult result = program.run();
+
+            File reportDir = new File(reportDirName);
+            Report report = new Report(reportDir);
+
+            report.writeResult(result);
+        } catch (ExitException ex) {
+            System.out.println("Error: " + ex.getReport());
+            System.exit(1);
+        }
     }
-
-    String rootDir = ns.getString("rootDir");
-    String languageOption = ns.getString("l");
-    String verbosityOption = ns.getString("v");
-    String subDirName = ns.getString("S");
-    String fileSuffixString = ns.getString("p");
-    String[] fileSuffixes = new String[]{};
-    if (fileSuffixString != null) {
-      fileSuffixes = fileSuffixString.replaceAll("\\s+","").split(",");
-    }
-    String exclusionFile = ns.getString("x");
-    String reportDirName = ns.getString("r");
-    float similarityThreshold = ns.getFloat("s");
-    int minTokenMatch = ns.getInt("t");
-    boolean useDebugParser = ns.getBoolean("d");
-
-    LanguageOption language = LanguageOption.fromOption(languageOption);
-    Verbosity verbosity = Verbosity.fromOption(verbosityOption);
-
-    try {
-      JPlagOptions options = new JPlagOptions(rootDir, language);
-      options.setBaseCodeSubmissionName("base-code");
-      options.setVerbosity(verbosity);
-      options.setDebugParser(useDebugParser);
-      options.setSubdirectoryName(subDirName);
-      options.setFileSuffixes(fileSuffixes);
-      options.setExclusionFileName(exclusionFile);
-      options.setMinTokenMatch(minTokenMatch);
-      options.setSimilarityThreshold(similarityThreshold);
-
-      JPlag program = new JPlag(options);
-
-      System.out.println("JPlag initialized");
-      JPlagResult result = program.run();
-
-      File reportDir = new File(reportDirName);
-      Report report = new Report(reportDir);
-
-      report.writeResult(result);
-    } catch (ExitException ex) {
-      System.out.println("Error: " + ex.getReport());
-      System.exit(1);
-    }
-  }
 }

+ 38 - 37
jplag/src/main/java/jplag/ExitException.java

@@ -1,45 +1,46 @@
 package jplag;
 /*
- * Created on 05.03.2005
- * Author Moritz Kroll, Emeric Kwemou
+ * Created on 05.03.2005 Author Moritz Kroll, Emeric Kwemou
  */
 
-
 /**
- * Exception to be reached through to the main caller of JPlag
- * to replace the "exit" method
+ * Exception to be reached through to the main caller of JPlag to replace the "exit" method
  */
-public class ExitException extends Exception
-{
-//	public static final int PACKAGING_RESULTS = 201;
-	public static final int COMPARE_SOURCE_DONE = 300;
-	public static final int UNKNOWN_ERROR_OCCURRED = 400;
-	public static final int BAD_LANGUAGE_ERROR = 401;
-	public static final int NOT_ENOUGH_SUBMISSIONS_ERROR = 402;
-	public static final int BAD_PARAMETER = 403;
-	public static final int BAD_SENSITIVITY_OF_COMPARISON = 404;
-	public static final int SUBMISSION_ABORTED = 405;
+public class ExitException extends Exception {
+    // public static final int PACKAGING_RESULTS = 201;
+    public static final int COMPARE_SOURCE_DONE = 300;
+    public static final int UNKNOWN_ERROR_OCCURRED = 400;
+    public static final int BAD_LANGUAGE_ERROR = 401;
+    public static final int NOT_ENOUGH_SUBMISSIONS_ERROR = 402;
+    public static final int BAD_PARAMETER = 403;
+    public static final int BAD_SENSITIVITY_OF_COMPARISON = 404;
+    public static final int SUBMISSION_ABORTED = 405;
+
+    private static final long serialVersionUID = 1L;
+    private int state = 0;
+    private String report = "";
+
+    public ExitException(String msg) {
+        super(msg);
+        this.state = UNKNOWN_ERROR_OCCURRED;
+        this.report = msg;
+    }
+
+    public ExitException(String msg, int errorcode) {
+        super(msg);
+        this.state = errorcode;
+        this.report = msg;
+    }
+
+    public ExitException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+
+    public int getState() {
+        return this.state;
+    }
 
-	private static final long serialVersionUID = 1L;
-	private int state = 0;
-	private String report ="";
-	
-	public ExitException(String msg) {
-		super(msg);
-		this.state=UNKNOWN_ERROR_OCCURRED;
-		this.report=msg;
-	}
-	
-	public ExitException(String msg, int errorcode) {
-		super(msg);
-		this.state=errorcode;
-		this.report=msg;
-	}
-	
-	public ExitException(String msg, Throwable cause) {
-		super(msg,cause);
-	}
-	
-	public int getState() { return this.state; }
-	public String getReport() { return this.report; }
+    public String getReport() {
+        return this.report;
+    }
 }

+ 6 - 6
jplag/src/main/java/jplag/GreedyStringTiling.java

@@ -3,9 +3,9 @@ package jplag;
 /**
  * This class implements the Greedy String Tiling algorithm as introduced by Michael Wise. However, it is very specific
  * to the classes {@link Structure}, {@link Token}, as well as {@link Matches} and {@link Match}.
- * @see <a href="https://www.researchgate.net/publication/262763983_String_Similarity_via_Greedy_String_Tiling_and_Running_Karp-Rabin_Matching">
- *          String Similarity via Greedy String Tiling and Running Karp−Rabin Matching
- *      </a>
+ * @see <a href=
+ * "https://www.researchgate.net/publication/262763983_String_Similarity_via_Greedy_String_Tiling_and_Running_Karp-Rabin_Matching">
+ * String Similarity via Greedy String Tiling and Running Karp−Rabin Matching </a>
  */
 public class GreedyStringTiling implements TokenConstants {
 
@@ -15,10 +15,10 @@ public class GreedyStringTiling implements TokenConstants {
     public GreedyStringTiling(JPlag program) {
         this.program = program;
     }
-    
+
     /**
-     * Creating hashes in linear time. The hash-code will be written in every Token for the next <hash_length> token (includes the Token
-     * itself).
+     * Creating hashes in linear time. The hash-code will be written in every Token for the next <hash_length> token
+     * (includes the Token itself).
      * @param structure contains the tokens.
      * @param hashLength is the hash length (condition: 1 < hashLength < 26)
      * @param makeTable determines if a simple hash table is created in the structure.

+ 482 - 522
jplag/src/main/java/jplag/JPlag.java

@@ -35,622 +35,582 @@ import jplagUtils.PropertiesLoader;
  */
 public class JPlag implements ProgramI {
 
-  private static final Properties versionProps =
-      PropertiesLoader.loadProps("jplag/version.properties");
-
-  public static final String name =
-      "JPlag" + versionProps.getProperty("version", "devel");
-
-  public static final String name_long =
-      "JPlag (Version " + versionProps.getProperty("version", "devel") + ")";
-
-  /**
-   * This stores the name of the submission that is currently parsed.
-   * <p>
-   * TODO PB: This should be moved to parseSubmissions(...)
-   */
-  public String currentSubmissionName = "<Unknown submission>";
-
-  /**
-   * Vector of errors that occurred during the execution of the program.
-   */
-  public Vector<String> errorVector = new Vector<>();
-
-  /**
-   * Used Objects of anothers jplag.Classes, they muss be just one time instantiate TODO PB: What?
-   */
-  public Clusters clusters = null;
-
-  private int errors = 0;
-
-  private String invalidSubmissionNames = null;
-
-  public Language language;
-
-  public SimilarityMatrix similarity = null;
-
-  /**
-   * The base code directory is considered a separate submission.
-   */
-  private Submission baseCodeSubmission = null;
-
-  /**
-   * Comparison strategy to use.
-   */
-  public ComparisonStrategy comparisonStrategy;
-
-  /**
-   * Set of file names to be excluded in comparison.
-   */
-  private HashSet<String> excludedFileNames = null;
-
-  /**
-   * Contains the comparison logic.
-   */
-  protected GreedyStringTiling gSTiling = new GreedyStringTiling(this);
-
-  /**
-   * JPlag configuration options.
-   */
-  private final JPlagOptions options;
-
-  /**
-   * File writer.
-   */
-  private FileWriter writer = null;
-
-  /**
-   * Creates and initializes a JPlag instance, parameterized by a set of options.
-   * @param options determines the parameterization.
-   * @throws ExitException if the initialization fails.
-   */
-  public JPlag(JPlagOptions options) throws ExitException {
-    this.options = options;
-    this.initialize();
-  }
-
-  public void initialize() throws ExitException {
-    this.initializeLanguage();
-    this.initializeComparisonStrategy();
-    this.checkBaseCodeOption();
-  }
-
-  public void initializeComparisonStrategy() throws ExitException {
-    ComparisonMode mode = options.getComparisonMode();
-
-    switch (mode) {
-      case NORMAL:
-        this.comparisonStrategy = new NormalComparisonStrategy(options, gSTiling);
-        return;
-      case REVISION:
-        this.comparisonStrategy = new RevisionComparisonStrategy(options, gSTiling);
-        return;
-      case SPECIAL:
-        this.comparisonStrategy = new SpecialComparisonStrategy(options, gSTiling);
-        return;
-      case EXTERNAL:
-        this.comparisonStrategy = new ExternalComparisonStrategy(options, gSTiling);
-        return;
-      default:
-        throw new ExitException("Illegal comparison mode: " + options.getComparisonMode());
+    private static final Properties versionProps = PropertiesLoader.loadProps("jplag/version.properties");
+
+    public static final String name = "JPlag" + versionProps.getProperty("version", "devel");
+
+    public static final String name_long = "JPlag (Version " + versionProps.getProperty("version", "devel") + ")";
+
+    /**
+     * This stores the name of the submission that is currently parsed.
+     * <p>
+     * TODO PB: This should be moved to parseSubmissions(...)
+     */
+    public String currentSubmissionName = "<Unknown submission>";
+
+    /**
+     * Vector of errors that occurred during the execution of the program.
+     */
+    public Vector<String> errorVector = new Vector<>();
+
+    /**
+     * Used Objects of anothers jplag.Classes, they muss be just one time instantiate TODO PB: What?
+     */
+    public Clusters clusters = null;
+
+    private int errors = 0;
+
+    private String invalidSubmissionNames = null;
+
+    public Language language;
+
+    public SimilarityMatrix similarity = null;
+
+    /**
+     * The base code directory is considered a separate submission.
+     */
+    private Submission baseCodeSubmission = null;
+
+    /**
+     * Comparison strategy to use.
+     */
+    public ComparisonStrategy comparisonStrategy;
+
+    /**
+     * Set of file names to be excluded in comparison.
+     */
+    private HashSet<String> excludedFileNames = null;
+
+    /**
+     * Contains the comparison logic.
+     */
+    protected GreedyStringTiling gSTiling = new GreedyStringTiling(this);
+
+    /**
+     * JPlag configuration options.
+     */
+    private final JPlagOptions options;
+
+    /**
+     * File writer.
+     */
+    private FileWriter writer = null;
+
+    /**
+     * Creates and initializes a JPlag instance, parameterized by a set of options.
+     * @param options determines the parameterization.
+     * @throws ExitException if the initialization fails.
+     */
+    public JPlag(JPlagOptions options) throws ExitException {
+        this.options = options;
+        this.initialize();
+    }
+
+    public void initialize() throws ExitException {
+        this.initializeLanguage();
+        this.initializeComparisonStrategy();
+        this.checkBaseCodeOption();
+    }
+
+    public void initializeComparisonStrategy() throws ExitException {
+        ComparisonMode mode = options.getComparisonMode();
+
+        switch (mode) {
+        case NORMAL:
+            this.comparisonStrategy = new NormalComparisonStrategy(options, gSTiling);
+            return;
+        case REVISION:
+            this.comparisonStrategy = new RevisionComparisonStrategy(options, gSTiling);
+            return;
+        case SPECIAL:
+            this.comparisonStrategy = new SpecialComparisonStrategy(options, gSTiling);
+            return;
+        case EXTERNAL:
+            this.comparisonStrategy = new ExternalComparisonStrategy(options, gSTiling);
+            return;
+        default:
+            throw new ExitException("Illegal comparison mode: " + options.getComparisonMode());
+        }
     }
-  }
 
-  public void initializeLanguage() throws ExitException {
-    LanguageOption languageOption = this.options.getLanguageOption();
+    public void initializeLanguage() throws ExitException {
+        LanguageOption languageOption = this.options.getLanguageOption();
+
+        try {
+            Constructor<?> constructor = Class.forName(languageOption.getClassPath()).getConstructor(ProgramI.class);
+            Object[] constructorParams = {this};
 
-    try {
-      Constructor<?> constructor = Class.forName(languageOption.getClassPath()).getConstructor(ProgramI.class);
-      Object[] constructorParams = {this};
+            Language language = (Language) constructor.newInstance(constructorParams);
 
-      Language language = (Language) constructor.newInstance(constructorParams);
+            this.language = language;
+            this.options.setLanguage(language);
+        } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | InstantiationException | IllegalAccessException
+                | IllegalArgumentException | InvocationTargetException e) {
+            e.printStackTrace();
 
-      this.language = language;
-      this.options.setLanguage(language);
-    } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | InstantiationException | IllegalAccessException
-            | IllegalArgumentException | InvocationTargetException e) {
-      e.printStackTrace();
+            throw new ExitException("Language instantiation failed", ExitException.BAD_LANGUAGE_ERROR);
+        }
 
-      throw new ExitException("Language instantiation failed", ExitException.BAD_LANGUAGE_ERROR);
+        this.options.setLanguageDefaults(this.language);
+
+        System.out.println("Initialized language " + this.language.name());
     }
 
-    this.options.setLanguageDefaults(this.language);
+    /**
+     * This method checks whether the base code directory value is valid.
+     */
+    private void checkBaseCodeOption() throws ExitException {
+        if (!this.options.hasBaseCode()) {
+            return;
+        }
+
+        String baseCodePath = this.options.getRootDirName() + File.separator + this.options.getBaseCodeSubmissionName();
 
-    System.out.println("Initialized language " + this.language.name());
-  }
+        if (!(new File(this.options.getRootDirName())).exists()) {
+            throw new ExitException("Root directory \"" + this.options.getRootDirName() + "\" doesn't exist!", ExitException.BAD_PARAMETER);
+        }
 
-  /**
-   * This method checks whether the base code directory value is valid.
-   */
-  private void checkBaseCodeOption() throws ExitException {
-    if (!this.options.hasBaseCode()) {
-      return;
-    }
+        File f = new File(baseCodePath);
 
-    String baseCodePath =
-        this.options.getRootDirName() + File.separator + this.options.getBaseCodeSubmissionName();
+        if (!f.exists()) {
+            // Base code dir doesn't exist
+            throw new ExitException("Basecode directory \"" + baseCodePath + "\" doesn't exist!", ExitException.BAD_PARAMETER);
+        }
 
-    if (!(new File(this.options.getRootDirName())).exists()) {
-      throw new ExitException(
-          "Root directory \"" + this.options.getRootDirName() + "\" doesn't exist!",
-          ExitException.BAD_PARAMETER
-      );
-    }
+        if (this.options.getSubdirectoryName() != null && this.options.getSubdirectoryName().length() != 0) {
+            f = new File(baseCodePath, this.options.getSubdirectoryName());
 
-    File f = new File(baseCodePath);
+            if (!f.exists()) {
+                throw new ExitException("Basecode directory doesn't contain" + " the subdirectory \"" + this.options.getSubdirectoryName() + "\"!",
+                        ExitException.BAD_PARAMETER);
+            }
+        }
 
-    if (!f.exists()) {
-      // Base code dir doesn't exist
-      throw new ExitException("Basecode directory \"" + baseCodePath
-          + "\" doesn't exist!", ExitException.BAD_PARAMETER);
+        System.out.println("Basecode directory \"" + baseCodePath + "\" will be used");
     }
 
-    if (this.options.getSubdirectoryName() != null
-        && this.options.getSubdirectoryName().length() != 0) {
-      f = new File(baseCodePath, this.options.getSubdirectoryName());
-
-      if (!f.exists()) {
-        throw new ExitException(
-            "Basecode directory doesn't contain" + " the subdirectory \"" + this.options
-                .getSubdirectoryName() + "\"!",
-            ExitException.BAD_PARAMETER
-        );
-      }
+    public JPlagOptions getOptions() {
+        return this.options;
     }
 
-    System.out.println("Basecode directory \"" + baseCodePath + "\" will be used");
-  }
+    /**
+     * Main procedure, executes the comparison of source code submissions.
+     * @return the results of the comparison, specifically the submissions whose similarity exceeds a set threshold.
+     * @throws ExitException if the JPlag exits preemptively.
+     */
+    public JPlagResult run() throws ExitException {
+        File rootDir = new File(options.getRootDirName());
 
-  public JPlagOptions getOptions() {
-    return this.options;
-  }
+        if (!rootDir.exists()) {
+            throw new ExitException("Root directory " + options.getRootDirName() + " does not exist!");
+        }
 
-  /**
-   * Main procedure, executes the comparison of source code submissions.
-   * @return the results of the comparison, specifically the submissions whose similarity exceeds a set threshold.
-   * @throws ExitException if the JPlag exits preemptively.
-   */
-  public JPlagResult run() throws ExitException {
-    File rootDir = new File(options.getRootDirName());
+        if (!rootDir.isDirectory()) {
+            throw new ExitException(options.getRootDirName() + " is not a directory!");
+        }
 
-    if (!rootDir.exists()) {
-      throw new ExitException("Root directory " + options.getRootDirName() + " does not exist!");
-    }
+        // This file contains all files names which are excluded
+        readExclusionFile();
 
-    if (!rootDir.isDirectory()) {
-      throw new ExitException(options.getRootDirName() + " is not a directory!");
-    }
+        Vector<Submission> submissions = findSubmissions(rootDir);
+        parseAllSubmissions(submissions, baseCodeSubmission);
+        submissions = filterValidSubmissions(submissions);
 
-    // This file contains all files names which are excluded
-    readExclusionFile();
+        if (submissions.size() < 2) {
+            printErrors();
+            throw new ExitException("Not enough valid submissions! (found " + submissions.size() + " valid submissions)",
+                    ExitException.NOT_ENOUGH_SUBMISSIONS_ERROR);
+        }
 
-    Vector<Submission> submissions = findSubmissions(rootDir);
-    parseAllSubmissions(submissions, baseCodeSubmission);
-    submissions = filterValidSubmissions(submissions);
+        // errorVector is not needed anymore
+        errorVector = null;
 
-    if (submissions.size() < 2) {
-      printErrors();
-      throw new ExitException(
-          "Not enough valid submissions! (found " + submissions.size() + " valid submissions)",
-          ExitException.NOT_ENOUGH_SUBMISSIONS_ERROR
-      );
-    }
+        if (options.getClusterType() != ClusterType.NONE) {
+            clusters = new Clusters(this);
+            similarity = new SimilarityMatrix(submissions.size());
+        }
+
+        System.gc();
+
+        JPlagResult result = comparisonStrategy.compareSubmissions(submissions, baseCodeSubmission);
 
-    // errorVector is not needed anymore
-    errorVector = null;
+        closeWriter();
 
-    if (options.getClusterType() != ClusterType.NONE) {
-      clusters = new Clusters(this);
-      similarity = new SimilarityMatrix(submissions.size());
+        return result;
     }
 
-    System.gc();
-
-    JPlagResult result = comparisonStrategy.compareSubmissions(submissions, baseCodeSubmission);
-
-    closeWriter();
-
-    return result;
-  }
-
-  private Vector<Submission> filterValidSubmissions(Vector<Submission> submissions) {
-    return submissions.stream()
-        .filter(submission -> !submission.hasErrors)
-        .collect(Collectors.toCollection(Vector::new));
-  }
-
-  /**
-   * TODO PB: Find a better way to separate parseSubmissions(...) and parseBaseCodeSubmission(...)
-   */
-  public void parseAllSubmissions(Vector<Submission> submissions, Submission baseCodeSubmission)
-      throws ExitException {
-    try {
-      parseSubmissions(submissions);
-      System.gc();
-      parseBaseCodeSubmission(baseCodeSubmission);
-    } catch (OutOfMemoryError e) {
-      System.gc();
-
-      throw new ExitException(
-          "Out of memory during parsing of submission \"" + currentSubmissionName + "\"");
-    } catch (Throwable e) {
-      e.printStackTrace();
-
-      throw new ExitException(
-          "Unknown exception during parsing of " + "submission \"" + currentSubmissionName
-              + "\"");
+    private Vector<Submission> filterValidSubmissions(Vector<Submission> submissions) {
+        return submissions.stream().filter(submission -> !submission.hasErrors).collect(Collectors.toCollection(Vector::new));
     }
-  }
 
-  public boolean hasValidSuffix(File file) {
-    String[] validSuffixes = options.getFileSuffixes();
+    /**
+     * TODO PB: Find a better way to separate parseSubmissions(...) and parseBaseCodeSubmission(...)
+     */
+    public void parseAllSubmissions(Vector<Submission> submissions, Submission baseCodeSubmission) throws ExitException {
+        try {
+            parseSubmissions(submissions);
+            System.gc();
+            parseBaseCodeSubmission(baseCodeSubmission);
+        } catch (OutOfMemoryError e) {
+            System.gc();
 
-    if (validSuffixes == null || validSuffixes.length == 0) {
-      return true;
+            throw new ExitException("Out of memory during parsing of submission \"" + currentSubmissionName + "\"");
+        } catch (Throwable e) {
+            e.printStackTrace();
+
+            throw new ExitException("Unknown exception during parsing of " + "submission \"" + currentSubmissionName + "\"");
+        }
     }
 
-    boolean hasValidSuffix = false;
-    String fileName = file.getName();
+    public boolean hasValidSuffix(File file) {
+        String[] validSuffixes = options.getFileSuffixes();
 
-    for (String validSuffix : validSuffixes) {
-      if (fileName.endsWith(validSuffix)) {
-        hasValidSuffix = true;
-        break;
-      }
-    }
+        if (validSuffixes == null || validSuffixes.length == 0) {
+            return true;
+        }
 
-    return hasValidSuffix;
-  }
+        boolean hasValidSuffix = false;
+        String fileName = file.getName();
 
-  /**
-   * Find all submissions in the given root directory.
-   */
-  private Vector<Submission> findSubmissions(File rootDir) throws ExitException {
-    String[] fileNamesInRootDir = getSortedFileNamesInRootDir(rootDir);
-    return mapFileNamesInRootDirToSubmissions(fileNamesInRootDir, rootDir);
-  }
+        for (String validSuffix : validSuffixes) {
+            if (fileName.endsWith(validSuffix)) {
+                hasValidSuffix = true;
+                break;
+            }
+        }
 
-  private String[] getSortedFileNamesInRootDir(File rootDir) throws ExitException {
-    String[] fileNamesInRootDir;
+        return hasValidSuffix;
+    }
 
-    try {
-      fileNamesInRootDir = rootDir.list();
-    } catch (SecurityException e) {
-      throw new ExitException("Cannot list files of the root directory! " + e.getMessage());
+    /**
+     * Find all submissions in the given root directory.
+     */
+    private Vector<Submission> findSubmissions(File rootDir) throws ExitException {
+        String[] fileNamesInRootDir = getSortedFileNamesInRootDir(rootDir);
+        return mapFileNamesInRootDirToSubmissions(fileNamesInRootDir, rootDir);
     }
 
-    if (fileNamesInRootDir == null) {
-      throw new ExitException("Cannot list files of the root directory! " +
-          "Make sure the specified root directory is in fact a directory.");
+    private String[] getSortedFileNamesInRootDir(File rootDir) throws ExitException {
+        String[] fileNamesInRootDir;
+
+        try {
+            fileNamesInRootDir = rootDir.list();
+        } catch (SecurityException e) {
+            throw new ExitException("Cannot list files of the root directory! " + e.getMessage());
+        }
+
+        if (fileNamesInRootDir == null) {
+            throw new ExitException("Cannot list files of the root directory! " + "Make sure the specified root directory is in fact a directory.");
+        }
+
+        Arrays.sort(fileNamesInRootDir);
+
+        return fileNamesInRootDir;
     }
 
-    Arrays.sort(fileNamesInRootDir);
+    private Vector<Submission> mapFileNamesInRootDirToSubmissions(String[] fileNames, File rootDir) throws ExitException {
+        Vector<Submission> submissions = new Vector<>();
 
-    return fileNamesInRootDir;
-  }
+        for (String fileName : fileNames) {
+            File submissionFile = new File(rootDir, fileName);
 
-  private Vector<Submission> mapFileNamesInRootDirToSubmissions(String[] fileNames, File rootDir)
-      throws ExitException {
-    Vector<Submission> submissions = new Vector<>();
+            if (isFileExcluded(submissionFile)) {
+                System.out.println("Exclude submission: " + submissionFile.getName());
+                continue;
+            }
 
-    for (String fileName : fileNames) {
-      File submissionFile = new File(rootDir, fileName);
+            if (submissionFile.isFile() && !hasValidSuffix(submissionFile)) {
+                System.out.println("Ignore submission with invalid suffix: " + submissionFile.getName());
+                continue;
+            }
 
-      if (isFileExcluded(submissionFile)) {
-        System.out.println("Exclude submission: " + submissionFile.getName());
-        continue;
-      }
+            if (submissionFile.isDirectory() && options.getSubdirectoryName() != null) {
+                // Use subdirectory instead
+                submissionFile = new File(submissionFile, options.getSubdirectoryName());
 
-      if (submissionFile.isFile() && !hasValidSuffix(submissionFile)) {
-        System.out.println("Ignore submission with invalid suffix: " + submissionFile.getName());
-        continue;
-      }
+                if (!submissionFile.exists()) {
+                    throw new ExitException(
+                            String.format("Submission %s does not contain the given subdirectory '%s'", fileName, options.getSubdirectoryName()));
+                }
 
-      if (submissionFile.isDirectory() && options.getSubdirectoryName() != null) {
-        // Use subdirectory instead
-        submissionFile = new File(submissionFile, options.getSubdirectoryName());
+                if (!submissionFile.isDirectory()) {
+                    throw new ExitException(String.format("The given subdirectory '%s' is not a directory!", options.getSubdirectoryName()));
+                }
+            }
 
-        if (!submissionFile.exists()) {
-          throw new ExitException(
-              String.format(
-                  "Submission %s does not contain the given subdirectory '%s'",
-                  fileName,
-                  options.getSubdirectoryName()
-              )
-          );
-        }
+            Submission submission = new Submission(fileName, submissionFile, this);
 
-        if (!submissionFile.isDirectory()) {
-          throw new ExitException(
-              String.format(
-                  "The given subdirectory '%s' is not a directory!",
-                  options.getSubdirectoryName()
-              )
-          );
+            if (options.hasBaseCode() && options.getBaseCodeSubmissionName().equals(fileName)) {
+                baseCodeSubmission = submission;
+            } else {
+                submissions.addElement(submission);
+            }
         }
-      }
 
-      Submission submission = new Submission(fileName, submissionFile, this);
-
-      if (options.hasBaseCode() && options.getBaseCodeSubmissionName().equals(fileName)) {
-        baseCodeSubmission = submission;
-      } else {
-        submissions.addElement(submission);
-      }
+        return submissions;
     }
 
-    return submissions;
-  }
+    /**
+     * Check if a file is excluded or not.
+     */
+    protected boolean isFileExcluded(File file) {
+        if (excludedFileNames == null) {
+            return false;
+        }
 
-  /**
-   * Check if a file is excluded or not.
-   */
-  protected boolean isFileExcluded(File file) {
-    if (excludedFileNames == null) {
-      return false;
-    }
+        String fileName = file.getName();
 
-    String fileName = file.getName();
+        for (String s : excludedFileNames) {
+            if (fileName.endsWith(s)) {
+                return true;
+            }
+        }
 
-    for (String s : excludedFileNames) {
-      if (fileName.endsWith(s)) {
-        return true;
-      }
+        return false;
     }
 
-    return false;
-  }
+    /**
+     * Parse all given submissions.
+     */
+    private void parseSubmissions(Vector<Submission> submissions) throws ExitException {
+        if (submissions == null) {
+            System.out.println("Nothing to parse!");
+            return;
+        }
 
-  /**
-   * Parse all given submissions.
-   */
-  private void parseSubmissions(Vector<Submission> submissions) throws ExitException {
-    if (submissions == null) {
-      System.out.println("Nothing to parse!");
-      return;
-    }
+        int count = 0;
 
-    int count = 0;
+        long msec = System.currentTimeMillis();
+        Iterator<Submission> iter = submissions.iterator();
 
-    long msec = System.currentTimeMillis();
-    Iterator<Submission> iter = submissions.iterator();
+        if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
+            makeTempDir();
+        }
 
-    if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
-      makeTempDir();
-    }
+        int invalid = 0;
+        while (iter.hasNext()) {
+            boolean ok;
+            boolean removed = false;
+            Submission subm = iter.next();
+
+            print(null, "------ Parsing submission: " + subm.name + "\n");
+            currentSubmissionName = subm.name;
+
+            if (!(ok = subm.parse())) {
+                errors++;
+            }
+
+            count++;
+
+            if (subm.tokenList != null && subm.getNumberOfTokens() < options.getMinTokenMatch()) {
+                print(null, "Submission contains fewer tokens than minimum match " + "length allows!\n");
+                subm.tokenList = null;
+                invalid++;
+                removed = true;
+            }
+
+            if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
+                if (subm.tokenList != null) {
+                    this.gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), false);
+                    subm.tokenList.save(new File("temp", subm.submissionFile.getName() + subm.name));
+                    subm.tokenList = null;
+                }
+            }
+
+            if (options.getComparisonMode() != ComparisonMode.EXTERNAL && subm.tokenList == null) {
+                invalidSubmissionNames = (invalidSubmissionNames == null) ? subm.name : invalidSubmissionNames + " - " + subm.name;
+                iter.remove();
+            }
+
+            if (ok && !removed) {
+                print(null, "OK\n");
+            } else {
+                print(null, "ERROR -> Submission removed\n");
+            }
+        }
 
-    int invalid = 0;
-    while (iter.hasNext()) {
-      boolean ok;
-      boolean removed = false;
-      Submission subm = iter.next();
-
-      print(null, "------ Parsing submission: " + subm.name + "\n");
-      currentSubmissionName = subm.name;
-
-      if (!(ok = subm.parse())) {
-        errors++;
-      }
-
-      count++;
-
-      if (subm.tokenList != null && subm.getNumberOfTokens() < options.getMinTokenMatch()) {
-        print(null, "Submission contains fewer tokens than minimum match " + "length allows!\n");
-        subm.tokenList = null;
-        invalid++;
-        removed = true;
-      }
-
-      if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
-        if (subm.tokenList != null) {
-          this.gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), false);
-          subm.tokenList.save(new File("temp", subm.submissionFile.getName() + subm.name));
-          subm.tokenList = null;
-        }
-      }
-
-      if (options.getComparisonMode() != ComparisonMode.EXTERNAL && subm.tokenList == null) {
-        invalidSubmissionNames = (invalidSubmissionNames == null) ? subm.name
-            : invalidSubmissionNames + " - " + subm.name;
-        iter.remove();
-      }
-
-      if (ok && !removed) {
-        print(null, "OK\n");
-      } else {
-        print(null, "ERROR -> Submission removed\n");
-      }
-    }
+        print("\n" + (count - errors - invalid) + " submissions parsed successfully!\n" + errors + " parser error" + (errors != 1 ? "s!\n" : "!\n"),
+                null);
 
-    print("\n" + (count - errors - invalid) + " submissions parsed successfully!\n" + errors
-        + " parser error"
-        + (errors != 1 ? "s!\n" : "!\n"), null);
+        if (invalid != 0) {
+            print(null,
+                    invalid + ((invalid == 1) ? " submission is not valid because it contains" : " submissions are not valid because they contain")
+                            + " fewer tokens\nthan minimum match length allows.\n");
+        }
 
-    if (invalid != 0) {
-      print(null, invalid
-          + ((invalid == 1) ? " submission is not valid because it contains"
-          : " submissions are not valid because they contain")
-          + " fewer tokens\nthan minimum match length allows.\n");
-    }
+        long time = System.currentTimeMillis() - msec;
 
-    long time = System.currentTimeMillis() - msec;
-
-    print("\n\n",
-        "\nTotal time for parsing: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "")
-            + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60)
-            + " sec\n"
-            + "Time per parsed submission: " + (count > 0 ? (time / count) : "n/a") + " msec\n\n");
-  }
-
-  /**
-   * Parse the given base code submission.
-   */
-  private void parseBaseCodeSubmission(Submission subm) throws ExitException {
-    if (subm == null) {
-      // TODO:
-      // options.useBasecode = false;
-      return;
+        print("\n\n",
+                "\nTotal time for parsing: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "")
+                        + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60) + " sec\n"
+                        + "Time per parsed submission: " + (count > 0 ? (time / count) : "n/a") + " msec\n\n");
     }
 
-    long msec = System.currentTimeMillis();
-    print("----- Parsing basecode submission: " + subm.name + "\n", null);
+    /**
+     * Parse the given base code submission.
+     */
+    private void parseBaseCodeSubmission(Submission subm) throws ExitException {
+        if (subm == null) {
+            // TODO:
+            // options.useBasecode = false;
+            return;
+        }
 
-    // lets go:
-    if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
-      makeTempDir();
-    }
+        long msec = System.currentTimeMillis();
+        print("----- Parsing basecode submission: " + subm.name + "\n", null);
 
-    if (!subm.parse()) {
-      printErrors();
-      throw new ExitException("Bad basecode submission");
-    }
+        // lets go:
+        if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
+            makeTempDir();
+        }
 
-    if (subm.tokenList != null && subm.getNumberOfTokens() < options.getMinTokenMatch()) {
-      throw new ExitException(
-          "Basecode submission contains fewer tokens " + "than minimum match length allows!\n");
-    }
+        if (!subm.parse()) {
+            printErrors();
+            throw new ExitException("Bad basecode submission");
+        }
 
-    if (options.hasBaseCode()) {
-      gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), true);
-    }
+        if (subm.tokenList != null && subm.getNumberOfTokens() < options.getMinTokenMatch()) {
+            throw new ExitException("Basecode submission contains fewer tokens " + "than minimum match length allows!\n");
+        }
 
-    if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
-      if (subm.tokenList != null) {
-        gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), false);
-        subm.tokenList.save(new File("temp", subm.submissionFile.getName() + subm.name));
-        subm.tokenList = null;
-      }
-    }
+        if (options.hasBaseCode()) {
+            gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), true);
+        }
 
-    print("\nBasecode submission parsed!\n", null);
+        if (options.getComparisonMode() == ComparisonMode.EXTERNAL) {
+            if (subm.tokenList != null) {
+                gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), false);
+                subm.tokenList.save(new File("temp", subm.submissionFile.getName() + subm.name));
+                subm.tokenList = null;
+            }
+        }
 
-    long time = System.currentTimeMillis() - msec;
+        print("\nBasecode submission parsed!\n", null);
 
-    print("\n",
-        "\nTime for parsing Basecode: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "")
-            + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60)
-            + " sec\n");
-  }
+        long time = System.currentTimeMillis() - msec;
 
-  /*
-   * If an exclusion file is given, it is read in and all stings are saved in
-   * the set "excluded".
-   */
-  private void readExclusionFile() {
-    if (options.getExclusionFileName() == null) {
-      return;
+        print("\n", "\nTime for parsing Basecode: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "")
+                + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60) + " sec\n");
     }
 
-    excludedFileNames = new HashSet<>();
+    /*
+     * If an exclusion file is given, it is read in and all stings are saved in the set "excluded".
+     */
+    private void readExclusionFile() {
+        if (options.getExclusionFileName() == null) {
+            return;
+        }
 
-    try {
-      BufferedReader in = new BufferedReader(new FileReader(options.getExclusionFileName()));
-      String line;
+        excludedFileNames = new HashSet<>();
 
-      while ((line = in.readLine()) != null) {
-        excludedFileNames.add(line.trim());
-      }
+        try {
+            BufferedReader in = new BufferedReader(new FileReader(options.getExclusionFileName()));
+            String line;
 
-      in.close();
-    } catch (IOException e) {
-      System.out.println("Could not read exclusion file: " + options.getExclusionFileName());
-    }
+            while ((line = in.readLine()) != null) {
+                excludedFileNames.add(line.trim());
+            }
 
-    if (options.getVerbosity() == LONG) {
-      print(null, "Excluded files:\n");
+            in.close();
+        } catch (IOException e) {
+            System.out.println("Could not read exclusion file: " + options.getExclusionFileName());
+        }
 
-      for (String excludedFileName : excludedFileNames) {
-        print(null, "  " + excludedFileName + "\n");
-      }
-    }
-  }
-
-  private void makeTempDir() throws ExitException {
-    print(null, "Creating temporary dir.\n");
-    File f = new File("temp");
-    if (!f.exists()) {
-      if (!f.mkdirs()) {
-        throw new jplag.ExitException("Cannot create temporary directory!");
-      }
-    }
-    if (!f.isDirectory()) {
-      throw new ExitException("'temp' is not a directory!");
-    }
-    if (!f.canWrite()) {
-      throw new ExitException("Cannot write directory: 'temp'");
+        if (options.getVerbosity() == LONG) {
+            print(null, "Excluded files:\n");
+
+            for (String excludedFileName : excludedFileNames) {
+                print(null, "  " + excludedFileName + "\n");
+            }
+        }
     }
-  }
-
-  private void myWrite(String str) {
-    if (writer != null) {
-      try {
-        writer.write(str);
-      } catch (IOException e) {
-        e.printStackTrace();
-      }
-    } else {
-      System.out.print(str);
+
+    private void makeTempDir() throws ExitException {
+        print(null, "Creating temporary dir.\n");
+        File f = new File("temp");
+        if (!f.exists()) {
+            if (!f.mkdirs()) {
+                throw new jplag.ExitException("Cannot create temporary directory!");
+            }
+        }
+        if (!f.isDirectory()) {
+            throw new ExitException("'temp' is not a directory!");
+        }
+        if (!f.canWrite()) {
+            throw new ExitException("Cannot write directory: 'temp'");
+        }
     }
-  }
-
-  public void closeWriter() {
-    try {
-      if (writer != null) {
-        writer.close();
-      }
-    } catch (IOException ex) {
-      ex.printStackTrace();
+
+    private void myWrite(String str) {
+        if (writer != null) {
+            try {
+                writer.write(str);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        } else {
+            System.out.print(str);
+        }
     }
-    writer = null;
-  }
-
-  /**
-   * Add an error to the errorVector.
-   */
-  @Override
-public void addError(String errorMsg) {
-    errorVector.add("[" + currentSubmissionName + "]\n" + errorMsg);
-    print(errorMsg, null);
-  }
-
-  /**
-   * Print all errors from the errorVector.
-   */
-  private void printErrors() {
-    StringBuilder errorStr = new StringBuilder();
-
-    for (String str : errorVector) {
-      errorStr.append(str);
-      errorStr.append('\n');
+
+    public void closeWriter() {
+        try {
+            if (writer != null) {
+                writer.close();
+            }
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+        writer = null;
     }
 
-    System.out.println(errorStr.toString());
-  }
-
-  @Override
-public void print(String normal, String lng) {
-    if (options.getVerbosity() == PARSER) {
-      if (lng != null) {
-        myWrite(lng);
-      } else if (normal != null) {
-        myWrite(normal);
-      }
+    /**
+     * Add an error to the errorVector.
+     */
+    @Override
+    public void addError(String errorMsg) {
+        errorVector.add("[" + currentSubmissionName + "]\n" + errorMsg);
+        print(errorMsg, null);
     }
-    if (options.getVerbosity() == QUIET) {
-      return;
+
+    /**
+     * Print all errors from the errorVector.
+     */
+    private void printErrors() {
+        StringBuilder errorStr = new StringBuilder();
+
+        for (String str : errorVector) {
+            errorStr.append(str);
+            errorStr.append('\n');
+        }
+
+        System.out.println(errorStr.toString());
     }
-    try {
-      if (normal != null) {
-        System.out.print(normal);
-      }
 
-      if (lng != null) {
-        if (options.getVerbosity() == LONG) {
-          System.out.print(lng);
+    @Override
+    public void print(String normal, String lng) {
+        if (options.getVerbosity() == PARSER) {
+            if (lng != null) {
+                myWrite(lng);
+            } else if (normal != null) {
+                myWrite(normal);
+            }
+        }
+        if (options.getVerbosity() == QUIET) {
+            return;
+        }
+        try {
+            if (normal != null) {
+                System.out.print(normal);
+            }
+
+            if (lng != null) {
+                if (options.getVerbosity() == LONG) {
+                    System.out.print(lng);
+                }
+            }
+        } catch (Throwable e) {
+            System.out.println(e.getMessage());
         }
-      }
-    } catch (Throwable e) {
-      System.out.println(e.getMessage());
     }
-  }
 }

+ 4 - 4
jplag/src/main/java/jplag/JPlagBaseCodeComparison.java

@@ -4,9 +4,9 @@ package jplag;
  * @author Michael Cocheteau
  */
 public class JPlagBaseCodeComparison extends JPlagComparison {
-	
-	public JPlagBaseCodeComparison(Submission firstSubmission, Submission secondSubmission) {
-		super(firstSubmission, secondSubmission);
-	}
+
+    public JPlagBaseCodeComparison(Submission firstSubmission, Submission secondSubmission) {
+        super(firstSubmission, secondSubmission);
+    }
 
 }

+ 290 - 290
jplag/src/main/java/jplag/JPlagComparison.java

@@ -10,355 +10,355 @@ import java.util.List;
  */
 public class JPlagComparison implements Comparator<JPlagComparison> {
 
-  public Submission firstSubmission;
-  public Submission secondSubmission;
+    public Submission firstSubmission;
+    public Submission secondSubmission;
 
-  public JPlagBaseCodeComparison bcMatchesA = null;
-  public JPlagBaseCodeComparison bcMatchesB = null;
+    public JPlagBaseCodeComparison bcMatchesA = null;
+    public JPlagBaseCodeComparison bcMatchesB = null;
 
-  public List<Match> matches = new ArrayList<>();
+    public List<Match> matches = new ArrayList<>();
 
-  public JPlagComparison(Submission firstSubmission, Submission secondSubmission) {
-    this.firstSubmission = firstSubmission;
-    this.secondSubmission = secondSubmission;
-  }
-
-  public final void addMatch(int startA, int startB, int length) {
-    for (Match match : matches) {
-      if (match.overlap(startA, startB, length)) {
-        return;
-      }
+    public JPlagComparison(Submission firstSubmission, Submission secondSubmission) {
+        this.firstSubmission = firstSubmission;
+        this.secondSubmission = secondSubmission;
     }
 
-    matches.add(new Match(startA, startB, length));
-  }
-
-  /* s==0 uses the start indexes of subA as key for the sorting algorithm.
-   * Otherwise the start indexes of subB are used. */
-  public final int[] sort_permutation(int s) {   // bubblesort!!!
-    int size = matches.size();
-    int[] perm = new int[size];
-    int i, j, tmp;
+    public final void addMatch(int startA, int startB, int length) {
+        for (Match match : matches) {
+            if (match.overlap(startA, startB, length)) {
+                return;
+            }
+        }
 
-    // initialize permutation array
-    for (i = 0; i < size; i++) {
-      perm[i] = i;
+        matches.add(new Match(startA, startB, length));
     }
 
-    if (s == 0) {     // submission A
-      for (i = 1; i < size; i++) {
-        for (j = 0; j < (size - i); j++) {
-          if (matches.get(perm[j]).startA > matches.get(perm[j + 1]).startA) {
-            tmp = perm[j];
-            perm[j] = perm[j + 1];
-            perm[j + 1] = tmp;
-          }
+    /*
+     * s==0 uses the start indexes of subA as key for the sorting algorithm. Otherwise the start indexes of subB are used.
+     */
+    public final int[] sort_permutation(int s) {   // bubblesort!!!
+        int size = matches.size();
+        int[] perm = new int[size];
+        int i, j, tmp;
+
+        // initialize permutation array
+        for (i = 0; i < size; i++) {
+            perm[i] = i;
         }
-      }
-    } else {        // submission B
-      for (i = 1; i < size; i++) {
-        for (j = 0; j < (size - i); j++) {
-          if (matches.get(perm[j]).startB > matches.get(perm[j + 1]).startB) {
-            tmp = perm[j];
-            perm[j] = perm[j + 1];
-            perm[j + 1] = tmp;
-          }
+
+        if (s == 0) {     // submission A
+            for (i = 1; i < size; i++) {
+                for (j = 0; j < (size - i); j++) {
+                    if (matches.get(perm[j]).startA > matches.get(perm[j + 1]).startA) {
+                        tmp = perm[j];
+                        perm[j] = perm[j + 1];
+                        perm[j + 1] = tmp;
+                    }
+                }
+            }
+        } else {        // submission B
+            for (i = 1; i < size; i++) {
+                for (j = 0; j < (size - i); j++) {
+                    if (matches.get(perm[j]).startB > matches.get(perm[j + 1]).startB) {
+                        tmp = perm[j];
+                        perm[j] = perm[j + 1];
+                        perm[j + 1] = tmp;
+                    }
+                }
+            }
         }
-      }
+        return perm;
     }
-    return perm;
-  }
-
-  /* sort start indexes of subA
-   */
-  public final void sort() {   // bubblesort!!!
-    Match tmp;
-    int size = matches.size();
-    int i, j;
-
-    for (i = 1; i < size; i++) {
-      for (j = 0; j < (size - i); j++) {
-        if (matches.get(j).startA > matches.get(j + 1).startA) {
-          tmp = matches.get(j);
-          matches.set(j, matches.get(j + 1));
-          matches.set(j + 1, tmp);
+
+    /*
+     * sort start indexes of subA
+     */
+    public final void sort() {   // bubblesort!!!
+        Match tmp;
+        int size = matches.size();
+        int i, j;
+
+        for (i = 1; i < size; i++) {
+            for (j = 0; j < (size - i); j++) {
+                if (matches.get(j).startA > matches.get(j + 1).startA) {
+                    tmp = matches.get(j);
+                    matches.set(j, matches.get(j + 1));
+                    matches.set(j + 1, tmp);
+                }
+            }
         }
-      }
     }
-  }
 
-  /* A few methods to calculate some statistical data
-   */
+    /*
+     * A few methods to calculate some statistical data
+     */
+
+    /**
+     * Get the total number of matched tokens for this comparison.
+     */
+    public final int getNumberOfMatchedTokens() {
+        int numberOfMatchedTokens = 0;
 
-  /**
-   * Get the total number of matched tokens for this comparison.
-   */
-  public final int getNumberOfMatchedTokens() {
-    int numberOfMatchedTokens = 0;
+        for (Match match : matches) {
+            numberOfMatchedTokens += match.length;
+        }
 
-    for (Match match : matches) {
-      numberOfMatchedTokens += match.length;
+        return numberOfMatchedTokens;
     }
 
-    return numberOfMatchedTokens;
-  }
+    private int biggestMatch() {
+        int erg = 0;
 
-  private int biggestMatch() {
-    int erg = 0;
+        for (Match match : matches) {
+            if (match.length > erg) {
+                erg = match.length;
+            }
+        }
 
-    for (Match match : matches) {
-      if (match.length > erg) {
-        erg = match.length;
-      }
+        return erg;
     }
 
-    return erg;
-  }
-
-  public final boolean moreThan(float percent) {
-    return (percent() > percent);
-  }
-
-  public final float roundedPercent() {
-    float percent = percent();
-    return ((int) (percent * 10)) / (float) 10;
-  }
-
-  public final float percent() {
-    float sa, sb;
-    if (bcMatchesB != null && bcMatchesA != null) {
-      sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size() - bcMatchesA.getNumberOfMatchedTokens();
-      sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size() - bcMatchesB.getNumberOfMatchedTokens();
-    } else {
-      sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
-      sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
-    }
-    return (200 * (float) getNumberOfMatchedTokens()) / (sa + sb);
-  }
-
-  public final float percentA() {
-    int divisor;
-    if (bcMatchesA != null) {
-      divisor =
-          firstSubmission.getNumberOfTokens() - firstSubmission.files.size() - bcMatchesA.getNumberOfMatchedTokens();
-    } else {
-      divisor = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
+    public final boolean moreThan(float percent) {
+        return (percent() > percent);
     }
-    return (divisor == 0 ? 0f : (getNumberOfMatchedTokens() * 100 / (float) divisor));
-  }
-
-  public final float percentB() {
-    int divisor;
-    if (bcMatchesB != null) {
-      divisor =
-          secondSubmission.getNumberOfTokens() - secondSubmission.files.size() - bcMatchesB.getNumberOfMatchedTokens();
-    } else {
-      divisor = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
+
+    public final float roundedPercent() {
+        float percent = percent();
+        return ((int) (percent * 10)) / (float) 10;
     }
-    return (divisor == 0 ? 0f : (getNumberOfMatchedTokens() * 100 / (float) divisor));
-  }
-
-  public final float roundedPercentMaxAB() {
-    float percent = percentMaxAB();
-    return ((int) (percent * 10)) / (float) 10;
-  }
-
-  public final float percentMaxAB() {
-    float a = percentA();
-    float b = percentB();
-    if (a > b) {
-      return a;
-    } else {
-      return b;
+
+    public final float percent() {
+        float sa, sb;
+        if (bcMatchesB != null && bcMatchesA != null) {
+            sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size() - bcMatchesA.getNumberOfMatchedTokens();
+            sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size() - bcMatchesB.getNumberOfMatchedTokens();
+        } else {
+            sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
+            sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
+        }
+        return (200 * (float) getNumberOfMatchedTokens()) / (sa + sb);
     }
-  }
-
-  public final float roundedPercentMinAB() {
-    float percent = percentMinAB();
-    return ((int) (percent * 10)) / (float) 10;
-  }
-
-  public final float percentMinAB() {
-    float a = percentA();
-    float b = percentB();
-    if (a < b) {
-      return a;
-    } else {
-      return b;
+
+    public final float percentA() {
+        int divisor;
+        if (bcMatchesA != null) {
+            divisor = firstSubmission.getNumberOfTokens() - firstSubmission.files.size() - bcMatchesA.getNumberOfMatchedTokens();
+        } else {
+            divisor = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
+        }
+        return (divisor == 0 ? 0f : (getNumberOfMatchedTokens() * 100 / (float) divisor));
     }
-  }
-
-  public final float percentBasecodeA() {
-    float sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
-    return bcMatchesA.getNumberOfMatchedTokens() * 100 / sa;
-  }
-
-  public final float percentBasecodeB() {
-    float sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
-    return bcMatchesB.getNumberOfMatchedTokens() * 100 / sb;
-  }
-
-  public final float roundedPercentBasecodeA() {
-    float percent = percentBasecodeA();
-    return ((int) (percent * 10)) / (float) 10;
-  }
-
-  public final float roundedPercentBasecodeB() {
-    float percent = percentBasecodeB();
-    return ((int) (percent * 10)) / (float) 10;
-  }
-
-  /**
-   * This method returns all the files which contributed to a match.
-   * Parameter: j == 0 submission A, j != 0   submission B.
-   */
-  public final String[] files(int j) {
-    if (matches.size() == 0) {
-      return new String[]{};
+
+    public final float percentB() {
+        int divisor;
+        if (bcMatchesB != null) {
+            divisor = secondSubmission.getNumberOfTokens() - secondSubmission.files.size() - bcMatchesB.getNumberOfMatchedTokens();
+        } else {
+            divisor = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
+        }
+        return (divisor == 0 ? 0f : (getNumberOfMatchedTokens() * 100 / (float) divisor));
     }
 
-    Token[] tokens = (j == 0 ? firstSubmission : secondSubmission).tokenList.tokens;
-    int i, h, starti, starth, count = 1;
+    public final float roundedPercentMaxAB() {
+        float percent = percentMaxAB();
+        return ((int) (percent * 10)) / (float) 10;
+    }
 
-    o1:
-    for (i = 1; i < matches.size(); i++) {
-      starti = (j == 0 ? matches.get(i).startA : matches.get(i).startB);
-      for (h = 0; h < i; h++) {
-        starth = (j == 0 ? matches.get(h).startA : matches.get(h).startB);
-        if (tokens[starti].file.equals(tokens[starth].file)) {
-          continue o1;
+    public final float percentMaxAB() {
+        float a = percentA();
+        float b = percentB();
+        if (a > b) {
+            return a;
+        } else {
+            return b;
         }
-      }
-      count++;
     }
 
-    String[] res = new String[count];
-    res[0] = tokens[(j == 0 ? matches.get(0).startA : matches.get(0).startB)].file;
-    count = 1;
-
-    o2:
-    for (i = 1; i < matches.size(); i++) {
-      starti = (j == 0 ? matches.get(i).startA : matches.get(i).startB);
-      for (h = 0; h < i; h++) {
-        starth = (j == 0 ? matches.get(h).startA : matches.get(h).startB);
-        if (tokens[starti].file.equals(tokens[starth].file)) {
-          continue o2;
+    public final float roundedPercentMinAB() {
+        float percent = percentMinAB();
+        return ((int) (percent * 10)) / (float) 10;
+    }
+
+    public final float percentMinAB() {
+        float a = percentA();
+        float b = percentB();
+        if (a < b) {
+            return a;
+        } else {
+            return b;
         }
-      }
-      res[count++] = tokens[starti].file;
     }
 
-    /* sort by file name. (so that equally named files are displayed
-     * approximately side by side.) */
-    Arrays.sort(res);
-
-    return res;
-  }
-
-  /**
-   * The bigger a match (length "anz") is relatively to the biggest match the redder is the color
-   * returned by this method.
-   */
-  public String color(int anz) {
-    int farbe = 255 * anz / biggestMatch();
-    String help = (farbe < 16 ? "0" : "") + Integer.toHexString(farbe);
-    return "#" + help + "0000";
-  }
-
-  /* This method returns the name of all files that are represented by
-   * at least one token. */
-  public final String[] allFiles(int sub) {
-    Structure struct = (sub == 0 ? firstSubmission : secondSubmission).tokenList;
-    int count = 1;
-    for (int i = 1; i < struct.size(); i++) {
-      if (!struct.tokens[i].file.equals(struct.tokens[i - 1].file)) {
-        count++;
-      }
+    public final float percentBasecodeA() {
+        float sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
+        return bcMatchesA.getNumberOfMatchedTokens() * 100 / sa;
     }
-    String[] res = new String[count];
-    if (count > 0) {
-      res[0] = struct.tokens[0].file;
+
+    public final float percentBasecodeB() {
+        float sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
+        return bcMatchesB.getNumberOfMatchedTokens() * 100 / sb;
     }
-    count = 1;
-    for (int i = 1; i < struct.size(); i++) {
-      if (!struct.tokens[i].file.equals(struct.tokens[i - 1].file)) {
-        res[count++] = struct.tokens[i].file;
-      }
+
+    public final float roundedPercentBasecodeA() {
+        float percent = percentBasecodeA();
+        return ((int) (percent * 10)) / (float) 10;
     }
 
-    /* bubblesort by file name. (so that equally named files are displayed
-     * approximately side by side.) */
-    for (int a = 1; a < res.length; a++) {
-      for (int b = 1; b < (res.length - a); b++) {
-        if (res[b - 1].compareTo(res[b]) < 0) {
-          String hilf = res[b - 1];
-          res[b - 1] = res[b];
-          res[b] = hilf;
-        }
-      }
+    public final float roundedPercentBasecodeB() {
+        float percent = percentBasecodeB();
+        return ((int) (percent * 10)) / (float) 10;
     }
 
-    return res;
-  }
+    /**
+     * This method returns all the files which contributed to a match. Parameter: j == 0 submission A, j != 0 submission B.
+     */
+    public final String[] files(int j) {
+        if (matches.size() == 0) {
+            return new String[] {};
+        }
 
-  @Override
-public int compare(JPlagComparison o1, JPlagComparison o2) {
-    float p1 = o1.percent();
-    float p2 = o2.percent();
-    if (p1 == p2) {
-      return 0;
-    }
-    if (p1 > p2) {
-      return -1;
-    } else {
-      return 1;
+        Token[] tokens = (j == 0 ? firstSubmission : secondSubmission).tokenList.tokens;
+        int i, h, starti, starth, count = 1;
+
+        o1: for (i = 1; i < matches.size(); i++) {
+            starti = (j == 0 ? matches.get(i).startA : matches.get(i).startB);
+            for (h = 0; h < i; h++) {
+                starth = (j == 0 ? matches.get(h).startA : matches.get(h).startB);
+                if (tokens[starti].file.equals(tokens[starth].file)) {
+                    continue o1;
+                }
+            }
+            count++;
+        }
+
+        String[] res = new String[count];
+        res[0] = tokens[(j == 0 ? matches.get(0).startA : matches.get(0).startB)].file;
+        count = 1;
+
+        o2: for (i = 1; i < matches.size(); i++) {
+            starti = (j == 0 ? matches.get(i).startA : matches.get(i).startB);
+            for (h = 0; h < i; h++) {
+                starth = (j == 0 ? matches.get(h).startA : matches.get(h).startB);
+                if (tokens[starti].file.equals(tokens[starth].file)) {
+                    continue o2;
+                }
+            }
+            res[count++] = tokens[starti].file;
+        }
+
+        /*
+         * sort by file name. (so that equally named files are displayed approximately side by side.)
+         */
+        Arrays.sort(res);
+
+        return res;
     }
-  }
 
-  @Override
-public boolean equals(Object obj) {
-    if (!(obj instanceof JPlagComparison)) {
-      return false;
+    /**
+     * The bigger a match (length "anz") is relatively to the biggest match the redder is the color returned by this method.
+     */
+    public String color(int anz) {
+        int farbe = 255 * anz / biggestMatch();
+        String help = (farbe < 16 ? "0" : "") + Integer.toHexString(farbe);
+        return "#" + help + "0000";
     }
-    return (compare(this, (JPlagComparison) obj) == 0);
-  }
 
-  @Override
-public String toString() {
-    return firstSubmission.name + " <-> " + secondSubmission.name;
-  }
+    /*
+     * This method returns the name of all files that are represented by at least one token.
+     */
+    public final String[] allFiles(int sub) {
+        Structure struct = (sub == 0 ? firstSubmission : secondSubmission).tokenList;
+        int count = 1;
+        for (int i = 1; i < struct.size(); i++) {
+            if (!struct.tokens[i].file.equals(struct.tokens[i - 1].file)) {
+                count++;
+            }
+        }
+        String[] res = new String[count];
+        if (count > 0) {
+            res[0] = struct.tokens[0].file;
+        }
+        count = 1;
+        for (int i = 1; i < struct.size(); i++) {
+            if (!struct.tokens[i].file.equals(struct.tokens[i - 1].file)) {
+                res[count++] = struct.tokens[i].file;
+            }
+        }
+
+        /*
+         * bubblesort by file name. (so that equally named files are displayed approximately side by side.)
+         */
+        for (int a = 1; a < res.length; a++) {
+            for (int b = 1; b < (res.length - a); b++) {
+                if (res[b - 1].compareTo(res[b]) < 0) {
+                    String hilf = res[b - 1];
+                    res[b - 1] = res[b];
+                    res[b] = hilf;
+                }
+            }
+        }
 
-  public static class AvgComparator implements Comparator<JPlagComparison> {
+        return res;
+    }
 
     @Override
     public int compare(JPlagComparison o1, JPlagComparison o2) {
-      float p1 = o1.percent();
-      float p2 = o2.percent();
-      return Float.compare(p2, p1);
+        float p1 = o1.percent();
+        float p2 = o2.percent();
+        if (p1 == p2) {
+            return 0;
+        }
+        if (p1 > p2) {
+            return -1;
+        } else {
+            return 1;
+        }
     }
 
-  }
-
-  public static class AvgReversedComparator implements Comparator<JPlagComparison> {
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof JPlagComparison)) {
+            return false;
+        }
+        return (compare(this, (JPlagComparison) obj) == 0);
+    }
 
     @Override
-    public int compare(JPlagComparison o1, JPlagComparison o2) {
-      float p1 = o1.percent();
-      float p2 = o2.percent();
-      return Float.compare(p1, p2);
+    public String toString() {
+        return firstSubmission.name + " <-> " + secondSubmission.name;
     }
 
-  }
+    public static class AvgComparator implements Comparator<JPlagComparison> {
 
-  public static class MaxComparator implements Comparator<JPlagComparison> {
+        @Override
+        public int compare(JPlagComparison o1, JPlagComparison o2) {
+            float p1 = o1.percent();
+            float p2 = o2.percent();
+            return Float.compare(p2, p1);
+        }
 
-    @Override
-    public int compare(JPlagComparison o1, JPlagComparison o2) {
-      float p1 = o1.percentMaxAB();
-      float p2 = o2.percentMaxAB();
-      return Float.compare(p2, p1);
     }
 
-  }
+    public static class AvgReversedComparator implements Comparator<JPlagComparison> {
+
+        @Override
+        public int compare(JPlagComparison o1, JPlagComparison o2) {
+            float p1 = o1.percent();
+            float p2 = o2.percent();
+            return Float.compare(p1, p2);
+        }
+
+    }
+
+    public static class MaxComparator implements Comparator<JPlagComparison> {
+
+        @Override
+        public int compare(JPlagComparison o1, JPlagComparison o2) {
+            float p1 = o1.percentMaxAB();
+            float p2 = o2.percentMaxAB();
+            return Float.compare(p2, p1);
+        }
+
+    }
 
 }

+ 282 - 285
jplag/src/main/java/jplag/JPlagOptions.java

@@ -10,290 +10,287 @@ import jplag.strategy.ComparisonMode;
 
 public class JPlagOptions {
 
-  /**
-   * This is related to `storeMatches`.
-   */
-  public static final int MAX_RESULT_PAIRS = 1000;
-
-  /**
-   * Language used to parse the submissions.
-   */
-  private Language language;
-
-  /**
-   * Deprecated - use similarityThreshold instead!
-   *
-   * Maximum number of comparisons to store per run.
-   */
-  @Deprecated
-  private int storeMatches = 30;
-
-  /**
-   * Deprecated - use similarityThreshold instead!
-   * <p>
-   * True, if `storeMatches` should be interpreted as a percentage threshold for the similarity of a
-   * comparison; false otherwise;
-   */
-  @Deprecated
-  private boolean storePercent = false;
-
-  /**
-   * TODO PB: Decide what to do with this.
-   * <p>
-   * Note: Previously, this option had two effects:
-   * <ol>
-   *   <li>If this option was > 0, it told JPlag to use the 'special' comparison strategy</li>
-   *   <li>It specifies the number of submissions to compare each submission to during the 'special' comparison</li>
-   * </ol>
-   */
-  private int numberOfSubmissionsToCompareTo = 0; // 0 = deactivated
-
-  /**
-   * Clustering option.
-   */
-  private ClusterType clusterType;
-
-  /**
-   * Determines which strategy to use for the comparison of submissions.
-   */
-  private ComparisonMode comparisonMode = NORMAL;
-
-  /**
-   * If true, submissions that cannot be parsed will be stored in a separate directory.
-   */
-  private boolean debugParser = false;
-
-  /**
-   * Array of file suffixes that should be included.
-   */
-  private String[] fileSuffixes;
-
-  /**
-   * Percentage value (must be between 0 and 100). Matches with a similarity below this threshold
-   * will be ignored. The default value of 0 allows all matches to be stored.
-   */
-  private float similarityThreshold = 0;
-
-  /**
-   * TODO PB: Not happy with the name yet.
-   */
-  private SimilarityMetric similarityMetric = SimilarityMetric.AVG;
-
-  /**
-   * Tune the sensitivity of the comparison. A smaller <n> increases the sensitivity
-   */
-  private Integer minTokenMatch;
-
-  /**
-   * Name of the file that contains the names of files to exclude from comparison.
-   */
-  private String exclusionFileName;
-
-  /**
-   * Directory that contains all submissions.
-   */
-  private String rootDirName;
-
-  /**
-   * Name of the directory which contains the base code.
-   */
-  private String baseCodeSubmissionName;
-
-  /**
-   * Example: If the subdirectoryName is 'src', only the code inside submissionDir/src of each
-   * submission will be used for comparison.
-   */
-  private String subdirectoryName;
-
-  /**
-   * Language to use when parsing the submissions.
-   */
-  private LanguageOption languageOption;
-
-  /**
-   * Level of output verbosity.
-   */
-  private Verbosity verbosity;
-
-  /**
-   * Constructor with required attributes.
-   */
-  public JPlagOptions(String rootDirName, LanguageOption languageOption) {
-    this.rootDirName = rootDirName;
-    this.languageOption = languageOption;
-  }
-
-  /**
-   * After the selected language has been initialized, this method is called by JPlag to set default
-   * values for options not set by the user.
-   *
-   * @param language - initialized language instance
-   */
-  void setLanguageDefaults(Language language) {
-    if (!this.hasMinTokenMatch()) {
-      this.minTokenMatch = language.min_token_match();
-    }
-
-    if (!this.hasFileSuffixes()) {
-      this.fileSuffixes = language.suffixes();
-    }
-  }
-
-  public LanguageOption getLanguageOption() {
-    return languageOption;
-  }
-
-  public Verbosity getVerbosity() {
-    return verbosity;
-  }
-
-  public boolean hasBaseCode() {
-    return this.baseCodeSubmissionName != null;
-  }
-
-  public boolean hasFileSuffixes() {
-    return this.fileSuffixes != null && this.fileSuffixes.length > 0;
-  }
-
-  public boolean hasMinTokenMatch() {
-    return this.minTokenMatch != null;
-  }
-
-  public ClusterType getClusterType() {
-    return clusterType;
-  }
-
-  public ComparisonMode getComparisonMode() {
-    return comparisonMode;
-  }
-
-  public String[] getFileSuffixes() {
-    return fileSuffixes;
-  }
-
-  @Deprecated
-  public int getStoreMatches() {
-    return storeMatches;
-  }
-
-  @Deprecated
-  public boolean isStorePercent() {
-    return storePercent;
-  }
-
-  public Language getLanguage() {
-    return language;
-  }
-
-  public Integer getMinTokenMatch() {
-    return minTokenMatch;
-  }
-
-  public String getExclusionFileName() {
-    return exclusionFileName;
-  }
-
-  public String getRootDirName() {
-    return rootDirName;
-  }
-
-  public String getBaseCodeSubmissionName() {
-    return baseCodeSubmissionName;
-  }
-
-  public String getSubdirectoryName() {
-    return subdirectoryName;
-  }
-
-  public boolean isDebugParser() {
-    return debugParser;
-  }
-
-  public int getNumberOfSubmissionsToCompareTo() {
-    return numberOfSubmissionsToCompareTo;
-  }
-
-  public float getSimilarityThreshold() {
-    return similarityThreshold;
-  }
-
-  public SimilarityMetric getSimilarityMetric() {
-    return similarityMetric;
-  }
-
-  void setLanguage(Language language) {
-    this.language = language;
-  }
-
-  public void setNumberOfSubmissionsToCompareTo(int numberOfSubmissionsToCompareTo) {
-    this.numberOfSubmissionsToCompareTo = numberOfSubmissionsToCompareTo;
-  }
-
-  public void setClusterType(ClusterType clusterType) {
-    this.clusterType = clusterType;
-  }
+    /**
+     * This is related to `storeMatches`.
+     */
+    public static final int MAX_RESULT_PAIRS = 1000;
+
+    /**
+     * Language used to parse the submissions.
+     */
+    private Language language;
+
+    /**
+     * Deprecated - use similarityThreshold instead! Maximum number of comparisons to store per run.
+     */
+    @Deprecated
+    private int storeMatches = 30;
+
+    /**
+     * Deprecated - use similarityThreshold instead!
+     * <p>
+     * True, if `storeMatches` should be interpreted as a percentage threshold for the similarity of a comparison; false
+     * otherwise;
+     */
+    @Deprecated
+    private boolean storePercent = false;
+
+    /**
+     * TODO PB: Decide what to do with this.
+     * <p>
+     * Note: Previously, this option had two effects:
+     * <ol>
+     * <li>If this option was > 0, it told JPlag to use the 'special' comparison strategy</li>
+     * <li>It specifies the number of submissions to compare each submission to during the 'special' comparison</li>
+     * </ol>
+     */
+    private int numberOfSubmissionsToCompareTo = 0; // 0 = deactivated
+
+    /**
+     * Clustering option.
+     */
+    private ClusterType clusterType;
+
+    /**
+     * Determines which strategy to use for the comparison of submissions.
+     */
+    private ComparisonMode comparisonMode = NORMAL;
+
+    /**
+     * If true, submissions that cannot be parsed will be stored in a separate directory.
+     */
+    private boolean debugParser = false;
+
+    /**
+     * Array of file suffixes that should be included.
+     */
+    private String[] fileSuffixes;
+
+    /**
+     * Percentage value (must be between 0 and 100). Matches with a similarity below this threshold will be ignored. The
+     * default value of 0 allows all matches to be stored.
+     */
+    private float similarityThreshold = 0;
+
+    /**
+     * TODO PB: Not happy with the name yet.
+     */
+    private SimilarityMetric similarityMetric = SimilarityMetric.AVG;
+
+    /**
+     * Tune the sensitivity of the comparison. A smaller <n> increases the sensitivity
+     */
+    private Integer minTokenMatch;
+
+    /**
+     * Name of the file that contains the names of files to exclude from comparison.
+     */
+    private String exclusionFileName;
+
+    /**
+     * Directory that contains all submissions.
+     */
+    private String rootDirName;
+
+    /**
+     * Name of the directory which contains the base code.
+     */
+    private String baseCodeSubmissionName;
+
+    /**
+     * Example: If the subdirectoryName is 'src', only the code inside submissionDir/src of each submission will be used for
+     * comparison.
+     */
+    private String subdirectoryName;
+
+    /**
+     * Language to use when parsing the submissions.
+     */
+    private LanguageOption languageOption;
+
+    /**
+     * Level of output verbosity.
+     */
+    private Verbosity verbosity;
+
+    /**
+     * Constructor with required attributes.
+     */
+    public JPlagOptions(String rootDirName, LanguageOption languageOption) {
+        this.rootDirName = rootDirName;
+        this.languageOption = languageOption;
+    }
+
+    /**
+     * After the selected language has been initialized, this method is called by JPlag to set default values for options
+     * not set by the user.
+     * @param language - initialized language instance
+     */
+    void setLanguageDefaults(Language language) {
+        if (!this.hasMinTokenMatch()) {
+            this.minTokenMatch = language.min_token_match();
+        }
+
+        if (!this.hasFileSuffixes()) {
+            this.fileSuffixes = language.suffixes();
+        }
+    }
+
+    public LanguageOption getLanguageOption() {
+        return languageOption;
+    }
+
+    public Verbosity getVerbosity() {
+        return verbosity;
+    }
+
+    public boolean hasBaseCode() {
+        return this.baseCodeSubmissionName != null;
+    }
+
+    public boolean hasFileSuffixes() {
+        return this.fileSuffixes != null && this.fileSuffixes.length > 0;
+    }
+
+    public boolean hasMinTokenMatch() {
+        return this.minTokenMatch != null;
+    }
+
+    public ClusterType getClusterType() {
+        return clusterType;
+    }
+
+    public ComparisonMode getComparisonMode() {
+        return comparisonMode;
+    }
+
+    public String[] getFileSuffixes() {
+        return fileSuffixes;
+    }
+
+    @Deprecated
+    public int getStoreMatches() {
+        return storeMatches;
+    }
+
+    @Deprecated
+    public boolean isStorePercent() {
+        return storePercent;
+    }
+
+    public Language getLanguage() {
+        return language;
+    }
+
+    public Integer getMinTokenMatch() {
+        return minTokenMatch;
+    }
+
+    public String getExclusionFileName() {
+        return exclusionFileName;
+    }
+
+    public String getRootDirName() {
+        return rootDirName;
+    }
+
+    public String getBaseCodeSubmissionName() {
+        return baseCodeSubmissionName;
+    }
+
+    public String getSubdirectoryName() {
+        return subdirectoryName;
+    }
+
+    public boolean isDebugParser() {
+        return debugParser;
+    }
+
+    public int getNumberOfSubmissionsToCompareTo() {
+        return numberOfSubmissionsToCompareTo;
+    }
+
+    public float getSimilarityThreshold() {
+        return similarityThreshold;
+    }
+
+    public SimilarityMetric getSimilarityMetric() {
+        return similarityMetric;
+    }
+
+    void setLanguage(Language language) {
+        this.language = language;
+    }
+
+    public void setNumberOfSubmissionsToCompareTo(int numberOfSubmissionsToCompareTo) {
+        this.numberOfSubmissionsToCompareTo = numberOfSubmissionsToCompareTo;
+    }
+
+    public void setClusterType(ClusterType clusterType) {
+        this.clusterType = clusterType;
+    }
+
+    public void setComparisonMode(ComparisonMode comparisonMode) {
+        this.comparisonMode = comparisonMode;
+    }
+
+    public void setDebugParser(boolean debugParser) {
+        this.debugParser = debugParser;
+    }
+
+    public void setFileSuffixes(String[] fileSuffixes) {
+        this.fileSuffixes = fileSuffixes;
+    }
+
+    @Deprecated
+    public void setStoreMatches(int storeMatches) {
+        this.storeMatches = storeMatches;
+    }
 
-  public void setComparisonMode(ComparisonMode comparisonMode) {
-    this.comparisonMode = comparisonMode;
-  }
-
-  public void setDebugParser(boolean debugParser) {
-    this.debugParser = debugParser;
-  }
-
-  public void setFileSuffixes(String[] fileSuffixes) {
-    this.fileSuffixes = fileSuffixes;
-  }
-
-  @Deprecated
-  public void setStoreMatches(int storeMatches) {
-    this.storeMatches = storeMatches;
-  }
-
-  @Deprecated
-  public void setStorePercent(boolean storePercent) {
-    this.storePercent = storePercent;
-  }
-
-  public void setMinTokenMatch(Integer minTokenMatch) {
-    this.minTokenMatch = minTokenMatch;
-  }
-
-  public void setExclusionFileName(String exclusionFileName) {
-    this.exclusionFileName = exclusionFileName;
-  }
-
-  public void setRootDirName(String rootDirName) {
-    this.rootDirName = rootDirName;
-  }
-
-  public void setBaseCodeSubmissionName(String baseCodeSubmissionName) {
-    this.baseCodeSubmissionName = baseCodeSubmissionName;
-  }
-
-  public void setSubdirectoryName(String subdirectoryName) {
-    this.subdirectoryName = subdirectoryName;
-  }
-
-  public void setLanguageOption(LanguageOption languageOption) {
-    this.languageOption = languageOption;
-  }
-
-  public void setVerbosity(Verbosity verbosity) {
-    this.verbosity = verbosity;
-  }
-
-  public void setSimilarityThreshold(float similarityThreshold) {
-    if (similarityThreshold > 100) {
-      this.similarityThreshold = 100;
-    } else if (similarityThreshold < 0) {
-      this.similarityThreshold = 0;
-    } else {
-      this.similarityThreshold = similarityThreshold;
-    }
-  }
-
-  public void setSimilarityMetric(SimilarityMetric similarityMetric) {
-    this.similarityMetric = similarityMetric;
-  }
+    @Deprecated
+    public void setStorePercent(boolean storePercent) {
+        this.storePercent = storePercent;
+    }
+
+    public void setMinTokenMatch(Integer minTokenMatch) {
+        this.minTokenMatch = minTokenMatch;
+    }
+
+    public void setExclusionFileName(String exclusionFileName) {
+        this.exclusionFileName = exclusionFileName;
+    }
+
+    public void setRootDirName(String rootDirName) {
+        this.rootDirName = rootDirName;
+    }
+
+    public void setBaseCodeSubmissionName(String baseCodeSubmissionName) {
+        this.baseCodeSubmissionName = baseCodeSubmissionName;
+    }
+
+    public void setSubdirectoryName(String subdirectoryName) {
+        this.subdirectoryName = subdirectoryName;
+    }
+
+    public void setLanguageOption(LanguageOption languageOption) {
+        this.languageOption = languageOption;
+    }
+
+    public void setVerbosity(Verbosity verbosity) {
+        this.verbosity = verbosity;
+    }
+
+    public void setSimilarityThreshold(float similarityThreshold) {
+        if (similarityThreshold > 100) {
+            this.similarityThreshold = 100;
+        } else if (similarityThreshold < 0) {
+            this.similarityThreshold = 0;
+        } else {
+            this.similarityThreshold = similarityThreshold;
+        }
+    }
+
+    public void setSimilarityMetric(SimilarityMetric similarityMetric) {
+        this.similarityMetric = similarityMetric;
+    }
 }

+ 42 - 43
jplag/src/main/java/jplag/Match.java

@@ -2,50 +2,49 @@ package jplag;
 
 public class Match {
 
-  public int startA;
-  public int startB;
-  public int length;
-
-  public Match() {
-  }
-
-  public Match(int startA, int startB, int length) {
-    this.startA = startA;
-    this.startB = startB;
-    this.length = length;
-  }
-
-  public void set(int startA, int startB, int length) {
-    this.startA = startA;
-    this.startB = startB;
-    this.length = length;
-  }
-
-  public final boolean contains(int index, int sub) {
-    int start = (sub == 0 ? startA : startB);
-    return (start <= index && index < (start + length));
-  }
-
-  public final boolean overlap(Match other) {
-    return overlap(other.startA, other.startB, other.length);
-  }
-
-  public final boolean overlap(int oStartA, int oStartB, int oLength) {
-    if (startA < oStartA) {
-      if ((oStartA - startA) < length) {
-        return true;
-      }
-    } else {
-      if ((startA - oStartA) < oLength) {
-        return true;
-      }
+    public int startA;
+    public int startB;
+    public int length;
+
+    public Match() {
     }
 
-    if (startB < oStartB) {
-      return (oStartB - startB) < length;
-    } else {
-      return (startB - oStartB) < oLength;
+    public Match(int startA, int startB, int length) {
+        this.startA = startA;
+        this.startB = startB;
+        this.length = length;
+    }
+
+    public void set(int startA, int startB, int length) {
+        this.startA = startA;
+        this.startB = startB;
+        this.length = length;
+    }
+
+    public final boolean contains(int index, int sub) {
+        int start = (sub == 0 ? startA : startB);
+        return (start <= index && index < (start + length));
+    }
+
+    public final boolean overlap(Match other) {
+        return overlap(other.startA, other.startB, other.length);
     }
-  }
-}
 
+    public final boolean overlap(int oStartA, int oStartB, int oLength) {
+        if (startA < oStartA) {
+            if ((oStartA - startA) < length) {
+                return true;
+            }
+        } else {
+            if ((startA - oStartA) < oLength) {
+                return true;
+            }
+        }
+
+        if (startB < oStartB) {
+            return (oStartB - startB) < length;
+        } else {
+            return (startB - oStartB) < oLength;
+        }
+    }
+}

+ 44 - 48
jplag/src/main/java/jplag/Matches.java

@@ -7,62 +7,58 @@ package jplag;
  */
 public class Matches {
 
-  public Match[] matches;
+    public Match[] matches;
 
-  private int anzahl;
-  private final int increment = 20;
+    private int anzahl;
+    private final int increment = 20;
 
-  public Matches() {
-    matches = new Match[10];
-    for (int i = 0; i < 10; i++) {
-      matches[i] = new Match();
+    public Matches() {
+        matches = new Match[10];
+        for (int i = 0; i < 10; i++) {
+            matches[i] = new Match();
+        }
+        anzahl = 0;
     }
-    anzahl = 0;
-  }
 
-  public final int size() {
-    return anzahl;
-  }
-
-  private void ensureCapacity(int minCapacity) {
-    int oldCapacity = matches.length;
-    if (minCapacity > oldCapacity) {
-      Match[] oldMatches = matches;
-      int newCapacity = (oldCapacity + increment);
-      if (newCapacity < minCapacity) {
-        newCapacity = minCapacity;
-      }
-      matches = new Match[newCapacity];
-      System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
-      for (int i = oldCapacity; i < newCapacity; i++) {
-        matches[i] = new Match();
-      }
+    public final int size() {
+        return anzahl;
     }
-  }
 
-  /*
-  public final void addMatch(Match match) {
-    for (int i=0; i<anzahl; i++)
-      if (match.overlap(matches[i])) return;  // do not allow overlaps
-    ensureCapacity(anzahl + 1);
-    matches[anzahl++] = match;
-  }
-  */
-  public final void addMatch(int startA, int startB, int length) {
-    for (int i = anzahl - 1; i >= 0; i--) { // starting at the end is better(?)
-      if (matches[i].overlap(startA, startB, length)) {
-        return;
-      }
-      // no overlaps!
+    private void ensureCapacity(int minCapacity) {
+        int oldCapacity = matches.length;
+        if (minCapacity > oldCapacity) {
+            Match[] oldMatches = matches;
+            int newCapacity = (oldCapacity + increment);
+            if (newCapacity < minCapacity) {
+                newCapacity = minCapacity;
+            }
+            matches = new Match[newCapacity];
+            System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
+            for (int i = oldCapacity; i < newCapacity; i++) {
+                matches[i] = new Match();
+            }
+        }
     }
 
-    ensureCapacity(anzahl + 1);
+    /*
+     * public final void addMatch(Match match) { for (int i=0; i<anzahl; i++) if (match.overlap(matches[i])) return; // do
+     * not allow overlaps ensureCapacity(anzahl + 1); matches[anzahl++] = match; }
+     */
+    public final void addMatch(int startA, int startB, int length) {
+        for (int i = anzahl - 1; i >= 0; i--) { // starting at the end is better(?)
+            if (matches[i].overlap(startA, startB, length)) {
+                return;
+            }
+            // no overlaps!
+        }
+
+        ensureCapacity(anzahl + 1);
 
-    matches[anzahl].set(startA, startB, length);
-    anzahl++;
-  }
+        matches[anzahl].set(startA, startB, length);
+        anzahl++;
+    }
 
-  public final void clear() {
-    anzahl = 0;
-  }
+    public final void clear() {
+        anzahl = 0;
+    }
 }

+ 24 - 24
jplag/src/main/java/jplag/SortedVector.java

@@ -5,32 +5,32 @@ import java.util.Vector;
 
 public class SortedVector<T> extends Vector<T> {
 
-  private static final long serialVersionUID = 1L;
-  private Comparator<T> cmp;
+    private static final long serialVersionUID = 1L;
+    private Comparator<T> cmp;
 
-  public SortedVector(Comparator<T> comparator) {
-    cmp = comparator;
-  }
+    public SortedVector(Comparator<T> comparator) {
+        cmp = comparator;
+    }
 
-  private void insert(T obj, int index1, int index2) {
-    int pos = 0;
-    int c = -1;
-    while (index1 <= index2) {
-      pos = (index1 + index2) / 2;
-      c = cmp.compare(obj, elementAt(pos - 1));
-      if (c < 0) {
-        index2 = pos - 1;
-      } else if (c > 0) {
-        index1 = pos + 1;
-      } else {
-        index1 = pos;
-        index2 = -1;
-      }
+    private void insert(T obj, int index1, int index2) {
+        int pos = 0;
+        int c = -1;
+        while (index1 <= index2) {
+            pos = (index1 + index2) / 2;
+            c = cmp.compare(obj, elementAt(pos - 1));
+            if (c < 0) {
+                index2 = pos - 1;
+            } else if (c > 0) {
+                index1 = pos + 1;
+            } else {
+                index1 = pos;
+                index2 = -1;
+            }
+        }
+        insertElementAt(obj, index1 - 1);
     }
-    insertElementAt(obj, index1 - 1);
-  }
 
-  public synchronized void insert(T obj) {
-    insert(obj, 1, elementCount);
-  }
+    public synchronized void insert(T obj) {
+        insert(obj, 1, elementCount);
+    }
 }

+ 218 - 236
jplag/src/main/java/jplag/Submission.java

@@ -24,277 +24,259 @@ import jplag.options.Verbosity;
  */
 public class Submission implements Comparable<Submission> {
 
-  /**
-   * Name that uniquely identifies this submission. Will most commonly be the directory or file
-   * name.
-   */
-  public String name;
-
-  public File submissionFile;
-
-  /**
-   * List of files this submission consists of.
-   */
-  public List<File> files;
-
-  /**
-   * List of tokens that have been parsed from the files this submission consists of.
-   * <p>
-   * TODO PB: The name 'Structure' is very generic and should be changed to something more
-   * descriptive.
-   */
-  public Structure tokenList;
-
-  /**
-   * True, if at least one error occurred while parsing this submission; false otherwise.
-   */
-  public boolean hasErrors = false;
-
-  private final JPlag program;
-
-  public Submission(
-      String name,
-      File submissionFile,
-      JPlag program
-  ) {
-    this.name = name;
-    this.submissionFile = submissionFile;
-    this.program = program;
-    this.files = parseFilesRecursively(submissionFile);
-  }
-
-  /**
-   * Recursively scan the given directory for nested files. Excluded files and files with an invalid
-   * suffix are ignored.
-   * <p>
-   * If the given file is not a directory, the input will be returned as a singleton list.
-   *
-   * @param file - File to start the scan from.
-   * @return a list of nested files.
-   */
-  private List<File> parseFilesRecursively(File file) {
-    if (program.isFileExcluded(file)) {
-      return Collections.emptyList();
+    /**
+     * Name that uniquely identifies this submission. Will most commonly be the directory or file name.
+     */
+    public String name;
+
+    public File submissionFile;
+
+    /**
+     * List of files this submission consists of.
+     */
+    public List<File> files;
+
+    /**
+     * List of tokens that have been parsed from the files this submission consists of.
+     * <p>
+     * TODO PB: The name 'Structure' is very generic and should be changed to something more descriptive.
+     */
+    public Structure tokenList;
+
+    /**
+     * True, if at least one error occurred while parsing this submission; false otherwise.
+     */
+    public boolean hasErrors = false;
+
+    private final JPlag program;
+
+    public Submission(String name, File submissionFile, JPlag program) {
+        this.name = name;
+        this.submissionFile = submissionFile;
+        this.program = program;
+        this.files = parseFilesRecursively(submissionFile);
     }
 
-    if (file.isFile() && program.hasValidSuffix(file)) {
-      return Collections.singletonList(file);
-    }
+    /**
+     * Recursively scan the given directory for nested files. Excluded files and files with an invalid suffix are ignored.
+     * <p>
+     * If the given file is not a directory, the input will be returned as a singleton list.
+     * @param file - File to start the scan from.
+     * @return a list of nested files.
+     */
+    private List<File> parseFilesRecursively(File file) {
+        if (program.isFileExcluded(file)) {
+            return Collections.emptyList();
+        }
+
+        if (file.isFile() && program.hasValidSuffix(file)) {
+            return Collections.singletonList(file);
+        }
+
+        String[] nestedFileNames = file.list();
+
+        if (nestedFileNames == null) {
+            return Collections.emptyList();
+        }
 
-    String[] nestedFileNames = file.list();
+        List<File> files = new ArrayList<>();
 
-    if (nestedFileNames == null) {
-      return Collections.emptyList();
+        for (String fileName : nestedFileNames) {
+            files.addAll(parseFilesRecursively(new File(file, fileName)));
+        }
+
+        return files;
     }
 
-    List<File> files = new ArrayList<>();
+    public int getNumberOfTokens() {
+        if (tokenList == null) {
+            return 0;
+        }
 
-    for (String fileName : nestedFileNames) {
-      files.addAll(parseFilesRecursively(new File(file, fileName)));
+        return tokenList.size();
     }
 
-    return files;
-  }
+    @Override
+    public int compareTo(Submission other) {
+        return name.compareTo(other.name);
+    }
 
-  public int getNumberOfTokens() {
-    if (tokenList == null) {
-      return 0;
+    @Override
+    public String toString() {
+        return name;
     }
 
-    return tokenList.size();
-  }
-
-  @Override
-  public int compareTo(Submission other) {
-    return name.compareTo(other.name);
-  }
-
-  @Override
-  public String toString() {
-    return name;
-  }
-
-  /**
-   * Map all files of this submission to their path relative to the submission directory.
-   * <p>
-   * This method is required to stay compatible with `program.language.parse(...)` as it requires
-   * the given file paths to be relative to the submission directory.
-   * <p>
-   * In a future update, `program.language.parse(...)` should probably just take a list of files.
-   *
-   * @param baseFile - File to base all relative file paths on.
-   * @param files    - List of files to map.
-   * @return an array of file paths relative to the submission directory.
-   */
-  public String[] getRelativeFilePaths(File baseFile, List<File> files) {
-    Path baseFilePath = baseFile.toPath();
-
-    return files.stream()
-        .map(File::toPath)
-        .map(baseFilePath::relativize)
-        .map(Path::toString)
-        .toArray(String[]::new);
-  }
-
-  /* parse all the files... */
-  public boolean parse() {
-    if (program.getOptions().getVerbosity() != Verbosity.PARSER) {
-      if (files == null || files.size() == 0) {
-        program.print("ERROR: nothing to parse for submission \"" + name + "\"\n", null);
-        return false;
-      }
+    /**
+     * Map all files of this submission to their path relative to the submission directory.
+     * <p>
+     * This method is required to stay compatible with `program.language.parse(...)` as it requires the given file paths to
+     * be relative to the submission directory.
+     * <p>
+     * In a future update, `program.language.parse(...)` should probably just take a list of files.
+     * @param baseFile - File to base all relative file paths on.
+     * @param files - List of files to map.
+     * @return an array of file paths relative to the submission directory.
+     */
+    public String[] getRelativeFilePaths(File baseFile, List<File> files) {
+        Path baseFilePath = baseFile.toPath();
+
+        return files.stream().map(File::toPath).map(baseFilePath::relativize).map(Path::toString).toArray(String[]::new);
     }
 
-    String[] relativeFilePaths = getRelativeFilePaths(submissionFile, files);
+    /* parse all the files... */
+    public boolean parse() {
+        if (program.getOptions().getVerbosity() != Verbosity.PARSER) {
+            if (files == null || files.size() == 0) {
+                program.print("ERROR: nothing to parse for submission \"" + name + "\"\n", null);
+                return false;
+            }
+        }
+
+        String[] relativeFilePaths = getRelativeFilePaths(submissionFile, files);
+
+        tokenList = this.program.language.parse(submissionFile, relativeFilePaths);
+        if (!program.language.errors()) {
+            if (tokenList.size() < 3) {
+                program.print("Submission \"" + name + "\" is too short!\n", null);
+                tokenList = null;
+                hasErrors = true; // invalidate submission
+                return false;
+            }
+            return true;
+        }
 
-    tokenList = this.program.language.parse(submissionFile, relativeFilePaths);
-    if (!program.language.errors()) {
-      if (tokenList.size() < 3) {
-        program.print("Submission \"" + name + "\" is too short!\n", null);
         tokenList = null;
         hasErrors = true; // invalidate submission
+        if (program.getOptions().isDebugParser()) {
+            copySubmission();
+        }
         return false;
-      }
-      return true;
     }
 
-    tokenList = null;
-    hasErrors = true; // invalidate submission
-    if (program.getOptions().isDebugParser()) {
-      copySubmission();
-    }
-    return false;
-  }
-
-  /**
-   * Used by the "Report" class. All source files are returned as an array of an array of strings.
-   */
-  public String[][] readFiles(String[] files) throws jplag.ExitException {
-    String[][] result = new String[files.length][];
-    String help;
-    Vector<String> text = new Vector<>();
-
-    for (int i = 0; i < files.length; i++) {
-      text.removeAllElements();
-
-      try {
-        /* file encoding = "UTF-8" */
-        FileInputStream fileInputStream = new FileInputStream(new File(submissionFile, files[i]));
-        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream,
-            StandardCharsets.UTF_8);
-        BufferedReader in = new BufferedReader(inputStreamReader);
-
-        while ((help = in.readLine()) != null) {
-          help = help.replaceAll("&", "&amp;");
-          help = help.replaceAll("<", "&lt;");
-          help = help.replaceAll(">", "&gt;");
-          help = help.replaceAll("\"", "&quot;");
-          text.addElement(help);
+    /**
+     * Used by the "Report" class. All source files are returned as an array of an array of strings.
+     */
+    public String[][] readFiles(String[] files) throws jplag.ExitException {
+        String[][] result = new String[files.length][];
+        String help;
+        Vector<String> text = new Vector<>();
+
+        for (int i = 0; i < files.length; i++) {
+            text.removeAllElements();
+
+            try {
+                /* file encoding = "UTF-8" */
+                FileInputStream fileInputStream = new FileInputStream(new File(submissionFile, files[i]));
+                InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
+                BufferedReader in = new BufferedReader(inputStreamReader);
+
+                while ((help = in.readLine()) != null) {
+                    help = help.replaceAll("&", "&amp;");
+                    help = help.replaceAll("<", "&lt;");
+                    help = help.replaceAll(">", "&gt;");
+                    help = help.replaceAll("\"", "&quot;");
+                    text.addElement(help);
+                }
+
+                in.close();
+                inputStreamReader.close();
+                fileInputStream.close();
+            } catch (FileNotFoundException e) {
+                System.out.println("File not found: " + ((new File(submissionFile, files[i])).toString()));
+            } catch (IOException e) {
+                throw new jplag.ExitException("I/O exception!");
+            }
+
+            result[i] = new String[text.size()];
+            text.copyInto(result[i]);
         }
 
-        in.close();
-        inputStreamReader.close();
-        fileInputStream.close();
-      } catch (FileNotFoundException e) {
-        System.out.println("File not found: " + ((new File(submissionFile, files[i])).toString()));
-      } catch (IOException e) {
-        throw new jplag.ExitException("I/O exception!");
-      }
-
-      result[i] = new String[text.size()];
-      text.copyInto(result[i]);
+        return result;
     }
 
-    return result;
-  }
+    /**
+     * Used by the "Report" class. All source files are returned as an array of an array of chars.
+     */
+    public char[][] readFilesChar(String[] files) throws jplag.ExitException {
+        char[][] result = new char[files.length][];
+
+        for (int i = 0; i < files.length; i++) {
+            try {
+                File file = new File(submissionFile, files[i]);
+                int size = (int) file.length();
+                char[] buffer = new char[size];
+
+                FileReader fis = new FileReader(file);
+
+                if (size != fis.read(buffer)) {
+                    System.out.println("Not right size read from the file, " + "but I will still continue...");
+                }
+
+                result[i] = buffer;
+                fis.close();
+            } catch (FileNotFoundException e) {
+                // TODO PB: Should an ExitException be thrown here?
+                System.out.println("File not found: " + ((new File(submissionFile, files[i])).toString()));
+            } catch (IOException e) {
+                throw new jplag.ExitException("I/O exception reading file \"" + (new File(submissionFile, files[i])).toString() + "\"!", e);
+            }
+        }
 
-  /**
-   * Used by the "Report" class. All source files are returned as an array of an array of chars.
-   */
-  public char[][] readFilesChar(String[] files) throws jplag.ExitException {
-    char[][] result = new char[files.length][];
+        return result;
+    }
 
-    for (int i = 0; i < files.length; i++) {
-      try {
-        File file = new File(submissionFile, files[i]);
-        int size = (int) file.length();
-        char[] buffer = new char[size];
+    /*
+     * This method is used to copy files that can not be parsed to a special folder: jplag/errors/java old_java scheme cpp
+     * /001/(...files...) /002/(...files...)
+     */
+    private void copySubmission() {
+        File errorDir = null;
+        DecimalFormat format = new DecimalFormat("0000");
+
+        try {
+            URL url = Submission.class.getResource("errors");
+            errorDir = new File(url.getFile());
+        } catch (NullPointerException e) {
+            return;
+        }
 
-        FileReader fis = new FileReader(file);
+        errorDir = new File(errorDir, this.program.language.getShortName());
 
-        if (size != fis.read(buffer)) {
-          System.out
-              .println("Not right size read from the file, " + "but I will still continue...");
+        if (!errorDir.exists()) {
+            errorDir.mkdir();
         }
 
-        result[i] = buffer;
-        fis.close();
-      } catch (FileNotFoundException e) {
-        // TODO PB: Should an ExitException be thrown here?
-        System.out.println("File not found: " + ((new File(submissionFile, files[i])).toString()));
-      } catch (IOException e) {
-        throw new jplag.ExitException(
-            "I/O exception reading file \"" + (new File(submissionFile, files[i])).toString()
-                + "\"!", e);
-      }
-    }
-    
-    return result;
-  }
-
-  /*
-   * This method is used to copy files that can not be parsed to a special
-   * folder: jplag/errors/java old_java scheme cpp /001/(...files...)
-   * /002/(...files...)
-   */
-  private void copySubmission() {
-    File errorDir = null;
-    DecimalFormat format = new DecimalFormat("0000");
-
-    try {
-      URL url = Submission.class.getResource("errors");
-      errorDir = new File(url.getFile());
-    } catch (NullPointerException e) {
-      return;
-    }
-
-    errorDir = new File(errorDir, this.program.language.getShortName());
+        int i = 0;
+        File destDir;
 
-    if (!errorDir.exists()) {
-      errorDir.mkdir();
-    }
+        while ((destDir = new File(errorDir, format.format(i))).exists()) {
+            i++;
+        }
 
-    int i = 0;
-    File destDir;
+        destDir.mkdir();
 
-    while ((destDir = new File(errorDir, format.format(i))).exists()) {
-      i++;
+        for (i = 0; i < files.size(); i++) {
+            copyFile(new File(files.get(i).getAbsolutePath()), new File(destDir, files.get(i).getName()));
+        }
     }
 
-    destDir.mkdir();
-
-    for (i = 0; i < files.size(); i++) {
-      copyFile(new File(files.get(i).getAbsolutePath()), new File(destDir, files.get(i).getName()));
-    }
-  }
-
-  /* Physical copy. :-) */
-  private void copyFile(File in, File out) {
-    byte[] buffer = new byte[10000];
-    try {
-      FileInputStream dis = new FileInputStream(in);
-      FileOutputStream dos = new FileOutputStream(out);
-      int count;
-      do {
-        count = dis.read(buffer);
-        if (count != -1) {
-          dos.write(buffer, 0, count);
+    /* Physical copy. :-) */
+    private void copyFile(File in, File out) {
+        byte[] buffer = new byte[10000];
+        try {
+            FileInputStream dis = new FileInputStream(in);
+            FileOutputStream dos = new FileOutputStream(out);
+            int count;
+            do {
+                count = dis.read(buffer);
+                if (count != -1) {
+                    dos.write(buffer, 0, count);
+                }
+            } while (count != -1);
+            dis.close();
+            dos.close();
+        } catch (IOException e) {
+            program.print("Error copying file: " + e.toString() + "\n", null);
         }
-      } while (count != -1);
-      dis.close();
-      dos.close();
-    } catch (IOException e) {
-      program.print("Error copying file: " + e.toString() + "\n", null);
     }
-  }
 }

+ 164 - 172
jplag/src/main/java/jplag/clustering/Cluster.java

@@ -2,195 +2,187 @@ package jplag.clustering;
 
 public class Cluster implements Comparable<Cluster> {
 
-  private float similarity; // similarity threshold for this cluster
-
-  private int submissionNr = -1;
-  // !=-1 -> this cluster consists of one document only
-
-  private Cluster left, right;
-
-  private int[] allSubmissions = null;
-  private Clusters clusters;// Warum habe ich nicht instanziert? ist es
-  // schon woanders instanziert? Emeric
-  public int x = -1, y = -1; // Coordinates for the dendrogram
-
-  public Cluster(int submissionNr, Clusters clusters) {
-    this.clusters = clusters;
-    this.submissionNr = submissionNr;
-    left = right = null;
-    similarity = 100;
-  }
-
-  // changed by Emeric Kwemou now, a cluster muss belong to a specific Objekt
-  // of Type Clusters ->Clusters object added in Constructor
-
-  public Cluster(Cluster left, Cluster right, float similarity,
-      Clusters clusters) {
-    this.clusters = clusters;
-    this.submissionNr = -1;
-    this.left = left;
-    this.right = right;
-    this.similarity = similarity;
-
-    calculateAllSubmissions();
-  }
-
-  public int size() {
-    return (submissionNr == -1 ? allSubmissions.length : 1);
-  }
-
-  public int getSubmissionAt(int i) {
-    return (submissionNr == -1 ? allSubmissions[i] : submissionNr);
-  }
-
-  public float getSimilarity() {
-    return similarity;
-  }
-
-  public Cluster getLeft() {
-    return left;
-  }
-
-  public Cluster getRight() {
-    return right;
-  }
-
-  private void calculateAllSubmissions() {
-    if (submissionNr == -1) {
-      int rSize = right.size();
-      int lSize = left.size();
-      allSubmissions = new int[lSize + rSize];
-
-      if (left.allSubmissions != null) {
-        System.arraycopy(left.allSubmissions, 0, allSubmissions, 0,
-            lSize);
-      } else {
-        allSubmissions[0] = left.submissionNr;
-      }
-
-      if (right.allSubmissions != null) {
-        System.arraycopy(right.allSubmissions, 0, allSubmissions,
-            lSize, rSize);
-      } else {
-        allSubmissions[lSize] = right.submissionNr;
-      }
-
-      // int i, li, ri;
-      // i = ri = li = 0;
-
-      // insert-sort
-      // while (i<lSize+rSize) {
-      // boolean takeLeft = true;
-      // if (li<lSize && ri<rSize)
-      // takeLeft = (left.getSubmissionAt(li) <
-      // right.getSubmissionAt(ri));
-      // else
-      // takeLeft = (li < lSize);
-
-      // if (takeLeft)
-      // allSubmissions[i++] = left.getSubmissionAt(li++);
-      // else
-      // allSubmissions[i++] = right.getSubmissionAt(ri++);
-      // }
-    } else {
-      allSubmissions = null;
+    private float similarity; // similarity threshold for this cluster
+
+    private int submissionNr = -1;
+    // !=-1 -> this cluster consists of one document only
+
+    private Cluster left, right;
+
+    private int[] allSubmissions = null;
+    private Clusters clusters;// Warum habe ich nicht instanziert? ist es schon woanders instanziert? Emeric
+    public int x = -1, y = -1; // Coordinates for the dendrogram
+
+    public Cluster(int submissionNr, Clusters clusters) {
+        this.clusters = clusters;
+        this.submissionNr = submissionNr;
+        left = right = null;
+        similarity = 100;
     }
-  }
-
-  // for MIN clustering
-  public float maxSimilarity(Cluster other, SimilarityMatrix simMatrix) {
-    int sizeThis = size();
-    int sizeOther = other.size();
-    float maxSim = -1;
-
-    for (int a = 0; a < sizeThis; a++) {
-      for (int b = 0; b < sizeOther; b++) {
-        float sim = simMatrix.getSimilarity(this.getSubmissionAt(a),
-            other.getSubmissionAt(b));
-        if (sim > maxSim) {
-          maxSim = sim;
-        }
-      }
+
+    // changed by Emeric Kwemou now, a cluster muss belong to a specific Objekt
+    // of Type Clusters ->Clusters object added in Constructor
+
+    public Cluster(Cluster left, Cluster right, float similarity, Clusters clusters) {
+        this.clusters = clusters;
+        this.submissionNr = -1;
+        this.left = left;
+        this.right = right;
+        this.similarity = similarity;
+
+        calculateAllSubmissions();
     }
 
-    return maxSim;
-  }
-
-  // for MAX clustering
-  public float minSimilarity(Cluster other, SimilarityMatrix simMatrix) {
-    int sizeThis = size();
-    int sizeOther = other.size();
-    float minSim = 100;
-
-    for (int a = 0; a < sizeThis; a++) {
-      for (int b = 0; b < sizeOther; b++) {
-        float sim = simMatrix.getSimilarity(this.getSubmissionAt(a),
-            other.getSubmissionAt(b));
-        if (sim < minSim) {
-          minSim = sim;
-        }
-      }
+    public int size() {
+        return (submissionNr == -1 ? allSubmissions.length : 1);
     }
 
-    return minSim;
-  }
+    public int getSubmissionAt(int i) {
+        return (submissionNr == -1 ? allSubmissions[i] : submissionNr);
+    }
 
-  // for AVR clustering
-  public float avrSimilarity(Cluster other, SimilarityMatrix simMatrix) {
-    int sizeThis = size();
-    int sizeOther = other.size();
-    float summedSim = 0;
+    public float getSimilarity() {
+        return similarity;
+    }
 
-    for (int a = 0; a < sizeThis; a++) {
-      for (int b = 0; b < sizeOther; b++) {
-        summedSim += simMatrix.getSimilarity(this.getSubmissionAt(a),
-            other.getSubmissionAt(b));
-      }
+    public Cluster getLeft() {
+        return left;
     }
-    return summedSim / (sizeThis * sizeOther);
-  }
-
-  @Override
-public String toString() {
-    String text = (submissionNr == -1 ? "Similarity: " + similarity + ":"
-        : "Submission:");
-    for (int i = 0; i < size(); i++) {
-      text += " " + clusters.submissions.elementAt(getSubmissionAt(i)).name;
+
+    public Cluster getRight() {
+        return right;
     }
-    text += "\n\n";
-    if (left != null) {
-      text += left.toString();
+
+    private void calculateAllSubmissions() {
+        if (submissionNr == -1) {
+            int rSize = right.size();
+            int lSize = left.size();
+            allSubmissions = new int[lSize + rSize];
+
+            if (left.allSubmissions != null) {
+                System.arraycopy(left.allSubmissions, 0, allSubmissions, 0, lSize);
+            } else {
+                allSubmissions[0] = left.submissionNr;
+            }
+
+            if (right.allSubmissions != null) {
+                System.arraycopy(right.allSubmissions, 0, allSubmissions, lSize, rSize);
+            } else {
+                allSubmissions[lSize] = right.submissionNr;
+            }
+
+            // int i, li, ri;
+            // i = ri = li = 0;
+
+            // insert-sort
+            // while (i<lSize+rSize) {
+            // boolean takeLeft = true;
+            // if (li<lSize && ri<rSize)
+            // takeLeft = (left.getSubmissionAt(li) <
+            // right.getSubmissionAt(ri));
+            // else
+            // takeLeft = (li < lSize);
+
+            // if (takeLeft)
+            // allSubmissions[i++] = left.getSubmissionAt(li++);
+            // else
+            // allSubmissions[i++] = right.getSubmissionAt(ri++);
+            // }
+        } else {
+            allSubmissions = null;
+        }
     }
-    if (right != null) {
-      text += right.toString();
+
+    // for MIN clustering
+    public float maxSimilarity(Cluster other, SimilarityMatrix simMatrix) {
+        int sizeThis = size();
+        int sizeOther = other.size();
+        float maxSim = -1;
+
+        for (int a = 0; a < sizeThis; a++) {
+            for (int b = 0; b < sizeOther; b++) {
+                float sim = simMatrix.getSimilarity(this.getSubmissionAt(a), other.getSubmissionAt(b));
+                if (sim > maxSim) {
+                    maxSim = sim;
+                }
+            }
+        }
+
+        return maxSim;
     }
-    return text;
-  }
 
-  @Override
-public int compareTo(Cluster cluster2) {
-    if (equals(cluster2)) {
-      return 0;
+    // for MAX clustering
+    public float minSimilarity(Cluster other, SimilarityMatrix simMatrix) {
+        int sizeThis = size();
+        int sizeOther = other.size();
+        float minSim = 100;
+
+        for (int a = 0; a < sizeThis; a++) {
+            for (int b = 0; b < sizeOther; b++) {
+                float sim = simMatrix.getSimilarity(this.getSubmissionAt(a), other.getSubmissionAt(b));
+                if (sim < minSim) {
+                    minSim = sim;
+                }
+            }
+        }
+
+        return minSim;
     }
 
-    int s1Size = size();
-    int s2Size = cluster2.size();
+    // for AVR clustering
+    public float avrSimilarity(Cluster other, SimilarityMatrix simMatrix) {
+        int sizeThis = size();
+        int sizeOther = other.size();
+        float summedSim = 0;
 
-    if (s1Size != s2Size) {
-      return (s1Size < s2Size ? +1 : -1);
+        for (int a = 0; a < sizeThis; a++) {
+            for (int b = 0; b < sizeOther; b++) {
+                summedSim += simMatrix.getSimilarity(this.getSubmissionAt(a), other.getSubmissionAt(b));
+            }
+        }
+        return summedSim / (sizeThis * sizeOther);
     }
 
-    int size = 0;
-    for (int i = 0; i < s1Size; i++) {
-      String name1 = clusters.submissions.elementAt(getSubmissionAt(i)).name;
-      String name2 = clusters.submissions.elementAt(cluster2.getSubmissionAt(i)).name;
-      if (name1.compareTo(name2) != 0) {
-        return name1.compareTo(name2);
-      }
-      size += name1.length();
-      size -= name2.length();
+    @Override
+    public String toString() {
+        String text = (submissionNr == -1 ? "Similarity: " + similarity + ":" : "Submission:");
+        for (int i = 0; i < size(); i++) {
+            text += " " + clusters.submissions.elementAt(getSubmissionAt(i)).name;
+        }
+        text += "\n\n";
+        if (left != null) {
+            text += left.toString();
+        }
+        if (right != null) {
+            text += right.toString();
+        }
+        return text;
     }
 
-    return (size >= 0 ? 1 : -1);
-  }
+    @Override
+    public int compareTo(Cluster cluster2) {
+        if (equals(cluster2)) {
+            return 0;
+        }
+
+        int s1Size = size();
+        int s2Size = cluster2.size();
+
+        if (s1Size != s2Size) {
+            return (s1Size < s2Size ? +1 : -1);
+        }
+
+        int size = 0;
+        for (int i = 0; i < s1Size; i++) {
+            String name1 = clusters.submissions.elementAt(getSubmissionAt(i)).name;
+            String name2 = clusters.submissions.elementAt(cluster2.getSubmissionAt(i)).name;
+            if (name1.compareTo(name2) != 0) {
+                return name1.compareTo(name2);
+            }
+            size += name1.length();
+            size -= name2.length();
+        }
+
+        return (size >= 0 ? 1 : -1);
+    }
 }

+ 66 - 66
jplag/src/main/java/jplag/clustering/Clusters.java

@@ -8,85 +8,85 @@ import jplag.Submission;
 import jplag.options.ClusterType;
 
 /**
- * This class calculates, based on the similarity matrix, the hierarchical clustering of the
- * documents, using MIN, MAX and AVR methods.
+ * This class calculates, based on the similarity matrix, the hierarchical clustering of the documents, using MIN, MAX
+ * and AVR methods.
  */
 public class Clusters {
 
-  public Vector<Submission> submissions;
-  public float maxMergeValue = 0;
-  private JPlag program;
+    public Vector<Submission> submissions;
+    public float maxMergeValue = 0;
+    private JPlag program;
 
-  public Clusters(JPlag program) {
-    this.program = program;
-  }
-
-  public Cluster calculateClustering(Vector<Submission> submissions) {
-    this.submissions = submissions;
-    Cluster clusters = null;
-
-    switch (this.program.getOptions().getClusterType()) {
-      case MAX:
-      case MIN:
-      case AVG:
-        clusters = minMaxAvrClustering();
-        break;
-      default:
+    public Clusters(JPlag program) {
+        this.program = program;
     }
 
-    return clusters;
-  }
+    public Cluster calculateClustering(Vector<Submission> submissions) {
+        this.submissions = submissions;
+        Cluster clusters = null;
 
-  /**
-   * Min clustering...
-   */
-  public Cluster minMaxAvrClustering() {
-    int nrOfSubmissions = submissions.size();
-    boolean minClustering = (this.program.getOptions().getClusterType() == ClusterType.MIN);
-    boolean maxClustering = (this.program.getOptions().getClusterType() == ClusterType.MAX);
-    SimilarityMatrix simMatrix = this.program.similarity;
+        switch (this.program.getOptions().getClusterType()) {
+        case MAX:
+        case MIN:
+        case AVG:
+            clusters = minMaxAvrClustering();
+            break;
+        default:
+        }
 
-    ArrayList<Cluster> clusters = new ArrayList<Cluster>(submissions.size());
-    for (int i = 0; i < nrOfSubmissions; i++) {
-      clusters.add(new Cluster(i, this));
+        return clusters;
     }
 
-    while (clusters.size() > 1) {
-      int indexA = -1, indexB = -1;
-      float maxSim = -1;
-      int nrOfClusters = clusters.size();
+    /**
+     * Min clustering...
+     */
+    public Cluster minMaxAvrClustering() {
+        int nrOfSubmissions = submissions.size();
+        boolean minClustering = (this.program.getOptions().getClusterType() == ClusterType.MIN);
+        boolean maxClustering = (this.program.getOptions().getClusterType() == ClusterType.MAX);
+        SimilarityMatrix simMatrix = this.program.similarity;
 
-      // find similarity
-      for (int a = 0; a < (nrOfClusters - 1); a++) {
-        Cluster cluster = clusters.get(a);
-        for (int b = a + 1; b < nrOfClusters; b++) {
-          float sim;
-          if (minClustering) {
-            sim = cluster.maxSimilarity(clusters.get(b), simMatrix);
-          } else if (maxClustering) {
-            sim = cluster.minSimilarity(clusters.get(b), simMatrix);
-          } else {
-            sim = cluster.avrSimilarity(clusters.get(b), simMatrix);
-          }
-          if (sim > maxSim) {
-            maxSim = sim;
-            indexA = a;
-            indexB = b;
-          }
+        ArrayList<Cluster> clusters = new ArrayList<Cluster>(submissions.size());
+        for (int i = 0; i < nrOfSubmissions; i++) {
+            clusters.add(new Cluster(i, this));
         }
-      }
 
-      if (maxSim > maxMergeValue) {
-        maxMergeValue = maxSim;
-      }
+        while (clusters.size() > 1) {
+            int indexA = -1, indexB = -1;
+            float maxSim = -1;
+            int nrOfClusters = clusters.size();
 
-      // now merge these clusters
-      Cluster clusterA = clusters.get(indexA);
-      Cluster clusterB = clusters.get(indexB);
-      clusters.remove(clusterA);
-      clusters.remove(clusterB);
-      clusters.add(new Cluster(clusterA, clusterB, maxSim, this));
+            // find similarity
+            for (int a = 0; a < (nrOfClusters - 1); a++) {
+                Cluster cluster = clusters.get(a);
+                for (int b = a + 1; b < nrOfClusters; b++) {
+                    float sim;
+                    if (minClustering) {
+                        sim = cluster.maxSimilarity(clusters.get(b), simMatrix);
+                    } else if (maxClustering) {
+                        sim = cluster.minSimilarity(clusters.get(b), simMatrix);
+                    } else {
+                        sim = cluster.avrSimilarity(clusters.get(b), simMatrix);
+                    }
+                    if (sim > maxSim) {
+                        maxSim = sim;
+                        indexA = a;
+                        indexB = b;
+                    }
+                }
+            }
+
+            if (maxSim > maxMergeValue) {
+                maxMergeValue = maxSim;
+            }
+
+            // now merge these clusters
+            Cluster clusterA = clusters.get(indexA);
+            Cluster clusterB = clusters.get(indexB);
+            clusters.remove(clusterA);
+            clusters.remove(clusterB);
+            clusters.add(new Cluster(clusterA, clusterB, maxSim, this));
+        }
+        return clusters.get(0);
     }
-    return clusters.get(0);
-  }
 }

+ 52 - 52
jplag/src/main/java/jplag/clustering/SimilarityMatrix.java

@@ -2,66 +2,66 @@ package jplag.clustering;
 
 public class SimilarityMatrix {
 
-  private int size;
-  private float[] matrix;
-//   private float maximum = 0;
+    private int size;
+    private float[] matrix;
+    // private float maximum = 0;
 
-  /**
-   * The parameter is the number of submissions.
-   */
-  public SimilarityMatrix(int size) {
-    this.size = size;
-    matrix = new float[size * (size + 1) / 2];
-  }
-
-  public int size() {
-    return size;
-  }
-
-  public void setSimilarity(int a, int b, float sim) {
-    int tmp;
-    if (a >= size || b >= size) {
-      throw new ArrayIndexOutOfBoundsException();
-    }
-    if (a > b) {
-      tmp = a;
-      a = b;
-      b = tmp;
+    /**
+     * The parameter is the number of submissions.
+     */
+    public SimilarityMatrix(int size) {
+        this.size = size;
+        matrix = new float[size * (size + 1) / 2];
     }
-    matrix[a + (b * (b - 1) / 2)] = sim;
 
-//     if (sim > maximum)
-//       maximum = sim;
-  }
+    public int size() {
+        return size;
+    }
 
-  //  public float getMaximum() { return maximum; }
+    public void setSimilarity(int a, int b, float sim) {
+        int tmp;
+        if (a >= size || b >= size) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+        if (a > b) {
+            tmp = a;
+            a = b;
+            b = tmp;
+        }
+        matrix[a + (b * (b - 1) / 2)] = sim;
 
-  public float getSimilarity(int a, int b) {
-    int tmp;
-    if (a >= size || b >= size) {
-      throw new ArrayIndexOutOfBoundsException();
+        // if (sim > maximum)
+        // maximum = sim;
     }
-    if (a > b) {
-      tmp = a;
-      a = b;
-      b = tmp;
+
+    // public float getMaximum() { return maximum; }
+
+    public float getSimilarity(int a, int b) {
+        int tmp;
+        if (a >= size || b >= size) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+        if (a > b) {
+            tmp = a;
+            a = b;
+            b = tmp;
+        }
+        return matrix[a + (b * (b - 1) / 2)];
     }
-    return matrix[a + (b * (b - 1) / 2)];
-  }
 
-  @Override
-public String toString() {
-    String tmp = "";
-    for (int a = 0; a < size; a++) {
-      for (int b = a + 1; b < size; b++) {
-        int length = tmp.length();
-        tmp += (int) getSimilarity(a, b);
-        while (tmp.length() < length + 3) {
-          tmp += " ";
+    @Override
+    public String toString() {
+        String tmp = "";
+        for (int a = 0; a < size; a++) {
+            for (int b = a + 1; b < size; b++) {
+                int length = tmp.length();
+                tmp += (int) getSimilarity(a, b);
+                while (tmp.length() < length + 3) {
+                    tmp += " ";
+                }
+            }
+            tmp += "\n";
         }
-      }
-      tmp += "\n";
+        return tmp;
     }
-    return tmp;
-  }
 }

+ 4 - 4
jplag/src/main/java/jplag/options/ClusterType.java

@@ -1,8 +1,8 @@
 package jplag.options;
 
 public enum ClusterType {
-  NONE,
-  MIN,
-  MAX,
-  AVG
+    NONE,
+    MIN,
+    MAX,
+    AVG
 }

+ 35 - 35
jplag/src/main/java/jplag/options/LanguageOption.java

@@ -4,44 +4,44 @@ package jplag.options;
  * The available languages.
  */
 public enum LanguageOption {
-  JAVA_1_1("jplag.javax.Language"),
-  JAVA_1_2("jplag.java.Language"),
-  JAVA_1_5("jplag.java15.Language"),
-  JAVA_1_5_DM("jplag.java15.LanguageWithDelimitedMethods"),
-  JAVA_1_7("jplag.java17.Language"),
-  JAVA_1_9("jplag.java19.Language"),
-  PYTHON_3("jplag.python3.Language"),
-  C_CPP("jplag.cpp.Language"),
-  C_SHARP("jplag.csharp.Language"),
-  CHAR("jplag.chars.Language"),
-  TEXT("jplag.text.Language"),
-  SCHEME("jplag.scheme.Language");
+    JAVA_1_1("jplag.javax.Language"),
+    JAVA_1_2("jplag.java.Language"),
+    JAVA_1_5("jplag.java15.Language"),
+    JAVA_1_5_DM("jplag.java15.LanguageWithDelimitedMethods"),
+    JAVA_1_7("jplag.java17.Language"),
+    JAVA_1_9("jplag.java19.Language"),
+    PYTHON_3("jplag.python3.Language"),
+    C_CPP("jplag.cpp.Language"),
+    C_SHARP("jplag.csharp.Language"),
+    CHAR("jplag.chars.Language"),
+    TEXT("jplag.text.Language"),
+    SCHEME("jplag.scheme.Language");
 
-  private final String classPath;
+    private final String classPath;
 
-  LanguageOption(String classPath) {
-    this.classPath = classPath;
-  }
+    LanguageOption(String classPath) {
+        this.classPath = classPath;
+    }
 
-  public String getClassPath() {
-    return this.classPath;
-  }
+    public String getClassPath() {
+        return this.classPath;
+    }
 
-  public static LanguageOption fromOption(String optionName) {
-    switch(optionName) {
-      case "java_1_1": return JAVA_1_1;
-      case "java_1_2": return JAVA_1_2;
-      case "java_1_5": return JAVA_1_5;
-      case "java_1_5_dm": return JAVA_1_5_DM;
-      case "java_1_7": return JAVA_1_7;
-      case "java_1_9": return JAVA_1_9;
-      case "python_3": return PYTHON_3;
-      case "c_cpp": return C_CPP;
-      case "c_sharp": return C_SHARP;
-      case "char": return CHAR;
-      case "text": return TEXT;
-      case "scheme": return SCHEME;
-      default: return JAVA_1_9;
+    public static LanguageOption fromOption(String optionName) {
+        switch(optionName) {
+            case "java_1_1": return JAVA_1_1;
+            case "java_1_2": return JAVA_1_2;
+            case "java_1_5": return JAVA_1_5;
+            case "java_1_5_dm": return JAVA_1_5_DM;
+            case "java_1_7": return JAVA_1_7;
+            case "java_1_9": return JAVA_1_9;
+            case "python_3": return PYTHON_3;
+            case "c_cpp": return C_CPP;
+            case "c_sharp": return C_SHARP;
+            case "char": return CHAR;
+            case "text": return TEXT;
+            case "scheme": return SCHEME;
+            default: return JAVA_1_9;
+        }
     }
-  }
 }

+ 3 - 3
jplag/src/main/java/jplag/options/SimilarityMetric.java

@@ -1,7 +1,7 @@
 package jplag.options;
 
 public enum SimilarityMetric {
-  AVG,
-  MIN,
-  MAX
+    AVG,
+    MIN,
+    MAX
 }

+ 17 - 12
jplag/src/main/java/jplag/options/Verbosity.java

@@ -1,18 +1,23 @@
 package jplag.options;
 
 public enum Verbosity {
-  PARSER,
-  QUIET,
-  LONG,
-  DETAILS;
+    PARSER,
+    QUIET,
+    LONG,
+    DETAILS;
 
-  public static Verbosity fromOption(String optionName) {
-    switch(optionName) {
-      case "parser": return PARSER;
-      case "quiet": return QUIET;
-      case "long": return LONG;
-      case "details": return DETAILS;
-      default: return QUIET;
+    public static Verbosity fromOption(String optionName) {
+        switch (optionName) {
+        case "parser":
+            return PARSER;
+        case "quiet":
+            return QUIET;
+        case "long":
+            return LONG;
+        case "details":
+            return DETAILS;
+        default:
+            return QUIET;
+        }
     }
-  }
 }

+ 41 - 42
jplag/src/main/java/jplag/reporting/BufferedCounter.java

@@ -4,49 +4,48 @@ import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.Writer;
 
-/* This class counts the number of printed characters.
+/*
+ * This class counts the number of printed characters.
  */
 public class BufferedCounter extends BufferedWriter {
 
-  private int count;
-
-  public BufferedCounter(Writer out) {
-    super(out);
-    count = 0;
-  }
-
-  public BufferedCounter(Writer out, int sz) {
-    super(out, sz);
-    count = 0;
-  }
-
-  @Override
-public void write(int c) throws IOException {
-    super.write(c);
-    count++;
-  }
-
-  @Override
-public void write(char[] cbuf, int off, int len) throws IOException {
-    super.write(cbuf, off, len);
-    count += len;
-  }
-
-  @Override
-public void write(String s, int off, int len) throws IOException {
-    super.write(s, off, len);
-    count += len;
-  }
-
-  @Override
-public void newLine() throws IOException {
-    super.newLine();
-    count++;
-  }
-
-  public int bytesWritten() {
-    return count;
-  }
+    private int count;
+
+    public BufferedCounter(Writer out) {
+        super(out);
+        count = 0;
+    }
+
+    public BufferedCounter(Writer out, int sz) {
+        super(out, sz);
+        count = 0;
+    }
+
+    @Override
+    public void write(int c) throws IOException {
+        super.write(c);
+        count++;
+    }
+
+    @Override
+    public void write(char[] cbuf, int off, int len) throws IOException {
+        super.write(cbuf, off, len);
+        count += len;
+    }
+
+    @Override
+    public void write(String s, int off, int len) throws IOException {
+        super.write(s, off, len);
+        count += len;
+    }
+
+    @Override
+    public void newLine() throws IOException {
+        super.newLine();
+        count++;
+    }
+
+    public int bytesWritten() {
+        return count;
+    }
 }
-
-

+ 405 - 413
jplag/src/main/java/jplag/reporting/Colors.java

@@ -2,424 +2,416 @@ package jplag.reporting;
 
 public class Colors {
 
-  static public final String[] colors = {
+    static public final String[] colors = {
 
-      //"#eff7ff", "AliceBlue ",
-      //"#f9e8d2", "AntiqueWhite ",
-      //"#feedd6", "AntiqueWhite1 ",
-      //"#ebdbc5", "AntiqueWhite2 ",
-      //"#c8b9a6", "AntiqueWhite3 ",
-      //"#817468", "AntiqueWhite4 ",
-      ///"#43b7ba", "Aquamarine ",
-      //"#87fdce", "aquamarine1 ",
-      //"#7deabe", "aquamarine2 ",
-      //"#69c69f", "aquamarine3 ",
-      //#417c64", "aquamarine4 ",
-      //"#efffff", "azure ",
-      //"#deecec", "azure2 ",
-      //"#bcc7c7", "azure3 ",
-      //"#7a7d7d", "azure4 ",
-      //"#f5f3d7", "beige ",
-      //"#fde0bc", "bisque ",
-      //"#ead0ae", "bisque2 ",
-      //"#c7af92", "bisque3 ",
-      //"#816e59", "bisque4 ",
-      //"#000000", "Black ",
-      //"#fee8c6", "BlanchedAlmond ",
-      "#0000ff", "Blue ",
-      //"#1535ff", "blue1 ",
-      //"#1531ec", "blue2 ",
-      //"#1528c7", "blue3 ",
-      //"#151b7e", "blue4 ",
-      //"#7931df", "BlueViolet ",
-      "#f63526", "brown1 ",
-      //"#e42d17", "brown2 ",
-      //"#c22217", "brown3 ",
-      //"#fcce8e", "burlywood1 ",
-      //"#eabe83", "burlywood2 ",
-      //"#c6a06d", "burlywood3 ",
-      //"#806341", "burlywood4 ",
-      //"#578693", "CadetBlue ",
-      //"#99f3ff", "CadetBlue1 ",
-      //"#8ee2ec", "CadetBlue2 ",
-      "#77bfc7", "CadetBlue3 ",
-      //"#4c787e", "CadetBlue4 ",
-      //"#8afb17", "chartreuse ",
-      //"#7fe817", "chartreuse2 ",
-      "#6cc417", "chartreuse3 ",
-      //"#437c17", "chartreuse4 ",
-      //"#c85a17", "chocolate ",
-      //"#f76541", "Coral ",
-      //"#e55b3c", "coral2 ",
-      //"#c34a2c", "coral3 ",
-      //"#7e2817", "coral4 ",
-      "#151b8d", "CornflowerBlue ",
-      //"#fff7d7", "cornsilk ",
-      //"#ece5c6", "cornsilk2 ",
-      "#c8c2a7", "cornsilk3 ",
-      //"#817a68", "cornsilk4 ",
-      //"#00ffff", "Cyan ",
-      //"#57feff", "cyan1 ",
-      "#50ebec", "cyan2 ",
-      //"#46c7c7", "cyan3 ",
-      //"#307d7e", "cyan4 ",
-      //"#af7817", "DarkGoldenrod ",
-      //"#fbb117", "DarkGoldenrod1 ",
-      //"#e8a317", "DarkGoldenrod2 ",
-      "#c58917", "DarkGoldenrod3 ",
-      //"#7f5217", "DarkGoldenrod4 ",
-      //"#254117", "DarkGreen ",
-      //"#b7ad59", "DarkKhaki ",
-      //"#4a4117", "DarkOliveGreen ",
-      //"#ccfb5d", "DarkOliveGreen1 ",
-      "#bce954", "DarkOliveGreen2 ",
-      //"#a0c544", "DarkOliveGreen3 ",
-      //"#667c26", "DarkOliveGreen4 ",
-      "#f88017", "DarkOrange ",
-      //"#f87217", "DarkOrange1 ",
-      //"#e56717", "DarkOrange2 ",
-      //"#c35617", "DarkOrange3 ",
-      //"#7e3117", "DarkOrange4 ",
-      //"#7d1b7e", "DarkOrchid ",
-      "#b041ff", "DarkOrchid1 ",
-      //"#a23bec", "DarkOrchid2 ",
-      //"#8b31c7", "DarkOrchid3 ",
-      "#571b7e", "DarkOrchid4 ",
-      //"#e18b6b", "DarkSalmon ",
-      //"#8bb381", "DarkSeaGreen ",
-      //"#c3fdb8", "DarkSeaGreen1 ",
-      //"#b5eaaa", "DarkSeaGreen2 ",
-      //"#99c68e", "DarkSeaGreen3 ",
-      //"#617c58", "DarkSeaGreen4 ",
-      //"#2b3856", "DarkSlateBlue ",
-      //"#25383c", "DarkSlateGray ",
-      //"#9afeff", "DarkSlateGray1 ",
-      //"#8eebec", "DarkSlateGray2 ",
-      //"#78c7c7", "DarkSlateGray3 ",
-      //"#4c7d7e", "DarkSlateGray4 ",
-      "#3b9c9c", "DarkTurquoise ",
-      "#842dce", "DarkViolet ",
-      "#f52887", "DeepPink ",
-      //"#e4287c", "DeepPink2 ",
-      //"#c12267", "DeepPink3 ",
-      //"#7d053f", "DeepPink4 ",
-      "#3bb9ff", "DeepSkyBlue ",
-      //"#38acec", "DeepSkyBlue2 ",
-      "#3090c7", "DeepSkyBlue3 ",
-      //"#25587e", "DeepSkyBlue4 ",
-      //"#463e41", "DimGray ",
-      //"#1589ff", "DodgerBlue ",
-      //"#157dec", "DodgerBlue2 ",
-      //"#1569c7", "DodgerBlue3 ",
-      //"#153e7e", "DodgerBlue4 ",
-      "#800517", "Firebrick ",
-      "#f62817", "firebrick1 ",
-      //"#e42217", "firebrick2 ",
-      //"#c11b17", "firebrick3 ",
-      //"#fff9ee", "FloralWhite ",
-      "#4e9258", "ForestGreen ",
-      //"#d8d9d7", "gainsboro ",
-      //"#f7f7ff", "GhostWhite ",
-      "#d4a017", "Gold ",
-      //"#fdd017", "gold1 ",
-      //"#eac117", "gold2 ",
-      //"#c7a317", "gold3 ",
-      //"#806517", "gold4 ",
-      //"#edda74", "Goldenrod ",
-      //"#fbb917", "goldenrod1 ",
-      //"#e9ab17", "goldenrod2 ",
-      //"#c68e17", "goldenrod3 ",
-      //"#805817", "goldenrod4 ",
-      "#00ff00", "Green ",
-      //"#5ffb17", "green1 ",
-      //"#59e817", "green2 ",
-      "#4cc417", "green3 ",
-      //"#347c17", "green4 ",
-      //"#b1fb17", "GreenYellow ",
-      //"#f0feee", "honeydew ",
-      //"#deebdc", "honeydew2 ",
-      //"#bcc7b9", "honeydew3 ",
-      //"#7a7d74", "honeydew4 ",
-      "#f660ab", "HotPink ",
-      //"#f665ab", "HotPink1 ",
-      //"#e45e9d", "HotPink2 ",
-      //"#c25283", "HotPink3 ",
-      //"#7d2252", "HotPink4 ",
-      //"#5e2217", "IndianRed ",
-      //"#f75d59", "IndianRed1 ",
-      //"#e55451", "IndianRed2 ",
-      //"#c24641", "IndianRed3 ",
-      //"#7e2217", "IndianRed4 ",
-      //"#ffffee", "ivory ",
-      //"#ececdc", "ivory2 ",
-      //"#c9c7b9", "ivory3 ",
-      //"#817d74", "ivory4 ",
-      "#ada96e", "Khaki ",
-      //"#fff380", "khaki1 ",
-      //"#ede275", "khaki2 ",
-      //"#c9be62", "khaki3 ",
-      //"#827839", "khaki4 ",
-      //"#e3e4fa", "lavender ",
-      //"#fdeef4", "LavenderBlush ",
-      //"#ebdde2", "LavenderBlush2 ",
-      //"#c8bbbe", "LavenderBlush3 ",
-      //"#817679", "LavenderBlush4 ",
-      "#87f717", "LawnGreen ",
-      //"#fff8c6", "LemonChiffon ",
-      //"#ece5b6", "LemonChiffon2 ",
-      //"#c9c299", "LemonChiffon3 ",
-      //"#827b60", "LemonChiffon4 ",
-      //"#addfff", "LightBlue ",
-      //"#bdedff", "LightBlue1 ",
-      //"#afdcec", "LightBlue2 ",
-      "#95b9c7", "LightBlue3 ",
-      //"#5e767e", "LightBlue4 ",
-      "#e77471", "LightCoral ",
-      //"#e0ffff", "LightCyan ",
-      //"#cfecec", "LightCyan2 ",
-      //"#afc7c7", "LightCyan3 ",
-      "#717d7d", "LightCyan4 ",
-      //"#ecd872", "LightGoldenrod ",
-      //"#ffe87c", "LightGoldenrod1 ",
-      //"#ecd672", "LightGoldenrod2 ",
-      //"#c8b560", "LightGoldenrod3 ",
-      //"#817339", "LightGoldenrod4 ",
-      //"#faf8cc", "LightGoldenrodYellow ",
-      "#faafba", "LightPink ",
-      //"#f9a7b0", "LightPink1 ",
-      //"#e799a3", "LightPink2 ",
-      //"#c48189", "LightPink3 ",
-      //"#7f4e52", "LightPink4 ",
-      "#f9966b", "LightSalmon ",
-      //"#e78a61", "LightSalmon2 ",
-      //"#c47451", "LightSalmon3 ",
-      //"#7f462c", "LightSalmon4 ",
-      "#3ea99f", "LightSeaGreen ",
-      "#82cafa", "LightSkyBlue ",
-      //"#a0cfec", "LightSkyBlue2 ",
-      //"#87afc7", "LightSkyBlue3 ",
-      //"#566d7e", "LightSkyBlue4 ",
-      "#736aff", "LightSlateBlue ",
-      //"#6d7b8d", "LightSlateGray ",
-      //"#728fce", "LightSteelBlue ",
-      //"#c6deff", "LightSteelBlue1 ",
-      //"#b7ceec", "LightSteelBlue2 ",
-      //"#9aadc7", "LightSteelBlue3 ",
-      //"#646d7e", "LightSteelBlue4 ",
-      //"#fffedc", "LightYellow ",
-      //"#edebcb", "LightYellow2 ",
-      //"#c9c7aa", "LightYellow3 ",
-      "#827d6b", "LightYellow4 ",
-      "#41a317", "LimeGreen ",
-      //"#f9eee2", "linen ",
-      "#ff00ff", "Magenta ",
-      //"#f43eff", "magenta1 ",
-      //"#e238ec", "magenta2 ",
-      //"#c031c7", "magenta3 ",
-      "#810541", "Maroon ",
-      //"#f535aa", "maroon1 ",
-      //"#e3319d", "maroon2 ",
-      //"#c12283", "maroon3 ",
-      //"#7d0552", "maroon4 ",
-      "#348781", "MediumAquamarine ",
-      "#152dc6", "MediumBlue ",
-      "#347235", "MediumForestGreen ",
-      //"#ccb954", "MediumGoldenrod ",
-      //"#b048b5", "MediumOrchid ",
-      //"#d462ff", "MediumOrchid1 ",
-      //"#c45aec", "MediumOrchid2 ",
-      //"#a74ac7", "MediumOrchid3 ",
-      //"#6a287e", "MediumOrchid4 ",
-      //"#8467d7", "MediumPurple ",
-      //"#9e7bff", "MediumPurple1 ",
-      //"#9172ec", "MediumPurple2 ",
-      //"#7a5dc7", "MediumPurple3 ",
-      //"#4e387e", "MediumPurple4 ",
-      //"#306754", "MediumSeaGreen ",
-      //"#5e5a80", "MediumSlateBlue ",
-      //"#348017", "MediumSpringGreen ",
-      //"#48cccd", "MediumTurquoise ",
-      //"#ca226b", "MediumVioletRed ",
-      //"#151b54", "MidnightBlue ",
-      //"#f5fff9", "MintCream ",
-      //"#fde1dd", "MistyRose ",
-      //"#ead0cc", "MistyRose2 ",
-      //"#c6afac", "MistyRose3 ",
-      //"#806f6c", "MistyRose4 ",
-      //"#fde0ac", "moccasin ",
-      //"#fddaa3", "NavajoWhite ",
-      //"#eac995", "NavajoWhite2 ",
-      //"#c7aa7d", "NavajoWhite3 ",
-      //"#806a4b", "NavajoWhite4 ",
-      //"#150567", "Navy ",
-      //"#fcf3e2", "OldLace ",
-      //"#658017", "OliveDrab ",
-      //"#c3fb17", "OliveDrab1 ",
-      //"#b5e917", "OliveDrab2 ",
-      //"#99c517", "OliveDrab3 ",
-      //"#617c17", "OliveDrab4 ",
-      "#f87a17", "Orange ",
-      //"#fa9b17", "orange1 ",
-      //"#e78e17", "orange2 ",
-      "#c57717", "orange3 ",
-      //"#7f4817", "orange4 ",
-      //"#f63817", "OrangeRed ",
-      //"#e43117", "OrangeRed2 ",
-      "#c22817", "OrangeRed3 ",
-      //"#7e0517", "OrangeRed4 ",
-      "#e57ded", "Orchid ",
-      //"#f67dfa", "orchid1 ",
-      //"#e473e7", "orchid2 ",
-      //"#c160c3", "orchid3 ",
-      //"#7d387c", "orchid4 ",
-      //"#ede49e", "PaleGoldenrod ",
-      "#79d867", "PaleGreen ",
-      //"#a0fc8d", "PaleGreen1 ",
-      //"#94e981", "PaleGreen2 ",
-      //"#7dc56c", "PaleGreen3 ",
-      //"#4e7c41", "PaleGreen4 ",
-      //"#aeebec", "PaleTurquoise ",
-      //"#bcfeff", "PaleTurquoise1 ",
-      //"#adebec", "PaleTurquoise2 ",
-      "#92c7c7", "PaleTurquoise3 ",
-      //"#5e7d7e", "PaleTurquoise4 ",
-      "#d16587", "PaleVioletRed ",
-      //"#f778a1", "PaleVioletRed1 ",
-      //"#e56e94", "PaleVioletRed2 ",
-      //"#c25a7c", "PaleVioletRed3 ",
-      //"#7e354d", "PaleVioletRed4 ",
-      //"#feeccf", "PapayaWhip ",
-      //"#fcd5b0", "PeachPuff ",
-      //"#eac5a3", "PeachPuff2 ",
-      //"#c6a688", "PeachPuff3 ",
-      //"#806752", "PeachPuff4 ",
-      "#c57726", "peru ",
-      //"#faafbe", "Pink ",
-      //"#e7a1b0", "pink2 ",
-      //"#c48793", "pink3 ",
-      //"#7f525d", "pink4 ",
-      //"#b93b8f", "Plum ",
-      //"#f9b7ff", "plum1 ",
-      //"#e6a9ec", "plum2 ",
-      //"#c38ec7", "plum3 ",
-      //"#7e587e", "plum4 ",
-      //"#addce3", "PowderBlue ",
-      "#8e35ef", "purple ",
-      //"#893bff", "purple1 ",
-      //"#7f38ec", "purple2 ",
-      //"#6c2dc7", "purple3 ",
-      //"#461b7e", "purple4 ",
-      "#ff0000", "Red ",
-      //"#f62217", "red1 ",
-      //"#e41b17", "red2 ",
-      "#b38481", "RosyBrown ",
-      //"#fbbbb9", "RosyBrown1 ",
-      //"#e8adaa", "RosyBrown2 ",
-      //"#c5908e", "RosyBrown3 ",
-      //"#7f5a58", "RosyBrown4 ",
-      "#2b60de", "RoyalBlue ",
-      //"#306eff", "RoyalBlue1 ",
-      //"#2b65ec", "RoyalBlue2 ",
-      //"#2554c7", "RoyalBlue3 ",
-      //"#15317e", "RoyalBlue4 ",
-      "#f88158", "salmon1 ",
-      //"#e67451", "salmon2 ",
-      //"#c36241", "salmon3 ",
-      //"#7e3817", "salmon4 ",
-      //"#ee9a4d", "SandyBrown ",
-      "#4e8975", "SeaGreen ",
-      //"#6afb92", "SeaGreen1 ",
-      //"#64e986", "SeaGreen2 ",
-      //"#54c571", "SeaGreen3 ",
-      //"#387c44", "SeaGreen4 ",
-      //"#fef3eb", "seashell ",
-      //"#ebe2d9", "seashell2 ",
-      //"#c8bfb6", "seashell3 ",
-      //"#817873", "seashell4 ",
-      //"#8a4117", "Sienna ",
-      //"#f87431", "sienna1 ",
-      //"#e66c2c", "sienna2 ",
-      //"#c35817", "sienna3 ",
-      //"#7e3517", "sienna4 ",
-      //"#6698ff", "SkyBlue ",
-      //"#82caff", "SkyBlue1 ",
-      //"#79baec", "SkyBlue2 ",
-      //"#659ec7", "SkyBlue3 ",
-      //"#41627e", "SkyBlue4 ",
-      //"#737ca1", "SlateBlue ",
-      //"#7369ff", "SlateBlue1 ",
-      //"#6960ec", "SlateBlue2 ",
-      //"#574ec7", "SlateBlue3 ",
-      //"#342d7e", "SlateBlue4 ",
-      //"#657383", "SlateGray ",
-      //"#c2dfff", "SlateGray1 ",
-      //"#b4cfec", "SlateGray2 ",
-      //"#98afc7", "SlateGray3 ",
-      //"#616d7e", "SlateGray4 ",
-      //"#fff9fa", "snow ",
-      //"#ece7e6", "snow2 ",
-      //"#c8c4c2", "snow3 ",
-      //"#817c7b", "snow4 ",
-      //"#4aa02c", "SpringGreen ",
-      //"#5efb6e", "SpringGreen1 ",
-      //"#57e964", "SpringGreen2 ",
-      //"#4cc552", "SpringGreen3 ",
-      //"#347c2c", "SpringGreen4 ",
-      "#4863a0", "SteelBlue ",
-      //"#5cb3ff", "SteelBlue1 ",
-      //"#56a5ec", "SteelBlue2 ",
-      //"#488ac7", "SteelBlue3 ",
-      //"#2b547e", "SteelBlue4 ",
-      //"#d8af79", "Tan ",
-      //"#fa9b3c", "tan1 ",
-      //"#e78e35", "tan2 ",
-      //"#d2b9d3", "Thistle ",
-      //"#fcdfff", "thistle1 ",
-      //"#e9cfec", "thistle2 ",
-      //"#c6aec7", "thistle3 ",
-      //"#806d7e", "thistle4 ",
-      //"#f75431", "tomato ",
-      //"#e54c2c", "tomato2 ",
-      //"#c23e17", "tomato3 ",
-      //"#43c6db", "Turquoise ",
-      //"#52f3ff", "turquoise1 ",
-      //"#4ee2ec", "turquoise2 ",
-      //"#43bfc7", "turquoise3 ",
-      //"#30787e", "turquoise4 ",
-      //"#8d38c9", "Violet ",
-      //"#e9358a", "VioletRed ",
-      //"#f6358a", "VioletRed1 ",
-      //"#e4317f", "VioletRed2 ",
-      //"#c12869", "VioletRed3 ",
-      //"#7d0541", "VioletRed4 ",
-      //"#f3daa9", "Wheat ",
-      //"#fee4b1", "wheat1 ",
-      //"#ebd3a3", "wheat2 ",
-      //"#c8b189", "wheat3 ",
-      //"#816f54", "wheat4 ",
-      //"#ffff00", "Yellow ",
-      //"#fffc17", "yellow1 ",
-      "#52d017", "YellowGreen ",
+            // "#eff7ff", "AliceBlue ",
+            // "#f9e8d2", "AntiqueWhite ",
+            // "#feedd6", "AntiqueWhite1 ",
+            // "#ebdbc5", "AntiqueWhite2 ",
+            // "#c8b9a6", "AntiqueWhite3 ",
+            // "#817468", "AntiqueWhite4 ",
+            /// "#43b7ba", "Aquamarine ",
+            // "#87fdce", "aquamarine1 ",
+            // "#7deabe", "aquamarine2 ",
+            // "#69c69f", "aquamarine3 ",
+            // #417c64", "aquamarine4 ",
+            // "#efffff", "azure ",
+            // "#deecec", "azure2 ",
+            // "#bcc7c7", "azure3 ",
+            // "#7a7d7d", "azure4 ",
+            // "#f5f3d7", "beige ",
+            // "#fde0bc", "bisque ",
+            // "#ead0ae", "bisque2 ",
+            // "#c7af92", "bisque3 ",
+            // "#816e59", "bisque4 ",
+            // "#000000", "Black ",
+            // "#fee8c6", "BlanchedAlmond ",
+            "#0000ff", "Blue ",
+            // "#1535ff", "blue1 ",
+            // "#1531ec", "blue2 ",
+            // "#1528c7", "blue3 ",
+            // "#151b7e", "blue4 ",
+            // "#7931df", "BlueViolet ",
+            "#f63526", "brown1 ",
+            // "#e42d17", "brown2 ",
+            // "#c22217", "brown3 ",
+            // "#fcce8e", "burlywood1 ",
+            // "#eabe83", "burlywood2 ",
+            // "#c6a06d", "burlywood3 ",
+            // "#806341", "burlywood4 ",
+            // "#578693", "CadetBlue ",
+            // "#99f3ff", "CadetBlue1 ",
+            // "#8ee2ec", "CadetBlue2 ",
+            "#77bfc7", "CadetBlue3 ",
+            // "#4c787e", "CadetBlue4 ",
+            // "#8afb17", "chartreuse ",
+            // "#7fe817", "chartreuse2 ",
+            "#6cc417", "chartreuse3 ",
+            // "#437c17", "chartreuse4 ",
+            // "#c85a17", "chocolate ",
+            // "#f76541", "Coral ",
+            // "#e55b3c", "coral2 ",
+            // "#c34a2c", "coral3 ",
+            // "#7e2817", "coral4 ",
+            "#151b8d", "CornflowerBlue ",
+            // "#fff7d7", "cornsilk ",
+            // "#ece5c6", "cornsilk2 ",
+            "#c8c2a7", "cornsilk3 ",
+            // "#817a68", "cornsilk4 ",
+            // "#00ffff", "Cyan ",
+            // "#57feff", "cyan1 ",
+            "#50ebec", "cyan2 ",
+            // "#46c7c7", "cyan3 ",
+            // "#307d7e", "cyan4 ",
+            // "#af7817", "DarkGoldenrod ",
+            // "#fbb117", "DarkGoldenrod1 ",
+            // "#e8a317", "DarkGoldenrod2 ",
+            "#c58917", "DarkGoldenrod3 ",
+            // "#7f5217", "DarkGoldenrod4 ",
+            // "#254117", "DarkGreen ",
+            // "#b7ad59", "DarkKhaki ",
+            // "#4a4117", "DarkOliveGreen ",
+            // "#ccfb5d", "DarkOliveGreen1 ",
+            "#bce954", "DarkOliveGreen2 ",
+            // "#a0c544", "DarkOliveGreen3 ",
+            // "#667c26", "DarkOliveGreen4 ",
+            "#f88017", "DarkOrange ",
+            // "#f87217", "DarkOrange1 ",
+            // "#e56717", "DarkOrange2 ",
+            // "#c35617", "DarkOrange3 ",
+            // "#7e3117", "DarkOrange4 ",
+            // "#7d1b7e", "DarkOrchid ",
+            "#b041ff", "DarkOrchid1 ",
+            // "#a23bec", "DarkOrchid2 ",
+            // "#8b31c7", "DarkOrchid3 ",
+            "#571b7e", "DarkOrchid4 ",
+            // "#e18b6b", "DarkSalmon ",
+            // "#8bb381", "DarkSeaGreen ",
+            // "#c3fdb8", "DarkSeaGreen1 ",
+            // "#b5eaaa", "DarkSeaGreen2 ",
+            // "#99c68e", "DarkSeaGreen3 ",
+            // "#617c58", "DarkSeaGreen4 ",
+            // "#2b3856", "DarkSlateBlue ",
+            // "#25383c", "DarkSlateGray ",
+            // "#9afeff", "DarkSlateGray1 ",
+            // "#8eebec", "DarkSlateGray2 ",
+            // "#78c7c7", "DarkSlateGray3 ",
+            // "#4c7d7e", "DarkSlateGray4 ",
+            "#3b9c9c", "DarkTurquoise ", "#842dce", "DarkViolet ", "#f52887", "DeepPink ",
+            // "#e4287c", "DeepPink2 ",
+            // "#c12267", "DeepPink3 ",
+            // "#7d053f", "DeepPink4 ",
+            "#3bb9ff", "DeepSkyBlue ",
+            // "#38acec", "DeepSkyBlue2 ",
+            "#3090c7", "DeepSkyBlue3 ",
+            // "#25587e", "DeepSkyBlue4 ",
+            // "#463e41", "DimGray ",
+            // "#1589ff", "DodgerBlue ",
+            // "#157dec", "DodgerBlue2 ",
+            // "#1569c7", "DodgerBlue3 ",
+            // "#153e7e", "DodgerBlue4 ",
+            "#800517", "Firebrick ", "#f62817", "firebrick1 ",
+            // "#e42217", "firebrick2 ",
+            // "#c11b17", "firebrick3 ",
+            // "#fff9ee", "FloralWhite ",
+            "#4e9258", "ForestGreen ",
+            // "#d8d9d7", "gainsboro ",
+            // "#f7f7ff", "GhostWhite ",
+            "#d4a017", "Gold ",
+            // "#fdd017", "gold1 ",
+            // "#eac117", "gold2 ",
+            // "#c7a317", "gold3 ",
+            // "#806517", "gold4 ",
+            // "#edda74", "Goldenrod ",
+            // "#fbb917", "goldenrod1 ",
+            // "#e9ab17", "goldenrod2 ",
+            // "#c68e17", "goldenrod3 ",
+            // "#805817", "goldenrod4 ",
+            "#00ff00", "Green ",
+            // "#5ffb17", "green1 ",
+            // "#59e817", "green2 ",
+            "#4cc417", "green3 ",
+            // "#347c17", "green4 ",
+            // "#b1fb17", "GreenYellow ",
+            // "#f0feee", "honeydew ",
+            // "#deebdc", "honeydew2 ",
+            // "#bcc7b9", "honeydew3 ",
+            // "#7a7d74", "honeydew4 ",
+            "#f660ab", "HotPink ",
+            // "#f665ab", "HotPink1 ",
+            // "#e45e9d", "HotPink2 ",
+            // "#c25283", "HotPink3 ",
+            // "#7d2252", "HotPink4 ",
+            // "#5e2217", "IndianRed ",
+            // "#f75d59", "IndianRed1 ",
+            // "#e55451", "IndianRed2 ",
+            // "#c24641", "IndianRed3 ",
+            // "#7e2217", "IndianRed4 ",
+            // "#ffffee", "ivory ",
+            // "#ececdc", "ivory2 ",
+            // "#c9c7b9", "ivory3 ",
+            // "#817d74", "ivory4 ",
+            "#ada96e", "Khaki ",
+            // "#fff380", "khaki1 ",
+            // "#ede275", "khaki2 ",
+            // "#c9be62", "khaki3 ",
+            // "#827839", "khaki4 ",
+            // "#e3e4fa", "lavender ",
+            // "#fdeef4", "LavenderBlush ",
+            // "#ebdde2", "LavenderBlush2 ",
+            // "#c8bbbe", "LavenderBlush3 ",
+            // "#817679", "LavenderBlush4 ",
+            "#87f717", "LawnGreen ",
+            // "#fff8c6", "LemonChiffon ",
+            // "#ece5b6", "LemonChiffon2 ",
+            // "#c9c299", "LemonChiffon3 ",
+            // "#827b60", "LemonChiffon4 ",
+            // "#addfff", "LightBlue ",
+            // "#bdedff", "LightBlue1 ",
+            // "#afdcec", "LightBlue2 ",
+            "#95b9c7", "LightBlue3 ",
+            // "#5e767e", "LightBlue4 ",
+            "#e77471", "LightCoral ",
+            // "#e0ffff", "LightCyan ",
+            // "#cfecec", "LightCyan2 ",
+            // "#afc7c7", "LightCyan3 ",
+            "#717d7d", "LightCyan4 ",
+            // "#ecd872", "LightGoldenrod ",
+            // "#ffe87c", "LightGoldenrod1 ",
+            // "#ecd672", "LightGoldenrod2 ",
+            // "#c8b560", "LightGoldenrod3 ",
+            // "#817339", "LightGoldenrod4 ",
+            // "#faf8cc", "LightGoldenrodYellow ",
+            "#faafba", "LightPink ",
+            // "#f9a7b0", "LightPink1 ",
+            // "#e799a3", "LightPink2 ",
+            // "#c48189", "LightPink3 ",
+            // "#7f4e52", "LightPink4 ",
+            "#f9966b", "LightSalmon ",
+            // "#e78a61", "LightSalmon2 ",
+            // "#c47451", "LightSalmon3 ",
+            // "#7f462c", "LightSalmon4 ",
+            "#3ea99f", "LightSeaGreen ", "#82cafa", "LightSkyBlue ",
+            // "#a0cfec", "LightSkyBlue2 ",
+            // "#87afc7", "LightSkyBlue3 ",
+            // "#566d7e", "LightSkyBlue4 ",
+            "#736aff", "LightSlateBlue ",
+            // "#6d7b8d", "LightSlateGray ",
+            // "#728fce", "LightSteelBlue ",
+            // "#c6deff", "LightSteelBlue1 ",
+            // "#b7ceec", "LightSteelBlue2 ",
+            // "#9aadc7", "LightSteelBlue3 ",
+            // "#646d7e", "LightSteelBlue4 ",
+            // "#fffedc", "LightYellow ",
+            // "#edebcb", "LightYellow2 ",
+            // "#c9c7aa", "LightYellow3 ",
+            "#827d6b", "LightYellow4 ", "#41a317", "LimeGreen ",
+            // "#f9eee2", "linen ",
+            "#ff00ff", "Magenta ",
+            // "#f43eff", "magenta1 ",
+            // "#e238ec", "magenta2 ",
+            // "#c031c7", "magenta3 ",
+            "#810541", "Maroon ",
+            // "#f535aa", "maroon1 ",
+            // "#e3319d", "maroon2 ",
+            // "#c12283", "maroon3 ",
+            // "#7d0552", "maroon4 ",
+            "#348781", "MediumAquamarine ", "#152dc6", "MediumBlue ", "#347235", "MediumForestGreen ",
+            // "#ccb954", "MediumGoldenrod ",
+            // "#b048b5", "MediumOrchid ",
+            // "#d462ff", "MediumOrchid1 ",
+            // "#c45aec", "MediumOrchid2 ",
+            // "#a74ac7", "MediumOrchid3 ",
+            // "#6a287e", "MediumOrchid4 ",
+            // "#8467d7", "MediumPurple ",
+            // "#9e7bff", "MediumPurple1 ",
+            // "#9172ec", "MediumPurple2 ",
+            // "#7a5dc7", "MediumPurple3 ",
+            // "#4e387e", "MediumPurple4 ",
+            // "#306754", "MediumSeaGreen ",
+            // "#5e5a80", "MediumSlateBlue ",
+            // "#348017", "MediumSpringGreen ",
+            // "#48cccd", "MediumTurquoise ",
+            // "#ca226b", "MediumVioletRed ",
+            // "#151b54", "MidnightBlue ",
+            // "#f5fff9", "MintCream ",
+            // "#fde1dd", "MistyRose ",
+            // "#ead0cc", "MistyRose2 ",
+            // "#c6afac", "MistyRose3 ",
+            // "#806f6c", "MistyRose4 ",
+            // "#fde0ac", "moccasin ",
+            // "#fddaa3", "NavajoWhite ",
+            // "#eac995", "NavajoWhite2 ",
+            // "#c7aa7d", "NavajoWhite3 ",
+            // "#806a4b", "NavajoWhite4 ",
+            // "#150567", "Navy ",
+            // "#fcf3e2", "OldLace ",
+            // "#658017", "OliveDrab ",
+            // "#c3fb17", "OliveDrab1 ",
+            // "#b5e917", "OliveDrab2 ",
+            // "#99c517", "OliveDrab3 ",
+            // "#617c17", "OliveDrab4 ",
+            "#f87a17", "Orange ",
+            // "#fa9b17", "orange1 ",
+            // "#e78e17", "orange2 ",
+            "#c57717", "orange3 ",
+            // "#7f4817", "orange4 ",
+            // "#f63817", "OrangeRed ",
+            // "#e43117", "OrangeRed2 ",
+            "#c22817", "OrangeRed3 ",
+            // "#7e0517", "OrangeRed4 ",
+            "#e57ded", "Orchid ",
+            // "#f67dfa", "orchid1 ",
+            // "#e473e7", "orchid2 ",
+            // "#c160c3", "orchid3 ",
+            // "#7d387c", "orchid4 ",
+            // "#ede49e", "PaleGoldenrod ",
+            "#79d867", "PaleGreen ",
+            // "#a0fc8d", "PaleGreen1 ",
+            // "#94e981", "PaleGreen2 ",
+            // "#7dc56c", "PaleGreen3 ",
+            // "#4e7c41", "PaleGreen4 ",
+            // "#aeebec", "PaleTurquoise ",
+            // "#bcfeff", "PaleTurquoise1 ",
+            // "#adebec", "PaleTurquoise2 ",
+            "#92c7c7", "PaleTurquoise3 ",
+            // "#5e7d7e", "PaleTurquoise4 ",
+            "#d16587", "PaleVioletRed ",
+            // "#f778a1", "PaleVioletRed1 ",
+            // "#e56e94", "PaleVioletRed2 ",
+            // "#c25a7c", "PaleVioletRed3 ",
+            // "#7e354d", "PaleVioletRed4 ",
+            // "#feeccf", "PapayaWhip ",
+            // "#fcd5b0", "PeachPuff ",
+            // "#eac5a3", "PeachPuff2 ",
+            // "#c6a688", "PeachPuff3 ",
+            // "#806752", "PeachPuff4 ",
+            "#c57726", "peru ",
+            // "#faafbe", "Pink ",
+            // "#e7a1b0", "pink2 ",
+            // "#c48793", "pink3 ",
+            // "#7f525d", "pink4 ",
+            // "#b93b8f", "Plum ",
+            // "#f9b7ff", "plum1 ",
+            // "#e6a9ec", "plum2 ",
+            // "#c38ec7", "plum3 ",
+            // "#7e587e", "plum4 ",
+            // "#addce3", "PowderBlue ",
+            "#8e35ef", "purple ",
+            // "#893bff", "purple1 ",
+            // "#7f38ec", "purple2 ",
+            // "#6c2dc7", "purple3 ",
+            // "#461b7e", "purple4 ",
+            "#ff0000", "Red ",
+            // "#f62217", "red1 ",
+            // "#e41b17", "red2 ",
+            "#b38481", "RosyBrown ",
+            // "#fbbbb9", "RosyBrown1 ",
+            // "#e8adaa", "RosyBrown2 ",
+            // "#c5908e", "RosyBrown3 ",
+            // "#7f5a58", "RosyBrown4 ",
+            "#2b60de", "RoyalBlue ",
+            // "#306eff", "RoyalBlue1 ",
+            // "#2b65ec", "RoyalBlue2 ",
+            // "#2554c7", "RoyalBlue3 ",
+            // "#15317e", "RoyalBlue4 ",
+            "#f88158", "salmon1 ",
+            // "#e67451", "salmon2 ",
+            // "#c36241", "salmon3 ",
+            // "#7e3817", "salmon4 ",
+            // "#ee9a4d", "SandyBrown ",
+            "#4e8975", "SeaGreen ",
+            // "#6afb92", "SeaGreen1 ",
+            // "#64e986", "SeaGreen2 ",
+            // "#54c571", "SeaGreen3 ",
+            // "#387c44", "SeaGreen4 ",
+            // "#fef3eb", "seashell ",
+            // "#ebe2d9", "seashell2 ",
+            // "#c8bfb6", "seashell3 ",
+            // "#817873", "seashell4 ",
+            // "#8a4117", "Sienna ",
+            // "#f87431", "sienna1 ",
+            // "#e66c2c", "sienna2 ",
+            // "#c35817", "sienna3 ",
+            // "#7e3517", "sienna4 ",
+            // "#6698ff", "SkyBlue ",
+            // "#82caff", "SkyBlue1 ",
+            // "#79baec", "SkyBlue2 ",
+            // "#659ec7", "SkyBlue3 ",
+            // "#41627e", "SkyBlue4 ",
+            // "#737ca1", "SlateBlue ",
+            // "#7369ff", "SlateBlue1 ",
+            // "#6960ec", "SlateBlue2 ",
+            // "#574ec7", "SlateBlue3 ",
+            // "#342d7e", "SlateBlue4 ",
+            // "#657383", "SlateGray ",
+            // "#c2dfff", "SlateGray1 ",
+            // "#b4cfec", "SlateGray2 ",
+            // "#98afc7", "SlateGray3 ",
+            // "#616d7e", "SlateGray4 ",
+            // "#fff9fa", "snow ",
+            // "#ece7e6", "snow2 ",
+            // "#c8c4c2", "snow3 ",
+            // "#817c7b", "snow4 ",
+            // "#4aa02c", "SpringGreen ",
+            // "#5efb6e", "SpringGreen1 ",
+            // "#57e964", "SpringGreen2 ",
+            // "#4cc552", "SpringGreen3 ",
+            // "#347c2c", "SpringGreen4 ",
+            "#4863a0", "SteelBlue ",
+            // "#5cb3ff", "SteelBlue1 ",
+            // "#56a5ec", "SteelBlue2 ",
+            // "#488ac7", "SteelBlue3 ",
+            // "#2b547e", "SteelBlue4 ",
+            // "#d8af79", "Tan ",
+            // "#fa9b3c", "tan1 ",
+            // "#e78e35", "tan2 ",
+            // "#d2b9d3", "Thistle ",
+            // "#fcdfff", "thistle1 ",
+            // "#e9cfec", "thistle2 ",
+            // "#c6aec7", "thistle3 ",
+            // "#806d7e", "thistle4 ",
+            // "#f75431", "tomato ",
+            // "#e54c2c", "tomato2 ",
+            // "#c23e17", "tomato3 ",
+            // "#43c6db", "Turquoise ",
+            // "#52f3ff", "turquoise1 ",
+            // "#4ee2ec", "turquoise2 ",
+            // "#43bfc7", "turquoise3 ",
+            // "#30787e", "turquoise4 ",
+            // "#8d38c9", "Violet ",
+            // "#e9358a", "VioletRed ",
+            // "#f6358a", "VioletRed1 ",
+            // "#e4317f", "VioletRed2 ",
+            // "#c12869", "VioletRed3 ",
+            // "#7d0541", "VioletRed4 ",
+            // "#f3daa9", "Wheat ",
+            // "#fee4b1", "wheat1 ",
+            // "#ebd3a3", "wheat2 ",
+            // "#c8b189", "wheat3 ",
+            // "#816f54", "wheat4 ",
+            // "#ffff00", "Yellow ",
+            // "#fffc17", "yellow1 ",
+            "#52d017", "YellowGreen ",
 
-      "#980517", "Brown ",
+            "#980517", "Brown ",
 
-  };
+    };
 
-  //"#c00000","#00a000","#0000d0", "#b0b020","#b000b0","#00a0a0", "#b06060","#70a070","#7070d0","#b0b070","#b070b0","#70a0a0"};
+    // "#c00000","#00a000","#0000d0", "#b0b020","#b000b0","#00a0a0",
+    // "#b06060","#70a070","#7070d0","#b0b070","#b070b0","#70a0a0"};
 
-  public static String getColor(int i) {
-    return colors[(i % (colors.length / 2)) * 2];
-  }
-
-  public static void main(String[] args) {
-    System.out.println("<!DOCTYPE HTML PUBLIC \"-//TEST//DTD HTML 3.2//EN\">" +
-        "<HTML>\n<HEAD>\n <TITLE>Test</TITLE></HEAD>\n" +
-        "<BODY BGCOLOR=\"#ffffff\">");
-    for (int i = 0; i < colors.length; i += 2) {
-      System.out.println("TEST TEST TEST <font color=\"" + colors[i] + "\">" +
-          "Das ist die Farbe #" + colors[i + 1] + "#</font><br>");
+    public static String getColor(int i) {
+        return colors[(i % (colors.length / 2)) * 2];
     }
 
-    System.out.println("</BODY></HTML>");
-  }
+    public static void main(String[] args) {
+        System.out.println("<!DOCTYPE HTML PUBLIC \"-//TEST//DTD HTML 3.2//EN\">" + "<HTML>\n<HEAD>\n <TITLE>Test</TITLE></HEAD>\n"
+                + "<BODY BGCOLOR=\"#ffffff\">");
+        for (int i = 0; i < colors.length; i += 2) {
+            System.out.println("TEST TEST TEST <font color=\"" + colors[i] + "\">" + "Das ist die Farbe #" + colors[i + 1] + "#</font><br>");
+        }
+
+        System.out.println("</BODY></HTML>");
+    }
 }

+ 21 - 25
jplag/src/main/java/jplag/reporting/HTMLFile.java

@@ -10,29 +10,25 @@ import java.nio.charset.StandardCharsets;
 
 public class HTMLFile extends PrintWriter {
 
-  private BufferedCounter bc;
-
-  /**
-   * Static factory method to instantiate an HTMLFile objects.
-   */
-  public static HTMLFile fromFile(File file) throws IOException {
-    BufferedCounter bc = new BufferedCounter(new OutputStreamWriter(
-        new FileOutputStream(file),
-        StandardCharsets.UTF_8
-    ));
-
-    HTMLFile htmlFile = new HTMLFile(bc);
-    htmlFile.bc = bc;
-
-    return htmlFile;
-  }
-
-  private HTMLFile(BufferedWriter writer) {
-    super(writer);
-  }
-
-  public int bytesWritten() {
-    return bc.bytesWritten();
-  }
-}
+    private BufferedCounter bc;
+
+    /**
+     * Static factory method to instantiate an HTMLFile objects.
+     */
+    public static HTMLFile fromFile(File file) throws IOException {
+        BufferedCounter bc = new BufferedCounter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
+
+        HTMLFile htmlFile = new HTMLFile(bc);
+        htmlFile.bc = bc;
 
+        return htmlFile;
+    }
+
+    private HTMLFile(BufferedWriter writer) {
+        super(writer);
+    }
+
+    public int bytesWritten() {
+        return bc.bytesWritten();
+    }
+}

+ 16 - 17
jplag/src/main/java/jplag/reporting/MarkupText.java

@@ -1,25 +1,24 @@
 package jplag.reporting;
 
 /**
- * This class represents one markup tag that will be included in the text. It is
- * necessary to sort the objects before they are included into the text, so that
- * the original position can be found.
+ * This class represents one markup tag that will be included in the text. It is necessary to sort the objects before
+ * they are included into the text, so that the original position can be found.
  */
 public class MarkupText {
-  public int fileIndex, lineIndex, column;
-  public String text;
-  public boolean frontMarkup = false;
+    public int fileIndex, lineIndex, column;
+    public String text;
+    public boolean frontMarkup = false;
 
-  public MarkupText(int fileIndex, int lineIndex, int column, String text, boolean frontMarkup) {
-    this.fileIndex = fileIndex;
-    this.lineIndex = lineIndex;
-    this.column = column;
-    this.text = text;
-    this.frontMarkup = frontMarkup;
-  }
+    public MarkupText(int fileIndex, int lineIndex, int column, String text, boolean frontMarkup) {
+        this.fileIndex = fileIndex;
+        this.lineIndex = lineIndex;
+        this.column = column;
+        this.text = text;
+        this.frontMarkup = frontMarkup;
+    }
 
-  @Override
-public String toString() {
-    return "MarkUp - file: " + fileIndex + " line: " + lineIndex + " column: " + column + " text: " + text;
-  }
+    @Override
+    public String toString() {
+        return "MarkUp - file: " + fileIndex + " line: " + lineIndex + " column: " + column + " text: " + text;
+    }
 }

+ 14 - 14
jplag/src/main/java/jplag/reporting/Messages.java

@@ -6,21 +6,21 @@ import java.util.ResourceBundle;
 
 public class Messages {
 
-  private final ResourceBundle resourceBundle;
+    private final ResourceBundle resourceBundle;
 
-  /**
-   * @param countryTag may be "de", "en", "fr", "es", "pt" or "ptbr"
-   */
-  public Messages(String countryTag) {
-    String bundleName = "jplag.messages";
-    resourceBundle = ResourceBundle.getBundle(bundleName, new Locale(countryTag));
-  }
+    /**
+     * @param countryTag may be "de", "en", "fr", "es", "pt" or "ptbr"
+     */
+    public Messages(String countryTag) {
+        String bundleName = "jplag.messages";
+        resourceBundle = ResourceBundle.getBundle(bundleName, new Locale(countryTag));
+    }
 
-  public String getString(String key) {
-    try {
-      return resourceBundle.getString(key);
-    } catch (MissingResourceException e) {
-      return '!' + key + '!';
+    public String getString(String key) {
+        try {
+            return resourceBundle.getString(key);
+        } catch (MissingResourceException e) {
+            return '!' + key + '!';
+        }
     }
-  }
 }

+ 763 - 855
jplag/src/main/java/jplag/reporting/Report.java

@@ -29,942 +29,850 @@ import jplag.Token;
  */
 public class Report {
 
-  private JPlagResult result;
-  private final File reportDir;
-  private final Messages msg;
-
-  int currentComparisonIndex = 0;
-  Map<JPlagComparison, Integer> comparisonToIndex = new HashMap<>();
-
-  public Report(File reportDir) throws ExitException {
-    this.reportDir = reportDir;
-    this.msg = new Messages("en");
-
-    validateReportDir();
-  }
-
-  /**
-   * Make sure the report directory exists, is a directory and has write access.
-   */
-  private void validateReportDir() throws ExitException {
-    if (!reportDir.exists() && !reportDir.mkdirs()) {
-      throw new ExitException("Cannot create report directory!");
+    private JPlagResult result;
+    private final File reportDir;
+    private final Messages msg;
+
+    int currentComparisonIndex = 0;
+    Map<JPlagComparison, Integer> comparisonToIndex = new HashMap<>();
+
+    public Report(File reportDir) throws ExitException {
+        this.reportDir = reportDir;
+        this.msg = new Messages("en");
+
+        validateReportDir();
     }
 
-    if (!reportDir.isDirectory()) {
-      throw new ExitException(reportDir + " is not a directory!");
+    /**
+     * Make sure the report directory exists, is a directory and has write access.
+     */
+    private void validateReportDir() throws ExitException {
+        if (!reportDir.exists() && !reportDir.mkdirs()) {
+            throw new ExitException("Cannot create report directory!");
+        }
+
+        if (!reportDir.isDirectory()) {
+            throw new ExitException(reportDir + " is not a directory!");
+        }
+
+        if (!reportDir.canWrite()) {
+            throw new ExitException("Cannot write directory: " + reportDir);
+        }
     }
 
-    if (!reportDir.canWrite()) {
-      throw new ExitException("Cannot write directory: " + reportDir);
+    /*
+     * Two colors, represented by Rl,Gl,Bl and Rh,Gh,Bh respectively are mixed according to the percentage "percent"
+     */
+    private String color(float percent, int Rl, int Rh, int Gl, int Gh, int Bl, int Bh) {
+        int farbeR = (int) (Rl + (Rh - Rl) * percent / 100);
+        int farbeG = (int) (Gl + (Gh - Gl) * percent / 100);
+        int farbeB = (int) (Bl + (Bh - Bl) * percent / 100);
+
+        String helpR = (farbeR < 16 ? "0" : "") + Integer.toHexString(farbeR);
+        String helpG = (farbeG < 16 ? "0" : "") + Integer.toHexString(farbeG);
+        String helpB = (farbeB < 16 ? "0" : "") + Integer.toHexString(farbeB);
+
+        return "#" + helpR + helpG + helpB;
     }
-  }
-
-  /*
-   * Two colors, represented by Rl,Gl,Bl and Rh,Gh,Bh respectively are mixed
-   * according to the percentage "percent"
-   */
-  private String color(float percent, int Rl, int Rh, int Gl, int Gh, int Bl, int Bh) {
-    int farbeR = (int) (Rl + (Rh - Rl) * percent / 100);
-    int farbeG = (int) (Gl + (Gh - Gl) * percent / 100);
-    int farbeB = (int) (Bl + (Bh - Bl) * percent / 100);
-
-    String helpR = (farbeR < 16 ? "0" : "") + Integer.toHexString(farbeR);
-    String helpG = (farbeG < 16 ? "0" : "") + Integer.toHexString(farbeG);
-    String helpB = (farbeB < 16 ? "0" : "") + Integer.toHexString(farbeB);
-
-    return "#" + helpR + helpG + helpB;
-  }
-
-  /*
-   * This procedure copies all the data from "data/" into the
-   * result-directory.
-   */
-  private void copyStaticFiles() {
-    final String[] fileList = {
-        "back.gif", "forward.gif", "help-en.html", "help-sim-en.html", "logo.gif", "fields.js"
-    };
-
-    for (int i = fileList.length - 1; i >= 0; i--) {
-      try {
-        URL url = Report.class.getResource("data/" + fileList[i]);
-        DataInputStream dis = new DataInputStream(url.openStream());
-
-        File dest = new File(reportDir, fileList[i]);
-        DataOutputStream dos = new DataOutputStream(new FileOutputStream(dest));
-
-        byte[] buffer = new byte[1024];
-        int count;
-        do {
-          count = dis.read(buffer);
-          if (count != -1) {
-            dos.write(buffer, 0, count);
-          }
-        } while (count != -1);
-        dis.close();
-        dos.close();
-      } catch (IOException | NullPointerException e) {
-        e.printStackTrace();
-      }
+
+    /*
+     * This procedure copies all the data from "data/" into the result-directory.
+     */
+    private void copyStaticFiles() {
+        final String[] fileList = {"back.gif", "forward.gif", "help-en.html", "help-sim-en.html", "logo.gif", "fields.js"};
+
+        for (int i = fileList.length - 1; i >= 0; i--) {
+            try {
+                URL url = Report.class.getResource("data/" + fileList[i]);
+                DataInputStream dis = new DataInputStream(url.openStream());
+
+                File dest = new File(reportDir, fileList[i]);
+                DataOutputStream dos = new DataOutputStream(new FileOutputStream(dest));
+
+                byte[] buffer = new byte[1024];
+                int count;
+                do {
+                    count = dis.read(buffer);
+                    if (count != -1) {
+                        dos.write(buffer, 0, count);
+                    }
+                } while (count != -1);
+                dis.close();
+                dos.close();
+            } catch (IOException | NullPointerException e) {
+                e.printStackTrace();
+            }
+        }
     }
-  }
 
-  private int getComparisonIndex(JPlagComparison comparison) {
-    Integer index = comparisonToIndex.get(comparison);
+    private int getComparisonIndex(JPlagComparison comparison) {
+        Integer index = comparisonToIndex.get(comparison);
 
-    if (index != null) {
-      return index;
-    }
+        if (index != null) {
+            return index;
+        }
 
-    comparisonToIndex.put(comparison, currentComparisonIndex++);
+        comparisonToIndex.put(comparison, currentComparisonIndex++);
 
-    return currentComparisonIndex - 1;
-  }
+        return currentComparisonIndex - 1;
+    }
 
-  public void writeResult(JPlagResult result) throws ExitException {
-    this.result = result;
+    public void writeResult(JPlagResult result) throws ExitException {
+        this.result = result;
 
-    writeIndex();
+        writeIndex();
 
-    // TODO TS: Cluster currently not supported
-    // if (result.getOptions().getClusterType() != ClusterType.NONE) {
-    //   writeClusters(clustering);
-    // }
+        // TODO TS: Cluster currently not supported
+        // if (result.getOptions().getClusterType() != ClusterType.NONE) {
+        // writeClusters(clustering);
+        // }
 
-    copyStaticFiles();
+        copyStaticFiles();
 
-    writeMatches(result.getComparisons());
-  }
+        writeMatches(result.getComparisons());
+    }
 
-  /**
-   * Create a new HTML file.
-   */
-  private HTMLFile createHTMLFile(String name) throws ExitException {
-    File file = new File(reportDir, name);
+    /**
+     * Create a new HTML file.
+     */
+    private HTMLFile createHTMLFile(String name) throws ExitException {
+        File file = new File(reportDir, name);
 
-    try {
-      return HTMLFile.fromFile(file);
-    } catch (IOException e) {
-      throw new jplag.ExitException("Error opening file: " + file);
+        try {
+            return HTMLFile.fromFile(file);
+        } catch (IOException e) {
+            throw new jplag.ExitException("Error opening file: " + file);
+        }
     }
-  }
-
-  private void writeHTMLHeader(HTMLFile file, String title) {
-    file.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
-    file.println("<HTML><HEAD><TITLE>" + title + "</TITLE>");
-    file.println("<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
-    file.println("</HEAD>");
-  }
-
-  /**
-   * Write the index.html file.
-   */
-  private void writeIndex() throws ExitException {
-    HTMLFile htmlFile = createHTMLFile("index.html");
-
-    writeIndexBegin(htmlFile, msg.getString("Report.Search_Results"));
-    writeDistribution(htmlFile);
-
-    String csvFile = "matches_avg.csv";
-
-    writeLinksToComparisons(
-        htmlFile,
-        "<H4>" + msg.getString("Report.MatchesAvg"),
-        csvFile
-    );
-
-    writeMatchesCSV(csvFile);
-
-    writeIndexEnd(htmlFile);
-
-    htmlFile.close();
-  }
-
-  /**
-   * Write the beginning of the index.html file.
-   */
-  private void writeIndexBegin(HTMLFile htmlFile, String title) {
-    writeHTMLHeader(htmlFile, title);
-
-    htmlFile.println("<BODY BGCOLOR=#ffffff LINK=#000088 VLINK=#000000 TEXT=#000000>");
-    htmlFile.println("<TABLE ALIGN=center CELLPADDING=2 CELLSPACING=1>");
-    htmlFile.println("<TR VALIGN=middle ALIGN=center BGCOLOR=#ffffff><TD>"
-        + "<IMG SRC=\"logo.gif\" ALT=\"JPlag\" BORDER=0></TD>");
-    htmlFile.println("<TD><H1><BIG>" + title + "</BIG></H1></TD></TR>");
-
-    htmlFile.println(
-        "<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Language") + ":</TD><TD>"
-            + result.getOptions().getLanguageOption().name()
-            + "</TD></TR>");
-    htmlFile.print(
-        "<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Submissions") + ":</TD><TD>"
-            + result.getNumberOfSubmissions());
-
-    htmlFile.println("</TD></TR>");
-
-    if (result.getOptions().hasBaseCode()) {
-      htmlFile.print(
-          "<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Basecode_submission")
-              + ":</TD>" + "<TD>"
-              + result.getOptions().getBaseCodeSubmissionName() + "</TD></TR>");
+
+    private void writeHTMLHeader(HTMLFile file, String title) {
+        file.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
+        file.println("<HTML><HEAD><TITLE>" + title + "</TITLE>");
+        file.println("<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
+        file.println("</HEAD>");
     }
 
-    if (result.getComparisons().size() > 0) {
-      htmlFile.println(
-          "<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Matches_displayed")
-              + ":</TD>" + "<TD>");
+    /**
+     * Write the index.html file.
+     */
+    private void writeIndex() throws ExitException {
+        HTMLFile htmlFile = createHTMLFile("index.html");
 
-      htmlFile.println(
-          result.getComparisons().size() + " (" + msg.getString("Report.Treshold") + ": "
-              + result.getOptions().getSimilarityThreshold() + "%)<br>");
+        writeIndexBegin(htmlFile, msg.getString("Report.Search_Results"));
+        writeDistribution(htmlFile);
 
-      htmlFile.println("</TD></TR>");
-    }
+        String csvFile = "matches_avg.csv";
 
-    SimpleDateFormat dateFormat = new SimpleDateFormat();
+        writeLinksToComparisons(htmlFile, "<H4>" + msg.getString("Report.MatchesAvg"), csvFile);
 
-    htmlFile.println(
-        "<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Date") + ":</TD><TD>"
-            + dateFormat.format(new Date()) + "</TD></TR>");
-    htmlFile.println(
-        "<TR BGCOLOR=#aaaaff>" + "<TD><EM>" + msg.getString("Report.Minimum_Match_Length")
-            + "</EM> ("
-            + msg.getString("Report.sensitivity") + "):</TD><TD>" + result.getOptions()
-            .getMinTokenMatch()
-            + "</TD></TR>");
-    htmlFile.println(
-        "<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Suffixes") + ":</TD><TD>");
+        writeMatchesCSV(csvFile);
 
-    String[] fileSuffixes = result.getOptions().getFileSuffixes();
+        writeIndexEnd(htmlFile);
 
-    for (int i = 0; i < fileSuffixes.length; i++) {
-      htmlFile.print(fileSuffixes[i] + (i < fileSuffixes.length - 1 ? ", " : "</TD></TR>\n"));
+        htmlFile.close();
     }
 
-    htmlFile.println("</TABLE>\n<HR>");
-  }
+    /**
+     * Write the beginning of the index.html file.
+     */
+    private void writeIndexBegin(HTMLFile htmlFile, String title) {
+        writeHTMLHeader(htmlFile, title);
 
-  /**
-   * Write the end of the index.html file.
-   */
-  private void writeIndexEnd(HTMLFile htmlFile) {
-    htmlFile.println(
-        "<HR>\n<P ALIGN=right><FONT SIZE=\"1\" FACE=\"helvetica\">JPlag</FONT></P>");
-    htmlFile.println("</BODY>\n</HTML>");
-  }
+        htmlFile.println("<BODY BGCOLOR=#ffffff LINK=#000088 VLINK=#000000 TEXT=#000000>");
+        htmlFile.println("<TABLE ALIGN=center CELLPADDING=2 CELLSPACING=1>");
+        htmlFile.println("<TR VALIGN=middle ALIGN=center BGCOLOR=#ffffff><TD>" + "<IMG SRC=\"logo.gif\" ALT=\"JPlag\" BORDER=0></TD>");
+        htmlFile.println("<TD><H1><BIG>" + title + "</BIG></H1></TD></TR>");
 
-  private void writeDistribution(HTMLFile htmlFile) {
-    int barLength = 75;
-    int[] similarityDistribution = result.getSimilarityDistribution();
+        htmlFile.println("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Language") + ":</TD><TD>"
+                + result.getOptions().getLanguageOption().name() + "</TD></TR>");
+        htmlFile.print("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Submissions") + ":</TD><TD>" + result.getNumberOfSubmissions());
 
-    int max = 1;
+        htmlFile.println("</TD></TR>");
 
-    for (int i = 0; i < 10; i++) {
-      if (similarityDistribution[i] > max) {
-        max = similarityDistribution[i];
-      }
-    }
+        if (result.getOptions().hasBaseCode()) {
+            htmlFile.print("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Basecode_submission") + ":</TD>" + "<TD>"
+                    + result.getOptions().getBaseCodeSubmissionName() + "</TD></TR>");
+        }
 
-    htmlFile.println("<H4>" + this.msg.getString("Report.Distribution") + ":</H4>\n<CENTER>");
-    htmlFile.println("<TABLE CELLPADDING=1 CELLSPACING=1>");
+        if (result.getComparisons().size() > 0) {
+            htmlFile.println("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Matches_displayed") + ":</TD>" + "<TD>");
 
-    for (int i = 9; i >= 0; i--) {
-      htmlFile.print(
-          "<TR BGCOLOR=" + color(i * 10 + 10, 128, 192, 128, 192, 255, 255) + "><TD ALIGN=center>"
-              + (i * 10) + "% - "
-              + (i * 10 + 10) + "%" + "</TD><TD ALIGN=right>" + similarityDistribution[i]
-              + "</TD><TD>");
+            htmlFile.println(result.getComparisons().size() + " (" + msg.getString("Report.Treshold") + ": "
+                    + result.getOptions().getSimilarityThreshold() + "%)<br>");
 
-      for (int j = (similarityDistribution[i] * barLength / max); j > 0; j--) {
-        htmlFile.print("#");
-      }
+            htmlFile.println("</TD></TR>");
+        }
 
-      if (similarityDistribution[i] * barLength / max == 0) {
-        if (similarityDistribution[i] == 0) {
-          htmlFile.print(".");
-        } else {
-          htmlFile.print("#");
+        SimpleDateFormat dateFormat = new SimpleDateFormat();
+
+        htmlFile.println(
+                "<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Date") + ":</TD><TD>" + dateFormat.format(new Date()) + "</TD></TR>");
+        htmlFile.println("<TR BGCOLOR=#aaaaff>" + "<TD><EM>" + msg.getString("Report.Minimum_Match_Length") + "</EM> ("
+                + msg.getString("Report.sensitivity") + "):</TD><TD>" + result.getOptions().getMinTokenMatch() + "</TD></TR>");
+        htmlFile.println("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Suffixes") + ":</TD><TD>");
+
+        String[] fileSuffixes = result.getOptions().getFileSuffixes();
+
+        for (int i = 0; i < fileSuffixes.length; i++) {
+            htmlFile.print(fileSuffixes[i] + (i < fileSuffixes.length - 1 ? ", " : "</TD></TR>\n"));
         }
-      }
 
-      htmlFile.println("</TD></TR>");
+        htmlFile.println("</TABLE>\n<HR>");
     }
 
-    htmlFile.println("</TABLE></CENTER>\n<P>\n<HR>");
-  }
-
-  private void writeLinksToComparisons(
-      HTMLFile htmlFile,
-      String headerStr,
-      String csvFile
-  ) {
-    List<JPlagComparison> comparisons = result.getComparisons();
-
-    htmlFile.println(headerStr + " (<a href=\"help-sim-" + "en" // Country tag
-        + ".html\"><small><font color=\"#000088\">"
-        + msg.getString("Report.WhatIsThis") + "</font></small></a>):</H4>");
-    htmlFile.println("<p><a href=\"" + csvFile + "\">download csv</a></p>");
-    htmlFile.println("<TABLE CELLPADDING=3 CELLSPACING=2>");
-
-    for (JPlagComparison comparison : comparisons) {
-      String submissionNameA = comparison.firstSubmission.name;
-      String submissionNameB = comparison.secondSubmission.name;
-
-      htmlFile.print(
-          "<TR><TD BGCOLOR=" + color(comparison.percentA(), 128, 192, 128, 192, 255, 255)
-              + ">" + submissionNameA
-              + "</TD><TD><nobr>-&gt;</nobr>");
-
-      htmlFile
-          .print("</TD><TD BGCOLOR=" + color(comparison.percentB(), 128, 192, 128, 192, 255, 255)
-              + " ALIGN=center><A HREF=\"match"
-              + getComparisonIndex(comparison) + ".html\">" + submissionNameB
-              + "</A><BR><FONT COLOR=\""
-              + color(comparison.percent(), 0, 255, 0, 0, 0, 0) + "\">(" + (
-              ((int) (comparison.percent() * 10))
-                  / (float) 10) + "%)</FONT>");
-
-      htmlFile.println("</TD></TR>");
+    /**
+     * Write the end of the index.html file.
+     */
+    private void writeIndexEnd(HTMLFile htmlFile) {
+        htmlFile.println("<HR>\n<P ALIGN=right><FONT SIZE=\"1\" FACE=\"helvetica\">JPlag</FONT></P>");
+        htmlFile.println("</BODY>\n</HTML>");
     }
 
-    htmlFile.println("</TABLE><P>\n");
-    htmlFile.println("<!---->");
-  }
-
-  private void writeMatchesCSV(String fileName) {
-    FileWriter writer = null;
-    File csvFile = new File(reportDir, fileName);
-    List<JPlagComparison> comparisons = result.getComparisons();
-
-    try {
-      csvFile.createNewFile();
-      writer = new FileWriter(csvFile);
-
-      for (JPlagComparison comparison : comparisons) {
-        String submissionNameA = comparison.firstSubmission.name;
-        String submissionNameB = comparison.secondSubmission.name;
-
-        writer.write(getComparisonIndex(comparison) + ";");
-        writer.write(submissionNameA + ";");
-        writer.write(submissionNameB + ";");
-        writer.write((((int) (comparison.percent() * 10)) / (float) 10) + ";");
-        writer.write("\n");
-      }
-
-      writer.flush();
-    } catch (Exception e) {
-      e.printStackTrace();
-    } finally {
-      try {
-        writer.close();
-      } catch (Exception ignored) {
-      }
+    private void writeDistribution(HTMLFile htmlFile) {
+        int barLength = 75;
+        int[] similarityDistribution = result.getSimilarityDistribution();
+
+        int max = 1;
+
+        for (int i = 0; i < 10; i++) {
+            if (similarityDistribution[i] > max) {
+                max = similarityDistribution[i];
+            }
+        }
+
+        htmlFile.println("<H4>" + this.msg.getString("Report.Distribution") + ":</H4>\n<CENTER>");
+        htmlFile.println("<TABLE CELLPADDING=1 CELLSPACING=1>");
+
+        for (int i = 9; i >= 0; i--) {
+            htmlFile.print("<TR BGCOLOR=" + color(i * 10 + 10, 128, 192, 128, 192, 255, 255) + "><TD ALIGN=center>" + (i * 10) + "% - "
+                    + (i * 10 + 10) + "%" + "</TD><TD ALIGN=right>" + similarityDistribution[i] + "</TD><TD>");
+
+            for (int j = (similarityDistribution[i] * barLength / max); j > 0; j--) {
+                htmlFile.print("#");
+            }
+
+            if (similarityDistribution[i] * barLength / max == 0) {
+                if (similarityDistribution[i] == 0) {
+                    htmlFile.print(".");
+                } else {
+                    htmlFile.print("#");
+                }
+            }
+
+            htmlFile.println("</TD></TR>");
+        }
+
+        htmlFile.println("</TABLE></CENTER>\n<P>\n<HR>");
     }
-  }
-
-  private void writeMatches(List<JPlagComparison> comparisons) {
-    comparisons.forEach(comparison -> {
-      try {
-        int i = getComparisonIndex(comparison);
-        writeMatch(comparison, i);
-      } catch (ExitException e) {
-        e.printStackTrace();
-      }
-    });
-  }
-
-  private void writeMatch(JPlagComparison comparison, int i) throws ExitException {
-    HTMLFile htmlFile = createHTMLFile("match" + i + ".html");
-
-    writeHTMLHeader(
-        htmlFile,
-        TagParser.parse(
-            msg.getString("Report.Matches_for_X1_AND_X2"),
-            new String[]{comparison.firstSubmission.name, comparison.secondSubmission.name}
-        )
-    );
-
-    htmlFile.println("<body>");
-    htmlFile.println(
-        "  <div style=\"align-items: center; display: flex; justify-content: space-around;\">");
-
-    htmlFile.println("    <div>");
-    htmlFile.println("      <h3 align=\"center\">");
-    htmlFile.println(
-        TagParser.parse(
-            msg.getString("Report.Matches_for_X1_AND_X2"),
-            new String[]{comparison.firstSubmission.name, comparison.secondSubmission.name}
-        )
-    );
-    htmlFile.println("      </h3>");
-    htmlFile.println("      <h1 align=\"center\">");
-    htmlFile.println("        " + comparison.roundedPercent() + "%");
-    htmlFile.println("      </h1>");
-    htmlFile.println("      <center>");
-    htmlFile.println("        <a href=\"index.html\" target=\"_top\">");
-    htmlFile.println("          " + msg.getString("Report.INDEX"));
-    htmlFile.println("        </a>");
-    htmlFile.println("        <span>-</span>");
-    htmlFile.println("        <a href=\"help-en.html\" target=\"_top\">");
-    htmlFile.println("          " + msg.getString("Report.HELP"));
-    htmlFile.println("        </a>");
-    htmlFile.println("      </center>");
-    htmlFile.println("    </div>");
-
-    htmlFile.println("    <div>");
-    reportComparison(htmlFile, comparison, i);
-    htmlFile.println("    </div>");
-
-    htmlFile.println("  </div>");
-
-    htmlFile.println("  <hr>");
-
-    htmlFile.println("  <div style=\"display: flex;\">");
-
-    if (result.getOptions().getLanguage().usesIndex()) {
-      writeIndexedSubmission(htmlFile, i, comparison, 0);
-      writeIndexedSubmission(htmlFile, i, comparison, 1);
-    } else if (result.getOptions().getLanguage().supportsColumns()) {
-      writeImprovedSubmission(htmlFile, i, comparison, 0);
-      writeImprovedSubmission(htmlFile, i, comparison, 1);
-    } else {
-      writeNormalSubmission(htmlFile, i, comparison, 0);
-      writeNormalSubmission(htmlFile, i, comparison, 1);
+
+    private void writeLinksToComparisons(HTMLFile htmlFile, String headerStr, String csvFile) {
+        List<JPlagComparison> comparisons = result.getComparisons();
+
+        htmlFile.println(headerStr + " (<a href=\"help-sim-" + "en" // Country tag
+                + ".html\"><small><font color=\"#000088\">" + msg.getString("Report.WhatIsThis") + "</font></small></a>):</H4>");
+        htmlFile.println("<p><a href=\"" + csvFile + "\">download csv</a></p>");
+        htmlFile.println("<TABLE CELLPADDING=3 CELLSPACING=2>");
+
+        for (JPlagComparison comparison : comparisons) {
+            String submissionNameA = comparison.firstSubmission.name;
+            String submissionNameB = comparison.secondSubmission.name;
+
+            htmlFile.print("<TR><TD BGCOLOR=" + color(comparison.percentA(), 128, 192, 128, 192, 255, 255) + ">" + submissionNameA
+                    + "</TD><TD><nobr>-&gt;</nobr>");
+
+            htmlFile.print("</TD><TD BGCOLOR=" + color(comparison.percentB(), 128, 192, 128, 192, 255, 255) + " ALIGN=center><A HREF=\"match"
+                    + getComparisonIndex(comparison) + ".html\">" + submissionNameB + "</A><BR><FONT COLOR=\""
+                    + color(comparison.percent(), 0, 255, 0, 0, 0, 0) + "\">(" + (((int) (comparison.percent() * 10)) / (float) 10) + "%)</FONT>");
+
+            htmlFile.println("</TD></TR>");
+        }
+
+        htmlFile.println("</TABLE><P>\n");
+        htmlFile.println("<!---->");
     }
 
-    htmlFile.println("  </div>");
-
-    htmlFile.println("</body>");
-    htmlFile.println("</html>");
-    htmlFile.close();
-  }
-
-  /**
-   * This method generates an table entry in the list of all comparisons.
-   */
-  private void reportComparison(HTMLFile htmlFile, JPlagComparison comparison, int index) {
-    Match match;
-    Token[] tokensA = comparison.firstSubmission.tokenList.tokens;
-    Token[] tokensB = comparison.secondSubmission.tokenList.tokens;
-    // sort();
-
-    htmlFile.println("<TABLE BORDER=\"1\" CELLSPACING=\"0\" BGCOLOR=\"#d0d0d0\">");
-    htmlFile
-        .println("<TR><TH><TH>" + comparison.firstSubmission.name + " (" + comparison.percentA() + "%)<TH>" +
-            comparison.secondSubmission.name + " (" + comparison.percentB() + "%)<TH>" + msg
-            .getString("AllMatches.Tokens"));
-
-    for (int i = 0; i < comparison.matches.size(); i++) {
-      match = comparison.matches.get(i);
-
-      Token startA = tokensA[match.startA];
-      Token endA = tokensA[match.startA + match.length - 1];
-      Token startB = tokensB[match.startB];
-      Token endB = tokensB[match.startB + match.length - 1];
-
-      String col = Colors.getColor(i);
-
-      htmlFile.print("<TR><TD BGCOLOR=\"" + col + "\"><FONT COLOR=\"" + col + "\">-</FONT>");
-      htmlFile.print("<TD><A HREF=\"javascript:ZweiFrames('match" +
-          index + "-0.html#" + i + "',2,'match" +
-          index + "-1.html#" + i + "',3)\" NAME=\"" + i + "\">");
-      htmlFile.print(new String(startA.file.getBytes()));
-
-      if (result.getOptions().getLanguage().usesIndex()) {
-        htmlFile.print("(" + startA.getIndex() + "-" + endA.getIndex() + ")");
-      } else {
-        htmlFile.print("(" + startA.getLine() + "-" + endA.getLine() + ")");
-      }
-
-      htmlFile.print("<TD><A HREF=\"javascript:ZweiFrames('match" +
-          index + "-0.html#" + i + "',2,'match" +
-          index + "-1.html#" + i + "',3)\" NAME=\"" + i + "\">");
-      htmlFile.print(startB.file);
-
-      if (result.getOptions().getLanguage().usesIndex()) {
-        htmlFile.print("(" + startB.getIndex() + "-" + endB.getIndex());
-      } else {
-        htmlFile.print("(" + startB.getLine() + "-" + endB.getLine());
-      }
-
-      htmlFile.println(")</A><TD ALIGN=center>" + "<FONT COLOR=\"" +
-          comparison.color(match.length) + "\">" + match.length + "</FONT>");
+    private void writeMatchesCSV(String fileName) {
+        FileWriter writer = null;
+        File csvFile = new File(reportDir, fileName);
+        List<JPlagComparison> comparisons = result.getComparisons();
+
+        try {
+            csvFile.createNewFile();
+            writer = new FileWriter(csvFile);
+
+            for (JPlagComparison comparison : comparisons) {
+                String submissionNameA = comparison.firstSubmission.name;
+                String submissionNameB = comparison.secondSubmission.name;
+
+                writer.write(getComparisonIndex(comparison) + ";");
+                writer.write(submissionNameA + ";");
+                writer.write(submissionNameB + ";");
+                writer.write((((int) (comparison.percent() * 10)) / (float) 10) + ";");
+                writer.write("\n");
+            }
+
+            writer.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                writer.close();
+            } catch (Exception ignored) {
+            }
+        }
     }
 
-    if (result.getOptions().hasBaseCode()) {
-      htmlFile.print("<TR><TD BGCOLOR=\"#C0C0C0\"><TD>"
-          + msg.getString("AllMatches.Basecode") + " "
-          + comparison.roundedPercentBasecodeA() + "%");
-      htmlFile.println("<TD>"
-          + msg.getString("AllMatches.Basecode") + " "
-          + comparison.roundedPercentBasecodeB() + "%<TD>&nbsp;");
+    private void writeMatches(List<JPlagComparison> comparisons) {
+        comparisons.forEach(comparison -> {
+            try {
+                int i = getComparisonIndex(comparison);
+                writeMatch(comparison, i);
+            } catch (ExitException e) {
+                e.printStackTrace();
+            }
+        });
     }
 
-    htmlFile.println("</TABLE>");
-  }
-
-  // --------------------------------------------------------------------------
-  // ==========================================================================
-  // --------------------------------------------------------------------------
-
-//  TODO:
-//  /* this function copies all submissions into the result directory */
-//  private int copySubmissions() throws jplag.ExitException {
-//    int bytes = 0;
-//    for (Iterator<Submission> i = program.clusters.neededSubmissions.iterator(); i.hasNext(); ) {
-//      Submission sub = i.next();
-//      int index = this.program.clusters.submissions.indexOf(sub);
-//
-//      HTMLFile f = createHTMLFile(reportDir, "submission" + index + ".html");
-//      writeHTMLHeader(f, sub.name);
-//      f.println("<BODY BGCOLOR=\"#ffffff\">");
-//
-//      String[] files = sub.files;
-//      String text[][] = sub.readFiles(files);
-//
-//      for (int j = 0; j < files.length; j++) {
-//        f.println("<HR>\n<H3><CENTER>" + files[j] + "</CENTER></H3><HR>");
-//        if (this.language.isPreformated()) {
-//          f.println("<PRE>");
-//        }
-//        for (int k = 0; k < text[j].length; k++) {
-//          f.print(text[j][k]);
-//          if (!this.language.isPreformated()) {
-//            f.println("<BR>");
-//          } else {
-//            f.println();
-//          }
-//        }
-//        if (language.isPreformated()) {
-//          f.println("</PRE>");
-//        }
-//      }
-//
-//      f.println("</BODY>\n</HTML>");
-//      f.close();
-//      bytes += f.bytesWritten();
-//    }
-//    return bytes;
-//  }
-
-//  TODO TS: Cluster currently not supported
-//  private int writeClusters(Cluster clustering) throws jplag.ExitException {
-//    int bytes = 0;
-//
-//    HTMLFile f = createHTMLFile("cluster.html");
-//    writeHTMLHeader(f, msg.getString("Report.Clustering_Results"));
-//    String clustertype = msg.getString("Report.Type") + ": " + program.clusters.getType();
-//    f.println("<BODY>\n<H2>" + msg.getString("Report.Clustering_Results") + " (" + clustertype
-//        + ")</H2>");
-//    f.println("<H3><A HREF=\"dendro.html\">" + msg.getString("Report.Dendrogram") + "</A></H3>");
-//    bytes += this.program.clusters.makeDendrograms(reportDir, clustering);
-//
-//    if (this.program.get_threshold() != null) {
-//      for (int i = 0; i < this.program.get_threshold().length; i++) {
-//        float threshold = this.program.get_threshold()[i];
-//        String clustertitle = TagParser
-//            .parse(msg.getString("Report.Clusters_for_Xpercent_treshold"),
-//                new String[]{threshold + ""});
-//        f.println("<H3><A HREF=\"cluster" + threshold + ".html\">" + clustertitle + "</A></H3>");
-//        HTMLFile f2 = createHTMLFile(reportDir, "cluster" + threshold + ".html");
-//        writeHTMLHeader(f2, clustertitle);
-//        f2.println("<BODY>\n<H2>" + clustertitle + " (" + clustertype + ")</H2>");
-//        String text = program.clusters.printClusters(clustering, threshold, f2);
-//        f2.println("</BODY>\n</HTML>");
-//        f2.close();
-//        bytes += f2.bytesWritten();
-//        f.print(text);
-//      }
-//    } else {
-//      float increase = this.program.clusters.maxMergeValue / 10;
-//      if (increase < 5) {
-//        increase = 5;
-//      }
-//      for (float threshold = increase; threshold <= program.clusters.maxMergeValue;
-//          threshold += increase) {
-//        String clustertitle = TagParser
-//            .parse(msg.getString("Report.Clusters_for_Xpercent_treshold"),
-//                new String[]{threshold + ""});
-//        f.println(
-//            "<H3><A HREF=\"cluster" + (int) threshold + ".html\">" + clustertitle + "</A></H3>");
-//        HTMLFile f2 = createHTMLFile(reportDir, "cluster" + (int) threshold + ".html");
-//        writeHTMLHeader(f2, clustertitle);
-//        f2.println("<BODY>\n<H2>" + clustertitle + " (" + clustertype + ")</H2>");
-//        String text = program.clusters.printClusters(clustering, (int) threshold, f2);
-//        f2.println("</BODY>\n</HTML>");
-//        f2.close();
-//        bytes += f2.bytesWritten();
-//        f.print(text);
-//      }
-//    }
-//
-//    f.println("</BODY>\n</HTML>");
-//    f.close();
-//
-//    bytes += copySubmissions();
-//    return f.bytesWritten() + bytes;
-//  }
-
-  // SUBMISSION - here it comes...
-  private final String[] pics = {"forward.gif", "back.gif"};
-
-  /*
-   * i is the number of the match j == 0 if subA is considered, otherwise (j
-   * must then be 1) it is subB
-   */
-  private void writeNormalSubmission(HTMLFile f, int i, JPlagComparison comparison, int j)
-      throws ExitException {
-    Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
-    String[] files = comparison.files(j);
-
-    String[][] text = sub.readFiles(files);
-
-    Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
-    Match currentMatch;
-    String hilf;
-    int h;
-    for (int x = 0; x < comparison.matches.size(); x++) {
-      currentMatch = comparison.matches.get(x);
-
-      Token start = tokens[(j == 0 ? currentMatch.startA : currentMatch.startB)];
-      Token ende = tokens[(
-          (j == 0 ? currentMatch.startA : currentMatch.startB) + currentMatch.length - 1)];
-
-      for (int y = 0; y < files.length; y++) {
-        if (start.file.equals(files[y]) && text[y] != null) {
-          hilf = "<FONT color=\"" + Colors.getColor(x) + "\">" + (j == 1
-              ? "<div style=\"position:absolute;left:0\">" : "")
-              + "<A HREF=\"javascript:ZweiFrames('match" + i + "-" + (1 - j) + ".html#" + x + "',"
-              + (3 - j) + ",'match" + i
-              + "-top.html#" + x + "',1)\"><IMG SRC=\"" + pics[j] + "\" ALT=\"other\" "
-              + "BORDER=\"0\" ALIGN=\""
-              + (j == 0 ? "right" : "left") + "\"></A>" + (j == 1 ? "</div>" : "") + "<B>";
-          // position the icon and the beginning of the colorblock
-          if (text[y][start.getLine() - 1].endsWith("</FONT>")) {
-            text[y][start.getLine() - 1] += hilf;
-          } else {
-            text[y][start.getLine() - 1] = hilf + text[y][start.getLine() - 1];
-          }
-          // the link location is placed 3 lines before the start of a block
-          h = (Math.max(start.getLine() - 4, 0));
-          text[y][h] = "<A NAME=\"" + x + "\"></A>" + text[y][h];
-          // mark the end
-          if (start.getLine() != ende.getLine() && // if match is only one line
-              text[y][ende.getLine() - 1].startsWith("<FONT ")) {
-            text[y][ende.getLine() - 1] = "</B></FONT>" + text[y][ende.getLine() - 1];
-          } else {
-            text[y][ende.getLine() - 1] += "</B></FONT>";
-          }
+    private void writeMatch(JPlagComparison comparison, int i) throws ExitException {
+        HTMLFile htmlFile = createHTMLFile("match" + i + ".html");
+
+        writeHTMLHeader(htmlFile, TagParser.parse(msg.getString("Report.Matches_for_X1_AND_X2"),
+                new String[] {comparison.firstSubmission.name, comparison.secondSubmission.name}));
+
+        htmlFile.println("<body>");
+        htmlFile.println("  <div style=\"align-items: center; display: flex; justify-content: space-around;\">");
+
+        htmlFile.println("    <div>");
+        htmlFile.println("      <h3 align=\"center\">");
+        htmlFile.println(TagParser.parse(msg.getString("Report.Matches_for_X1_AND_X2"),
+                new String[] {comparison.firstSubmission.name, comparison.secondSubmission.name}));
+        htmlFile.println("      </h3>");
+        htmlFile.println("      <h1 align=\"center\">");
+        htmlFile.println("        " + comparison.roundedPercent() + "%");
+        htmlFile.println("      </h1>");
+        htmlFile.println("      <center>");
+        htmlFile.println("        <a href=\"index.html\" target=\"_top\">");
+        htmlFile.println("          " + msg.getString("Report.INDEX"));
+        htmlFile.println("        </a>");
+        htmlFile.println("        <span>-</span>");
+        htmlFile.println("        <a href=\"help-en.html\" target=\"_top\">");
+        htmlFile.println("          " + msg.getString("Report.HELP"));
+        htmlFile.println("        </a>");
+        htmlFile.println("      </center>");
+        htmlFile.println("    </div>");
+
+        htmlFile.println("    <div>");
+        reportComparison(htmlFile, comparison, i);
+        htmlFile.println("    </div>");
+
+        htmlFile.println("  </div>");
+
+        htmlFile.println("  <hr>");
+
+        htmlFile.println("  <div style=\"display: flex;\">");
+
+        if (result.getOptions().getLanguage().usesIndex()) {
+            writeIndexedSubmission(htmlFile, i, comparison, 0);
+            writeIndexedSubmission(htmlFile, i, comparison, 1);
+        } else if (result.getOptions().getLanguage().supportsColumns()) {
+            writeImprovedSubmission(htmlFile, i, comparison, 0);
+            writeImprovedSubmission(htmlFile, i, comparison, 1);
+        } else {
+            writeNormalSubmission(htmlFile, i, comparison, 0);
+            writeNormalSubmission(htmlFile, i, comparison, 1);
         }
-      }
+
+        htmlFile.println("  </div>");
+
+        htmlFile.println("</body>");
+        htmlFile.println("</html>");
+        htmlFile.close();
     }
 
-    if (result.getOptions().hasBaseCode() && comparison.bcMatchesA != null
-        && comparison.bcMatchesB != null) {
-      JPlagBaseCodeComparison baseCodeComparison = (j == 0 ? comparison.bcMatchesA
-          : comparison.bcMatchesB);
-
-      for (int x = 0; x < baseCodeComparison.matches.size(); x++) {
-        currentMatch = baseCodeComparison.matches.get(x);
-        Token start = tokens[currentMatch.startA];
-        Token ende = tokens[currentMatch.startA + currentMatch.length - 1];
-
-        for (int y = 0; y < files.length; y++) {
-          if (start.file.equals(files[y]) && text[y] != null) {
-            hilf = ("<font color=\"#C0C0C0\"><EM>");
-            // position the icon and the beginning of the colorblock
-            if (text[y][start.getLine() - 1].endsWith("<font color=\"#000000\">")) {
-              text[y][start.getLine() - 1] += hilf;
+    /**
+     * This method generates an table entry in the list of all comparisons.
+     */
+    private void reportComparison(HTMLFile htmlFile, JPlagComparison comparison, int index) {
+        Match match;
+        Token[] tokensA = comparison.firstSubmission.tokenList.tokens;
+        Token[] tokensB = comparison.secondSubmission.tokenList.tokens;
+        // sort();
+
+        htmlFile.println("<TABLE BORDER=\"1\" CELLSPACING=\"0\" BGCOLOR=\"#d0d0d0\">");
+        htmlFile.println("<TR><TH><TH>" + comparison.firstSubmission.name + " (" + comparison.percentA() + "%)<TH>" + comparison.secondSubmission.name
+                + " (" + comparison.percentB() + "%)<TH>" + msg.getString("AllMatches.Tokens"));
+
+        for (int i = 0; i < comparison.matches.size(); i++) {
+            match = comparison.matches.get(i);
+
+            Token startA = tokensA[match.startA];
+            Token endA = tokensA[match.startA + match.length - 1];
+            Token startB = tokensB[match.startB];
+            Token endB = tokensB[match.startB + match.length - 1];
+
+            String col = Colors.getColor(i);
+
+            htmlFile.print("<TR><TD BGCOLOR=\"" + col + "\"><FONT COLOR=\"" + col + "\">-</FONT>");
+            htmlFile.print("<TD><A HREF=\"javascript:ZweiFrames('match" + index + "-0.html#" + i + "',2,'match" + index + "-1.html#" + i
+                    + "',3)\" NAME=\"" + i + "\">");
+            htmlFile.print(new String(startA.file.getBytes()));
+
+            if (result.getOptions().getLanguage().usesIndex()) {
+                htmlFile.print("(" + startA.getIndex() + "-" + endA.getIndex() + ")");
             } else {
-              text[y][start.getLine() - 1] = hilf + text[y][start.getLine() - 1];
+                htmlFile.print("(" + startA.getLine() + "-" + endA.getLine() + ")");
             }
 
-            // mark the end
-            if (start.getLine() != ende.getLine() && // match is only one line
-                text[y][ende.getLine() - 1].startsWith("<font color=\"#C0C0C0\">")) {
-              text[y][ende.getLine() - 1] =
-                  "</EM><font color=\"#000000\">" + text[y][ende.getLine() - 1];
+            htmlFile.print("<TD><A HREF=\"javascript:ZweiFrames('match" + index + "-0.html#" + i + "',2,'match" + index + "-1.html#" + i
+                    + "',3)\" NAME=\"" + i + "\">");
+            htmlFile.print(startB.file);
+
+            if (result.getOptions().getLanguage().usesIndex()) {
+                htmlFile.print("(" + startB.getIndex() + "-" + endB.getIndex());
             } else {
-              text[y][ende.getLine() - 1] += "</EM><font color=\"#000000\">";
+                htmlFile.print("(" + startB.getLine() + "-" + endB.getLine());
             }
-          }
+
+            htmlFile.println(")</A><TD ALIGN=center>" + "<FONT COLOR=\"" + comparison.color(match.length) + "\">" + match.length + "</FONT>");
         }
-      }
-    }
 
-    f.println("<div style=\"flex-grow: 1;\">");
-
-    for (int x = 0; x < text.length; x++) {
-      f.println("<h3>");
-      f.println("<center>");
-      f.println("<span>" + sub.name + "</span>");
-      f.println("<span> - </span>");
-      f.println("<span>" + files[x] + "</span>");
-      f.println("</center>");
-      f.println("</h3>");
-      f.println("<HR>");
-      if (result.getOptions().getLanguage().isPreformated()) {
-        f.println("<PRE>");
-      }
-      for (int y = 0; y < text[x].length; y++) {
-        f.print(text[x][y]);
-        if (!result.getOptions().getLanguage().isPreformated()) {
-          f.println("<BR>");
-        } else {
-          f.println();
+        if (result.getOptions().hasBaseCode()) {
+            htmlFile.print(
+                    "<TR><TD BGCOLOR=\"#C0C0C0\"><TD>" + msg.getString("AllMatches.Basecode") + " " + comparison.roundedPercentBasecodeA() + "%");
+            htmlFile.println("<TD>" + msg.getString("AllMatches.Basecode") + " " + comparison.roundedPercentBasecodeB() + "%<TD>&nbsp;");
         }
-      }
-      if (result.getOptions().getLanguage().isPreformated()) {
-        f.println("</PRE>");
-      }
+
+        htmlFile.println("</TABLE>");
     }
 
-    f.println("</div>");
-  }
-
-  /*
-   * i is the number of the match j == 0 if subA is considered, otherwise it
-   * is subB
-   *
-   * This procedure uses only the getIndex() method of the token. It is meant
-   * to be used with the Character front end
-   */
-  private void writeIndexedSubmission(HTMLFile f, int i, JPlagComparison comparison, int j)
-      throws ExitException {
-    Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
-    String[] files = comparison.files(j);
-    char[][] text = sub.readFilesChar(files);
-    Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
-
-    // get index array with matches sorted in ascending order.
-    int[] perm = comparison.sort_permutation(j);
-
-    int index = 0; // match index
-    Match onematch = null;
-    Token start = null;
-    Token end = null;
-
-    f.println("<div style=\"flex-grow: 1;\">");
-
-    for (int fileIndex = 0; fileIndex < files.length; fileIndex++) {
-      f.println("<h3>");
-      f.println("<center>");
-      f.println("<span>" + sub.name + "</span>");
-      f.println("<span> - </span>");
-      f.println("<span>" + files[fileIndex] + "</span>");
-      f.println("</center>");
-      f.println("</h3>");
-      f.println("<HR>");
-      char[] buffer = text[fileIndex];
-
-      for (int charNr = 0; charNr < buffer.length; charNr++) {
-        if (onematch == null) {
-          if (index < comparison.matches.size()) {
-            onematch = comparison.matches.get(perm[index]);
-            start = tokens[(j == 0 ? onematch.startA : onematch.startB)];
-            end = tokens[((j == 0 ? onematch.startA : onematch.startB) + onematch.length - 1)];
-            index++;
-          } else {
-            start = end = null;
-          }
-        }
-        // begin markup
-        if (start != null && start.getIndex() == charNr) {
-          f.print("<A NAME=\"" + perm[index - 1] + "\"></A>");
-          f.print("<FONT color=\"" + Colors.getColor(perm[index - 1]) + "\"><B>");
-          //"<A HREF=\"javascript:ZweiFrames('match"+i+"-"+(1-j)+
-          //".html#"+index+"',"+(3-j)+",'match"+i+"-top.html#"+index+
-          //"',1)\">"+"<IMG SRC=\""+pics[j]+
-          //"\" ALT=\"other\" BORDER=\"0\" "+"ALIGN="+
-          //(j==0 ? "right" : "left")+"></A>");
-        }
-        // text
-        if (buffer[charNr] == '<') {
-          f.print("&lt;");
-        } else if (buffer[charNr] == '>') {
-          f.print("&gt;");
-        } else if (buffer[charNr] == '\n') {
-          f.print("<br>\n");
-        } else {
-          f.print(buffer[charNr]);
+    // --------------------------------------------------------------------------
+    // ==========================================================================
+    // --------------------------------------------------------------------------
+
+    // TODO:
+    // /* this function copies all submissions into the result directory */
+    // private int copySubmissions() throws jplag.ExitException {
+    // int bytes = 0;
+    // for (Iterator<Submission> i = program.clusters.neededSubmissions.iterator(); i.hasNext(); ) {
+    // Submission sub = i.next();
+    // int index = this.program.clusters.submissions.indexOf(sub);
+    //
+    // HTMLFile f = createHTMLFile(reportDir, "submission" + index + ".html");
+    // writeHTMLHeader(f, sub.name);
+    // f.println("<BODY BGCOLOR=\"#ffffff\">");
+    //
+    // String[] files = sub.files;
+    // String text[][] = sub.readFiles(files);
+    //
+    // for (int j = 0; j < files.length; j++) {
+    // f.println("<HR>\n<H3><CENTER>" + files[j] + "</CENTER></H3><HR>");
+    // if (this.language.isPreformated()) {
+    // f.println("<PRE>");
+    // }
+    // for (int k = 0; k < text[j].length; k++) {
+    // f.print(text[j][k]);
+    // if (!this.language.isPreformated()) {
+    // f.println("<BR>");
+    // } else {
+    // f.println();
+    // }
+    // }
+    // if (language.isPreformated()) {
+    // f.println("</PRE>");
+    // }
+    // }
+    //
+    // f.println("</BODY>\n</HTML>");
+    // f.close();
+    // bytes += f.bytesWritten();
+    // }
+    // return bytes;
+    // }
+
+    // TODO TS: Cluster currently not supported
+    // private int writeClusters(Cluster clustering) throws jplag.ExitException {
+    // int bytes = 0;
+    //
+    // HTMLFile f = createHTMLFile("cluster.html");
+    // writeHTMLHeader(f, msg.getString("Report.Clustering_Results"));
+    // String clustertype = msg.getString("Report.Type") + ": " + program.clusters.getType();
+    // f.println("<BODY>\n<H2>" + msg.getString("Report.Clustering_Results") + " (" + clustertype
+    // + ")</H2>");
+    // f.println("<H3><A HREF=\"dendro.html\">" + msg.getString("Report.Dendrogram") + "</A></H3>");
+    // bytes += this.program.clusters.makeDendrograms(reportDir, clustering);
+    //
+    // if (this.program.get_threshold() != null) {
+    // for (int i = 0; i < this.program.get_threshold().length; i++) {
+    // float threshold = this.program.get_threshold()[i];
+    // String clustertitle = TagParser
+    // .parse(msg.getString("Report.Clusters_for_Xpercent_treshold"),
+    // new String[]{threshold + ""});
+    // f.println("<H3><A HREF=\"cluster" + threshold + ".html\">" + clustertitle + "</A></H3>");
+    // HTMLFile f2 = createHTMLFile(reportDir, "cluster" + threshold + ".html");
+    // writeHTMLHeader(f2, clustertitle);
+    // f2.println("<BODY>\n<H2>" + clustertitle + " (" + clustertype + ")</H2>");
+    // String text = program.clusters.printClusters(clustering, threshold, f2);
+    // f2.println("</BODY>\n</HTML>");
+    // f2.close();
+    // bytes += f2.bytesWritten();
+    // f.print(text);
+    // }
+    // } else {
+    // float increase = this.program.clusters.maxMergeValue / 10;
+    // if (increase < 5) {
+    // increase = 5;
+    // }
+    // for (float threshold = increase; threshold <= program.clusters.maxMergeValue;
+    // threshold += increase) {
+    // String clustertitle = TagParser
+    // .parse(msg.getString("Report.Clusters_for_Xpercent_treshold"),
+    // new String[]{threshold + ""});
+    // f.println(
+    // "<H3><A HREF=\"cluster" + (int) threshold + ".html\">" + clustertitle + "</A></H3>");
+    // HTMLFile f2 = createHTMLFile(reportDir, "cluster" + (int) threshold + ".html");
+    // writeHTMLHeader(f2, clustertitle);
+    // f2.println("<BODY>\n<H2>" + clustertitle + " (" + clustertype + ")</H2>");
+    // String text = program.clusters.printClusters(clustering, (int) threshold, f2);
+    // f2.println("</BODY>\n</HTML>");
+    // f2.close();
+    // bytes += f2.bytesWritten();
+    // f.print(text);
+    // }
+    // }
+    //
+    // f.println("</BODY>\n</HTML>");
+    // f.close();
+    //
+    // bytes += copySubmissions();
+    // return f.bytesWritten() + bytes;
+    // }
+
+    // SUBMISSION - here it comes...
+    private final String[] pics = {"forward.gif", "back.gif"};
+
+    /*
+     * i is the number of the match j == 0 if subA is considered, otherwise (j must then be 1) it is subB
+     */
+    private void writeNormalSubmission(HTMLFile f, int i, JPlagComparison comparison, int j) throws ExitException {
+        Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
+        String[] files = comparison.files(j);
+
+        String[][] text = sub.readFiles(files);
+
+        Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
+        Match currentMatch;
+        String hilf;
+        int h;
+        for (int x = 0; x < comparison.matches.size(); x++) {
+            currentMatch = comparison.matches.get(x);
+
+            Token start = tokens[(j == 0 ? currentMatch.startA : currentMatch.startB)];
+            Token ende = tokens[((j == 0 ? currentMatch.startA : currentMatch.startB) + currentMatch.length - 1)];
+
+            for (int y = 0; y < files.length; y++) {
+                if (start.file.equals(files[y]) && text[y] != null) {
+                    hilf = "<FONT color=\"" + Colors.getColor(x) + "\">" + (j == 1 ? "<div style=\"position:absolute;left:0\">" : "")
+                            + "<A HREF=\"javascript:ZweiFrames('match" + i + "-" + (1 - j) + ".html#" + x + "'," + (3 - j) + ",'match" + i
+                            + "-top.html#" + x + "',1)\"><IMG SRC=\"" + pics[j] + "\" ALT=\"other\" " + "BORDER=\"0\" ALIGN=\""
+                            + (j == 0 ? "right" : "left") + "\"></A>" + (j == 1 ? "</div>" : "") + "<B>";
+                    // position the icon and the beginning of the colorblock
+                    if (text[y][start.getLine() - 1].endsWith("</FONT>")) {
+                        text[y][start.getLine() - 1] += hilf;
+                    } else {
+                        text[y][start.getLine() - 1] = hilf + text[y][start.getLine() - 1];
+                    }
+                    // the link location is placed 3 lines before the start of a block
+                    h = (Math.max(start.getLine() - 4, 0));
+                    text[y][h] = "<A NAME=\"" + x + "\"></A>" + text[y][h];
+                    // mark the end
+                    if (start.getLine() != ende.getLine() && // if match is only one line
+                            text[y][ende.getLine() - 1].startsWith("<FONT ")) {
+                        text[y][ende.getLine() - 1] = "</B></FONT>" + text[y][ende.getLine() - 1];
+                    } else {
+                        text[y][ende.getLine() - 1] += "</B></FONT>";
+                    }
+                }
+            }
         }
-        // end markup
-        if (end != null && end.getIndex() == charNr) {
-          f.print("</B></FONT>");
-          onematch = null; // switch to next match
+
+        if (result.getOptions().hasBaseCode() && comparison.bcMatchesA != null && comparison.bcMatchesB != null) {
+            JPlagBaseCodeComparison baseCodeComparison = (j == 0 ? comparison.bcMatchesA : comparison.bcMatchesB);
+
+            for (int x = 0; x < baseCodeComparison.matches.size(); x++) {
+                currentMatch = baseCodeComparison.matches.get(x);
+                Token start = tokens[currentMatch.startA];
+                Token ende = tokens[currentMatch.startA + currentMatch.length - 1];
+
+                for (int y = 0; y < files.length; y++) {
+                    if (start.file.equals(files[y]) && text[y] != null) {
+                        hilf = ("<font color=\"#C0C0C0\"><EM>");
+                        // position the icon and the beginning of the colorblock
+                        if (text[y][start.getLine() - 1].endsWith("<font color=\"#000000\">")) {
+                            text[y][start.getLine() - 1] += hilf;
+                        } else {
+                            text[y][start.getLine() - 1] = hilf + text[y][start.getLine() - 1];
+                        }
+
+                        // mark the end
+                        if (start.getLine() != ende.getLine() && // match is only one line
+                                text[y][ende.getLine() - 1].startsWith("<font color=\"#C0C0C0\">")) {
+                            text[y][ende.getLine() - 1] = "</EM><font color=\"#000000\">" + text[y][ende.getLine() - 1];
+                        } else {
+                            text[y][ende.getLine() - 1] += "</EM><font color=\"#000000\">";
+                        }
+                    }
+                }
+            }
         }
-      }
-    }
 
-    f.println("</div>");
-  }
-
-  /*
-   * i is the number of the match j == 0 if subA is considered, otherwise (j
-   * must then be 1) it is subB
-   *
-   * This procedure makes use of the column and length information!
-   */
-  private int writeImprovedSubmission(HTMLFile f, int i, JPlagComparison comparison, int j)
-      throws jplag.ExitException {
-    Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
-    String[] files = comparison.files(j);
-    String[][] text = sub.readFiles(files);
-    Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
-
-    // Markup list:
-    Comparator<MarkupText> comp = (mo1, mo2) -> {
-      int col1 = mo1.column;
-      int col2 = mo2.column;
-      if (col1 > col2) {
-        return -1;
-      } else if (col1 < col2) {
-        return 1;
-      }
-      return (mo1.frontMarkup ? -1 : 1);
-    };
-    TreeMap<MarkupText, Object> markupList = new TreeMap<>(comp);
-
-    for (int x = 0; x < comparison.matches.size(); x++) {
-      Match onematch = comparison.matches.get(x);
-
-      Token start = tokens[(j == 0 ? onematch.startA : onematch.startB)];
-      Token end = tokens[((j == 0 ? onematch.startA : onematch.startB) + onematch.length - 1)];
-      for (int fileIndex = 0; fileIndex < files.length; fileIndex++) {
-        if (start.file.equals(files[fileIndex]) && text[fileIndex] != null) {
-          String tmp = "<FONT color=\"" + Colors.getColor(x) + "\">" + (j == 1
-              ? "<div style=\"position:absolute;left:0\">" : "")
-              + "<A HREF=\"javascript:ZweiFrames('match" + i + "-" + (1 - j) + ".html#" + x + "',"
-              + (3 - j) + ",'match" + i
-              + "-top.html#" + x + "',1)\"><IMG SRC=\"" + pics[j] + "\" ALT=\"other\" "
-              + "BORDER=\"0\" ALIGN=\""
-              + (j == 0 ? "right" : "left") + "\"></A>" + (j == 1 ? "</div>" : "") + "<B>";
-          // position the icon and the beginning of the colorblock
-          markupList
-              .put(new MarkupText(fileIndex, start.getLine() - 1, start.getColumn() - 1, tmp, true),
-                  null);
-          // mark the end
-          markupList
-              .put(new MarkupText(fileIndex, end.getLine() - 1,
-                      end.getColumn() + end.getLength() - 1, "</B></FONT>", false),
-                  null);
-
-          // the link location is placed 3 lines before the start of a block
-          int linkLine = (Math.max(start.getLine() - 4, 0));
-          markupList
-              .put(new MarkupText(fileIndex, linkLine, 0, "<A NAME=\"" + x + "\"></A>", false),
-                  null);
+        f.println("<div style=\"flex-grow: 1;\">");
+
+        for (int x = 0; x < text.length; x++) {
+            f.println("<h3>");
+            f.println("<center>");
+            f.println("<span>" + sub.name + "</span>");
+            f.println("<span> - </span>");
+            f.println("<span>" + files[x] + "</span>");
+            f.println("</center>");
+            f.println("</h3>");
+            f.println("<HR>");
+            if (result.getOptions().getLanguage().isPreformated()) {
+                f.println("<PRE>");
+            }
+            for (int y = 0; y < text[x].length; y++) {
+                f.print(text[x][y]);
+                if (!result.getOptions().getLanguage().isPreformated()) {
+                    f.println("<BR>");
+                } else {
+                    f.println();
+                }
+            }
+            if (result.getOptions().getLanguage().isPreformated()) {
+                f.println("</PRE>");
+            }
         }
-      }
+
+        f.println("</div>");
     }
 
-    if (result.getOptions().hasBaseCode() && comparison.bcMatchesA != null
-        && comparison.bcMatchesB != null) {
-      JPlagBaseCodeComparison baseCodeComparison = (j == 0 ? comparison.bcMatchesA
-          : comparison.bcMatchesB);
+    /*
+     * i is the number of the match j == 0 if subA is considered, otherwise it is subB This procedure uses only the
+     * getIndex() method of the token. It is meant to be used with the Character front end
+     */
+    private void writeIndexedSubmission(HTMLFile f, int i, JPlagComparison comparison, int j) throws ExitException {
+        Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
+        String[] files = comparison.files(j);
+        char[][] text = sub.readFilesChar(files);
+        Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
+
+        // get index array with matches sorted in ascending order.
+        int[] perm = comparison.sort_permutation(j);
 
-      for (int x = 0; x < baseCodeComparison.matches.size(); x++) {
-        Match onematch = baseCodeComparison.matches.get(x);
-        Token start = tokens[onematch.startA];
-        Token end = tokens[onematch.startA + onematch.length - 1];
+        int index = 0; // match index
+        Match onematch = null;
+        Token start = null;
+        Token end = null;
+
+        f.println("<div style=\"flex-grow: 1;\">");
 
         for (int fileIndex = 0; fileIndex < files.length; fileIndex++) {
-          if (start.file.equals(files[fileIndex]) && text[fileIndex] != null) {
-            String tmp = "<font color=\"#C0C0C0\"><EM>";
-            // beginning of the colorblock
-            markupList.put(
-                new MarkupText(fileIndex, start.getLine() - 1, start.getColumn() - 1, tmp, false),
-                null);
-            // mark the end
-            markupList.put(
-                new MarkupText(fileIndex, end.getLine() - 1, end.getColumn() + end.getLength() - 1,
-                    "</EM></font>",
-                    true), null);
-          }
+            f.println("<h3>");
+            f.println("<center>");
+            f.println("<span>" + sub.name + "</span>");
+            f.println("<span> - </span>");
+            f.println("<span>" + files[fileIndex] + "</span>");
+            f.println("</center>");
+            f.println("</h3>");
+            f.println("<HR>");
+            char[] buffer = text[fileIndex];
+
+            for (int charNr = 0; charNr < buffer.length; charNr++) {
+                if (onematch == null) {
+                    if (index < comparison.matches.size()) {
+                        onematch = comparison.matches.get(perm[index]);
+                        start = tokens[(j == 0 ? onematch.startA : onematch.startB)];
+                        end = tokens[((j == 0 ? onematch.startA : onematch.startB) + onematch.length - 1)];
+                        index++;
+                    } else {
+                        start = end = null;
+                    }
+                }
+                // begin markup
+                if (start != null && start.getIndex() == charNr) {
+                    f.print("<A NAME=\"" + perm[index - 1] + "\"></A>");
+                    f.print("<FONT color=\"" + Colors.getColor(perm[index - 1]) + "\"><B>");
+                    // "<A HREF=\"javascript:ZweiFrames('match"+i+"-"+(1-j)+
+                    // ".html#"+index+"',"+(3-j)+",'match"+i+"-top.html#"+index+
+                    // "',1)\">"+"<IMG SRC=\""+pics[j]+
+                    // "\" ALT=\"other\" BORDER=\"0\" "+"ALIGN="+
+                    // (j==0 ? "right" : "left")+"></A>");
+                }
+                // text
+                if (buffer[charNr] == '<') {
+                    f.print("&lt;");
+                } else if (buffer[charNr] == '>') {
+                    f.print("&gt;");
+                } else if (buffer[charNr] == '\n') {
+                    f.print("<br>\n");
+                } else {
+                    f.print(buffer[charNr]);
+                }
+                // end markup
+                if (end != null && end.getIndex() == charNr) {
+                    f.print("</B></FONT>");
+                    onematch = null; // switch to next match
+                }
+            }
         }
-      }
+
+        f.println("</div>");
     }
 
-    // Apply changes:
-    for (MarkupText markup : markupList.keySet()) {
-      //System.out.println(markup);
-      String tmp = text[markup.fileIndex][markup.lineIndex];
-      // is there any &quot;, &amp;, &gt; or &lt; in the String?
-      if (tmp.indexOf('&') >= 0) {
-        Vector<String> tmpV = new Vector<>();
-        // convert the string into a vector
-        int strLength = tmp.length();
-        for (int k = 0; k < strLength; k++) {
-          if (tmp.charAt(k) != '&') {
-            tmpV.addElement(tmp.charAt(k) + "");
-          } else { //put &quot;, &amp;, &gt; and &lt; into one element
-            String tmpSub = tmp.substring(k);
-            if (tmpSub.startsWith("&quot;")) {
-              tmpV.addElement("&quot;");
-              k = k + 5;
-            } else if (tmpSub.startsWith("&amp;")) {
-              tmpV.addElement("&amp;");
-              k = k + 4;
-            } else if (tmpSub.startsWith("&lt;")) {
-              tmpV.addElement("&lt;");
-              k = k + 3;
-            } else if (tmpSub.startsWith("&gt;")) {
-              tmpV.addElement("&gt;");
-              k = k + 3;
-            } else {
-              tmpV.addElement(tmp.charAt(k) + "");
+    /*
+     * i is the number of the match j == 0 if subA is considered, otherwise (j must then be 1) it is subB This procedure
+     * makes use of the column and length information!
+     */
+    private int writeImprovedSubmission(HTMLFile f, int i, JPlagComparison comparison, int j) throws jplag.ExitException {
+        Submission sub = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission);
+        String[] files = comparison.files(j);
+        String[][] text = sub.readFiles(files);
+        Token[] tokens = (j == 0 ? comparison.firstSubmission : comparison.secondSubmission).tokenList.tokens;
+
+        // Markup list:
+        Comparator<MarkupText> comp = (mo1, mo2) -> {
+            int col1 = mo1.column;
+            int col2 = mo2.column;
+            if (col1 > col2) {
+                return -1;
+            } else if (col1 < col2) {
+                return 1;
+            }
+            return (mo1.frontMarkup ? -1 : 1);
+        };
+        TreeMap<MarkupText, Object> markupList = new TreeMap<>(comp);
+
+        for (int x = 0; x < comparison.matches.size(); x++) {
+            Match onematch = comparison.matches.get(x);
+
+            Token start = tokens[(j == 0 ? onematch.startA : onematch.startB)];
+            Token end = tokens[((j == 0 ? onematch.startA : onematch.startB) + onematch.length - 1)];
+            for (int fileIndex = 0; fileIndex < files.length; fileIndex++) {
+                if (start.file.equals(files[fileIndex]) && text[fileIndex] != null) {
+                    String tmp = "<FONT color=\"" + Colors.getColor(x) + "\">" + (j == 1 ? "<div style=\"position:absolute;left:0\">" : "")
+                            + "<A HREF=\"javascript:ZweiFrames('match" + i + "-" + (1 - j) + ".html#" + x + "'," + (3 - j) + ",'match" + i
+                            + "-top.html#" + x + "',1)\"><IMG SRC=\"" + pics[j] + "\" ALT=\"other\" " + "BORDER=\"0\" ALIGN=\""
+                            + (j == 0 ? "right" : "left") + "\"></A>" + (j == 1 ? "</div>" : "") + "<B>";
+                    // position the icon and the beginning of the colorblock
+                    markupList.put(new MarkupText(fileIndex, start.getLine() - 1, start.getColumn() - 1, tmp, true), null);
+                    // mark the end
+                    markupList.put(new MarkupText(fileIndex, end.getLine() - 1, end.getColumn() + end.getLength() - 1, "</B></FONT>", false), null);
+
+                    // the link location is placed 3 lines before the start of a block
+                    int linkLine = (Math.max(start.getLine() - 4, 0));
+                    markupList.put(new MarkupText(fileIndex, linkLine, 0, "<A NAME=\"" + x + "\"></A>", false), null);
+                }
             }
-          }
         }
-        if (markup.column <= tmpV.size()) {
-          tmpV.insertElementAt(markup.text, markup.column);
-        } else {
-          tmpV.addElement(markup.text);
+
+        if (result.getOptions().hasBaseCode() && comparison.bcMatchesA != null && comparison.bcMatchesB != null) {
+            JPlagBaseCodeComparison baseCodeComparison = (j == 0 ? comparison.bcMatchesA : comparison.bcMatchesB);
+
+            for (int x = 0; x < baseCodeComparison.matches.size(); x++) {
+                Match onematch = baseCodeComparison.matches.get(x);
+                Token start = tokens[onematch.startA];
+                Token end = tokens[onematch.startA + onematch.length - 1];
+
+                for (int fileIndex = 0; fileIndex < files.length; fileIndex++) {
+                    if (start.file.equals(files[fileIndex]) && text[fileIndex] != null) {
+                        String tmp = "<font color=\"#C0C0C0\"><EM>";
+                        // beginning of the colorblock
+                        markupList.put(new MarkupText(fileIndex, start.getLine() - 1, start.getColumn() - 1, tmp, false), null);
+                        // mark the end
+                        markupList.put(new MarkupText(fileIndex, end.getLine() - 1, end.getColumn() + end.getLength() - 1, "</EM></font>", true),
+                                null);
+                    }
+                }
+            }
         }
 
-        StringBuilder tmpVStr = new StringBuilder();
-        // reconvert the Vector into a String
-        for (int k = 0; k < tmpV.size(); k++) {
-          tmpVStr.append(tmpV.elementAt(k));
+        // Apply changes:
+        for (MarkupText markup : markupList.keySet()) {
+            // System.out.println(markup);
+            String tmp = text[markup.fileIndex][markup.lineIndex];
+            // is there any &quot;, &amp;, &gt; or &lt; in the String?
+            if (tmp.indexOf('&') >= 0) {
+                Vector<String> tmpV = new Vector<>();
+                // convert the string into a vector
+                int strLength = tmp.length();
+                for (int k = 0; k < strLength; k++) {
+                    if (tmp.charAt(k) != '&') {
+                        tmpV.addElement(tmp.charAt(k) + "");
+                    } else { // put &quot;, &amp;, &gt; and &lt; into one element
+                        String tmpSub = tmp.substring(k);
+                        if (tmpSub.startsWith("&quot;")) {
+                            tmpV.addElement("&quot;");
+                            k = k + 5;
+                        } else if (tmpSub.startsWith("&amp;")) {
+                            tmpV.addElement("&amp;");
+                            k = k + 4;
+                        } else if (tmpSub.startsWith("&lt;")) {
+                            tmpV.addElement("&lt;");
+                            k = k + 3;
+                        } else if (tmpSub.startsWith("&gt;")) {
+                            tmpV.addElement("&gt;");
+                            k = k + 3;
+                        } else {
+                            tmpV.addElement(tmp.charAt(k) + "");
+                        }
+                    }
+                }
+                if (markup.column <= tmpV.size()) {
+                    tmpV.insertElementAt(markup.text, markup.column);
+                } else {
+                    tmpV.addElement(markup.text);
+                }
+
+                StringBuilder tmpVStr = new StringBuilder();
+                // reconvert the Vector into a String
+                for (int k = 0; k < tmpV.size(); k++) {
+                    tmpVStr.append(tmpV.elementAt(k));
+                }
+                text[markup.fileIndex][markup.lineIndex] = tmpVStr.toString();
+            } else {
+                text[markup.fileIndex][markup.lineIndex] = tmp.substring(0, (Math.min(tmp.length(), markup.column))) + markup.text
+                        + tmp.substring((Math.min(tmp.length(), markup.column)));
+            }
         }
-        text[markup.fileIndex][markup.lineIndex] = tmpVStr.toString();
-      } else {
-        text[markup.fileIndex][markup.lineIndex] =
-            tmp.substring(0, (Math.min(tmp.length(), markup.column)))
-                + markup.text + tmp
-                .substring((Math.min(tmp.length(), markup.column)));
-      }
-    }
 
-    f.println("<div style=\"flex-grow: 1;\">");
-
-    for (int x = 0; x < text.length; x++) {
-      f.println("<h3>");
-      f.println("<center>");
-      f.println("<span>" + sub.name + "</span>");
-      f.println("<span> - </span>");
-      f.println("<span>" + files[x] + "</span>");
-      f.println("</center>");
-      f.println("</h3>");
-      f.println("<HR>");
-      if (result.getOptions().getLanguage().isPreformated()) {
-        f.println("<PRE>");
-      }
-      for (int y = 0; y < text[x].length; y++) {
-        f.print(text[x][y]);
-        if (!result.getOptions().getLanguage().isPreformated()) {
-          f.println("<BR>");
-        } else {
-          f.println();
+        f.println("<div style=\"flex-grow: 1;\">");
+
+        for (int x = 0; x < text.length; x++) {
+            f.println("<h3>");
+            f.println("<center>");
+            f.println("<span>" + sub.name + "</span>");
+            f.println("<span> - </span>");
+            f.println("<span>" + files[x] + "</span>");
+            f.println("</center>");
+            f.println("</h3>");
+            f.println("<HR>");
+            if (result.getOptions().getLanguage().isPreformated()) {
+                f.println("<PRE>");
+            }
+            for (int y = 0; y < text[x].length; y++) {
+                f.print(text[x][y]);
+                if (!result.getOptions().getLanguage().isPreformated()) {
+                    f.println("<BR>");
+                } else {
+                    f.println();
+                }
+            }
+            if (result.getOptions().getLanguage().isPreformated()) {
+                f.println("</PRE>");
+            }
         }
-      }
-      if (result.getOptions().getLanguage().isPreformated()) {
-        f.println("</PRE>");
-      }
-    }
 
-    f.println("</div>");
+        f.println("</div>");
 
-    return f.bytesWritten();
-  }
+        return f.bytesWritten();
+    }
 }

+ 28 - 29
jplag/src/main/java/jplag/reporting/TagParser.java

@@ -2,36 +2,35 @@ package jplag.reporting;
 
 public class TagParser {
 
-  /**
-   * Replaces all "{<index>_description}" tags inside the message string with params[<index>-1].
-   * <p>
-   * Example: parse("blb {1_n/a} d {3_desc} sf {2_bla} d", new String[] {"#", blabla(), null});
-   * returns "blb # d null sf blab d", if blabla() returns "blab"
-   */
-  public static String parse(String message, String[] params) {
-    String[] tokens = message.split("[{}]", -1);
-    String result = tokens[0];
+    /**
+     * Replaces all "{<index>_description}" tags inside the message string with params[<index>-1].
+     * <p>
+     * Example: parse("blb {1_n/a} d {3_desc} sf {2_bla} d", new String[] {"#", blabla(), null}); returns "blb # d null sf
+     * blab d", if blabla() returns "blab"
+     */
+    public static String parse(String message, String[] params) {
+        String[] tokens = message.split("[{}]", -1);
+        String result = tokens[0];
 
-    for (int i = 1; i < tokens.length; i += 2)    // Go to next tag position
-    {
-      try {
-        int ind = tokens[i].indexOf('_');
-        String num = (ind == -1) ? tokens[i] : tokens[i].substring(0, ind);
-        result += params[Integer.parseInt(num) - 1];
-      } catch (Exception ex) {
-        if (ex instanceof NumberFormatException
-            || ex instanceof IndexOutOfBoundsException) {
-          ex.printStackTrace();
-          result += "{ILLEGAL PARAMETER INDEX \"" + tokens[i] + "\"}";
-        } else {
-          throw (RuntimeException) ex;
+        for (int i = 1; i < tokens.length; i += 2)    // Go to next tag position
+        {
+            try {
+                int ind = tokens[i].indexOf('_');
+                String num = (ind == -1) ? tokens[i] : tokens[i].substring(0, ind);
+                result += params[Integer.parseInt(num) - 1];
+            } catch (Exception ex) {
+                if (ex instanceof NumberFormatException || ex instanceof IndexOutOfBoundsException) {
+                    ex.printStackTrace();
+                    result += "{ILLEGAL PARAMETER INDEX \"" + tokens[i] + "\"}";
+                } else {
+                    throw (RuntimeException) ex;
+                }
+            }
+            if (i + 1 < tokens.length) {
+                result += tokens[i + 1];
+            }
         }
-      }
-      if (i + 1 < tokens.length) {
-        result += tokens[i + 1];
-      }
-    }
 
-    return result;
-  }
+        return result;
+    }
 }

+ 4 - 4
jplag/src/main/java/jplag/strategy/ComparisonMode.java

@@ -4,8 +4,8 @@ package jplag.strategy;
  * The comparison mode determines which `ComparisonStrategy` is used to compare submissions.
  */
 public enum ComparisonMode {
-  NORMAL,
-  REVISION,
-  SPECIAL,
-  EXTERNAL
+    NORMAL,
+    REVISION,
+    SPECIAL,
+    EXTERNAL
 }

+ 2 - 2
jplag/src/main/java/jplag/strategy/SpecialComparisonStrategy.java

@@ -18,8 +18,8 @@ public class SpecialComparisonStrategy extends AbstractComparisonStrategy {
     }
 
     /*
-     * Now the special comparison TODO PB: Previously, this comparison created a `Report.java` (removed) 
-     * TODO PB: Check whether this comparison is now any different than the others after the report has been removed
+     * Now the special comparison TODO PB: Previously, this comparison created a `Report.java` (removed) TODO PB: Check
+     * whether this comparison is now any different than the others after the report has been removed
      */
     @Override
     public JPlagResult compareSubmissions(Vector<Submission> submissions, Submission baseCodeSubmission) {