From 3ae44ca0400e33a71dce3b7ac0739c6b4f298c04 Mon Sep 17 00:00:00 2001 From: bancika Date: Wed, 15 Apr 2020 10:01:15 +0200 Subject: [PATCH] "Trace Cut" can now be placed horizontally or vertically when "Cut Between Lines" is selected --- .../src/org/diylc/presenter/update.xml | 4 +++ .../components/connectivity/TraceCut.java | 26 +++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/diylc/diylc-core/src/org/diylc/presenter/update.xml b/diylc/diylc-core/src/org/diylc/presenter/update.xml index ba1a6d43..3902e66f 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/update.xml +++ b/diylc/diylc-core/src/org/diylc/presenter/update.xml @@ -2954,6 +2954,10 @@ NEW_FEATURE Transistor components can display pinout instead of name or value + + NEW_FEATURE + "Trace Cut" can now be placed horizontally or vertically when "Cut Between Lines" is selected + IMPROVEMENT Prevent the app from closing while running background operations, like saving and exporting files diff --git a/diylc/diylc-library/src/org/diylc/components/connectivity/TraceCut.java b/diylc/diylc-library/src/org/diylc/components/connectivity/TraceCut.java index 8319873c..0259d70c 100644 --- a/diylc/diylc-library/src/org/diylc/components/connectivity/TraceCut.java +++ b/diylc/diylc-library/src/org/diylc/components/connectivity/TraceCut.java @@ -27,6 +27,7 @@ import java.awt.Point; import java.awt.geom.Rectangle2D; import org.diylc.common.ObjectCache; +import org.diylc.common.OrientationHV; import org.diylc.common.SimpleComponentTransformer; import org.diylc.components.AbstractComponent; import org.diylc.components.boards.AbstractBoard; @@ -63,7 +64,8 @@ public class TraceCut extends AbstractComponent { @Deprecated private Color borderColor = BORDER_COLOR; private Color boardColor = AbstractBoard.BOARD_COLOR; - private Boolean cutBetweenHoles = false; + private Boolean cutBetweenHoles = false; + private OrientationHV orientation = OrientationHV.VERTICAL; private Size holeSpacing = VeroBoard.SPACING; protected Point point = new Point(0, 0); @@ -81,8 +83,11 @@ public class TraceCut extends AbstractComponent { int holeSpacing = getClosestOdd(getHoleSpacing().convertToPixels()); g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR : getBoardColor()); - drawingObserver.startTrackingContinuityArea(false); - g2d.fillRect(point.x - holeSpacing / 2 - cutWidth / 2, point.y - size / 2 - 1, cutWidth, size + 2); + drawingObserver.startTrackingContinuityArea(false); + if (getOrientation() == OrientationHV.VERTICAL) + g2d.fillRect(point.x - holeSpacing / 2 - cutWidth / 2, point.y - size / 2 - 1, cutWidth, size + 2); + else + g2d.fillRect(point.x - size / 2 - 1, point.y - holeSpacing / 2 - cutWidth / 2, size + 2, cutWidth); drawingObserver.stopTrackingContinuityArea(); } else { g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR @@ -193,7 +198,7 @@ public class TraceCut extends AbstractComponent { this.borderColor = borderColor; } - @EditableProperty(name = "Cut between holes") + @EditableProperty(name = "Cut Between Holes") public boolean getCutBetweenHoles() { if (cutBetweenHoles == null) { cutBetweenHoles = false; @@ -217,7 +222,7 @@ public class TraceCut extends AbstractComponent { this.boardColor = boardColor; } - @EditableProperty(name = "Hole spacing") + @EditableProperty(name = "Hole Spacing") public Size getHoleSpacing() { if (holeSpacing == null) { holeSpacing = VeroBoard.SPACING; @@ -227,6 +232,17 @@ public class TraceCut extends AbstractComponent { public void setHoleSpacing(Size holeSpacing) { this.holeSpacing = holeSpacing; + } + + @EditableProperty(name = "Cut Orientation") + public OrientationHV getOrientation() { + if (orientation == null) + orientation = OrientationHV.VERTICAL; + return orientation; + } + + public void setOrientation(OrientationHV orientation) { + this.orientation = orientation; } @Deprecated