Просмотр исходного кода

Remove BufferedCounter and Colors

Philipp Bauch 6 лет назад
Родитель
Сommit
5544507c4e

+ 0 - 45
jplag/src/main/java/jplag/BufferedCounter.java

@@ -1,45 +0,0 @@
-package jplag;
-
-
-import java.io.*;
-
-/* 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;
-  }
-
-  public void write(int c) throws IOException {
-    super.write(c);
-    count++;
-  }
-  
-  public void write(char cbuf[], int off, int len) throws IOException {
-    super.write(cbuf,off,len);
-    count += len;
-  }
-  
-  public void write(String s, int off, int len) throws IOException {
-    super.write(s,off,len);
-    count += len;
-  }
-  
-  public void newLine() throws IOException {
-    super.newLine();
-    count++;
-  }
-  
-  public int bytesWritten() {
-    return count;
-  }
-}
-

+ 0 - 426
jplag/src/main/java/jplag/Colors.java

@@ -1,426 +0,0 @@
-package jplag;
-
-
-
-public class 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 ",
-
-    "#980517", "Brown ",
-
-  };
-
-  //"#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 argsv[]) {
-    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>");
-  }
-}

+ 1 - 1
jplag/src/main/java/jplag/JPlag.java

@@ -16,6 +16,6 @@ public class JPlag {
       System.out.println("Error: " + ex.getReport());
       System.out.println("Error: " + ex.getReport());
       System.exit(1);
       System.exit(1);
     }
     }
-    
+
   }
   }
 }
 }

+ 30 - 12
jplag/src/main/java/jplag/Match.java

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

+ 2 - 2
jplag/src/main/java/jplag/Matches.java

@@ -1,7 +1,7 @@
 package jplag;
 package jplag;
 
 
-
-/* Minimal class that stores "Match" objects.
+/**
+ * Minimal class that stores "Match" objects.
  */
  */
 public class Matches {
 public class Matches {
   public Match[] matches;
   public Match[] matches;

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

@@ -1,36 +1,36 @@
 package jplag;
 package jplag;
 
 
-
 import java.util.Vector;
 import java.util.Vector;
 import java.util.Comparator;
 import java.util.Comparator;
 
 
 public class SortedVector<T> extends Vector<T> {
 public class SortedVector<T> extends Vector<T> {
-    private static final long serialVersionUID = 1L;
-    private Comparator<T> cmp;
-    
-    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;
-			}
-		}
-		insertElementAt(obj, index1 - 1);
-	}
+  private static final long serialVersionUID = 1L;
+  private Comparator<T> cmp;
+
+  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;
+      }
+    }
+    insertElementAt(obj, index1 - 1);
+  }
 
 
-	public synchronized void insert(T obj) {
-		insert(obj, 1, elementCount);
-	}
+  public synchronized void insert(T obj) {
+    insert(obj, 1, elementCount);
+  }
 }
 }

+ 0 - 5
jplag/src/main/java/jplag/Submission.java

@@ -1,17 +1,12 @@
 package jplag;
 package jplag;
 
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;
-import java.io.FileReader;
 import java.io.FilenameFilter;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.net.URL;
 import java.net.URL;
 import java.text.DecimalFormat;
 import java.text.DecimalFormat;
