mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Added ability to set node name (or names) for some connectivity components
This commit is contained in:
@@ -183,12 +183,6 @@ public class CompositeComponent extends AbstractComponent<Void> {
|
||||
return childComponents.get(childOf[index]).getControlPointNodeName(pointOf[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSectionNames(int pointIndex) {
|
||||
buildIndexIfNeeded();
|
||||
return new String[] {childComponents.get(childOf[pointIndex]).getName()};
|
||||
}
|
||||
|
||||
/**
|
||||
* The composite is always rigid: it moves and rotates as a unit and never stretches. See design
|
||||
* decision D4 in {@code docs/plans/composite-building-blocks.md}.
|
||||
|
||||
@@ -369,6 +369,14 @@
|
||||
<releaseDate>2026-08-22 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Building blocks instantiate by default as a single component, inheriting control points and terminal nodes from all individual components but acting as a single component; still possible to instantiate individual components using 'Insert as Grouped Components' action from the context menu over a building block</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability to set node name (or names) for some connectivity components (e.g. Solder Pad, Eyelet, PCB Terminal Block, etc); when combined into building blocks, these names will become node names of the composite component stamped from the building block</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Percentage values such as transparency Alpha, image Scale, etc, can have decimal values and not just integers</description>
|
||||
|
||||
@@ -62,6 +62,7 @@ public class Eyelet extends AbstractTransparentComponent<String> {
|
||||
private Color color = COLOR;
|
||||
private Point2D.Double point = new Point2D.Double(0, 0);
|
||||
private String value = "";
|
||||
private String nodeName = "";
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
@@ -173,9 +174,22 @@ public class Eyelet extends AbstractTransparentComponent<String> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Node Name", defaultable = false)
|
||||
public String getNodeName() {
|
||||
if (nodeName == null) {
|
||||
nodeName = "";
|
||||
}
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
public void setNodeName(String nodeName) {
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
public String getControlPointNodeName(int index) {
|
||||
String n = getNodeName();
|
||||
return n.trim().isEmpty() ? null : n.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+23
-2
@@ -71,6 +71,7 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
||||
private Size pitch = new Size(0.2d, SizeUnit.in);
|
||||
private Size width = new Size(0.3d, SizeUnit.in);
|
||||
private ScrewPosition screwPosition = ScrewPosition.Offset;
|
||||
private String nodeNames = "";
|
||||
|
||||
public PCBTerminalBlock() {
|
||||
super();
|
||||
@@ -330,10 +331,30 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
||||
}
|
||||
|
||||
|
||||
@EditableProperty(name = "Node Names", defaultable = false)
|
||||
public String getNodeNames() {
|
||||
if (nodeNames == null) {
|
||||
nodeNames = "";
|
||||
}
|
||||
return nodeNames;
|
||||
}
|
||||
|
||||
public void setNodeNames(String nodeNames) {
|
||||
this.nodeNames = nodeNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
// we don't want the block to produce any nodes, it just makes connections
|
||||
return null;
|
||||
// By default the block produces no nodes, it just makes connections. Once the user
|
||||
// assigns explicit node names, each labeled point becomes a named node; unlabeled
|
||||
// points fall back to their ordinal number.
|
||||
String raw = getNodeNames();
|
||||
if (raw.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String[] parts = raw.split(",", -1);
|
||||
String label = index < parts.length ? parts[index].trim() : "";
|
||||
return label.isEmpty() ? Integer.toString(index + 1) : label;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,6 +71,7 @@ public class SolderPad extends AbstractTransparentComponent<Void>
|
||||
private Size holeSize = HOLE_SIZE;
|
||||
private PCBLayer layer = PCBLayer._1;
|
||||
private HoleType holeType = HoleType.NTPH;
|
||||
private String nodeName = "";
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||
@@ -246,9 +247,22 @@ public class SolderPad extends AbstractTransparentComponent<Void>
|
||||
return null;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Node Name", defaultable = false)
|
||||
public String getNodeName() {
|
||||
if (nodeName == null) {
|
||||
nodeName = "";
|
||||
}
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
public void setNodeName(String nodeName) {
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
String n = getNodeName();
|
||||
return n.trim().isEmpty() ? null : n.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,6 +60,7 @@ public class Turret extends AbstractTransparentComponent<String> {
|
||||
private Color color = COLOR;
|
||||
private Point2D.Double point = new Point2D.Double(0, 0);
|
||||
private String value = "";
|
||||
private String nodeName = "";
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
@@ -168,9 +169,22 @@ public class Turret extends AbstractTransparentComponent<String> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Node Name", defaultable = false)
|
||||
public String getNodeName() {
|
||||
if (nodeName == null) {
|
||||
nodeName = "";
|
||||
}
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
public void setNodeName(String nodeName) {
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
public String getControlPointNodeName(int index) {
|
||||
String n = getNodeName();
|
||||
return n.trim().isEmpty() ? null : n.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+26
@@ -71,6 +71,7 @@ public class PinHeader extends AbstractTransparentComponent<Void> {
|
||||
private int columnCount = 5;
|
||||
private Size spacing = PIN_SPACING;
|
||||
private Boolean shrouded = false;
|
||||
private String nodeNames = "";
|
||||
|
||||
private Color bodyColor = BODY_COLOR;
|
||||
private Color shroudColor = BODY_COLOR.darker();
|
||||
@@ -342,6 +343,31 @@ public class PinHeader extends AbstractTransparentComponent<Void> {
|
||||
this.shroudColor = shroudColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Node Names", defaultable = false)
|
||||
public String getNodeNames() {
|
||||
if (nodeNames == null) {
|
||||
nodeNames = "";
|
||||
}
|
||||
return nodeNames;
|
||||
}
|
||||
|
||||
public void setNodeNames(String nodeNames) {
|
||||
this.nodeNames = nodeNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
// Comma-separated list, one entry per pin in control point order. When the list is
|
||||
// blank, or an individual entry is missing/blank, the pin keeps its ordinal number.
|
||||
String raw = getNodeNames();
|
||||
if (raw.trim().isEmpty()) {
|
||||
return Integer.toString(index + 1);
|
||||
}
|
||||
String[] parts = raw.split(",", -1);
|
||||
String label = index < parts.length ? parts[index].trim() : "";
|
||||
return label.isEmpty() ? Integer.toString(index + 1) : label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
|
||||
@@ -585,7 +585,7 @@ public class TreePanel extends JPanel {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.blockName = blockName;
|
||||
putValue(AbstractAction.NAME, "Insert as Separate Components");
|
||||
putValue(AbstractAction.NAME, "Insert as Grouped Components");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user