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> { public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
private static final double RING_THETA = Math.PI * 0.795; 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 SLEEVE_SWITCHED_THETA = Math.PI * 4 / 3;
private static final double SWITCH_THETA = Math.PI * 5 / 3; private static final double SWITCH_THETA = Math.PI * 5 / 3;
@@ -77,7 +77,9 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
private String value = ""; private String value = "";
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)}; private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
transient Area[] body; transient Area[] body;
@Deprecated
private Orientation orientation = Orientation.DEFAULT; private Orientation orientation = Orientation.DEFAULT;
private Integer angle = 0;
private OpenJackType type = OpenJackType.MONO; private OpenJackType type = OpenJackType.MONO;
private boolean showLabels = true; private boolean showLabels = true;
@@ -86,7 +88,6 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
updateControlPoints(); updateControlPoints();
} }
@SuppressWarnings("incomplete-switch")
@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) {
@@ -162,24 +163,9 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
Point sleeveLabel = new Point(0, 0); Point sleeveLabel = new Point(0, 0);
ringTransform.transform(tipLabel, ringOrSwitchLabel); ringTransform.transform(tipLabel, ringOrSwitchLabel);
sleeveTransform.transform(tipLabel, sleeveLabel); 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) { if (getTheta() != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(theta, controlPoints[0].x, controlPoints[0].y); AffineTransform rotation = AffineTransform.getRotateInstance(getTheta(), controlPoints[0].x, controlPoints[0].y);
rotation.transform(tipLabel, tipLabel); rotation.transform(tipLabel, tipLabel);
rotation.transform(ringOrSwitchLabel, ringOrSwitchLabel); rotation.transform(ringOrSwitchLabel, ringOrSwitchLabel);
rotation.transform(sleeveLabel, sleeveLabel); rotation.transform(sleeveLabel, sleeveLabel);
@@ -195,7 +181,6 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver); drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
} }
@SuppressWarnings("incomplete-switch")
public Area[] getBody() { public Area[] getBody() {
if (body == null) { if (body == null) {
body = new Area[4]; body = new Area[4];
@@ -255,25 +240,9 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
body[3] = ringOrSwitch; body[3] = ringOrSwitch;
} }
double theta = 0;
// Rotate if needed // Rotate if needed
if (orientation != Orientation.DEFAULT) { if (getTheta() != 0) {
switch (orientation) { AffineTransform rotation = AffineTransform.getRotateInstance(getTheta(), x, y);
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);
// Skip the last one because it's already rotated // Skip the last one because it's already rotated
for (int i = 0; i < body.length; i++) { for (int i = 0; i < body.length; i++) {
Shape shape = body[i]; Shape shape = body[i];
@@ -288,7 +257,6 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
return body; return body;
} }
@SuppressWarnings("incomplete-switch")
private void updateControlPoints() { private void updateControlPoints() {
int x = controlPoints[0].x; int x = controlPoints[0].x;
int y = controlPoints[0].y; 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]); AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY).transform(controlPoints[0], controlPoints[2]);
// Rotate if needed // Rotate if needed
if (orientation != Orientation.DEFAULT) { if (getTheta() != 0) {
double theta = 0; AffineTransform rotation = AffineTransform.getRotateInstance(getTheta(), x, y);
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);
for (Point point : controlPoints) { for (Point point : controlPoints) {
rotation.transform(point, point); rotation.transform(point, point);
} }
@@ -388,17 +344,27 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
} }
@EditableProperty @EditableProperty
public Orientation getOrientation() { public Integer getAngle() {
return orientation; if (angle == null) {
if (orientation != null)
angle = Integer.parseInt(orientation.name().replace("_", ""));
else
angle = 0;
}
return angle;
} }
public void setOrientation(Orientation orientation) { public void setAngle(Integer angle) {
this.orientation = orientation; this.angle = angle;
updateControlPoints(); updateControlPoints();
// Invalidate the body // Invalidate the body
body = null; body = null;
} }
protected double getTheta() {
return Math.toRadians(getAngle());
}
@EditableProperty @EditableProperty
public OpenJackType getType() { public OpenJackType getType() {
return type; return type;
@@ -61,6 +61,8 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
private static Color BASE_COLOR = Color.lightGray; 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 THREAD_OUTER_DIAMETER = new Size(11 / 16d, SizeUnit.in);
private static Size NUT_DIAMETER = new Size(14 / 16d, SizeUnit.in); private static Size NUT_DIAMETER = new Size(14 / 16d, SizeUnit.in);
private static Size THREAD_THICKNESS = new Size(0.05d, SizeUnit.in); private static Size THREAD_THICKNESS = new Size(0.05d, SizeUnit.in);
@@ -76,7 +78,9 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
private String value = ""; private String value = "";
private Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) }; private Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) };
transient Area[] body; transient Area[] body;
@Deprecated
private Orientation orientation = Orientation.DEFAULT; private Orientation orientation = Orientation.DEFAULT;
private Integer angle = 0;
public PilotLampHolder() { public PilotLampHolder() {
super(); super();
@@ -154,7 +158,6 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver); drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
} }
@SuppressWarnings("incomplete-switch")
public Area[] getBody() { public Area[] getBody() {
if (body == null) { if (body == null) {
body = new Area[6]; body = new Area[6];
@@ -191,7 +194,7 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
Area sleeve = Area sleeve =
new Area(new RoundRectangle2D.Double(x - springWidth / 2, y - holeToEdge, springWidth, springLength, new Area(new RoundRectangle2D.Double(x - springWidth / 2, y - holeToEdge, springWidth, springLength,
springWidth, springWidth)); 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.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))); sleeve.subtract(new Area(new Ellipse2D.Double(x - innerDiameter / 2, centerY - innerDiameter / 2, innerDiameter, innerDiameter)));
@@ -232,24 +235,8 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
nut.subtract(link); nut.subtract(link);
thread.subtract(link); thread.subtract(link);
double theta = 0; if (getTheta() != 0) {
// Rotate if needed AffineTransform rotation = AffineTransform.getRotateInstance(getTheta(), x, y);
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, x, y);
for (Area area : body) { for (Area area : body) {
if (area != null) if (area != null)
area.transform(rotation); area.transform(rotation);
@@ -264,7 +251,6 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
return body; return body;
} }
@SuppressWarnings("incomplete-switch")
private void updateControlPoints() { private void updateControlPoints() {
int x = controlPoints[0].x; int x = controlPoints[0].x;
int y = controlPoints[0].y; int y = controlPoints[0].y;
@@ -283,20 +269,8 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
rotation.transform(controlPoints[2], controlPoints[3]); rotation.transform(controlPoints[2], controlPoints[3]);
// Rotate if needed // Rotate if needed
if (orientation != Orientation.DEFAULT) { if (getTheta() != 0) {
double theta = 0; rotation = AffineTransform.getRotateInstance(getTheta(), x, y);
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);
for (Point point : controlPoints) { for (Point point : controlPoints) {
rotation.transform(point, point); rotation.transform(point, point);
} }
@@ -413,14 +387,24 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
} }
@EditableProperty @EditableProperty
public Orientation getOrientation() { public Integer getAngle() {
return orientation; if (angle == null) {
if (orientation != null)
angle = Integer.parseInt(orientation.name().replace("_", ""));
else
angle = 0;
}
return angle;
} }
public void setOrientation(Orientation orientation) { public void setAngle(Integer angle) {
this.orientation = orientation; this.angle = angle;
updateControlPoints(); updateControlPoints();
// Invalidate the body // Invalidate the body
body = null; 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> <changeType>NEW_FEATURE</changeType>
<description>Added pinout property to all transistor components</description> <description>Added pinout property to all transistor components</description>
</org.diylc.appframework.update.Change> </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> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <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> <description>When in "Highlight Connected Area" mode, the status bar shows useful information making it harder to forget what the mode does</description>