public static HTMLFile createHTMLFile(File f) throws IOException { BufferedCounter new_bc = new BufferedCounter( new OutputStreamWriter(new FileOutputStream(f), "UTF-8")); HTMLFile htmlfile = new HTMLFile(new_bc); htmlfile.bc = new_bc; // if (Program.verbose_details) // Program.print(null,f.toString()+" "); return htmlfile; }
private int writeFrames(int i, AllMatches match) throws jplag.ExitException { HTMLFile f = openHTMLFile(root, "match" + i + ".html"); writeHTMLHeader(f, TagParser.parse(msg.getString("Report.Matches_for_X1_AND_X2"), new String[] { match.subName(0), match.subName(1) })); f.println("<FRAMESET ROWS=\"130,*\">\n <FRAMESET COLS=\"30%,70%\">"); f.println(" <FRAME SRC=\"match" + i + "-link.html\" NAME=\"link\" " + "FRAMEBORDER=0>"); f.println(" <FRAME SRC=\"match" + i + "-top.html\" NAME=\"top\" " + "FRAMEBORDER=0>"); f.println(" </FRAMESET>"); f.println(" <FRAMESET COLS=\"50%,50%\">"); f.println(" <FRAME SRC=\"match" + i + "-0.html\" NAME=\"0\">"); f.println(" <FRAME SRC=\"match" + i + "-1.html\" NAME=\"1\">"); f.println(" </FRAMESET>\n</FRAMESET>\n</HTML>"); f.close(); return f.bytesWritten(); }
private void writeDistribution(HTMLFile f) { // Die Verteilung: int max = 0; for (int i = 0; i < 10; i++) if (dist[i] > max) max = dist[i]; f.println("<H4>" + this.msg.getString("Report.Distribution") + ":</H4>\n<CENTER>"); f.println("<TABLE CELLPADDING=1 CELLSPACING=1>"); for (int i = 9; i >= 0; i--) { f.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>" + dist[i] + "</TD><TD>"); for (int j = (dist[i] * bar_length / max); j > 0; j--) f.print("#"); if (dist[i] * bar_length / max == 0) { if (dist[i] == 0) f.print("."); else f.print("#"); } f.println("</TD></TR>"); } f.println("</TABLE></CENTER>\n<P>\n<HR>"); }
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 = openHTMLFile(root, "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; }
f.println("<P><A NAME=\"matches\"><H4>Matches:</H4><P>"); f.println("<TABLE CELLPADDING=3 CELLSPACING=2>"); boolean once = true; for (Iterator<AllMatches> iter = matches.iterator(); iter.hasNext(); ) { match = iter.next(); if (once) { f.println("<TR><TD BGCOLOR=" + this.report.color(match.percent(), 128, 192, 128, 192, 255, 255) + ">" + s1.name + "<TD WIDTH=\"10\">->"); once = false; f.println(" <TD BGCOLOR=" + this.report.color(match.percent(), 128, 192, 128, 192, 255, 255) + " ALIGN=center><A HREF=\"match" + matchIndex + ".html\">" + match.subName(other) + "</A><BR><FONT COLOR=\"" + this.report.color(match.percent(), 0, 255, 0, 0, 0, 0) + "\"><B>(" + match.roundedPercent() + "%)</B></FONT>"); this.report.writeMatch(root, matchIndex++, match); f.println("</TR>"); f.println("</TABLE><P>\n"); f.println("<!---->"); this.report.writeIndexEnd(f); f.close();
public 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>"); }
public HTMLFile openHTMLFile(File root, String name) throws ExitException { if (!root.exists()) if (!root.mkdirs()) { throw new jplag.ExitException("Cannot create directory!"); } if (!root.isDirectory()) { throw new jplag.ExitException(root + " is not a directory!"); } if (!root.canWrite()) { throw new jplag.ExitException("Cannot write directory: " + root); } // now the actual file creation: File f = new File(root, name); HTMLFile res = null; try { res = HTMLFile.createHTMLFile(f); } catch (IOException e) { throw new jplag.ExitException("Error opening file: " + f.toString()); } return res; }
f.println("<BODY BGCOLOR=\"#ffffff\">"); for (int fileIndex = 0; fileIndex < files.length; fileIndex++) { f.println("<HR>\n<H3><CENTER>" + files[fileIndex] + "</CENTER></H3><HR>"); char[] buffer = text[fileIndex]; f.print("<A NAME=\"" + perm[index - 1] + "\"></A>"); f.print("<FONT color=\"" + Colors.getColor(perm[index - 1]) + "\"><B>"); f.print("<"); } else if (buffer[charNr] == '>') { f.print(">"); } else if (buffer[charNr] == '\n') { f.print("<br>\n"); } else f.print(buffer[charNr]); f.print("</B></FONT>"); f.println("\n</BODY>\n</HTML>"); f.close(); return f.bytesWritten();
public void writeHTMLHeaderWithScript(HTMLFile file, String title) { file.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); file.println("<HTML>\n<HEAD>\n <TITLE>" + title + "</TITLE>"); file.println("<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"); file.println(" <script type=\"text/javascript\">\n <!--"); file.println(" function ZweiFrames(URL1,F1,URL2,F2)\n {"); file.println(" parent.frames[F1].location.href=URL1;"); file.println(" parent.frames[F2].location.href=URL2;\n }\n //-->"); file.println(" </script>\n</HEAD>"); }
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(root, clustering); 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 = openHTMLFile(root, "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); 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 = openHTMLFile(root, "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);
private int writeTop(int i, AllMatches match) throws jplag.ExitException { HTMLFile f = openHTMLFile(root, "match" + i + "-top.html"); writeHTMLHeaderWithScript(f, "Top"); f.println("<BODY BGCOLOR=\"#ffffff\">"); if (this.program.use_externalSearch()) { f.println("<A HREF=\"match" + i + "-dist.html\" TARGET=\"_top\">" + msg.getString("Report.Distribution") + "</A><P>"); } match.HTMLreport(f, i, this.program); f.println("</BODY>\n</HTML>\n"); f.close(); return f.bytesWritten(); }
f.println("<TABLE CELLPADDING=2 CELLSPACING=2>"); f.println("<TR><TH ALIGN=center BGCOLOR=#8080ff>" + msg.getString("Clusters.Cluster_number") + "<TH ALIGN=center BGCOLOR=#8080ff>" f.print("<TR><TD ALIGN=center BGCOLOR=#8080ff>" + i + "<TD ALIGN=center BGCOLOR=#c0c0ff>" + cluster.size() + "<TD ALIGN=center BGCOLOR=#c0c0ff>" + cluster.getSimilarity() Submission sub = iter.next(); int index = submissions.indexOf(sub); f.print("<A HREF=\"submission"+index+".html\">"+sub.name+"</A>"); if (iter.hasNext()) f.print(", "); f.println("<TD ALIGN=left BGCOLOR=#c0c0ff>" + ThemeGenerator.generateThemes(sortedSubmissions, this.program.get_themewords(), true,this.program)); } else { f.println("<TD ALIGN=left BGCOLOR=#c0c0ff>-"); f.println("</TR>"); f.println("</TABLE>\n<P>\n"); f.println("<H5>" + msg.getString("Clusters.Distribution_of_cluster_size") + ":</H5>");
f.println("<BODY BGCOLOR=\"#ffffff\"" + (j == 1 ? " style=\"margin-left:25\">" : ">")); f.println("<HR>\n<H3><CENTER>" + files[x] + "</CENTER></H3><HR>"); if (this.language.isPreformated()) f.println("<PRE>"); for (int y = 0; y < text[x].length; y++) { f.print(text[x][y]); if (!this.language.isPreformated()) f.println("<BR>"); else f.println(); f.println("</PRE>"); f.println("\n</BODY>\n</HTML>"); f.close(); return f.bytesWritten();
private int writeDist(int i, AllMatches match) throws jplag.ExitException { HTMLFile f = openHTMLFile(root, "match" + i + "-dist.html"); writeHTMLHeader(f, msg.getString("Report.Token_Distribution")); f.println("<BODY>"); match.distributionReport(f, msg); f.println("</BODY>\n</HTML>"); f.close(); return f.bytesWritten(); }
f.println(headerStr + " (<a href=\"help-sim-" + program.getCountryTag() + ".html\"><small><font color=\"#000088\">" + msg.getString("Report.WhatIsThis") + "</font></small></a>):</H4>"); f.println("<p><a href=\"" + csvfile + "\">download csv</a></p>"); f.println("<TABLE CELLPADDING=3 CELLSPACING=2>"); if (!header) { // only print header when necessary! header = true; f.print("<TR><TD BGCOLOR=" + color(helper.getPercent(match), 128, 192, 128, 192, 255, 255) + ">" + name + "</TD><TD><nobr>-></nobr>"); f.print("</TD><TD BGCOLOR=" + color(percent, 128, 192, 128, 192, 255, 255) + " ALIGN=center><A HREF=\"match" + getMatchIndex(output) + ".html\">" + output.subName(other) + "</A><BR><FONT COLOR=\"" + color(percent, 0, 255, 0, 0, 0, 0) + "\">(" + (((int) (percent * 10)) / (float) 10) + "%)</FONT>"); f.println("</TD></TR>"); f.println("</TABLE><P>\n"); f.println("<!---->"); // important for front end
f.println("<BODY BGCOLOR=\"#ffffff\"" + (j == 1 ? " style=\"margin-left:25\">" : ">")); f.println("<HR>\n<H3><CENTER>" + files[x] + "</CENTER></H3><HR>"); if (this.language.isPreformated()) f.println("<PRE>"); for (int y = 0; y < text[x].length; y++) { f.print(text[x][y]); if (!this.language.isPreformated()) f.println("<BR>"); else f.println(); f.println("</PRE>"); f.println("</BODY>\n</HTML>"); f.close(); return f.bytesWritten();
public int makeDendrograms(File root, Cluster clustering) throws jplag.ExitException { HTMLFile f = this.program.report.openHTMLFile(root, "dendro.html"); f.println("<!DOCTYPE HTML PUBLIC \"-//DTD HTML 3.2//EN\">"); f.println("<HTML>\n<HEAD>\n<TITLE>" + msg.getString("Clusters.Dendrogram") + "</TITLE>\n" + "<script language=\"JavaScript\" type=\"text/javascript\" " + "src=\"fields.js\">\n</script>\n</HEAD>\n<BODY>"); f.println("<H1>" + msg.getString("Clusters.Dendrogram") + "</H1>"); f.println("<form name=\"data\" action=\"\">"); f.println("<table border=\"0\">"); f.println("<tr><td>" + msg.getString("Clusters.Cluster_size") + ":</td>" + "<td><input type=\"text\" readonly name=\"size\" size=\"5\"></td>"); f.println("<td rowspan=\"3\">" + msg.getString("Clusters.Themewords") + ":</td><td rowspan=\"3\"><textarea cols=\"80\" rows=\"3\" readonly " + "name=\"theme\"></textarea></td></tr>"); f.println("<tr><td>" + msg.getString("Clusters.Threshold") + ":</td><td><input type=\"text\" readonly name=\"thresh\" " + "size=\"6\"></td></tr>"); f.println("<tr><td>" + msg.getString("Clusters.Documents") + ":</td><td><input type=\"text\" readonly name=\"docs\" " + "size=\"30\"></td></tr>"); f.println("</table>\n</form>"); f.println(paintDendrogram(new File(root, "dendro.gif"), clustering)); f.println("<P><IMG SRC=\"dendro.gif\" ALT=\"" + msg.getString("Clusters.Dendrogram_picture") + "\" USEMAP=\"#Dendrogram\"></P>"); f.println("</BODY>\n</HTML>");
public void writeIndexBegin(HTMLFile f, String title) { writeHTMLHeader(f, title); f.println("<BODY BGCOLOR=#ffffff LINK=#000088 VLINK=#000000 TEXT=#000000>"); f.println("<TABLE ALIGN=center CELLPADDING=2 CELLSPACING=1>"); f.println("<TR VALIGN=middle ALIGN=center BGCOLOR=#ffffff><TD>" + "<IMG SRC=\"logo.gif\" ALT=\"JPlag\" BORDER=0></TD>"); f.println("<TD><H1><BIG>" + title + "</BIG></H1></TD></TR>"); f.println("<TR BGCOLOR=\"#aaaaff\" VALIGN=\"top\"><TD>" + "<BIG><BIG>" + msg.getString("Report.Title") + ":</BIG></BIG><TD><BIG><BIG><CODE>" + program.get_title() + "</CODE></BIG></BIG></TD></TR>"); if (program.get_original_dir() != null) f.println("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + "<BIG>" + msg.getString("Report.Directory") + ":</BIG></TD><TD><BIG><CODE>" + program.get_original_dir() + (program.get_sub_dir() == null ? "" : File.separator + "*" + File.separator + program.get_sub_dir()) } else { if (this.program.get_original_dir() == null) f.println("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + "<BIG><BIG>" + msg.getString("Report.Directory") + ":</BIG></BIG><TD><BIG><BIG><CODE>" + msg.getString("Report.Not_available") + "</CODE></BIG></BIG></TD></TR>"); else f.println("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + "<BIG><BIG>" + msg.getString("Report.Directory") + ":</BIG></BIG></TD><TD><BIG><BIG><CODE>" + program.get_original_dir() + (program.get_sub_dir() == null ? "" : File.separator + "*" + File.separator + program.get_sub_dir()) f.println("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Programs") + ":</TD><TD>"); f.println("<CODE>" + program.allValidSubmissions(" - ") + "</CODE></TD></TR>"); f.println("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Language") + ":</TD><TD>" + this.language.name() + "</TD></TR>"); f.print("<TR BGCOLOR=#aaaaff VALIGN=top><TD>" + msg.getString("Report.Submissions") + ":</TD><TD>" + this.program.validSubmissions()); if (program.getErrors() != 0) {