basic implementation of spice exporter

This commit is contained in:
Branislav Stojkovic
2019-03-09 14:46:00 +01:00
parent c893b37fdf
commit 54ff518438
12 changed files with 188 additions and 46 deletions
@@ -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<Summary> summarize(List<Netlist> 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();
}
@@ -381,6 +381,21 @@ public class NetlistAnalyzer {
protected String extractName(IDIYComponent<?> c) {
return c.getName() + " " + c.getValueForDisplay();
}
protected Set<IDIYComponent<?>> extractComponents(Netlist netlist) {
Set<IDIYComponent<?>> res = new HashSet<IDIYComponent<?>>();
for (Group g : netlist.getGroups())
for (Node n : g.getNodes())
res.add(n.getComponent());
return res;
}
protected int find(Node node, List<Group> groups) {
for (int i = 0; i < groups.size(); i++)
if (groups.get(i).getNodes().contains(node))
return i;
return -1;
}
protected List<String> extractNames(Collection<IDIYComponent<?>> components) {
List<String> names = new ArrayList<String>();
@@ -21,31 +21,24 @@
*/
package org.diylc.netlist;
import java.util.List;
public class Summary {
private Netlist netlist;
private List<String> notes;
private Tree tree;
private String summary;
public Summary(Netlist netlist, List<String> 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<String> 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();
}
}
@@ -2930,6 +2930,15 @@ public class Presenter implements IPlugInPort {
result.add((INetlistAnalyzer) clazz.newInstance());
}
}
Collections.sort(result, new Comparator<INetlistAnalyzer>() {
@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);