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 ea07df05..fff5070c 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 @@ -2,7 +2,6 @@ package org.diylc.components.semiconductors; import java.awt.Graphics2D; import java.awt.Polygon; -import java.awt.geom.Rectangle2D; import org.diylc.common.ObjectCache; import org.diylc.core.CreationMethod; @@ -31,8 +30,10 @@ public class DiodeSymbol extends AbstractDiodeSymbol { (width - size) / 2, (int) ((width - size) / 2 + size / Math.sqrt(2)) }, new int[] { (height - size) / 2, (height + size) / 2, height / 2 }, 3)); - g2d.fill(new Rectangle2D.Double((int) ((width - size) / 2 + size - / Math.sqrt(2)), (height - size) / 2, bandSize, size)); + 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); } @Override 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 new file mode 100644 index 00000000..a6500668 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-library/src/org/diylc/components/semiconductors/ZenerDiodeSymbol.java @@ -0,0 +1,63 @@ +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 = "Zener diode (schematic symbol)", author = "Branislav Stojkovic", category = "Semiconductors", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Zener diode schematic symbol", zOrder = IDIYComponent.COMPONENT) +public class ZenerDiodeSymbol 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 = 2 * width / 32; + 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 + - 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 + + finSize); + } + + @Override + protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) { + double width = getWidth().convertToPixels(); + double finSize = width / 5; + 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)); + } +}