mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-13 10:42:09 +10:00
transistor improvements
This commit is contained in:
+31
-46
@@ -24,21 +24,26 @@ package org.diylc.components.semiconductors;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.awt.StringUtils;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.IDatasheetSupport;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.gerber.IGerberComponentSimple;
|
||||
import org.diylc.netlist.ISpiceMapper;
|
||||
|
||||
public abstract class AbstractTransistorPackage extends AbstractLabeledComponent<String> implements ISpiceMapper, IGerberComponentSimple {
|
||||
public abstract class AbstractTransistorPackage extends AbstractLabeledComponent<String> implements ISpiceMapper, IGerberComponentSimple,
|
||||
IDatasheetSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -58,59 +63,23 @@ public abstract class AbstractTransistorPackage extends AbstractLabeledComponent
|
||||
public AbstractTransistorPackage() {
|
||||
}
|
||||
|
||||
// columns: group, part number, pinout
|
||||
@Override
|
||||
public void applyModel(String[] model) {
|
||||
setValue(model[1]);
|
||||
setPinout(TransistorPinout.valueOf(model[2]));
|
||||
}
|
||||
|
||||
protected abstract void updateControlPoints();
|
||||
|
||||
public abstract Area[] getBody();
|
||||
|
||||
@Override
|
||||
public int mapToSpiceNode(int index) {
|
||||
if (getPinout() == null)
|
||||
if (getPinout() == null) {
|
||||
return index;
|
||||
|
||||
switch (getPinout()) {
|
||||
case BJT_CBE:
|
||||
return index;
|
||||
case BJT_EBC:
|
||||
return 2 - index;
|
||||
case JFET_DGS:
|
||||
case MOSFET_DGS:
|
||||
return index;
|
||||
case JFET_DSG:
|
||||
case MOSFET_DSG:
|
||||
switch (index) {
|
||||
case 0: return 0;
|
||||
case 1: return 2;
|
||||
case 2: return 1;
|
||||
}
|
||||
case JFET_GSD:
|
||||
case MOSFET_GSD:
|
||||
switch (index) {
|
||||
case 0: return 1;
|
||||
case 1: return 2;
|
||||
case 2: return 0;
|
||||
}
|
||||
case JFET_GDS:
|
||||
case MOSFET_GDS:
|
||||
switch (index) {
|
||||
case 0: return 1;
|
||||
case 1: return 0;
|
||||
case 2: return 2;
|
||||
}
|
||||
case JFET_SGD:
|
||||
case MOSFET_SGD:
|
||||
return 2 - index;
|
||||
case BJT_BCE:
|
||||
switch (index) {
|
||||
case 0: return 1;
|
||||
case 1: return 0;
|
||||
case 2: return 2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return index;
|
||||
return getPinout().mapToSpiceNode(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,6 +251,22 @@ public abstract class AbstractTransistorPackage extends AbstractLabeledComponent
|
||||
return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin, maxY - minY + 2 * margin);
|
||||
}
|
||||
|
||||
// drawn after the body so that pins stay visible whatever its alpha; a null pinColor draws only
|
||||
// the outline
|
||||
protected void drawPins(Graphics2D g2d, int pinSize, Color pinColor, Color pinBorderColor) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
for (Point2D point : controlPoints) {
|
||||
Shape pin = new Ellipse2D.Double(point.getX() - pinSize / 2, point.getY() - pinSize / 2,
|
||||
pinSize, pinSize);
|
||||
if (pinColor != null) {
|
||||
g2d.setColor(pinColor);
|
||||
g2d.fill(pin);
|
||||
}
|
||||
g2d.setColor(pinBorderColor);
|
||||
g2d.draw(pin);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean flipPinoutLabel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+17
-1
@@ -2,7 +2,7 @@ package org.diylc.components.semiconductors;
|
||||
|
||||
public enum TransistorPinout {
|
||||
|
||||
BJT_EBC, BJT_CBE, BJT_BCE, BJT_ECB, JFET_DSG, JFET_GSD, JFET_DGS, JFET_SGD, JFET_GDS, MOSFET_DSG, MOSFET_GSD, MOSFET_DGS, MOSFET_SGD, MOSFET_GDS, REGULATOR_IGO, REGULATOR_OGI, REGULATOR_GOI, REGULATOR_AOI, REGULATOR_GIO;
|
||||
BJT_EBC, BJT_CBE, BJT_BCE, BJT_ECB, BJT_BEC, BJT_CEB, JFET_DSG, JFET_GSD, JFET_DGS, JFET_SGD, JFET_GDS, JFET_SDG, MOSFET_DSG, MOSFET_GSD, MOSFET_DGS, MOSFET_SGD, MOSFET_GDS, REGULATOR_IGO, REGULATOR_OGI, REGULATOR_GOI, REGULATOR_AOI, REGULATOR_AIO, REGULATOR_IOG, REGULATOR_IOA, REGULATOR_GIO;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -21,4 +21,20 @@ public enum TransistorPinout {
|
||||
String[] parts = name().split("_");
|
||||
return parts[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Position of the pin at {@code index} in SPICE node order: C B E for a BJT, D G S for a FET.
|
||||
* Regulators have no SPICE element, so their pins keep their own order.
|
||||
*/
|
||||
public int mapToSpiceNode(int index) {
|
||||
String spiceOrder;
|
||||
if (name().startsWith("BJT")) {
|
||||
spiceOrder = "CBE";
|
||||
} else if (name().startsWith("REGULATOR")) {
|
||||
return index;
|
||||
} else {
|
||||
spiceOrder = "DGS";
|
||||
}
|
||||
return spiceOrder.indexOf(toPinout().charAt(index));
|
||||
}
|
||||
}
|
||||
|
||||
+15
-15
@@ -27,7 +27,6 @@ import java.awt.Composite;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Point2D;
|
||||
@@ -54,10 +53,12 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@AiNote("The first control point is the anchor; with 'Orientation' DEFAULT the third pin is 2 x 'Pin spacing' below it and the middle pin 'Pin spacing' below and 'Pin spacing' to the left, a triangle under the round can. 'Folded' puts the three pins in a straight line down from the anchor and lays the body flat on the right of them. The other orientations rotate this around the anchor")
|
||||
@AiNote("On a 0.1in grid board the default 0.05in 'Pin spacing' puts the middle pin between holes: set 'Pin spacing' to 0.1in to land all three pins on holes")
|
||||
@AiNote("'Pinout' values list pins 1, 2, 3 in control point order. Seen from above, a metal can's leads run counter-clockwise from the tab, which sits beside pin 1; most parts, silicon TO-18/TO-39 and germanium alike, are E-B-C")
|
||||
@ComponentDescriptor(name = "Transistor (TO-1)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistor with small metal body",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO1Transformer.class,
|
||||
enableCache = true)
|
||||
enableCache = true, enableDatasheet = true, datasheetCreationStepCount = 2,
|
||||
datasheetModelColumn = 1)
|
||||
public class TransistorTO1 extends AbstractTransistorPackage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -83,6 +84,12 @@ public class TransistorTO1 extends AbstractTransistorPackage {
|
||||
borderColor = BORDER_COLOR;
|
||||
}
|
||||
|
||||
public TransistorTO1(String[] model) {
|
||||
this();
|
||||
|
||||
applyModel(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateControlPoints() {
|
||||
int pinSpacing = (int) getPinSpacing().convertToPixels();
|
||||
@@ -172,18 +179,8 @@ public class TransistorTO1 extends AbstractTransistorPackage {
|
||||
}
|
||||
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
for (Point2D point : controlPoints) {
|
||||
Shape shape = new Ellipse2D.Double(point.getX() - pinSize / 2, point.getY() - pinSize / 2, pinSize, pinSize);
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fill(shape);
|
||||
}
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.draw(shape);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Area mainArea = getBody()[0];
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||
@@ -204,7 +201,10 @@ public class TransistorTO1 extends AbstractTransistorPackage {
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.draw(mainArea);
|
||||
g2d.draw(mainArea);
|
||||
|
||||
drawPins(g2d, pinSize, outlineMode ? null : PIN_COLOR,
|
||||
outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
+16
-14
@@ -44,6 +44,7 @@ import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Theme;
|
||||
import org.diylc.core.annotations.AiNote;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
@@ -51,10 +52,13 @@ import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@AiNote("The first control point is the anchor and pin 1; with 'Orientation' DEFAULT the three pins run straight down from it 0.1in apart, and the other orientations rotate this around the anchor")
|
||||
@AiNote("'Pinout' values list the pins as a datasheet does, facing the printed front with the metal back away and the legs down, left to right; BD139-style parts are E-C-B")
|
||||
@ComponentDescriptor(name = "Transistor (TO-126)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistors with a hole for heat sink mounting",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class,
|
||||
enableCache = true)
|
||||
enableCache = true, enableDatasheet = true, datasheetCreationStepCount = 2,
|
||||
datasheetModelColumn = 1)
|
||||
public class TransistorTO126 extends AbstractTransistorPackage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -84,6 +88,12 @@ public class TransistorTO126 extends AbstractTransistorPackage {
|
||||
borderColor = BORDER_COLOR;
|
||||
}
|
||||
|
||||
public TransistorTO126(String[] model) {
|
||||
this();
|
||||
|
||||
applyModel(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateControlPoints() {
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
@@ -203,8 +213,8 @@ public class TransistorTO126 extends AbstractTransistorPackage {
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
} else {
|
||||
finalPinColor = METAL_COLOR;
|
||||
finalPinBorderColor = METAL_COLOR.darker();
|
||||
finalPinColor = PIN_COLOR;
|
||||
finalPinBorderColor = PIN_BORDER_COLOR;
|
||||
}
|
||||
Line2D line;
|
||||
for (Point2D point : controlPoints) {
|
||||
@@ -256,17 +266,6 @@ public class TransistorTO126 extends AbstractTransistorPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!outlineMode) {
|
||||
for (Point2D point : controlPoints) {
|
||||
|
||||
g2d.setColor(PIN_COLOR);
|
||||
Shape pin = new Ellipse2D.Double(point.getX() - pinSize / 2, point.getY() - pinSize / 2, pinSize, pinSize);
|
||||
g2d.fill(pin);
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.draw(pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -298,6 +297,9 @@ public class TransistorTO126 extends AbstractTransistorPackage {
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
drawPins(g2d, pinSize, outlineMode ? null : PIN_COLOR,
|
||||
outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
|
||||
+13
-14
@@ -58,7 +58,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Transistor (TO-220)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistors with metal tab for heat sink mounting",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class,
|
||||
enableCache = true)
|
||||
enableCache = true, enableDatasheet = true, datasheetCreationStepCount = 2,
|
||||
datasheetModelColumn = 1)
|
||||
public class TransistorTO220 extends AbstractTransistorPackage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -93,6 +94,12 @@ public class TransistorTO220 extends AbstractTransistorPackage {
|
||||
borderColor = BORDER_COLOR;
|
||||
}
|
||||
|
||||
public TransistorTO220(String[] model) {
|
||||
this();
|
||||
|
||||
applyModel(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateControlPoints() {
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
@@ -234,8 +241,8 @@ public class TransistorTO220 extends AbstractTransistorPackage {
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
} else {
|
||||
finalPinColor = METAL_COLOR;
|
||||
finalPinBorderColor = METAL_COLOR.darker();
|
||||
finalPinColor = PIN_COLOR;
|
||||
finalPinBorderColor = PIN_BORDER_COLOR;
|
||||
}
|
||||
Line2D line;
|
||||
for (Point2D point : controlPoints) {
|
||||
@@ -287,17 +294,6 @@ public class TransistorTO220 extends AbstractTransistorPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!outlineMode) {
|
||||
for (Point2D point : controlPoints) {
|
||||
|
||||
g2d.setColor(PIN_COLOR);
|
||||
Shape pin = new Ellipse2D.Double(point.getX() - pinSize / 2, point.getY() - pinSize / 2, pinSize, pinSize);
|
||||
g2d.fill(pin);
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.draw(pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,6 +335,9 @@ public class TransistorTO220 extends AbstractTransistorPackage {
|
||||
g2d.draw(tabArea);
|
||||
}
|
||||
|
||||
drawPins(g2d, pinSize, outlineMode ? null : PIN_COLOR,
|
||||
outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
|
||||
+191
-20
@@ -36,26 +36,35 @@ import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
|
||||
import org.diylc.awt.StringUtils;
|
||||
import org.diylc.awt.TwoCircleTangent;
|
||||
import org.diylc.common.*;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.components.semiconductors.AbstractTransistorPackage.TransistorDisplay;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDatasheetSupport;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Theme;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.AiNote;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.netlist.ISpiceMapper;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@AiNote("The first control point is pin 1; with 'Orientation' DEFAULT pin 2 is 10.9mm below it and the mounting holes lie left and right of the pins, which sit 1.8mm left of the case centre. The third control point is the case, at the centre of the left mounting hole: connect a wire or solder lug there to reach the collector")
|
||||
@AiNote("'Pinout' values list pin 1, pin 2, then the case, e.g. B-E-C for a 2N3055 whose case is the collector")
|
||||
@ComponentDescriptor(name = "Transistor (TO-3)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistor with large metal body",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, enableCache = true)
|
||||
public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, enableCache = true,
|
||||
enableDatasheet = true, datasheetCreationStepCount = 2, datasheetModelColumn = 1)
|
||||
public class TransistorTO3 extends AbstractLabeledComponent<String>
|
||||
implements ISpiceMapper, IDatasheetSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -76,12 +85,17 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
|
||||
private String value = "";
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
private Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0), new Point2D.Double(0, 0)};
|
||||
// pin 1, pin 2 and the case, reached through the mounting hole on the side of the pins
|
||||
private Point2D[] controlPoints =
|
||||
new Point2D[] {new Point2D.Double(0, 0), new Point2D.Double(0, 0), new Point2D.Double(0, 0)};
|
||||
transient private Area[] body;
|
||||
private Color bodyColor = BODY_COLOR;
|
||||
private Color borderColor = BORDER_COLOR;
|
||||
private Color labelColor = LABEL_COLOR;
|
||||
@Deprecated
|
||||
protected Display display = Display.NAME;
|
||||
private TransistorDisplay transistorDisplay = TransistorDisplay.NAME;
|
||||
private TransistorPinout pinout;
|
||||
|
||||
public TransistorTO3() {
|
||||
super();
|
||||
@@ -89,6 +103,19 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
this.alphaPercent = new Percentage(100);
|
||||
}
|
||||
|
||||
public TransistorTO3(String[] model) {
|
||||
this();
|
||||
|
||||
applyModel(model);
|
||||
}
|
||||
|
||||
// columns: group, part number, pinout of pin 1, pin 2 and the case
|
||||
@Override
|
||||
public void applyModel(String[] model) {
|
||||
setValue(model[1]);
|
||||
setPinout(TransistorPinout.valueOf(model[2]));
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public String getValue() {
|
||||
return value;
|
||||
@@ -110,14 +137,67 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
body = null;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public TransistorPinout getPinout() {
|
||||
return pinout;
|
||||
}
|
||||
|
||||
public void setPinout(TransistorPinout pinout) {
|
||||
this.pinout = pinout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
return getControlPoints().length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return controlPoints[index];
|
||||
return getControlPoints()[index];
|
||||
}
|
||||
|
||||
// files saved before the case point existed hold only the two pins
|
||||
private Point2D[] getControlPoints() {
|
||||
if (controlPoints.length < 3) {
|
||||
controlPoints = new Point2D[] {controlPoints[0], controlPoints[1], new Point2D.Double(0, 0)};
|
||||
updateCasePoint();
|
||||
}
|
||||
return controlPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
if (getPinout() != null) {
|
||||
return getPinout().toPinout().substring(index, index + 1);
|
||||
}
|
||||
return super.getControlPointNodeName(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mapToSpiceNode(int index) {
|
||||
if (getPinout() == null) {
|
||||
return index;
|
||||
}
|
||||
return getPinout().mapToSpiceNode(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return getPinout() == null ? "Pinout not configured, validate this line"
|
||||
: (getPinout().toString() + " pinout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
if (getPinout() == null) {
|
||||
return null;
|
||||
}
|
||||
return getPinout().name().substring(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,11 +212,12 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
controlPoints[index].setLocation(point);
|
||||
getControlPoints()[index].setLocation(point);
|
||||
body = null;
|
||||
}
|
||||
|
||||
private void updateControlPoints() {
|
||||
Point2D[] controlPoints = getControlPoints();
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
// Update control points.
|
||||
double x = controlPoints[0].getX();
|
||||
@@ -157,10 +238,37 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
default:
|
||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
}
|
||||
updateCasePoint();
|
||||
}
|
||||
|
||||
// the centre of the mounting hole on the side the pins are offset towards, rounded as getBody()
|
||||
// rounds it
|
||||
private void updateCasePoint() {
|
||||
int pinOffset = (int) PIN_OFFSET.convertToPixels();
|
||||
int holeDistance = getClosestOdd(HOLE_DISTANCE.convertToPixels());
|
||||
double x = (controlPoints[0].getX() + controlPoints[1].getX()) / 2;
|
||||
double y = (controlPoints[0].getY() + controlPoints[1].getY()) / 2;
|
||||
switch (orientation) {
|
||||
case DEFAULT:
|
||||
controlPoints[2].setLocation(x + pinOffset - holeDistance / 2, y);
|
||||
break;
|
||||
case _90:
|
||||
controlPoints[2].setLocation(x, y + pinOffset - holeDistance / 2);
|
||||
break;
|
||||
case _180:
|
||||
controlPoints[2].setLocation(x - pinOffset + holeDistance / 2, y);
|
||||
break;
|
||||
case _270:
|
||||
controlPoints[2].setLocation(x, y - pinOffset + holeDistance / 2);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
}
|
||||
}
|
||||
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
Point2D[] controlPoints = getControlPoints();
|
||||
body = new Area[2];
|
||||
int pinOffset = (int) PIN_OFFSET.convertToPixels();
|
||||
double x = (controlPoints[0].getX() + controlPoints[1].getX()) / 2;
|
||||
@@ -233,15 +341,6 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
|
||||
for (Point2D point : controlPoints) {
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fillOval((int) Math.round(point.getX() - pinSize / 2), (int) Math.round(point.getY() - pinSize / 2), pinSize, pinSize);
|
||||
}
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.drawOval((int) Math.round(point.getX() - pinSize / 2), (int) Math.round(point.getY() - pinSize / 2), pinSize, pinSize);
|
||||
}
|
||||
|
||||
Area mainArea = getBody()[0];
|
||||
Area innerArea = getBody()[1];
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
@@ -264,7 +363,21 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
g2d.setColor(finalBorderColor);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.draw(mainArea);
|
||||
g2d.draw(innerArea);
|
||||
g2d.draw(innerArea);
|
||||
|
||||
// the pins leave through the bottom of the case, so they are drawn over it to stay visible
|
||||
// whatever its alpha
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Point2D point = getControlPoint(i);
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fillOval((int) Math.round(point.getX() - pinSize / 2),
|
||||
(int) Math.round(point.getY() - pinSize / 2), pinSize, pinSize);
|
||||
}
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.drawOval((int) Math.round(point.getX() - pinSize / 2),
|
||||
(int) Math.round(point.getY() - pinSize / 2), pinSize, pinSize);
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
@@ -284,12 +397,16 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
: getLabelColor();
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
if (getTransistorDisplay() == TransistorDisplay.PINOUT) {
|
||||
drawPinout(g2d);
|
||||
return;
|
||||
}
|
||||
String label = "";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
if (getDisplay() == Display.NONE) {
|
||||
label = (getTransistorDisplay() == TransistorDisplay.NAME) ? getName() : getValue();
|
||||
if (getTransistorDisplay() == TransistorDisplay.NONE) {
|
||||
label = "";
|
||||
}
|
||||
if (getDisplay() == Display.BOTH) {
|
||||
if (getTransistorDisplay() == TransistorDisplay.BOTH) {
|
||||
label = getName() + " " + (getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
@@ -303,6 +420,47 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
g2d.drawString(label, x, y);
|
||||
}
|
||||
|
||||
// each letter sits beside its pin or hole on the side of the body centre
|
||||
private void drawPinout(Graphics2D g2d) {
|
||||
if (getPinout() == null) {
|
||||
return;
|
||||
}
|
||||
g2d.setFont(g2d.getFont().deriveFont((float) (g2d.getFont().getSize() * 0.7)));
|
||||
String pinout = getPinout().toPinout();
|
||||
int pinD = (int) PIN_DIAMETER.convertToPixels();
|
||||
int holeD = (int) HOLE_SIZE.convertToPixels();
|
||||
for (int i = 0; i < pinout.length(); i++) {
|
||||
Point2D point = getControlPoint(i);
|
||||
int d = (i < 2 ? pinD : holeD) / 2 + 2;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
HorizontalAlignment ha = HorizontalAlignment.CENTER;
|
||||
VerticalAlignment va = VerticalAlignment.CENTER;
|
||||
switch (getOrientation()) {
|
||||
case DEFAULT:
|
||||
dx = d;
|
||||
ha = HorizontalAlignment.LEFT;
|
||||
break;
|
||||
case _90:
|
||||
dy = d;
|
||||
va = VerticalAlignment.BOTTOM;
|
||||
break;
|
||||
case _180:
|
||||
dx = -d;
|
||||
ha = HorizontalAlignment.RIGHT;
|
||||
break;
|
||||
case _270:
|
||||
dy = -d;
|
||||
va = VerticalAlignment.TOP;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
}
|
||||
StringUtils.drawCenteredText(g2d, pinout.substring(i, i + 1), point.getX() + dx,
|
||||
point.getY() + dy, ha, va);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
|
||||
@@ -351,7 +509,7 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
this.labelColor = labelColor;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@Deprecated
|
||||
public Display getDisplay() {
|
||||
if (display == null) {
|
||||
display = Display.NAME;
|
||||
@@ -359,9 +517,22 @@ public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
return display;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDisplay(Display display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Display")
|
||||
public TransistorDisplay getTransistorDisplay() {
|
||||
if (transistorDisplay == null) {
|
||||
transistorDisplay = TransistorDisplay.valueOf(getDisplay().name());
|
||||
}
|
||||
return transistorDisplay;
|
||||
}
|
||||
|
||||
public void setTransistorDisplay(TransistorDisplay transistorDisplay) {
|
||||
this.transistorDisplay = transistorDisplay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
|
||||
+14
-18
@@ -28,7 +28,6 @@ import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Point2D;
|
||||
@@ -59,7 +58,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Transistor (TO-92)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistor with small plastic or epoxy body",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO92Transformer.class,
|
||||
enableCache = true)
|
||||
enableCache = true, enableDatasheet = true, datasheetCreationStepCount = 2,
|
||||
datasheetModelColumn = 1)
|
||||
public class TransistorTO92 extends AbstractTransistorPackage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -83,6 +83,12 @@ public class TransistorTO92 extends AbstractTransistorPackage {
|
||||
borderColor = BORDER_COLOR;
|
||||
}
|
||||
|
||||
public TransistorTO92(String[] model) {
|
||||
this();
|
||||
|
||||
applyModel(model);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Pin spacing")
|
||||
public Size getPinSpacing() {
|
||||
if (pinSpacing == null) {
|
||||
@@ -195,18 +201,9 @@ public class TransistorTO92 extends AbstractTransistorPackage {
|
||||
}
|
||||
drawingObserver.stopTracking();
|
||||
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
|
||||
if (!outlineMode) {
|
||||
for (Point2D point : controlPoints) {
|
||||
Shape pin = new Ellipse2D.Double(point.getX() - pinSize / 2, point.getY() - pinSize / 2, pinSize, pinSize);
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fill(pin);
|
||||
g2d.setColor(PIN_BORDER_COLOR);
|
||||
g2d.draw(pin);
|
||||
}
|
||||
}
|
||||
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
|
||||
Area mainArea = getBody()[0];
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||
@@ -216,8 +213,6 @@ public class TransistorTO92 extends AbstractTransistorPackage {
|
||||
g2d.setComposite(oldComposite);
|
||||
Color finalBorderColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
@@ -230,6 +225,9 @@ public class TransistorTO92 extends AbstractTransistorPackage {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.draw(mainArea);
|
||||
|
||||
drawPins(g2d, pinSize, outlineMode ? null : PIN_COLOR,
|
||||
outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
@@ -239,8 +237,6 @@ public class TransistorTO92 extends AbstractTransistorPackage {
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalLabelColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||
: theme.getOutlineColor();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
BJT (NPN),BC107,BJT_EBC
|
||||
BJT (NPN),BC108,BJT_EBC
|
||||
BJT (NPN),BC109,BJT_EBC
|
||||
BJT (NPN),2N2222A,BJT_EBC
|
||||
BJT (NPN),2N2369A,BJT_EBC
|
||||
BJT (NPN),2N2219A,BJT_EBC
|
||||
BJT (NPN),2N1613,BJT_EBC
|
||||
BJT (NPN),2N1711,BJT_EBC
|
||||
BJT (NPN),2N3053,BJT_EBC
|
||||
BJT (NPN),2N3866,BJT_EBC
|
||||
BJT (NPN),BFY51,BJT_EBC
|
||||
BJT (PNP),BC177,BJT_EBC
|
||||
BJT (PNP),BC178,BJT_EBC
|
||||
BJT (PNP),BC179,BJT_EBC
|
||||
BJT (PNP),2N2907A,BJT_EBC
|
||||
BJT (PNP),2N2905A,BJT_EBC
|
||||
Germanium (NPN),AC127,BJT_EBC
|
||||
Germanium (NPN),AC176,BJT_EBC
|
||||
Germanium (NPN),AC187,BJT_EBC
|
||||
Germanium (NPN),2N1308,BJT_EBC
|
||||
Germanium (PNP),AC126,BJT_EBC
|
||||
Germanium (PNP),AC128,BJT_EBC
|
||||
Germanium (PNP),AC188,BJT_EBC
|
||||
Germanium (PNP),OC44,BJT_EBC
|
||||
Germanium (PNP),OC45,BJT_EBC
|
||||
Germanium (PNP),OC71,BJT_EBC
|
||||
Germanium (PNP),OC75,BJT_EBC
|
||||
Germanium (PNP),OC76,BJT_EBC
|
||||
Germanium (PNP),OC81,BJT_EBC
|
||||
Germanium (PNP),2N404,BJT_EBC
|
||||
Germanium (PNP),2N1305,BJT_EBC
|
||||
@@ -0,0 +1,22 @@
|
||||
BJT (NPN),BD135,BJT_ECB
|
||||
BJT (NPN),BD137,BJT_ECB
|
||||
BJT (NPN),BD139,BJT_ECB
|
||||
BJT (NPN),BD237,BJT_ECB
|
||||
BJT (NPN),MJE340,BJT_ECB
|
||||
BJT (NPN),MJE180,BJT_ECB
|
||||
BJT (NPN),2SC3423,BJT_ECB
|
||||
BJT (NPN),KSC3503,BJT_ECB
|
||||
BJT (NPN),2SD669A,BJT_ECB
|
||||
BJT (NPN),BF469,BJT_ECB
|
||||
BJT (PNP),BD136,BJT_ECB
|
||||
BJT (PNP),BD138,BJT_ECB
|
||||
BJT (PNP),BD140,BJT_ECB
|
||||
BJT (PNP),BD238,BJT_ECB
|
||||
BJT (PNP),MJE350,BJT_ECB
|
||||
BJT (PNP),MJE170,BJT_ECB
|
||||
BJT (PNP),2SA1360,BJT_ECB
|
||||
BJT (PNP),KSA1381,BJT_ECB
|
||||
BJT (PNP),2SB649A,BJT_ECB
|
||||
BJT (PNP),BF470,BJT_ECB
|
||||
Darlington (NPN),BD681,BJT_ECB
|
||||
Darlington (PNP),BD682,BJT_ECB
|
||||
@@ -0,0 +1,67 @@
|
||||
BJT (NPN),TIP29C,BJT_BCE
|
||||
BJT (NPN),TIP31C,BJT_BCE
|
||||
BJT (NPN),TIP41C,BJT_BCE
|
||||
BJT (NPN),MJE3055T,BJT_BCE
|
||||
BJT (NPN),MJE15028,BJT_BCE
|
||||
BJT (NPN),MJE15030,BJT_BCE
|
||||
BJT (NPN),MJE15032,BJT_BCE
|
||||
BJT (NPN),BD243C,BJT_BCE
|
||||
BJT (NPN),BD911,BJT_BCE
|
||||
BJT (PNP),TIP30C,BJT_BCE
|
||||
BJT (PNP),TIP32C,BJT_BCE
|
||||
BJT (PNP),TIP42C,BJT_BCE
|
||||
BJT (PNP),MJE2955T,BJT_BCE
|
||||
BJT (PNP),MJE15029,BJT_BCE
|
||||
BJT (PNP),MJE15031,BJT_BCE
|
||||
BJT (PNP),MJE15033,BJT_BCE
|
||||
BJT (PNP),BD244C,BJT_BCE
|
||||
BJT (PNP),BD912,BJT_BCE
|
||||
Darlington (NPN),TIP120,BJT_BCE
|
||||
Darlington (NPN),TIP121,BJT_BCE
|
||||
Darlington (NPN),TIP122,BJT_BCE
|
||||
Darlington (PNP),TIP125,BJT_BCE
|
||||
Darlington (PNP),TIP126,BJT_BCE
|
||||
Darlington (PNP),TIP127,BJT_BCE
|
||||
MOSFET (N),IRF510,MOSFET_GDS
|
||||
MOSFET (N),IRF520,MOSFET_GDS
|
||||
MOSFET (N),IRF530,MOSFET_GDS
|
||||
MOSFET (N),IRF540N,MOSFET_GDS
|
||||
MOSFET (N),IRF610,MOSFET_GDS
|
||||
MOSFET (N),IRF640,MOSFET_GDS
|
||||
MOSFET (N),IRF840,MOSFET_GDS
|
||||
MOSFET (N),IRFZ44N,MOSFET_GDS
|
||||
MOSFET (N),IRLZ44N,MOSFET_GDS
|
||||
MOSFET (N),IRF3205,MOSFET_GDS
|
||||
MOSFET (N),FQP30N06L,MOSFET_GDS
|
||||
MOSFET (P),IRF9530,MOSFET_GDS
|
||||
MOSFET (P),IRF9540N,MOSFET_GDS
|
||||
MOSFET (P),IRF9610,MOSFET_GDS
|
||||
MOSFET (P),IRF9640,MOSFET_GDS
|
||||
Regulator (+),7805,REGULATOR_IGO
|
||||
Regulator (+),7806,REGULATOR_IGO
|
||||
Regulator (+),7808,REGULATOR_IGO
|
||||
Regulator (+),7809,REGULATOR_IGO
|
||||
Regulator (+),7812,REGULATOR_IGO
|
||||
Regulator (+),7815,REGULATOR_IGO
|
||||
Regulator (+),7818,REGULATOR_IGO
|
||||
Regulator (+),7824,REGULATOR_IGO
|
||||
Regulator (+),LM317T,REGULATOR_AOI
|
||||
Regulator (+),LM338T,REGULATOR_AOI
|
||||
Regulator (+),LM350T,REGULATOR_AOI
|
||||
Regulator (+),LM1084-ADJ,REGULATOR_AOI
|
||||
Regulator (+),LM1085-ADJ,REGULATOR_AOI
|
||||
Regulator (+),LM1086-ADJ,REGULATOR_AOI
|
||||
Regulator (+),LM1086-3.3,REGULATOR_GOI
|
||||
Regulator (+),LM1086-5.0,REGULATOR_GOI
|
||||
Regulator (+),LM1117T-ADJ,REGULATOR_AOI
|
||||
Regulator (+),LM1117T-3.3,REGULATOR_GOI
|
||||
Regulator (+),LM1117T-5.0,REGULATOR_GOI
|
||||
Regulator (+),LD1117V,REGULATOR_AOI
|
||||
Regulator (+),LD1117V33,REGULATOR_GOI
|
||||
Regulator (+),LD1117V50,REGULATOR_GOI
|
||||
Regulator (+),LM2940CT-5.0,REGULATOR_IGO
|
||||
Regulator (+),LM2940CT-12,REGULATOR_IGO
|
||||
Regulator (-),7905,REGULATOR_GIO
|
||||
Regulator (-),7912,REGULATOR_GIO
|
||||
Regulator (-),7915,REGULATOR_GIO
|
||||
Regulator (-),LM337T,REGULATOR_AIO
|
||||
@@ -0,0 +1,27 @@
|
||||
BJT (NPN),2N3055,BJT_BEC
|
||||
BJT (NPN),2N3442,BJT_BEC
|
||||
BJT (NPN),2N3773,BJT_BEC
|
||||
BJT (NPN),MJ15003,BJT_BEC
|
||||
BJT (NPN),MJ15015,BJT_BEC
|
||||
BJT (NPN),MJ15022,BJT_BEC
|
||||
BJT (NPN),MJ15024,BJT_BEC
|
||||
BJT (PNP),MJ2955,BJT_BEC
|
||||
BJT (PNP),2N6609,BJT_BEC
|
||||
BJT (PNP),MJ15004,BJT_BEC
|
||||
BJT (PNP),MJ15016,BJT_BEC
|
||||
BJT (PNP),MJ15023,BJT_BEC
|
||||
BJT (PNP),MJ15025,BJT_BEC
|
||||
Darlington (NPN),MJ11016,BJT_BEC
|
||||
Darlington (NPN),MJ11032,BJT_BEC
|
||||
Darlington (PNP),MJ11015,BJT_BEC
|
||||
Darlington (PNP),MJ11033,BJT_BEC
|
||||
MOSFET (N),IRF150,MOSFET_GSD
|
||||
Regulator (+),LM317K,REGULATOR_AIO
|
||||
Regulator (+),LM338K,REGULATOR_AIO
|
||||
Regulator (+),LM350K,REGULATOR_AIO
|
||||
Regulator (+),LM309K,REGULATOR_IOG
|
||||
Regulator (+),LM323K,REGULATOR_IOG
|
||||
Regulator (+),LM340K-5.0,REGULATOR_IOG
|
||||
Regulator (+),LM340K-12,REGULATOR_IOG
|
||||
Regulator (+),LM340K-15,REGULATOR_IOG
|
||||
Regulator (-),LM337K,REGULATOR_AOI
|
||||
@@ -0,0 +1,109 @@
|
||||
BJT (NPN),2N3904,BJT_EBC
|
||||
BJT (NPN),2N4401,BJT_EBC
|
||||
BJT (NPN),PN2222A,BJT_EBC
|
||||
BJT (NPN),2N4124,BJT_EBC
|
||||
BJT (NPN),2N5088,BJT_EBC
|
||||
BJT (NPN),2N5089,BJT_EBC
|
||||
BJT (NPN),2N5210,BJT_EBC
|
||||
BJT (NPN),2N5551,BJT_EBC
|
||||
BJT (NPN),MPSA06,BJT_EBC
|
||||
BJT (NPN),MPSA18,BJT_EBC
|
||||
BJT (NPN),MPSA42,BJT_EBC
|
||||
BJT (NPN),MPS5179,BJT_EBC
|
||||
BJT (NPN),S8050,BJT_EBC
|
||||
BJT (NPN),S9013,BJT_EBC
|
||||
BJT (NPN),S9014,BJT_EBC
|
||||
BJT (NPN),S9018,BJT_EBC
|
||||
BJT (NPN),BC546,BJT_CBE
|
||||
BJT (NPN),BC547,BJT_CBE
|
||||
BJT (NPN),BC548,BJT_CBE
|
||||
BJT (NPN),BC549,BJT_CBE
|
||||
BJT (NPN),BC550,BJT_CBE
|
||||
BJT (NPN),BC337,BJT_CBE
|
||||
BJT (NPN),BC182,BJT_CBE
|
||||
BJT (NPN),BC184,BJT_CBE
|
||||
BJT (NPN),BC239,BJT_CBE
|
||||
BJT (NPN),P2N2222A,BJT_CBE
|
||||
BJT (NPN),BC639,BJT_ECB
|
||||
BJT (NPN),BC182L,BJT_ECB
|
||||
BJT (NPN),BC184L,BJT_ECB
|
||||
BJT (NPN),2SC1815,BJT_ECB
|
||||
BJT (NPN),2SC945,BJT_ECB
|
||||
BJT (NPN),2SC2240,BJT_ECB
|
||||
BJT (NPN),2SC1845,BJT_ECB
|
||||
BJT (NPN),KSC1845,BJT_ECB
|
||||
BJT (NPN),2SC2458,BJT_ECB
|
||||
BJT (NPN),BF199,BJT_CEB
|
||||
BJT (NPN),BF494,BJT_CEB
|
||||
BJT (NPN),MPSH10,BJT_BEC
|
||||
BJT (PNP),2N3906,BJT_EBC
|
||||
BJT (PNP),2N4403,BJT_EBC
|
||||
BJT (PNP),PN2907A,BJT_EBC
|
||||
BJT (PNP),2N4126,BJT_EBC
|
||||
BJT (PNP),2N5087,BJT_EBC
|
||||
BJT (PNP),2N5401,BJT_EBC
|
||||
BJT (PNP),MPSA56,BJT_EBC
|
||||
BJT (PNP),MPSA92,BJT_EBC
|
||||
BJT (PNP),S8550,BJT_EBC
|
||||
BJT (PNP),S9012,BJT_EBC
|
||||
BJT (PNP),S9015,BJT_EBC
|
||||
BJT (PNP),KSP2907A,BJT_EBC
|
||||
BJT (PNP),BC556,BJT_CBE
|
||||
BJT (PNP),BC557,BJT_CBE
|
||||
BJT (PNP),BC558,BJT_CBE
|
||||
BJT (PNP),BC559,BJT_CBE
|
||||
BJT (PNP),BC560,BJT_CBE
|
||||
BJT (PNP),BC327,BJT_CBE
|
||||
BJT (PNP),BC212,BJT_CBE
|
||||
BJT (PNP),BC214,BJT_CBE
|
||||
BJT (PNP),BC640,BJT_ECB
|
||||
BJT (PNP),2SA1015,BJT_ECB
|
||||
BJT (PNP),2SA970,BJT_ECB
|
||||
BJT (PNP),2SA992,BJT_ECB
|
||||
BJT (PNP),KSA992,BJT_ECB
|
||||
BJT (PNP),KSP2907AC,BJT_ECB
|
||||
Darlington (NPN),MPSA13,BJT_EBC
|
||||
Darlington (NPN),MPSA14,BJT_EBC
|
||||
Darlington (PNP),MPSA63,BJT_EBC
|
||||
Darlington (PNP),MPSA64,BJT_EBC
|
||||
JFET (N),J201,JFET_DSG
|
||||
JFET (N),J202,JFET_DSG
|
||||
JFET (N),J111,JFET_DSG
|
||||
JFET (N),J112,JFET_DSG
|
||||
JFET (N),J113,JFET_DSG
|
||||
JFET (N),J310,JFET_DSG
|
||||
JFET (N),2N5457,JFET_DSG
|
||||
JFET (N),2N5458,JFET_DSG
|
||||
JFET (N),2N5459,JFET_DSG
|
||||
JFET (N),2N5484,JFET_DSG
|
||||
JFET (N),2N5485,JFET_DSG
|
||||
JFET (N),2N5486,JFET_DSG
|
||||
JFET (N),PN4416,JFET_DSG
|
||||
JFET (N),MPF102,JFET_DSG
|
||||
JFET (N),BF245A,JFET_DSG
|
||||
JFET (N),BF245B,JFET_DSG
|
||||
JFET (N),BF245C,JFET_DSG
|
||||
JFET (N),2N3819,JFET_SGD
|
||||
JFET (N),BF256B,JFET_GSD
|
||||
JFET (N),2SK170,JFET_DGS
|
||||
JFET (N),LSK170,JFET_DGS
|
||||
JFET (P),J174,JFET_DGS
|
||||
JFET (P),J175,JFET_DGS
|
||||
JFET (P),J176,JFET_DGS
|
||||
JFET (P),2N3820,JFET_DGS
|
||||
JFET (P),2N5460,JFET_SDG
|
||||
MOSFET (N),2N7000,MOSFET_SGD
|
||||
MOSFET (N),LND150,MOSFET_SGD
|
||||
MOSFET (N),BS170,MOSFET_DGS
|
||||
Regulator (+),78L05,REGULATOR_OGI
|
||||
Regulator (+),78L09,REGULATOR_OGI
|
||||
Regulator (+),78L12,REGULATOR_OGI
|
||||
Regulator (+),78L15,REGULATOR_OGI
|
||||
Regulator (+),LP2950-5.0,REGULATOR_OGI
|
||||
Regulator (+),LM2936Z-5.0,REGULATOR_OGI
|
||||
Regulator (+),LM317LZ,REGULATOR_AOI
|
||||
Regulator (+),LR8,REGULATOR_IOA
|
||||
Regulator (-),79L05,REGULATOR_GIO
|
||||
Regulator (-),79L12,REGULATOR_GIO
|
||||
Regulator (-),79L15,REGULATOR_GIO
|
||||
Regulator (-),LM337LZ,REGULATOR_AOI
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.semiconductors;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.presenter.DatasheetService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/** The datasheets of all transistor packages, which share one row format. */
|
||||
public class TransistorDatasheetTest {
|
||||
|
||||
private static final List<Class<? extends IDIYComponent<?>>> PACKAGES =
|
||||
Arrays.asList(TransistorTO1.class, TransistorTO3.class, TransistorTO92.class,
|
||||
TransistorTO126.class, TransistorTO220.class);
|
||||
|
||||
@Test
|
||||
public void everyRowApplies() throws Exception {
|
||||
for (Class<? extends IDIYComponent<?>> type : PACKAGES) {
|
||||
for (String[] row : datasheet(type)) {
|
||||
String context = type.getSimpleName() + ": " + String.join(",", row);
|
||||
Assert.assertEquals(context, 3, row.length);
|
||||
IDIYComponent<?> transistor =
|
||||
type.getConstructor(String[].class).newInstance((Object) row);
|
||||
Assert.assertEquals(context, row[1], transistor.getValue());
|
||||
String pinout = TransistorPinout.valueOf(row[2]).toPinout();
|
||||
for (int i = 0; i < pinout.length(); i++) {
|
||||
Assert.assertEquals(context, pinout.substring(i, i + 1),
|
||||
transistor.getControlPointNodeName(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void partNumbersAreUnique() {
|
||||
for (Class<? extends IDIYComponent<?>> type : PACKAGES) {
|
||||
Set<String> parts = new HashSet<String>();
|
||||
for (String[] row : datasheet(type)) {
|
||||
Assert.assertTrue(type.getSimpleName() + " repeats " + row[1],
|
||||
parts.add(row[1].toUpperCase()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void partIsFoundByNumberNotByGroup() {
|
||||
DatasheetService service = DatasheetService.getInstance();
|
||||
for (Class<? extends IDIYComponent<?>> type : PACKAGES) {
|
||||
String[] first = datasheet(type).get(0);
|
||||
Assert.assertEquals(1, service.findSeries(type, first[1]).size());
|
||||
Assert.assertTrue(service.findSeries(type, first[0]).isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String[]> datasheet(Class<? extends IDIYComponent<?>> type) {
|
||||
List<String[]> datasheet = DatasheetService.getInstance().loadDatasheet(type);
|
||||
Assert.assertNotNull(type.getSimpleName(), datasheet);
|
||||
Assert.assertFalse(type.getSimpleName(), datasheet.isEmpty());
|
||||
return datasheet;
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.semiconductors;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TransistorPinoutTest {
|
||||
|
||||
@Test
|
||||
public void bjtPinsMapToCollectorBaseEmitter() {
|
||||
assertSpiceNodes(TransistorPinout.BJT_EBC, 2, 1, 0);
|
||||
assertSpiceNodes(TransistorPinout.BJT_CBE, 0, 1, 2);
|
||||
assertSpiceNodes(TransistorPinout.BJT_BCE, 1, 0, 2);
|
||||
assertSpiceNodes(TransistorPinout.BJT_ECB, 2, 0, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetPinsMapToDrainGateSource() {
|
||||
assertSpiceNodes(TransistorPinout.JFET_DSG, 0, 2, 1);
|
||||
assertSpiceNodes(TransistorPinout.JFET_GSD, 1, 2, 0);
|
||||
assertSpiceNodes(TransistorPinout.JFET_SGD, 2, 1, 0);
|
||||
assertSpiceNodes(TransistorPinout.MOSFET_GDS, 1, 0, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regulatorPinsKeepTheirOrder() {
|
||||
assertSpiceNodes(TransistorPinout.REGULATOR_IGO, 0, 1, 2);
|
||||
}
|
||||
|
||||
/** Every value names three distinct pins with letters its type knows. */
|
||||
@Test
|
||||
public void everyPinoutIsAPermutationOfItsRoles() {
|
||||
for (TransistorPinout pinout : TransistorPinout.values()) {
|
||||
String pins = pinout.toPinout();
|
||||
Assert.assertEquals(pinout.name(), 3, pins.length());
|
||||
Assert.assertEquals(pinout.name(), 3, pins.chars().distinct().count());
|
||||
String roles = pinout.name().startsWith("BJT") ? "BCE"
|
||||
: pinout.name().startsWith("REGULATOR") ? "IOGA" : "DGS";
|
||||
for (char c : pins.toCharArray()) {
|
||||
Assert.assertTrue(pinout.name(), roles.indexOf(c) >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertSpiceNodes(TransistorPinout pinout, int... expected) {
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
Assert.assertEquals(pinout + " pin " + i, expected[i], pinout.mapToSpiceNode(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.semiconductors;
|
||||
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.diylc.common.Display;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.semiconductors.AbstractTransistorPackage.TransistorDisplay;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TransistorTO3Test {
|
||||
|
||||
@Test
|
||||
public void caseIsReachedThroughAMountingHole() {
|
||||
for (Orientation orientation : Orientation.values()) {
|
||||
TransistorTO3 transistor = new TransistorTO3();
|
||||
transistor.setOrientation(orientation);
|
||||
Point2D casePoint = transistor.getControlPoint(2);
|
||||
Area body = transistor.getBody()[0];
|
||||
Assert.assertTrue(orientation.name(), body.getBounds2D().contains(casePoint));
|
||||
Assert.assertFalse(orientation.name(), body.contains(casePoint));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileWithoutCasePointGainsIt() throws Exception {
|
||||
TransistorTO3 expected = new TransistorTO3();
|
||||
expected.setOrientation(Orientation._90);
|
||||
TransistorTO3 legacy = new TransistorTO3();
|
||||
legacy.setOrientation(Orientation._90);
|
||||
setField(legacy, "controlPoints",
|
||||
new Point2D[] {legacy.getControlPoint(0), legacy.getControlPoint(1)});
|
||||
|
||||
Assert.assertEquals(3, legacy.getControlPointCount());
|
||||
Assert.assertEquals(expected.getControlPoint(2), legacy.getControlPoint(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nodeNamesFollowThePinout() {
|
||||
TransistorTO3 transistor = new TransistorTO3();
|
||||
Assert.assertEquals("1", transistor.getControlPointNodeName(0));
|
||||
Assert.assertEquals("3", transistor.getControlPointNodeName(2));
|
||||
transistor.setPinout(TransistorPinout.BJT_BEC);
|
||||
Assert.assertEquals("B", transistor.getControlPointNodeName(0));
|
||||
Assert.assertEquals("E", transistor.getControlPointNodeName(1));
|
||||
Assert.assertEquals("C", transistor.getControlPointNodeName(2));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void displayIsReadFromTheLegacyField() throws Exception {
|
||||
TransistorTO3 transistor = new TransistorTO3();
|
||||
transistor.setDisplay(Display.BOTH);
|
||||
setField(transistor, "transistorDisplay", null);
|
||||
Assert.assertEquals(TransistorDisplay.BOTH, transistor.getTransistorDisplay());
|
||||
}
|
||||
|
||||
private static void setField(Object target, String name, Object value) throws Exception {
|
||||
Field field = TransistorTO3.class.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
field.set(target, value);
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ semiconductors.SchottkyDiodeSymbol = fixed
|
||||
semiconductors.TransistorTO1 = Pinout
|
||||
semiconductors.TransistorTO126 = Pinout
|
||||
semiconductors.TransistorTO220 = Pinout
|
||||
semiconductors.TransistorTO3 = fixed
|
||||
semiconductors.TransistorTO3 = Pinout
|
||||
semiconductors.TransistorTO92 = Pinout
|
||||
semiconductors.ZenerDiodeSymbol = fixed
|
||||
shapes.Ellipse = none
|
||||
|
||||
Reference in New Issue
Block a user