Added two or four terminal hookup to bass pickups types

This commit is contained in:
Branislav Stojkovic
2019-02-28 19:11:02 +01:00
parent 595cfb3ed1
commit 403d0ea433
12 changed files with 441 additions and 742 deletions
Binary file not shown.
@@ -0,0 +1,190 @@
/*
*
* 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
* <http://www.gnu.org/licenses/>.
*/
package org.diylc.components.guitar;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Shape;
import org.diylc.common.HorizontalAlignment;
import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.AbstractTransparentComponent;
import org.diylc.core.Project;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<String> {
private static final long serialVersionUID = 1L;
protected static Size POINT_SPACING = new Size(0.1d, SizeUnit.in);
protected static final int TERMINAL_FONT_SIZE = 11;
protected String value = "";
protected Orientation orientation = Orientation.DEFAULT;
protected transient Shape[] body;
protected Point controlPoint = new Point(0, 0);
protected Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
protected Polarity polarity = Polarity.North;
public AbstractGuitarPickup() {
updateControlPoints();
}
protected void drawTerminalLabels(Graphics2D g2d, Color color, Project project) {
Point[] points = getControlPoints();
g2d.setColor(color);
g2d.setFont(project.getFont().deriveFont(TERMINAL_FONT_SIZE * 1f));
int dx = 0;
int dy = 0;
switch (orientation) {
case DEFAULT:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : (int) (TERMINAL_FONT_SIZE * 0.8);
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? -TERMINAL_FONT_SIZE : 0;
break;
case _90:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? TERMINAL_FONT_SIZE : 0;
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : (int) (TERMINAL_FONT_SIZE * 0.8);
break;
case _180:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -(int) (TERMINAL_FONT_SIZE * 0.8);
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? TERMINAL_FONT_SIZE : 0;
break;
case _270:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? -TERMINAL_FONT_SIZE : 0;
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -(int) (TERMINAL_FONT_SIZE * 0.8);
break;
}
drawCenteredText(g2d, "N", (points[0].x + points[1].x) / 2 + dx, (points[0].y + points[1].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
drawCenteredText(g2d, "S", (points[2].x + points[3].x) / 2 + dx, (points[2].y + points[3].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
@EditableProperty(name = "Model")
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
// Invalidate the body
body = null;
updateControlPoints();
}
protected Point[] getControlPoints() {
if (controlPoints == null) {
controlPoints =
new Point[] {controlPoint, new Point(controlPoint.x, controlPoint.y),
new Point(controlPoint.x, controlPoint.y), new Point(controlPoint.x, controlPoint.y)};
updateControlPoints();
}
return controlPoints;
}
@Override
public int getControlPointCount() {
return getControlPoints().length;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.ALWAYS;
}
@Override
public Point getControlPoint(int index) {
return getControlPoints()[index];
}
@Override
public void setControlPoint(Point point, int index) {
getControlPoints()[index].setLocation(point);
// Invalidate the body
body = null;
}
@EditableProperty
public Polarity getPolarity() {
if (polarity == null)
polarity = Polarity.North;
return polarity;
}
public void setPolarity(Polarity polarity) {
this.polarity = polarity;
// Invalidate the body
body = null;
}
protected abstract OrientationHV getControlPointDirection();
@SuppressWarnings("incomplete-switch")
protected void updateControlPoints() {
Point[] points = getControlPoints();
int pointSpacing = (int) POINT_SPACING.convertToPixels();
int dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? 1 : 0;
int dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : 1;
if (orientation != Orientation.DEFAULT) {
switch (orientation) {
case _90:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -1;
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? -1 : 0;
break;
case _180:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? -1 : 0;
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -1;
break;
case _270:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : 1;
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 1 : 0;
break;
}
}
points[1].setLocation(points[0].x + dx * pointSpacing, points[0].y + dy * pointSpacing);
points[2]
.setLocation(points[0].x + 2 * dx * pointSpacing, points[0].y + 2 * dy * pointSpacing);
points[3]
.setLocation(points[0].x + 3 * dx * pointSpacing, points[0].y + 3 * dy * pointSpacing);
}
public enum Polarity {
North, South, Humbucking;
}
}
@@ -0,0 +1,135 @@
/*
*
* 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
* <http://www.gnu.org/licenses/>.
*/
package org.diylc.components.guitar;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import org.diylc.common.HorizontalAlignment;
import org.diylc.common.OrientationHV;
import org.diylc.common.VerticalAlignment;
import org.diylc.core.Project;
import org.diylc.core.VisibilityPolicy;
public abstract class AbstractSingleOrHumbuckerPickup extends AbstractGuitarPickup {
private static final long serialVersionUID = 1L;
@Override
protected void drawTerminalLabels(Graphics2D g2d, Color color, Project project) {
Point[] points = getControlPoints();
g2d.setColor(color);
g2d.setFont(project.getFont().deriveFont(TERMINAL_FONT_SIZE * 1f));
int dx = 0;
int dy = 0;
switch (orientation) {
case DEFAULT:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : (int) (TERMINAL_FONT_SIZE * 0.8);
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? -TERMINAL_FONT_SIZE : 0;
break;
case _90:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? TERMINAL_FONT_SIZE : 0;
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : (int) (TERMINAL_FONT_SIZE * 0.8);
break;
case _180:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -(int) (TERMINAL_FONT_SIZE * 0.8);
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? TERMINAL_FONT_SIZE : 0;
break;
case _270:
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? -TERMINAL_FONT_SIZE : 0;
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -(int) (TERMINAL_FONT_SIZE * 0.8);
break;
}
if (getPolarity() == Polarity.North || getPolarity() == Polarity.South) {
drawCenteredText(g2d, getPolarity().name().substring(0, 1), (points[1].x + points[2].x) / 2 + dx, (points[1].y + points[2].y) / 2 + dy, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER);
} else {
drawCenteredText(g2d, "N", (points[0].x + points[1].x) / 2 + dx, (points[0].y + points[1].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
drawCenteredText(g2d, "S", (points[2].x + points[3].x) / 2 + dx, (points[2].y + points[3].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
if (getPolarity() != Polarity.Humbucking && (index == 0 || index == 3))
return VisibilityPolicy.NEVER;
return VisibilityPolicy.ALWAYS;
}
@Override
public boolean isControlPointSticky(int index) {
if (getPolarity() != Polarity.Humbucking && (index == 0 || index == 3))
return false;
return true;
}
@Override
public String getControlPointNodeName(int index) {
switch (index) {
case 0:
if (getPolarity() != Polarity.Humbucking)
return null;
return"North Start";
case 1:
if (getPolarity() == Polarity.South)
return "South Start";
if (getPolarity() == Polarity.North)
return "North Start";
return "North Finish";
case 2:
if (getPolarity() == Polarity.South)
return "South Finish";
if (getPolarity() == Polarity.North)
return "North Finish";
return "South Start";
case 3:
if (getPolarity() != Polarity.Humbucking)
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;
}
}
@@ -37,15 +37,13 @@ import org.diylc.common.HorizontalAlignment;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
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;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
@@ -57,12 +55,10 @@ import org.diylc.utils.Constants;
description = "Double-coil humbucker guitar pickup (PAF, Mini Humbuckers, Filtertrons)", stretchable = false,
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram")
public class HumbuckerPickup extends AbstractTransparentComponent<String> {
public class HumbuckerPickup extends AbstractGuitarPickup {
private static final long serialVersionUID = 1L;
private static final int TERMINAL_FONT_SIZE = 11;
private static Color BASE_COLOR = Color.lightGray;
private static Color BOBIN_COLOR1 = Color.decode("#EAE3C6");
private static Color BOBIN_COLOR2 = Color.black;
@@ -78,7 +74,6 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
private static Size LIP_LENGTH = new Size(7.9d, SizeUnit.mm);
private static Size EDGE_RADIUS = new Size(4d, SizeUnit.mm);
private static Size POINT_MARGIN = new Size(1.5d, SizeUnit.mm);
private static Size POINT_SPACING = new Size(0.1d, SizeUnit.in);
private static Size SCREW_LINE = new Size(1d, SizeUnit.mm);
private static Size POINT_SIZE = new Size(2d, SizeUnit.mm);
private static Size LIP_HOLE_SIZE = new Size(2d, SizeUnit.mm);
@@ -86,10 +81,6 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
private static Size POLE_SIZE_FILTERTRON = new Size(5d, SizeUnit.mm);
private static Size POLE_SPACING = new Size(10.1d, SizeUnit.mm);
private String value = "";
private Point controlPoint = new Point(0, 0);
transient Shape[] body;
private Orientation orientation = Orientation.DEFAULT;
private Color color = BASE_COLOR;
private Color poleColor = METAL_COLOR;
private HumbuckerType type;
@@ -100,12 +91,6 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
private PolePieceType coilType1;
private PolePieceType coilType2;
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
public HumbuckerPickup() {
updateControlPoints();
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
@@ -207,73 +192,12 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER);
// terminal labels
Point[] points = getControlPoints();
g2d.setColor(finalBorderColor);
g2d.setFont(project.getFont().deriveFont(TERMINAL_FONT_SIZE * 1f));
int dx = 0;
int dy = 0;
switch (orientation) {
case DEFAULT:
dx = (int) (TERMINAL_FONT_SIZE * 0.8);
dy = 0;
break;
case _90:
dx = 0;
dy = (int) (TERMINAL_FONT_SIZE * 0.8);
break;
case _180:
dx = -(int) (TERMINAL_FONT_SIZE * 0.8);
dy = 0;
break;
case _270:
dx = 0;
dy = -(int) (TERMINAL_FONT_SIZE * 0.8);
break;
}
drawCenteredText(g2d, "N", (points[0].x + points[1].x) / 2 + dx, (points[0].y + points[1].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
drawCenteredText(g2d, "S", (points[2].x + points[3].x) / 2 + dx, (points[2].y + points[3].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
drawTerminalLabels(g2d, finalBorderColor, project);
}
private Point[] getControlPoints() {
if (controlPoints == null) {
controlPoints =
new Point[] {controlPoint, new Point(controlPoint.x, controlPoint.y),
new Point(controlPoint.x, controlPoint.y), new Point(controlPoint.x, controlPoint.y)};
updateControlPoints();
}
return controlPoints;
}
@SuppressWarnings("incomplete-switch")
private void updateControlPoints() {
Point[] points = getControlPoints();
int pointSpacing = (int) POINT_SPACING.convertToPixels();
int dx = 0;
int dy = 1;
if (orientation != Orientation.DEFAULT) {
switch (orientation) {
case _90:
dx = -1;
dy = 0;
break;
case _180:
dx = 0;
dy = -1;
break;
case _270:
dx = 1;
dy = 0;
break;
}
}
points[1].setLocation(points[0].x + dx * pointSpacing, points[0].y + dy * pointSpacing);
points[2]
.setLocation(points[0].x + 2 * dx * pointSpacing, points[0].y + 2 * dy * pointSpacing);
points[3]
.setLocation(points[0].x + 3 * dx * pointSpacing, points[0].y + 3 * dy * pointSpacing);
@Override
protected OrientationHV getControlPointDirection() {
return OrientationHV.VERTICAL;
}
@SuppressWarnings("incomplete-switch")
@@ -556,56 +480,11 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
body = null;
}
@Override
public int getControlPointCount() {
return getControlPoints().length;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.ALWAYS;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public Point getControlPoint(int index) {
return getControlPoints()[index];
}
@Override
public void setControlPoint(Point point, int index) {
getControlPoints()[index].setLocation(point);
// Invalidate the body
body = null;
}
@EditableProperty(name = "Model")
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
// Invalidate the body
body = null;
updateControlPoints();
}
@EditableProperty
public Color getColor() {
return color;
@@ -683,6 +562,12 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
return null;
}
@Override
public Polarity getPolarity() {
// just to disable editor
return super.getPolarity();
}
public static enum HumbuckerType {
PAF(WIDTH, LENGTH, POLE_SIZE), Mini(WIDTH_MINI, LENGTH_MINI, POLE_SIZE), Filtertron(WIDTH_FILTERTRON,
@@ -38,14 +38,13 @@ import org.diylc.common.HorizontalAlignment;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.AbstractTransparentComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
@@ -57,12 +56,11 @@ import org.diylc.utils.Constants;
description = "Single coil pickup for Jazz Bass and similar guitars", stretchable = false,
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram")
public class JazzBassPickup extends AbstractTransparentComponent<String> {
public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup {
private static final long serialVersionUID = 1L;
private static Color BODY_COLOR = Color.decode("#333333");;
private static Color POINT_COLOR = Color.gray;
private static Color BODY_COLOR = Color.decode("#333333");
private static Size WIDTH = new Size(0.73, SizeUnit.in);
private static Size LENGTH = new Size(4.1, SizeUnit.in);
@@ -78,10 +76,6 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
private static Size POLE_SPACING = new Size(0.85d, SizeUnit.in);
private static Size POLE_SPACING_MINOR = new Size(0.28d, SizeUnit.in);
private String value = "";
private Point controlPoint = new Point(0, 0);
transient Shape[] body;
private Orientation orientation = Orientation.DEFAULT;
private Color color = BODY_COLOR;
private Color poleColor = METAL_COLOR;
@@ -99,8 +93,6 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : color);
g2d.fill(body[0]);
g2d.fill(body[1]);
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
g2d.fill(body[2]);
g2d.setComposite(oldComposite);
Color finalBorderColor;
@@ -144,6 +136,9 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
Rectangle bounds = body[0].getBounds();
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER);
// terminal labels
drawTerminalLabels(g2d, finalLabelColor, project);
}
@SuppressWarnings("incomplete-switch")
@@ -151,8 +146,9 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
if (body == null) {
body = new Shape[4];
int x = controlPoint.x;
int y = controlPoint.y;
Point[] points = getControlPoints();
int x = points[0].x;
int y = points[0].y;
int width = (int) WIDTH.convertToPixels();
int length = (int) LENGTH.convertToPixels();
int edgeRadius = (int) EDGE_RADIUS.convertToPixels();
@@ -164,12 +160,12 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
int lipHoleSpacing = getClosestOdd(LIP_HOLE_SPACING.convertToPixels());
body[0] =
new Area(new RoundRectangle2D.Double(x + pointMargin - length, y - pointMargin, length, width, edgeRadius,
new Area(new RoundRectangle2D.Double(x - length, y - pointMargin, length, width, edgeRadius,
edgeRadius));
Area lip = new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
lip.subtract(new Area(new Ellipse2D.Double(-lipHoleSize / 2, -lipHoleSpacing - lipHoleSize / 2, lipHoleSize, lipHoleSize)));
lip.transform(AffineTransform.getTranslateInstance(x + pointMargin - length / 2 - lipSpacing / 2, y - pointMargin));
lip.transform(AffineTransform.getTranslateInstance(x - length / 2 - lipSpacing / 2, y - pointMargin));
body[1] = new Area(lip);
lip.transform(AffineTransform.getTranslateInstance(lipSpacing, 0));
@@ -191,11 +187,11 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
Area poleArea = new Area();
for (int i = 0; i < 4; i++) {
Ellipse2D pole =
new Ellipse2D.Double(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 - poleSpacingMinor / 2, y
new Ellipse2D.Double(x - length + poleMargin + i * poleSpacing - poleSize / 2 - poleSpacingMinor / 2, y
- pointMargin - poleSize / 2 + width / 2, poleSize, poleSize);
poleArea.add(new Area(pole));
pole =
new Ellipse2D.Double(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSpacingMinor / 2, y
new Ellipse2D.Double(x - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSpacingMinor / 2, y
- pointMargin - poleSize / 2 + width / 2, poleSize, poleSize);
poleArea.add(new Area(pole));
}
@@ -226,6 +222,11 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
return body;
}
@Override
protected OrientationHV getControlPointDirection() {
return OrientationHV.VERTICAL;
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.rotate(Math.PI / 4, width / 2, height / 2);
@@ -258,55 +259,6 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
}
}
@Override
public int getControlPointCount() {
return 1;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.WHEN_SELECTED;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public Point getControlPoint(int index) {
return controlPoint;
}
@Override
public void setControlPoint(Point point, int index) {
this.controlPoint.setLocation(point);
// Invalidate the body
body = null;
}
@EditableProperty(name = "Model")
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
// Invalidate the body
body = null;
}
@EditableProperty
public Color getColor() {
return color;
@@ -326,9 +278,4 @@ public class JazzBassPickup extends AbstractTransparentComponent<String> {
public void setPoleColor(Color poleColor) {
this.poleColor = poleColor;
}
@Override
public String getControlPointNodeName(int index) {
return getName() + ".PickupTerminal";
}
}
@@ -39,14 +39,13 @@ import org.diylc.common.HorizontalAlignment;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.AbstractTransparentComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
@@ -58,7 +57,7 @@ import org.diylc.utils.Constants;
description = "Single coil P-90 guitar pickup, both \"dog ear\" and \"soap bar\"", stretchable = false,
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram")
public class P90Pickup extends AbstractTransparentComponent<String> {
public class P90Pickup extends AbstractSingleOrHumbuckerPickup {
private static final long serialVersionUID = 1L;
@@ -83,62 +82,14 @@ public class P90Pickup extends AbstractTransparentComponent<String> {
private static Size LIP_HOLE_SPACING = new Size(97d, SizeUnit.mm);
private static Size POLE_SIZE = new Size(4d, SizeUnit.mm);
private static Size POLE_SPACING = new Size(11.68d, SizeUnit.mm);
private static Size POINT_SPACING = new Size(0.1d, SizeUnit.in);
private static final int TERMINAL_FONT_SIZE = 11;
private String value = "";
private Point controlPoint = new Point(0, 0);
transient Shape[] body;
private Orientation orientation = Orientation.DEFAULT;
private Color color = BODY_COLOR;
private P90Type type = P90Type.DOG_EAR;
private Color poleColor = METAL_COLOR;
private Polarity polarity = Polarity.North;
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
public P90Pickup() {
updateControlPoints();
}
private Point[] getControlPoints() {
if (controlPoints == null) {
controlPoints =
new Point[] {controlPoint, new Point(controlPoint.x, controlPoint.y),
new Point(controlPoint.x, controlPoint.y), new Point(controlPoint.x, controlPoint.y)};
updateControlPoints();
}
return controlPoints;
}
@SuppressWarnings("incomplete-switch")
private void updateControlPoints() {
Point[] points = getControlPoints();
int pointSpacing = (int) POINT_SPACING.convertToPixels();
int dx = 0;
int dy = 1;
if (orientation != Orientation.DEFAULT) {
switch (orientation) {
case _90:
dx = -1;
dy = 0;
break;
case _180:
dx = 0;
dy = -1;
break;
case _270:
dx = 1;
dy = 0;
break;
}
}
points[1].setLocation(points[0].x + dx * pointSpacing, points[0].y + dy * pointSpacing);
points[2]
.setLocation(points[0].x + 2 * dx * pointSpacing, points[0].y + 2 * dy * pointSpacing);
points[3]
.setLocation(points[0].x + 3 * dx * pointSpacing, points[0].y + 3 * dy * pointSpacing);
@Override
protected OrientationHV getControlPointDirection() {
return OrientationHV.VERTICAL;
}
@Override
@@ -366,57 +317,6 @@ public class P90Pickup extends AbstractTransparentComponent<String> {
body = null;
}
@Override
public int getControlPointCount() {
return getControlPoints().length;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
if (getPolarity() != Polarity.Humbucking && (index == 0 || index == 3))
return VisibilityPolicy.NEVER;
return VisibilityPolicy.ALWAYS;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public Point getControlPoint(int index) {
return getControlPoints()[index];
}
@Override
public void setControlPoint(Point point, int index) {
getControlPoints()[index].setLocation(point);
// Invalidate the body
body = null;
}
@EditableProperty(name = "Model")
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
// Invalidate the body
body = null;
}
@EditableProperty
public Color getColor() {
return color;
@@ -437,46 +337,6 @@ public class P90Pickup extends AbstractTransparentComponent<String> {
this.poleColor = poleColor;
}
@Override
public String getControlPointNodeName(int index) {
switch (index) {
case 0:
if (getPolarity() != Polarity.Humbucking)
return null;
return"North Start";
case 1:
if (getPolarity() == Polarity.South)
return "South Start";
if (getPolarity() == Polarity.North)
return "North Start";
return "North Finish";
case 2:
if (getPolarity() == Polarity.South)
return "South Finish";
if (getPolarity() == Polarity.North)
return "North Finish";
return "South Start";
case 3:
if (getPolarity() != Polarity.Humbucking)
return null;
return "South Finish";
}
return null;
}
@EditableProperty
public Polarity getPolarity() {
if (polarity == null)
polarity = Polarity.North;
return polarity;
}
public void setPolarity(Polarity polarity) {
this.polarity = polarity;
// Invalidate the body
body = null;
}
public enum P90Type {
DOG_EAR("Dog Ear", DOG_EAR_LENGTH, DOG_EAR_WIDTH, DOG_EAR_EDGE_RADIUS), SOAP_BAR("Soap Bar", SOAP_BAR_LENGTH,
SOAP_BAR_WIDTH, SOAP_BAR_EDGE_RADIUS);
@@ -510,8 +370,4 @@ public class P90Pickup extends AbstractTransparentComponent<String> {
return label;
}
}
public enum Polarity {
North, South, Humbucking;
}
}
@@ -38,14 +38,13 @@ import org.diylc.common.HorizontalAlignment;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.AbstractTransparentComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
@@ -57,12 +56,11 @@ import org.diylc.utils.Constants;
description = "Split-coil pickup for P-Bass and similar guitars", stretchable = false,
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram")
public class PBassPickup extends AbstractTransparentComponent<String> {
public class PBassPickup extends AbstractSingleOrHumbuckerPickup {
private static final long serialVersionUID = 1L;
private static Color BODY_COLOR = Color.decode("#333333");;
private static Color POINT_COLOR = Color.gray;
private static Size WIDTH = new Size(1.1, SizeUnit.in);
private static Size LENGTH = new Size(2.2, SizeUnit.in);
@@ -76,10 +74,6 @@ public class PBassPickup extends AbstractTransparentComponent<String> {
private static Size POLE_SIZE = new Size(4d, SizeUnit.mm);
private static Size POLE_SPACING = new Size(0.38d, SizeUnit.in);
private String value = "";
private Point controlPoint = new Point(0, 0);
transient Shape[] body;
private Orientation orientation = Orientation.DEFAULT;
private Color color = BODY_COLOR;
private Color poleColor = METAL_COLOR;
@@ -97,8 +91,6 @@ public class PBassPickup extends AbstractTransparentComponent<String> {
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : color);
g2d.fill(body[0]);
g2d.fill(body[1]);
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
g2d.fill(body[2]);
g2d.setComposite(oldComposite);
Color finalBorderColor;
@@ -142,6 +134,8 @@ public class PBassPickup extends AbstractTransparentComponent<String> {
Rectangle bounds = body[0].getBounds();
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER);
drawTerminalLabels(g2d, finalLabelColor, project);
}
@SuppressWarnings("incomplete-switch")
@@ -149,8 +143,9 @@ public class PBassPickup extends AbstractTransparentComponent<String> {
if (body == null) {
body = new Shape[4];
int x = controlPoint.x;
int y = controlPoint.y;
Point[] points = getControlPoints();
int x = points[0].x;
int y = points[0].y;
int width = (int) WIDTH.convertToPixels();
int length = (int) LENGTH.convertToPixels();
int edgeRadius = (int) EDGE_RADIUS.convertToPixels();
@@ -161,16 +156,16 @@ public class PBassPickup extends AbstractTransparentComponent<String> {
int lipHoleSpacing = getClosestOdd(LIP_HOLE_SPACING.convertToPixels());
body[0] =
new Area(new RoundRectangle2D.Double(x + pointMargin - length, y - pointMargin, length, width, edgeRadius,
new Area(new RoundRectangle2D.Double(x - length, y - pointMargin, length, width, edgeRadius,
edgeRadius));
Area lip = new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
lip.subtract(new Area(new Ellipse2D.Double(-lipHoleSize / 2 + lipHoleSpacing, -lipHoleSize / 2, lipHoleSize, lipHoleSize)));
lip.transform(AffineTransform.getTranslateInstance(x + pointMargin, y - pointMargin + width / 2));
lip.transform(AffineTransform.getTranslateInstance(x, y - pointMargin + width / 2));
Area lip2 = new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
lip2 = new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
lip2.subtract(new Area(new Ellipse2D.Double(-lipHoleSize / 2 - lipHoleSpacing, -lipHoleSize / 2, lipHoleSize, lipHoleSize)));
lip2.transform(AffineTransform.getTranslateInstance(x + pointMargin - length, y - pointMargin + width / 2));
lip2.transform(AffineTransform.getTranslateInstance(x - length, y - pointMargin + width / 2));
lip.add(lip2);
body[1] = new Area(lip);
@@ -185,7 +180,7 @@ public class PBassPickup extends AbstractTransparentComponent<String> {
Area poleArea = new Area();
for (int i = 0; i < 4; i++) {
Ellipse2D pole =
new Ellipse2D.Double(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2, y
new Ellipse2D.Double(x - length + poleMargin + i * poleSpacing - poleSize / 2, y
- pointMargin - poleSize / 2 + width / 2, poleSize, poleSize);
poleArea.add(new Area(pole));
}
@@ -247,52 +242,8 @@ public class PBassPickup extends AbstractTransparentComponent<String> {
}
@Override
public int getControlPointCount() {
return 1;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.WHEN_SELECTED;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public Point getControlPoint(int index) {
return controlPoint;
}
@Override
public void setControlPoint(Point point, int index) {
this.controlPoint.setLocation(point);
// Invalidate the body
body = null;
}
@EditableProperty(name = "Model")
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
// Invalidate the body
body = null;
protected OrientationHV getControlPointDirection() {
return OrientationHV.VERTICAL;
}
@EditableProperty
@@ -314,9 +265,4 @@ public class PBassPickup extends AbstractTransparentComponent<String> {
public void setPoleColor(Color poleColor) {
this.poleColor = poleColor;
}
@Override
public String getControlPointNodeName(int index) {
return getName() + ".PickupTerminal";
}
}
@@ -39,15 +39,14 @@ import org.diylc.common.HorizontalAlignment;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.AbstractTransparentComponent;
import org.diylc.components.RoundedPath;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
@@ -59,12 +58,10 @@ import org.diylc.utils.Constants;
description = "Single coil guitar pickup, both Strat and Tele style", stretchable = false,
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram")
public class SingleCoilPickup extends AbstractTransparentComponent<String> {
public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup {
private static final long serialVersionUID = 1L;
private static final int TERMINAL_FONT_SIZE = 11;
private static Color BODY_COLOR = Color.white;
private static Color BASE_COLOR = Color.gray;
public static Color LUG_COLOR = Color.decode("#E0C04C");
@@ -72,7 +69,6 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
private static Size WIDTH = new Size(15.5d, SizeUnit.mm);
private static Size LENGTH = new Size(83d, SizeUnit.mm);
private static Size BASE_RADIUS = new Size(0.15d, SizeUnit.in);
private static Size POINT_SPACING = new Size(0.1d, SizeUnit.in);
private static Size LUG_DIAMETER = new Size(0.06d, SizeUnit.in);
// strat-specific
@@ -95,61 +91,16 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
private static Size RAIL_LENGTH = new Size(60d, SizeUnit.mm);
private static Size COIL_SPACING = new Size(7.5d, SizeUnit.mm);
private String value = "";
private Point controlPoint = new Point(0, 0);
transient Shape[] body;
private Orientation orientation = Orientation.DEFAULT;
private Color color = BODY_COLOR;
private Color poleColor = METAL_COLOR;
private Color baseColor = BASE_COLOR;
private SingleCoilType type = SingleCoilType.Stratocaster;
private PolePieceType polePieceType = PolePieceType.Rods;
private Color lugColor = LUG_COLOR;
private Polarity polarity = Polarity.North;
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
public SingleCoilPickup() {
updateControlPoints();
}
private Point[] getControlPoints() {
if (controlPoints == null) {
controlPoints =
new Point[] {controlPoint, new Point(controlPoint.x, controlPoint.y),
new Point(controlPoint.x, controlPoint.y), new Point(controlPoint.x, controlPoint.y)};
updateControlPoints();
}
return controlPoints;
}
@SuppressWarnings("incomplete-switch")
private void updateControlPoints() {
Point[] points = getControlPoints();
int pointSpacing = (int) POINT_SPACING.convertToPixels();
int dx = 1;
int dy = 0;
if (orientation != Orientation.DEFAULT) {
switch (orientation) {
case _90:
dx = 0;
dy = -1;
break;
case _180:
dx = -1;
dy = 0;
break;
case _270:
dx = 0;
dy = 1;
break;
}
}
points[1].setLocation(points[0].x + dx * pointSpacing, points[0].y + dy * pointSpacing);
points[2]
.setLocation(points[0].x + 2 * dx * pointSpacing, points[0].y + 2 * dy * pointSpacing);
points[3]
.setLocation(points[0].x + 3 * dx * pointSpacing, points[0].y + 3 * dy * pointSpacing);
@Override
protected OrientationHV getControlPointDirection() {
return OrientationHV.HORIZONTAL;
}
@Override
@@ -236,38 +187,7 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER);
// terminal labels
Point[] points = getControlPoints();
g2d.setColor(darkerOrLighter(baseColor));
g2d.setFont(project.getFont().deriveFont(TERMINAL_FONT_SIZE * 1f));
int dx = 0;
int dy = 0;
switch (orientation) {
case DEFAULT:
dx = 0;
dy = -TERMINAL_FONT_SIZE;
break;
case _90:
dx = TERMINAL_FONT_SIZE;
dy = 0;
break;
case _180:
dx = 0;
dy = TERMINAL_FONT_SIZE;
break;
case _270:
dx = -TERMINAL_FONT_SIZE;
dy = 0;
break;
}
if (getPolarity() == Polarity.North || getPolarity() == Polarity.South) {
drawCenteredText(g2d, getPolarity().name().substring(0, 1), (points[1].x + points[2].x) / 2 + dx, (points[1].y + points[2].y) / 2 + dy, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER);
} else {
drawCenteredText(g2d, "N", (points[0].x + points[1].x) / 2 + dx, (points[0].y + points[1].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
drawCenteredText(g2d, "S", (points[2].x + points[3].x) / 2 + dx, (points[2].y + points[3].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
drawTerminalLabels(g2d, finalLabelColor, project);
}
@SuppressWarnings("incomplete-switch")
@@ -477,56 +397,6 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
body = null;
}
@Override
public int getControlPointCount() {
return getControlPoints().length;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@Override
public boolean isControlPointSticky(int index) {
return getPolarity() == Polarity.Humbucking || (index > 0 && index < 3);
}
@Override
public Point getControlPoint(int index) {
return getControlPoints()[index];
}
@Override
public void setControlPoint(Point point, int index) {
getControlPoints()[index].setLocation(point);
// Invalidate the body
body = null;
}
@EditableProperty(name = "Model")
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
// Invalidate the body
body = null;
updateControlPoints();
}
@EditableProperty
public Color getColor() {
return color;
@@ -570,78 +440,11 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
this.lugColor = lugColor;
}
@EditableProperty
public Polarity getPolarity() {
if (polarity == null)
polarity = Polarity.North;
return polarity;
}
public void setPolarity(Polarity polarity) {
this.polarity = polarity;
// Invalidate the body
body = null;
}
@Override
public String getControlPointNodeName(int index) {
switch (index) {
case 0:
if (getPolarity() != Polarity.Humbucking)
return null;
return"North Start";
case 1:
if (getPolarity() == Polarity.South)
return "South Start";
if (getPolarity() == Polarity.North)
return "North Start";
return "North Finish";
case 2:
if (getPolarity() == Polarity.South)
return "South Finish";
if (getPolarity() == Polarity.North)
return "North Finish";
return "South Start";
case 3:
if (getPolarity() != Polarity.Humbucking)
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;
}
public enum SingleCoilType {
Stratocaster, Telecaster;
}
public enum Polarity {
North, South, Humbucking;
}
public enum PolePieceType {
Rods("Single Rods"), Rail("Single Rail"), RailHumbucker("Dual Rail Humbucker"), RodHumbucker("Dual Rods"), None("None");
@@ -35,7 +35,6 @@ 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 NetlistAnalyzer implements INetlistAnalyzer {
@@ -75,76 +74,10 @@ public class GuitarDiagramAnalyzer extends NetlistAnalyzer implements INetlistAn
private Summary summarize(Netlist netlist, Node preferredOutput) throws TreeException {
List<String> notes = new ArrayList<String>();
List<Group> jackTipGroups = findGroups(JACK_TYPES, "Tip", netlist);
List<Group> 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<Node> pickupTipNodes = find(PICKUP_TYPES, null, jackTipGroup);
// List<Node> pickupSleeveNodes = find(PICKUP_TYPES, null, jackSleeveGroup);
// notes.add("test");
// }
// }
Tree tree = constructTree(netlist);
return new Summary(netlist, notes, constructTree(netlist));
}
private Netlist findAndEliminatePots(Netlist netlist, Group jackTipGroup, Group jackSleeveGroup, List<String> notes) {
// try to find any pots that have connections to jack tip or sleeve
List<Node> potTipNodes = find(POT_TYPES, null, jackTipGroup);
List<Node> potSleeveNodes = find(POT_TYPES, null, jackSleeveGroup);
if (!potTipNodes.isEmpty() && !potSleeveNodes.isEmpty()) {
Set<IDIYComponent<?>> pots = extractComponents(potTipNodes);
List<Node> potInputNodes = find(POT_TYPES, "1", netlist, pots);
// List<Group> potInputGroups = findGroups(POT_TYPES, "1", netlist, pots);
// if (allMatch(potTipNodes, "2") && allMatch(potSleeveNodes, "3")) {
//
// for (Group g : potInputGroups) {
// List<Node> potNodes = find(POT_TYPES, null, g);
// List<Node> 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<String> pickups = new HashSet<String>();
// for (Node n : pickupNodes) {
// pickups.add(n.getComponent().getName());
// }
// List<String> pickupList = new ArrayList<String>(pickups);
// Collections.sort(pickupList);
// sb.append(pickupList.toString());
// notes.add(sb.toString());
// }
// }
// List<String> potNames = extractNames(pots);
// notes.add("Detected volume control(s): " + potNames);
Set<Node> toMerge = new HashSet<Node>(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;
return new Summary(netlist, notes, tree);
}
@Override
Binary file not shown.
Binary file not shown.
+4
View File
@@ -2518,6 +2518,10 @@
<changeType>NEW_FEATURE</changeType>
<description>Show wire diameter in mm and in next to AWG gauge</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added two or four terminal hookup to bass pickups types</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Increase the range of zoom slider for images to 500%</description>