Increased tolerance of sticky points on guitar pickup terminals in order to make it easier for leads to make proper contact and for the circuit analyzer to work

This commit is contained in:
Bane Stojkovic
2025-05-16 12:10:35 +02:00
parent f1d886865d
commit fe0dadd64b
9 changed files with 204 additions and 198 deletions
+16 -52
View File
@@ -1,57 +1,5 @@
<java.util.Arrays_-ArrayList>
<a class="org.diylc.appframework.update.Version-array">
<org.diylc.appframework.update.Version>
<versionNumber>
<major>4</major>
<minor>41</minor>
<build>0</build>
</versionNumber>
<releaseDate>2025-03-08 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Export traces, pads (with holes), ground fill and PCB text to Gerber files</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added ability to select PTH or NPTH holes for solder pads</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Optimized continuity calculations to be faster</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Increased maximum available memory for DIYLC to 4GB</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Upgraded Java JRE to version 17 LTE</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Added support for high DPI displays</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Added windows x64 build</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Pasting a building block sometimes messes up the z-order of components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Pasting a building block sometimes switches selection to previously added components and canvas moves to the wrong position</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>'Highlight Continuity Areas' sometimes renders stale areas when clicked</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>4</major>
@@ -336,5 +284,21 @@
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>5</major>
<minor>5</minor>
<build>0</build>
</versionNumber>
<releaseDate>2025-05-13 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Increased tolerance of sticky points on guitar pickup terminals in order to make it easier for leads to make proper contact and for the circuit analyzer to work</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
</a>
</java.util.Arrays_-ArrayList>
@@ -4721,5 +4721,57 @@
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>4</major>
<minor>41</minor>
<build>0</build>
</versionNumber>
<releaseDate>2025-03-08 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Export traces, pads (with holes), ground fill and PCB text to Gerber files</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added ability to select PTH or NPTH holes for solder pads</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Optimized continuity calculations to be faster</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Increased maximum available memory for DIYLC to 4GB</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Upgraded Java JRE to version 17 LTE</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Added support for high DPI displays</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Added windows x64 build</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Pasting a building block sometimes messes up the z-order of components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Pasting a building block sometimes switches selection to previously added components and canvas moves to the wrong position</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>'Highlight Continuity Areas' sometimes renders stale areas when clicked</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
</a>
</java.util.Arrays_-ArrayList>
@@ -23,6 +23,7 @@ import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager;
@@ -34,10 +35,7 @@ import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.AbstractLabeledComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.*;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
@@ -48,6 +46,7 @@ public abstract class AbstractGuitarPickup extends AbstractLabeledComponent<Stri
private static final long serialVersionUID = 1L;
protected static Size POINT_SPACING = new Size(0.1d, SizeUnit.in);
private static Size POINT_SIZE = new Size(1.5d, SizeUnit.mm);
protected static final int TERMINAL_FONT_SIZE = 11;
@@ -131,6 +130,21 @@ public abstract class AbstractGuitarPickup extends AbstractLabeledComponent<Stri
g2d.setTransform(originalTx);
}
protected void markContactPoints(Graphics2D g2d, IDrawingObserver drawingObserver) {
g2d.setColor(Constants.TRANSPARENT_COLOR);
int pointSize = getClosestOdd(POINT_SIZE.convertToPixels());
drawingObserver.startTrackingContinuityArea(true);
for (int i = 0; i < getControlPointCount(); i++) {
if (isControlPointSticky(i)) {
Point2D p = getControlPoint(i);
g2d.fill(
new Ellipse2D.Double(p.getX() - pointSize / 2, p.getY() - pointSize / 2, pointSize,
pointSize));
}
}
drawingObserver.stopTrackingContinuityArea();
}
protected abstract Shape[] getBody();
@@ -74,7 +74,6 @@ public class HumbuckerPickup extends AbstractGuitarPickup {
private static Size EDGE_RADIUS = new Size(4d, SizeUnit.mm);
private static Size POINT_MARGIN = new Size(1.5d, SizeUnit.mm);
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);
private static Size POLE_SIZE = new Size(4d, SizeUnit.mm);
private static Size POLE_SIZE_FILTERTRON = new Size(5d, SizeUnit.mm);
@@ -133,12 +132,8 @@ public class HumbuckerPickup extends AbstractGuitarPickup {
drawingObserver.stopTracking();
}
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
// g2d.fill(body[2]);
g2d.setComposite(oldComposite);
Color finalBorderColor;
if (outlineMode) {
Theme theme =
@@ -158,6 +153,8 @@ public class HumbuckerPickup extends AbstractGuitarPickup {
if (body[1] != null)
g2d.draw(body[1]);
markContactPoints(g2d, drawingObserver);
if (!outlineMode) {
g2d.setColor(getPoleColor());
g2d.fill(body[3]);
@@ -208,7 +205,7 @@ public class HumbuckerPickup extends AbstractGuitarPickup {
int lipLength = (int) LIP_LENGTH.convertToPixels();
int edgeRadius = (int) EDGE_RADIUS.convertToPixels();
int pointMargin = (int) POINT_MARGIN.convertToPixels();
int pointSize = getClosestOdd(POINT_SIZE.convertToPixels());
int lipHoleSize = getClosestOdd(LIP_HOLE_SIZE.convertToPixels());
int poleSize = (int) getType().getPoleSize().convertToPixels();
int poleSpacing = (int) POLE_SPACING.convertToPixels();
@@ -279,9 +276,6 @@ public class HumbuckerPickup extends AbstractGuitarPickup {
body[1] = legArea;
}
// contact point
body[2] = new Area(new Ellipse2D.Double(x - pointSize / 2, y - pointSize / 2, pointSize, pointSize));
Area poleArea = new Area();
Area poleDecorationArea = new Area();
@@ -70,7 +70,6 @@ public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup {
private static Size LIP_HOLE_SPACING = new Size(0.1d, SizeUnit.in);
private static Size POINT_MARGIN = new Size(1.5d, SizeUnit.mm);
private static Size POINT_SIZE = new Size(2d, SizeUnit.mm);
private static Size POLE_SIZE = new Size(4d, SizeUnit.mm);
private static Size POLE_SPACING = new Size(0.85d, SizeUnit.in);
private static Size POLE_SPACING_MINOR = new Size(0.28d, SizeUnit.in);
@@ -95,7 +94,9 @@ public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup {
g2d.fill(body[1]);
drawingObserver.stopTracking();
g2d.setComposite(oldComposite);
markContactPoints(g2d, drawingObserver);
Color finalBorderColor;
if (outlineMode) {
Theme theme =
@@ -157,7 +158,6 @@ public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup {
int pointMargin = (int) POINT_MARGIN.convertToPixels();
int lipRadius = (int) LIP_RADIUS.convertToPixels();
int lipSpacing = (int) LIP_SPACING.convertToPixels();
int pointSize = getClosestOdd(POINT_SIZE.convertToPixels());
int lipHoleSize = getClosestOdd(LIP_HOLE_SIZE.convertToPixels());
int lipHoleSpacing = getClosestOdd(LIP_HOLE_SPACING.convertToPixels());
@@ -180,8 +180,6 @@ public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup {
((Area)body[1]).subtract((Area)body[0]);
body[2] = new Area(new Ellipse2D.Double(x - pointSize / 2, y - pointSize / 2, pointSize, pointSize));
int poleSize = (int) POLE_SIZE.convertToPixels();
int poleSpacing = (int) POLE_SPACING.convertToPixels();
int poleSpacingMinor = (int) POLE_SPACING_MINOR.convertToPixels();
@@ -75,7 +75,6 @@ public class P90Pickup extends AbstractSingleOrHumbuckerPickup {
private static Size LIP_RADIUS = new Size(10d, SizeUnit.mm);
private static Size POINT_MARGIN = new Size(3.5d, SizeUnit.mm);
private static Size POINT_SIZE = new Size(2d, SizeUnit.mm);
private static Size LIP_HOLE_SIZE = new Size(2.5d, SizeUnit.mm);
private static Size LIP_HOLE_SPACING = new Size(97d, SizeUnit.mm);
private static Size POLE_SIZE = new Size(4d, SizeUnit.mm);
@@ -127,7 +126,9 @@ public class P90Pickup extends AbstractSingleOrHumbuckerPickup {
g2d.draw(body[0]);
if (body[1] != null)
g2d.draw(body[1]);
markContactPoints(g2d, drawingObserver);
if (!outlineMode) {
g2d.setColor(getPoleColor());
g2d.fill(body[3]);
@@ -205,7 +206,6 @@ public class P90Pickup extends AbstractSingleOrHumbuckerPickup {
int pointMargin = (int) POINT_MARGIN.convertToPixels();
int totalLength = (int) TOTAL_LENGTH.convertToPixels();
int lipRadius = (int) LIP_RADIUS.convertToPixels();
int pointSize = getClosestOdd(POINT_SIZE.convertToPixels());
int lipHoleSize = getClosestOdd(LIP_HOLE_SIZE.convertToPixels());
int lipHoleSpacing = getClosestOdd(LIP_HOLE_SPACING.convertToPixels());
@@ -237,8 +237,6 @@ public class P90Pickup extends AbstractSingleOrHumbuckerPickup {
body[1] = lipArea;
}
body[2] = new Area(new Ellipse2D.Double(x - pointSize / 2, y - pointSize / 2, pointSize, pointSize));
int poleSize = (int) POLE_SIZE.convertToPixels();
int poleSpacing = (int) POLE_SPACING.convertToPixels();
int poleMargin = (length - poleSpacing * 5) / 2;
@@ -69,7 +69,6 @@ public class PBassPickup extends AbstractSingleOrHumbuckerPickup {
private static Size LIP_HOLE_SPACING = new Size(0.1d, SizeUnit.in);
private static Size POINT_MARGIN = new Size(1.5d, SizeUnit.mm);
private static Size POINT_SIZE = new Size(2d, SizeUnit.mm);
private static Size POLE_SIZE = new Size(4d, SizeUnit.mm);
private static Size POLE_SPACING = new Size(0.38d, SizeUnit.in);
@@ -93,6 +92,8 @@ public class PBassPickup extends AbstractSingleOrHumbuckerPickup {
drawingObserver.stopTracking();
g2d.setComposite(oldComposite);
markContactPoints(g2d, drawingObserver);
Color finalBorderColor;
if (outlineMode) {
Theme theme =
@@ -153,7 +154,6 @@ public class PBassPickup extends AbstractSingleOrHumbuckerPickup {
int edgeRadius = (int) EDGE_RADIUS.convertToPixels();
int pointMargin = (int) POINT_MARGIN.convertToPixels();
int lipRadius = (int) LIP_RADIUS.convertToPixels();
int pointSize = getClosestOdd(POINT_SIZE.convertToPixels());
int lipHoleSize = getClosestOdd(LIP_HOLE_SIZE.convertToPixels());
int lipHoleSpacing = getClosestOdd(LIP_HOLE_SPACING.convertToPixels());
@@ -174,8 +174,6 @@ public class PBassPickup extends AbstractSingleOrHumbuckerPickup {
((Area)body[1]).subtract((Area)body[0]);
body[2] = new Area(new Ellipse2D.Double(x - pointSize / 2, y - pointSize / 2, pointSize, pointSize));
int poleSize = (int) POLE_SIZE.convertToPixels();
int poleSpacing = (int) POLE_SPACING.convertToPixels();
int poleMargin = (length - poleSpacing * 3) / 2;
@@ -126,7 +126,9 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup {
g2d.fill(body[3]);
drawingObserver.stopTracking();
markContactPoints(g2d, drawingObserver);
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getLugColor());
g2d.fill(body[1]);
g2d.setColor(outlineMode ? theme.getOutlineColor() : darkerOrLighter(LUG_COLOR));
@@ -21,28 +21,13 @@
*/
package org.diylc.components.guitar;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.RoundRectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
import org.diylc.components.transform.GuitarPickupTransformer;
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.*;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
@@ -50,55 +35,59 @@ import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
import java.awt.*;
import java.awt.geom.*;
@ComponentDescriptor(name = "Stingray Bass Pickup", category = "Guitar", author = "JD",
description = "Humbucker Bass Pickup for Musicman Stingray and similar guitars",
description = "Humbucker Bass Pickup for Musicman Stingray and similar guitars",
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true,
transformer = GuitarPickupTransformer.class)
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram",
enableCache = true, transformer = GuitarPickupTransformer.class)
/**
* Component type for Stingray Bass Humbucker
* Modified from the P Bass Pickup. Author: JD
* @author JD
*/
public class StingrayBassPickup extends AbstractGuitarPickup {
*/ public class StingrayBassPickup extends AbstractGuitarPickup {
private static final long serialVersionUID = 1L;
private static Color BODY_COLOR = Color.decode("#333333");
private static Size WIDTH = new Size(1.910, SizeUnit.in);
private static Size LENGTH = new Size(3.505, SizeUnit.in);
private static Size EDGE_RADIUS = new Size(0.08d, SizeUnit.in);
private static Size LIP_RADIUS = new Size(0.4d, SizeUnit.in);
private static Size LIP_HOLE_SIZE = new Size(0.1d, SizeUnit.in);
private static Size LIP_HOLE_SPACING = new Size(0.05d, SizeUnit.in);
private static Size LIP_DISTANCE_VERTICAL = new Size(0.935d, SizeUnit.in);// Left side vertical between mount points
private static Size LIP_DISTANCE_VERTICAL = new Size(0.935d, SizeUnit.in);
// Left side vertical between mount points
// private static Size LIP_DISTANCE_HORIZONTAL = new Size(3.7000d, SizeUnit.in); // Distance across pickup
private static Size POINT_MARGIN = new Size(1.5d, SizeUnit.mm);
private static Size POINT_SIZE = new Size(2d, SizeUnit.mm);
private static Size POLE_SIZE = new Size(.39d, SizeUnit.in);
private static Size POLE_SPACING_HORIZONTAL = new Size(0.75366d, SizeUnit.in); // Distance Between poles
private static Size POLE_SPACING_TO_EDGE= new Size(0.4875d, SizeUnit.in);// Outer edge to centre of nearest pole
// (Perpendicular of course!)
private static Size POLE_SPACING_HORIZONTAL = new Size(0.75366d, SizeUnit.in);
// Distance Between poles
private static Size POLE_SPACING_TO_EDGE = new Size(0.4875d, SizeUnit.in);
// Outer edge to centre of nearest pole
// (Perpendicular of course!)
private Color color = BODY_COLOR;
private Color poleColor = METAL_COLOR;
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
Project project, IDrawingObserver drawingObserver) {
Shape[] body = getBody();
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : color);
g2d.fill(body[0]);
g2d.fill(body[1]);
@@ -107,21 +96,25 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
Color finalBorderColor;
if (outlineMode) {
Theme theme =
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
Theme theme = (Theme) ConfigurationManager.getInstance()
.readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: theme.getOutlineColor();
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ?
SELECTION_COLOR :
theme.getOutlineColor();
} else {
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: color.darker();
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ?
SELECTION_COLOR :
color.darker();
}
g2d.setColor(finalBorderColor);
g2d.draw(body[0]);
g2d.draw(body[1]);
markContactPoints(g2d, drawingObserver);
if (!outlineMode) {
g2d.setColor(getPoleColor());
g2d.fill(body[3]);
@@ -129,26 +122,8 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
g2d.draw(body[3]);
}
// Color finalLabelColor;
// if (outlineMode) {
// Theme theme =
// (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
// finalLabelColor =
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
// : theme.getOutlineColor();
// } else {
// finalLabelColor =
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
// : LABEL_COLOR;
// }
// g2d.setColor(finalLabelColor);
// g2d.setFont(project.getFont());
// Rectangle bounds = body[0].getBounds();
// drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
// VerticalAlignment.CENTER);
drawMainLabel(g2d, project, outlineMode, componentState);
drawTerminalLabels(g2d, finalBorderColor, project);
}
@@ -159,72 +134,76 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
body = new Shape[4];
Point2D[] points = getControlPoints();
double x = points[0].getX();
double y = points[0].getY();
int width = (int) WIDTH.convertToPixels();
int length = (int) LENGTH.convertToPixels();
int edgeRadius = (int) EDGE_RADIUS.convertToPixels();
int pointMargin = (int) POINT_MARGIN.convertToPixels();
int lipRadius = (int) LIP_RADIUS.convertToPixels();
int pointSize = getClosestOdd(POINT_SIZE.convertToPixels());
int lipHoleSize = (int) LIP_HOLE_SIZE.convertToPixels();
double x = points[0].getX();
double y = points[0].getY();
int width = (int) WIDTH.convertToPixels();
int length = (int) LENGTH.convertToPixels();
int edgeRadius = (int) EDGE_RADIUS.convertToPixels();
int pointMargin = (int) POINT_MARGIN.convertToPixels();
int lipRadius = (int) LIP_RADIUS.convertToPixels();
int lipHoleSize = (int) LIP_HOLE_SIZE.convertToPixels();
int lipHoleSpacing = getClosestOdd(LIP_HOLE_SPACING.convertToPixels());
int lipDistanceV = (int) LIP_DISTANCE_VERTICAL.convertToPixels();
int lipDistanceV = (int) LIP_DISTANCE_VERTICAL.convertToPixels();
// This is the main body
body[0] =
new Area(new RoundRectangle2D.Double(x - length, y - pointMargin, length, width, edgeRadius,
body[0] = new Area(
new RoundRectangle2D.Double(x - length, y - pointMargin, length, width, edgeRadius,
edgeRadius));
// Lips around pickup - change transforms
Area lip = new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
lip.subtract(new Area(new Ellipse2D.Double(-lipRadius / 2 + lipHoleSpacing, -lipRadius / 4 + lipHoleSize / 2, lipHoleSize, lipHoleSize)));
lip.transform(AffineTransform.getTranslateInstance(x - length, y - pointMargin + (width - lipDistanceV) / 2));
Area lip2 = new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
Area lip =
new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
lip.subtract(new Area(
new Ellipse2D.Double(-lipRadius / 2 + lipHoleSpacing, -lipRadius / 4 + lipHoleSize / 2,
lipHoleSize, lipHoleSize)));
lip.transform(AffineTransform.getTranslateInstance(x - length,
y - pointMargin + (width - lipDistanceV) / 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(lipRadius / 2 - lipHoleSize - lipHoleSpacing, -lipRadius / 4 + lipHoleSize / 2, lipHoleSize, lipHoleSize)));
lip2.subtract(new Area(new Ellipse2D.Double(lipRadius / 2 - lipHoleSize - lipHoleSpacing,
-lipRadius / 4 + lipHoleSize / 2, lipHoleSize, lipHoleSize)));
lip2.transform(AffineTransform.getTranslateInstance(x, y - pointMargin + width / 2));
lip.add(lip2);
Area lip3 = new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
lip3.subtract(new Area(new Ellipse2D.Double(-lipRadius / 2 + lipHoleSpacing, -lipRadius / 4 + lipHoleSize / 2, lipHoleSize, lipHoleSize)));
lip3.transform(AffineTransform.getTranslateInstance(x - length, (y - pointMargin) + (width - ((width - lipDistanceV) / 2))));
Area lip3 =
new Area(new Ellipse2D.Double(-lipRadius / 2, -lipRadius / 2, lipRadius, lipRadius));
lip3.subtract(new Area(
new Ellipse2D.Double(-lipRadius / 2 + lipHoleSpacing, -lipRadius / 4 + lipHoleSize / 2,
lipHoleSize, lipHoleSize)));
lip3.transform(AffineTransform.getTranslateInstance(x - length,
(y - pointMargin) + (width - ((width - lipDistanceV) / 2))));
lip.add(lip3);
body[1] = new Area(lip);
// Merge
((Area)body[1]).subtract((Area)body[0]);
// ??? - Perhaps Overall Area - it's never filled in draw()
body[2] = new Area(new Ellipse2D.Double(x - pointSize / 2, y - pointSize / 2, pointSize, pointSize));
((Area) body[1]).subtract((Area) body[0]);
// Poles
int poleSize = (int) POLE_SIZE.convertToPixels();
int poleSpacing = (int) POLE_SPACING_HORIZONTAL.convertToPixels();
int poleSize = (int) POLE_SIZE.convertToPixels();
int poleSpacing = (int) POLE_SPACING_HORIZONTAL.convertToPixels();
int poleSpacingEdge = (int) POLE_SPACING_TO_EDGE.convertToPixels();
int poleMargin = (length - poleSpacing * 3) / 2; // Edge to centre of outer poles
int poleMargin = (length - poleSpacing * 3) / 2; // Edge to centre of outer poles
Area poleArea = new Area();
for (int i = 0; i < 4; i++) {
// Top Row
Ellipse2D pole =
new Ellipse2D.Double(x - length + poleMargin + i * poleSpacing - poleSize / 2,
y + poleSpacingEdge - pointMargin - poleSize / 2 ,
poleSize, poleSize);
new Ellipse2D.Double(x - length + poleMargin + i * poleSpacing - poleSize / 2,
y + poleSpacingEdge - pointMargin - poleSize / 2, poleSize, poleSize);
// Bottom Row
Ellipse2D pole2 =
new Ellipse2D.Double(x - length + poleMargin + i * poleSpacing - poleSize / 2,
Ellipse2D pole2 =
new Ellipse2D.Double(x - length + poleMargin + i * poleSpacing - poleSize / 2,
y - pointMargin - poleSize / 2 + (width - poleSpacingEdge), poleSize, poleSize);
poleArea.add(new Area(pole));
poleArea.add(new Area(pole2));
}
body[3] = poleArea;
// Rotate if needed
if (orientation != Orientation.DEFAULT) {
// Set variables depending on required transform
@@ -251,7 +230,7 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
} // end the if (body == null)
return body;
}
@Override
protected int getMainLabelYOffset() {
return (int) (WIDTH.convertToPixels() / 2 - 20);
@@ -263,23 +242,28 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
int bodyWidth = (int) (14f * width / 32);
int bodyLength = (int) (26f * width / 32);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
g2d.setColor(BODY_COLOR);
g2d.fillRoundRect((width - bodyWidth) / 2, (height - bodyLength) / 2, bodyWidth, bodyLength, 3, 3);
g2d.fillRoundRect((width - bodyWidth) / 2, (height - bodyLength) / 2, bodyWidth, bodyLength, 3,
3);
// Very neat solution, doesn't work for this :(
// Could potentially make them shorter so they don't poke out both ends and then do three of them?
int lipSize = (int) (4f * width / 32);
// g2d.fillRoundRect((width - lipSize) / 2, (height - bodyLength) / 2 - lipSize + 1, lipSize, bodyLength + 2 * lipSize - 2, lipSize, lipSize);
g2d.fillRoundRect((width - lipSize) / 2, (height - bodyLength) / 2 - lipSize + 1, lipSize, lipSize, lipSize, lipSize); // Right, center
g2d.fillRoundRect(9 * width / 32, bodyLength + ((height - bodyLength) / 2), lipSize, lipSize, lipSize, lipSize);
g2d.fillRoundRect(18 * width / 32, bodyLength + ((height - bodyLength) / 2), lipSize, lipSize, lipSize, lipSize);
g2d.fillRoundRect((width - lipSize) / 2, (height - bodyLength) / 2 - lipSize + 1, lipSize,
lipSize, lipSize, lipSize); // Right, center
g2d.fillRoundRect(9 * width / 32, bodyLength + ((height - bodyLength) / 2), lipSize, lipSize,
lipSize, lipSize);
g2d.fillRoundRect(18 * width / 32, bodyLength + ((height - bodyLength) / 2), lipSize, lipSize,
lipSize, lipSize);
//g2d.fillRoundRect((width - lipSize) / 2, 12 * width / 32, lipSize, lipSize,lipSize,lipSize);
//g2d.fillRoundRect((width - lipSize) / 2, 20 * width / 32, lipSize, lipSize,lipSize,lipSize);
g2d.setColor(BODY_COLOR.darker());
g2d.drawRoundRect((width - bodyWidth) / 2, (height - bodyLength) / 2, bodyWidth, bodyLength, 3, 3);
g2d.drawRoundRect((width - bodyWidth) / 2, (height - bodyLength) / 2, bodyWidth, bodyLength, 3,
3);
// g2d.setColor(Color.gray);
// g2d.drawLine(width / 2, 4 * width / 32, width / 2, 4 * width / 32);
@@ -290,15 +274,17 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
int poleSpacing = (int) (6d * width / 32);
for (int i = 0; i < 4; i++) {
// Top Row
g2d.fillOval(11 * width / 32, 5 * width / 32 + i * poleSpacing, poleSize * width / 32, poleSize * width / 32);
g2d.fillOval(11 * width / 32, 5 * width / 32 + i * poleSpacing, poleSize * width / 32,
poleSize * width / 32);
//g2d.fillOval((width - poleSize) / 2, (height - poleSpacing) / 2 + (i * poleSpacing / 3), poleSize, poleSize);
// Bottom Row
g2d.fillOval(17 * width / 32, 5 * width / 32 + i * poleSpacing, poleSize * width / 32, poleSize * width / 32);
g2d.fillOval(17 * width / 32, 5 * width / 32 + i * poleSpacing, poleSize * width / 32,
poleSize * width / 32);
}
}
@Override
protected OrientationHV getControlPointDirection() {
protected OrientationHV getControlPointDirection() {
return OrientationHV.VERTICAL;
}
@@ -310,7 +296,7 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
public void setColor(Color color) {
this.color = color;
}
@EditableProperty(name = "Pole Color")
public Color getPoleColor() {
if (poleColor == null)
@@ -321,7 +307,7 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
public void setPoleColor(Color poleColor) {
this.poleColor = poleColor;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
@@ -331,7 +317,7 @@ public class StingrayBassPickup extends AbstractGuitarPickup {
public boolean isHumbucker() {
return true;
}
@Override
public Polarity getPolarity() {
// just to disable editor