Merge branch 'master' into schem-view

This commit is contained in:
Bane Stojkovic
2026-09-29 12:43:14 +02:00
28 changed files with 770 additions and 102 deletions
-2
View File
@@ -24,8 +24,6 @@ It provides an intuitive, drag-and-drop interface for placing components, arrang
The **Official DIYLC Guide (v1.0)** is a comprehensive 174-page eBook that goes way beyond the basics. It features step-by-step design workflows for everything from multi-layer PCBs to hot-rodded point-to-point tube amps. Learn to master advanced tools like the Virtual Multimeter, Netlist generation, the Guitar Wiring Analyzer, and the new AI Assistant.
🎉 **Launch Special:** Get **40% off** during our 14-day introductory sale! Buying v1.0 guarantees you free lifetime updates as the app evolves.
👉 **[Click here to grab your copy!](https://www.diy-fever.com/diylc-book)**
*Active Patreon supporters get an additional 50% off or a completely free copy. Check the [Patreon feed](https://www.patreon.com/c/user?u=5213116) for your VIP link!*
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>org.diylc</groupId>
<artifactId>diylc-parent</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</parent>
<artifactId>diylc-core</artifactId>
@@ -295,9 +295,39 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
}
@Override
public boolean canPointMoveFreely(int pointIndex) {
public boolean canPointMoveFreely(int pointIndex) {
return true;
}
@Override
public void stretchBetween(Point2D first, Point2D second) {
int count = getControlPointCount();
// fresh instances because implementations are free to keep the point objects they are handed
setControlPoint(new Point2D.Double(first.getX(), first.getY()), 0);
if (count > 1) {
setControlPoint(new Point2D.Double(second.getX(), second.getY()), count - 1);
}
for (int i = 1; i < count - 1; i++) {
setControlPoint(getStretchedPoint(first, second, i), i);
}
}
/**
* Decides where a control point that is neither of the two ends lands when the component is
* stretched between them, see {@link #stretchBetween(Point2D, Point2D)}. The default spaces the
* points evenly along the straight line joining the ends. Override to place a point that carries
* a meaning of its own, such as one that positions a label.
*
* @param first
* @param second
* @param index
* @return position of the control point at the specified index.
*/
protected Point2D getStretchedPoint(Point2D first, Point2D second, int index) {
double t = (double) index / (getControlPointCount() - 1);
return new Point2D.Double(first.getX() + t * (second.getX() - first.getX()),
first.getY() + t * (second.getY() - first.getY()));
}
@Override
public Rectangle2D getCachingBounds() {
@@ -52,6 +52,7 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
public static Color GUIDELINE_COLOR = Color.blue;
public static Size DEFAULT_SIZE = new Size(1d, SizeUnit.in);
public static double CREATION_CURVATURE = 0.1;
// for backward compatibility
protected Point2D[] controlPoints = null;
@@ -287,6 +288,72 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
// }
}
/**
* Waves the curve from side to side instead of leaving the intermediate points on the straight
* line joining the ends, so that a freshly created component reads as a slack wire that can be
* reshaped rather than as a rigid line. Successive handles go to opposite sides, which turns the
* default four point curve into an S, while the points that lie on the curve itself stay on the
* straight line and the sine envelope fades the excursions out towards both ends. The first
* excursion always points down the screen so that the shape does not depend on which end was
* drawn first.
* <p>
* Keeping the on-curve points on the line is what makes the wave survive: a handle either side
* of one of them then comes out as its exact mirror, which is the continuity rule that the
* smoothing in {@link #draw} enforces, so that pass leaves the shape alone instead of pulling
* one handle across to satisfy it.
*/
@Override
protected Point2D getStretchedPoint(Point2D first, Point2D second, int index) {
Point2D p = super.getStretchedPoint(first, second, index);
double dx = second.getX() - first.getX();
double dy = second.getY() - first.getY();
double length = Math.hypot(dx, dy);
if (length == 0 || isOnCurve(index)) {
return p;
}
if (dx < 0 || (dx == 0 && dy > 0)) {
dx = -dx;
dy = -dy;
}
double t = (double) index / (getControlPointCount() - 1);
double offset = getStretchedSide(index) * CREATION_CURVATURE * length * Math.sin(Math.PI * t);
return new Point2D.Double(p.getX() - dy / length * offset, p.getY() + dx / length * offset);
}
/**
* @param index
* @return true if the control point at the specified index lies on the curve rather than pulling
* it from the side, which follows from how {@link #draw} chains the segments together.
*/
private boolean isOnCurve(int index) {
if (index == 0 || index == getControlPointCount() - 1) {
return true;
}
if (getPointCount() == PointCount.FIVE) {
return index == 2;
}
if (getPointCount() == PointCount.SEVEN) {
return index == 3;
}
return false;
}
/**
* @param index
* @return which side of the straight line the handle at the specified index is pushed to,
* counting handles rather than control points so that an on-curve point in between does
* not break the alternation.
*/
private int getStretchedSide(int index) {
int handleCount = 0;
for (int i = 1; i < index; i++) {
if (!isOnCurve(i)) {
handleCount++;
}
}
return handleCount % 2 == 0 ? 1 : -1;
}
private Point2D findThirdPoint(Point2D p0, Point2D p) {
return new Point2D.Double(2 * p0.getX() - p.getX(), 2 * p0.getY() - p.getY());
}
@@ -237,24 +237,40 @@ public abstract class AbstractOrthogonalComponent<T> extends AbstractTransparent
newPoints[0] = start;
newPoints[pointCount.count - 1] = end;
// spread the bend points so that the route comes out as an even staircase: they advance evenly
// along the axis the route travels last, and sit halfway between those steps on the other axis
int bendCount = pointCount.count - 2;
boolean horizontalFirst = getStartDirection() == OrientationHV.HORIZONTAL;
for (int i = 1; i <= bendCount; i++) {
double along = (double) i / bendCount;
double across = (2d * i - 1) / (2d * bendCount);
double tx = horizontalFirst ? across : along;
double ty = horizontalFirst ? along : across;
newPoints[i] =
new Point2D.Double(start.getX() + (end.getX() - start.getX()) * tx, start.getY()
+ (end.getY() - start.getY()) * ty);
newPoints[i] = getBendPoint(start, end, i, bendCount);
}
this.controlPoints = newPoints;
this.pointCount = pointCount;
}
@Override
protected Point2D getStretchedPoint(Point2D first, Point2D second, int index) {
return getBendPoint(first, second, index, getControlPointCount() - 2);
}
/**
* Spreads the bend points so that the route comes out as an even staircase: they advance evenly
* along the axis the route travels last, and sit halfway between those steps on the other axis.
*
* @param start
* @param end
* @param index
* @param bendCount number of control points between the two ends
* @return position of the bend point at the specified index.
*/
private Point2D getBendPoint(Point2D start, Point2D end, int index, int bendCount) {
double along = (double) index / bendCount;
double across = (2d * index - 1) / (2d * bendCount);
boolean horizontalFirst = getStartDirection() == OrientationHV.HORIZONTAL;
double tx = horizontalFirst ? across : along;
double ty = horizontalFirst ? along : across;
return new Point2D.Double(start.getX() + (end.getX() - start.getX()) * tx, start.getY()
+ (end.getY() - start.getY()) * ty);
}
/**
* Not an editable property on purpose. Every route shape is reachable by dragging the bend
* points, so exposing this would only give the user a second, less discoverable way to do the
@@ -28,8 +28,12 @@ import java.awt.Stroke;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.diylc.components.AbstractComponent;
import org.diylc.components.AbstractTransparentComponent;
@@ -83,6 +87,7 @@ public class CompositeComponent extends AbstractTransparentComponent<String> {
// serialized (transient).
private transient int[] childOf;
private transient int[] pointOf;
private transient String[] nodeNameOf;
/**
* Required no-arg constructor, used reflectively by {@code ComponentProcessor} and XStream.
@@ -111,8 +116,77 @@ public class CompositeComponent extends AbstractTransparentComponent<String> {
idx++;
}
}
childOf = newChildOf;
nodeNameOf = buildNodeNames(newChildOf, newPointOf);
pointOf = newPointOf;
// assigned last, it is what marks the index as built
childOf = newChildOf;
}
/**
* Resolves the node names the composite exposes. A child's own node name is kept unchanged
* whenever it is unique, so the pads of a custom board read "VCC" rather than "Pad3.VCC" - the
* pad's component name is an arbitrary leftover from the project the block was saved in.
* Clashing names are resolved in two passes: pins of multi-point children are qualified with the
* child's name ("R1.1", "R2.1"), then whatever still clashes, typically several pads sharing a
* name, gets a numeric suffix in save order ("GND_1", "GND_2").
*
* <p>Only sticky, named points take part. Non-sticky points never become netlist nodes, and a
* board's corner points would otherwise force a rename on a pad that shares their default
* numeric name.
*/
private String[] buildNodeNames(int[] newChildOf, int[] newPointOf) {
String[] names = new String[newChildOf.length];
boolean[] terminal = new boolean[newChildOf.length];
for (int i = 0; i < names.length; i++) {
IDIYComponent<?> child = childComponents.get(newChildOf[i]);
names[i] = child.getControlPointNodeName(newPointOf[i]);
terminal[i] = names[i] != null && child.isControlPointSticky(newPointOf[i]);
}
Set<String> clashing = findClashingNames(names, terminal);
for (int i = 0; i < names.length; i++) {
IDIYComponent<?> child = childComponents.get(newChildOf[i]);
String childName = child.getName();
if (terminal[i] && clashing.contains(names[i]) && child.getControlPointCount() > 1
&& childName != null && !childName.trim().isEmpty()) {
names[i] = childName.trim() + "." + names[i];
}
}
clashing = findClashingNames(names, terminal);
if (clashing.isEmpty()) {
return names;
}
Set<String> taken = new HashSet<String>();
for (int i = 0; i < names.length; i++) {
if (terminal[i] && !clashing.contains(names[i])) {
taken.add(names[i]);
}
}
Map<String, Integer> nextSuffix = new HashMap<String, Integer>();
for (int i = 0; i < names.length; i++) {
if (terminal[i] && clashing.contains(names[i])) {
int suffix = nextSuffix.getOrDefault(names[i], 1);
while (taken.contains(names[i] + "_" + suffix)) {
suffix++;
}
nextSuffix.put(names[i], suffix + 1);
names[i] = names[i] + "_" + suffix;
taken.add(names[i]);
}
}
return names;
}
private static Set<String> findClashingNames(String[] names, boolean[] terminal) {
Set<String> seen = new HashSet<String>();
Set<String> clashing = new HashSet<String>();
for (int i = 0; i < names.length; i++) {
if (terminal[i] && !seen.add(names[i])) {
clashing.add(names[i]);
}
}
return clashing;
}
/**
@@ -179,7 +253,7 @@ public class CompositeComponent extends AbstractTransparentComponent<String> {
@Override
public String getControlPointNodeName(int index) {
buildIndexIfNeeded();
return childComponents.get(childOf[index]).getControlPointNodeName(pointOf[index]);
return nodeNameOf[index];
}
/**
@@ -105,6 +105,17 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
*/
void setControlPoint(Point2D point, int index);
/**
* Positions the component so that it spans the two points, which is how components created with
* <code>CreationMethod.POINT_BY_POINT</code> are shaped while the user is placing them. The first
* and the last control point go to the two ends; where the points in between land is up to the
* component.
*
* @param first
* @param second
*/
void stretchBetween(Point2D first, Point2D second);
/**
* @param index
* @return true, if the specified control point may stick to control points of other components.
@@ -164,10 +164,10 @@ public class BuildingBlockManager {
return clones;
}
// COMPOSITE mode: clone components keeping their saved names. Those names are namespaced
// under the composite's own name in the netlist (e.g. "ARD1.PH1.3"), so running them through
// createUniqueName against the whole project would produce meaningless drift and break
// netlist labels between two instances of the same block.
// COMPOSITE mode: clone components keeping their saved names. Those names surface in the
// composite's terminal names when pins clash (e.g. "BLK1.R1.1"), so running them through
// createUniqueName against the whole project would produce meaningless drift and make two
// instances of the same block resolve different netlist labels.
List<IDIYComponent<?>> childClones = new ArrayList<IDIYComponent<?>>();
for (IDIYComponent<?> c : components) {
try {
@@ -123,23 +123,21 @@ public class InstantiationManager {
firstControlPoint = scaledPoint;
componentSlot = instantiateComponent(componentTypeSlot, firstControlPoint, currentProject);
// Set the other control point to the same location, we'll
// move it later when mouse moves.
componentSlot.get(0).setControlPoint(firstControlPoint, 0);
componentSlot.get(0).setControlPoint(firstControlPoint, 1);
// Collapse the component onto the first point, we'll stretch it later when mouse moves.
componentSlot.get(0).stretchBetween(firstControlPoint, firstControlPoint);
}
/**
* Updates component in the slot with the new second control point.
*
* Updates component in the slot with the new end control point.
*
* @param scaledPoint
* @return true, if any change is made
*/
public boolean updatePointByPoint(Point2D scaledPoint) {
boolean changeMade = !scaledPoint.equals(potentialControlPoint);
potentialControlPoint = scaledPoint;
if (componentSlot != null && !componentSlot.isEmpty()) {
componentSlot.get(0).setControlPoint(scaledPoint, 1);
if (componentSlot != null && !componentSlot.isEmpty() && firstControlPoint != null) {
componentSlot.get(0).stretchBetween(firstControlPoint, scaledPoint);
}
return changeMade;
}
@@ -667,11 +667,16 @@ public class Presenter implements IPlugInPort {
private void addPendingComponentsToProject(Point2D scaledPoint, ComponentType componentTypeSlot, Template template, String[] model,
Project oldProject) {
List<IDIYComponent<?>> componentSlot = instantiationManager.getComponentSlot();
Point2D firstPoint = componentSlot.get(0).getControlPoint(0);
// don't allow to create component with the same points
if (scaledPoint == null || scaledPoint.equals(firstPoint))
if (scaledPoint == null) {
return;
// componentSlot.get(0).setControlPoint(scaledPoint, 1);
}
// A slot with no first control point was instantiated up front and already carries its default
// shape, so it legitimately lands with the first control point under the cursor. Only reject a
// degenerate component when the user is placing it point by point.
boolean instantiatedUpFront = instantiationManager.getFirstControlPoint() == null;
if (!instantiatedUpFront && scaledPoint.equals(componentSlot.get(0).getControlPoint(0))) {
return;
}
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>();
for (IDIYComponent<?> component : componentSlot) {
addComponent(component, true);
@@ -691,7 +696,7 @@ public class Presenter implements IPlugInPort {
editSelection();
}
if (configManager.readBoolean(IPlugInPort.CONTINUOUS_CREATION_KEY, false)) {
setNewComponentTypeSlot(componentTypeSlot, template, model, false);
setNewComponentTypeSlot(componentTypeSlot, template, model, instantiatedUpFront);
} else {
setNewComponentTypeSlot(null, null, null, false);
}
@@ -844,16 +849,17 @@ public class Presenter implements IPlugInPort {
} else if (isSnapToObjects()) {
CalcUtils.snapPointToObjects(previousScaledPoint, currentProject.getGridSpacing(), null, currentProject.getComponents());
}
boolean refresh = false;
switch (instantiationManager.getComponentTypeSlot().getCreationMethod()) {
case POINT_BY_POINT:
refresh = instantiationManager.updatePointByPoint(previousScaledPoint);
break;
case SINGLE_CLICK:
refresh =
instantiationManager.updateSingleClick(previousScaledPoint, isSnapToGrid(),
currentProject.getGridSpacing());
break;
// What the cursor does is decided by how the slot was armed rather than by the creation
// method: a slot instantiated up front carries a whole component that follows the cursor,
// while a point-by-point slot only stretches once the first point has been clicked.
boolean refresh;
if (instantiationManager.getComponentSlot() != null
&& instantiationManager.getFirstControlPoint() == null) {
refresh =
instantiationManager.updateSingleClick(previousScaledPoint, isSnapToGrid(),
currentProject.getGridSpacing());
} else {
refresh = instantiationManager.updatePointByPoint(previousScaledPoint);
}
if (refresh) {
messageDispatcher.dispatchMessage(EventType.REPAINT);
+13 -1
View File
@@ -474,13 +474,25 @@
<minor>6</minor>
<build>0</build>
</versionNumber>
<releaseDate>2026-09-11 00:00:00.000 CET</releaseDate>
<releaseDate>2026-09-29 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added 'Right Angle Wire' and 'Right Angle Line' components that route between two points using only horizontal and vertical runs with rounded corners</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Double click on a component type in the tree or the toolbar to instantiate it at once, even for those that are intended to be placed point-by-point</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>All curved components ('Curved Trace', 'Hookup Wire', 'Twisted Leads') are now getting created between the two points by default instead of getting created with some preset shape and length</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Improve terminal node naming within building blocks to ensure no duplicates by adding a name of the nested component as a prefix</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
@@ -0,0 +1,201 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2025 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.components;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import org.junit.Test;
import org.diylc.components.AbstractCurvedComponent.PointCount;
import org.diylc.core.ComponentState;
import org.diylc.core.IDrawingObserver;
public class AbstractCurvedComponentTest {
private static final double DELTA = 1e-6;
@Test
public void stretchBetween_putsTheEndsExactlyOnTheSuppliedPoints() {
CurvedTestComponent c = new CurvedTestComponent();
c.stretchBetween(new Point2D.Double(10, 20), new Point2D.Double(110, 20));
assertPoint(10, 20, c.getControlPoint(0));
assertPoint(110, 20, c.getControlPoint(3));
}
@Test
public void stretchBetween_movesTheIntermediatePointsOffTheChord() {
CurvedTestComponent c = new CurvedTestComponent();
c.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 0));
assertTrue("first handle should not sit on the chord",
Math.abs(c.getControlPoint(1).getY()) > 1);
assertTrue("second handle should not sit on the chord",
Math.abs(c.getControlPoint(2).getY()) > 1);
}
@Test
public void stretchBetween_putsConsecutivePointsOnOppositeSides() {
CurvedTestComponent c = new CurvedTestComponent();
c.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 0));
assertTrue("the first excursion should point down the screen", c.getControlPoint(1).getY() > 0);
assertTrue("the second excursion should point the other way", c.getControlPoint(2).getY() < 0);
}
@Test
public void stretchBetween_alternatesSidesForEveryPointCount() {
for (PointCount pointCount : PointCount.values()) {
CurvedTestComponent c = new CurvedTestComponent();
c.setPointCount(pointCount);
c.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 0));
double previous = 0;
for (int i = 1; i < c.getControlPointCount() - 1; i++) {
double current = c.getControlPoint(i).getY();
// points that lie on the curve stay on the chord and do not take part in the alternation
if (Math.abs(current) < DELTA) {
continue;
}
if (previous != 0) {
assertTrue(pointCount + " handle " + i + " should sit opposite the previous one",
previous * current < 0);
}
previous = current;
}
}
}
@Test
public void stretchBetween_keepsTheOnCurvePointsOnTheStraightLine() {
for (PointCount pointCount : new PointCount[] {PointCount.FIVE, PointCount.SEVEN}) {
CurvedTestComponent c = new CurvedTestComponent();
c.setPointCount(pointCount);
c.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 0));
assertEquals(pointCount + " should keep its middle point on the chord", 0,
c.getControlPoint(middleIndex(pointCount)).getY(), DELTA);
}
}
/**
* The smoothing in {@code draw} mirrors the handles around a point that lies on the curve, and
* rewrites one of them when they are not already mirrored. Placing them mirrored to begin with
* is what keeps that pass from pulling the freshly created wave out of shape.
*/
@Test
public void stretchBetween_placesHandlesTheWayTheSmoothingRuleWants() {
for (PointCount pointCount : new PointCount[] {PointCount.FIVE, PointCount.SEVEN}) {
CurvedTestComponent c = new CurvedTestComponent();
c.setPointCount(pointCount);
c.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 60));
int middle = middleIndex(pointCount);
Point2D before = c.getControlPoint(middle - 1);
Point2D on = c.getControlPoint(middle);
Point2D after = c.getControlPoint(middle + 1);
assertEquals(pointCount + " handles should mirror horizontally", 2 * on.getX() - before.getX(),
after.getX(), DELTA);
assertEquals(pointCount + " handles should mirror vertically", 2 * on.getY() - before.getY(),
after.getY(), DELTA);
}
}
private static int middleIndex(PointCount pointCount) {
return pointCount == PointCount.FIVE ? 2 : 3;
}
@Test
public void stretchBetween_waveIsSymmetricAboutTheMiddle() {
CurvedTestComponent c = new CurvedTestComponent();
c.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 0));
assertEquals(-c.getControlPoint(1).getY(), c.getControlPoint(2).getY(), DELTA);
assertEquals(100 - c.getControlPoint(2).getX(), c.getControlPoint(1).getX(), DELTA);
}
@Test
public void stretchBetween_wavesTheSameWayRegardlessOfDrawingDirection() {
CurvedTestComponent forward = new CurvedTestComponent();
forward.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 0));
CurvedTestComponent backward = new CurvedTestComponent();
backward.stretchBetween(new Point2D.Double(100, 0), new Point2D.Double(0, 0));
for (int i = 1; i < forward.getControlPointCount() - 1; i++) {
assertEquals(forward.getControlPoint(i).getY(), backward.getControlPoint(i).getY(), DELTA);
}
}
@Test
public void stretchBetween_scalesTheWaveWithTheDistance() {
CurvedTestComponent shortWire = new CurvedTestComponent();
shortWire.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(50, 0));
CurvedTestComponent longWire = new CurvedTestComponent();
longWire.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(200, 0));
assertEquals(4 * shortWire.getControlPoint(1).getY(), longWire.getControlPoint(1).getY(), DELTA);
}
@Test
public void stretchBetween_collapsesOntoASinglePointWithoutDividingByZero() {
CurvedTestComponent c = new CurvedTestComponent();
c.stretchBetween(new Point2D.Double(40, 40), new Point2D.Double(40, 40));
for (int i = 0; i < c.getControlPointCount(); i++) {
assertPoint(40, 40, c.getControlPoint(i));
}
}
@Test
public void stretchBetween_keepsTheEndsForEveryPointCount() {
for (PointCount pointCount : PointCount.values()) {
CurvedTestComponent c = new CurvedTestComponent();
c.setPointCount(pointCount);
c.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 60));
assertPoint(0, 0, c.getControlPoint(0));
assertPoint(100, 60, c.getControlPoint(c.getControlPointCount() - 1));
}
}
private static void assertPoint(double x, double y, Point2D actual) {
assertEquals(x, actual.getX(), DELTA);
assertEquals(y, actual.getY(), DELTA);
}
private static class CurvedTestComponent extends AbstractCurvedComponent<Void> {
private static final long serialVersionUID = 1L;
@Override
protected void drawCurve(Path2D curve, Graphics2D g2d, ComponentState componentState,
IDrawingObserver drawingObserver) {}
@Override
protected Color getDefaultColor() {
return Color.black;
}
@Override
public Void getValue() {
return null;
}
@Override
public void setValue(Void value) {}
}
}
@@ -130,6 +130,32 @@ public class AbstractOrthogonalComponentTest {
assertPoint(100, 50, c.getControlPoint(2));
}
// --- stretching ---
@Test
public void stretchBetween_keepsTheEndsAndStaysAxisAligned() {
OrthogonalTestComponent c = component(0, 0, 100, 50, 60, 20);
c.stretchBetween(new Point2D.Double(10, 10), new Point2D.Double(210, 110));
assertPoint(10, 10, c.getControlPoint(0));
assertPoint(210, 110, c.getControlPoint(2));
assertAxisAligned(c);
}
@Test
public void stretchBetween_placesTheBendsWhereSetPointCountWould() {
OrthogonalTestComponent stretched = component(0, 0, 100, 50, 60, 20);
stretched.setPointCount(PointCount.FIVE);
stretched.stretchBetween(new Point2D.Double(0, 0), new Point2D.Double(100, 50));
OrthogonalTestComponent expanded = component(0, 0, 100, 50, 60, 20);
expanded.setPointCount(PointCount.FIVE);
for (int i = 0; i < expanded.getControlPointCount(); i++) {
assertPoint(expanded.getControlPoint(i).getX(), expanded.getControlPoint(i).getY(),
stretched.getControlPoint(i));
}
}
// --- transformer ---
@Test
@@ -24,17 +24,20 @@ package org.diylc.components.composite;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.UUID;
import org.diylc.common.Percentage;
import org.diylc.core.IDIYComponent;
import org.diylc.netlist.Node;
import org.diylc.serialization.ProjectFileManager;
import org.diylc.testcomponents.OnePointTestComponent;
import org.diylc.testcomponents.TwoPointTestComponent;
import org.junit.Test;
@@ -55,6 +58,32 @@ public class CompositeComponentTest {
return composite;
}
private CompositeComponent customBoard(IDIYComponent<?>... children) {
CompositeComponent composite = new CompositeComponent();
composite.setName("BLK1");
composite.initBlockName("Custom Board");
composite.getChildComponents().addAll(Arrays.asList(children));
return composite;
}
private OnePointTestComponent pad(String name, String nodeName) {
return new OnePointTestComponent(name, nodeName, new Point2D.Double(0, 0));
}
// Stands in for a blank board: its corner points keep the default "1" and "2" node names but
// are not sticky.
private TwoPointTestComponent blankBoard() {
TwoPointTestComponent board = new TwoPointTestComponent("Board1", new Point2D.Double(0, 0),
new Point2D.Double(100, 100));
board.setSticky(0, false);
board.setSticky(1, false);
return board;
}
private TwoPointTestComponent twoPoint(String name) {
return new TwoPointTestComponent(name, new Point2D.Double(0, 0), new Point2D.Double(10, 0));
}
@Test
public void controlPointCountIsSumOverChildren() {
CompositeComponent composite = twoChildComposite();
@@ -103,18 +132,94 @@ public class CompositeComponentTest {
}
@Test
public void nodeNamingProducesHierarchicalNetlistLabels() {
// Design decision D3: Node.toString() should read "<composite>.<child>.<local point name>"
public void clashingPinsOfMultiPointChildrenAreQualifiedWithTheChildName() {
CompositeComponent composite = twoChildComposite();
Node r1FirstPoint = new Node(composite, 0);
Node r2FirstPoint = new Node(composite, 2);
Node r2SecondPoint = new Node(composite, 3);
assertEquals("BLK1.1", r1FirstPoint.toString());
assertEquals("BLK1.1", r2FirstPoint.toString());
assertEquals("R1.1", composite.getControlPointNodeName(0));
assertEquals("R1.2", composite.getControlPointNodeName(1));
assertEquals("BLK1.R2.1", new Node(composite, 2).toString());
// local point index must reset per child, not keep growing with the flat composite index
assertEquals("BLK1.2", r2SecondPoint.toString());
assertEquals("BLK1.R2.2", new Node(composite, 3).toString());
}
@Test
public void uniquePadNamesPassThroughWithoutThePadName() {
CompositeComponent composite =
customBoard(blankBoard(), pad("Pad3", "VCC"), pad("Pad7", "SDA"));
assertEquals("VCC", composite.getControlPointNodeName(2));
assertEquals("SDA", composite.getControlPointNodeName(3));
assertEquals("BLK1.VCC", new Node(composite, 2).toString());
}
@Test
public void nonStickyPointsDoNotForceARename() {
CompositeComponent composite = customBoard(blankBoard(), pad("Pad1", "1"));
assertEquals("1", composite.getControlPointNodeName(2));
}
@Test
public void padsSharingANameGetNumericSuffixesInSaveOrder() {
CompositeComponent composite = customBoard(blankBoard(), pad("Pad1", "GND"),
pad("Pad2", "VCC"), pad("Pad3", "GND"), pad("Pad4", "GND"));
assertEquals("GND_1", composite.getControlPointNodeName(2));
assertEquals("VCC", composite.getControlPointNodeName(3));
assertEquals("GND_2", composite.getControlPointNodeName(4));
assertEquals("GND_3", composite.getControlPointNodeName(5));
}
@Test
public void suffixesSkipNamesThatAreAlreadyTaken() {
CompositeComponent composite =
customBoard(pad("Pad1", "GND"), pad("Pad2", "GND_1"), pad("Pad3", "GND"));
assertEquals("GND_2", composite.getControlPointNodeName(0));
assertEquals("GND_1", composite.getControlPointNodeName(1));
assertEquals("GND_3", composite.getControlPointNodeName(2));
}
@Test
public void padClashingWithAPinOfAMultiPointChildKeepsItsName() {
CompositeComponent composite = customBoard(pad("Pad1", "1"), twoPoint("R1"));
assertEquals("1", composite.getControlPointNodeName(0));
assertEquals("R1.1", composite.getControlPointNodeName(1));
assertEquals("2", composite.getControlPointNodeName(2));
}
@Test
public void childrenSharingANameAreStillDistinguished() {
// renaming in the property editor does not enforce uniqueness, so a block can hold two "R1"s
CompositeComponent composite = customBoard(twoPoint("R1"), twoPoint("R1"));
assertEquals("R1.1_1", composite.getControlPointNodeName(0));
assertEquals("R1.2_1", composite.getControlPointNodeName(1));
assertEquals("R1.1_2", composite.getControlPointNodeName(2));
assertEquals("R1.2_2", composite.getControlPointNodeName(3));
}
@Test
public void unnamedPointsAreNotTerminals() {
CompositeComponent composite =
customBoard(pad("Pad1", null), pad("Pad2", null), pad("Pad3", "VCC"));
assertNull(composite.getControlPointNodeName(0));
assertNull(composite.getControlPointNodeName(1));
assertEquals("VCC", composite.getControlPointNodeName(2));
}
@Test
public void instancesOfTheSameBlockResolveIdenticalNames() throws Exception {
CompositeComponent original = customBoard(blankBoard(), pad("Pad1", "GND"),
pad("Pad2", "GND"), twoPoint("R1"), twoPoint("R2"));
CompositeComponent clone = (CompositeComponent) original.clone();
for (int i = 0; i < original.getControlPointCount(); i++) {
assertEquals(original.getControlPointNodeName(i), clone.getControlPointNodeName(i));
}
}
@Test
@@ -204,7 +309,7 @@ public class CompositeComponentTest {
assertEquals(original.getBlockName(), reloaded.getBlockName());
for (int i = 0; i < original.getControlPointCount(); i++)
assertEquals(original.getControlPoint(i), reloaded.getControlPoint(i));
assertEquals("BLK1.2", new Node(reloaded, 3).toString());
assertEquals("BLK1.R2.2", new Node(reloaded, 3).toString());
}
@Test
@@ -0,0 +1,107 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2025 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.testcomponents;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import org.diylc.components.AbstractComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
/**
* Minimal single-point, sticky component with a settable node name, standing in for a solder pad
* or turret when testing how {@code CompositeComponent} resolves the terminal names of a custom
* board. A {@code null} node name marks the point as not being a netlist node, like a pad whose
* Node Name is left blank.
*/
@ComponentDescriptor(name = "One Point Test", category = "Test", author = "Test",
description = "test", instanceNamePrefix = "OP", zOrder = IDIYComponent.COMPONENT)
public class OnePointTestComponent extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L;
private Point2D point;
private String nodeName;
public OnePointTestComponent() {
this("", null, new Point2D.Double(0, 0));
}
public OnePointTestComponent(String name, String nodeName, Point2D point) {
setName(name);
this.nodeName = nodeName;
this.point = point;
}
@Override
public int getControlPointCount() {
return 1;
}
@Override
public Point2D getControlPoint(int index) {
return point;
}
@Override
public void setControlPoint(Point2D point, int index) {
this.point = point;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.ALWAYS;
}
@Override
public String getControlPointNodeName(int index) {
return nodeName;
}
@Override
public Void getValue() {
return null;
}
@Override
public void setValue(Void value) {
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>org.diylc</groupId>
<artifactId>diylc-parent</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</parent>
<artifactId>diylc-library</artifactId>
@@ -33,6 +33,7 @@ import org.diylc.components.AbstractLeadedComponent;
import org.diylc.components.LineEndingStyle;
import org.diylc.components.transform.SimpleComponentTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.ILayeredComponent;
@@ -50,7 +51,7 @@ import org.diylc.core.measures.SizeUnit;
instanceNamePrefix = "Trace", description = "Curved copper trace with two control points",
zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class,
enableCache = true)
enableCache = true, creationMethod = CreationMethod.POINT_BY_POINT)
public class CurvedTrace extends AbstractCurvedComponent<Void> implements ILayeredComponent, IGerberComponentSimple {
private static final long serialVersionUID = 1L;
@@ -30,6 +30,7 @@ import org.diylc.common.ObjectCache;
import org.diylc.components.AbstractCurvedComponent;
import org.diylc.components.transform.SimpleComponentTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod;
import org.diylc.core.IContinuity;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
@@ -40,7 +41,7 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Hookup Wire", author = "Branislav Stojkovic", category = "Connectivity",
instanceNamePrefix = "W", description = "Flexible wire with two control points", zOrder = IDIYComponent.WIRING,
flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW,
flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW, creationMethod = CreationMethod.POINT_BY_POINT,
transformer = SimpleComponentTransformer.class, enableCache = false)
public class HookupWire extends AbstractCurvedComponent<AWG> implements IContinuity {
@@ -35,6 +35,7 @@ import org.diylc.common.ObjectCache;
import org.diylc.components.AbstractOrthogonalComponent;
import org.diylc.components.transform.OrthogonalComponentTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod;
import org.diylc.core.IContinuity;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
@@ -49,7 +50,7 @@ import org.diylc.core.measures.SizeUnit;
instanceNamePrefix = "LN", description = "Line with rounded right angle turns and optional arrows",
zOrder = IDIYComponent.WIRING, flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic",
transformer = OrthogonalComponentTransformer.class, enableCache = false)
transformer = OrthogonalComponentTransformer.class, enableCache = false, creationMethod = CreationMethod.POINT_BY_POINT)
public class OrthogonalLine extends AbstractOrthogonalComponent<Void> implements IContinuity {
private static final long serialVersionUID = 1L;
@@ -34,6 +34,7 @@ import org.diylc.common.ObjectCache;
import org.diylc.components.AbstractOrthogonalComponent;
import org.diylc.components.transform.OrthogonalComponentTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod;
import org.diylc.core.IContinuity;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
@@ -45,7 +46,7 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Right Angle Wire", author = "Branislav Stojkovic", category = "Connectivity",
instanceNamePrefix = "W", description = "Wire that runs horizontally and vertically and turns at right angles",
zOrder = IDIYComponent.WIRING, flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW,
transformer = OrthogonalComponentTransformer.class, enableCache = false)
transformer = OrthogonalComponentTransformer.class, enableCache = false, creationMethod = CreationMethod.POINT_BY_POINT)
public class OrthogonalWire extends AbstractOrthogonalComponent<AWG> implements IContinuity {
private static final long serialVersionUID = 1L;
@@ -38,6 +38,7 @@ import org.diylc.common.ObjectCache;
import org.diylc.components.AbstractCurvedComponent;
import org.diylc.components.transform.SimpleComponentTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod;
import org.diylc.core.IContinuity;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
@@ -50,7 +51,8 @@ import org.diylc.utils.Constants;
category = "Connectivity", instanceNamePrefix = "W",
description = "A pair of flexible leads twisted tightly together", zOrder = IDIYComponent.WIRING,
flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW,
transformer = SimpleComponentTransformer.class, enableCache = true)
transformer = SimpleComponentTransformer.class, enableCache = true,
creationMethod = CreationMethod.POINT_BY_POINT)
public class TwistedWire extends AbstractCurvedComponent<Void> implements IContinuity {
private static final long serialVersionUID = 1L;
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>org.diylc</groupId>
<artifactId>diylc-parent</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</parent>
<artifactId>diylc-swing</artifactId>
@@ -82,7 +82,8 @@ public class StatusBar extends JPanel implements IPlugIn {
private static final String HOLD_TO_UNSTUCK = LangUtil.translate("hold %s and drag to unstick from");
private static final String SELECTION = LangUtil.translate("Selection");
private static final String DRAG_POINTS_OF = LangUtil.translate("Drag control point(s) of");
private static final String DRAG_TO_PLACE_A_NEW = LangUtil.translate("Drag the mouse over the canvas to place a new");
private static final String DRAG_TO_PLACE_A_NEW =
LangUtil.translate("Click or drag over the canvas to place a new");
private static final String ZOOM = LangUtil.translate("Zoom");
private static final String SELECTION_SIZE = LangUtil.translate("Selection Size");
private static final String SELECTION_IS_EMPTY = LangUtil.translate("Selection is empty.");
@@ -94,6 +94,19 @@ public class ComponentButtonFactory {
button.addMouseListener(new MouseAdapter() {
/**
* Runs after the button has already fired its action for this click, so re-arming the slot
* here is what decides the mode: a double click instantiates the component up front so that
* it follows the cursor and drops in a single gesture, the way dragging it onto the canvas
* does, instead of asking for a point at a time.
*/
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) {
plugInPort.setNewComponentTypeSlot(componentType, null, null, true);
}
}
@Override
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
@@ -123,13 +123,7 @@ public class CustomTreeModel implements TreeModel {
if (fav.getType() == FavoriteType.Component) {
ComponentType type = this.typesByClass.get(fav.getName());
if (this.searchText == null || type.getName().toLowerCase().contains(this.searchText)) {
visibleTypes.add(new TreeNode(type, new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
plugInPort.setNewComponentTypeSlot(type, null, null, false);
}
}));
visibleTypes.add(new TreeNode(type, createComponentClickListener(type)));
}
} else {
// block
@@ -189,13 +183,7 @@ public class CustomTreeModel implements TreeModel {
if (type == null)
continue;
if (this.searchText == null || type.getName().toLowerCase().contains(this.searchText)) {
visibleTypes.add(new TreeNode(type, new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
plugInPort.setNewComponentTypeSlot(type, null, null, false);
}
}));
visibleTypes.add(new TreeNode(type, createComponentClickListener(type)));
}
}
}
@@ -230,17 +218,29 @@ public class CustomTreeModel implements TreeModel {
|| category.toLowerCase().contains(this.searchText.toLowerCase()) ||
typeMatches(this.searchText, type))
visibleTypes.add(new TreeNode(type, new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
plugInPort.setNewComponentTypeSlot(type, null, null, false);
}
}));
visibleTypes.add(new TreeNode(type, createComponentClickListener(type)));
this.visibleLeaves.put(category, visibleTypes);
return visibleTypes;
}
/**
* Arms the slot for the specified type. A double click instantiates the component up front so
* that it follows the cursor and drops in a single gesture, the way dragging it onto the canvas
* does, instead of asking for a point at a time.
*
* @param type
* @return listener to attach to the tree node.
*/
private MouseAdapter createComponentClickListener(ComponentType type) {
return new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
plugInPort.setNewComponentTypeSlot(type, null, null, e != null && e.getClickCount() > 1);
}
};
}
private boolean typeMatches(String searchText, ComponentType type) {
if (searchText == null || searchText.isEmpty())
return true;
@@ -258,17 +258,15 @@ public class TreePanel extends JPanel {
/**
* Prefer release over click: {@code mouseClicked} is not posted if the cursor moves
* between press and release (common with DnD or hand jitter), while selection may still
* change — then re-clicks on the same row fire no selection event.
* change - then re-clicks on the same row fire no selection event. Every release is
* forwarded rather than only the first, so that the listener can tell a double click from
* a single one; re-arming the slot on the second release is harmless.
*/
@Override
public void mouseReleased(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e) || e.isPopupTrigger()) {
return;
}
if (e.getClickCount() != 1) {
return;
}
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
if (path == null) {
path = tree.getClosestPathForLocation(e.getX(), e.getY());
+12 -13
View File
@@ -26,7 +26,7 @@ click; group mode costs one extra click.
|---|---|---|---|
| D1 | Where child definitions live | Embedded in the instance, serialized into the `.diy` file | Projects stay portable; a file opens correctly on a machine that does not have the block in its local config. Blocks in config remain the *template*, not a live dependency. |
| D2 | Which control points are exposed | All of them, delegated straight through to children | No curation UI needed, and `isControlPointSticky` / `getControlPointVisibilityPolicy` come along for free with correct per-child semantics. |
| D3 | Terminal naming | `getSectionNames(i)` returns the child's name; `getControlPointNodeName(i)` returns the child's node name | `Node.toString()` already renders `component.getName() + "." + section + "." + nodeName`, so a netlist node reads `ARD1.PH1.3` with no changes to the netlist code. |
| D3 | Terminal naming | A child's node name is exposed unchanged when it is unique within the composite. Clashes are resolved by qualifying pins of multi-point children with the child's name (`R1.1`), then numbering whatever still clashes in save order (`GND_1`, `GND_2`) | Blocks are also used to build custom maker boards from a blank board and solder pads, where the pad's Node Name is the terminal name and its component name (`Pad3`) is an arbitrary leftover of the project the block was saved in. Children are frozen (D8), so every instance of a block resolves identical names. `Node.toString()` prefixes the composite's name, so a netlist node reads `BLK1.VCC` or `BLK1.R1.1`. |
| D4 | Geometry | Rigid — `canPointMoveFreely(i)` returns `false` for every index | This is already a first-class concept used by ~60 components (`DIL_IC`, `Breadboard`, `TubeSocket`…). No new plumbing. |
| D5 | Type identity | One shared `ComponentType`; the instance carries a `blockName` field, and the handful of type-name consumers prefer it | `ComponentProcessor` caches `ComponentType` per Java class, so per-block types would mean changing the cache key of a widely used singleton. The field approach has a much smaller blast radius. |
| D6 | Electrical modelling | The composite is **not** `IContinuity` and **not** `ISwitch` | A composite is a footprint that exposes terminals, not a circuit model. Internal point-to-point continuity and internal switching are explicitly out of scope. |
@@ -67,10 +67,10 @@ components by translating *every* control point by the same delta via
child. Rigidity is enforced by `canPointMoveFreely`, never by `setControlPoint`
refusing a write.
**Node naming.** `Node.getDisplayName()` prefixes the node name with
`getSectionNames(pointIndex)[0]` when there is exactly one section, and
`Node.toString()` prefixes that with the component name. Returning the child's
name as the section gives hierarchical netlist labels for free.
**Node naming.** `Node.toString()` prefixes the node name with the component
name, so whatever the composite returns from `getControlPointNodeName` reads as
`BLK1.<name>` in the netlist with no changes to the netlist code. Only resolving
clashes between children's names is new (D3).
Three things do *not* come for free and are the substance of the work: type
identity (D5), palette visibility (§4.2), and a correct deep `clone()` (§7).
@@ -131,8 +131,7 @@ deserialization, which the lazy getter handles.
| `isControlPointSticky(i)` | Delegate |
| `canControlPointOverlap(i)` | Delegate |
| `getControlPointVisibilityPolicy(i)` | Delegate |
| `getControlPointNodeName(i)` | Child's node name, prefixed with the child's own section name when it has exactly one |
| `getSectionNames(i)` | `new String[] { child.getName() }` |
| `getControlPointNodeName(i)` | Resolved once alongside the index arrays (D3). Only sticky, named points take part in clash detection, so a board's non-sticky corner points never force a pad to be renamed |
| `canPointMoveFreely(i)` | `false` (D4) |
| `createdIn(project)` | Forward to every child |
@@ -202,10 +201,10 @@ left behind.
- `GROUP` — exactly today's behaviour.
- `COMPOSITE` — clone the stored components with fresh UUIDs but **keep their
saved names unchanged**. Child names are namespaced under the composite's name
saved names unchanged**. Child names surface in terminal names when pins clash
(D3), so running them through `createUniqueName` against the project would
produce meaningless drift (`R1` becoming `R37`) and break netlist labels
between two instances of the same block. Then wrap them in a
produce meaningless drift (`R1` becoming `R37`) and make two instances of the
same block resolve different netlist labels. Then wrap them in a
`CompositeComponent`, set `blockName`, and give the composite itself a
project-unique name via `createUniqueName`.
@@ -312,7 +311,7 @@ selections.
**Naming collisions.** Two instances of the same block deliberately carry
identically named children (§4.4). Netlist labels stay unique because they are
prefixed with the composite's own name (`ARD1.PH1.3` vs `ARD2.PH1.3`). Any code
prefixed with the composite's own name (`ARD1.R1.1` vs `ARD2.R1.1`). Any code
that assumes component names are globally unique across the project would be
affected — none is known, but worth watching.
@@ -320,8 +319,8 @@ affected — none is known, but worth watching.
- **Unit** — point count equals the sum over children; `getControlPoint(i)`
tracks the child after the child moves; `canPointMoveFreely` is false for
every index; `getSectionNames`/`getControlPointNodeName` produce
`ARD1.PH1.3` through `Node.toString()`.
every index; `getControlPointNodeName` passes unique names through, qualifies
clashing pins of multi-point children and numbers the remaining clashes (D3).
- **Clone isolation** — clone a composite, move the clone, assert the original's
points did not move.
- **Round trip** — save a project containing a composite, reload it, assert the
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>org.diylc</groupId>
<artifactId>diylc-parent</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
<packaging>pom</packaging>
<name>DIY Layout Creator</name>