to-1 flange added

This commit is contained in:
Bane Stojkovic
2026-11-03 18:31:11 +01:00
parent 1ae9c17cb0
commit 12ac7fe809
12 changed files with 68 additions and 1 deletions
@@ -577,6 +577,10 @@
<changeType>IMPROVEMENT</changeType>
<description>The '+N' variant count next to a component in the component tree is now a button - click it to pick one of the component's variants or datasheet parts from a drop-down menu, without having to right-click the component</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>'Transistor (TO-1)' now shows the tab on the rim of the metal can next to pin 1, as on the real part, so the orientation is easy to tell at a glance; turn it off with the new 'Flange' property</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>'DIP IC' with 'Display Pin #s' set to 'No' numbered its pins in the wrong order in netlists and AI analysis, e.g. pin 8 of an 8-pin IC was reported as pin 5</description>
@@ -27,6 +27,7 @@ import java.awt.Composite;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
@@ -71,8 +72,11 @@ public class TransistorTO1 extends AbstractTransistorPackage {
public static Size BODY_DIAMETER = new Size(0.24d, SizeUnit.in);
public static Size BODY_LENGTH = new Size(0.4d, SizeUnit.in);
public static Size EDGE_RADIUS = new Size(2d, SizeUnit.mm);
public static Size TAB_WIDTH = new Size(0.04d, SizeUnit.in);
public static Size TAB_LENGTH = new Size(0.03d, SizeUnit.in);
private Size pinSpacing = PIN_SPACING;
private Boolean flange = true;
public TransistorTO1() {
super();
@@ -162,11 +166,32 @@ public class TransistorTO1 extends AbstractTransistorPackage {
newBody = new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
}
body = new Area[] { newBody };
body = new Area[] { newBody,
getFlange() ? createTab(x, y, bodyDiameter, newBody) : null };
}
return body;
}
private Area createTab(double x, double y, int bodyDiameter, Area can) {
double tabWidth = TAB_WIDTH.convertToPixels();
double tabLength = TAB_LENGTH.convertToPixels();
Area tab;
if (folded) {
// the tab is on the flange at the lead end of the can, so it sticks out beside pin 1
tab = new Area(
new Rectangle2D.Double(x, y - bodyDiameter / 2 - tabLength, tabWidth, tabLength));
} else {
// seen from above the tab sits 45 degrees past pin 1, on the side away from pin 2
tab = new Area(
new Rectangle2D.Double(x, y - tabWidth / 2, bodyDiameter / 2 + tabLength, tabWidth));
tab.transform(AffineTransform.getRotateInstance(-Math.atan(0.5), x, y));
tab.subtract(can);
}
// both shapes above are laid out for the default orientation
tab.transform(AffineTransform.getRotateInstance(orientation.ordinal() * Math.PI / 2, x, y));
return tab;
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
@@ -180,9 +205,13 @@ public class TransistorTO1 extends AbstractTransistorPackage {
Area mainArea = getBody()[0];
Area tabArea = getBody()[1];
Composite oldComposite = applyAlpha(g2d, componentState);
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
drawingObserver.startTracking();
if (tabArea != null) {
g2d.fill(tabArea);
}
g2d.fill(mainArea);
drawingObserver.stopTracking();
g2d.setComposite(oldComposite);
@@ -199,6 +228,9 @@ public class TransistorTO1 extends AbstractTransistorPackage {
}
g2d.setColor(finalBorderColor);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
if (tabArea != null) {
g2d.draw(tabArea);
}
g2d.draw(mainArea);
drawPins(g2d, pinSize, outlineMode ? null : PIN_COLOR,
@@ -249,6 +281,14 @@ public class TransistorTO1 extends AbstractTransistorPackage {
public void drawIcon(Graphics2D g2d, int width, int height) {
int margin = (int) (2f * width / 32);
Area area = new Area(new Ellipse2D.Double(margin / 2, margin, width - 2 * margin, width - 2 * margin));
double centerX = width / 2d - margin / 2;
double centerY = width / 2d;
int tabWidth = 4 * width / 32;
Area tab = new Area(new Rectangle2D.Double(centerX, centerY - tabWidth / 2d,
(width - 2 * margin) / 2d + 3 * width / 32, tabWidth));
tab.transform(AffineTransform.getRotateInstance(-Math.atan(0.5), centerX, centerY));
tab.subtract(area);
area.add(tab);
g2d.setColor(BODY_COLOR);
g2d.fill(area);
g2d.setColor(BORDER_COLOR);
@@ -272,6 +312,19 @@ public class TransistorTO1 extends AbstractTransistorPackage {
body = null;
}
@EditableProperty(name = "Flange")
public Boolean getFlange() {
if (flange == null) {
flange = true;
}
return flange;
}
public void setFlange(Boolean flange) {
this.flange = flange;
body = null;
}
@Override
protected boolean flipPinoutLabel() {
return true;
@@ -721,3 +721,4 @@ Sides|Seiten
All|Alle
Front and Back|Vorne und hinten
Click to choose from %s variants|Klicken, um aus %s Varianten zu wählen
Flange|Flansch
@@ -714,3 +714,4 @@ Sides
All
Front and Back
Click to choose from %s variants
Flange
@@ -717,3 +717,4 @@ Sides|Lados
All|Todos
Front and Back|Frente y parte trasera
Click to choose from %s variants|Haga clic para elegir entre %s variantes
Flange|Brida
@@ -716,3 +716,4 @@ Sides|Côtés
All|Tous
Front and Back|Avant et arrière
Click to choose from %s variants|Cliquez pour choisir parmi %s variantes
Flange|Collerette
@@ -718,3 +718,4 @@ Sides|Lati
All|Tutti
Front and Back|Fronte e retro
Click to choose from %s variants|Fai clic per scegliere tra %s varianti
Flange|Flangia
@@ -722,3 +722,4 @@ Sides|Zijden
All|Alle
Front and Back|Voor- en achterkant
Click to choose from %s variants|Klik om te kiezen uit %s varianten
Flange|Flens
@@ -717,3 +717,4 @@ Sides|Lados
All|Todos
Front and Back|Frente e traseira
Click to choose from %s variants|Clique para escolher entre %s variantes
Flange|Flange
@@ -713,3 +713,4 @@ Sides|Strane
All|Sve
Front and Back|Prednja i zadnja
Click to choose from %s variants|Kliknite da izaberete jednu od %s varijanti
Flange|Obod
@@ -715,3 +715,4 @@ Sides|भुजाएं
All|सभी
Front and Back|आगे और पीछे
Click to choose from %s variants|%s वेरिएंट में से चुनने के लिए क्लिक करें
Flange|फ़्लैंज
@@ -715,3 +715,4 @@ Sides|侧面
All|全部
Front and Back|前后
Click to choose from %s variants|点击从 %s 个变体中选择
Flange|法兰