From 0cb0e950f7eb5d7433a99fb1c84dea2490c4aebe Mon Sep 17 00:00:00 2001 From: bancika Date: Fri, 28 Sep 2012 15:51:11 +0000 Subject: [PATCH] Schottky diode --- .../semiconductors/DiodeSymbol.java | 2 +- .../semiconductors/SchottkyDiodeSymbol.java | 74 +++++++++++++++++++ .../semiconductors/ZenerDiodeSymbol.java | 23 ++++-- 3 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/SchottkyDiodeSymbol.java diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/DiodeSymbol.java b/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/DiodeSymbol.java index fff5070c..0d19a727 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/DiodeSymbol.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/DiodeSymbol.java @@ -19,7 +19,7 @@ public class DiodeSymbol extends AbstractDiodeSymbol { public void drawIcon(Graphics2D g2d, int width, int height) { int size = width * 3 / 8; - int bandSize = 2 * width / 32; + int bandSize = 1; g2d.rotate(-Math.PI / 4, width / 2, height / 2); g2d.setColor(LEAD_COLOR); g2d.drawLine(0, height / 2, (width - size) / 2, height / 2); diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/SchottkyDiodeSymbol.java b/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/SchottkyDiodeSymbol.java new file mode 100644 index 00000000..1ec5234f --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/SchottkyDiodeSymbol.java @@ -0,0 +1,74 @@ +package org.diylc.components.semiconductors; + +import java.awt.Graphics2D; +import java.awt.Polygon; + +import org.diylc.common.ObjectCache; +import org.diylc.core.CreationMethod; +import org.diylc.core.IDIYComponent; +import org.diylc.core.annotations.ComponentDescriptor; +import org.diylc.core.measures.Size; +import org.diylc.core.measures.SizeUnit; + +@ComponentDescriptor(name = "Schottky diode (schematic symbol)", author = "Branislav Stojkovic", category = "Semiconductors", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Schottky diode schematic symbol", zOrder = IDIYComponent.COMPONENT) +public class SchottkyDiodeSymbol extends AbstractDiodeSymbol { + + private static final long serialVersionUID = 1L; + + public static Size BAND_SIZE = new Size(0.01, SizeUnit.in); + + public void drawIcon(Graphics2D g2d, int width, int height) { + int size = width * 3 / 8; + int bandSize = 1; + g2d.rotate(-Math.PI / 4, width / 2, height / 2); + g2d.setColor(LEAD_COLOR); + g2d.drawLine(0, height / 2, (width - size) / 2, height / 2); + g2d.drawLine((int) (width + size / Math.sqrt(2) + bandSize) / 2, + height / 2, width, height / 2); + g2d.setColor(COLOR); + g2d.fill(new Polygon(new int[] { (width - size) / 2, + (width - size) / 2, + (int) ((width - size) / 2 + size / Math.sqrt(2)) }, new int[] { + (height - size) / 2, (height + size) / 2, height / 2 }, 3)); + g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(bandSize)); + g2d.drawLine((int) ((width - size) / 2 + size / Math.sqrt(2)), + (height - size) / 2, (int) ((width - size) / 2 + size + / Math.sqrt(2)), (height + size) / 2); + int finSize = 2 * width / 32; + g2d.drawLine((int) ((width - size) / 2 + size / Math.sqrt(2)), + (height - size) / 2, (int) ((width - size) / 2 + size + / Math.sqrt(2) + finSize), (height - size) / 2); + g2d.drawLine( + (int) ((width - size) / 2 + size / Math.sqrt(2) + finSize), + (height - size) / 2, (int) ((width - size) / 2 + size + / Math.sqrt(2) + finSize), (height - size) / 2 + + finSize); + + g2d.drawLine((int) ((width - size) / 2 + size / Math.sqrt(2)), + (height + size) / 2, (int) ((width - size) / 2 + size + / Math.sqrt(2) - finSize), (height + size) / 2); + g2d.drawLine( + (int) ((width - size) / 2 + size / Math.sqrt(2) - finSize), + (height + size) / 2, (int) ((width - size) / 2 + size + / Math.sqrt(2) - finSize), (height + size) / 2 + - finSize); + } + + @Override + protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) { + double width = getWidth().convertToPixels(); + int finSize = (int) (width / 6); + int bandSize = (int) BAND_SIZE.convertToPixels(); + g2d.setColor(getBodyColor()); + g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(bandSize)); + g2d.drawPolyline(new int[] { + (int) (width / Math.sqrt(2) + bandSize) + finSize + 1, + (int) (width / Math.sqrt(2) + bandSize) + finSize + 1, + (int) (width / Math.sqrt(2) + bandSize), + (int) (width / Math.sqrt(2) + bandSize), + (int) (width / Math.sqrt(2) + bandSize) - finSize - 1, + (int) (width / Math.sqrt(2) + bandSize) - finSize - 1 }, + new int[] { (int) finSize, 0, 0, (int) width, (int) width, + (int) (width - finSize) }, 6); + } +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/ZenerDiodeSymbol.java b/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/ZenerDiodeSymbol.java index a6500668..a2045ceb 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/ZenerDiodeSymbol.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/ZenerDiodeSymbol.java @@ -19,7 +19,7 @@ public class ZenerDiodeSymbol extends AbstractDiodeSymbol { public void drawIcon(Graphics2D g2d, int width, int height) { int size = width * 3 / 8; - int bandSize = 2 * width / 32; + int bandSize = 1; g2d.rotate(-Math.PI / 4, width / 2, height / 2); g2d.setColor(LEAD_COLOR); g2d.drawLine(0, height / 2, (width - size) / 2, height / 2); @@ -52,12 +52,19 @@ public class ZenerDiodeSymbol extends AbstractDiodeSymbol { int bandSize = (int) BAND_SIZE.convertToPixels(); g2d.setColor(getBodyColor()); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(bandSize)); - g2d.drawLine((int) (width / Math.sqrt(2)) + bandSize, 0, (int) (width - / Math.sqrt(2) + bandSize), (int) width); - g2d.drawLine((int) (width / Math.sqrt(2)) + bandSize, 0, (int) (width - / Math.sqrt(2) + bandSize + finSize), -(int) finSize); - g2d.drawLine((int) (width / Math.sqrt(2) + bandSize), (int) width, - (int) (width / Math.sqrt(2) + bandSize - finSize), - (int) (width + finSize)); + // g2d.drawLine((int) (width / Math.sqrt(2)) + bandSize, 0, (int) (width + // / Math.sqrt(2) + bandSize), (int) width); + // g2d.drawLine((int) (width / Math.sqrt(2)) + bandSize, 0, (int) (width + // / Math.sqrt(2) + bandSize + finSize), -(int) finSize); + // g2d.drawLine((int) (width / Math.sqrt(2) + bandSize), (int) width, + // (int) (width / Math.sqrt(2) + bandSize - finSize), + // (int) (width + finSize)); + + g2d.drawPolyline(new int[] { + (int) (width / Math.sqrt(2) + bandSize + finSize), + (int) (width / Math.sqrt(2) + bandSize), + (int) (width / Math.sqrt(2) + bandSize), + (int) (width / Math.sqrt(2) + bandSize - finSize) }, new int[] { + (int) -finSize, 0, (int) width, (int) (width + finSize) }, 4); } }