diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/library/main.jar b/ diy-layout-creator --username bancika@gmail.com/DIYLC/library/main.jar index 5a66d344..455d9cf0 100644 Binary files a/ diy-layout-creator --username bancika@gmail.com/DIYLC/library/main.jar and b/ diy-layout-creator --username bancika@gmail.com/DIYLC/library/main.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/components/AbstractLeadedComponent.java b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/components/AbstractLeadedComponent.java index e8184394..b0ec5acb 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/components/AbstractLeadedComponent.java +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/components/AbstractLeadedComponent.java @@ -119,8 +119,8 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp (int) ((shapeRect.width + distance) / 2 - leadLenght) + leadThickness / 2, (int) shapeRect.height / 2); } - // Do not track the label because that area was already covered. - drawingObserver.stopTracking(); +// Do not track the label because that area was already covered. +// drawingObserver.stopTracking(); // Draw label. g2d.setFont(LABEL_FONT); g2d.setColor(componentState == ComponentState.SELECTED diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/ProjectFileManager.java b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/ProjectFileManager.java index 8222bdc4..cac31652 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/ProjectFileManager.java +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/ProjectFileManager.java @@ -27,7 +27,7 @@ import org.diylc.components.connectivity.HookupWire; import org.diylc.components.connectivity.Jumper; import org.diylc.components.connectivity.SolderPad; import org.diylc.components.misc.Label; -import org.diylc.components.passive.ElectrolyticRadial; +import org.diylc.components.passive.RadialElectrolytic; import org.diylc.components.passive.RadialFilmCapacitor; import org.diylc.components.passive.Resistor; import org.diylc.components.semiconductors.DIL_IC; @@ -293,7 +293,7 @@ public class ProjectFileManager { component = capacitor; } else if (nodeName.equalsIgnoreCase("electrolyte")) { LOG.debug("Recognized " + nodeName); - ElectrolyticRadial capacitor = new ElectrolyticRadial(); + RadialElectrolytic capacitor = new RadialElectrolytic(); capacitor.setName(nameAttr); try { capacitor.setValue(Capacitance.parseCapacitance(valueAttr)); diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/update.xml b/ diy-layout-creator --username bancika@gmail.com/DIYLC/update.xml index f2ab8cef..33be1616 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/update.xml +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/update.xml @@ -163,6 +163,10 @@ NEW_FEATURE Added resistor schematic symbol + + NEW_FEATURE + Added capacitor schematic symbol + http://code.google.com/p/diy-layout-creator/downloads/list diff --git a/ diy-layout-creator --username bancika@gmail.com/Library/build.xml b/ diy-layout-creator --username bancika@gmail.com/Library/build.xml index b375dd52..bd2075b4 100644 --- a/ diy-layout-creator --username bancika@gmail.com/Library/build.xml +++ b/ diy-layout-creator --username bancika@gmail.com/Library/build.xml @@ -46,6 +46,9 @@ + + + diff --git a/ diy-layout-creator --username bancika@gmail.com/Library/src/org/diylc/components/passive/CapacitorSymbol.java b/ diy-layout-creator --username bancika@gmail.com/Library/src/org/diylc/components/passive/CapacitorSymbol.java new file mode 100644 index 00000000..a6377108 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/Library/src/org/diylc/components/passive/CapacitorSymbol.java @@ -0,0 +1,100 @@ +package org.diylc.components.passive; + +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.GeneralPath; + +import org.diylc.components.AbstractSchematicLeadedSymbol; +import org.diylc.core.CreationMethod; +import org.diylc.core.IDIYComponent; +import org.diylc.core.annotations.ComponentDescriptor; +import org.diylc.core.annotations.EditableProperty; +import org.diylc.core.measures.Capacitance; +import org.diylc.core.measures.CapacitanceUnit; +import org.diylc.core.measures.Size; +import org.diylc.core.measures.SizeUnit; + +@ComponentDescriptor(name = "Capacitor (schematic symbol)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "", zOrder = IDIYComponent.COMPONENT) +public class CapacitorSymbol extends AbstractSchematicLeadedSymbol { + + private static final long serialVersionUID = 1L; + + public static Size DEFAULT_LENGTH = new Size(0.05, SizeUnit.in); + public static Size DEFAULT_WIDTH = new Size(0.15, SizeUnit.in); + + private Capacitance value = new Capacitance(22d, CapacitanceUnit.nF); + private Voltage voltage = Voltage._63V; + private boolean polarized = false; + + @EditableProperty + public Capacitance getValue() { + return value; + } + + public void setValue(Capacitance value) { + this.value = value; + } + + @EditableProperty + public Voltage getVoltage() { + return voltage; + } + + public void setVoltage(Voltage voltage) { + this.voltage = voltage; + } + + @EditableProperty + public boolean getPolarized() { + return polarized; + } + + public void setPolarized(boolean polarized) { + this.polarized = polarized; + } + + public void drawIcon(Graphics2D g2d, int width, int height) { + g2d.rotate(-Math.PI / 4, width / 2, height / 2); + g2d.setColor(LEAD_COLOR); + g2d.drawLine(0, height / 2, 13, height / 2); + g2d.drawLine(width - 13, height / 2, width, height / 2); + g2d.setColor(COLOR); + g2d.drawLine(14, height / 2 - 6, 14, height / 2 + 6); + g2d.drawLine(width - 14, height / 2 - 6, width - 14, height / 2 + 6); + } + + @Override + protected Size getDefaultWidth() { + return DEFAULT_WIDTH; + } + + @Override + protected Size getDefaultLength() { + return DEFAULT_LENGTH; + } + + @Override + protected Shape getBodyShape() { + GeneralPath polyline = new GeneralPath(); + double length = getLength().convertToPixels(); + double width = getWidth().convertToPixels(); + polyline.moveTo(0, 0); + polyline.lineTo(0, width); + polyline.moveTo(length, 0); + polyline.lineTo(length, width); + return polyline; + } + + @Override + protected void decorateComponentBody(Graphics2D g2d) { + if (polarized) { + // Draw + sign. + g2d.setColor(getBorderColor()); + int plusSize = getClosestOdd(getWidth().convertToPixels() / 4); + int x = -plusSize; + int y = plusSize; + g2d.drawLine(x - plusSize / 2, y, x + plusSize / 2, y); + g2d.drawLine(x, y - plusSize / 2, x, y + plusSize / 2); + } + } +} diff --git a/ diy-layout-creator --username bancika@gmail.com/Library/src/org/diylc/components/passive/RadialElectrolytic.java b/ diy-layout-creator --username bancika@gmail.com/Library/src/org/diylc/components/passive/RadialElectrolytic.java index e6fa8c9e..35ba2d13 100644 --- a/ diy-layout-creator --username bancika@gmail.com/Library/src/org/diylc/components/passive/RadialElectrolytic.java +++ b/ diy-layout-creator --username bancika@gmail.com/Library/src/org/diylc/components/passive/RadialElectrolytic.java @@ -50,7 +50,7 @@ public class RadialElectrolytic extends AbstractLeadedComponent { public void setValue(Capacitance value) { this.value = value; } - + @EditableProperty public Voltage getVoltage() { return voltage; @@ -60,7 +60,6 @@ public class RadialElectrolytic extends AbstractLeadedComponent { this.voltage = voltage; } - public void drawIcon(Graphics2D g2d, int width, int height) { g2d.setColor(BODY_COLOR); int margin = 3;