mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
When loaded from an existing file "Potentiometer Symbol" doesn't retain
the specified orientation
This commit is contained in:
@@ -90,6 +90,10 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
|
|||||||
|
|
||||||
// Draw transistor
|
// Draw transistor
|
||||||
|
|
||||||
|
if (this.body == null) {
|
||||||
|
this.body = getBody();
|
||||||
|
applyOrientation(this.body);
|
||||||
|
}
|
||||||
Shape[] body = getBody();
|
Shape[] body = getBody();
|
||||||
|
|
||||||
AffineTransform old = g2d.getTransform();
|
AffineTransform old = g2d.getTransform();
|
||||||
@@ -166,7 +170,7 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
|
|||||||
return controlPoints[0].y;
|
return controlPoints[0].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateControlPoints() {
|
protected void updateControlPoints() {
|
||||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||||
// Update control points.
|
// Update control points.
|
||||||
int x = controlPoints[0].x;
|
int x = controlPoints[0].x;
|
||||||
@@ -179,6 +183,16 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
|
|||||||
|
|
||||||
controlPoints[2].x = x + f * pinSpacing * 2;
|
controlPoints[2].x = x + f * pinSpacing * 2;
|
||||||
controlPoints[2].y = y + pinSpacing * 2;
|
controlPoints[2].y = y + pinSpacing * 2;
|
||||||
|
|
||||||
|
if (getOrientation() != Orientation.DEFAULT)
|
||||||
|
{
|
||||||
|
Point first = this.controlPoints[0];
|
||||||
|
double angle = Double.parseDouble(getOrientation().name().replace("_", ""));
|
||||||
|
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(angle), first.x, first.y);
|
||||||
|
for (int i = 1; i < this.controlPoints.length; i++) {
|
||||||
|
rotate.transform(this.controlPoints[i], this.controlPoints[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -206,7 +220,8 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
|
|||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
controlPoints[index].setLocation(point);
|
controlPoints[index].setLocation(point);
|
||||||
|
|
||||||
refreshDrawing();
|
// make sure we have a new drawing
|
||||||
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -217,7 +232,9 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
|
|||||||
public void setFlip(SymbolFlipping flip) {
|
public void setFlip(SymbolFlipping flip) {
|
||||||
this.flip = flip;
|
this.flip = flip;
|
||||||
|
|
||||||
refreshDrawing();
|
updateControlPoints();
|
||||||
|
// make sure we have a new drawing
|
||||||
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -249,27 +266,22 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
|
|||||||
public void setOrientation(Orientation orientation) {
|
public void setOrientation(Orientation orientation) {
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
|
|
||||||
refreshDrawing();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void refreshDrawing() {
|
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
// make sure we have a new drawing
|
// make sure we have a new drawing
|
||||||
body = null;
|
body = null;
|
||||||
getBody();
|
}
|
||||||
|
|
||||||
|
protected void applyOrientation(Shape[] body) {
|
||||||
if (getOrientation() == Orientation.DEFAULT)
|
if (getOrientation() == Orientation.DEFAULT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Point first = this.controlPoints[0];
|
Point first = this.controlPoints[0];
|
||||||
double angle = Double.parseDouble(getOrientation().name().replace("_", ""));
|
double angle = Double.parseDouble(getOrientation().name().replace("_", ""));
|
||||||
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(angle), first.x, first.y);
|
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(angle), first.x, first.y);
|
||||||
for (int i = 1; i < this.controlPoints.length; i++) {
|
|
||||||
rotate.transform(this.controlPoints[i], this.controlPoints[i]);
|
if (body != null) {
|
||||||
}
|
for (int i = 0; i < body.length; i++) {
|
||||||
if (this.body != null) {
|
body[i] = rotate.createTransformedShape(body[i]);
|
||||||
for (int i = 0; i < this.body.length; i++) {
|
|
||||||
this.body[i] = rotate.createTransformedShape(this.body[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,49 +45,48 @@ public class BJTSymbol extends Abstract3LegSymbol {
|
|||||||
protected BJTPolarity polarity = BJTPolarity.NPN;
|
protected BJTPolarity polarity = BJTPolarity.NPN;
|
||||||
|
|
||||||
public Shape[] getBody() {
|
public Shape[] getBody() {
|
||||||
if (body == null) {
|
Shape[] body = new Shape[3];
|
||||||
body = new Shape[3];
|
int x = controlPoints[0].x;
|
||||||
int x = controlPoints[0].x;
|
int y = controlPoints[0].y;
|
||||||
int y = controlPoints[0].y;
|
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
|
||||||
|
|
||||||
GeneralPath polyline = new GeneralPath();
|
GeneralPath polyline = new GeneralPath();
|
||||||
|
|
||||||
polyline.moveTo(x + pinSpacing / 2, y - pinSpacing);
|
polyline.moveTo(x + pinSpacing / 2, y - pinSpacing);
|
||||||
polyline.lineTo(x + pinSpacing / 2, y + pinSpacing);
|
polyline.lineTo(x + pinSpacing / 2, y + pinSpacing);
|
||||||
|
|
||||||
body[0] = polyline;
|
body[0] = polyline;
|
||||||
|
|
||||||
polyline = new GeneralPath();
|
polyline = new GeneralPath();
|
||||||
|
|
||||||
polyline.moveTo(x, y);
|
polyline.moveTo(x, y);
|
||||||
polyline.lineTo(x + pinSpacing / 2, y);
|
polyline.lineTo(x + pinSpacing / 2, y);
|
||||||
polyline.moveTo(x + pinSpacing / 2, y - pinSpacing / 2);
|
polyline.moveTo(x + pinSpacing / 2, y - pinSpacing / 2);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing);
|
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing * 2);
|
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing * 2);
|
||||||
polyline.moveTo(x + pinSpacing / 2, y + pinSpacing / 2);
|
polyline.moveTo(x + pinSpacing / 2, y + pinSpacing / 2);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing);
|
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 2);
|
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 2);
|
||||||
body[1] = polyline;
|
body[1] = polyline;
|
||||||
|
|
||||||
Area arrow;
|
Area arrow;
|
||||||
double theta;
|
double theta;
|
||||||
if (polarity == BJTPolarity.NPN) {
|
if (polarity == BJTPolarity.NPN) {
|
||||||
theta = Math.atan(1.0 / 3);
|
theta = Math.atan(1.0 / 3);
|
||||||
arrow =
|
arrow =
|
||||||
new Area(new Polygon(new int[] {x + pinSpacing, x + pinSpacing, x + pinSpacing * 10 / 6}, new int[] {
|
new Area(new Polygon(new int[] {x + pinSpacing, x + pinSpacing, x + pinSpacing * 10 / 6}, new int[] {
|
||||||
y - pinSpacing / 5 + pinSpacing / 2, y + pinSpacing / 5 + pinSpacing / 2, y + pinSpacing / 2}, 3));
|
y - pinSpacing / 5 + pinSpacing / 2, y + pinSpacing / 5 + pinSpacing / 2, y + pinSpacing / 2}, 3));
|
||||||
arrow.transform(AffineTransform.getRotateInstance(theta, x + pinSpacing / 2, y + pinSpacing / 2));
|
arrow.transform(AffineTransform.getRotateInstance(theta, x + pinSpacing / 2, y + pinSpacing / 2));
|
||||||
} else {
|
} else {
|
||||||
theta = -Math.atan(1.0 / 3);
|
theta = -Math.atan(1.0 / 3);
|
||||||
arrow =
|
arrow =
|
||||||
new Area(
|
new Area(
|
||||||
new Polygon(new int[] {x + pinSpacing, x + pinSpacing * 10 / 6, x + pinSpacing * 10 / 6}, new int[] {
|
new Polygon(new int[] {x + pinSpacing, x + pinSpacing * 10 / 6, x + pinSpacing * 10 / 6}, new int[] {
|
||||||
y - pinSpacing / 2, y - pinSpacing / 5 - pinSpacing / 2, y + pinSpacing / 5 - pinSpacing / 2}, 3));
|
y - pinSpacing / 2, y - pinSpacing / 5 - pinSpacing / 2, y + pinSpacing / 5 - pinSpacing / 2}, 3));
|
||||||
arrow.transform(AffineTransform.getRotateInstance(theta, x + pinSpacing / 2, y - pinSpacing / 2));
|
arrow.transform(AffineTransform.getRotateInstance(theta, x + pinSpacing / 2, y - pinSpacing / 2));
|
||||||
}
|
|
||||||
body[2] = arrow;
|
|
||||||
}
|
}
|
||||||
|
body[2] = arrow;
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +115,6 @@ public class BJTSymbol extends Abstract3LegSymbol {
|
|||||||
public void setPolarity(BJTPolarity polarity) {
|
public void setPolarity(BJTPolarity polarity) {
|
||||||
this.polarity = polarity;
|
this.polarity = polarity;
|
||||||
|
|
||||||
|
body = null;
|
||||||
refreshDrawing();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,43 +43,42 @@ public class JFETSymbol extends Abstract3LegSymbol {
|
|||||||
protected FETPolarity polarity = FETPolarity.NEGATIVE;
|
protected FETPolarity polarity = FETPolarity.NEGATIVE;
|
||||||
|
|
||||||
public Shape[] getBody() {
|
public Shape[] getBody() {
|
||||||
if (body == null) {
|
Shape[] body = new Shape[3];
|
||||||
body = new Shape[3];
|
int x = controlPoints[0].x;
|
||||||
int x = controlPoints[0].x;
|
int y = controlPoints[0].y;
|
||||||
int y = controlPoints[0].y;
|
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
|
||||||
|
|
||||||
GeneralPath polyline = new GeneralPath();
|
GeneralPath polyline = new GeneralPath();
|
||||||
|
|
||||||
polyline.moveTo(x + pinSpacing, y - pinSpacing);
|
polyline.moveTo(x + pinSpacing, y - pinSpacing);
|
||||||
polyline.lineTo(x + pinSpacing, y + pinSpacing);
|
polyline.lineTo(x + pinSpacing, y + pinSpacing);
|
||||||
|
|
||||||
body[0] = polyline;
|
body[0] = polyline;
|
||||||
|
|
||||||
polyline = new GeneralPath();
|
polyline = new GeneralPath();
|
||||||
|
|
||||||
polyline.moveTo(x, y);
|
polyline.moveTo(x, y);
|
||||||
polyline.lineTo(x + pinSpacing, y);
|
polyline.lineTo(x + pinSpacing, y);
|
||||||
polyline.moveTo(x + pinSpacing, y - pinSpacing * 7 / 8);
|
polyline.moveTo(x + pinSpacing, y - pinSpacing * 7 / 8);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing * 7 / 8);
|
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing * 7 / 8);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing * 2);
|
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing * 2);
|
||||||
polyline.moveTo(x + pinSpacing, y + pinSpacing * 7 / 8);
|
polyline.moveTo(x + pinSpacing, y + pinSpacing * 7 / 8);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 7 / 8);
|
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 7 / 8);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 2);
|
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 2);
|
||||||
body[1] = polyline;
|
body[1] = polyline;
|
||||||
|
|
||||||
Polygon arrow;
|
Polygon arrow;
|
||||||
if (polarity == FETPolarity.NEGATIVE) {
|
if (polarity == FETPolarity.NEGATIVE) {
|
||||||
arrow =
|
arrow =
|
||||||
new Polygon(new int[] {x + pinSpacing * 2 / 6, x + pinSpacing * 2 / 6, x + pinSpacing * 6 / 6}, new int[] {
|
new Polygon(new int[] {x + pinSpacing * 2 / 6, x + pinSpacing * 2 / 6, x + pinSpacing * 6 / 6}, new int[] {
|
||||||
y - pinSpacing / 5, y + pinSpacing / 5, y}, 3);
|
y - pinSpacing / 5, y + pinSpacing / 5, y}, 3);
|
||||||
} else {
|
} else {
|
||||||
arrow =
|
arrow =
|
||||||
new Polygon(new int[] {x + pinSpacing / 6, x + pinSpacing * 5 / 6, x + pinSpacing * 5 / 6}, new int[] {y,
|
new Polygon(new int[] {x + pinSpacing / 6, x + pinSpacing * 5 / 6, x + pinSpacing * 5 / 6}, new int[] {y,
|
||||||
y + pinSpacing / 5, y - pinSpacing / 5}, 3);
|
y + pinSpacing / 5, y - pinSpacing / 5}, 3);
|
||||||
}
|
|
||||||
body[2] = arrow;
|
|
||||||
}
|
}
|
||||||
|
body[2] = arrow;
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +107,6 @@ public class JFETSymbol extends Abstract3LegSymbol {
|
|||||||
public void setPolarity(FETPolarity polarity) {
|
public void setPolarity(FETPolarity polarity) {
|
||||||
this.polarity = polarity;
|
this.polarity = polarity;
|
||||||
|
|
||||||
refreshDrawing();
|
body = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,46 +43,45 @@ public class MOSFETSymbol extends Abstract3LegSymbol {
|
|||||||
protected FETPolarity polarity = FETPolarity.NEGATIVE;
|
protected FETPolarity polarity = FETPolarity.NEGATIVE;
|
||||||
|
|
||||||
public Shape[] getBody() {
|
public Shape[] getBody() {
|
||||||
if (body == null) {
|
Shape[] body = new Shape[3];
|
||||||
body = new Shape[3];
|
int x = controlPoints[0].x;
|
||||||
int x = controlPoints[0].x;
|
int y = controlPoints[0].y;
|
||||||
int y = controlPoints[0].y;
|
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
|
||||||
|
|
||||||
GeneralPath polyline = new GeneralPath();
|
GeneralPath polyline = new GeneralPath();
|
||||||
|
|
||||||
polyline.moveTo(x + pinSpacing / 2, y - pinSpacing + 1);
|
polyline.moveTo(x + pinSpacing / 2, y - pinSpacing + 1);
|
||||||
polyline.lineTo(x + pinSpacing / 2, y + pinSpacing - 1);
|
polyline.lineTo(x + pinSpacing / 2, y + pinSpacing - 1);
|
||||||
polyline.moveTo(x + pinSpacing, y - pinSpacing + 1);
|
polyline.moveTo(x + pinSpacing, y - pinSpacing + 1);
|
||||||
polyline.lineTo(x + pinSpacing, y + pinSpacing - 1);
|
polyline.lineTo(x + pinSpacing, y + pinSpacing - 1);
|
||||||
body[0] = polyline;
|
body[0] = polyline;
|
||||||
|
|
||||||
polyline = new GeneralPath();
|
polyline = new GeneralPath();
|
||||||
|
|
||||||
polyline.moveTo(x + pinSpacing, y - pinSpacing);
|
polyline.moveTo(x + pinSpacing, y - pinSpacing);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing);
|
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing);
|
||||||
polyline.moveTo(x + pinSpacing, y + pinSpacing);
|
polyline.moveTo(x + pinSpacing, y + pinSpacing);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing);
|
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing);
|
||||||
polyline.moveTo(x, y);
|
polyline.moveTo(x, y);
|
||||||
polyline.lineTo(x + pinSpacing / 2, y);
|
polyline.lineTo(x + pinSpacing / 2, y);
|
||||||
polyline.moveTo(x + pinSpacing * 2, y - pinSpacing * 2);
|
polyline.moveTo(x + pinSpacing * 2, y - pinSpacing * 2);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing);
|
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing);
|
||||||
polyline.moveTo(x + pinSpacing * 2, y + pinSpacing * 2);
|
polyline.moveTo(x + pinSpacing * 2, y + pinSpacing * 2);
|
||||||
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing);
|
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing);
|
||||||
body[1] = polyline;
|
body[1] = polyline;
|
||||||
|
|
||||||
Polygon arrow;
|
Polygon arrow;
|
||||||
if (polarity == FETPolarity.NEGATIVE) {
|
if (polarity == FETPolarity.NEGATIVE) {
|
||||||
arrow =
|
arrow =
|
||||||
new Polygon(new int[] {x + pinSpacing * 8 / 6, x + pinSpacing * 8 / 6, x + pinSpacing * 12 / 6}, new int[] {
|
new Polygon(new int[] {x + pinSpacing * 8 / 6, x + pinSpacing * 8 / 6, x + pinSpacing * 12 / 6}, new int[] {
|
||||||
y + pinSpacing * 6 / 5, y + pinSpacing * 4 / 5, y + pinSpacing}, 3);
|
y + pinSpacing * 6 / 5, y + pinSpacing * 4 / 5, y + pinSpacing}, 3);
|
||||||
} else {
|
} else {
|
||||||
arrow =
|
arrow =
|
||||||
new Polygon(new int[] {x + pinSpacing * 7 / 6, x + pinSpacing * 11 / 6, x + pinSpacing * 11 / 6},
|
new Polygon(new int[] {x + pinSpacing * 7 / 6, x + pinSpacing * 11 / 6, x + pinSpacing * 11 / 6},
|
||||||
new int[] {y - pinSpacing, y - pinSpacing * 6 / 5, y - pinSpacing * 4 / 5}, 3);
|
new int[] {y - pinSpacing, y - pinSpacing * 6 / 5, y - pinSpacing * 4 / 5}, 3);
|
||||||
}
|
|
||||||
body[2] = arrow;
|
|
||||||
}
|
}
|
||||||
|
body[2] = arrow;
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +110,6 @@ public class MOSFETSymbol extends Abstract3LegSymbol {
|
|||||||
public void setPolarity(FETPolarity polarity) {
|
public void setPolarity(FETPolarity polarity) {
|
||||||
this.polarity = polarity;
|
this.polarity = polarity;
|
||||||
|
|
||||||
refreshDrawing();
|
body = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -2166,6 +2166,10 @@
|
|||||||
<changeType>BUG_FIX</changeType>
|
<changeType>BUG_FIX</changeType>
|
||||||
<description>Project font gets reverted to "Square721 BT" on Undo</description>
|
<description>Project font gets reverted to "Square721 BT" on Undo</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>When loaded from an existing file "Potentiometer Symbol" doesn't retain the specified orientation</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user