added capacitor symbol

This commit is contained in:
bancika
2011-01-30 23:35:07 +00:00
parent 4d6e994555
commit 8ea53b6876
7 changed files with 112 additions and 6 deletions
@@ -119,8 +119,8 @@ public abstract class AbstractLeadedComponent<T> 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
@@ -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));
@@ -163,6 +163,10 @@
<changeType>NEW_FEATURE</changeType>
<description>Added resistor schematic symbol</description>
</com.diyfever.gui.update.Change>
<com.diyfever.gui.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added capacitor schematic symbol</description>
</com.diyfever.gui.update.Change>
</changes>
<url>http://code.google.com/p/diy-layout-creator/downloads/list
</url>
@@ -46,6 +46,9 @@
<target name="jar" depends="clean, lib.copy, resource.copy, compile">
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}" />
<copy todir="../DIYLC/library" overwrite="true">
<fileset dir="${jar.dir}" includes="${ant.project.name}.jar" />
</copy>
</target>
<target name="javadoc">
@@ -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<Capacitance> {
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);
}
}
}
@@ -50,7 +50,7 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
public void setValue(Capacitance value) {
this.value = value;
}
@EditableProperty
public Voltage getVoltage() {
return voltage;
@@ -60,7 +60,6 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
this.voltage = voltage;
}
public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.setColor(BODY_COLOR);
int margin = 3;