fix IC pin alignment issue

This commit is contained in:
bancika
2017-04-20 15:25:17 +02:00
parent b3d63e9f22
commit d65609b3d2
8 changed files with 30 additions and 25 deletions
@@ -438,7 +438,8 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
public void setStroke(Stroke s) { public void setStroke(Stroke s) {
if (this.zoom > 1 && s.getClass() == BasicStroke.class) { if (this.zoom > 1 && s.getClass() == BasicStroke.class) {
BasicStroke bs = (BasicStroke) s; BasicStroke bs = (BasicStroke) s;
if (bs.getLineWidth() == 1) // make thin lines even thinner to compensate for zoom factor
if (bs.getLineWidth() <= 2)
s = ObjectCache.getInstance().fetchBasicStroke((float) (bs.getLineWidth() / zoom)); s = ObjectCache.getInstance().fetchBasicStroke((float) (bs.getLineWidth() / zoom));
} }
canvasGraphics.setStroke(s); canvasGraphics.setStroke(s);
Binary file not shown.
@@ -178,13 +178,13 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
Point firstPoint = controlPoints[0]; Point firstPoint = controlPoints[0];
controlPoints = new Point[pinCount.getValue()]; controlPoints = new Point[pinCount.getValue()];
controlPoints[0] = firstPoint; controlPoints[0] = firstPoint;
int pinSpacing = (int) this.pinSpacing.convertToPixels(); double pinSpacing = this.pinSpacing.convertToPixels();
int rowSpacing = (int) this.rowSpacing.convertToPixels(); double rowSpacing = this.rowSpacing.convertToPixels();
// Update control points. // Update control points.
int dx1; double dx1;
int dy1; double dy1;
int dx2; double dx2;
int dy2; double dy2;
for (int i = 0; i < pinCount.getValue() / 2; i++) { for (int i = 0; i < pinCount.getValue() / 2; i++) {
switch (orientation) { switch (orientation) {
case DEFAULT: case DEFAULT:
@@ -214,21 +214,21 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
default: default:
throw new RuntimeException("Unexpected orientation: " + orientation); throw new RuntimeException("Unexpected orientation: " + orientation);
} }
controlPoints[i] = new Point(firstPoint.x + dx1, firstPoint.y + dy1); controlPoints[i] = new Point((int) (firstPoint.x + dx1), (int) (firstPoint.y + dy1));
controlPoints[i + pinCount.getValue() / 2] = new Point(firstPoint.x + dx2, firstPoint.y + dy2); controlPoints[i + pinCount.getValue() / 2] = new Point((int) (firstPoint.x + dx2), (int) (firstPoint.y + dy2));
} }
} }
public Area[] getBody() { public Area[] getBody() {
if (body == null) { if (body == null) {
body = new Area[2]; body = new Area[2];
int x = controlPoints[0].x; double x = controlPoints[0].x;
int y = controlPoints[0].y; double y = controlPoints[0].y;
int width; double width;
int height; double height;
int pinSize = (int) PIN_SIZE.convertToPixels(); double pinSize = PIN_SIZE.convertToPixels();
int pinSpacing = (int) this.pinSpacing.convertToPixels(); double pinSpacing = this.pinSpacing.convertToPixels();
int rowSpacing = (int) this.rowSpacing.convertToPixels(); double rowSpacing = this.rowSpacing.convertToPixels();
Area indentation = null; Area indentation = null;
int indentationSize = getClosestOdd(INDENT_SIZE.convertToPixels()); int indentationSize = getClosestOdd(INDENT_SIZE.convertToPixels());
switch (orientation) { switch (orientation) {
@@ -164,10 +164,10 @@ public class SIL_IC extends AbstractTransparentComponent<String> {
Point firstPoint = controlPoints[0]; Point firstPoint = controlPoints[0];
controlPoints = new Point[pinCount.getValue()]; controlPoints = new Point[pinCount.getValue()];
controlPoints[0] = firstPoint; controlPoints[0] = firstPoint;
int pinSpacing = (int) this.pinSpacing.convertToPixels(); double pinSpacing = this.pinSpacing.convertToPixels();
// Update control points. // Update control points.
int dx1; double dx1;
int dy1; double dy1;
for (int i = 0; i < pinCount.getValue(); i++) { for (int i = 0; i < pinCount.getValue(); i++) {
switch (orientation) { switch (orientation) {
case DEFAULT: case DEFAULT:
@@ -189,7 +189,7 @@ public class SIL_IC extends AbstractTransparentComponent<String> {
default: default:
throw new RuntimeException("Unexpected orientation: " + orientation); throw new RuntimeException("Unexpected orientation: " + orientation);
} }
controlPoints[i] = new Point(firstPoint.x + dx1, firstPoint.y + dy1); controlPoints[i] = new Point((int) (firstPoint.x + dx1), (int) (firstPoint.y + dy1));
} }
} }
@@ -199,9 +199,9 @@ public class SIL_IC extends AbstractTransparentComponent<String> {
int x = controlPoints[0].x; int x = controlPoints[0].x;
int y = controlPoints[0].y; int y = controlPoints[0].y;
int thickness = getClosestOdd(THICKNESS.convertToPixels()); int thickness = getClosestOdd(THICKNESS.convertToPixels());
int width; double width;
int height; double height;
int pinSpacing = (int) this.pinSpacing.convertToPixels(); double pinSpacing = (int) this.pinSpacing.convertToPixels();
Area indentation = null; Area indentation = null;
int indentationSize = getClosestOdd(INDENT_SIZE.convertToPixels()); int indentationSize = getClosestOdd(INDENT_SIZE.convertToPixels());
switch (orientation) { switch (orientation) {
Binary file not shown.
Binary file not shown.
+5 -1
View File
@@ -1704,7 +1704,11 @@
<changes> <changes>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>Red ticks on both rulers track selection bounds, blue tick tracks cursor position</description> <description>Red ticks on both rulers mark selection bounds, blue tick tracks cursor position</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<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>
</changes> </changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url> <url>https://github.com/bancika/diy-layout-creator/releases</url>