mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Do not hard-code voltage and power ratings
This commit is contained in:
@@ -65,7 +65,7 @@
|
|||||||
<copy todir="../diylc-swing/lib" overwrite="true">
|
<copy todir="../diylc-swing/lib" overwrite="true">
|
||||||
<fileset dir="${jar.dir}" includes="${ant.project.name}.jar" />
|
<fileset dir="${jar.dir}" includes="${ant.project.name}.jar" />
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="../library/lib" overwrite="true">
|
<copy todir="../diylc-library/lib" overwrite="true">
|
||||||
<fileset dir="${jar.dir}" includes="${ant.project.name}.jar" />
|
<fileset dir="${jar.dir}" includes="${ant.project.name}.jar" />
|
||||||
</copy>
|
</copy>
|
||||||
</target>
|
</target>
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package org.diylc.core.measures;
|
||||||
|
|
||||||
|
public class Power extends AbstractMeasure<PowerUnit> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public Power() {
|
||||||
|
super();
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public Power(Double value, PowerUnit unit) {
|
||||||
|
super(value, unit);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Power clone() throws CloneNotSupportedException {
|
||||||
|
return new Power(value, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Power parseCapacitance(String value) {
|
||||||
|
for (PowerUnit unit : PowerUnit.values()) {
|
||||||
|
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
|
||||||
|
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
|
||||||
|
return new Power(Double.parseDouble(value), unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Could not parse power: " + value);
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package org.diylc.core.measures;
|
||||||
|
|
||||||
|
public enum PowerUnit implements Unit {
|
||||||
|
|
||||||
|
MW(1e-1, "mW"), W(1, "W"), KW(1e3, "KW");
|
||||||
|
|
||||||
|
double factor;
|
||||||
|
String display;
|
||||||
|
|
||||||
|
private PowerUnit(double factor, String display) {
|
||||||
|
this.factor = factor;
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getFactor() {
|
||||||
|
return factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package org.diylc.core.measures;
|
||||||
|
|
||||||
|
public class Voltage extends AbstractMeasure<VoltageUnit> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public Voltage() {
|
||||||
|
super();
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public Voltage(Double value, VoltageUnit unit) {
|
||||||
|
super(value, unit);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Voltage clone() throws CloneNotSupportedException {
|
||||||
|
return new Voltage(value, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Voltage parseCapacitance(String value) {
|
||||||
|
for (VoltageUnit unit : VoltageUnit.values()) {
|
||||||
|
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
|
||||||
|
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
|
||||||
|
return new Voltage(Double.parseDouble(value), unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Could not parse voltage: " + value);
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package org.diylc.core.measures;
|
||||||
|
|
||||||
|
public enum VoltageUnit implements Unit {
|
||||||
|
|
||||||
|
MV(1e-1, "mV"), V(1, "V"), KV(1e3, "KV");
|
||||||
|
|
||||||
|
double factor;
|
||||||
|
String display;
|
||||||
|
|
||||||
|
private VoltageUnit(double factor, String display) {
|
||||||
|
this.factor = factor;
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getFactor() {
|
||||||
|
return factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
+21
-1
@@ -18,6 +18,7 @@ import org.diylc.core.measures.Capacitance;
|
|||||||
import org.diylc.core.measures.CapacitanceUnit;
|
import org.diylc.core.measures.CapacitanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Electrolytic Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Axial electrolytic capacitor, similar to Sprague Atom, F&T, etc", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Electrolytic Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Axial electrolytic capacitor, similar to Sprague Atom, F&T, etc", zOrder = IDIYComponent.COMPONENT)
|
||||||
@@ -33,7 +34,10 @@ public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacita
|
|||||||
public static Color TICK_COLOR = Color.white;
|
public static Color TICK_COLOR = Color.white;
|
||||||
|
|
||||||
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
||||||
|
@Deprecated
|
||||||
private Voltage voltage = Voltage._63V;
|
private Voltage voltage = Voltage._63V;
|
||||||
|
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||||
|
VoltageUnit.V);
|
||||||
|
|
||||||
private Color markerColor = MARKER_COLOR;
|
private Color markerColor = MARKER_COLOR;
|
||||||
private Color tickColor = TICK_COLOR;
|
private Color tickColor = TICK_COLOR;
|
||||||
@@ -54,14 +58,30 @@ public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacita
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@Deprecated
|
||||||
public Voltage getVoltage() {
|
public Voltage getVoltage() {
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setVoltage(Voltage voltage) {
|
public void setVoltage(Voltage voltage) {
|
||||||
this.voltage = voltage;
|
this.voltage = voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Voltage")
|
||||||
|
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||||
|
// Backward comptibility
|
||||||
|
if (voltageNew == null) {
|
||||||
|
voltageNew = voltage.convertToNewFormat();
|
||||||
|
voltage = null;
|
||||||
|
// Clear old value, don't need it anymore
|
||||||
|
}
|
||||||
|
return voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||||
|
this.voltageNew = voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||||
|
|||||||
+20
-1
@@ -14,6 +14,7 @@ import org.diylc.core.measures.Capacitance;
|
|||||||
import org.diylc.core.measures.CapacitanceUnit;
|
import org.diylc.core.measures.CapacitanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Film Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Axial film capacitor, similar to Mallory 150s", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Film Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Axial film capacitor, similar to Mallory 150s", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||||
@@ -26,7 +27,10 @@ public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
|
|
||||||
private Capacitance value = new Capacitance(22d, CapacitanceUnit.nF);
|
private Capacitance value = new Capacitance(22d, CapacitanceUnit.nF);
|
||||||
|
@Deprecated
|
||||||
private Voltage voltage = Voltage._63V;
|
private Voltage voltage = Voltage._63V;
|
||||||
|
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||||
|
VoltageUnit.V);
|
||||||
|
|
||||||
public AxialFilmCapacitor() {
|
public AxialFilmCapacitor() {
|
||||||
super();
|
super();
|
||||||
@@ -48,15 +52,30 @@ public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@Deprecated
|
||||||
public Voltage getVoltage() {
|
public Voltage getVoltage() {
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setVoltage(Voltage voltage) {
|
public void setVoltage(Voltage voltage) {
|
||||||
this.voltage = voltage;
|
this.voltage = voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Voltage")
|
||||||
|
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||||
|
// Backward comptibility
|
||||||
|
if (voltageNew == null) {
|
||||||
|
voltageNew = voltage.convertToNewFormat();
|
||||||
|
voltage = null;
|
||||||
|
// Clear old value, don't need it anymore
|
||||||
|
}
|
||||||
|
return voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||||
|
this.voltageNew = voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||||
|
|||||||
+21
-1
@@ -13,6 +13,7 @@ import org.diylc.core.measures.Capacitance;
|
|||||||
import org.diylc.core.measures.CapacitanceUnit;
|
import org.diylc.core.measures.CapacitanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Capacitor (schematic symbol)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Capacitor schematic symbol with an optional polarity sign", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Capacitor (schematic symbol)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Capacitor schematic symbol with an optional polarity sign", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance> {
|
public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance> {
|
||||||
@@ -23,7 +24,10 @@ public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance>
|
|||||||
public static Size DEFAULT_WIDTH = new Size(0.15, SizeUnit.in);
|
public static Size DEFAULT_WIDTH = new Size(0.15, SizeUnit.in);
|
||||||
|
|
||||||
private Capacitance value = new Capacitance(22d, CapacitanceUnit.nF);
|
private Capacitance value = new Capacitance(22d, CapacitanceUnit.nF);
|
||||||
|
@Deprecated
|
||||||
private Voltage voltage = Voltage._63V;
|
private Voltage voltage = Voltage._63V;
|
||||||
|
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||||
|
VoltageUnit.V);
|
||||||
private boolean polarized = false;
|
private boolean polarized = false;
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -35,15 +39,31 @@ public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance>
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@Deprecated
|
||||||
public Voltage getVoltage() {
|
public Voltage getVoltage() {
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setVoltage(Voltage voltage) {
|
public void setVoltage(Voltage voltage) {
|
||||||
this.voltage = voltage;
|
this.voltage = voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Voltage")
|
||||||
|
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||||
|
// Backward compatibility
|
||||||
|
if (voltageNew == null) {
|
||||||
|
voltageNew = voltage.convertToNewFormat();
|
||||||
|
voltage = null;
|
||||||
|
// Clear old value, don't need it anymore
|
||||||
|
}
|
||||||
|
return voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||||
|
this.voltageNew = voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
public boolean getPolarized() {
|
public boolean getPolarized() {
|
||||||
return polarized;
|
return polarized;
|
||||||
|
|||||||
+38
@@ -1,5 +1,7 @@
|
|||||||
package org.diylc.components.passive;
|
package org.diylc.components.passive;
|
||||||
|
|
||||||
|
import org.diylc.core.measures.PowerUnit;
|
||||||
|
|
||||||
public enum Power {
|
public enum Power {
|
||||||
|
|
||||||
EIGHT("1/8W"), QUARTER("1/4W"), HALF("1/2W"), ONE("1W"), TWO("2W"), FIVE("5W"), TEN("10W"), FIFTY(
|
EIGHT("1/8W"), QUARTER("1/4W"), HALF("1/2W"), ONE("1W"), TWO("2W"), FIVE("5W"), TEN("10W"), FIFTY(
|
||||||
@@ -15,4 +17,40 @@ public enum Power {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public org.diylc.core.measures.Power convertToNewFormat() {
|
||||||
|
org.diylc.core.measures.Power powerNew;
|
||||||
|
switch (this) {
|
||||||
|
case EIGHT:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(1 / 8d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
case FIVE:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(5d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
case FIFTY:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(50d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
case HALF:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(1 / 2d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
case HUNDRED:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(100d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
case ONE:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(1d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
case QUARTER:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(1 / 4d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
case TEN:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(10d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
case TWO:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(2d, PowerUnit.W);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
powerNew = new org.diylc.core.measures.Power(1 / 2d, PowerUnit.W);
|
||||||
|
}
|
||||||
|
return powerNew;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-1
@@ -20,6 +20,7 @@ import org.diylc.core.measures.Capacitance;
|
|||||||
import org.diylc.core.measures.CapacitanceUnit;
|
import org.diylc.core.measures.CapacitanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Electrolytic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Vertical mounted electrolytic capacitor, polarized or bipolar", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Electrolytic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Vertical mounted electrolytic capacitor, polarized or bipolar", zOrder = IDIYComponent.COMPONENT)
|
||||||
@@ -34,7 +35,10 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
|||||||
public static Color TICK_COLOR = Color.white;
|
public static Color TICK_COLOR = Color.white;
|
||||||
|
|
||||||
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
||||||
|
@Deprecated
|
||||||
private Voltage voltage = Voltage._63V;
|
private Voltage voltage = Voltage._63V;
|
||||||
|
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||||
|
VoltageUnit.V);
|
||||||
|
|
||||||
private Color markerColor = MARKER_COLOR;
|
private Color markerColor = MARKER_COLOR;
|
||||||
private Color tickColor = TICK_COLOR;
|
private Color tickColor = TICK_COLOR;
|
||||||
@@ -55,14 +59,30 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@Deprecated
|
||||||
public Voltage getVoltage() {
|
public Voltage getVoltage() {
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setVoltage(Voltage voltage) {
|
public void setVoltage(Voltage voltage) {
|
||||||
this.voltage = voltage;
|
this.voltage = voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Voltage")
|
||||||
|
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||||
|
// Backward comptibility
|
||||||
|
if (voltageNew == null) {
|
||||||
|
voltageNew = voltage.convertToNewFormat();
|
||||||
|
voltage = null;
|
||||||
|
// Clear old value, don't need it anymore
|
||||||
|
}
|
||||||
|
return voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||||
|
this.voltageNew = voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
g2d.setColor(BODY_COLOR);
|
g2d.setColor(BODY_COLOR);
|
||||||
|
|||||||
+20
-1
@@ -14,6 +14,7 @@ import org.diylc.core.measures.Capacitance;
|
|||||||
import org.diylc.core.measures.CapacitanceUnit;
|
import org.diylc.core.measures.CapacitanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Film Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Radial film capacitor, similar to Sprague Orange Drop", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Film Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Radial film capacitor, similar to Sprague Orange Drop", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||||
@@ -26,7 +27,10 @@ public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
|
|
||||||
private Capacitance value = new Capacitance(123d, CapacitanceUnit.nF);
|
private Capacitance value = new Capacitance(123d, CapacitanceUnit.nF);
|
||||||
|
@Deprecated
|
||||||
private Voltage voltage = Voltage._63V;
|
private Voltage voltage = Voltage._63V;
|
||||||
|
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||||
|
VoltageUnit.V);
|
||||||
|
|
||||||
public RadialFilmCapacitor() {
|
public RadialFilmCapacitor() {
|
||||||
super();
|
super();
|
||||||
@@ -43,16 +47,31 @@ public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@Deprecated
|
||||||
public Voltage getVoltage() {
|
public Voltage getVoltage() {
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setVoltage(Voltage voltage) {
|
public void setVoltage(Voltage voltage) {
|
||||||
this.voltage = voltage;
|
this.voltage = voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Voltage")
|
||||||
|
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||||
|
// Backward comptibility
|
||||||
|
if (voltageNew == null) {
|
||||||
|
voltageNew = voltage.convertToNewFormat();
|
||||||
|
voltage = null;
|
||||||
|
// Clear old value, don't need it anymore
|
||||||
|
}
|
||||||
|
return voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||||
|
this.voltageNew = voltageNew;
|
||||||
|
}
|
||||||
|
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||||
g2d.setColor(LEAD_COLOR);
|
g2d.setColor(LEAD_COLOR);
|
||||||
|
|||||||
+21
-1
@@ -13,6 +13,7 @@ import org.diylc.core.IDIYComponent;
|
|||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.annotations.PositiveMeasureValidator;
|
import org.diylc.core.annotations.PositiveMeasureValidator;
|
||||||
|
import org.diylc.core.measures.PowerUnit;
|
||||||
import org.diylc.core.measures.Resistance;
|
import org.diylc.core.measures.Resistance;
|
||||||
import org.diylc.core.measures.ResistanceUnit;
|
import org.diylc.core.measures.ResistanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
@@ -31,7 +32,10 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
|||||||
public static int FIRST_BAND = 4;
|
public static int FIRST_BAND = 4;
|
||||||
|
|
||||||
private Resistance value = new Resistance(123d, ResistanceUnit.K);
|
private Resistance value = new Resistance(123d, ResistanceUnit.K);
|
||||||
|
@Deprecated
|
||||||
private Power power = Power.HALF;
|
private Power power = Power.HALF;
|
||||||
|
private org.diylc.core.measures.Power powerNew = new org.diylc.core.measures.Power(0.5,
|
||||||
|
PowerUnit.W);
|
||||||
private ResistorColorCode colorCode = ResistorColorCode._5_BAND;
|
private ResistorColorCode colorCode = ResistorColorCode._5_BAND;
|
||||||
|
|
||||||
public Resistor() {
|
public Resistor() {
|
||||||
@@ -54,15 +58,31 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@Deprecated
|
||||||
public Power getPower() {
|
public Power getPower() {
|
||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setPower(Power power) {
|
public void setPower(Power power) {
|
||||||
this.power = power;
|
this.power = power;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Power rating")
|
||||||
|
public org.diylc.core.measures.Power getPowerNew() {
|
||||||
|
// Backward compatibility
|
||||||
|
if (powerNew == null) {
|
||||||
|
powerNew = power.convertToNewFormat();
|
||||||
|
// Clear old value, don't need it anymore
|
||||||
|
power = null;
|
||||||
|
}
|
||||||
|
return powerNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPowerNew(org.diylc.core.measures.Power powerNew) {
|
||||||
|
this.powerNew = powerNew;
|
||||||
|
}
|
||||||
|
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||||
g2d.setColor(LEAD_COLOR);
|
g2d.setColor(LEAD_COLOR);
|
||||||
|
|||||||
+22
-1
@@ -9,6 +9,7 @@ import org.diylc.core.CreationMethod;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
import org.diylc.core.measures.PowerUnit;
|
||||||
import org.diylc.core.measures.Resistance;
|
import org.diylc.core.measures.Resistance;
|
||||||
import org.diylc.core.measures.ResistanceUnit;
|
import org.diylc.core.measures.ResistanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
@@ -23,7 +24,10 @@ public class ResistorSymbol extends AbstractSchematicLeadedSymbol<Resistance> {
|
|||||||
public static Size DEFAULT_WIDTH = new Size(0.08, SizeUnit.in);
|
public static Size DEFAULT_WIDTH = new Size(0.08, SizeUnit.in);
|
||||||
|
|
||||||
private Resistance value = new Resistance(100d, ResistanceUnit.K);
|
private Resistance value = new Resistance(100d, ResistanceUnit.K);
|
||||||
|
@Deprecated
|
||||||
private Power power = Power.HALF;
|
private Power power = Power.HALF;
|
||||||
|
private org.diylc.core.measures.Power powerNew = new org.diylc.core.measures.Power(0.5,
|
||||||
|
PowerUnit.W);
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
public Resistance getValue() {
|
public Resistance getValue() {
|
||||||
@@ -34,14 +38,31 @@ public class ResistorSymbol extends AbstractSchematicLeadedSymbol<Resistance> {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@Deprecated
|
||||||
public Power getPower() {
|
public Power getPower() {
|
||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setPower(Power power) {
|
public void setPower(Power power) {
|
||||||
this.power = power;
|
this.power = power;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Power rating")
|
||||||
|
public org.diylc.core.measures.Power getPowerNew() {
|
||||||
|
// Backward compatibility
|
||||||
|
if (powerNew == null) {
|
||||||
|
powerNew = power.convertToNewFormat();
|
||||||
|
// Clear old value, don't need it anymore
|
||||||
|
power = null;
|
||||||
|
}
|
||||||
|
return powerNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPowerNew(org.diylc.core.measures.Power powerNew) {
|
||||||
|
this.powerNew = powerNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||||
|
|||||||
+48
-1
@@ -1,11 +1,58 @@
|
|||||||
package org.diylc.components.passive;
|
package org.diylc.components.passive;
|
||||||
|
|
||||||
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
|
|
||||||
public enum Voltage {
|
public enum Voltage {
|
||||||
|
|
||||||
_16V, _25V, _63V, _100V, _160V, _250V, _300V, _350V, _400V, _500V, _630V, _1KV;
|
_16V, _25V, _63V, _100V, _160V, _250V, _300V, _350V, _400V, _500V, _630V, _1KV;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name().replace("_", "");
|
return name().replace("_", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public org.diylc.core.measures.Voltage convertToNewFormat() {
|
||||||
|
org.diylc.core.measures.Voltage voltageNew;
|
||||||
|
switch (this) {
|
||||||
|
case _100V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(100d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _160V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(160d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _16V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(16d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _1KV:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(1d, VoltageUnit.KV);
|
||||||
|
break;
|
||||||
|
case _250V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(250d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _25V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(25d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _300V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(300d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _350V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(350d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _400V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(400d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _500V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(500d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _630V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(630d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
case _63V:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(63d, VoltageUnit.V);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
voltageNew = new org.diylc.core.measures.Voltage(100d, VoltageUnit.V);
|
||||||
|
}
|
||||||
|
return voltageNew;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -446,6 +446,10 @@
|
|||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Allow finer grid spacing up to 0.5mm (0.02")</description>
|
<description>Allow finer grid spacing up to 0.5mm (0.02")</description>
|
||||||
</com.diyfever.gui.update.Change>
|
</com.diyfever.gui.update.Change>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Do not hard-code voltage and power ratings</description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||||
</com.diyfever.gui.update.Version>
|
</com.diyfever.gui.update.Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user