mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
improve styling of summarize reports
This commit is contained in:
@@ -34,10 +34,10 @@ public abstract class AbstractNetlistAnalyzer {
|
||||
Map<String, Summary> summaries = new HashMap<String, Summary>();
|
||||
for (Netlist n : netlists) {
|
||||
Summary s = summarize(n);
|
||||
if (summaries.containsKey(s.getSummary()))
|
||||
summaries.get(s.getSummary()).append(n);
|
||||
if (summaries.containsKey(s.getSummaryHtml()))
|
||||
summaries.get(s.getSummaryHtml()).append(n);
|
||||
else
|
||||
summaries.put(s.getSummary(), s);
|
||||
summaries.put(s.getSummaryHtml(), s);
|
||||
}
|
||||
|
||||
List<Summary> res = new ArrayList<Summary>(summaries.values());
|
||||
|
||||
@@ -37,10 +37,10 @@ public abstract class NetlistAnalyzer {
|
||||
Map<String, Summary> summaries = new HashMap<String, Summary>();
|
||||
for (Netlist n : netlists) {
|
||||
Summary s = summarize(n, preferredOutput);
|
||||
if (summaries.containsKey(s.getSummary()))
|
||||
summaries.get(s.getSummary()).append(n);
|
||||
if (summaries.containsKey(s.getSummaryHtml()))
|
||||
summaries.get(s.getSummaryHtml()).append(n);
|
||||
else
|
||||
summaries.put(s.getSummary(), s);
|
||||
summaries.put(s.getSummaryHtml(), s);
|
||||
}
|
||||
|
||||
List<Summary> res = new ArrayList<Summary>(summaries.values());
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.diylc.netlist;
|
||||
|
||||
import org.diylc.netlist.Netlist;
|
||||
import org.diylc.netlist.Summary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NetlistSummaryHtmlReport {
|
||||
|
||||
public static String generateHtml(List<Summary> summaries, String fontName) {
|
||||
if (summaries == null || summaries.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder("<html><head><style>");
|
||||
sb.append("body { font-family: ").append(fontName)
|
||||
.append(", sans-serif; color: black; margin: 10px; }");
|
||||
sb.append("h2 { font-size: 12px; margin-top: 10px; margin-bottom: 0px; }");
|
||||
sb.append("p { margin: 0; }");
|
||||
sb.append("hr { margin-top: 10px; margin-bottom: 0; }");
|
||||
sb.append("</style></head><body>");
|
||||
|
||||
for (Summary summary : summaries) {
|
||||
if (summaries.size() > 1) {
|
||||
sb.append("<h2>Switch configuration: ").append(summary.getNetlist().getSwitchSetup())
|
||||
.append("</h2>");
|
||||
}
|
||||
|
||||
sb.append(summary.getSummaryHtml());
|
||||
|
||||
if (summaries.size() > 1) {
|
||||
sb.append("<br><hr>");
|
||||
}
|
||||
}
|
||||
sb.append("</body></html>");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,12 @@ package org.diylc.netlist;
|
||||
public class Summary implements Comparable<Summary> {
|
||||
|
||||
private Netlist netlist;
|
||||
private String summary;
|
||||
private String summaryHtml;
|
||||
|
||||
public Summary(Netlist netlist, String summary) {
|
||||
public Summary(Netlist netlist, String summaryHtml) {
|
||||
super();
|
||||
this.netlist = netlist;
|
||||
this.summary = summary;
|
||||
this.summaryHtml = summaryHtml;
|
||||
}
|
||||
|
||||
public Netlist getNetlist() {
|
||||
@@ -40,8 +40,8 @@ public class Summary implements Comparable<Summary> {
|
||||
this.netlist.getSwitchSetup().addAll(netlist.getSwitchSetup());
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
public String getSummaryHtml() {
|
||||
return summaryHtml;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +49,7 @@ public class Summary implements Comparable<Summary> {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((netlist == null) ? 0 : netlist.hashCode());
|
||||
result = prime * result + ((summary == null) ? 0 : summary.hashCode());
|
||||
result = prime * result + ((summaryHtml == null) ? 0 : summaryHtml.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -67,17 +67,17 @@ public class Summary implements Comparable<Summary> {
|
||||
return false;
|
||||
} else if (!netlist.equals(other.netlist))
|
||||
return false;
|
||||
if (summary == null) {
|
||||
if (other.summary != null)
|
||||
if (summaryHtml == null) {
|
||||
if (other.summaryHtml != null)
|
||||
return false;
|
||||
} else if (!summary.equals(other.summary))
|
||||
} else if (!summaryHtml.equals(other.summaryHtml))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return summary.toString();
|
||||
return summaryHtml.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -301,6 +301,10 @@
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved trace proximity calculation to avoid showing false positives</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved the styling of the guitar wiring analysis report</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>If the internet connection is present, but unstable, the application starts but nothing can be clicked until the connection restores</description>
|
||||
|
||||
+25
-19
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.swing.actions.analyze;
|
||||
|
||||
import java.awt.Dimension;
|
||||
@@ -12,6 +33,7 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ITask;
|
||||
import org.diylc.netlist.Netlist;
|
||||
import org.diylc.netlist.Summary;
|
||||
import org.diylc.netlist.NetlistSummaryHtmlReport;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.utils.IconLoader;
|
||||
|
||||
@@ -68,25 +90,9 @@ public class SummarizeNetlistAction extends AbstractAction {
|
||||
summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("<html>");
|
||||
|
||||
for (Summary summary : res) {
|
||||
sb.append("<p style=\"font-family: ").append(summarizer.getFontName())
|
||||
.append("; font-size: 9px\">");
|
||||
|
||||
if (res.size() > 1)
|
||||
sb.append("<b>Switch configuration: ").append(summary.getNetlist().getSwitchSetup())
|
||||
.append("</b><br><br>");
|
||||
|
||||
sb.append(summary.getSummary());
|
||||
|
||||
sb.append("</p><br>");
|
||||
|
||||
if (res.size() > 1)
|
||||
sb.append("<hr>");
|
||||
}
|
||||
sb.append("</html>");
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), summarizer.getName(),
|
||||
|
||||
String html = NetlistSummaryHtmlReport.generateHtml(res, summarizer.getFontName());
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), html, summarizer.getName(),
|
||||
new Dimension(800, 600)).setVisible(true);
|
||||
}
|
||||
}, true);
|
||||
|
||||
Reference in New Issue
Block a user