mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Added two DPDT ON/ON/ON variations to 'Mini Toggle Switch' component
This commit is contained in:
@@ -3894,6 +3894,14 @@
|
||||
<releaseDate>2022-07-09 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Voltage Source' symbol. Thank you, JD!</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added two DPDT ON/ON/ON variations to 'Mini Toggle Switch' component</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>The app crashes if there's a component that is reduced to 0 pixels with 'Cache Boost' enabled</description>
|
||||
|
||||
+31
-5
@@ -98,7 +98,9 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
new Point2D.Double(firstPoint.getX(), firstPoint.getY() + 2 * spacing)};
|
||||
break;
|
||||
case DPDT:
|
||||
case DPDT_off:
|
||||
case DPDT_off:
|
||||
case DPDT_ononon_1:
|
||||
case DPDT_ononon_2:
|
||||
controlPoints =
|
||||
new Point2D[] {firstPoint, new Point2D.Double(firstPoint.getX(), firstPoint.getY() + spacing),
|
||||
new Point2D.Double(firstPoint.getX(), firstPoint.getY() + 2 * spacing),
|
||||
@@ -336,7 +338,9 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
* spacing, margin, margin);
|
||||
break;
|
||||
case DPDT:
|
||||
case DPDT_off:
|
||||
case DPDT_off:
|
||||
case DPDT_ononon_1:
|
||||
case DPDT_ononon_2:
|
||||
body =
|
||||
new RoundRectangle2D.Double(firstPoint.getX() - margin, firstPoint.getY() - margin, 2 * margin + spacing, 2
|
||||
* margin + 2 * spacing, margin, margin);
|
||||
@@ -441,13 +445,15 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
case _3PDT_off:
|
||||
case _4PDT_off:
|
||||
case _5PDT_off:
|
||||
case DPDT_ononon_1:
|
||||
case DPDT_ononon_2:
|
||||
return 3;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPositionName(int position) {
|
||||
public String getPositionName(int position) {
|
||||
if (switchType.name().endsWith("_off") && position == 2)
|
||||
return "OFF";
|
||||
return "ON" + Integer.toString(position + 1);
|
||||
@@ -463,7 +469,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
case _3PDT:
|
||||
case _4PDT:
|
||||
case _5PDT:
|
||||
return (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1;
|
||||
return (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1;
|
||||
case SPDT_off:
|
||||
case DPDT_off:
|
||||
case _3PDT_off:
|
||||
@@ -471,7 +477,27 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
case _5PDT_off:
|
||||
return position != 2 && (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1;
|
||||
case _DP3T_mustang:
|
||||
return (index2 - index1) < 3 && index1 % 3 == 0 && index2 % 3 == position + 1;
|
||||
return (index2 - index1) < 3 && index1 % 3 == 0 && index2 % 3 == position + 1;
|
||||
case DPDT_ononon_1:
|
||||
switch (position) {
|
||||
case 0:
|
||||
return (index1 == 0 && index2 == 1) || (index1 == 3 && index2 == 4);
|
||||
case 1:
|
||||
return (index1 == 0 && index2 == 1) || (index1 == 4 && index2 == 5);
|
||||
case 2:
|
||||
return (index1 == 1 && index2 == 2) || (index1 == 4 && index2 == 5);
|
||||
default: return false;
|
||||
}
|
||||
case DPDT_ononon_2:
|
||||
switch (position) {
|
||||
case 0:
|
||||
return (index1 == 0 && index2 == 1) || (index1 == 3 && index2 == 4);
|
||||
case 1:
|
||||
return (index1 == 1 && index2 == 2) || (index1 == 3 && index2 == 4);
|
||||
case 2:
|
||||
return (index1 == 1 && index2 == 2) || (index1 == 4 && index2 == 5);
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-1
@@ -23,7 +23,7 @@ package org.diylc.components.electromechanical;
|
||||
|
||||
public enum ToggleSwitchType {
|
||||
|
||||
SPST, SPDT, DPDT, _DP3T_mustang, _3PDT, _4PDT, _5PDT, SPDT_off, DPDT_off, _3PDT_off, _4PDT_off, _5PDT_off;
|
||||
SPST, SPDT, DPDT, _DP3T_mustang, _3PDT, _4PDT, _5PDT, SPDT_off, DPDT_off, _3PDT_off, _4PDT_off, _5PDT_off, DPDT_ononon_1, DPDT_ononon_2;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -33,6 +33,8 @@ public enum ToggleSwitchType {
|
||||
name = name.replace("_", " ");
|
||||
name = name.replace("mustang", "");
|
||||
name = name.replace("off", " (Center OFF)");
|
||||
name = name.replace("ononon_1", " On/On/On (Type 1)");
|
||||
name = name.replace("ononon_2", " On/On/On (Type 2)");
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ package org.diylc.netlist;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import java.util.Arrays;
|
||||
import org.diylc.components.electromechanical.MiniToggleSwitch;
|
||||
import org.diylc.components.electromechanical.SlideSwitch;
|
||||
import org.diylc.components.electromechanical.SlideSwitchType;
|
||||
import org.diylc.components.electromechanical.ToggleSwitchType;
|
||||
import org.diylc.components.guitar.LPSwitch;
|
||||
import org.diylc.components.guitar.LeverSwitch;
|
||||
import org.diylc.components.guitar.LeverSwitch.LeverSwitchType;
|
||||
@@ -66,6 +68,22 @@ public class SwitchTests {
|
||||
String[] validCombinations = new String[] {"0,0,2", "0,1,3", "1,2,4", "1,3,5", "2,4,6", "2,5,7"};
|
||||
testSwitch(slideSwitch, validCombinations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMiniToggleSwitchDPDTononon1() {
|
||||
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||
toggleSwitch.setValue(ToggleSwitchType.DPDT_ononon_1);
|
||||
String[] validCombinations = new String[] {"0,0,1", "0,3,4", "1,0,1", "1,4,5", "2,1,2", "2,4,5"};
|
||||
testSwitch(toggleSwitch, validCombinations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMiniToggleSwitchDPDTononon2() {
|
||||
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||
toggleSwitch.setValue(ToggleSwitchType.DPDT_ononon_2);
|
||||
String[] validCombinations = new String[] {"0,0,1", "0,3,4", "1,1,2", "1,3,4", "2,1,2", "2,4,5"};
|
||||
testSwitch(toggleSwitch, validCombinations);
|
||||
}
|
||||
|
||||
private void testSwitch(ISwitch sw, String[] validCombinations) {
|
||||
Arrays.sort(validCombinations);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
5PDT
|
||||
5PDT (Center OFF)
|
||||
A-O-I REGULATOR
|
||||
AC
|
||||
AWG
|
||||
And
|
||||
B-C-E BJT
|
||||
@@ -31,6 +32,7 @@ D-G-S JFET
|
||||
D-G-S MOSFET
|
||||
D-S-G JFET
|
||||
D-S-G MOSFET
|
||||
DC
|
||||
DFM A
|
||||
DFM B
|
||||
DIP
|
||||
@@ -81,6 +83,7 @@ SMD
|
||||
SPDT
|
||||
SPDT (Center OFF)
|
||||
SPST
|
||||
SourceType
|
||||
Srpski
|
||||
Xnor
|
||||
Xor
|
||||
|
||||
Reference in New Issue
Block a user