diff --git a/diylc/diylc-core/src/org/diylc/common/INetlistSummarizer.java b/diylc/diylc-core/src/org/diylc/common/INetlistSummarizer.java
index 7e9d0738..bba1da98 100644
--- a/diylc/diylc-core/src/org/diylc/common/INetlistSummarizer.java
+++ b/diylc/diylc-core/src/org/diylc/common/INetlistSummarizer.java
@@ -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 .
+
+*/
package org.diylc.common;
import java.util.List;
diff --git a/diylc/diylc-core/src/org/diylc/netlist/Group.java b/diylc/diylc-core/src/org/diylc/netlist/Group.java
index 666eba44..5843691a 100644
--- a/diylc/diylc-core/src/org/diylc/netlist/Group.java
+++ b/diylc/diylc-core/src/org/diylc/netlist/Group.java
@@ -35,6 +35,10 @@ import java.util.Set;
public class Group implements Comparable {
private Set nodes = new HashSet();
+
+ public Group() {
+
+ }
public Group(Node node1, Node node2) {
nodes.add(node1);
diff --git a/diylc/diylc-core/src/org/diylc/netlist/Node.java b/diylc/diylc-core/src/org/diylc/netlist/Node.java
index 29eee7b6..16905c9d 100644
--- a/diylc/diylc-core/src/org/diylc/netlist/Node.java
+++ b/diylc/diylc-core/src/org/diylc/netlist/Node.java
@@ -46,6 +46,10 @@ public class Node implements Comparable {
public int getPointIndex() {
return pointIndex;
}
+
+ public String getDisplayName() {
+ return component.getControlPointNodeName(pointIndex);
+ }
@Override
public int hashCode() {
@@ -77,7 +81,7 @@ public class Node implements Comparable {
@Override
public String toString() {
- return component.getName() + "." + component.getControlPointNodeName(pointIndex) /*+ " @ (" + component.getControlPoint(pointIndex).getX() + ":" + component.getControlPoint(pointIndex).getY() + ")"*/;
+ return component.getName() + "." + getDisplayName() /*+ " @ (" + component.getControlPoint(pointIndex).getX() + ":" + component.getControlPoint(pointIndex).getY() + ")"*/;
}
@Override
diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar
index 30022924..7a98c1fc 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/AbstractNetlistSummarizer.java b/diylc/diylc-library/src/org/diylc/netlist/AbstractNetlistSummarizer.java
new file mode 100644
index 00000000..42034bd7
--- /dev/null
+++ b/diylc/diylc-library/src/org/diylc/netlist/AbstractNetlistSummarizer.java
@@ -0,0 +1,117 @@
+/*
+
+ 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;
+import java.util.Set;
+
+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 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 Netlist eliminate(Netlist netlist, Set nodes) {
+ Netlist res = new Netlist();
+ res.getSwitchSetup().addAll(netlist.getSwitchSetup());
+
+ Group merged = new Group();
+
+ for (Group g : netlist.getGroups()) {
+ boolean needsMerging = false;
+ for (Node n : nodes) {
+ if (g.getNodes().contains(n)) {
+ needsMerging = true;
+ break;
+ }
+ }
+ if (needsMerging) {
+ for (Node n : g.getNodes()) {
+ if (!nodes.contains(n))
+ merged.getNodes().add(n);
+ }
+ } else {
+ res.getGroups().add(g);
+ }
+ }
+
+ if (!merged.getNodes().isEmpty())
+ res.getGroups().add(merged);
+
+ 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/GuitarDiagramSummarizer.java b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramSummarizer.java
index 09fa6dcf..95e22b23 100644
--- a/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramSummarizer.java
+++ b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramSummarizer.java
@@ -1,11 +1,58 @@
+/*
+
+ 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;
-public class GuitarDiagramSummarizer implements INetlistSummarizer {
+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() {
@@ -27,8 +74,32 @@ public class GuitarDiagramSummarizer implements INetlistSummarizer {
private Summary summarize(Netlist netlist, Node preferredOutput) {
List notes = new ArrayList();
- notes.add("test");
+ List jackTipNodes = find(JACK_TYPES, "Tip", netlist, null);
+ List jackSleeveNodes = find(JACK_TYPES, "Sleeve", netlist, null);
+
+ netlist = findAndEliminateVolumePot(netlist, jackTipNodes, jackSleeveNodes, notes);
+
return new Summary(netlist, notes);
}
+ private Netlist findAndEliminateVolumePot(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()) {
+ if (potTipNodes.size() == 1 && potTipNodes.get(0).getDisplayName().equals("2") &&
+ potSleeveNodes.size() == 1 && potSleeveNodes.get(0).getDisplayName().equals("3")) {
+ notes.add("Volume pot detected: " + potTipNodes.get(0).getComponent().getName());
+
+ Set toEliminate = new HashSet(potTipNodes);
+ toEliminate.addAll(potSleeveNodes);
+ return eliminate(netlist, toEliminate);
+ } else if (potTipNodes.size() > 1 || potSleeveNodes.size() > 1) {
+ notes.add("Detected multiple volume pots, test inconclusive.");
+ return netlist;
+ }
+ }
+
+ notes.add("No volume pot detected.");
+ return netlist;
+ }
}
diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar
index 30022924..7a98c1fc 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 91281ef6..c4618835 100644
Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