mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
BJT symbol
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
||||||
|
|
||||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 3, 0);
|
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 4, 0);
|
||||||
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
||||||
|
|
||||||
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
|
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@ public class ProjectFileManager {
|
|||||||
FileOutputStream fos;
|
FileOutputStream fos;
|
||||||
fos = new FileOutputStream(fileName);
|
fos = new FileOutputStream(fileName);
|
||||||
Writer writer = new OutputStreamWriter(fos, "UTF-8");
|
Writer writer = new OutputStreamWriter(fos, "UTF-8");
|
||||||
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
|
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
|
||||||
xStream.toXML(project, writer);
|
xStream.toXML(project, writer);
|
||||||
fos.close();
|
fos.close();
|
||||||
if (!isBackup) {
|
if (!isBackup) {
|
||||||
|
|||||||
Binary file not shown.
+1
-1
@@ -34,7 +34,7 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
|||||||
new Point(0, 0) };
|
new Point(0, 0) };
|
||||||
protected Color color = COLOR;
|
protected Color color = COLOR;
|
||||||
protected Display display = Display.NAME;
|
protected Display display = Display.NAME;
|
||||||
protected Shape[] body;
|
transient protected Shape[] body;
|
||||||
|
|
||||||
public AbstractTransistorSymbol() {
|
public AbstractTransistorSymbol() {
|
||||||
super();
|
super();
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package org.diylc.components.semiconductors;
|
||||||
|
|
||||||
|
public enum BJTPolarity {
|
||||||
|
|
||||||
|
NPN("NPN"), PNP("PNP");
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private BJTPolarity(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
}
|
||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
package org.diylc.components.semiconductors;
|
||||||
|
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Polygon;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
import java.awt.geom.Area;
|
||||||
|
import java.awt.geom.GeneralPath;
|
||||||
|
|
||||||
|
import org.diylc.common.ObjectCache;
|
||||||
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
|
||||||
|
@ComponentDescriptor(name = "BJT Symbol", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "Q", description = "Bipolar junction transistor schematic symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
|
public class BJTSymbol extends AbstractTransistorSymbol {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
protected BJTPolarity polarity = BJTPolarity.NPN;
|
||||||
|
|
||||||
|
public Shape[] getBody() {
|
||||||
|
if (body == null) {
|
||||||
|
body = new Shape[3];
|
||||||
|
int x = controlPoints[0].x;
|
||||||
|
int y = controlPoints[0].y;
|
||||||
|
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||||
|
|
||||||
|
GeneralPath polyline = new GeneralPath();
|
||||||
|
|
||||||
|
polyline.moveTo(x + pinSpacing / 2, y - pinSpacing * 3 / 2);
|
||||||
|
polyline.lineTo(x + pinSpacing / 2, y + pinSpacing * 3 / 2);
|
||||||
|
|
||||||
|
body[0] = polyline;
|
||||||
|
|
||||||
|
polyline = new GeneralPath();
|
||||||
|
|
||||||
|
polyline.moveTo(x, y);
|
||||||
|
polyline.lineTo(x + pinSpacing / 2, y);
|
||||||
|
polyline.moveTo(x + pinSpacing / 2, y - pinSpacing * 7 / 8);
|
||||||
|
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing * 3 / 2);
|
||||||
|
polyline.lineTo(x + pinSpacing * 2, y - pinSpacing * 2);
|
||||||
|
polyline.moveTo(x + pinSpacing / 2, y + pinSpacing * 7 / 8);
|
||||||
|
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 3 / 2);
|
||||||
|
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 2);
|
||||||
|
body[1] = polyline;
|
||||||
|
|
||||||
|
Area arrow;
|
||||||
|
double theta;
|
||||||
|
if (polarity == BJTPolarity.NPN) {
|
||||||
|
theta = Math.atan(5.0 / 12);
|
||||||
|
arrow = new Area(new Polygon(new int[] { x + pinSpacing, x + pinSpacing,
|
||||||
|
x + pinSpacing * 10 / 6 }, new int[] {
|
||||||
|
y - pinSpacing / 5 + pinSpacing * 7 / 8,
|
||||||
|
y + pinSpacing / 5 + pinSpacing * 7 / 8, y + pinSpacing * 7 / 8 }, 3));
|
||||||
|
arrow.transform(AffineTransform.getRotateInstance(theta, x + pinSpacing / 2, y
|
||||||
|
+ pinSpacing * 7 / 8));
|
||||||
|
} else {
|
||||||
|
theta = -Math.atan(5.0 / 12);
|
||||||
|
arrow = new Area(new Polygon(new int[] { x + pinSpacing, x + pinSpacing * 10 / 6,
|
||||||
|
x + pinSpacing * 10 / 6 }, new int[] { y - pinSpacing * 7 / 8,
|
||||||
|
y - pinSpacing / 5 - pinSpacing * 7 / 8,
|
||||||
|
y + pinSpacing / 5 - pinSpacing * 7 / 8 }, 3));
|
||||||
|
arrow.transform(AffineTransform.getRotateInstance(theta, x + pinSpacing / 2, y
|
||||||
|
- pinSpacing * 7 / 8));
|
||||||
|
}
|
||||||
|
body[2] = arrow;
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
g2d.setColor(COLOR);
|
||||||
|
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||||
|
g2d.drawLine(width / 3, height / 5, width / 3, height * 4 / 5);
|
||||||
|
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
|
g2d.drawLine(width / 8, height / 2, width / 3, height / 2);
|
||||||
|
|
||||||
|
g2d.drawLine(width * 3 / 4, 1, width * 3 / 4, height / 4);
|
||||||
|
g2d.drawLine(width / 3, height / 3 + 1, width * 3 / 4, height / 4);
|
||||||
|
|
||||||
|
g2d.drawLine(width * 3 / 4, height - 1, width * 3 / 4, height * 3 / 4);
|
||||||
|
g2d.drawLine(width / 3, height * 2 / 3 - 1, width * 3 / 4, height * 3 / 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Polarity")
|
||||||
|
public BJTPolarity getPolarity() {
|
||||||
|
return polarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolarity(BJTPolarity polarity) {
|
||||||
|
this.polarity = polarity;
|
||||||
|
// Invalidate body
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -486,6 +486,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>IC Symbol</description>
|
<description>IC Symbol</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>BJT Symbol</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>MOSFET Symbol</description>
|
<description>MOSFET Symbol</description>
|
||||||
@@ -506,6 +510,10 @@
|
|||||||
<changeType>BUG_FIX</changeType>
|
<changeType>BUG_FIX</changeType>
|
||||||
<description>"Index out of bounds" exception logs when selecting components</description>
|
<description>"Index out of bounds" exception logs when selecting components</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>Loading files fails because encoding is not recognized</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>BUG_FIX</changeType>
|
<changeType>BUG_FIX</changeType>
|
||||||
<description>Application breaks when resistance is set to 0 ohms</description>
|
<description>Application breaks when resistance is set to 0 ohms</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user