mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added TO220 transistor
improved status text
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
<map>
|
<map>
|
||||||
<entry>
|
<entry>
|
||||||
<string>lastPath</string>
|
<string>metric</string>
|
||||||
<string>C:\Documents and Settings\Branislav Stojkovic\workspace\DIYLC\templates</string>
|
<boolean>true</boolean>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>zoom</string>
|
<string>zoom</string>
|
||||||
<double>1.0</double>
|
<double>1.0</double>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>metric</string>
|
<string>lastPath</string>
|
||||||
<boolean>true</boolean>
|
<string>C:\Documents and Settings\Branislav Stojkovic\workspace\DIYLC\templates</string>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>default.org.diylc.components.misc.Label:Color</string>
|
<string>default.org.diylc.components.misc.Label:Color</string>
|
||||||
|
|||||||
Binary file not shown.
+2
-12
@@ -40,8 +40,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
protected Point[] points = new Point[] {
|
protected Point[] points = new Point[] {
|
||||||
new Point((int) (-DEFAULT_SIZE.convertToPixels() / 2), 0),
|
new Point((int) (-DEFAULT_SIZE.convertToPixels() / 2), 0),
|
||||||
new Point(DEFAULT_SIZE.convertToPixels() / 2, 0) };
|
new Point(DEFAULT_SIZE.convertToPixels() / 2, 0) };
|
||||||
protected Color bodyColor = getDefaultBodyColor();
|
protected Color bodyColor = Color.white;
|
||||||
protected Color borderColor = getDefaultBorderColor();
|
protected Color borderColor = Color.black;
|
||||||
protected Color labelColor = LABEL_COLOR;
|
protected Color labelColor = LABEL_COLOR;
|
||||||
protected Display display = Display.NAME;
|
protected Display display = Display.NAME;
|
||||||
|
|
||||||
@@ -162,16 +162,6 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
*/
|
*/
|
||||||
protected abstract Shape getBodyShape();
|
protected abstract Shape getBodyShape();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return default component body color.
|
|
||||||
*/
|
|
||||||
protected abstract Color getDefaultBodyColor();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return default component border color.
|
|
||||||
*/
|
|
||||||
protected abstract Color getDefaultBorderColor();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return default lead thickness. Override this method to change it.
|
* @return default lead thickness. Override this method to change it.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+5
-4
@@ -277,12 +277,13 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
} else {
|
} else {
|
||||||
count = "second";
|
count = "second";
|
||||||
}
|
}
|
||||||
statusText = "Click on the canvas to set the " + count + " control point of a new "
|
statusText = "<html>Click on the canvas to set the " + count
|
||||||
+ componentSlot.getName() + " or press Esc to cancel";
|
+ " control point of a new <font color='blue'>" + componentSlot.getName()
|
||||||
|
+ "</font> or press <b>Esc</b> to cancel</html>";
|
||||||
break;
|
break;
|
||||||
case SINGLE_CLICK:
|
case SINGLE_CLICK:
|
||||||
statusText = "Click on the canvas to create a new " + componentSlot.getName()
|
statusText = "<html>Click on the canvas to create a new <font color='blue'>"
|
||||||
+ " or press Esc to cancel";
|
+ componentSlot.getName() + "</font> or press <b>Esc</b> to cancel</html>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,14 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added support for creating and loading templates</description>
|
<description>Added support for creating and loading templates</description>
|
||||||
</com.diyfever.gui.update.Change>
|
</com.diyfever.gui.update.Change>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Added TO-92 transistor</description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Added TO-220 transistor</description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
||||||
</url>
|
</url>
|
||||||
|
|||||||
Binary file not shown.
+1
-11
@@ -15,7 +15,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace", description = "", zOrder = IDIYComponent.TRACE)
|
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace", description = "Straight copper trace", zOrder = IDIYComponent.TRACE)
|
||||||
public class CopperTrace extends AbstractLeadedComponent<Void> {
|
public class CopperTrace extends AbstractLeadedComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -109,16 +109,6 @@ public class CopperTrace extends AbstractLeadedComponent<Void> {
|
|||||||
public void setValue(Void value) {
|
public void setValue(Void value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBodyColor() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBorderColor() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape getBodyShape() {
|
protected Shape getBodyShape() {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
-1
@@ -8,7 +8,6 @@ import org.diylc.common.ObjectCache;
|
|||||||
import org.diylc.components.AbstractCurvedComponent;
|
import org.diylc.components.AbstractCurvedComponent;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
|
|||||||
-10
@@ -74,16 +74,6 @@ public class Jumper extends AbstractLeadedComponent<Void> {
|
|||||||
public void setValue(Void value) {
|
public void setValue(Void value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBodyColor() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBorderColor() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape getBodyShape() {
|
protected Shape getBodyShape() {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "Cut", stretchable = false, zOrder = IDIYComponent.BOARD + 1)
|
@ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic", description = "Designates the place where a trace on the vero board needs to be cut", instanceNamePrefix = "Cut", stretchable = false, zOrder = IDIYComponent.BOARD + 1)
|
||||||
public class TraceCut extends AbstractComponent<Void> {
|
public class TraceCut extends AbstractComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic", description = "", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SW")
|
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic", description = "Panel mounted mini toggle switch", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SW")
|
||||||
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
|
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+2
-10
@@ -29,6 +29,8 @@ public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
|
|
||||||
public AxialFilmCapacitor() {
|
public AxialFilmCapacitor() {
|
||||||
super();
|
super();
|
||||||
|
this.bodyColor = BODY_COLOR;
|
||||||
|
this.borderColor = BORDER_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -60,16 +62,6 @@ public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
return DEFAULT_WIDTH;
|
return DEFAULT_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBodyColor() {
|
|
||||||
return BODY_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBorderColor() {
|
|
||||||
return BORDER_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape getBodyShape() {
|
protected Shape getBodyShape() {
|
||||||
return new Rectangle2D.Double(0f, 0f, getWidth().convertToPixels(),
|
return new Rectangle2D.Double(0f, 0f, getWidth().convertToPixels(),
|
||||||
|
|||||||
+12
-9
@@ -15,7 +15,7 @@ import org.diylc.core.measures.CapacitanceUnit;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Electrolytic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Electrolytic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Vertical mounted electrolytic capacitor, polarized or bipolar", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class ElectrolyticRadial extends AbstractLeadedComponent<Capacitance> {
|
public class ElectrolyticRadial extends AbstractLeadedComponent<Capacitance> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -27,8 +27,12 @@ public class ElectrolyticRadial extends AbstractLeadedComponent<Capacitance> {
|
|||||||
|
|
||||||
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
||||||
|
|
||||||
|
private Color coverColor = COVER_COLOR;
|
||||||
|
|
||||||
public ElectrolyticRadial() {
|
public ElectrolyticRadial() {
|
||||||
super();
|
super();
|
||||||
|
this.bodyColor = BODY_COLOR;
|
||||||
|
this.borderColor = BORDER_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -51,10 +55,10 @@ public class ElectrolyticRadial extends AbstractLeadedComponent<Capacitance> {
|
|||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d) {
|
||||||
int totalDiameter = getClosestOdd(getWidth().convertToPixels());
|
int totalDiameter = getClosestOdd(getWidth().convertToPixels());
|
||||||
int coverDiameter = getClosestOdd(totalDiameter * 3 / 4);
|
int coverDiameter = getClosestOdd(totalDiameter * 3 / 4);
|
||||||
g2d.setColor(COVER_COLOR);
|
g2d.setColor(coverColor);
|
||||||
int position = (totalDiameter - coverDiameter) / 2;
|
int position = (totalDiameter - coverDiameter) / 2;
|
||||||
g2d.fillOval(position, position, coverDiameter, coverDiameter);
|
g2d.fillOval(position, position, coverDiameter, coverDiameter);
|
||||||
g2d.setColor(COVER_COLOR.darker());
|
g2d.setColor(coverColor.darker());
|
||||||
g2d.drawLine(position + coverDiameter / 5, position + coverDiameter / 5, position + 4
|
g2d.drawLine(position + coverDiameter / 5, position + coverDiameter / 5, position + 4
|
||||||
* coverDiameter / 5, position + 4 * coverDiameter / 5);
|
* coverDiameter / 5, position + 4 * coverDiameter / 5);
|
||||||
g2d.drawLine(position + coverDiameter / 5, position + 4 * coverDiameter / 5, position + 4
|
g2d.drawLine(position + coverDiameter / 5, position + 4 * coverDiameter / 5, position + 4
|
||||||
@@ -84,14 +88,13 @@ public class ElectrolyticRadial extends AbstractLeadedComponent<Capacitance> {
|
|||||||
return super.getWidth();
|
return super.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EditableProperty(name = "Cover")
|
||||||
protected Color getDefaultBodyColor() {
|
public Color getCoverColor() {
|
||||||
return BODY_COLOR;
|
return coverColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setCoverColor(Color coverColor) {
|
||||||
protected Color getDefaultBorderColor() {
|
this.coverColor = coverColor;
|
||||||
return BORDER_COLOR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-10
@@ -29,6 +29,8 @@ public class RadialCeramicDiskCapacitor extends AbstractLeadedComponent<Capacita
|
|||||||
|
|
||||||
public RadialCeramicDiskCapacitor() {
|
public RadialCeramicDiskCapacitor() {
|
||||||
super();
|
super();
|
||||||
|
this.bodyColor = BODY_COLOR;
|
||||||
|
this.borderColor = BORDER_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -60,16 +62,6 @@ public class RadialCeramicDiskCapacitor extends AbstractLeadedComponent<Capacita
|
|||||||
return DEFAULT_WIDTH;
|
return DEFAULT_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBodyColor() {
|
|
||||||
return BODY_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBorderColor() {
|
|
||||||
return BORDER_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape getBodyShape() {
|
protected Shape getBodyShape() {
|
||||||
return new Ellipse2D.Double(0f, 0f, getWidth().convertToPixels(), getClosestOdd(getHeight()
|
return new Ellipse2D.Double(0f, 0f, getWidth().convertToPixels(), getClosestOdd(getHeight()
|
||||||
|
|||||||
+2
-10
@@ -29,6 +29,8 @@ public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
|
|
||||||
public RadialFilmCapacitor() {
|
public RadialFilmCapacitor() {
|
||||||
super();
|
super();
|
||||||
|
this.bodyColor = BODY_COLOR;
|
||||||
|
this.borderColor = BORDER_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -60,16 +62,6 @@ public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
return DEFAULT_WIDTH;
|
return DEFAULT_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBodyColor() {
|
|
||||||
return BODY_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBorderColor() {
|
|
||||||
return BORDER_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape getBodyShape() {
|
protected Shape getBodyShape() {
|
||||||
double radius = getHeight().convertToPixels() * 0.7;
|
double radius = getHeight().convertToPixels() * 0.7;
|
||||||
|
|||||||
+2
-10
@@ -32,6 +32,8 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
|||||||
|
|
||||||
public Resistor() {
|
public Resistor() {
|
||||||
super();
|
super();
|
||||||
|
this.bodyColor = BODY_COLOR;
|
||||||
|
this.borderColor = BORDER_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -63,16 +65,6 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
|||||||
return DEFAULT_WIDTH;
|
return DEFAULT_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBodyColor() {
|
|
||||||
return BODY_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBorderColor() {
|
|
||||||
return BORDER_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty(name = "Color code")
|
@EditableProperty(name = "Color code")
|
||||||
public ResistorColorCode getColorCode() {
|
public ResistorColorCode getColorCode() {
|
||||||
return colorCode;
|
return colorCode;
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "DIL IC", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "IC", description = "test", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "DIL IC", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "IC", description = "IC with rectangular housing and two parallel rows of pins", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
public class DIL_IC extends AbstractTransparentComponent<String> {
|
public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+16
-14
@@ -13,7 +13,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Diode (plastic)", author = "Branislav Stojkovic", category = "Semiconductors", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "test", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Diode (plastic)", author = "Branislav Stojkovic", category = "Semiconductors", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Plastic diode, like most rectifier, zener, schottky, etc.", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class DiodePlastic extends AbstractLeadedComponent<String> {
|
public class DiodePlastic extends AbstractLeadedComponent<String> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -27,10 +27,13 @@ public class DiodePlastic extends AbstractLeadedComponent<String> {
|
|||||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
|
|
||||||
private String value = "";
|
private String value = "";
|
||||||
|
private Color markerColor = MARKER_COLOR;
|
||||||
|
|
||||||
public DiodePlastic() {
|
public DiodePlastic() {
|
||||||
super();
|
super();
|
||||||
this.labelColor = LABEL_COLOR;
|
this.labelColor = LABEL_COLOR;
|
||||||
|
this.bodyColor = BODY_COLOR;
|
||||||
|
this.borderColor = BORDER_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
@@ -65,16 +68,6 @@ public class DiodePlastic extends AbstractLeadedComponent<String> {
|
|||||||
return DEFAULT_WIDTH;
|
return DEFAULT_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBodyColor() {
|
|
||||||
return BODY_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Color getDefaultBorderColor() {
|
|
||||||
return BORDER_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape getBodyShape() {
|
protected Shape getBodyShape() {
|
||||||
return new Rectangle2D.Double(0f, 0f, getWidth().convertToPixels(),
|
return new Rectangle2D.Double(0f, 0f, getWidth().convertToPixels(),
|
||||||
@@ -83,10 +76,19 @@ public class DiodePlastic extends AbstractLeadedComponent<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d) {
|
||||||
g2d.setColor(MARKER_COLOR);
|
g2d.setColor(markerColor);
|
||||||
int width = getWidth().convertToPixels();
|
int width = getWidth().convertToPixels();
|
||||||
int markerWidth = MARKER_WIDTH.convertToPixels();
|
int markerWidth = MARKER_WIDTH.convertToPixels();
|
||||||
g2d.fillRect(width - markerWidth, 0, markerWidth, getClosestOdd(getHeight().convertToPixels()));
|
g2d.fillRect(width - markerWidth, 0, markerWidth, getClosestOdd(getHeight()
|
||||||
super.decorateComponentBody(g2d);
|
.convertToPixels()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Marker")
|
||||||
|
public Color getMarkerColor() {
|
||||||
|
return markerColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkerColor(Color markerColor) {
|
||||||
|
this.markerColor = markerColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+265
@@ -0,0 +1,265 @@
|
|||||||
|
package org.diylc.components.semiconductors;
|
||||||
|
|
||||||
|
import java.awt.AlphaComposite;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Composite;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.common.ObjectCache;
|
||||||
|
import org.diylc.common.Orientation;
|
||||||
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
|
import org.diylc.core.ComponentState;
|
||||||
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.IDrawingObserver;
|
||||||
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
import org.diylc.core.measures.Size;
|
||||||
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
|
@ComponentDescriptor(name = "Transistor (TO-220 package)", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "Q", description = "Transistors with metal tab for heat sink mounting", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
|
public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static Color BODY_COLOR = Color.gray;
|
||||||
|
public static Color BORDER_COLOR = Color.gray.darker();
|
||||||
|
public static Color PIN_COLOR = Color.decode("#00B2EE");
|
||||||
|
public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
|
||||||
|
public static Color TAB_COLOR = Color.decode("#C3E4ED");
|
||||||
|
public static Color TAB_BORDER_COLOR = TAB_COLOR.darker();
|
||||||
|
public static Color LABEL_COLOR = Color.white;
|
||||||
|
public static Size PIN_SIZE = new Size(0.03d, SizeUnit.in);
|
||||||
|
public static Size PIN_SPACING = new Size(0.1d, SizeUnit.in);
|
||||||
|
public static Size BODY_WIDTH = new Size(0.4d, SizeUnit.in);
|
||||||
|
public static Size BODY_HEIGHT = new Size(4.5d, SizeUnit.mm);
|
||||||
|
public static Size TAB_THICKNESS = new Size(0.05d, SizeUnit.in);
|
||||||
|
|
||||||
|
private String value = "";
|
||||||
|
private Orientation orientation = Orientation.DEFAULT;
|
||||||
|
private Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0) };
|
||||||
|
private Shape[] body;
|
||||||
|
private Color bodyColor = BODY_COLOR;
|
||||||
|
private Color borderColor = BORDER_COLOR;
|
||||||
|
private Color tabColor = TAB_COLOR;
|
||||||
|
private Color tabBorderColor = TAB_BORDER_COLOR;
|
||||||
|
|
||||||
|
public TransistorTO220() {
|
||||||
|
super();
|
||||||
|
updateControlPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Orientation getOrientation() {
|
||||||
|
return orientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrientation(Orientation orientation) {
|
||||||
|
this.orientation = orientation;
|
||||||
|
updateControlPoints();
|
||||||
|
// Reset body shape;
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getControlPointCount() {
|
||||||
|
return controlPoints.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Point getControlPoint(int index) {
|
||||||
|
return controlPoints[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setControlPoint(Point point, int index) {
|
||||||
|
controlPoints[index].setLocation(point);
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateControlPoints() {
|
||||||
|
int pinSpacing = PIN_SPACING.convertToPixels();
|
||||||
|
// Update control points.
|
||||||
|
int x = controlPoints[0].x;
|
||||||
|
int y = controlPoints[0].y;
|
||||||
|
switch (orientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
controlPoints[1].setLocation(x, y + pinSpacing);
|
||||||
|
controlPoints[2].setLocation(x, y + 2 * pinSpacing);
|
||||||
|
break;
|
||||||
|
case _90:
|
||||||
|
controlPoints[1].setLocation(x - pinSpacing, y);
|
||||||
|
controlPoints[2].setLocation(x - 2 * pinSpacing, y);
|
||||||
|
break;
|
||||||
|
case _180:
|
||||||
|
controlPoints[1].setLocation(x, y - pinSpacing);
|
||||||
|
controlPoints[2].setLocation(x, y - 2 * pinSpacing);
|
||||||
|
break;
|
||||||
|
case _270:
|
||||||
|
controlPoints[1].setLocation(x + pinSpacing, y);
|
||||||
|
controlPoints[2].setLocation(x + 2 * pinSpacing, y);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shape[] getBody() {
|
||||||
|
if (body == null) {
|
||||||
|
body = new Shape[2];
|
||||||
|
int x = controlPoints[0].x;
|
||||||
|
int y = controlPoints[0].y;
|
||||||
|
int pinSpacing = PIN_SPACING.convertToPixels();
|
||||||
|
int bodyWidth = getClosestOdd(BODY_WIDTH.convertToPixels());
|
||||||
|
int bodyHeight = getClosestOdd(BODY_HEIGHT.convertToPixels());
|
||||||
|
int tabThickness = TAB_THICKNESS.convertToPixels();
|
||||||
|
|
||||||
|
switch (orientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
body[0] = new Rectangle2D.Double(x - bodyHeight / 2,
|
||||||
|
y + pinSpacing - bodyWidth / 2, bodyHeight, bodyWidth);
|
||||||
|
body[1] = new Rectangle2D.Double(x + bodyHeight / 2 - tabThickness, y + pinSpacing
|
||||||
|
- bodyWidth / 2, tabThickness, bodyWidth);
|
||||||
|
break;
|
||||||
|
case _90:
|
||||||
|
body[0] = new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2,
|
||||||
|
y - bodyHeight / 2, bodyWidth, bodyHeight);
|
||||||
|
body[1] = new Rectangle2D.Double(x - pinSpacing - bodyWidth / 2, y + bodyHeight / 2
|
||||||
|
- tabThickness, bodyWidth, tabThickness);
|
||||||
|
break;
|
||||||
|
case _180:
|
||||||
|
body[0] = new Rectangle2D.Double(x - bodyHeight / 2,
|
||||||
|
y - pinSpacing - bodyWidth / 2, bodyHeight, bodyWidth);
|
||||||
|
body[1] = new Rectangle2D.Double(x - bodyHeight / 2,
|
||||||
|
y - pinSpacing - bodyWidth / 2, tabThickness, bodyWidth);
|
||||||
|
break;
|
||||||
|
case _270:
|
||||||
|
body[0] = new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2,
|
||||||
|
y - bodyHeight / 2, bodyWidth, bodyHeight);
|
||||||
|
body[1] = new Rectangle2D.Double(x + pinSpacing - bodyWidth / 2,
|
||||||
|
y - bodyHeight / 2, bodyWidth, tabThickness);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||||
|
IDrawingObserver drawingObserver) {
|
||||||
|
int pinSize = PIN_SIZE.convertToPixels() / 2 * 2;
|
||||||
|
Shape mainArea = getBody()[0];
|
||||||
|
Shape tabArea = getBody()[1];
|
||||||
|
Composite oldComposite = g2d.getComposite();
|
||||||
|
if (alpha < MAX_ALPHA) {
|
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
|
/ MAX_ALPHA));
|
||||||
|
}
|
||||||
|
g2d.setColor(bodyColor);
|
||||||
|
g2d.fill(mainArea);
|
||||||
|
g2d.setColor(tabColor);
|
||||||
|
g2d.fill(tabArea);
|
||||||
|
g2d.setComposite(oldComposite);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
|
g2d.setColor(tabBorderColor);
|
||||||
|
g2d.draw(tabArea);
|
||||||
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||||
|
g2d.draw(mainArea);
|
||||||
|
|
||||||
|
for (Point point : controlPoints) {
|
||||||
|
g2d.setColor(PIN_COLOR);
|
||||||
|
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
|
g2d.setColor(PIN_BORDER_COLOR);
|
||||||
|
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw label.
|
||||||
|
g2d.setFont(LABEL_FONT);
|
||||||
|
g2d.setColor(LABEL_COLOR);
|
||||||
|
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||||
|
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
||||||
|
int textHeight = (int) (rect.getHeight());
|
||||||
|
int textWidth = (int) (rect.getWidth());
|
||||||
|
// Center text horizontally and vertically
|
||||||
|
Rectangle bounds = mainArea.getBounds();
|
||||||
|
int x = bounds.x + (bounds.width - textWidth) / 2;
|
||||||
|
int y = bounds.y + (bounds.height - textHeight) / 2 + fontMetrics.getAscent();
|
||||||
|
g2d.drawString(getName(), x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
g2d.setColor(BODY_COLOR);
|
||||||
|
int margin = 2 * width / 32;
|
||||||
|
int thickness = 7 * width / 32;
|
||||||
|
g2d.fillRect(margin, (height - thickness) / 2, width - margin * 2, thickness);
|
||||||
|
g2d.setColor(TAB_COLOR);
|
||||||
|
g2d.fillRect(margin, (height + thickness) / 2 - margin - 1, width - margin * 2, margin);
|
||||||
|
g2d.setColor(BORDER_COLOR);
|
||||||
|
g2d.drawRect(margin, (height - thickness) / 2, width - margin * 2, thickness);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Body")
|
||||||
|
public Color getBodyColor() {
|
||||||
|
return bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyColor(Color bodyColor) {
|
||||||
|
this.bodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Border")
|
||||||
|
public Color getBorderColor() {
|
||||||
|
return borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBorderColor(Color borderColor) {
|
||||||
|
this.borderColor = borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Tab")
|
||||||
|
public Color getTabColor() {
|
||||||
|
return tabColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTabColor(Color tabColor) {
|
||||||
|
this.tabColor = tabColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Tab border")
|
||||||
|
public Color getTabBorderColor() {
|
||||||
|
return tabBorderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTabBorderColor(Color tabBorderColor) {
|
||||||
|
this.tabBorderColor = tabBorderColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
-14
@@ -7,7 +7,6 @@ import java.awt.FontMetrics;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Shape;
|
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
@@ -25,7 +24,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Transistor (TO-92 package)", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "Q", description = "test", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Transistor (TO-92 package)", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "Q", description = "Transistor with small plastic or epoxy body", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -42,17 +41,9 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
private String value = "";
|
private String value = "";
|
||||||
private Orientation orientation = Orientation.DEFAULT;
|
private Orientation orientation = Orientation.DEFAULT;
|
||||||
private Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0) };
|
private Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0) };
|
||||||
// new Point(0, pinSpacing.convertToPixels()),
|
|
||||||
// new Point(0, 2 * pinSpacing.convertToPixels()),
|
|
||||||
// new Point(0, 3 * pinSpacing.convertToPixels()),
|
|
||||||
// new Point(3 * pinSpacing.convertToPixels(), 0),
|
|
||||||
// new Point(3 * pinSpacing.convertToPixels(),
|
|
||||||
// pinSpacing.convertToPixels()),
|
|
||||||
// new Point(3 * pinSpacing.convertToPixels(), 2 *
|
|
||||||
// pinSpacing.convertToPixels()),
|
|
||||||
// new Point(3 * pinSpacing.convertToPixels(), 3 *
|
|
||||||
// pinSpacing.convertToPixels()) };
|
|
||||||
private Area body;
|
private Area body;
|
||||||
|
private Color bodyColor = BODY_COLOR;
|
||||||
|
private Color borderColor = BORDER_COLOR;
|
||||||
|
|
||||||
public TransistorTO92() {
|
public TransistorTO92() {
|
||||||
super();
|
super();
|
||||||
@@ -182,11 +173,11 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(BODY_COLOR);
|
g2d.setColor(bodyColor);
|
||||||
g2d.fill(mainArea);
|
g2d.fill(mainArea);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR);
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
g2d.draw(mainArea);
|
g2d.draw(mainArea);
|
||||||
|
|
||||||
@@ -222,4 +213,22 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.draw(area);
|
g2d.draw(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Body")
|
||||||
|
public Color getBodyColor() {
|
||||||
|
return bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyColor(Color bodyColor) {
|
||||||
|
this.bodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Border")
|
||||||
|
public Color getBorderColor() {
|
||||||
|
return borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBorderColor(Color borderColor) {
|
||||||
|
this.borderColor = borderColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user