Re-modeled factory variants of Resistor component type as datasheet in order to make them available to the AI; this will produce more accurate AI-driven edits

This commit is contained in:
Bane Stojkovic
2026-10-31 20:21:04 +01:00
parent 5d92812d3e
commit 15277452f4
12 changed files with 690 additions and 1512 deletions
@@ -37,6 +37,7 @@ import org.diylc.components.AbstractLeadedComponent;
import org.diylc.components.transform.SimpleComponentTransformer;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDatasheetSupport;
import org.diylc.core.annotations.AiNote;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
@@ -48,10 +49,13 @@ import org.diylc.core.measures.SizeUnit;
@AiNote("The two control points are the holes the leads go into and the body is centred between them; 'Length' is the body length, not the hole spacing")
@AiNote("If the control points are closer together than 'Length' (0.5in by default) the part is drawn standing, its body over the first point; to keep it lying on a tighter footprint, reduce 'Length'")
@AiNote("A datasheet model sets the body size, shape and colors of a resistor family at one power rating but never the resistance; set 'Power Rating' together with the model to pick the matching size")
@ComponentDescriptor(name = "Resistor", author = "Branislav Stojkovic", category = "Passive",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "R", description = "Resistor layout symbol",
zOrder = IDIYComponent.COMPONENT, transformer = SimpleComponentTransformer.class, enableCache = true)
public class Resistor extends AbstractLeadedComponent<Resistance> implements IGerberComponentSimple {
zOrder = IDIYComponent.COMPONENT, transformer = SimpleComponentTransformer.class, enableCache = true,
enableDatasheet = true, datasheetCreationStepCount = 2)
public class Resistor extends AbstractLeadedComponent<Resistance>
implements IGerberComponentSimple, IDatasheetSupport {
private static final long serialVersionUID = 1L;
@@ -75,6 +79,41 @@ public class Resistor extends AbstractLeadedComponent<Resistance> implements IGe
this.borderColor = BORDER_COLOR;
}
public Resistor(String[] model) {
this();
applyModel(model);
}
// columns: family, power, body length, body width, shape, color code, body color, border color;
// the resistance is not part of a row because the body size depends only on family and power
@Override
public void applyModel(String[] model) {
setPowerNew(org.diylc.core.measures.Power.parseCapacitance(model[1]));
setLength(parseDatasheetSize(model[2]));
setWidth(parseDatasheetSize(model[3]));
setShape(parseDatasheetEnum(ResistorShape.values(), model[4]));
setColorCode(parseDatasheetEnum(ResistorColorCode.values(), model[5]));
setBodyColor(Color.decode(model[6]));
setBorderColor(Color.decode(model[7]));
}
// sizes are in mm unless a unit follows the number, as some families are specified in inches
private static Size parseDatasheetSize(String value) {
String[] parts = value.split(" ");
SizeUnit unit = parts.length > 1 ? SizeUnit.valueOf(parts[1]) : SizeUnit.mm;
return new Size(Double.parseDouble(parts[0]), unit);
}
private static <E extends Enum<E>> E parseDatasheetEnum(E[] values, String name) {
for (E value : values) {
if (value.toString().equalsIgnoreCase(name)) {
return value;
}
}
throw new IllegalArgumentException("Unknown datasheet value: " + name);
}
@Override
protected boolean supportsStandingMode() {
return true;
@@ -0,0 +1,22 @@
Carbon Comp,0.25 W,0.3 in,0.1 in,Tubular,5 band,#8A5E20,#735832
Carbon Comp,0.5 W,0.41 in,0.15 in,Tubular,5 band,#8A5E20,#735832
Carbon Film,0.25 W,7,2.5,Standard,5 band,#E0C68B,#A59268
Carbon Film,0.5 W,9,3.2,Standard,5 band,#E0C68B,#A59268
Metal Film,0.25 W,7,2.5,Standard,5 band,#82CFFD,#5B90B1
Metal Film,0.5 W,9,3.2,Standard,5 band,#82CFFD,#5B90B1
Metal Oxide,1 W,9,3,Standard,5 band,#D2D7DB,#B2B7BB
Metal Oxide,2 W,12,4,Standard,5 band,#D2D7DB,#B2B7BB
Metal Oxide,3 W,16,6,Standard,5 band,#D2D7DB,#B2B7BB
Ceramic,2 W,18,7,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,3 W,22,8,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,5 W,22,9.5,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,7 W,35,9.5,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,10 W,48,9.5,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,15 W,48,13,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,20 W,63,13,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,30 W,75,19,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,50 W,90,19,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,80 W,109,19,Tubular,None,#F6F5F5,#CCCCCC
Ceramic,100 W,135,22,Tubular,None,#F6F5F5,#CCCCCC
Dale CMF55,0.5 W,6.22,2.29,Tubular Beveled,5 band,#D37D5B,#A04C2B
Dale CMF60,1 W,8.75,3.53,Tubular Beveled,5 band,#D37D5B,#A04C2B