fix resistor changing shape

This commit is contained in:
bancika
2017-04-24 10:48:24 +02:00
parent 87e0997377
commit 4f0018d655
3 changed files with 8 additions and 4 deletions
@@ -136,7 +136,7 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
@Override @Override
protected Shape getBodyShape() { protected Shape getBodyShape() {
if (shape == ResistorShape.Standard) { if (getShape() == ResistorShape.Standard) {
double length = getLength().convertToPixels(); double length = getLength().convertToPixels();
double width = getClosestOdd(getWidth().convertToPixels()); double width = getClosestOdd(getWidth().convertToPixels());
Rectangle2D rect = new Rectangle2D.Double(width / 2, width / 10, length - width, width * 8 / 10); Rectangle2D rect = new Rectangle2D.Double(width / 2, width / 10, length - width, width * 8 / 10);
@@ -155,7 +155,7 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
return; return;
} }
int width = getClosestOdd(getWidth().convertToPixels()); int width = getClosestOdd(getWidth().convertToPixels());
if (shape == ResistorShape.Standard) { if (getShape() == ResistorShape.Standard) {
int x = width + FIRST_BAND; int x = width + FIRST_BAND;
Color[] bands = value.getColorCode(colorCode); Color[] bands = value.getColorCode(colorCode);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2)); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
@@ -184,7 +184,7 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
int width = getClosestOdd(getWidth().convertToPixels()); int width = getClosestOdd(getWidth().convertToPixels());
Color[] bands = value.getColorCode(colorCode); Color[] bands = value.getColorCode(colorCode);
int bandArea = int bandArea =
shape == ResistorShape.Standard ? width + FIRST_BAND + BAND_SPACING * (bands.length - 1) : -FIRST_BAND getShape() == ResistorShape.Standard ? width + FIRST_BAND + BAND_SPACING * (bands.length - 1) : -FIRST_BAND
+ BAND_SPACING * (bands.length - 1); + BAND_SPACING * (bands.length - 1);
return (bodyWidth - bandArea - labelWidth) / 2; return (bodyWidth - bandArea - labelWidth) / 2;
Binary file not shown.
+5 -1
View File
@@ -1716,7 +1716,7 @@
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Solder Pad and Copper Trace size shouldn't be rounded up or down to the nearest integer to allow better precision</description> <description>Improve precision for Solder Pad and Copper Trace by not rounding the size up or down</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
@@ -1730,6 +1730,10 @@
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Issues with DIL and SIL IC pin alignment when using metric grid and pin spacing</description> <description>Issues with DIL and SIL IC pin alignment when using metric grid and pin spacing</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Resistor changes shape on its own</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>