mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Ability to rotate all guitar/bass pickups through the 'Transform Selection' feature or keyboard shortcut
This commit is contained in:
@@ -4009,7 +4009,11 @@
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'DP4T (6-Position Oak Grigsby)' as a new type of Lever Switch component</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Ability to rotate all guitar/bass pickups through the 'Transform Selection' feature or keyboard shortcut</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
|
||||
Binary file not shown.
@@ -200,7 +200,7 @@ public abstract class AbstractGuitarPickup extends AbstractLabeledComponent<Stri
|
||||
return false;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@EditableProperty(name = "Coil(s)")
|
||||
public Polarity getPolarity() {
|
||||
if (polarity == null)
|
||||
polarity = Polarity.North;
|
||||
@@ -280,6 +280,17 @@ public abstract class AbstractGuitarPickup extends AbstractLabeledComponent<Stri
|
||||
}
|
||||
|
||||
public enum Polarity {
|
||||
North, South, Humbucking;
|
||||
North("Single - North"), South("Single - South"), Humbucking("Humbucking - 4 leads");
|
||||
|
||||
private String label;
|
||||
|
||||
private Polarity(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -114,20 +114,20 @@ public abstract class AbstractSingleOrHumbuckerPickup extends AbstractGuitarPick
|
||||
switch (getPolarity()) {
|
||||
case Humbucking:
|
||||
if (index1 == 0 && index2 == 1)
|
||||
return Polarity.North.toString() + "->";
|
||||
return Polarity.North.name() + "->";
|
||||
else if (index1 == 1 && index2 == 0)
|
||||
return Polarity.North.toString() + "<-";
|
||||
return Polarity.North.name() + "<-";
|
||||
else if (index1 == 2 && index2 == 3)
|
||||
return Polarity.South.toString() + "->";
|
||||
return Polarity.South.name() + "->";
|
||||
else if (index1 == 3 && index2 == 2)
|
||||
return Polarity.South.toString() + "<-";
|
||||
return Polarity.South.name() + "<-";
|
||||
break;
|
||||
case North:
|
||||
case South:
|
||||
if (index1 == 1 && index2 == 2)
|
||||
return getPolarity().toString() + "->";
|
||||
return getPolarity().name() + "->";
|
||||
else if (index1 == 2 && index2 == 1)
|
||||
return getPolarity().toString() + "<-";
|
||||
return getPolarity().name() + "<-";
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -35,6 +35,7 @@ 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;
|
||||
@@ -50,7 +51,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Humbucker Pickup", category = "Guitar", author = "Branislav Stojkovic",
|
||||
description = "Double-coil humbucker guitar pickup (PAF, Mini Humbuckers, Filtertrons)",
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true)
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true,
|
||||
transformer = GuitarPickupTransformer.class)
|
||||
public class HumbuckerPickup extends AbstractGuitarPickup {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -36,6 +36,7 @@ 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;
|
||||
@@ -51,7 +52,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Jazz Bass Pickup", category = "Guitar", author = "Branislav Stojkovic",
|
||||
description = "Single coil pickup for Jazz Bass and similar guitars",
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true)
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true,
|
||||
transformer = GuitarPickupTransformer.class)
|
||||
public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -36,6 +36,7 @@ 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;
|
||||
@@ -51,7 +52,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "P- Bass Pickup", category = "Guitar", author = "Branislav Stojkovic",
|
||||
description = "Split-coil pickup for P-Bass and similar guitars",
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true)
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true,
|
||||
transformer = GuitarPickupTransformer.class)
|
||||
public class PBassPickup extends AbstractSingleOrHumbuckerPickup {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.components.RoundedPath;
|
||||
import org.diylc.components.transform.GuitarPickupTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -53,7 +54,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Single Coil Pickup", category = "Guitar", author = "Branislav Stojkovic",
|
||||
description = "Single coil guitar pickup, both Strat and Tele style",
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true)
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true,
|
||||
transformer = GuitarPickupTransformer.class)
|
||||
public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -438,7 +440,7 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup {
|
||||
}
|
||||
|
||||
public enum PolePieceType {
|
||||
Rods("Single Rods"), Rail("Single Rail"), RailHumbucker("Dual Rail Humbucker"), RodHumbucker("Dual Rods"), None("None");
|
||||
Rods("Single Rods"), Rail("Single Rail"), RodHumbucker("Double Rods"), RailHumbucker("Double Rails"), None("None");
|
||||
|
||||
private String label;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ 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;
|
||||
@@ -51,7 +52,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Stingray Bass Pickup", category = "Guitar", author = "JD",
|
||||
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)
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram", enableCache = true,
|
||||
transformer = GuitarPickupTransformer.class)
|
||||
|
||||
/**
|
||||
* Component type for Stingray Bass Humbucker
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
|
||||
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.transform;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.guitar.AbstractGuitarPickup;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class GuitarPickupTransformer implements IComponentTransformer {
|
||||
|
||||
@Override
|
||||
public boolean canRotate(IDIYComponent<?> component) {
|
||||
return AbstractGuitarPickup.class.isAssignableFrom(component.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMirror(IDIYComponent<?> component) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirroringChangesCircuit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
|
||||
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.getX(), center.getY());
|
||||
for (int index = 0; index < component.getControlPointCount(); index++) {
|
||||
Point2D p = new Point2D.Double();
|
||||
rotate.transform(component.getControlPoint(index), p);
|
||||
component.setControlPoint(p, index);
|
||||
}
|
||||
|
||||
AbstractGuitarPickup pickup = (AbstractGuitarPickup) component;
|
||||
Orientation o = pickup.getOrientation();
|
||||
int oValue = o.ordinal();
|
||||
oValue += direction;
|
||||
if (oValue < 0)
|
||||
oValue = Orientation.values().length - 1;
|
||||
if (oValue >= Orientation.values().length)
|
||||
oValue = 0;
|
||||
o = Orientation.values()[oValue];
|
||||
pickup.setOrientation(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mirror(IDIYComponent<?> component, Point2D center, int direction) {
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user