mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
graph improvmeents
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.diylc.common;
|
package org.diylc.common;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.diylc.graph.Graph;
|
import org.diylc.graph.Graph;
|
||||||
@@ -28,5 +29,5 @@ import org.diylc.graph.GraphKey;
|
|||||||
|
|
||||||
public interface IGraphProcessor {
|
public interface IGraphProcessor {
|
||||||
|
|
||||||
Map<GraphKey, Graph> extractGraphs();
|
Map<Graph, List<GraphKey>> extractGraphs();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,6 +283,6 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getControlPointNodeName(int index) {
|
public String getControlPointNodeName(int index) {
|
||||||
return getName() + "." + index;
|
return Integer.toString(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,36 @@ public class Graph {
|
|||||||
return this.vertices.equals(other.vertices);
|
return this.vertices.equals(other.vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((vertices == null) ? 0 : vertices.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Graph other = (Graph) obj;
|
||||||
|
if (vertices == null) {
|
||||||
|
if (other.vertices != null)
|
||||||
|
return false;
|
||||||
|
} else if (!vertices.equals(other.vertices))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (Vertex v : vertices) {
|
for (Vertex v : vertices) {
|
||||||
sb.append("\t").append(v.getNode1()).append(" - ").append(v.getNode2()).append("\n");
|
sb.append("\t").append(v).append("\n");
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,6 @@ public class Node {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return component.getName() + "." + pointIndex + " @ (" + component.getControlPoint(pointIndex).getX() + ":" + component.getControlPoint(pointIndex).getY() + ")";
|
return component.getName() + "." + component.getControlPointNodeName(pointIndex) /*+ " @ (" + component.getControlPoint(pointIndex).getX() + ":" + component.getControlPoint(pointIndex).getY() + ")"*/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,34 @@
|
|||||||
package org.diylc.graph;
|
package org.diylc.graph;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class Vertex {
|
public class Vertex {
|
||||||
|
|
||||||
private Node node1;
|
private Set<Node> nodes = new HashSet<Node>();
|
||||||
private Node node2;
|
|
||||||
|
|
||||||
public Vertex(Node node1, Node node2) {
|
public Vertex(Node node1, Node node2) {
|
||||||
this.node1 = node1;
|
nodes.add(node1);
|
||||||
this.node2 = node2;
|
nodes.add(node2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node getNode1() {
|
public Node getNode1() {
|
||||||
return node1;
|
Iterator<Node> i = nodes.iterator();
|
||||||
|
return i.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node getNode2() {
|
public Node getNode2() {
|
||||||
return node2;
|
Iterator<Node> i = nodes.iterator();
|
||||||
|
i.next();
|
||||||
|
return i.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((node1 == null) ? 0 : node1.hashCode());
|
result = prime * result + ((nodes == null) ? 0 : nodes.hashCode());
|
||||||
result = prime * result + ((node2 == null) ? 0 : node2.hashCode());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,21 +41,16 @@ public class Vertex {
|
|||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
Vertex other = (Vertex) obj;
|
Vertex other = (Vertex) obj;
|
||||||
if (node1 == null) {
|
if (nodes == null) {
|
||||||
if (other.node1 != null)
|
if (other.nodes != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!node1.equals(other.node1))
|
} else if (!nodes.equals(other.nodes))
|
||||||
return false;
|
|
||||||
if (node2 == null) {
|
|
||||||
if (other.node2 != null)
|
|
||||||
return false;
|
|
||||||
} else if (!node2.equals(other.node2))
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return node1.toString() + " -> " + node2.toString();
|
return getNode1().toString() + " <-> " + getNode2().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2687,8 +2687,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Map<GraphKey, Graph> extractGraphs() {
|
public Map<Graph, List<GraphKey>> extractGraphs() {
|
||||||
Map<GraphKey, Graph> result = new HashMap<GraphKey, Graph>();
|
Map<Graph, List<GraphKey>> result = new HashMap<Graph, List<GraphKey>>();
|
||||||
List<Node> nodes = new ArrayList<Node>();
|
List<Node> nodes = new ArrayList<Node>();
|
||||||
|
|
||||||
List<ISwitch> switches = new ArrayList<ISwitch>();
|
List<ISwitch> switches = new ArrayList<ISwitch>();
|
||||||
@@ -2753,7 +2753,15 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
List<Line2D> connections = getConnections(switchPositions);
|
List<Line2D> connections = getConnections(switchPositions);
|
||||||
Graph graph = constructGraph(nodes, connections, continuity);
|
Graph graph = constructGraph(nodes, connections, continuity);
|
||||||
result.put(new GraphKey(posList), graph);
|
|
||||||
|
// merge graphs that are effectivelly the same
|
||||||
|
if (result.containsKey(graph)) {
|
||||||
|
result.get(graph).add(new GraphKey(posList));
|
||||||
|
} else {
|
||||||
|
List<GraphKey> list = new ArrayList<GraphKey>();
|
||||||
|
list.add(new GraphKey(posList));
|
||||||
|
result.put(graph, list);
|
||||||
|
}
|
||||||
|
|
||||||
// find the next combination if possible
|
// find the next combination if possible
|
||||||
if (positions[i] < switches.get(i).getPositionCount() - 1) {
|
if (positions[i] < switches.get(i).getPositionCount() - 1) {
|
||||||
|
|||||||
Binary file not shown.
@@ -1,23 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
|
*
|
||||||
DIY Layout Creator (DIYLC).
|
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
*
|
||||||
|
* This file is part of DIYLC.
|
||||||
This file is part of DIYLC.
|
*
|
||||||
|
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||||
DIYLC is free software: you can redistribute it and/or modify
|
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||||
it under the terms of the GNU General Public License as published by
|
* License, or (at your option) any later version.
|
||||||
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
|
||||||
DIYLC is distributed in the hope that it will be useful,
|
* Public License for more details.
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
*
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||||
GNU General Public License for more details.
|
* <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
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;
|
package org.diylc.components.guitar;
|
||||||
|
|
||||||
@@ -57,9 +53,9 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Humbucker Pickup", category = "Guitar", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "Humbucker Pickup", category = "Guitar", author = "Branislav Stojkovic",
|
||||||
description = "Double-coil humbucker guitar pickup (PAF, Mini Humbuckers, Filtertrons)", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
description = "Double-coil humbucker guitar pickup (PAF, Mini Humbuckers, Filtertrons)", stretchable = false,
|
||||||
instanceNamePrefix = "PKP", autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG,
|
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PKP", autoEdit = false,
|
||||||
keywordTag = "Guitar Wiring Diagram")
|
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Guitar Wiring Diagram")
|
||||||
public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -67,7 +63,7 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
private static Color BASE_COLOR = Color.lightGray;
|
private static Color BASE_COLOR = Color.lightGray;
|
||||||
private static Color BOBIN_COLOR1 = Color.decode("#EAE3C6");
|
private static Color BOBIN_COLOR1 = Color.decode("#EAE3C6");
|
||||||
private static Color BOBIN_COLOR2 = Color.black;
|
private static Color BOBIN_COLOR2 = Color.black;
|
||||||
private static Color POINT_COLOR = Color.darkGray;
|
// private static Color POINT_COLOR = Color.darkGray;
|
||||||
private static Size WIDTH = new Size(36.5d, SizeUnit.mm);
|
private static Size WIDTH = new Size(36.5d, SizeUnit.mm);
|
||||||
private static Size LENGTH = new Size(68.58d, SizeUnit.mm);
|
private static Size LENGTH = new Size(68.58d, SizeUnit.mm);
|
||||||
private static Size WIDTH_MINI = new Size(29.3d, SizeUnit.mm);
|
private static Size WIDTH_MINI = new Size(29.3d, SizeUnit.mm);
|
||||||
@@ -79,6 +75,7 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
private static Size LIP_LENGTH = new Size(7.9d, SizeUnit.mm);
|
private static Size LIP_LENGTH = new Size(7.9d, SizeUnit.mm);
|
||||||
private static Size EDGE_RADIUS = new Size(4d, 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_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 SCREW_LINE = new Size(1d, SizeUnit.mm);
|
||||||
private static Size POINT_SIZE = new Size(2d, 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 LIP_HOLE_SIZE = new Size(2d, SizeUnit.mm);
|
||||||
@@ -100,6 +97,12 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
private PolePieceType coilType1;
|
private PolePieceType coilType1;
|
||||||
private PolePieceType coilType2;
|
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
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
@@ -133,8 +136,8 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
g2d.fill(body[0]);
|
g2d.fill(body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
|
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
|
||||||
g2d.fill(body[2]);
|
// g2d.fill(body[2]);
|
||||||
|
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
|
|
||||||
@@ -202,13 +205,53 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
VerticalAlignment.CENTER);
|
VerticalAlignment.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
public Shape[] getBody() {
|
public Shape[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[7];
|
body = new Shape[7];
|
||||||
|
|
||||||
int x = controlPoint.x;
|
Point[] points = getControlPoints();
|
||||||
int y = controlPoint.y;
|
int x = points[0].x;
|
||||||
|
int y = points[0].y;
|
||||||
int width = (int) getType().getWidth().convertToPixels();
|
int width = (int) getType().getWidth().convertToPixels();
|
||||||
int length = (int) getType().getLength().convertToPixels();
|
int length = (int) getType().getLength().convertToPixels();
|
||||||
int lipWidth = (int) LIP_WIDTH.convertToPixels();
|
int lipWidth = (int) LIP_WIDTH.convertToPixels();
|
||||||
@@ -223,8 +266,9 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
int coilMargin = (width - coilSpacing) / 2;
|
int coilMargin = (width - coilSpacing) / 2;
|
||||||
int poleMargin = (length - poleSpacing * 5) / 2;
|
int poleMargin = (length - poleSpacing * 5) / 2;
|
||||||
|
|
||||||
Area base = new Area(new RoundRectangle2D.Double(x + pointMargin - length, y - pointMargin, length, width, edgeRadius,
|
Area base =
|
||||||
edgeRadius));
|
new Area(new RoundRectangle2D.Double(x /* + pointMargin */- length, y - pointMargin, length, width,
|
||||||
|
edgeRadius, edgeRadius));
|
||||||
|
|
||||||
// base or cover
|
// base or cover
|
||||||
body[0] = new Area(base);
|
body[0] = new Area(base);
|
||||||
@@ -232,22 +276,29 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
int cutoutMargin = (int) FILTETRON_CUTOUT_MARGIN.convertToPixels();
|
int cutoutMargin = (int) FILTETRON_CUTOUT_MARGIN.convertToPixels();
|
||||||
int cutoutHeight = poleSize + 2 * cutoutMargin;
|
int cutoutHeight = poleSize + 2 * cutoutMargin;
|
||||||
int cutoutWidth = 5 * poleSpacing + poleSize + 2 * cutoutMargin;
|
int cutoutWidth = 5 * poleSpacing + poleSize + 2 * cutoutMargin;
|
||||||
Area cutout = new Area(new RoundRectangle2D.Double(x + pointMargin - length + poleMargin - poleSize / 2 - cutoutMargin, y
|
Area cutout =
|
||||||
- pointMargin + coilMargin - poleSize / 2 - cutoutMargin, cutoutWidth, cutoutHeight, cutoutHeight, cutoutHeight));
|
new Area(new RoundRectangle2D.Double(x /* + pointMargin */- length + poleMargin - poleSize / 2
|
||||||
|
- cutoutMargin, y - pointMargin + coilMargin - poleSize / 2 - cutoutMargin, cutoutWidth, cutoutHeight,
|
||||||
|
cutoutHeight, cutoutHeight));
|
||||||
((Area) body[0]).subtract(cutout);
|
((Area) body[0]).subtract(cutout);
|
||||||
cutout = new Area(new RoundRectangle2D.Double(x + pointMargin - length + poleMargin - poleSize / 2 - cutoutMargin, y
|
cutout =
|
||||||
- pointMargin + width - coilMargin - poleSize / 2 - cutoutMargin, cutoutWidth, cutoutHeight, cutoutHeight, cutoutHeight));
|
new Area(new RoundRectangle2D.Double(x /* + pointMargin */- length + poleMargin - poleSize / 2
|
||||||
|
- cutoutMargin, y - pointMargin + width - coilMargin - poleSize / 2 - cutoutMargin, cutoutWidth,
|
||||||
|
cutoutHeight, cutoutHeight, cutoutHeight));
|
||||||
((Area) body[0]).subtract(cutout);
|
((Area) body[0]).subtract(cutout);
|
||||||
int middleCutoutWidth = poleSpacing / 5;
|
int middleCutoutWidth = poleSpacing / 5;
|
||||||
cutout = new Area(new Rectangle2D.Double(x + pointMargin - length / 2 - middleCutoutWidth / 2, y
|
cutout =
|
||||||
- pointMargin + width / 4, middleCutoutWidth, width / 2));
|
new Area(new Rectangle2D.Double(x /* + pointMargin */- length / 2 - middleCutoutWidth / 2, y - pointMargin
|
||||||
|
+ width / 4, middleCutoutWidth, width / 2));
|
||||||
((Area) body[0]).subtract(cutout);
|
((Area) body[0]).subtract(cutout);
|
||||||
if (!getLegs()) {
|
if (!getLegs()) {
|
||||||
cutout = new Area(new Ellipse2D.Double(x + pointMargin - length + lipHoleSize * 2, y
|
cutout =
|
||||||
- pointMargin + width / 2 - lipHoleSize * 0.75, lipHoleSize * 1.5, lipHoleSize * 1.5));
|
new Area(new Ellipse2D.Double(x /* + pointMargin */- length + lipHoleSize * 2, y - pointMargin + width
|
||||||
|
/ 2 - lipHoleSize * 0.75, lipHoleSize * 1.5, lipHoleSize * 1.5));
|
||||||
((Area) body[0]).subtract(cutout);
|
((Area) body[0]).subtract(cutout);
|
||||||
cutout = new Area(new Ellipse2D.Double(x + pointMargin - lipHoleSize * 3, y
|
cutout =
|
||||||
- pointMargin + width / 2 - lipHoleSize * 0.75, lipHoleSize* 1.5, lipHoleSize* 1.5));
|
new Area(new Ellipse2D.Double(x /* + pointMargin */- lipHoleSize * 3, y - pointMargin + width / 2
|
||||||
|
- lipHoleSize * 0.75, lipHoleSize * 1.5, lipHoleSize * 1.5));
|
||||||
((Area) body[0]).subtract(cutout);
|
((Area) body[0]).subtract(cutout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,22 +308,23 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
int bobinWidth = width / 2;
|
int bobinWidth = width / 2;
|
||||||
int bobinRadius = (int) (getType() == HumbuckerType.Filtertron ? edgeRadius * 1.1f : bobinWidth);
|
int bobinRadius = (int) (getType() == HumbuckerType.Filtertron ? edgeRadius * 1.1f : bobinWidth);
|
||||||
body[4] =
|
body[4] =
|
||||||
new Area(new RoundRectangle2D.Double(x + pointMargin - length, y - pointMargin, length, bobinWidth,
|
new Area(new RoundRectangle2D.Double(x /* + pointMargin */- length, y - pointMargin, length, bobinWidth,
|
||||||
bobinRadius, bobinRadius));
|
bobinRadius, bobinRadius));
|
||||||
body[5] =
|
body[5] =
|
||||||
new Area(new RoundRectangle2D.Double(x + pointMargin - length, y - pointMargin + bobinWidth, length,
|
new Area(new RoundRectangle2D.Double(x /* + pointMargin */- length, y - pointMargin + bobinWidth, length,
|
||||||
bobinWidth, bobinRadius, bobinRadius));
|
bobinWidth, bobinRadius, bobinRadius));
|
||||||
}
|
}
|
||||||
|
|
||||||
// legs
|
// legs
|
||||||
if (getLegs()) {
|
if (getLegs()) {
|
||||||
Area legArea = new Area(new RoundRectangle2D.Double(x + pointMargin - length - lipLength, y - pointMargin + width / 2
|
Area legArea =
|
||||||
|
new Area(new RoundRectangle2D.Double(x /* + pointMargin */- length - lipLength, y - pointMargin + width / 2
|
||||||
- lipWidth / 2, length + 2 * lipLength, lipWidth, edgeRadius / 2, edgeRadius / 2));
|
- lipWidth / 2, length + 2 * lipLength, lipWidth, edgeRadius / 2, edgeRadius / 2));
|
||||||
legArea.subtract((Area) (body[0]));
|
legArea.subtract((Area) (body[0]));
|
||||||
legArea.subtract(new Area(new Ellipse2D.Double(x + pointMargin - length - lipLength / 2, y - pointMargin + width
|
legArea.subtract(new Area(new Ellipse2D.Double(x /* + pointMargin */- length - lipLength / 2, y - pointMargin
|
||||||
|
+ width / 2 - lipHoleSize / 2, lipHoleSize, lipHoleSize)));
|
||||||
|
legArea.subtract(new Area(new Ellipse2D.Double(x /* + pointMargin */+ lipLength / 2, y - pointMargin + width
|
||||||
/ 2 - lipHoleSize / 2, lipHoleSize, lipHoleSize)));
|
/ 2 - lipHoleSize / 2, lipHoleSize, lipHoleSize)));
|
||||||
legArea.subtract(new Area(new Ellipse2D.Double(x + pointMargin + lipLength / 2, y - pointMargin + width / 2
|
|
||||||
- lipHoleSize / 2, lipHoleSize, lipHoleSize)));
|
|
||||||
legArea.subtract(base);
|
legArea.subtract(base);
|
||||||
body[1] = legArea;
|
body[1] = legArea;
|
||||||
}
|
}
|
||||||
@@ -285,26 +337,26 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
|
|
||||||
if (getCoilType1() == PolePieceType.Rail) {
|
if (getCoilType1() == PolePieceType.Rail) {
|
||||||
poleArea.add(new Area(
|
poleArea.add(new Area(
|
||||||
new RoundRectangle2D.Double(x + pointMargin - length + poleMargin - poleSize / 2, y - pointMargin
|
new RoundRectangle2D.Double(x /* + pointMargin */- length + poleMargin - poleSize / 2, y - pointMargin
|
||||||
+ coilMargin - poleSize / 2, poleSpacing * 5 + poleSize, poleSize, poleSize / 2, poleSize / 2)));
|
+ coilMargin - poleSize / 2, poleSpacing * 5 + poleSize, poleSize, poleSize / 2, poleSize / 2)));
|
||||||
} else if (getCoilType1() == PolePieceType.Rods || getCoilType1() == PolePieceType.Screws) {
|
} else if (getCoilType1() == PolePieceType.Rods || getCoilType1() == PolePieceType.Screws) {
|
||||||
Path2D screwPath = new Path2D.Double();
|
Path2D screwPath = new Path2D.Double();
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
Ellipse2D pole =
|
Ellipse2D pole =
|
||||||
new Ellipse2D.Double(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2, y
|
new Ellipse2D.Double(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2, y
|
||||||
- pointMargin + coilMargin - poleSize / 2, poleSize, poleSize);
|
- pointMargin + coilMargin - poleSize / 2, poleSize, poleSize);
|
||||||
poleArea.add(new Area(pole));
|
poleArea.add(new Area(pole));
|
||||||
if (getCoilType1() == PolePieceType.Screws) {
|
if (getCoilType1() == PolePieceType.Screws) {
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
screwPath.moveTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2, y
|
screwPath.moveTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2, y
|
||||||
- pointMargin + coilMargin - poleSize / 2);
|
- pointMargin + coilMargin - poleSize / 2);
|
||||||
screwPath.lineTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize, y
|
screwPath.lineTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize,
|
||||||
- pointMargin + coilMargin - poleSize / 2 + poleSize);
|
y - pointMargin + coilMargin - poleSize / 2 + poleSize);
|
||||||
} else {
|
} else {
|
||||||
screwPath.moveTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2, y
|
screwPath.moveTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2, y
|
||||||
- pointMargin + coilMargin - poleSize / 2 + poleSize);
|
- pointMargin + coilMargin - poleSize / 2 + poleSize);
|
||||||
screwPath.lineTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize, y
|
screwPath.lineTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize,
|
||||||
- pointMargin + coilMargin - poleSize / 2);
|
y - pointMargin + coilMargin - poleSize / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,27 +369,27 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getCoilType2() == PolePieceType.Rail) {
|
if (getCoilType2() == PolePieceType.Rail) {
|
||||||
poleArea.add(new Area(new RoundRectangle2D.Double(x + pointMargin - length + poleMargin - poleSize / 2, y
|
poleArea.add(new Area(new RoundRectangle2D.Double(x /* + pointMargin */- length + poleMargin - poleSize / 2, y
|
||||||
- pointMargin + width - coilMargin - poleSize / 2, poleSpacing * 5 + poleSize, poleSize, poleSize / 2,
|
- pointMargin + width - coilMargin - poleSize / 2, poleSpacing * 5 + poleSize, poleSize, poleSize / 2,
|
||||||
poleSize / 2)));
|
poleSize / 2)));
|
||||||
} else if (getCoilType2() == PolePieceType.Rods || getCoilType2() == PolePieceType.Screws) {
|
} else if (getCoilType2() == PolePieceType.Rods || getCoilType2() == PolePieceType.Screws) {
|
||||||
Path2D screwPath = new Path2D.Double();
|
Path2D screwPath = new Path2D.Double();
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
Ellipse2D pole =
|
Ellipse2D pole =
|
||||||
new Ellipse2D.Double(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2, y
|
new Ellipse2D.Double(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2, y
|
||||||
- pointMargin + width - coilMargin - poleSize / 2, poleSize, poleSize);
|
- pointMargin + width - coilMargin - poleSize / 2, poleSize, poleSize);
|
||||||
poleArea.add(new Area(pole));
|
poleArea.add(new Area(pole));
|
||||||
if (getCoilType1() == PolePieceType.Screws) {
|
if (getCoilType1() == PolePieceType.Screws) {
|
||||||
if (i % 2 == 1) {
|
if (i % 2 == 1) {
|
||||||
screwPath.moveTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2, y
|
screwPath.moveTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2, y
|
||||||
- pointMargin + width - coilMargin - poleSize / 2);
|
- pointMargin + width - coilMargin - poleSize / 2);
|
||||||
screwPath.lineTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize, y
|
screwPath.lineTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize,
|
||||||
- pointMargin + width - coilMargin - poleSize / 2 + poleSize);
|
y - pointMargin + width - coilMargin - poleSize / 2 + poleSize);
|
||||||
} else {
|
} else {
|
||||||
screwPath.moveTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2, y
|
screwPath.moveTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2, y
|
||||||
- pointMargin + width - coilMargin - poleSize / 2 + poleSize);
|
- pointMargin + width - coilMargin - poleSize / 2 + poleSize);
|
||||||
screwPath.lineTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize, y
|
screwPath.lineTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize,
|
||||||
- pointMargin + width - coilMargin - poleSize / 2);
|
y - pointMargin + width - coilMargin - poleSize / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,12 +526,12 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getControlPointCount() {
|
public int getControlPointCount() {
|
||||||
return 1;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
return VisibilityPolicy.WHEN_SELECTED;
|
return VisibilityPolicy.ALWAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -489,12 +541,12 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Point getControlPoint(int index) {
|
public Point getControlPoint(int index) {
|
||||||
return controlPoint;
|
return getControlPoints()[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
this.controlPoint.setLocation(point);
|
getControlPoints()[index].setLocation(point);
|
||||||
// Invalidate the body
|
// Invalidate the body
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
@@ -519,6 +571,7 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
// Invalidate the body
|
// Invalidate the body
|
||||||
body = null;
|
body = null;
|
||||||
|
updateControlPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -571,12 +624,23 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getControlPointNodeName(int index) {
|
public String getControlPointNodeName(int index) {
|
||||||
return "PickupTerminal";
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
return"North Start";
|
||||||
|
case 1:
|
||||||
|
return "North End";
|
||||||
|
case 2:
|
||||||
|
return "South Start";
|
||||||
|
case 3:
|
||||||
|
return "South End";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum HumbuckerType {
|
public static enum HumbuckerType {
|
||||||
|
|
||||||
PAF(WIDTH, LENGTH, POLE_SIZE), Mini(WIDTH_MINI, LENGTH_MINI, POLE_SIZE), Filtertron(WIDTH_FILTERTRON, LENGTH_FILTERTRON, POLE_SIZE_FILTERTRON);
|
PAF(WIDTH, LENGTH, POLE_SIZE), Mini(WIDTH_MINI, LENGTH_MINI, POLE_SIZE), Filtertron(WIDTH_FILTERTRON,
|
||||||
|
LENGTH_FILTERTRON, POLE_SIZE_FILTERTRON);
|
||||||
|
|
||||||
private Size width;
|
private Size width;
|
||||||
private Size length;
|
private Size length;
|
||||||
|
|||||||
@@ -65,10 +65,11 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
|||||||
|
|
||||||
private static Color BODY_COLOR = Color.white;
|
private static Color BODY_COLOR = Color.white;
|
||||||
private static Color BASE_COLOR = Color.gray;
|
private static Color BASE_COLOR = Color.gray;
|
||||||
private static Color POINT_COLOR = Color.lightGray;
|
// private static Color POINT_COLOR = Color.lightGray;
|
||||||
private static Size WIDTH = new Size(15.5d, SizeUnit.mm);
|
private static Size WIDTH = new Size(15.5d, SizeUnit.mm);
|
||||||
private static Size LENGTH = new Size(83d, 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 BASE_RADIUS = new Size(0.15d, SizeUnit.in);
|
||||||
|
private static Size POINT_SPACING = new Size(0.1d, SizeUnit.in);
|
||||||
|
|
||||||
// strat-specific
|
// strat-specific
|
||||||
private static Size STRAT_LIP_WIDTH = new Size(5d, SizeUnit.mm);
|
private static Size STRAT_LIP_WIDTH = new Size(5d, SizeUnit.mm);
|
||||||
@@ -101,6 +102,51 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
|||||||
private SingleCoilType type = SingleCoilType.Stratocaster;
|
private SingleCoilType type = SingleCoilType.Stratocaster;
|
||||||
private PolePieceType polePieceType = PolePieceType.Rods;
|
private PolePieceType polePieceType = PolePieceType.Rods;
|
||||||
|
|
||||||
|
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
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
@@ -120,8 +166,8 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
|||||||
g2d.fill(body[3]);
|
g2d.fill(body[3]);
|
||||||
else
|
else
|
||||||
g2d.fill(body[0]);
|
g2d.fill(body[0]);
|
||||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
|
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
|
||||||
g2d.fill(body[1]);
|
// g2d.fill(body[1]);
|
||||||
|
|
||||||
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : color);
|
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : color);
|
||||||
// g2d.fill(body[3]);
|
// g2d.fill(body[3]);
|
||||||
@@ -191,8 +237,9 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
|||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[5];
|
body = new Shape[5];
|
||||||
|
|
||||||
int x = controlPoint.x;
|
Point[] points = getControlPoints();
|
||||||
int y = controlPoint.y;
|
int x = (points[0].x + points[3].x) / 2;
|
||||||
|
int y = (points[0].y + points[3].y) / 2;;
|
||||||
int width = (int) WIDTH.convertToPixels();
|
int width = (int) WIDTH.convertToPixels();
|
||||||
int length = (int) LENGTH.convertToPixels();
|
int length = (int) LENGTH.convertToPixels();
|
||||||
int stratInnerLength = (int) STRAT_INNER_LENGTH.convertToPixels();
|
int stratInnerLength = (int) STRAT_INNER_LENGTH.convertToPixels();
|
||||||
@@ -388,7 +435,7 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getControlPointCount() {
|
public int getControlPointCount() {
|
||||||
return 1;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -403,12 +450,12 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Point getControlPoint(int index) {
|
public Point getControlPoint(int index) {
|
||||||
return controlPoint;
|
return getControlPoints()[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
this.controlPoint.setLocation(point);
|
getControlPoints()[index].setLocation(point);
|
||||||
// Invalidate the body
|
// Invalidate the body
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
@@ -433,6 +480,7 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
|||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
// Invalidate the body
|
// Invalidate the body
|
||||||
body = null;
|
body = null;
|
||||||
|
updateControlPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -468,7 +516,17 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getControlPointNodeName(int index) {
|
public String getControlPointNodeName(int index) {
|
||||||
return getName() + ".PickupTerminal";
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
return"North Start";
|
||||||
|
case 1:
|
||||||
|
return "North End";
|
||||||
|
case 2:
|
||||||
|
return "South Start";
|
||||||
|
case 3:
|
||||||
|
return "South End";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SingleCoilType {
|
public enum SingleCoilType {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user