diff --git a/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java b/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java index 9b7d9f9b..8b2ee7d4 100644 --- a/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java +++ b/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java @@ -297,5 +297,9 @@ public abstract class AbstractComponent implements IDIYComponent { public String[] getSectionNames(int pointIndex) { return null; } - + + @Override + public String getCommonPointName(int pointIndex) { + return null; + } } diff --git a/diylc/diylc-core/src/org/diylc/core/IDIYComponent.java b/diylc/diylc-core/src/org/diylc/core/IDIYComponent.java index ff1dafb9..bf4ea1cc 100644 --- a/diylc/diylc-core/src/org/diylc/core/IDIYComponent.java +++ b/diylc/diylc-core/src/org/diylc/core/IDIYComponent.java @@ -131,11 +131,17 @@ public interface IDIYComponent extends Serializable { String getInternalLinkName(int index1, int index2); /** - * @param pointIndex name of the internal section containing the specified point, or null if the component does not have internal sections. - * One point can be shared between multiple sections, in which case, the result may contain more than one element. - * @return + * @param pointIndex + * @return name of the internal section containing the specified point, or null if the component does not have internal sections. + * One point can be shared between multiple sections, in which case, the result may contain more than one element. */ - String[] getSectionNames(int pointIndex); + String[] getSectionNames(int pointIndex); + + /** + * @param pointIndex + * @return name of the common point that joins all the other points with the same name together, e.g. GND + */ + String getCommonPointName(int pointIndex); /** * Draws the component onto the {@link Graphics2D}. diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java index 84edacc4..17fa3baa 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java +++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java @@ -2824,10 +2824,14 @@ public class Presenter implements IPlugInPort { Point2D point1 = node1.getComponent().getControlPoint(node1.getPointIndex()); Point2D point2 = node2.getComponent().getControlPoint(node2.getPointIndex()); + String commonPoint1 = node1.getComponent().getCommonPointName(node1.getPointIndex()); + String commonPoint2 = node2.getComponent().getCommonPointName(node2.getPointIndex()); + // try both directions if (point1.distance(point2) < t || checkGraphConnection(point1, point2, connections, continuityAreas, new boolean[connections.size()]) || - checkGraphConnection(point2, point1, connections, continuityAreas, new boolean[connections.size()])) { + checkGraphConnection(point2, point1, connections, continuityAreas, new boolean[connections.size()]) || + (commonPoint1 != null && commonPoint1.equalsIgnoreCase(commonPoint2))) { boolean added = false; // add to an existing vertex if possible for (Group g : netlist.getGroups()) diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index 22b94dad..f4b9dd04 100644 Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ diff --git a/diylc/diylc-library/src/org/diylc/components/misc/GroundSymbol.java b/diylc/diylc-library/src/org/diylc/components/misc/GroundSymbol.java index 83fd540b..fc4211d3 100644 --- a/diylc/diylc-library/src/org/diylc/components/misc/GroundSymbol.java +++ b/diylc/diylc-library/src/org/diylc/components/misc/GroundSymbol.java @@ -139,6 +139,11 @@ public class GroundSymbol extends AbstractComponent { @Override public String getControlPointNodeName(int index) { return getName(); + } + + @Override + public String getCommonPointName(int pointIndex) { + return "GND"; } @Override diff --git a/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java b/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java index c37442d6..ee195056 100644 --- a/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java +++ b/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java @@ -113,7 +113,7 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer { // output to spice for (int i = 0; i < c.getControlPointCount(); i++) { - sb.append(fill(Integer.toString(nodeIndices[i]), 5)); + sb.append(fill(formatSpiceNode(nodeIndices[i]), 5)); sb.append(" "); } @@ -130,6 +130,10 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer { return new Summary(netlist, sb.toString()); } + private static String formatSpiceNode(int i) { + return String.format("N%03d" , i); + } + private String fill(String source, int desiredLength) { String res = source; for (int i = 0; i < desiredLength - source.length(); i++) diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index 22b94dad..f4b9dd04 100644 Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar index d3c03884..cbb836f9 100644 Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml index 16795141..dbaccca2 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -2620,6 +2620,22 @@ https://github.com/bancika/diy-layout-creator/releases + + + + 3 + 57 + 0 + + 2019-03-10 00:00:00.000 CET + + + + IMPROVEMENT + Output SPICE node names in the "Nxxx" format + + + https://github.com/bancika/diy-layout-creator/releases