Skip to content

Commit

Permalink
Improved repetition anaylsis style
Browse files Browse the repository at this point in the history
  • Loading branch information
rmraya committed Nov 17, 2024
1 parent e411ab1 commit c07942b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 36 deletions.
Binary file modified lib/openxliff.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions src/com/maxprograms/converters/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ private Constants() {

public static final String TOOLID = "OpenXLIFF";
public static final String TOOLNAME = "OpenXLIFF Filters";
public static final String VERSION = "3.23.0";
public static final String BUILD = "20241024_0743";
public static final String VERSION = "3.24.0";
public static final String BUILD = "20241117_0813";

public static final String SUCCESS = "0";
public static final String ERROR = "1";
Expand Down
57 changes: 23 additions & 34 deletions src/com/maxprograms/stats/RepetitionAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
*******************************************************************************/
package com.maxprograms.stats;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -174,7 +177,7 @@ public void analyse(String fileName, String catalog)
SAXBuilder builder = new SAXBuilder();
builder.setEntityResolver(new Catalog(catalog));
Iterator<Element> it = null;
String shortName = new File(fileName).getName();
String shortName = Utils.cleanString(new File(fileName).getName());
Document doc = builder.build(fileName);
Element root = doc.getRootElement();

Expand Down Expand Up @@ -247,45 +250,31 @@ public void analyse(String fileName, String catalog)
int matches75Total = 0;
int matches50Total = 0;

String css = "";
try (InputStream is = RepetitionAnalysis.class.getResourceAsStream("styles.css")) {
StringBuffer sb = new StringBuffer();
try (InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
try (BufferedReader br = new BufferedReader(reader)) {
String line;
while ((line = br.readLine()) != null) {
if (!sb.isEmpty()) {
sb.append("\n");
}
sb.append(line);
}
}
}
css = sb.toString();
}

try (FileOutputStream out = new FileOutputStream(fileName + ".log.html")) {
writeString(out, "<!DOCTYPE html>\n");
writeString(out, "<html>\n");
writeString(out, "<head>\n");
writeString(out, " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
writeString(out, " <title>" + Messages.getString("RepetitionAnalysis.6") + "</title>\n");
writeString(out, " <style type=\"text/css\">\n");
writeString(out, " table.wordCount {\n");
writeString(out, " border-left:1px solid grey;\n");
writeString(out, " }\n");
writeString(out, " table {\n");
writeString(out, " border: 1px solid #aaaaaa;\n");
writeString(out, " border-collapse: collapse;\n");
writeString(out, " }\n");
writeString(out, " td {\n");
writeString(out, " border: 1px solid #aaaaaa;\n");
writeString(out, " }\n");
writeString(out, " .wordCount th {\n");
writeString(out, " background:#003854;\n");
writeString(out, " border: 1px solid #eeeeee;\n");
writeString(out, " color:white;\n");
writeString(out, " text-align:center;\n");
writeString(out, " padding:3px\n");
writeString(out, " }\n");
writeString(out, " .wordCount td.left {\n");
writeString(out, " text-align:left;\n");
writeString(out, " padding:2px;\n");
writeString(out, " }\n");
writeString(out, " .wordCount td.center {\n");
writeString(out, " text-align:center;\n");
writeString(out, " padding:2px;\n");
writeString(out, " }\n");
writeString(out, " .wordCount td.right {\n");
writeString(out, " text-align:right;\n");
writeString(out, " padding:2px;\n");
writeString(out, " }\n");
writeString(out, " h2, h3 {\n");
writeString(out, " font-family: Arial,Helvetica,sans-serif;\n");
writeString(out, " }\n");
writeString(out, css);
writeString(out, " </style>\n");
writeString(out, "</head>\n");
writeString(out, "<body>\n");
Expand All @@ -295,7 +284,7 @@ public void analyse(String fileName, String catalog)
//
mf = new MessageFormat(title);
Object[] args = { shortName };
writeString(out, "<h2>" + mf.format(args) + "</h2>\n");
writeString(out, "<h1>" + mf.format(args) + "</h1>\n");
writeString(out, "<h2>" + Messages.getString("RepetitionAnalysis.7") + "</h2>\n");
writeString(out, "<table class=\"wordCount\" width=\"100%\">\n");

Expand Down
43 changes: 43 additions & 0 deletions src/com/maxprograms/stats/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

* {
font-family: Arial,Helvetica,sans-serif;
}
body {
padding: 20px;
}
h1 {
font-size: 1.5em;
font-weight: lighter;
}
table {
width:100%;
border: 1px solid #aaaaaa;
border-collapse: collapse;
border-radius: 4px;
}
td {
border: 1px solid #aaaaaa;
text-align:right;
padding:4px
}
th {
font-weight: lighter;
background:#2066A3;
border: 1px solid #eeeeee;
color:white;
text-align:center;
padding:4px
}
.left {
text-align:left;
}
.total {
font-weight: bolder;
background: #efefef;
}
.center {
text-align:center;
}
.right {
text-align:right;
}

0 comments on commit c07942b

Please sign in to comment.