mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
refactor transistor packages with a base class, add pinouts
This commit is contained in:
Binary file not shown.
+187
@@ -0,0 +1,187 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
DIY Layout Creator (DIYLC).
|
||||||
|
Copyright (c) 2009-2018 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.Color;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.geom.Area;
|
||||||
|
|
||||||
|
import org.diylc.common.Display;
|
||||||
|
import org.diylc.common.Orientation;
|
||||||
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
import org.diylc.netlist.ISpiceMapper;
|
||||||
|
|
||||||
|
public abstract class AbstractTransistorPackage extends AbstractTransparentComponent<String> implements ISpiceMapper {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
protected String value = "";
|
||||||
|
protected TransistorPinout pinout;
|
||||||
|
protected Orientation orientation = Orientation.DEFAULT;
|
||||||
|
protected Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||||
|
transient protected Area[] body;
|
||||||
|
|
||||||
|
protected Color bodyColor;
|
||||||
|
protected Color borderColor;
|
||||||
|
protected Color labelColor = LABEL_COLOR;
|
||||||
|
protected Display display = Display.NAME;
|
||||||
|
|
||||||
|
public AbstractTransistorPackage() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void updateControlPoints();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int mapToSpiceNode(int index) {
|
||||||
|
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_SGD:
|
||||||
|
case MOSFET_SGD:
|
||||||
|
return 2 - index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Orientation getOrientation() {
|
||||||
|
return orientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrientation(Orientation orientation) {
|
||||||
|
this.orientation = orientation;
|
||||||
|
updateControlPoints();
|
||||||
|
// Reset body shape;
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getControlPointCount() {
|
||||||
|
return controlPoints.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Point getControlPoint(int index) {
|
||||||
|
return controlPoints[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setControlPoint(Point point, int index) {
|
||||||
|
controlPoints[index].setLocation(point);
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Body")
|
||||||
|
public Color getBodyColor() {
|
||||||
|
return bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyColor(Color bodyColor) {
|
||||||
|
this.bodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Border")
|
||||||
|
public Color getBorderColor() {
|
||||||
|
return borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBorderColor(Color borderColor) {
|
||||||
|
this.borderColor = borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Label")
|
||||||
|
public Color getLabelColor() {
|
||||||
|
if (labelColor == null) {
|
||||||
|
labelColor = LABEL_COLOR;
|
||||||
|
}
|
||||||
|
return labelColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabelColor(Color labelColor) {
|
||||||
|
this.labelColor = labelColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Display getDisplay() {
|
||||||
|
if (display == null) {
|
||||||
|
display = Display.NAME;
|
||||||
|
}
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplay(Display display) {
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public TransistorPinout getPinout() {
|
||||||
|
return pinout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPinout(TransistorPinout pinout) {
|
||||||
|
this.pinout = pinout;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.diylc.components.semiconductors;
|
||||||
|
|
||||||
|
public enum TransistorPinout {
|
||||||
|
|
||||||
|
BJT_EBC, BJT_CBE, JFET_DSG, JFET_GSD, JFET_DGS, JFET_SGD, MOSFET_DSG, MOSFET_GSD, MOSFET_DGS, MOSFET_SGD;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().replace("_", " ");
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -37,15 +37,12 @@ import org.diylc.appframework.miscutils.ConfigurationManager;
|
|||||||
import org.diylc.common.Display;
|
import org.diylc.common.Display;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
|
||||||
import org.diylc.components.transform.TO1Transformer;
|
import org.diylc.components.transform.TO1Transformer;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.Theme;
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
|
||||||
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.KeywordPolicy;
|
import org.diylc.core.annotations.KeywordPolicy;
|
||||||
@@ -56,7 +53,7 @@ import org.diylc.utils.Constants;
|
|||||||
@ComponentDescriptor(name = "Transistor (TO-1)", author = "Branislav Stojkovic", category = "Semiconductors",
|
@ComponentDescriptor(name = "Transistor (TO-1)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||||
instanceNamePrefix = "Q", description = "Transistor with small metal body", stretchable = false,
|
instanceNamePrefix = "Q", description = "Transistor with small metal body", stretchable = false,
|
||||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO1Transformer.class)
|
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO1Transformer.class)
|
||||||
public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
public class TransistorTO1 extends AbstractTransistorPackage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -71,14 +68,6 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
public static Size BODY_LENGTH = new Size(0.4d, 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 EDGE_RADIUS = new Size(2d, SizeUnit.mm);
|
||||||
|
|
||||||
private String value = "";
|
|
||||||
private Orientation orientation = Orientation.DEFAULT;
|
|
||||||
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
|
||||||
transient private Area body;
|
|
||||||
private Color bodyColor = BODY_COLOR;
|
|
||||||
private Color borderColor = BORDER_COLOR;
|
|
||||||
private Color labelColor = LABEL_COLOR;
|
|
||||||
protected Display display = Display.NAME;
|
|
||||||
private boolean folded = false;
|
private boolean folded = false;
|
||||||
private Size pinSpacing = PIN_SPACING;
|
private Size pinSpacing = PIN_SPACING;
|
||||||
|
|
||||||
@@ -86,56 +75,12 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
super();
|
super();
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
alpha = (byte) 100;
|
alpha = (byte) 100;
|
||||||
}
|
bodyColor = BODY_COLOR;
|
||||||
|
borderColor = BORDER_COLOR;
|
||||||
@EditableProperty
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty
|
|
||||||
public Orientation getOrientation() {
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrientation(Orientation orientation) {
|
|
||||||
this.orientation = orientation;
|
|
||||||
updateControlPoints();
|
|
||||||
// Reset body shape;
|
|
||||||
body = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getControlPointCount() {
|
protected void updateControlPoints() {
|
||||||
return controlPoints.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point getControlPoint(int index) {
|
|
||||||
return controlPoints[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isControlPointSticky(int index) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
|
||||||
return VisibilityPolicy.NEVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setControlPoint(Point point, int index) {
|
|
||||||
controlPoints[index].setLocation(point);
|
|
||||||
body = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateControlPoints() {
|
|
||||||
int pinSpacing = (int) getPinSpacing().convertToPixels();
|
int pinSpacing = (int) getPinSpacing().convertToPixels();
|
||||||
// Update control points.
|
// Update control points.
|
||||||
int x = controlPoints[0].x;
|
int x = controlPoints[0].x;
|
||||||
@@ -162,7 +107,7 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Area getBody() {
|
public Area[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
int x = (controlPoints[0].x + controlPoints[1].x + controlPoints[2].x) / 3;
|
int x = (controlPoints[0].x + controlPoints[1].x + controlPoints[2].x) / 3;
|
||||||
int y = (controlPoints[0].y + controlPoints[1].y + controlPoints[2].y) / 3;
|
int y = (controlPoints[0].y + controlPoints[1].y + controlPoints[2].y) / 3;
|
||||||
@@ -170,41 +115,44 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
int bodyLength = getClosestOdd(BODY_LENGTH.convertToPixels());
|
int bodyLength = getClosestOdd(BODY_LENGTH.convertToPixels());
|
||||||
int edgeRadius = (int) EDGE_RADIUS.convertToPixels();
|
int edgeRadius = (int) EDGE_RADIUS.convertToPixels();
|
||||||
|
|
||||||
|
Area newBody = null;
|
||||||
|
|
||||||
if (folded) {
|
if (folded) {
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
body =
|
newBody =
|
||||||
new Area(new RoundRectangle2D.Double(x - bodyLength, y - bodyDiameter / 2, bodyLength, bodyDiameter,
|
new Area(new RoundRectangle2D.Double(x - bodyLength, y - bodyDiameter / 2, bodyLength, bodyDiameter,
|
||||||
edgeRadius, edgeRadius));
|
edgeRadius, edgeRadius));
|
||||||
body.add(new Area(new Rectangle2D.Double(x - bodyLength / 2, y - bodyDiameter / 2, bodyLength / 2,
|
newBody.add(new Area(new Rectangle2D.Double(x - bodyLength / 2, y - bodyDiameter / 2, bodyLength / 2,
|
||||||
bodyDiameter)));
|
bodyDiameter)));
|
||||||
break;
|
break;
|
||||||
case _90:
|
case _90:
|
||||||
body =
|
newBody =
|
||||||
new Area(new RoundRectangle2D.Double(x - bodyDiameter / 2, y - bodyLength, bodyDiameter, bodyLength,
|
new Area(new RoundRectangle2D.Double(x - bodyDiameter / 2, y - bodyLength, bodyDiameter, bodyLength,
|
||||||
edgeRadius, edgeRadius));
|
edgeRadius, edgeRadius));
|
||||||
body.add(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y - bodyLength / 2, bodyDiameter,
|
newBody.add(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y - bodyLength / 2, bodyDiameter,
|
||||||
bodyLength / 2)));
|
bodyLength / 2)));
|
||||||
break;
|
break;
|
||||||
case _180:
|
case _180:
|
||||||
body =
|
newBody =
|
||||||
new Area(new RoundRectangle2D.Double(x, y - bodyDiameter / 2, bodyLength, bodyDiameter, edgeRadius,
|
new Area(new RoundRectangle2D.Double(x, y - bodyDiameter / 2, bodyLength, bodyDiameter, edgeRadius,
|
||||||
edgeRadius));
|
edgeRadius));
|
||||||
body.add(new Area(new Rectangle2D.Double(x, y - bodyDiameter / 2, bodyLength / 2, bodyDiameter)));
|
newBody.add(new Area(new Rectangle2D.Double(x, y - bodyDiameter / 2, bodyLength / 2, bodyDiameter)));
|
||||||
break;
|
break;
|
||||||
case _270:
|
case _270:
|
||||||
body =
|
newBody =
|
||||||
new Area(new RoundRectangle2D.Double(x - bodyDiameter / 2, y, bodyDiameter, bodyLength, edgeRadius,
|
new Area(new RoundRectangle2D.Double(x - bodyDiameter / 2, y, bodyDiameter, bodyLength, edgeRadius,
|
||||||
edgeRadius));
|
edgeRadius));
|
||||||
body.add(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y, bodyDiameter, bodyLength / 2)));
|
newBody.add(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y, bodyDiameter, bodyLength / 2)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
body = new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
newBody = new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body = new Area[] { newBody };
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
@@ -228,7 +176,7 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Area mainArea = getBody();
|
Area mainArea = getBody()[0];
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
@@ -298,15 +246,6 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Body")
|
|
||||||
public Color getBodyColor() {
|
|
||||||
return bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBodyColor(Color bodyColor) {
|
|
||||||
this.bodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
public boolean getFolded() {
|
public boolean getFolded() {
|
||||||
return folded;
|
return folded;
|
||||||
@@ -330,34 +269,4 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
// Reset body shape;
|
// Reset body shape;
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Border")
|
|
||||||
public Color getBorderColor() {
|
|
||||||
return borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBorderColor(Color borderColor) {
|
|
||||||
this.borderColor = borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty(name = "Label")
|
|
||||||
public Color getLabelColor() {
|
|
||||||
return labelColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabelColor(Color labelColor) {
|
|
||||||
this.labelColor = labelColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty
|
|
||||||
public Display getDisplay() {
|
|
||||||
if (display == null) {
|
|
||||||
display = Display.NAME;
|
|
||||||
}
|
|
||||||
return display;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplay(Display display) {
|
|
||||||
this.display = display;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,15 +37,12 @@ import org.diylc.appframework.miscutils.ConfigurationManager;
|
|||||||
import org.diylc.common.Display;
|
import org.diylc.common.Display;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
|
||||||
import org.diylc.components.transform.TO220Transformer;
|
import org.diylc.components.transform.TO220Transformer;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.Theme;
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
|
||||||
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.KeywordPolicy;
|
import org.diylc.core.annotations.KeywordPolicy;
|
||||||
@@ -56,7 +53,7 @@ import org.diylc.utils.Constants;
|
|||||||
@ComponentDescriptor(name = "Transistor (TO-220)", author = "Branislav Stojkovic", category = "Semiconductors",
|
@ComponentDescriptor(name = "Transistor (TO-220)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||||
instanceNamePrefix = "Q", description = "Transistors with metal tab for heat sink mounting", stretchable = false,
|
instanceNamePrefix = "Q", description = "Transistors with metal tab for heat sink mounting", stretchable = false,
|
||||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class)
|
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class)
|
||||||
public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
public class TransistorTO220 extends AbstractTransistorPackage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -78,15 +75,8 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
public static Size LEAD_LENGTH = new Size(3.5d, SizeUnit.mm);
|
public static Size LEAD_LENGTH = new Size(3.5d, SizeUnit.mm);
|
||||||
public static Size LEAD_THICKNESS = new Size(0.8d, SizeUnit.mm);
|
public static Size LEAD_THICKNESS = new Size(0.8d, SizeUnit.mm);
|
||||||
|
|
||||||
private String value = "";
|
|
||||||
private Orientation orientation = Orientation.DEFAULT;
|
|
||||||
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
|
||||||
transient private Shape[] body;
|
|
||||||
private Color bodyColor = BODY_COLOR;
|
|
||||||
private Color borderColor = BORDER_COLOR;
|
|
||||||
private Color tabColor = TAB_COLOR;
|
private Color tabColor = TAB_COLOR;
|
||||||
private Color tabBorderColor = TAB_BORDER_COLOR;
|
private Color tabBorderColor = TAB_BORDER_COLOR;
|
||||||
private Display display = Display.NAME;
|
|
||||||
private boolean folded = false;
|
private boolean folded = false;
|
||||||
private Size leadLength = LEAD_LENGTH;
|
private Size leadLength = LEAD_LENGTH;
|
||||||
|
|
||||||
@@ -94,56 +84,12 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
super();
|
super();
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
alpha = (byte) 100;
|
alpha = (byte) 100;
|
||||||
}
|
bodyColor = BODY_COLOR;
|
||||||
|
borderColor = BORDER_COLOR;
|
||||||
@EditableProperty
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty
|
|
||||||
public Orientation getOrientation() {
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrientation(Orientation orientation) {
|
|
||||||
this.orientation = orientation;
|
|
||||||
updateControlPoints();
|
|
||||||
// Reset body shape;
|
|
||||||
body = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getControlPointCount() {
|
protected void updateControlPoints() {
|
||||||
return controlPoints.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point getControlPoint(int index) {
|
|
||||||
return controlPoints[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isControlPointSticky(int index) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
|
||||||
return VisibilityPolicy.NEVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setControlPoint(Point point, int index) {
|
|
||||||
controlPoints[index].setLocation(point);
|
|
||||||
body = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateControlPoints() {
|
|
||||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||||
// Update control points.
|
// Update control points.
|
||||||
int x = controlPoints[0].x;
|
int x = controlPoints[0].x;
|
||||||
@@ -170,9 +116,9 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shape[] getBody() {
|
public Area[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[2];
|
body = new Area[2];
|
||||||
int x = controlPoints[0].x;
|
int x = controlPoints[0].x;
|
||||||
int y = controlPoints[0].y;
|
int y = controlPoints[0].y;
|
||||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||||
@@ -187,68 +133,68 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
if (folded) {
|
if (folded) {
|
||||||
body[0] = new Rectangle2D.Double(x + leadLength, y + pinSpacing - bodyWidth / 2, bodyHeight, bodyWidth);
|
body[0] = new Area(new Rectangle2D.Double(x + leadLength, y + pinSpacing - bodyWidth / 2, bodyHeight, bodyWidth));
|
||||||
body[1] =
|
body[1] =
|
||||||
new Area(new Rectangle2D.Double(x + leadLength + bodyHeight, y + pinSpacing - bodyWidth / 2, tabHeight,
|
new Area(new Rectangle2D.Double(x + leadLength + bodyHeight, y + pinSpacing - bodyWidth / 2, tabHeight,
|
||||||
bodyWidth));
|
bodyWidth));
|
||||||
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x + leadLength + bodyHeight + tabHeight / 2
|
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x + leadLength + bodyHeight + tabHeight / 2
|
||||||
- tabHoleDiameter / 2, y + pinSpacing - tabHoleDiameter / 2, tabHoleDiameter, tabHoleDiameter)));
|
- tabHoleDiameter / 2, y + pinSpacing - tabHoleDiameter / 2, tabHoleDiameter, tabHoleDiameter)));
|
||||||
} else {
|
} else {
|
||||||
body[0] =
|
body[0] = new Area(
|
||||||
new Rectangle2D.Double(x - bodyThickness / 2, y + pinSpacing - bodyWidth / 2, bodyThickness, bodyWidth);
|
new Rectangle2D.Double(x - bodyThickness / 2, y + pinSpacing - bodyWidth / 2, bodyThickness, bodyWidth));
|
||||||
body[1] =
|
body[1] = new Area(
|
||||||
new Rectangle2D.Double(x + bodyThickness / 2 - tabThickness, y + pinSpacing - bodyWidth / 2,
|
new Rectangle2D.Double(x + bodyThickness / 2 - tabThickness, y + pinSpacing - bodyWidth / 2,
|
||||||
tabThickness, bodyWidth);
|
tabThickness, bodyWidth));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _90:
|
case _90:
|
||||||
if (folded) {
|
if (folded) {
|
||||||
body[0] = new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y + leadLength, bodyWidth, bodyHeight);
|
body[0] = new Area(new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y + leadLength, bodyWidth, bodyHeight));
|
||||||
body[1] =
|
body[1] =
|
||||||
new Area(new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y + leadLength + bodyHeight, bodyWidth,
|
new Area(new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y + leadLength + bodyHeight, bodyWidth,
|
||||||
tabHeight));
|
tabHeight));
|
||||||
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x - pinSpacing - tabHoleDiameter / 2, y
|
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x - pinSpacing - tabHoleDiameter / 2, y
|
||||||
+ leadLength + bodyHeight + tabHeight / 2 - tabHoleDiameter / 2, tabHoleDiameter, tabHoleDiameter)));
|
+ leadLength + bodyHeight + tabHeight / 2 - tabHoleDiameter / 2, tabHoleDiameter, tabHoleDiameter)));
|
||||||
} else {
|
} else {
|
||||||
body[0] =
|
body[0] = new Area(
|
||||||
new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y - bodyThickness / 2, bodyWidth, bodyThickness);
|
new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y - bodyThickness / 2, bodyWidth, bodyThickness));
|
||||||
body[1] =
|
body[1] = new Area(
|
||||||
new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y + bodyThickness / 2 - tabThickness, bodyWidth,
|
new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y + bodyThickness / 2 - tabThickness, bodyWidth,
|
||||||
tabThickness);
|
tabThickness));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _180:
|
case _180:
|
||||||
if (folded) {
|
if (folded) {
|
||||||
body[0] =
|
body[0] = new Area(
|
||||||
new Rectangle2D.Double(x - leadLength - bodyHeight, y - pinSpacing - bodyWidth / 2, bodyHeight,
|
new Rectangle2D.Double(x - leadLength - bodyHeight, y - pinSpacing - bodyWidth / 2, bodyHeight,
|
||||||
bodyWidth);
|
bodyWidth));
|
||||||
body[1] =
|
body[1] =
|
||||||
new Area(new Rectangle2D.Double(x - leadLength - bodyHeight - tabHeight,
|
new Area(new Rectangle2D.Double(x - leadLength - bodyHeight - tabHeight,
|
||||||
y - pinSpacing - bodyWidth / 2, tabHeight, bodyWidth));
|
y - pinSpacing - bodyWidth / 2, tabHeight, bodyWidth));
|
||||||
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x - leadLength - bodyHeight - tabHeight / 2
|
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x - leadLength - bodyHeight - tabHeight / 2
|
||||||
- tabHoleDiameter / 2, y - pinSpacing - tabHoleDiameter / 2, tabHoleDiameter, tabHoleDiameter)));
|
- tabHoleDiameter / 2, y - pinSpacing - tabHoleDiameter / 2, tabHoleDiameter, tabHoleDiameter)));
|
||||||
} else {
|
} else {
|
||||||
body[0] =
|
body[0] = new Area(
|
||||||
new Rectangle2D.Double(x - bodyThickness / 2, y - pinSpacing - bodyWidth / 2, bodyThickness, bodyWidth);
|
new Rectangle2D.Double(x - bodyThickness / 2, y - pinSpacing - bodyWidth / 2, bodyThickness, bodyWidth));
|
||||||
body[1] =
|
body[1] = new Area(
|
||||||
new Rectangle2D.Double(x - bodyThickness / 2, y - pinSpacing - bodyWidth / 2, tabThickness, bodyWidth);
|
new Rectangle2D.Double(x - bodyThickness / 2, y - pinSpacing - bodyWidth / 2, tabThickness, bodyWidth));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _270:
|
case _270:
|
||||||
if (folded) {
|
if (folded) {
|
||||||
body[0] =
|
body[0] = new Area(
|
||||||
new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2, y - leadLength - bodyHeight, bodyWidth,
|
new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2, y - leadLength - bodyHeight, bodyWidth,
|
||||||
bodyHeight);
|
bodyHeight));
|
||||||
body[1] =
|
body[1] =
|
||||||
new Area(new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2,
|
new Area(new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2,
|
||||||
y - leadLength - bodyHeight - tabHeight, bodyWidth, tabHeight));
|
y - leadLength - bodyHeight - tabHeight, bodyWidth, tabHeight));
|
||||||
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x + pinSpacing - tabHoleDiameter / 2, y
|
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x + pinSpacing - tabHoleDiameter / 2, y
|
||||||
- leadLength - bodyHeight - tabHeight / 2 - tabHoleDiameter / 2, tabHoleDiameter, tabHoleDiameter)));
|
- leadLength - bodyHeight - tabHeight / 2 - tabHoleDiameter / 2, tabHoleDiameter, tabHoleDiameter)));
|
||||||
} else {
|
} else {
|
||||||
body[0] =
|
body[0] = new Area(
|
||||||
new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2, y - bodyThickness / 2, bodyWidth, bodyThickness);
|
new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2, y - bodyThickness / 2, bodyWidth, bodyThickness));
|
||||||
body[1] =
|
body[1] = new Area(
|
||||||
new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2, y - bodyThickness / 2, bodyWidth, tabThickness);
|
new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2, y - bodyThickness / 2, bodyWidth, tabThickness));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -382,7 +328,7 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
} else {
|
} else {
|
||||||
finalLabelColor =
|
finalLabelColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: LABEL_COLOR;
|
: getLabelColor();
|
||||||
}
|
}
|
||||||
g2d.setColor(finalLabelColor);
|
g2d.setColor(finalLabelColor);
|
||||||
String label = "";
|
String label = "";
|
||||||
@@ -428,24 +374,6 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.drawLine(width / 2 + bodySize / 3, margin + tabSize + bodySize, width / 2 + bodySize / 3, height - margin);
|
g2d.drawLine(width / 2 + bodySize / 3, margin + tabSize + bodySize, width / 2 + bodySize / 3, height - margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Body")
|
|
||||||
public Color getBodyColor() {
|
|
||||||
return bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBodyColor(Color bodyColor) {
|
|
||||||
this.bodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty(name = "Border")
|
|
||||||
public Color getBorderColor() {
|
|
||||||
return borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBorderColor(Color borderColor) {
|
|
||||||
this.borderColor = borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty(name = "Tab")
|
@EditableProperty(name = "Tab")
|
||||||
public Color getTabColor() {
|
public Color getTabColor() {
|
||||||
return tabColor;
|
return tabColor;
|
||||||
@@ -488,16 +416,4 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
public void setTabBorderColor(Color tabBorderColor) {
|
public void setTabBorderColor(Color tabBorderColor) {
|
||||||
this.tabBorderColor = tabBorderColor;
|
this.tabBorderColor = tabBorderColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
|
||||||
public Display getDisplay() {
|
|
||||||
if (display == null) {
|
|
||||||
display = Display.NAME;
|
|
||||||
}
|
|
||||||
return display;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplay(Display display) {
|
|
||||||
this.display = display;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,15 +37,12 @@ import org.diylc.appframework.miscutils.ConfigurationManager;
|
|||||||
import org.diylc.common.Display;
|
import org.diylc.common.Display;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
|
||||||
import org.diylc.components.transform.TO92Transformer;
|
import org.diylc.components.transform.TO92Transformer;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.Theme;
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
|
||||||
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.KeywordPolicy;
|
import org.diylc.core.annotations.KeywordPolicy;
|
||||||
@@ -56,7 +53,7 @@ import org.diylc.utils.Constants;
|
|||||||
@ComponentDescriptor(name = "Transistor (TO-92)", author = "Branislav Stojkovic", category = "Semiconductors",
|
@ComponentDescriptor(name = "Transistor (TO-92)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||||
instanceNamePrefix = "Q", description = "Transistor with small plastic or epoxy body", stretchable = false,
|
instanceNamePrefix = "Q", description = "Transistor with small plastic or epoxy body", stretchable = false,
|
||||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO92Transformer.class)
|
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO92Transformer.class)
|
||||||
public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
public class TransistorTO92 extends AbstractTransistorPackage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -69,14 +66,6 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
public static Size PIN_SPACING = new Size(0.05d, SizeUnit.in);
|
public static Size PIN_SPACING = new Size(0.05d, SizeUnit.in);
|
||||||
public static Size BODY_DIAMETER = new Size(0.2d, SizeUnit.in);
|
public static Size BODY_DIAMETER = new Size(0.2d, SizeUnit.in);
|
||||||
|
|
||||||
private String value = "";
|
|
||||||
private Orientation orientation = Orientation.DEFAULT;
|
|
||||||
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
|
||||||
transient private Area body;
|
|
||||||
private Color bodyColor = BODY_COLOR;
|
|
||||||
private Color borderColor = BORDER_COLOR;
|
|
||||||
private Color labelColor = LABEL_COLOR;
|
|
||||||
protected Display display = Display.NAME;
|
|
||||||
private boolean folded = false;
|
private boolean folded = false;
|
||||||
private Size pinSpacing = PIN_SPACING;
|
private Size pinSpacing = PIN_SPACING;
|
||||||
|
|
||||||
@@ -84,27 +73,8 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
super();
|
super();
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
alpha = (byte) 100;
|
alpha = (byte) 100;
|
||||||
}
|
bodyColor = BODY_COLOR;
|
||||||
|
borderColor = BORDER_COLOR;
|
||||||
@EditableProperty
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty
|
|
||||||
public Orientation getOrientation() {
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrientation(Orientation orientation) {
|
|
||||||
this.orientation = orientation;
|
|
||||||
updateControlPoints();
|
|
||||||
// Reset body shape;
|
|
||||||
body = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -134,32 +104,7 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getControlPointCount() {
|
protected void updateControlPoints() {
|
||||||
return controlPoints.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point getControlPoint(int index) {
|
|
||||||
return controlPoints[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isControlPointSticky(int index) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
|
||||||
return VisibilityPolicy.NEVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setControlPoint(Point point, int index) {
|
|
||||||
controlPoints[index].setLocation(point);
|
|
||||||
body = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateControlPoints() {
|
|
||||||
int pinSpacing = (int) getPinSpacing().convertToPixels();
|
int pinSpacing = (int) getPinSpacing().convertToPixels();
|
||||||
// Update control points.
|
// Update control points.
|
||||||
int x = controlPoints[0].x;
|
int x = controlPoints[0].x;
|
||||||
@@ -186,25 +131,27 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Area getBody() {
|
public Area[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
int x = (controlPoints[0].x + controlPoints[1].x + controlPoints[2].x) / 3;
|
int x = (controlPoints[0].x + controlPoints[1].x + controlPoints[2].x) / 3;
|
||||||
int y = (controlPoints[0].y + controlPoints[1].y + controlPoints[2].y) / 3;
|
int y = (controlPoints[0].y + controlPoints[1].y + controlPoints[2].y) / 3;
|
||||||
int bodyDiameter = getClosestOdd(BODY_DIAMETER.convertToPixels());
|
int bodyDiameter = getClosestOdd(BODY_DIAMETER.convertToPixels());
|
||||||
|
|
||||||
|
Area newBody = null;
|
||||||
|
|
||||||
if (folded) {
|
if (folded) {
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
body = new Area(new Rectangle2D.Double(x - bodyDiameter, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
newBody = new Area(new Rectangle2D.Double(x - bodyDiameter, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
||||||
break;
|
break;
|
||||||
case _90:
|
case _90:
|
||||||
body = new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y - bodyDiameter, bodyDiameter, bodyDiameter));
|
newBody = new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y - bodyDiameter, bodyDiameter, bodyDiameter));
|
||||||
break;
|
break;
|
||||||
case _180:
|
case _180:
|
||||||
body = new Area(new Rectangle2D.Double(x, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
newBody = new Area(new Rectangle2D.Double(x, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
||||||
break;
|
break;
|
||||||
case _270:
|
case _270:
|
||||||
body = new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y, bodyDiameter, bodyDiameter));
|
newBody = new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y, bodyDiameter, bodyDiameter));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||||
@@ -212,33 +159,35 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
} else {
|
} else {
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
body =
|
newBody =
|
||||||
new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
||||||
body.subtract(new Area(new Rectangle2D.Double(x - bodyDiameter, y - bodyDiameter / 2, 3 * bodyDiameter / 4,
|
newBody.subtract(new Area(new Rectangle2D.Double(x - bodyDiameter, y - bodyDiameter / 2, 3 * bodyDiameter / 4,
|
||||||
bodyDiameter)));
|
bodyDiameter)));
|
||||||
break;
|
break;
|
||||||
case _90:
|
case _90:
|
||||||
body =
|
newBody =
|
||||||
new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
||||||
body.subtract(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y - bodyDiameter, bodyDiameter,
|
newBody.subtract(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y - bodyDiameter, bodyDiameter,
|
||||||
3 * bodyDiameter / 4)));
|
3 * bodyDiameter / 4)));
|
||||||
break;
|
break;
|
||||||
case _180:
|
case _180:
|
||||||
body =
|
newBody =
|
||||||
new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
||||||
body.subtract(new Area(new Rectangle2D.Double(x + bodyDiameter / 4, y - bodyDiameter / 2,
|
newBody.subtract(new Area(new Rectangle2D.Double(x + bodyDiameter / 4, y - bodyDiameter / 2,
|
||||||
3 * bodyDiameter / 4, bodyDiameter)));
|
3 * bodyDiameter / 4, bodyDiameter)));
|
||||||
break;
|
break;
|
||||||
case _270:
|
case _270:
|
||||||
body =
|
newBody =
|
||||||
new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
|
||||||
body.subtract(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y + bodyDiameter / 4, bodyDiameter,
|
newBody.subtract(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y + bodyDiameter / 4, bodyDiameter,
|
||||||
3 * bodyDiameter / 4)));
|
3 * bodyDiameter / 4)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body = new Area[] { newBody };
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
@@ -261,7 +210,7 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Area mainArea = getBody();
|
Area mainArea = getBody()[0];
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
@@ -337,46 +286,4 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.fillOval(width / 2 - pinSize / 2, (height / 4) * (i + 1), pinSize, pinSize);
|
g2d.fillOval(width / 2 - pinSize / 2, (height / 4) * (i + 1), pinSize, pinSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Body")
|
|
||||||
public Color getBodyColor() {
|
|
||||||
return bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBodyColor(Color bodyColor) {
|
|
||||||
this.bodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty(name = "Border")
|
|
||||||
public Color getBorderColor() {
|
|
||||||
return borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBorderColor(Color borderColor) {
|
|
||||||
this.borderColor = borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty(name = "Label")
|
|
||||||
public Color getLabelColor() {
|
|
||||||
if (labelColor == null) {
|
|
||||||
labelColor = LABEL_COLOR;
|
|
||||||
}
|
|
||||||
return labelColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabelColor(Color labelColor) {
|
|
||||||
this.labelColor = labelColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty
|
|
||||||
public Display getDisplay() {
|
|
||||||
if (display == null) {
|
|
||||||
display = Display.NAME;
|
|
||||||
}
|
|
||||||
return display;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplay(Display display) {
|
|
||||||
this.display = display;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user