diff --git a/diylc/diylc-core/src/org/diylc/netlist/Tree.java b/diylc/diylc-core/src/org/diylc/netlist/Tree.java index e99b36d2..bfa1ed23 100644 --- a/diylc/diylc-core/src/org/diylc/netlist/Tree.java +++ b/diylc/diylc-core/src/org/diylc/netlist/Tree.java @@ -247,6 +247,9 @@ public class Tree { if (p1 == null || p2 == null) return null; + if (p1 == p2) + return p1; + if (p1 != p2) return this; @@ -272,6 +275,20 @@ public class Tree { return findCommonParent(t.get(0), findCommonParent(remainder)); } + public Tree findParent(Tree t) { + if (children == null) + return null; + if (children.contains(t)) + return this; + for (Tree c : children) + { + Tree p = c.findParent(t); + if (p != null) + return p; + } + return null; + } + public boolean contains(Tree t) { if (this == t) return true; diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index ad329e17..5d69ceec 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/guitar/LeverSwitch.java b/diylc/diylc-library/src/org/diylc/components/guitar/LeverSwitch.java index 7d09e05a..faf1bbc1 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/LeverSwitch.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/LeverSwitch.java @@ -237,7 +237,7 @@ public class LeverSwitch extends AbstractTransparentComponent implements // Rotate if needed if (theta != 0) { - AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y); + AffineTransform rotation = AffineTransform.getRotateInstance(theta, controlPoints[0].x, controlPoints[0].y); // Skip the last two because terminals are already rotated for (int i = 0; i < body.length - 2; i++) { Shape shape = body[i]; @@ -462,7 +462,7 @@ public class LeverSwitch extends AbstractTransparentComponent implements case DP3T: return (index1 == 1 && index2 == index1 + 2 * (position + 1)) || (index2 == 6 && index2 == index1 + 2 * (3 - position)); case DP4T: - return (index1 == 1 && index2 == index1 + 2 * (position + 1)) || (index2 == 8 && index2 == index1 + 2 * (3 - position)); + return (index1 == 1 && index2 == index1 + 2 * (position + 1)) || (index2 == 8 && index2 == index1 + 2 * (4 - position)); case DP3T_5pos: if (position % 2 == 0) return (index1 == 1 && index2 == index1 + position + 2) || (index2 == 6 && index2 == index1 + 6 - position); 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 4a1ae53f..5bc21d19 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java @@ -156,10 +156,10 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup { : darkerOrLighter(color); } - g2d.setColor(finalBorderColor); - if (body[0] != null) - g2d.draw(body[0]); - g2d.draw(body[3]); + g2d.setColor(finalBorderColor); + g2d.draw(body[0]); + if (body[3] != null) + g2d.draw(body[3]); if (!outlineMode) { g2d.setColor(getPoleColor()); @@ -203,7 +203,7 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup { int holeSize = getClosestOdd(HOLE_SIZE.convertToPixels()); int holeMargin = getClosestOdd(HOLE_MARGIN.convertToPixels()); int baseRadius = (int) BASE_RADIUS.convertToPixels(); - int coilOffset = 0; + int coilOffset = 0; if (getType() == SingleCoilType.Stratocaster) { coilOffset = lipWidth / 2; @@ -251,7 +251,7 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup { base.subtract(new Area(new Ellipse2D.Double(x - teleLipLength / 2 - holeSize / 2, y, holeSize, holeSize))); base.subtract(new Area(new Ellipse2D.Double(x + teleLipLength / 2 - holeSize / 2, y, holeSize, holeSize))); base.subtract(new Area(new Ellipse2D.Double(x - holeSize / 2, y - teleHoleSpacing, holeSize, holeSize))); - + body[4] = base; } @@ -290,15 +290,17 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup { int railLength = (int) RAIL_LENGTH.convertToPixels(); poleArea.add(new Area(new RoundRectangle2D.Double(x - railLength / 2, y - coilOffset - width / 2 - railWidth / 2, railLength, railWidth, railWidth / 2, railWidth / 2))); - } - - body[2] = poleArea; - - body[0] = - new Area(new RoundRectangle2D.Double(x - coilLength / 2, y - coilOffset - width, coilLength, width, width, + } + + body[0] = + new Area(new RoundRectangle2D.Double(x - coilLength / 2, y - coilOffset - width, coilLength, width, width, width)); - ((Area) body[4]).subtract((Area) body[3]); + body[2] = poleArea; + + if (body[3] == null) { + ((Area)body[4]).subtract((Area) body[0]); + } // Rotate if needed if (orientation != Orientation.DEFAULT) { diff --git a/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java index e435f4ce..6df107e7 100644 --- a/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java +++ b/diylc/diylc-library/src/org/diylc/netlist/GuitarDiagramAnalyzer.java @@ -37,7 +37,10 @@ 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.AxialFilmCapacitor; import org.diylc.components.passive.PotentiometerPanel; +import org.diylc.components.passive.RadialCeramicDiskCapacitor; +import org.diylc.components.passive.RadialFilmCapacitor; import org.diylc.core.IDIYComponent; import org.diylc.netlist.Tree.ITreeWalker; @@ -46,6 +49,7 @@ public class GuitarDiagramAnalyzer extends NetlistAnalyzer implements INetlistAn private static Set JACK_TYPES = new HashSet(); private static Set POT_TYPES = new HashSet(); private static Set PICKUP_TYPES = new HashSet(); + private static Set CAP_TYPES = new HashSet(); static { JACK_TYPES.add(OpenJack1_4.class.getCanonicalName()); JACK_TYPES.add(ClosedJack1_4.class.getCanonicalName()); @@ -57,6 +61,10 @@ public class GuitarDiagramAnalyzer extends NetlistAnalyzer implements INetlistAn PICKUP_TYPES.add(P90Pickup.class.getCanonicalName()); PICKUP_TYPES.add(JazzBassPickup.class.getCanonicalName()); PICKUP_TYPES.add(PBassPickup.class.getCanonicalName()); + + CAP_TYPES.add(RadialCeramicDiskCapacitor.class.getCanonicalName()); + CAP_TYPES.add(RadialFilmCapacitor.class.getCanonicalName()); + CAP_TYPES.add(AxialFilmCapacitor.class.getCanonicalName()); } @Override @@ -168,17 +176,137 @@ public class GuitarDiagramAnalyzer extends NetlistAnalyzer implements INetlistAn boolean humCancelling = noiseCount == 0; if (humCancelling) - notes.add("This position is hum-cancelling"); + notes.add("This configuration is hum-cancelling"); else - notes.add("This position is NOT hum-cancelling"); + notes.add("This configuration is NOT hum-cancelling"); - if (positiveCount > 1 || negativeCount > 1) { + if (positiveCount > 1 || negativeCount > 1 || (positiveCount == 1 && negativeCount == 1)) { boolean inPhase = (positiveCount == 0 && negativeCount > 0) || (positiveCount > 0 && negativeCount == 0); if (inPhase) - notes.add("Pickup coils are wired in-phase"); + notes.add("All pickup coils are wired in-phase"); else - notes.add("Pickup coils are wired OUT-of-phase"); + notes.add("Some pickup coils are wired OUT-of-phase"); } + + // locate volume and tone pots + Map, List>> volPotPickupMap = new HashMap, List>>(); + Map, List>> tonePotPickupMap = new HashMap, List>>(); + Map, List>> tonePotPickupReverseMap = new HashMap, List>>(); + Map, List>> volPotPickupReverseMap = new HashMap, List>>(); + + Set> pots = tree.extractComponents(POT_TYPES); + for (IDIYComponent pot : pots) { + TreeLeaf leaf1 = new TreeLeaf(pot, 0, 1); + TreeLeaf leaf2 = new TreeLeaf(pot, 1, 2); + Tree tree1 = tree.locate(leaf1, false); + Tree tree2 = tree.locate(leaf2, false); + + if ((tree1 == null && tree2 != null) || (tree1 != null && tree2 == null)) { + boolean tonePotReversed = tree1 != null; + Tree t = tree1 == null ? tree2 : tree1; + Tree p = tree.findParent(t); + if (p != null && p.getChildren().size() == 2) { + Set> caps = p.extractComponents(CAP_TYPES); + if (caps != null && caps.size() == 1) { + for (Map.Entry, Tree> r : pickupRoots.entrySet()) { + Tree toneParent = tree.findCommonParent(p, r.getValue()); + if (toneParent != null && toneParent.getConnectionType() == TreeConnectionType.Parallel) { + if (tonePotReversed) { + List> pickupList = tonePotPickupReverseMap.get(pot); + if (pickupList == null) { + pickupList = new ArrayList>(); + tonePotPickupReverseMap.put(pot, pickupList); + } + pickupList.add(r.getKey()); + } else { + List> pickupList = tonePotPickupMap.get(pot); + if (pickupList == null) { + pickupList = new ArrayList>(); + tonePotPickupMap.put(pot, pickupList); + } + pickupList.add(r.getKey()); + } + } + } + } + } + } + + // volume + if (tree1 == null || tree2 == null) + continue; + for (Map.Entry, Tree> r : pickupRoots.entrySet()) { + Tree parent1 = tree.findCommonParent(tree1, r.getValue()); + Tree parent2 = tree.findCommonParent(tree2, r.getValue()); + if (parent1 != null && parent2 != null && parent1.getConnectionType() == TreeConnectionType.Series && parent2.getConnectionType() == TreeConnectionType.Parallel) + { + List> pickupList = volPotPickupMap.get(pot); + if (pickupList == null) { + pickupList = new ArrayList>(); + volPotPickupMap.put(pot, pickupList); + } + pickupList.add(r.getKey()); + } else if (parent1 != null && parent2 != null && parent1.getConnectionType() == TreeConnectionType.Parallel && parent2.getConnectionType() == TreeConnectionType.Series) + { + List> pickupList = volPotPickupReverseMap.get(pot); + if (pickupList == null) { + pickupList = new ArrayList>(); + volPotPickupReverseMap.put(pot, pickupList); + } + pickupList.add(r.getKey()); + } + } + } + + for (Map.Entry, List>> e : volPotPickupMap.entrySet()) { + StringBuilder sb = new StringBuilder("'" + e.getKey().getName() + "' potentiometer acts as a volume control for "); + boolean first = true; + for (IDIYComponent c : e.getValue()) { + if (!first) + sb.append(e.getValue().size() == 2 ? " and " : ", "); + first = false; + sb.append("'").append(c.getName()).append("'"); + } + notes.add(sb.toString()); + } + + for (Map.Entry, List>> e : volPotPickupReverseMap.entrySet()) { + StringBuilder sb = new StringBuilder("'" + e.getKey().getName() + "' potentiometer acts as a volume control for "); + boolean first = true; + for (IDIYComponent c : e.getValue()) { + if (!first) + sb.append(e.getValue().size() == 2 ? " and " : ", "); + first = false; + sb.append("'").append(c.getName()).append("'"); + } + sb.append(", but is wired in REVERSE!"); + notes.add(sb.toString()); + } + + for (Map.Entry, List>> e : tonePotPickupMap.entrySet()) { + StringBuilder sb = new StringBuilder("'" + e.getKey().getName() + "' potentiometer acts as a tone control for "); + boolean first = true; + for (IDIYComponent c : e.getValue()) { + if (!first) + sb.append(e.getValue().size() == 2 ? " and " : ", "); + first = false; + sb.append("'").append(c.getName()).append("'"); + } + notes.add(sb.toString()); + } + + for (Map.Entry, List>> e : tonePotPickupReverseMap.entrySet()) { + StringBuilder sb = new StringBuilder("'" + e.getKey().getName() + "' potentiometer acts as a tone control for "); + boolean first = true; + for (IDIYComponent c : e.getValue()) { + if (!first) + sb.append(e.getValue().size() == 2 ? " and " : ", "); + first = false; + sb.append("'").append(c.getName()).append("'"); + } + sb.append(", but is wired in REVERSE!"); + notes.add(sb.toString()); + } } return new Summary(netlist, notes, tree); diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index ad329e17..5d69ceec 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 a741a0a5..c5e38b64 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/update.xml b/diylc/diylc-swing/update.xml index 62905697..6f34a9ac 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -2528,7 +2528,7 @@ NEW_FEATURE - "Analyze Guitar Wiring" can figure out if wiring is hum-cancelling and in or out of phase for each position, can detect split-coil wiring and series/parallel humbucking mode + "Analyze Guitar Wiring" can figure out if wiring is hum-cancelling and in or out of phase for each position, split-coil wiring, series/parallel humbucking mode, volume and tone potentiometers IMPROVEMENT