mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
graph improvmeents
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.diylc.graph.Graph;
|
||||
@@ -28,5 +29,5 @@ import org.diylc.graph.GraphKey;
|
||||
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
@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
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,6 @@ public class Node {
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public class Vertex {
|
||||
|
||||
private Node node1;
|
||||
private Node node2;
|
||||
private Set<Node> nodes = new HashSet<Node>();
|
||||
|
||||
public Vertex(Node node1, Node node2) {
|
||||
this.node1 = node1;
|
||||
this.node2 = node2;
|
||||
nodes.add(node1);
|
||||
nodes.add(node2);
|
||||
}
|
||||
|
||||
public Node getNode1() {
|
||||
return node1;
|
||||
Iterator<Node> i = nodes.iterator();
|
||||
return i.next();
|
||||
}
|
||||
|
||||
public Node getNode2() {
|
||||
return node2;
|
||||
Iterator<Node> i = nodes.iterator();
|
||||
i.next();
|
||||
return i.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((node1 == null) ? 0 : node1.hashCode());
|
||||
result = prime * result + ((node2 == null) ? 0 : node2.hashCode());
|
||||
result = prime * result + ((nodes == null) ? 0 : nodes.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -36,21 +41,16 @@ public class Vertex {
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Vertex other = (Vertex) obj;
|
||||
if (node1 == null) {
|
||||
if (other.node1 != null)
|
||||
if (nodes == null) {
|
||||
if (other.nodes != null)
|
||||
return false;
|
||||
} else if (!node1.equals(other.node1))
|
||||
return false;
|
||||
if (node2 == null) {
|
||||
if (other.node2 != null)
|
||||
return false;
|
||||
} else if (!node2.equals(other.node2))
|
||||
} else if (!nodes.equals(other.nodes))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return node1.toString() + " -> " + node2.toString();
|
||||
return getNode1().toString() + " <-> " + getNode2().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2687,8 +2687,8 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<GraphKey, Graph> extractGraphs() {
|
||||
Map<GraphKey, Graph> result = new HashMap<GraphKey, Graph>();
|
||||
public Map<Graph, List<GraphKey>> extractGraphs() {
|
||||
Map<Graph, List<GraphKey>> result = new HashMap<Graph, List<GraphKey>>();
|
||||
List<Node> nodes = new ArrayList<Node>();
|
||||
|
||||
List<ISwitch> switches = new ArrayList<ISwitch>();
|
||||
@@ -2753,7 +2753,15 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
List<Line2D> connections = getConnections(switchPositions);
|
||||
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
|
||||
if (positions[i] < switches.get(i).getPositionCount() - 1) {
|
||||
|
||||
Binary file not shown.
@@ -1,24 +1,20 @@
|
||||
/*
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
*
|
||||
* 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.AlphaComposite;
|
||||
@@ -57,9 +53,9 @@ import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Humbucker Pickup", category = "Guitar", author = "Branislav Stojkovic",
|
||||
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")
|
||||
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> {
|
||||
|
||||
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 BOBIN_COLOR1 = Color.decode("#EAE3C6");
|
||||
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 LENGTH = new Size(68.58d, 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 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);
|
||||
@@ -100,6 +97,12 @@ 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) {
|
||||
@@ -133,8 +136,8 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
g2d.fill(body[0]);
|
||||
}
|
||||
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
|
||||
g2d.fill(body[2]);
|
||||
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
|
||||
// g2d.fill(body[2]);
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
@@ -202,13 +205,53 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
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")
|
||||
public Shape[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[7];
|
||||
|
||||
int x = controlPoint.x;
|
||||
int y = controlPoint.y;
|
||||
Point[] points = getControlPoints();
|
||||
int x = points[0].x;
|
||||
int y = points[0].y;
|
||||
int width = (int) getType().getWidth().convertToPixels();
|
||||
int length = (int) getType().getLength().convertToPixels();
|
||||
int lipWidth = (int) LIP_WIDTH.convertToPixels();
|
||||
@@ -223,8 +266,9 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
int coilMargin = (width - coilSpacing) / 2;
|
||||
int poleMargin = (length - poleSpacing * 5) / 2;
|
||||
|
||||
Area base = new Area(new RoundRectangle2D.Double(x + pointMargin - length, y - pointMargin, length, width, edgeRadius,
|
||||
edgeRadius));
|
||||
Area base =
|
||||
new Area(new RoundRectangle2D.Double(x /* + pointMargin */- length, y - pointMargin, length, width,
|
||||
edgeRadius, edgeRadius));
|
||||
|
||||
// base or cover
|
||||
body[0] = new Area(base);
|
||||
@@ -232,23 +276,30 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
int cutoutMargin = (int) FILTETRON_CUTOUT_MARGIN.convertToPixels();
|
||||
int cutoutHeight = 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
|
||||
- pointMargin + coilMargin - poleSize / 2 - cutoutMargin, cutoutWidth, cutoutHeight, cutoutHeight, cutoutHeight));
|
||||
((Area)body[0]).subtract(cutout);
|
||||
cutout = 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 cutout =
|
||||
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);
|
||||
cutout =
|
||||
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);
|
||||
int middleCutoutWidth = poleSpacing / 5;
|
||||
cutout = new Area(new Rectangle2D.Double(x + pointMargin - length / 2 - middleCutoutWidth / 2, y
|
||||
- pointMargin + width / 4, middleCutoutWidth, width / 2));
|
||||
((Area)body[0]).subtract(cutout);
|
||||
cutout =
|
||||
new Area(new Rectangle2D.Double(x /* + pointMargin */- length / 2 - middleCutoutWidth / 2, y - pointMargin
|
||||
+ width / 4, middleCutoutWidth, width / 2));
|
||||
((Area) body[0]).subtract(cutout);
|
||||
if (!getLegs()) {
|
||||
cutout = 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);
|
||||
cutout = 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);
|
||||
cutout =
|
||||
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);
|
||||
cutout =
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,22 +308,23 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
int bobinWidth = width / 2;
|
||||
int bobinRadius = (int) (getType() == HumbuckerType.Filtertron ? edgeRadius * 1.1f : bobinWidth);
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
// legs
|
||||
if (getLegs()) {
|
||||
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));
|
||||
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));
|
||||
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)));
|
||||
legArea.subtract(new Area(new Ellipse2D.Double(x + pointMargin + lipLength / 2, y - pointMargin + width / 2
|
||||
- lipHoleSize / 2, lipHoleSize, lipHoleSize)));
|
||||
legArea.subtract(base);
|
||||
body[1] = legArea;
|
||||
}
|
||||
@@ -285,26 +337,26 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
|
||||
if (getCoilType1() == PolePieceType.Rail) {
|
||||
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)));
|
||||
} else if (getCoilType1() == PolePieceType.Rods || getCoilType1() == PolePieceType.Screws) {
|
||||
Path2D screwPath = new Path2D.Double();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
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);
|
||||
poleArea.add(new Area(pole));
|
||||
if (getCoilType1() == PolePieceType.Screws) {
|
||||
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);
|
||||
screwPath.lineTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize, y
|
||||
- pointMargin + coilMargin - poleSize / 2 + poleSize);
|
||||
screwPath.lineTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize,
|
||||
y - pointMargin + coilMargin - poleSize / 2 + poleSize);
|
||||
} 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);
|
||||
screwPath.lineTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize, y
|
||||
- pointMargin + coilMargin - poleSize / 2);
|
||||
screwPath.lineTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize,
|
||||
y - pointMargin + coilMargin - poleSize / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,27 +369,27 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
|
||||
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,
|
||||
poleSize / 2)));
|
||||
} else if (getCoilType2() == PolePieceType.Rods|| getCoilType2() == PolePieceType.Screws) {
|
||||
} else if (getCoilType2() == PolePieceType.Rods || getCoilType2() == PolePieceType.Screws) {
|
||||
Path2D screwPath = new Path2D.Double();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
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);
|
||||
poleArea.add(new Area(pole));
|
||||
if (getCoilType1() == PolePieceType.Screws) {
|
||||
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);
|
||||
screwPath.lineTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize, y
|
||||
- pointMargin + width - coilMargin - poleSize / 2 + poleSize);
|
||||
screwPath.lineTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize,
|
||||
y - pointMargin + width - coilMargin - poleSize / 2 + poleSize);
|
||||
} 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);
|
||||
screwPath.lineTo(x + pointMargin - length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize, y
|
||||
- pointMargin + width - coilMargin - poleSize / 2);
|
||||
screwPath.lineTo(x /* + pointMargin */- length + poleMargin + i * poleSpacing - poleSize / 2 + poleSize,
|
||||
y - pointMargin + width - coilMargin - poleSize / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -474,12 +526,12 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.WHEN_SELECTED;
|
||||
return VisibilityPolicy.ALWAYS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -489,12 +541,12 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return controlPoint;
|
||||
return getControlPoints()[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
this.controlPoint.setLocation(point);
|
||||
getControlPoints()[index].setLocation(point);
|
||||
// Invalidate the body
|
||||
body = null;
|
||||
}
|
||||
@@ -519,6 +571,7 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
this.orientation = orientation;
|
||||
// Invalidate the body
|
||||
body = null;
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@@ -571,12 +624,23 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
|
||||
@Override
|
||||
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 {
|
||||
|
||||
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 length;
|
||||
|
||||
@@ -65,10 +65,11 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
||||
|
||||
private static Color BODY_COLOR = Color.white;
|
||||
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 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);
|
||||
|
||||
// strat-specific
|
||||
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 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
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
@@ -120,8 +166,8 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
||||
g2d.fill(body[3]);
|
||||
else
|
||||
g2d.fill(body[0]);
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
|
||||
g2d.fill(body[1]);
|
||||
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : POINT_COLOR);
|
||||
// g2d.fill(body[1]);
|
||||
|
||||
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : color);
|
||||
// g2d.fill(body[3]);
|
||||
@@ -191,8 +237,9 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
||||
if (body == null) {
|
||||
body = new Shape[5];
|
||||
|
||||
int x = controlPoint.x;
|
||||
int y = controlPoint.y;
|
||||
Point[] points = getControlPoints();
|
||||
int x = (points[0].x + points[3].x) / 2;
|
||||
int y = (points[0].y + points[3].y) / 2;;
|
||||
int width = (int) WIDTH.convertToPixels();
|
||||
int length = (int) LENGTH.convertToPixels();
|
||||
int stratInnerLength = (int) STRAT_INNER_LENGTH.convertToPixels();
|
||||
@@ -388,7 +435,7 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -403,12 +450,12 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return controlPoint;
|
||||
return getControlPoints()[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
this.controlPoint.setLocation(point);
|
||||
getControlPoints()[index].setLocation(point);
|
||||
// Invalidate the body
|
||||
body = null;
|
||||
}
|
||||
@@ -433,6 +480,7 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
||||
this.orientation = orientation;
|
||||
// Invalidate the body
|
||||
body = null;
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@@ -468,7 +516,17 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
||||
|
||||
@Override
|
||||
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 {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user