update.xml

This commit is contained in:
Branislav Stojkovic
2019-03-10 17:51:21 +01:00
parent b279510e5c
commit 49d93b42a4
6 changed files with 68 additions and 114 deletions
Binary file not shown.
@@ -57,7 +57,7 @@ import org.diylc.utils.Constants;
public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
private static final double RING_THETA = Math.PI * 0.795;
private static final double SLEEVE_THETA = Math.PI * 0.295;
private static final double SLEEVE_THETA = Math.PI * 0.29444444444;
private static final double SLEEVE_SWITCHED_THETA = Math.PI * 4 / 3;
private static final double SWITCH_THETA = Math.PI * 5 / 3;
@@ -76,8 +76,10 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
private String value = "";
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
transient Area[] body;
private Orientation orientation = Orientation.DEFAULT;
transient Area[] body;
@Deprecated
private Orientation orientation = Orientation.DEFAULT;
private Integer angle = 0;
private OpenJackType type = OpenJackType.MONO;
private boolean showLabels = true;
@@ -86,7 +88,6 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
updateControlPoints();
}
@SuppressWarnings("incomplete-switch")
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
@@ -162,24 +163,9 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
Point sleeveLabel = new Point(0, 0);
ringTransform.transform(tipLabel, ringOrSwitchLabel);
sleeveTransform.transform(tipLabel, sleeveLabel);
double theta = 0;
// Rotate if needed
if (orientation != Orientation.DEFAULT) {
switch (orientation) {
case _90:
theta = Math.PI / 2;
break;
case _180:
theta = Math.PI;
break;
case _270:
theta = Math.PI * 3 / 2;
break;
}
}
if (theta != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(theta, controlPoints[0].x, controlPoints[0].y);
if (getTheta() != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(getTheta(), controlPoints[0].x, controlPoints[0].y);
rotation.transform(tipLabel, tipLabel);
rotation.transform(ringOrSwitchLabel, ringOrSwitchLabel);
rotation.transform(sleeveLabel, sleeveLabel);
@@ -195,7 +181,6 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
}
@SuppressWarnings("incomplete-switch")
public Area[] getBody() {
if (body == null) {
body = new Area[4];
@@ -255,25 +240,9 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
body[3] = ringOrSwitch;
}
double theta = 0;
// Rotate if needed
if (orientation != Orientation.DEFAULT) {
switch (orientation) {
case _90:
theta = Math.PI / 2;
break;
case _180:
theta = Math.PI;
break;
case _270:
theta = Math.PI * 3 / 2;
break;
}
}
// Rotate if needed
if (theta != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y);
if (getTheta() != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(getTheta(), x, y);
// Skip the last one because it's already rotated
for (int i = 0; i < body.length; i++) {
Shape shape = body[i];
@@ -288,7 +257,6 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
return body;
}
@SuppressWarnings("incomplete-switch")
private void updateControlPoints() {
int x = controlPoints[0].x;
int y = controlPoints[0].y;
@@ -302,20 +270,8 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY).transform(controlPoints[0], controlPoints[2]);
// Rotate if needed
if (orientation != Orientation.DEFAULT) {
double theta = 0;
switch (orientation) {
case _90:
theta = Math.PI / 2;
break;
case _180:
theta = Math.PI;
break;
case _270:
theta = Math.PI * 3 / 2;
break;
}
AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y);
if (getTheta() != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(getTheta(), x, y);
for (Point point : controlPoints) {
rotation.transform(point, point);
}
@@ -386,17 +342,27 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
updateControlPoints();
// Invalidate the body
body = null;
public Integer getAngle() {
if (angle == null) {
if (orientation != null)
angle = Integer.parseInt(orientation.name().replace("_", ""));
else
angle = 0;
}
return angle;
}
public void setAngle(Integer angle) {
this.angle = angle;
updateControlPoints();
// Invalidate the body
body = null;
}
protected double getTheta() {
return Math.toRadians(getAngle());
}
@EditableProperty
@@ -59,7 +59,9 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
private static final long serialVersionUID = 1L;
private static Color BASE_COLOR = Color.lightGray;
private static Color WAFER_COLOR = Color.decode("#CD8500");
private static Color WAFER_COLOR = Color.decode("#CD8500");
private static final double SLEEVE_THETA = Math.PI * 0.29444444444;
private static Size THREAD_OUTER_DIAMETER = new Size(11 / 16d, SizeUnit.in);
private static Size NUT_DIAMETER = new Size(14 / 16d, SizeUnit.in);
@@ -75,8 +77,10 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
private String value = "";
private Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) };
transient Area[] body;
private Orientation orientation = Orientation.DEFAULT;
transient Area[] body;
@Deprecated
private Orientation orientation = Orientation.DEFAULT;
private Integer angle = 0;
public PilotLampHolder() {
super();
@@ -154,7 +158,6 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
}
@SuppressWarnings("incomplete-switch")
public Area[] getBody() {
if (body == null) {
body = new Area[6];
@@ -191,7 +194,7 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
Area sleeve =
new Area(new RoundRectangle2D.Double(x - springWidth / 2, y - holeToEdge, springWidth, springLength,
springWidth, springWidth));
sleeve.transform(AffineTransform.getRotateInstance(Math.PI * 0.295, x, centerY));
sleeve.transform(AffineTransform.getRotateInstance(SLEEVE_THETA, x, centerY));
sleeve.add(new Area(new Ellipse2D.Double(x - ringDiameter / 2, centerY - ringDiameter / 2, ringDiameter, ringDiameter)));
sleeve.subtract(new Area(new Ellipse2D.Double(x - innerDiameter / 2, centerY - innerDiameter / 2, innerDiameter, innerDiameter)));
@@ -230,26 +233,10 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
body[5] = link;
nut.subtract(link);
thread.subtract(link);
double theta = 0;
// Rotate if needed
if (orientation != Orientation.DEFAULT) {
switch (orientation) {
case _90:
theta = Math.PI / 2;
break;
case _180:
theta = Math.PI;
break;
case _270:
theta = Math.PI * 3 / 2;
break;
}
}
thread.subtract(link);
if (theta != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y);
if (getTheta() != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(getTheta(), x, y);
for (Area area : body) {
if (area != null)
area.transform(rotation);
@@ -264,7 +251,6 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
return body;
}
@SuppressWarnings("incomplete-switch")
private void updateControlPoints() {
int x = controlPoints[0].x;
int y = controlPoints[0].y;
@@ -283,20 +269,8 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
rotation.transform(controlPoints[2], controlPoints[3]);
// Rotate if needed
if (orientation != Orientation.DEFAULT) {
double theta = 0;
switch (orientation) {
case _90:
theta = Math.PI / 2;
break;
case _180:
theta = Math.PI;
break;
case _270:
theta = Math.PI * 3 / 2;
break;
}
rotation = AffineTransform.getRotateInstance(theta, x, y);
if (getTheta() != 0) {
rotation = AffineTransform.getRotateInstance(getTheta(), x, y);
for (Point point : controlPoints) {
rotation.transform(point, point);
}
@@ -412,15 +386,25 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
updateControlPoints();
// Invalidate the body
body = null;
@EditableProperty
public Integer getAngle() {
if (angle == null) {
if (orientation != null)
angle = Integer.parseInt(orientation.name().replace("_", ""));
else
angle = 0;
}
return angle;
}
public void setAngle(Integer angle) {
this.angle = angle;
updateControlPoints();
// Invalidate the body
body = null;
}
protected double getTheta() {
return Math.toRadians(getAngle());
}
}
Binary file not shown.
Binary file not shown.
+4
View File
@@ -2590,6 +2590,10 @@
<changeType>NEW_FEATURE</changeType>
<description>Added pinout property to all transistor components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Ability to enter arbitrary angle of rotation for "Open 1/4" Jack" and "Pilot Lamp Holder"</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>When in "Highlight Connected Area" mode, the status bar shows useful information making it harder to forget what the mode does</description>