diff --git a/diylc/diylc-core/src/org/diylc/common/INetlistSummarizer.java b/diylc/diylc-core/src/org/diylc/common/INetlistAnalyzer.java similarity index 79% rename from diylc/diylc-core/src/org/diylc/common/INetlistSummarizer.java rename to diylc/diylc-core/src/org/diylc/common/INetlistAnalyzer.java index bba1da98..747506e5 100644 --- a/diylc/diylc-core/src/org/diylc/common/INetlistSummarizer.java +++ b/diylc/diylc-core/src/org/diylc/common/INetlistAnalyzer.java @@ -26,8 +26,10 @@ 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 INetlistSummarizer { +public interface INetlistAnalyzer { /** * @return summarizer name @@ -37,7 +39,7 @@ public interface INetlistSummarizer { /** * @return name of the icon to use */ - String getIconName(); + String getIconName(); /** * Summarizes all {@link Netlist}s provided. @@ -47,4 +49,12 @@ public interface INetlistSummarizer { * @return */ List summarize(List netlists, Node preferredOutput); + + /** + * + * @param netlist + * @return + * @throws TreeException + */ + Tree constructTree(Netlist netlist) throws TreeException; } diff --git a/diylc/diylc-core/src/org/diylc/common/INetlistProcessor.java b/diylc/diylc-core/src/org/diylc/common/INetlistProcessor.java index 2c6fc736..1707482e 100644 --- a/diylc/diylc-core/src/org/diylc/common/INetlistProcessor.java +++ b/diylc/diylc-core/src/org/diylc/common/INetlistProcessor.java @@ -40,9 +40,11 @@ public interface INetlistProcessor { List extractNetlists(); /** - * Finds all available {@link INetlistSummarizer} implementations. + * Finds all available {@link INetlistAnalyzer} implementations. * * @return */ - List getNetlistSummarizers(); + List getNetlistAnalyzers(); + + } diff --git a/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java b/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java index ddb5076e..69346c34 100644 --- a/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java +++ b/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java @@ -284,5 +284,10 @@ public abstract class AbstractComponent implements IDIYComponent { @Override public String getControlPointNodeName(int index) { return Integer.toString(index + 1); + } + + @Override + public String getInternalLinkName(int index1, int index2) { + return null; } } diff --git a/diylc/diylc-core/src/org/diylc/core/IDIYComponent.java b/diylc/diylc-core/src/org/diylc/core/IDIYComponent.java index 436b870e..8f69d692 100644 --- a/diylc/diylc-core/src/org/diylc/core/IDIYComponent.java +++ b/diylc/diylc-core/src/org/diylc/core/IDIYComponent.java @@ -121,7 +121,14 @@ public interface IDIYComponent extends Serializable { * @param index * @return name of the control point node, if the control point represents a graph node, null otherwise. */ - String getControlPointNodeName(int index); + String getControlPointNodeName(int index); + + /** + * @param index1 + * @param index2 + * @return name of the internal linked formed by the two control points, null if they do not form an internal link + */ + String getInternalLinkName(int index1, int index2); /** * Draws the component onto the {@link Graphics2D}. diff --git a/diylc/diylc-core/src/org/diylc/netlist/ITree.java b/diylc/diylc-core/src/org/diylc/netlist/ITree.java new file mode 100644 index 00000000..52c79b4c --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/netlist/ITree.java @@ -0,0 +1,31 @@ +/* + + 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.List; + +public interface ITree { + + List getChildren(); + + TreeConnectionType getConnectionType(); +} diff --git a/diylc/diylc-core/src/org/diylc/netlist/Summary.java b/diylc/diylc-core/src/org/diylc/netlist/Summary.java index 6bff5fe5..0ed1114f 100644 --- a/diylc/diylc-core/src/org/diylc/netlist/Summary.java +++ b/diylc/diylc-core/src/org/diylc/netlist/Summary.java @@ -27,11 +27,13 @@ public class Summary { private Netlist netlist; private List notes; + private Tree tree; - public Summary(Netlist netlist, List notes) { + public Summary(Netlist netlist, List notes, Tree tree) { super(); this.netlist = netlist; this.notes = notes; + this.tree = tree; } public Netlist getNetlist() { @@ -41,6 +43,10 @@ public class Summary { public List getNotes() { return notes; } + + public Tree getTree() { + return tree; + } @Override public int hashCode() { diff --git a/diylc/diylc-core/src/org/diylc/netlist/Tree.java b/diylc/diylc-core/src/org/diylc/netlist/Tree.java new file mode 100644 index 00000000..dbaf7246 --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/netlist/Tree.java @@ -0,0 +1,137 @@ +/* + + 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.List; + +public class Tree { + + private List children; + private TreeConnectionType connectionType; + private TreeLeaf leaf; + + public Tree(TreeLeaf leaf) { + this.leaf = leaf; + } + + public Tree(List children, TreeConnectionType connectionType) { + this.children = children; + this.connectionType = connectionType; + } + + public List getChildren() { + return children; + } + + public void trimChildren(int count) { + children = children.subList(count, children.size()); + } + + public TreeConnectionType getConnectionType() { + return connectionType; + } + + public TreeLeaf getLeaf() { + return leaf; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((children == null) ? 0 : children.hashCode()); + result = prime * result + ((connectionType == null) ? 0 : connectionType.hashCode()); + result = prime * result + ((leaf == null) ? 0 : leaf.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Tree other = (Tree) obj; + if (children == null) { + if (other.children != null) + return false; + } else if (!children.equals(other.children)) + return false; + if (connectionType != other.connectionType) + return false; + if (leaf == null) { + if (other.leaf != null) + return false; + } else if (!leaf.equals(other.leaf)) + return false; + return true; + } + + @Override + public String toString() { + if (leaf != null) + return leaf.toString(); + + StringBuilder sb = new StringBuilder("("); + boolean first = true; + for(Tree child : children) { + if (!first) + sb.append(" " ).append(connectionType).append(" "); + first = false; + sb.append(child); + } + sb.append(")"); + return sb.toString(); + } + + public String toHTML(int depth) { + if (leaf != null) + return leaf.toHTML(); + + StringBuilder sb = new StringBuilder(); + if (depth > 0 && children.size() > 1) + sb.append("("); + boolean first = true; + for(Tree child : children) { + if (!first) { + sb.append(" ").append(connectionType.toHTML()).append(" "); + if (depth == 0) + sb.append("
"); + } + first = false; + sb.append(child.toHTML(depth + children.size() > 1 ? 1 : 0)); + } + if (depth > 0 && children.size() > 1) + sb.append(")"); + return sb.toString(); + } + + @Override + protected Object clone() throws CloneNotSupportedException { + if (leaf != null) + return new Tree(leaf); + return new Tree(new ArrayList(children), connectionType); + } +} diff --git a/diylc/diylc-core/src/org/diylc/netlist/TreeConnectionType.java b/diylc/diylc-core/src/org/diylc/netlist/TreeConnectionType.java new file mode 100644 index 00000000..eac198f2 --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/netlist/TreeConnectionType.java @@ -0,0 +1,44 @@ +/* + + 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; + +public enum TreeConnectionType { + + Series("+", "red"), Parallel("||", "blue"); + + private String label; + private String color; + + private TreeConnectionType(String label, String color) { + this.label = label; + this.color = color; + } + + @Override + public String toString() { + return label; + } + + public String toHTML() { + return "" + label + ""; + } +} diff --git a/diylc/diylc-core/src/org/diylc/netlist/TreeException.java b/diylc/diylc-core/src/org/diylc/netlist/TreeException.java new file mode 100644 index 00000000..e1a672ae --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/netlist/TreeException.java @@ -0,0 +1,26 @@ +package org.diylc.netlist; + +public class TreeException extends Exception { + + private static final long serialVersionUID = 1L; + + public TreeException() { + // TODO Auto-generated constructor stub + } + + public TreeException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + public TreeException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + public TreeException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/diylc/diylc-core/src/org/diylc/netlist/TreeLeaf.java b/diylc/diylc-core/src/org/diylc/netlist/TreeLeaf.java new file mode 100644 index 00000000..f6135947 --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/netlist/TreeLeaf.java @@ -0,0 +1,101 @@ +/* + + 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.List; + +import org.diylc.core.IDIYComponent; + +public class TreeLeaf implements ITree { + + private IDIYComponent component; + private int pointIndex1; + private int pointIndex2; + + public TreeLeaf(IDIYComponent component, int pointIndex1, int pointIndex2) { + this.component = component; + this.pointIndex1 = pointIndex1; + this.pointIndex2 = pointIndex2; + } + + public IDIYComponent getComponent() { + return component; + } + + public int getPointIndex1() { + return pointIndex1; + } + + public int getPointIndex2() { + return pointIndex2; + } + + @Override + public List getChildren() { + return null; + } + + @Override + public TreeConnectionType getConnectionType() { + return null; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((component == null) ? 0 : component.hashCode()); + result = prime * result + pointIndex1; + result = prime * result + pointIndex2; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TreeLeaf other = (TreeLeaf) obj; + if (component == null) { + if (other.component != null) + return false; + } else if (!component.equals(other.component)) + return false; + if (pointIndex1 != other.pointIndex1) + return false; + if (pointIndex2 != other.pointIndex2) + return false; + return true; + } + + @Override + public String toString() { + return component.getName() + "." + component.getInternalLinkName(pointIndex1, pointIndex2); + } + + public String toHTML() { + return toString().replace("<", "<").replace(">", ">"); + } +} diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java index 8f4d82ce..e5150a4c 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java +++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java @@ -62,7 +62,7 @@ import org.diylc.common.EventType; import org.diylc.common.IComponentFiler; import org.diylc.common.IComponentTransformer; import org.diylc.common.IKeyProcessor; -import org.diylc.common.INetlistSummarizer; +import org.diylc.common.INetlistAnalyzer; import org.diylc.common.IPlugIn; import org.diylc.common.IPlugInPort; import org.diylc.common.PropertyWrapper; @@ -2753,7 +2753,7 @@ public class Presenter implements IPlugInPort { posList.add(new Position(switches.get(j), positions[j])); } List connections = getConnections(switchPositions); - Netlist graph = constructGraph(nodes, connections, continuity); + Netlist graph = constructNetlist(nodes, connections, continuity); // merge graphs that are effectivelly the same if (result.containsKey(graph)) { @@ -2785,7 +2785,7 @@ public class Presenter implements IPlugInPort { return netlists; } - private Netlist constructGraph(List nodes, List connections, List continuityAreas) { + private Netlist constructNetlist(List nodes, List connections, List continuityAreas) { Netlist netlist = new Netlist(); // debugging code @@ -2827,7 +2827,7 @@ public class Presenter implements IPlugInPort { } } - netlist.done(); + Collections.sort(netlist.getSwitchSetup()); return netlist; } @@ -2889,15 +2889,15 @@ public class Presenter implements IPlugInPort { } @Override - public List getNetlistSummarizers() { + public List getNetlistAnalyzers() { Set> classes; try { classes = Utils.getClasses("org.diylc.netlist"); - List result = new ArrayList(); + List result = new ArrayList(); for (Class clazz : classes) { - if (!Modifier.isAbstract(clazz.getModifiers()) && INetlistSummarizer.class.isAssignableFrom(clazz)) { - result.add((INetlistSummarizer) clazz.newInstance()); + if (!Modifier.isAbstract(clazz.getModifiers()) && INetlistAnalyzer.class.isAssignableFrom(clazz)) { + result.add((INetlistAnalyzer) clazz.newInstance()); } } return result; diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index cf84282b..c61dc191 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/components/AbstractLeadedComponent.java b/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java index 8c33ba02..5fb28ef3 100644 --- a/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java +++ b/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java @@ -534,6 +534,13 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp public void setLabelOriantation(LabelOriantation labelOriantation) { this.labelOriantation = labelOriantation; } + + @Override + public String getInternalLinkName(int index1, int index2) { + if ((index1 == 0 && index2 == getControlPointCount() - 1) || (index2 == 0 && index1 == getControlPointCount() - 1)) + return getName(); + return null; + } /** * Override this method with @EditableProperty annotation in child classes where standing mode is diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/HumbuckerPickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/HumbuckerPickup.java index 9c98b6e4..8e9ff117 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/HumbuckerPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/HumbuckerPickup.java @@ -39,6 +39,7 @@ import org.diylc.common.ObjectCache; import org.diylc.common.Orientation; import org.diylc.common.VerticalAlignment; import org.diylc.components.AbstractTransparentComponent; +import org.diylc.components.guitar.SingleCoilPickup.Polarity; import org.diylc.core.ComponentState; import org.diylc.core.IDIYComponent; import org.diylc.core.IDrawingObserver; @@ -667,6 +668,20 @@ public class HumbuckerPickup extends AbstractTransparentComponent { } return null; } + + @Override + public String getInternalLinkName(int index1, int index2) { + if (index1 == 0 && index2 == 1) + return Polarity.North.toString() + "->"; + else if (index1 == 2 && index2 == 3) + return Polarity.South.toString() + "->"; + else if (index1 == 1 && index2 == 0) + return Polarity.North.toString() + "<-"; + else if (index1 == 3 && index2 == 2) + return Polarity.South.toString() + "<-"; + + return null; + } public static enum HumbuckerType { diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java index eb80e16e..9b45ecc2 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java @@ -607,6 +607,30 @@ public class SingleCoilPickup extends AbstractTransparentComponent { return null; return "South Finish"; } + return null; + } + + @Override + public String getInternalLinkName(int index1, int index2) { + switch (getPolarity()) { + case Humbucking: + if (index1 == 0 && index2 == 1) + return Polarity.North.toString() + "->"; + else if (index1 == 1 && index2 == 0) + return Polarity.North.toString() + "<-"; + else if (index1 == 2 && index2 == 3) + return Polarity.South.toString() + "->"; + else if (index1 == 3 && index2 == 2) + return Polarity.South.toString() + "<-"; + break; + case North: + case South: + if (index1 == 1 && index2 == 2) + return getPolarity().toString() + "->"; + else if (index1 == 2 && index2 == 1) + return getPolarity().toString() + "<-"; + } + return null; } diff --git a/diylc/diylc-library/src/org/diylc/components/passive/PotentiometerPanel.java b/diylc/diylc-library/src/org/diylc/components/passive/PotentiometerPanel.java index 2ce38086..968de2ef 100644 --- a/diylc/diylc-library/src/org/diylc/components/passive/PotentiometerPanel.java +++ b/diylc/diylc-library/src/org/diylc/components/passive/PotentiometerPanel.java @@ -457,6 +457,17 @@ public class PotentiometerPanel extends AbstractPotentiometer { public void setWaferColor(Color waferColor) { this.waferColor = waferColor; + } + + @Override + public String getInternalLinkName(int index1, int index2) { + if (index1 > index2) + return getInternalLinkName(index2, index1); + + if (index2 - index1 == 1) + return (index1 + 1) + "-" + (index2 + 1); + + return null; } public enum Type { diff --git a/diylc/diylc-library/src/org/diylc/netlist/AbstractNetlistAnalyzer.java b/diylc/diylc-library/src/org/diylc/netlist/AbstractNetlistAnalyzer.java new file mode 100644 index 00000000..a9fb74f9 --- /dev/null +++ b/diylc/diylc-library/src/org/diylc/netlist/AbstractNetlistAnalyzer.java @@ -0,0 +1,362 @@ +/* + + 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.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.diylc.core.IDIYComponent; + +public abstract class AbstractNetlistAnalyzer { + + public AbstractNetlistAnalyzer() { + } + + protected Tree constructTree(Netlist netlist, Node nodeA, Node nodeB) { + Tree tree = new Tree(new ArrayList(), TreeConnectionType.Parallel); + connectNodes(netlist, nodeA, nodeB, tree.getChildren(), null, new HashSet()); +// System.out.println(netlist.getSwitchSetup()); +// System.out.println(tree); + return tree; + } + + protected void connectNodes(Netlist netlist, Node nodeA, Node nodeB, List concurrentPaths, Tree currentPath, Set visited) { + if (nodeA == nodeB) { + concurrentPaths.add(currentPath); + return; + } + + Group groupA = findGroup(netlist, nodeA); + + if (groupA == null) + return; + + if (groupA.getNodes().contains(nodeB)) { + concurrentPaths.add(currentPath); + return; + } + + visited.add(nodeA); + + for (Node n : groupA.getNodes()) { + IDIYComponent c = n.getComponent(); + for (int i = 0; i < c.getControlPointCount(); i++) { + if (i != n.getPointIndex() && c.getInternalLinkName(i, n.getPointIndex()) != null) { + TreeLeaf l = new TreeLeaf(c, i, n.getPointIndex()); + Node newNodeA = new Node(c, i); + if (!visited.contains(newNodeA)) { + visited.add(n); + Tree newCurrentPath = null; + try { + if (currentPath == null) + newCurrentPath = new Tree(new ArrayList(), TreeConnectionType.Series); + else + newCurrentPath = (Tree) currentPath.clone(); + } catch (CloneNotSupportedException e) { + } + Tree newItem = new Tree(l); + if (!newCurrentPath.getChildren().contains(newItem)) + newCurrentPath.getChildren().add(newItem); +// if (!currentPath.contains(l)) +// newCurrentPath.add(l); + Set newVisited = new HashSet(visited); + connectNodes(netlist, newNodeA, nodeB, concurrentPaths, newCurrentPath, newVisited); + } + } + } + } + + if (concurrentPaths.size() < 2) + return; + + Tree jointSection = new Tree(new ArrayList(), TreeConnectionType.Series); + for (int i = 0; i < concurrentPaths.get(0).getChildren().size(); i++) { + Tree unique = concurrentPaths.get(0).getChildren().get(i); + boolean canMerge = true; + for (Tree t : concurrentPaths) { + if (t.getConnectionType() != TreeConnectionType.Series || t.getChildren().size() <= i || !t.getChildren().get(i).equals(unique)) { + canMerge = false; + break; + } + } + if (canMerge) + jointSection.getChildren().add(unique); + else + break; + } + if (!jointSection.getChildren().isEmpty()) { + Tree mergedTree = new Tree(new ArrayList(), TreeConnectionType.Series); + mergedTree.getChildren().add(jointSection); + Tree parallelSection = new Tree(new ArrayList(concurrentPaths), TreeConnectionType.Parallel); + for (Tree t : parallelSection.getChildren()) { + t.trimChildren(jointSection.getChildren().size()); + } + mergedTree.getChildren().add(parallelSection); + concurrentPaths.clear(); + concurrentPaths.add(mergedTree); + } + } + + protected void findAllPaths(Netlist netlist, Node nodeA, Node nodeB, List currentPath, List> allPaths, Set visited) { + if (nodeA == nodeB) { + allPaths.add(currentPath); + return; + } + +// System.out.println("Finding path between " + nodeA + " and " + nodeB); + + Group groupA = findGroup(netlist, nodeA); + + if (groupA == null) + return; + + if (groupA.getNodes().contains(nodeB)) { + allPaths.add(currentPath); + return; + } + + for (Node n : groupA.getNodes()) { + IDIYComponent c = n.getComponent(); + for (int i = 0; i < c.getControlPointCount(); i++) { + if (i != n.getPointIndex() && c.getInternalLinkName(i, n.getPointIndex()) != null) { + TreeLeaf l = new TreeLeaf(c, i, n.getPointIndex()); + Node newNodeA = new Node(c, i); + if (!visited.contains(newNodeA)) { + List newCurrentPath = new ArrayList(currentPath); + if (!currentPath.contains(l)) + newCurrentPath.add(l); + Set newVisited = new HashSet(visited); + newVisited.add(nodeA); + newVisited.add(newNodeA); + findAllPaths(netlist, newNodeA, nodeB, newCurrentPath, allPaths, newVisited); + } + } + } + } + } + + protected Group findGroup(Netlist netlist, Node node) { + for (Group g : netlist.getGroups()) + if (g.getNodes().contains(node)) + return g; + return null; + } + + protected List trace(Set typeNames, String nodeName, Netlist netlist) { + List res = new ArrayList(); + for (Group g : netlist.getGroups()) { + for (Node n : g.getNodes()) { + if (typeNames.contains(n.getComponent().getClass().getCanonicalName()) && + (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { + res.add(g); + break; + } + } + } + return res; + } + + protected List find(Set typeNames, String nodeName, Group group) { + List res = new ArrayList(); + + for (Node n : group.getNodes()) { + if (typeNames.contains(n.getComponent().getClass().getCanonicalName()) && + (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { + res.add(n); + } + } + + return res; + } + + protected List findGroups(Set typeNames, String nodeName, Netlist netlist) { + List res = new ArrayList(); + for (Group g : netlist.getGroups()) { + for (Node n : g.getNodes()) { + if (typeNames.contains(n.getComponent().getClass().getCanonicalName()) && + (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { + res.add(g); + break; + } + } + } + return res; + } + + protected List findGroups(Set typeNames, String nodeName, Netlist netlist, Collection> belongTo) { + List res = new ArrayList(); + for (Group g : netlist.getGroups()) { + for (Node n : g.getNodes()) { + if ((belongTo == null || belongTo.contains(n.getComponent())) && + (typeNames.contains(n.getComponent().getClass().getCanonicalName())) && + (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { + res.add(g); + break; + } + } + } + return res; + } + + protected List find(Set typeNames, String nodeName, Netlist netlist) { + List res = new ArrayList(); + for (Group g : netlist.getGroups()) { + for (Node n : g.getNodes()) { + if (typeNames.contains(n.getComponent().getClass().getCanonicalName()) && + (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { + res.add(n); + } + } + } + return res; + } + + protected List find(Set typeNames, String nodeName, Netlist netlist, List inGroupWith) { + List res = new ArrayList(); + for (Group g : netlist.getGroups()) { + + boolean inGroup; + if (inGroupWith == null) { + inGroup = true; + } else { + inGroup = true; + for (Node n1 : inGroupWith) + if (!g.getNodes().contains(n1)) { + inGroup = false; + break; + } + } + + for (Node n : g.getNodes()) { + if (inGroup && typeNames.contains(n.getComponent().getClass().getCanonicalName()) && + (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { + res.add(n); + } + } + } + return res; + } + + protected List find(Set typeNames, String nodeName, Netlist netlist, Collection> belongTo) { + List res = new ArrayList(); + for (Group g : netlist.getGroups()) { + + for (Node n : g.getNodes()) { + if ((belongTo == null || belongTo.contains(n.getComponent())) && typeNames.contains(n.getComponent().getClass().getCanonicalName()) && + (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { + res.add(n); + } + } + } + return res; + } + + protected boolean allMatch(Collection nodes, String name) { + for (Node n : nodes) + if (!n.getDisplayName().equalsIgnoreCase(name)) + return false; + + return true; + } + + protected boolean allComponentsMatch(Collection nodes, Set> components) { + Set> extracted = extractComponents(nodes); + return extracted.containsAll(components); + } + + protected Set> extractComponents(Collection nodes) { + Set> components = new HashSet>(); + for (Node n : nodes) + components.add(n.getComponent()); + return components; + } + + protected String extractName(IDIYComponent c) { + return c.getName() + " " + c.getValueForDisplay(); + } + + protected List extractNames(Collection> components) { + List names = new ArrayList(); + for (IDIYComponent c : components) + names.add(c.getName() + " " + c.getValueForDisplay()); + Collections.sort(names); + return names; + } + + protected Netlist simplify(Netlist netlist, Set nodesToMerge, Collection nodesToPurge) { + Netlist res = new Netlist(); + res.getSwitchSetup().addAll(netlist.getSwitchSetup()); + + Group merged = new Group(); + + // merge + for (Group g : netlist.getGroups()) { + boolean needsMerging = false; + for (Node n : nodesToMerge) { + if (g.getNodes().contains(n)) { + needsMerging = true; + break; + } + } + if (needsMerging) { + for (Node n : g.getNodes()) { + if (!nodesToMerge.contains(n)) + merged.getNodes().add(n); + } + } else { + res.getGroups().add(g.clone()); + } + } + + if (!merged.getNodes().isEmpty()) + res.getGroups().add(merged); + + // purge + for (Group g : res.getGroups()) { + g.getNodes().removeAll(nodesToPurge); + } + + System.out.println("Before:\n" + netlist); + System.out.println("After:\n" + res); + + return res; + } + + protected boolean intersect(List groups, Node node) { + for (Group g : groups) + if (g.getNodes().contains(node)) + return true; + return false; + } + + protected Node intersect(List groups, Group group) { + for (Group g : groups) + for (Node node : group.getNodes()) + if (g.getNodes().contains(node)) + return node; + return null; + } +} diff --git a/diylc/diylc-library/src/org/diylc/netlist/AbstractNetlistSummarizer.java b/diylc/diylc-library/src/org/diylc/netlist/AbstractNetlistSummarizer.java deleted file mode 100644 index 6bf2dd15..00000000 --- a/diylc/diylc-library/src/org/diylc/netlist/AbstractNetlistSummarizer.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - - 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.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.diylc.core.IDIYComponent; - -public abstract class AbstractNetlistSummarizer { - - public AbstractNetlistSummarizer() { - } - - protected List trace(Set typeNames, String nodeName, Netlist netlist) { - List res = new ArrayList(); - for (Group g : netlist.getGroups()) { - for (Node n : g.getNodes()) { - if (typeNames.contains(n.getComponent().getClass().getCanonicalName()) && - (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { - res.add(g); - break; - } - } - } - return res; - } - - protected List find(Set typeNames, String nodeName, Netlist netlist) { - List res = new ArrayList(); - for (Group g : netlist.getGroups()) { - for (Node n : g.getNodes()) { - if (typeNames.contains(n.getComponent().getClass().getCanonicalName()) && - (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { - res.add(n); - } - } - } - return res; - } - - protected List find(Set typeNames, String nodeName, Netlist netlist, List inGroupWith) { - List res = new ArrayList(); - for (Group g : netlist.getGroups()) { - - boolean inGroup; - if (inGroupWith == null) { - inGroup = true; - } else { - inGroup = true; - for (Node n1 : inGroupWith) - if (!g.getNodes().contains(n1)) { - inGroup = false; - break; - } - } - - for (Node n : g.getNodes()) { - if (inGroup && typeNames.contains(n.getComponent().getClass().getCanonicalName()) && - (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { - res.add(n); - } - } - } - return res; - } - - protected List find(Set typeNames, String nodeName, Netlist netlist, Collection> belongTo) { - List res = new ArrayList(); - for (Group g : netlist.getGroups()) { - - for (Node n : g.getNodes()) { - if ((belongTo == null || belongTo.contains(n.getComponent())) && typeNames.contains(n.getComponent().getClass().getCanonicalName()) && - (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { - res.add(n); - } - } - } - return res; - } - - protected boolean allMatch(Collection nodes, String name) { - for (Node n : nodes) - if (!n.getDisplayName().equalsIgnoreCase(name)) - return false; - - return true; - } - - protected boolean allComponentsMatch(Collection nodes, Set> components) { - Set> extracted = extractComponents(nodes); - return extracted.containsAll(components); - } - - protected Set> extractComponents(Collection nodes) { - Set> components = new HashSet>(); - for (Node n : nodes) - components.add(n.getComponent()); - return components; - } - - protected List extractNames(Collection> components) { - List names = new ArrayList(); - for (IDIYComponent c : components) - names.add(c.getName() + " " + c.getValueForDisplay()); - Collections.sort(names); - return names; - } - - protected Netlist simplify(Netlist netlist, Set nodesToMerge, Collection nodesToPurge) { - Netlist res = new Netlist(); - res.getSwitchSetup().addAll(netlist.getSwitchSetup()); - - Group merged = new Group(); - - // merge - for (Group g : netlist.getGroups()) { - boolean needsMerging = false; - for (Node n : nodesToMerge) { - if (g.getNodes().contains(n)) { - needsMerging = true; - break; - } - } - if (needsMerging) { - for (Node n : g.getNodes()) { - if (!nodesToMerge.contains(n)) - merged.getNodes().add(n); - } - } else { - res.getGroups().add(g.clone()); - } - } - - if (!merged.getNodes().isEmpty()) - res.getGroups().add(merged); - - // purge - for (Group g : res.getGroups()) { - g.getNodes().removeAll(nodesToPurge); - } - - System.out.println("Before:\n" + netlist); - System.out.println("After:\n" + res); - - return res; - } - - protected boolean intersect(List groups, Node node) { - for (Group g : groups) - if (g.getNodes().contains(node)) - return true; - return false; - } - - protected Node intersect(List groups, Group group) { - for (Group g : groups) - for (Node node : group.getNodes()) - if (g.getNodes().contains(node)) - return node; - return null; - } -} diff --git a/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java new file mode 100644 index 00000000..98b81cda --- /dev/null +++ b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java @@ -0,0 +1,170 @@ +/* + + 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.HashSet; +import java.util.List; +import java.util.Set; + +import org.diylc.common.INetlistAnalyzer; +import org.diylc.components.electromechanical.ClosedJack1_4; +import org.diylc.components.electromechanical.OpenJack1_4; +import org.diylc.components.guitar.HumbuckerPickup; +import org.diylc.components.guitar.JazzBassPickup; +import org.diylc.components.guitar.P90Pickup; +import org.diylc.components.guitar.PBassPickup; +import org.diylc.components.guitar.SingleCoilPickup; +import org.diylc.components.passive.PotentiometerPanel; +import org.diylc.core.IDIYComponent; + +public class GuitarDiagramAnalyzer extends AbstractNetlistAnalyzer implements INetlistAnalyzer { + + private static Set JACK_TYPES = new HashSet(); + private static Set POT_TYPES = new HashSet(); + private static Set PICKUP_TYPES = new HashSet(); + static { + JACK_TYPES.add(OpenJack1_4.class.getCanonicalName()); + JACK_TYPES.add(ClosedJack1_4.class.getCanonicalName()); + + POT_TYPES.add(PotentiometerPanel.class.getCanonicalName()); + + PICKUP_TYPES.add(SingleCoilPickup.class.getCanonicalName()); + PICKUP_TYPES.add(HumbuckerPickup.class.getCanonicalName()); + PICKUP_TYPES.add(P90Pickup.class.getCanonicalName()); + PICKUP_TYPES.add(JazzBassPickup.class.getCanonicalName()); + PICKUP_TYPES.add(PBassPickup.class.getCanonicalName()); + } + + @Override + public String getName() { + return "Guitar Diagrams"; + } + + @Override + public String getIconName() { + return "Guitar"; + } + + public List summarize(List netlists, Node preferredOutput) { + List summaries = new ArrayList(); + for (Netlist n : netlists) + summaries.add(summarize(n, preferredOutput)); + + return summaries; + } + + private Summary summarize(Netlist netlist, Node preferredOutput) { + List notes = new ArrayList(); + List jackTipGroups = findGroups(JACK_TYPES, "Tip", netlist); + List jackSleeveGroups = findGroups(JACK_TYPES, "Sleeve", netlist); + +// if (jackTipGroups.size() == 0 || jackSleeveGroups.size() == 0) { +// notes.add("Could not find anything connected to a jack tip terminal."); +// } else if (jackTipGroups.size() > 1 || jackSleeveGroups.size() > 1) { +// notes.add("Multiple jacks found, could not proceed."); +// } else { +// Group jackTipGroup = jackTipGroups.get(0); +// Group jackSleeveGroup = jackSleeveGroups.get(0); +// netlist = findAndEliminatePots(netlist, jackTipGroup, jackSleeveGroup, notes); +// // find jack tip group again after eliminating pots, it should be connecter straight to the pickups +// jackTipGroups = findGroups(JACK_TYPES, "Tip", netlist); +// if (jackTipGroups.size() == 1) { +// jackTipGroup = jackTipGroups.get(0); +// List pickupTipNodes = find(PICKUP_TYPES, null, jackTipGroup); +// List pickupSleeveNodes = find(PICKUP_TYPES, null, jackSleeveGroup); +// notes.add("test"); +// } +// } + + try { + return new Summary(netlist, notes, constructTree(netlist)); + } catch (TreeException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + } + + private Netlist findAndEliminatePots(Netlist netlist, Group jackTipGroup, Group jackSleeveGroup, List notes) { + // try to find any pots that have connections to jack tip or sleeve + List potTipNodes = find(POT_TYPES, null, jackTipGroup); + List potSleeveNodes = find(POT_TYPES, null, jackSleeveGroup); + + if (!potTipNodes.isEmpty() && !potSleeveNodes.isEmpty()) { + + Set> pots = extractComponents(potTipNodes); + List potInputNodes = find(POT_TYPES, "1", netlist, pots); +// List potInputGroups = findGroups(POT_TYPES, "1", netlist, pots); + +// if (allMatch(potTipNodes, "2") && allMatch(potSleeveNodes, "3")) { +// +// for (Group g : potInputGroups) { +// List potNodes = find(POT_TYPES, null, g); +// List pickupNodes = find(PICKUP_TYPES, null, g); +// if (potNodes.size() != 1) { +// notes.add("Detected control potentiometer wiring issue."); +// } else { +// StringBuilder sb = new StringBuilder("Detected volume potentiometer ["); +// sb.append(extractName(potNodes.get(0).getComponent())).append("] controlling: "); +// Set pickups = new HashSet(); +// for (Node n : pickupNodes) { +// pickups.add(n.getComponent().getName()); +// } +// List pickupList = new ArrayList(pickups); +// Collections.sort(pickupList); +// sb.append(pickupList.toString()); +// notes.add(sb.toString()); +// } +// } +// List potNames = extractNames(pots); +// notes.add("Detected volume control(s): " + potNames); + + Set toMerge = new HashSet(potTipNodes); + toMerge.addAll(potInputNodes); + return simplify(netlist, toMerge, potSleeveNodes); +// } else { +// notes.add("Detected incorrectly wired volume control(s)."); +// return netlist; +// } + } + +// notes.add("No volume controls detected."); + return netlist; + } + + @Override + public Tree constructTree(Netlist netlist) throws TreeException { + List jackTipNodes = find(JACK_TYPES, "Tip", netlist); + List jackSleeveNodes = find(JACK_TYPES, "Sleeve", netlist); + + if (jackTipNodes.size() == 0 || jackSleeveNodes.size() == 0) { + throw new TreeException("Could not find anything connected to a jack tip terminal."); + } else if (jackTipNodes.size() > 1 || jackSleeveNodes.size() > 1) { + throw new TreeException("Multiple jacks found, could not proceed."); + } else { + Node jackTip = jackTipNodes.get(0); + Node jackSleeve = jackSleeveNodes.get(0); + return constructTree(netlist, jackTip, jackSleeve); + } + } +} diff --git a/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramSummarizer.java b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramSummarizer.java deleted file mode 100644 index 15c23e18..00000000 --- a/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramSummarizer.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - - 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.HashSet; -import java.util.List; -import java.util.Set; - -import org.diylc.common.INetlistSummarizer; -import org.diylc.components.electromechanical.ClosedJack1_4; -import org.diylc.components.electromechanical.OpenJack1_4; -import org.diylc.components.guitar.HumbuckerPickup; -import org.diylc.components.guitar.JazzBassPickup; -import org.diylc.components.guitar.P90Pickup; -import org.diylc.components.guitar.PBassPickup; -import org.diylc.components.guitar.SingleCoilPickup; -import org.diylc.components.passive.PotentiometerPanel; -import org.diylc.core.IDIYComponent; - -public class GuitarDiagramSummarizer extends AbstractNetlistSummarizer implements INetlistSummarizer { - - private static Set JACK_TYPES = new HashSet(); - private static Set POT_TYPES = new HashSet(); - private static Set PICKUP_TYPES = new HashSet(); - static { - JACK_TYPES.add(OpenJack1_4.class.getCanonicalName()); - JACK_TYPES.add(ClosedJack1_4.class.getCanonicalName()); - - POT_TYPES.add(PotentiometerPanel.class.getCanonicalName()); - - PICKUP_TYPES.add(SingleCoilPickup.class.getCanonicalName()); - PICKUP_TYPES.add(HumbuckerPickup.class.getCanonicalName()); - PICKUP_TYPES.add(P90Pickup.class.getCanonicalName()); - PICKUP_TYPES.add(JazzBassPickup.class.getCanonicalName()); - PICKUP_TYPES.add(PBassPickup.class.getCanonicalName()); - } - - @Override - public String getName() { - return "Guitar Diagrams"; - } - - @Override - public String getIconName() { - return "Guitar"; - } - - public List summarize(List netlists, Node preferredOutput) { - List summaries = new ArrayList(); - for (Netlist n : netlists) - summaries.add(summarize(n, preferredOutput)); - - return summaries; - } - - private Summary summarize(Netlist netlist, Node preferredOutput) { - List notes = new ArrayList(); - List jackTipNodes = find(JACK_TYPES, "Tip", netlist); - List jackSleeveNodes = find(JACK_TYPES, "Sleeve", netlist); - - netlist = findAndEliminateVolumeControls(netlist, jackTipNodes, jackSleeveNodes, notes); - - return new Summary(netlist, notes); - } - - private Netlist findAndEliminateVolumeControls(Netlist netlist, List jackTipGroups, List jackSleeveGroups, List notes) { - List potTipNodes = find(POT_TYPES, null, netlist, jackTipGroups); - List potSleeveNodes = find(POT_TYPES, null, netlist, jackSleeveGroups); - if (!potTipNodes.isEmpty() && !potSleeveNodes.isEmpty()) { - Set> pots = extractComponents(potTipNodes); - List potInputNodes = find(POT_TYPES, "1", netlist, pots); - - if (allMatch(potTipNodes, "2") && allMatch(potSleeveNodes, "3") && allComponentsMatch(potInputNodes, pots)) { - List potNames = extractNames(pots); - notes.add("Detected volume control(s): " + potNames); - - Set toMerge = new HashSet(potTipNodes); - toMerge.addAll(potInputNodes); - return simplify(netlist, toMerge, potSleeveNodes); - } else { - notes.add("Detected incorrectly wired volume control(s)."); - return netlist; - } - } - - notes.add("No volume controls detected."); - return netlist; - } -} diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index cf84282b..c61dc191 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 103891b7..f7145a03 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/swing/ActionFactory.java b/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java index dc9268a6..8f6c9f5e 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java +++ b/diylc/diylc-swing/src/org/diylc/swing/ActionFactory.java @@ -49,7 +49,7 @@ import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.common.BuildingBlockPackage; import org.diylc.common.ComponentType; import org.diylc.common.IComponentTransformer; -import org.diylc.common.INetlistSummarizer; +import org.diylc.common.INetlistAnalyzer; import org.diylc.common.IPlugInPort; import org.diylc.common.ITask; import org.diylc.common.PropertyWrapper; @@ -258,7 +258,7 @@ public class ActionFactory { return new GenerateNetlistAction(plugInPort, swingUI); } - public SummarizeNetlistAction createSummarizeNetlistAction(IPlugInPort plugInPort, ISwingUI swingUI, INetlistSummarizer summarizer) { + public SummarizeNetlistAction createSummarizeNetlistAction(IPlugInPort plugInPort, ISwingUI swingUI, INetlistAnalyzer summarizer) { return new SummarizeNetlistAction(plugInPort, swingUI, summarizer); } @@ -1688,9 +1688,9 @@ public class ActionFactory { private IPlugInPort plugInPort; private ISwingUI swingUI; - private INetlistSummarizer summarizer; + private INetlistAnalyzer summarizer; - public SummarizeNetlistAction(IPlugInPort plugInPort, ISwingUI swingUI, INetlistSummarizer summarizer) { + public SummarizeNetlistAction(IPlugInPort plugInPort, ISwingUI swingUI, INetlistAnalyzer summarizer) { super(); this.plugInPort = plugInPort; this.swingUI = swingUI; @@ -1716,6 +1716,8 @@ public class ActionFactory { for (Summary summary : res) { sb.append("

Switch configuration: ").append(summary.getNetlist().getSwitchSetup()).append("

"); + + sb.append("Parallel/Series connectivity tree:

").append(summary.getTree().toHTML(0)); for (String v : summary.getNotes()) { sb.append("  ").append(v).append("
"); } diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/file/FileMenuPlugin.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/file/FileMenuPlugin.java index 36dccd7e..9022e28b 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/plugins/file/FileMenuPlugin.java +++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/file/FileMenuPlugin.java @@ -29,7 +29,7 @@ import java.util.List; import org.apache.log4j.Logger; import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.common.EventType; -import org.diylc.common.INetlistSummarizer; +import org.diylc.common.INetlistAnalyzer; import org.diylc.common.IPlugIn; import org.diylc.common.IPlugInPort; import org.diylc.images.IconLoader; @@ -91,9 +91,9 @@ public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler { swingUI.injectMenuAction(actionFactory.createBomAction(plugInPort), ANALYZE_TITLE); swingUI.injectMenuAction(actionFactory.createGenerateNetlistAction(plugInPort, swingUI), ANALYZE_TITLE); - List summarizers = plugInPort.getNetlistSummarizers(); + List summarizers = plugInPort.getNetlistAnalyzers(); if (summarizers != null) { - for(INetlistSummarizer summarizer : summarizers) + for(INetlistAnalyzer summarizer : summarizers) swingUI.injectMenuAction(actionFactory.createSummarizeNetlistAction(plugInPort, swingUI, summarizer), ANALYZE_TITLE); }