Include switches in the schematic

ISwitch extends IContinuity, so SchematicBuilder.isEligible() was filtering
every switch out of the schematic even though the netlist (built with
includeSwitches=false) keeps them as regular nodes with connections.
isEligible() now treats ISwitch as an eligible symbol; with no dedicated
factory yet it falls back to a GenericBoxSchematicFactory box carrying the
switch's lug node names, and gets wired like any other symbol.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWD3QJxbr7RuEHxyFEYeEY
This commit is contained in:
Bane Stojkovic
2026-09-03 11:03:28 +02:00
parent f229ef2c1a
commit 20116ec98c
3 changed files with 21 additions and 2 deletions
@@ -38,6 +38,7 @@ import org.diylc.components.schematic.SchematicWire;
import org.diylc.core.IContinuity;
import org.diylc.core.ICommonNode;
import org.diylc.core.IDIYComponent;
import org.diylc.core.ISwitch;
import org.diylc.core.Project;
import org.diylc.core.SchematicView;
import org.diylc.netlist.Group;
@@ -151,6 +152,9 @@ public class SchematicBuilder {
if (component instanceof ICommonNode) {
return true; // ground / common node symbols pass through
}
if (component instanceof ISwitch) {
return true; // switches are drawn as symbols (netlist is built with includeSwitches=false)
}
if (component instanceof IContinuity) {
return false; // wires, traces, solder bridges, board strips
}
@@ -25,8 +25,9 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import org.diylc.components.semiconductors.ICSymbol;
import org.diylc.components.electromechanical.MiniToggleSwitch;
import org.diylc.components.schematic.SchematicBox;
import org.diylc.components.semiconductors.ICSymbol;
import org.junit.Test;
public class GenericBoxSchematicFactoryTest {
@@ -56,6 +57,20 @@ public class GenericBoxSchematicFactoryTest {
assertEquals("IC1", mapping.getSchematicSymbol().getName());
}
@Test
public void switchesAreEligibleAndFallBackToABox() {
MiniToggleSwitch sw = new MiniToggleSwitch();
sw.setName("SW1");
assertTrue(SchematicBuilder.isEligible(sw));
List<SchematicSymbolMapping> mappings =
new GenericBoxSchematicFactory().createSchematicSymbols(sw);
assertEquals(1, mappings.size());
assertTrue(mappings.get(0).getSchematicSymbol() instanceof SchematicBox);
assertTrue(mappings.get(0).getSchematicSymbol().getControlPointCount() >= 2);
}
@Test
public void schematicBoxExposesConfiguredNodeNames() {
SchematicBox box = new SchematicBox();
+1 -1
View File
@@ -436,7 +436,7 @@ The schematic uses the **existing `DrawingManager` + `Presenter`** rendering pip
- `SchematicBox` component (`org.diylc.components.schematic`) — generic box with configurable left/right/top/bottom comma-separated terminal lists, NAME/VALUE/BOTH/NONE display.
- `SchematicWire` component — auto-routed Manhattan connection; implements `IContinuity`; stores source/target component id + pin index and the calculated `routePoints`; deep-cloned.
- `ManhattanRouter` — straight / L / HVH / VHV routing with pin exit-direction preference and overlap/crossing cost scoring against existing segments.
- `GenericBoxSchematicFactory` (default fallback) + `SchematicBuilder` (filter, symbol creation, connection-density grid placement, per-net wire chaining, canvas auto-resize) + `SchematicSynchronizer` (add/remove/keep-position incremental sync, full wire rebuild).
- `GenericBoxSchematicFactory` (default fallback) + `SchematicBuilder` (filter, symbol creation, connection-density grid placement, per-net wire chaining, canvas auto-resize) + `SchematicSynchronizer` (add/remove/keep-position incremental sync, full wire rebuild). Switches (`ISwitch`, which extends `IContinuity`) are treated as regular symbols — the generic box fallback until a dedicated factory is added — since the netlist is built with `includeSwitches=false`.
- Concrete factories: `Resistor`, `Capacitor`, `Diode`, `Transistor` (→ `BJTSymbol`), `Inductor`, `Potentiometer`, wired onto the common physical component types (resistors, film/ceramic/electrolytic/tantalum/mica caps, plastic/glass diodes, TO-1/92/126/220/3 transistors, radial/toroidal inductors, panel/trimmer/miniature pots).
**diylc-swing**