diff --git a/diylc/diylc-core/src/org/diylc/common/INetlistAnalyzer.java b/diylc/diylc-core/src/org/diylc/common/INetlistAnalyzer.java
index 59efcc91..0e799bf5 100644
--- a/diylc/diylc-core/src/org/diylc/common/INetlistAnalyzer.java
+++ b/diylc/diylc-core/src/org/diylc/common/INetlistAnalyzer.java
@@ -26,7 +26,6 @@ import java.util.List;
import org.diylc.netlist.Netlist;
import org.diylc.netlist.Node;
import org.diylc.netlist.Summary;
-import org.diylc.netlist.Tree;
import org.diylc.netlist.TreeException;
public interface INetlistAnalyzer {
@@ -50,12 +49,9 @@ public interface INetlistAnalyzer {
* @throws TreeException
*/
List summarize(List netlists, Node preferredOutput) throws TreeException;
-
- /**
- *
- * @param netlist
- * @return
- * @throws TreeException
+
+ /**
+ * @return name of the font to be used for display.
*/
- Tree constructTree(Netlist netlist) throws TreeException;
+ String getFontName();
}
diff --git a/diylc/diylc-core/src/org/diylc/netlist/NetlistAnalyzer.java b/diylc/diylc-core/src/org/diylc/netlist/NetlistAnalyzer.java
index de1b8956..b8bba904 100644
--- a/diylc/diylc-core/src/org/diylc/netlist/NetlistAnalyzer.java
+++ b/diylc/diylc-core/src/org/diylc/netlist/NetlistAnalyzer.java
@@ -381,6 +381,21 @@ public class NetlistAnalyzer {
protected String extractName(IDIYComponent> c) {
return c.getName() + " " + c.getValueForDisplay();
}
+
+ protected Set> extractComponents(Netlist netlist) {
+ Set> res = new HashSet>();
+ for (Group g : netlist.getGroups())
+ for (Node n : g.getNodes())
+ res.add(n.getComponent());
+ return res;
+ }
+
+ protected int find(Node node, List groups) {
+ for (int i = 0; i < groups.size(); i++)
+ if (groups.get(i).getNodes().contains(node))
+ return i;
+ return -1;
+ }
protected List extractNames(Collection> components) {
List names = new ArrayList();
diff --git a/diylc/diylc-core/src/org/diylc/netlist/Summary.java b/diylc/diylc-core/src/org/diylc/netlist/Summary.java
index 0ed1114f..232c7dd0 100644
--- a/diylc/diylc-core/src/org/diylc/netlist/Summary.java
+++ b/diylc/diylc-core/src/org/diylc/netlist/Summary.java
@@ -21,31 +21,24 @@
*/
package org.diylc.netlist;
-import java.util.List;
public class Summary {
private Netlist netlist;
- private List notes;
- private Tree tree;
+ private String summary;
- public Summary(Netlist netlist, List notes, Tree tree) {
+ public Summary(Netlist netlist, String summary) {
super();
this.netlist = netlist;
- this.notes = notes;
- this.tree = tree;
+ this.summary = summary;
}
public Netlist getNetlist() {
return netlist;
}
- public List getNotes() {
- return notes;
- }
-
- public Tree getTree() {
- return tree;
+ public String getSummary() {
+ return summary;
}
@Override
@@ -53,7 +46,7 @@ public class Summary {
final int prime = 31;
int result = 1;
result = prime * result + ((netlist == null) ? 0 : netlist.hashCode());
- result = prime * result + ((notes == null) ? 0 : notes.hashCode());
+ result = prime * result + ((summary == null) ? 0 : summary.hashCode());
return result;
}
@@ -71,16 +64,16 @@ public class Summary {
return false;
} else if (!netlist.equals(other.netlist))
return false;
- if (notes == null) {
- if (other.notes != null)
+ if (summary == null) {
+ if (other.summary != null)
return false;
- } else if (!notes.equals(other.notes))
+ } else if (!summary.equals(other.summary))
return false;
return true;
}
@Override
public String toString() {
- return notes.toString();
+ return summary.toString();
}
}
diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
index 94199f5b..b8584229 100644
--- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
+++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
@@ -2930,6 +2930,15 @@ public class Presenter implements IPlugInPort {
result.add((INetlistAnalyzer) clazz.newInstance());
}
}
+
+ Collections.sort(result, new Comparator() {
+
+ @Override
+ public int compare(INetlistAnalyzer o1, INetlistAnalyzer o2) {
+ return o1.getName().compareToIgnoreCase(o2.getName());
+ }
+ });
+
return result;
} catch (Exception e) {
LOG.error("Could not load INetlistSummarizer implementations", e);
diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar
index e732e0e6..9fd92047 100644
Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ
diff --git a/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java
index 6df107e7..3dfa773f 100644
--- a/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java
+++ b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java
@@ -28,6 +28,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.swing.JLabel;
+
import org.diylc.common.INetlistAnalyzer;
import org.diylc.components.electromechanical.ClosedJack1_4;
import org.diylc.components.electromechanical.OpenJack1_4;
@@ -69,13 +71,18 @@ public class GuitarDiagramAnalyzer extends NetlistAnalyzer implements INetlistAn
@Override
public String getName() {
- return "Guitar Diagrams";
+ return "Analyze Guitar Diagrams (beta)";
}
@Override
public String getIconName() {
return "Guitar";
}
+
+ @Override
+ public String getFontName() {
+ return new JLabel().getFont().getName();
+ }
public List summarize(List netlists, Node preferredOutput) throws TreeException {
List summaries = new ArrayList();
@@ -309,11 +316,18 @@ public class GuitarDiagramAnalyzer extends NetlistAnalyzer implements INetlistAn
}
}
- return new Summary(netlist, notes, tree);
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("Parallel/Series connectivity tree:
").append(tree.toHTML(0));
+ if (!notes.isEmpty())
+ sb.append("
Notes:
");
+ for (String v : notes) {
+ sb.append(" ").append(v).append("
");
+ }
+
+ return new Summary(netlist, sb.toString());
}
-
- @Override
public Tree constructTree(Netlist netlist) throws TreeException {
List jackTipNodes = find(JACK_TYPES, "Tip", netlist);
List jackSleeveNodes = find(JACK_TYPES, "Sleeve", netlist);
diff --git a/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java b/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java
new file mode 100644
index 00000000..9a2c173b
--- /dev/null
+++ b/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java
@@ -0,0 +1,108 @@
+/*
+
+ 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 .
+
+*/
+package org.diylc.netlist;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.diylc.common.INetlistAnalyzer;
+import org.diylc.core.IDIYComponent;
+
+public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
+
+ public SpiceAnalyzer() {
+ }
+
+ @Override
+ public String getName() {
+ return "Generate Spice Netlist (beta)";
+ }
+
+ @Override
+ public String getIconName() {
+ return "JarBeanInto";
+ }
+
+ @Override
+ public String getFontName() {
+ return "Courier New";
+ }
+
+ @Override
+ public List summarize(List netlists, Node preferredOutput) throws TreeException {
+ List summaries = new ArrayList();
+ for (Netlist n : netlists)
+ summaries.add(summarize(n, preferredOutput));
+
+ return summaries;
+ }
+
+ private Summary summarize(Netlist netlist, Node preferredOutput) throws TreeException {
+ // grab all components that are in the netlist
+ List> allComponents = new ArrayList>(extractComponents(netlist));
+ Collections.sort(allComponents, new Comparator>() {
+
+ @Override
+ public int compare(IDIYComponent> o1, IDIYComponent> o2) {
+ return o1.getName().compareToIgnoreCase(o2.getName());
+ }
+ });
+
+ StringBuilder sb = new StringBuilder();
+
+ List groups = netlist.getSortedGroups();
+ int unconnectedIndex = groups.size() + 1;
+
+ int maxLen = 0;
+ for (IDIYComponent> c : allComponents) {
+ if (c.getName().length() > maxLen)
+ maxLen = c.getName().length();
+ }
+
+ for (IDIYComponent> c : allComponents) {
+ sb.append(fill(c.getName(), (int) (Math.ceil(maxLen / 5.0) * 5)));
+ sb.append(" ");
+ for (int i = 0; i < c.getControlPointCount(); i++) {
+ int index = find(new Node(c, i), groups);
+ if (index < 0)
+ index = unconnectedIndex++;
+ else
+ index++;
+ sb.append(fill(Integer.toString(index), 5));
+ sb.append(" ");
+ }
+ sb.append(c.getValueForDisplay());
+ sb.append("
");
+ }
+
+ return new Summary(netlist, sb.toString());
+ }
+
+ private String fill(String source, int desiredLength) {
+ String res = source;
+ for (int i = 0; i < desiredLength - source.length(); i++)
+ res += " ";
+ return res;
+ }
+}
diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar
index e732e0e6..9fd92047 100644
Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ
diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar
index 35821e76..fcb89f30 100644
Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ
diff --git a/diylc/diylc-swing/src/org/diylc/images/IconLoader.java b/diylc/diylc-swing/src/org/diylc/images/IconLoader.java
index dade75d4..d1d1d983 100644
--- a/diylc/diylc-swing/src/org/diylc/images/IconLoader.java
+++ b/diylc/diylc-swing/src/org/diylc/images/IconLoader.java
@@ -63,7 +63,8 @@ public enum IconLoader {
"component_add.png"), History("history.png"), DocumentPlain("document_plain.png"), FitToSize("fit_to_size.png"), DocumentsGear(
"documents_gear.png"), SplashResistor("splash_resistor.png"), SplashCeramic("splash_ceramic.png"), SplashElectrolytic(
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png"), Help("help2.png"), ScrollInformation("scroll_information.png"),
- Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png");
+ Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png"),
+ JarBeanInto("jar_bean_into.png");
protected String name;
diff --git a/diylc/diylc-swing/src/org/diylc/images/jar_bean_into.png b/diylc/diylc-swing/src/org/diylc/images/jar_bean_into.png
new file mode 100644
index 00000000..4c7f506a
Binary files /dev/null and b/diylc/diylc-swing/src/org/diylc/images/jar_bean_into.png differ
diff --git a/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java b/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java
index c51542e7..e638a7d0 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java
@@ -1657,7 +1657,7 @@ public class ActionFactory {
super();
this.plugInPort = plugInPort;
this.swingUI = swingUI;
- putValue(AbstractAction.NAME, "Create Netlist (beta)");
+ putValue(AbstractAction.NAME, "Create DIYLC Netlist");
putValue(AbstractAction.SMALL_ICON, IconLoader.Web.getIcon());
}
@@ -1665,7 +1665,7 @@ public class ActionFactory {
public void actionPerformed(ActionEvent e) {
List res = plugInPort.extractNetlists();
if (res == null) {
- swingUI.showMessage("The generated netlist is empty, nothing to show.", "Netlist", ISwingUI.INFORMATION_MESSAGE);
+ swingUI.showMessage("The generated netlist is empty, nothing to show.", "DIYLC Netlist", ISwingUI.INFORMATION_MESSAGE);
return;
}
StringBuilder sb = new StringBuilder("");
@@ -1678,7 +1678,7 @@ public class ActionFactory {
sb.append("
");
}
sb.append("");
- new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), "Netlist", new Dimension(600, 480)).setVisible(true);
+ new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), "DIYLC Netlist", new Dimension(600, 480)).setVisible(true);
}
}
@@ -1695,7 +1695,7 @@ public class ActionFactory {
this.plugInPort = plugInPort;
this.swingUI = swingUI;
this.summarizer = summarizer;
- putValue(AbstractAction.NAME, "Analyze " + summarizer.getName() + " (beta)");
+ putValue(AbstractAction.NAME, summarizer.getName());
putValue(AbstractAction.SMALL_ICON, Enum.valueOf(IconLoader.class, summarizer.getIconName()).getIcon());
}
@@ -1703,7 +1703,7 @@ public class ActionFactory {
public void actionPerformed(ActionEvent e) {
List netlists = plugInPort.extractNetlists();
if (netlists == null || netlists.isEmpty()) {
- swingUI.showMessage("The generated netlist is empty, nothing to show.", "Analyze " + summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
+ swingUI.showMessage("The generated netlist is empty, nothing to show.", summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
return;
}
@@ -1711,29 +1711,35 @@ public class ActionFactory {
try {
res = summarizer.summarize(netlists, null);
} catch (Exception ex) {
- swingUI.showMessage(ex.getMessage(), "Analyze " + summarizer.getName(), ISwingUI.ERROR_MESSAGE);
+ swingUI.showMessage(ex.getMessage(), summarizer.getName(), ISwingUI.ERROR_MESSAGE);
return;
}
if (res == null) {
- swingUI.showMessage("The generated summary is empty, nothing to show.", "Analyze " + summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
+ swingUI.showMessage("The generated summary is empty, nothing to show.", summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
return;
}
StringBuilder sb = new StringBuilder("");
for (Summary summary : res) {
- sb.append("Switch configuration: ").append(summary.getNetlist().getSwitchSetup()).append("
");
+ sb.append("
");
- sb.append("Parallel/Series connectivity tree:
").append(summary.getTree().toHTML(0));
- if (!summary.getNotes().isEmpty())
- sb.append("
Notes:
");
- for (String v : summary.getNotes()) {
- sb.append(" ").append(v).append("
");
- }
- sb.append("
");
+ if (res.size() > 1)
+ sb.append("Switch configuration: ").
+ append(summary.getNetlist().getSwitchSetup()).
+ append("
");
+
+ sb.append(summary.getSummary());
+
+ sb.append("
");
+
+ if (res.size() > 1)
+ sb.append("
");
}
sb.append("");
- new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), "Analyze " + summarizer.getName(), new Dimension(600, 480)).setVisible(true);
+ new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), summarizer.getName(), new Dimension(600, 480)).setVisible(true);
}
}
}