-import java.util.Vector;
 import jplag.options.Verbosity;
 import jplag.options.Verbosity;
 
 
 /*
 /*

+ 162 - 146
jplag/src/main/java/jplag/clustering/Cluster.java

@@ -1,178 +1,194 @@
 package jplag.clustering;
 package jplag.clustering;
 
 
 public class Cluster implements Comparable<Cluster> {
 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 float similarity; // similarity threshold for this cluster
 
 
-    private Cluster left, right;
+  private int submissionNr = -1;
+  // !=-1 -> this cluster consists of one document only
 
 
-    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
+  private Cluster left, right;
 
 
-    public Cluster(int submissionNr, Clusters clusters) {
-        this.clusters = clusters;
-        this.submissionNr = submissionNr;
-        left = right = null;
-        similarity = 100;
+  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
+  // 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;
+  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();
-    }
+    calculateAllSubmissions();
+  }
 
 
-    public int size() {
-        return (submissionNr == -1 ? allSubmissions.length : 1);
-    }
+  public int size() {
+    return (submissionNr == -1 ? allSubmissions.length : 1);
+  }
 
 
-    public int getSubmissionAt(int i) {
-        return (submissionNr == -1 ? allSubmissions[i] : submissionNr);
-    }
+  public int getSubmissionAt(int i) {
+    return (submissionNr == -1 ? allSubmissions[i] : submissionNr);
+  }
 
 
-    public float getSimilarity() {
-        return similarity;
-    }
+  public float getSimilarity() {
+    return similarity;
+  }
 
 
-    public Cluster getLeft() {
-        return left;
-    }
+  public Cluster getLeft() {
+    return left;
+  }
 
 
-    public Cluster getRight() {
-        return right;
-    }
+  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 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;
     }
     }
+  }
 
 
-    // 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;
+  // 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;
+        }
+      }
     }
     }
 
 
-    // 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;
-    }
+    return maxSim;
+  }
 
 
-    // for AVR clustering
-    public float avrSimilarity(Cluster other, SimilarityMatrix simMatrix) {
-        int sizeThis = size();
-        int sizeOther = other.size();
-        float summedSim = 0;
-
-        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 / (float) (sizeThis * sizeOther);
+  // 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 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 minSim;
+  }
+
+  // for AVR clustering
+  public float avrSimilarity(Cluster other, SimilarityMatrix simMatrix) {
+    int sizeThis = size();
+    int sizeOther = other.size();
+    float summedSim = 0;
+
+    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 / (float) (sizeThis * sizeOther);
+  }
 
 
-    public int compareTo(Cluster cluster2) {
-        if(equals(cluster2))
-            return 0;
+  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;
+  }
 
 
-        int s1Size = size();
-        int s2Size = cluster2.size();
+  public int compareTo(Cluster cluster2) {
+    if (equals(cluster2)) {
+      return 0;
+    }
 
 
-        if(s1Size != s2Size)
-            return (s1Size < s2Size ? +1 : -1);
+    int s1Size = size();
+    int s2Size = cluster2.size();
 
 
-        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();
-        }
+    if (s1Size != s2Size) {
+      return (s1Size < s2Size ? +1 : -1);
+    }
 
 
-        return (size >= 0 ? 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);
+  }
 }
 }

+ 29 - 19
jplag/src/main/java/jplag/clustering/SimilarityMatrix.java

@@ -1,28 +1,34 @@
 package jplag.clustering;
 package jplag.clustering;
 
 
-//import jplag.*;
-
 public class SimilarityMatrix {
 public class SimilarityMatrix {
+
   private int size;
   private int size;
-  private float [] matrix;
+  private float[] matrix;
 //   private float maximum = 0;
 //   private float maximum = 0;
-  
-  /** The parameter is the number of submissions. */
+
+  /**
+   * The parameter is the number of submissions.
+   */
   public SimilarityMatrix(int size) {
   public SimilarityMatrix(int size) {
     this.size = size;
     this.size = size;
-    matrix = new float[size*(size+1)/2];
+    matrix = new float[size * (size + 1) / 2];
   }
   }
 
 
-  public int size() { return size; }
+  public int size() {
+    return size;
+  }
 
 
   public void setSimilarity(int a, int b, float sim) {
   public void setSimilarity(int a, int b, float sim) {
     int tmp;
     int tmp;
-    if (a >= size || b >= size)
+    if (a >= size || b >= size) {
       throw new ArrayIndexOutOfBoundsException();
       throw new ArrayIndexOutOfBoundsException();
+    }
     if (a > b) {
     if (a > b) {
-      tmp = a;   a = b;   b = tmp;
+      tmp = a;
+      a = b;
+      b = tmp;
     }
     }
-    matrix[a+(b*(b-1)/2)] = sim;
+    matrix[a + (b * (b - 1) / 2)] = sim;
 
 
 //     if (sim > maximum)
 //     if (sim > maximum)
 //       maximum = sim;
 //       maximum = sim;
@@ -32,22 +38,26 @@ public class SimilarityMatrix {
 
 
   public float getSimilarity(int a, int b) {
   public float getSimilarity(int a, int b) {
     int tmp;
     int tmp;
-    if (a >= size || b >= size)
+    if (a >= size || b >= size) {
       throw new ArrayIndexOutOfBoundsException();
       throw new ArrayIndexOutOfBoundsException();
+    }
     if (a > b) {
     if (a > b) {
-      tmp = a;   a = b;   b = tmp;
+      tmp = a;
+      a = b;
+      b = tmp;
     }
     }
-    return matrix[a+(b*(b-1)/2)];
+    return matrix[a + (b * (b - 1) / 2)];
   }
   }
 
 
   public String toString() {
   public String toString() {
     String tmp = "";
     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 += " ";
+    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";
     }
     }