mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
added LED
This commit is contained in:
+6
-6
@@ -88,14 +88,14 @@ public class CopperTrace extends AbstractLeadedComponent<Void> {
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Size getWidth() {
|
||||
return super.getWidth();
|
||||
public Size getLength() {
|
||||
return super.getLength();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Size getHeight() {
|
||||
return super.getHeight();
|
||||
public Size getWidth() {
|
||||
return super.getWidth();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -115,12 +115,12 @@ public class CopperTrace extends AbstractLeadedComponent<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultHeight() {
|
||||
protected Size getDefaultWidth() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
protected Size getDefaultLength() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -53,14 +53,14 @@ public class Jumper extends AbstractLeadedComponent<Void> {
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Size getWidth() {
|
||||
return super.getWidth();
|
||||
public Size getLength() {
|
||||
return super.getLength();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Size getHeight() {
|
||||
return super.getHeight();
|
||||
public Size getWidth() {
|
||||
return super.getWidth();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -80,12 +80,12 @@ public class Jumper extends AbstractLeadedComponent<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultHeight() {
|
||||
protected Size getDefaultWidth() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
protected Size getDefaultLength() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -53,18 +53,18 @@ public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultHeight() {
|
||||
protected Size getDefaultWidth() {
|
||||
return DEFAULT_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
protected Size getDefaultLength() {
|
||||
return DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Shape getBodyShape() {
|
||||
return new Rectangle2D.Double(0f, 0f, getWidth().convertToPixels(),
|
||||
getClosestOdd(getHeight().convertToPixels()));
|
||||
return new Rectangle2D.Double(0f, 0f, getLength().convertToPixels(),
|
||||
getClosestOdd(getWidth().convertToPixels()));
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -53,7 +53,7 @@ public class ElectrolyticRadial extends AbstractLeadedComponent<Capacitance> {
|
||||
|
||||
@Override
|
||||
protected void decorateComponentBody(Graphics2D g2d) {
|
||||
int totalDiameter = getClosestOdd(getWidth().convertToPixels());
|
||||
int totalDiameter = getClosestOdd(getLength().convertToPixels());
|
||||
int coverDiameter = getClosestOdd(totalDiameter * 3 / 4);
|
||||
g2d.setColor(coverColor);
|
||||
int position = (totalDiameter - coverDiameter) / 2;
|
||||
@@ -66,26 +66,26 @@ public class ElectrolyticRadial extends AbstractLeadedComponent<Capacitance> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultHeight() {
|
||||
protected Size getDefaultWidth() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Size getHeight() {
|
||||
return super.getHeight();
|
||||
public Size getWidth() {
|
||||
return super.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
protected Size getDefaultLength() {
|
||||
// We'll reuse width property to set the diameter.
|
||||
return DEFAULT_SIZE;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Diameter")
|
||||
@Override
|
||||
public Size getWidth() {
|
||||
return super.getWidth();
|
||||
public Size getLength() {
|
||||
return super.getLength();
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Cover")
|
||||
@@ -99,7 +99,7 @@ public class ElectrolyticRadial extends AbstractLeadedComponent<Capacitance> {
|
||||
|
||||
@Override
|
||||
protected Shape getBodyShape() {
|
||||
return new Ellipse2D.Double(0f, 0f, getClosestOdd(getWidth().convertToPixels()),
|
||||
getClosestOdd(getWidth().convertToPixels()));
|
||||
return new Ellipse2D.Double(0f, 0f, getClosestOdd(getLength().convertToPixels()),
|
||||
getClosestOdd(getLength().convertToPixels()));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -53,18 +53,18 @@ public class RadialCeramicDiskCapacitor extends AbstractLeadedComponent<Capacita
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultHeight() {
|
||||
protected Size getDefaultWidth() {
|
||||
return DEFAULT_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
protected Size getDefaultLength() {
|
||||
return DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Shape getBodyShape() {
|
||||
return new Ellipse2D.Double(0f, 0f, getWidth().convertToPixels(), getClosestOdd(getHeight()
|
||||
return new Ellipse2D.Double(0f, 0f, getLength().convertToPixels(), getClosestOdd(getWidth()
|
||||
.convertToPixels()));
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -53,19 +53,19 @@ public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultHeight() {
|
||||
protected Size getDefaultWidth() {
|
||||
return DEFAULT_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
protected Size getDefaultLength() {
|
||||
return DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Shape getBodyShape() {
|
||||
double radius = getHeight().convertToPixels() * 0.7;
|
||||
return new RoundRectangle2D.Double(0f, 0f, getWidth().convertToPixels(),
|
||||
getClosestOdd(getHeight().convertToPixels()), radius, radius);
|
||||
double radius = getWidth().convertToPixels() * 0.7;
|
||||
return new RoundRectangle2D.Double(0f, 0f, getLength().convertToPixels(),
|
||||
getClosestOdd(getWidth().convertToPixels()), radius, radius);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -56,12 +56,12 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultHeight() {
|
||||
protected Size getDefaultWidth() {
|
||||
return DEFAULT_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
protected Size getDefaultLength() {
|
||||
return DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||
|
||||
@Override
|
||||
protected Shape getBodyShape() {
|
||||
return new Rectangle2D.Double(0f, 0f, getWidth().convertToPixels(),
|
||||
getClosestOdd(getHeight().convertToPixels()));
|
||||
return new Rectangle2D.Double(0f, 0f, getLength().convertToPixels(),
|
||||
getClosestOdd(getWidth().convertToPixels()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +86,7 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||
if (colorCode == ResistorColorCode.NONE) {
|
||||
return;
|
||||
}
|
||||
int height = getClosestOdd(getHeight().convertToPixels());
|
||||
int height = getClosestOdd(getWidth().convertToPixels());
|
||||
Color[] bands = value.getColorCode(colorCode);
|
||||
int x = 4;
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||
|
||||
+6
-6
@@ -59,27 +59,27 @@ public class DiodePlastic extends AbstractLeadedComponent<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultHeight() {
|
||||
protected Size getDefaultWidth() {
|
||||
return DEFAULT_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
protected Size getDefaultLength() {
|
||||
return DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Shape getBodyShape() {
|
||||
return new Rectangle2D.Double(0f, 0f, getWidth().convertToPixels(),
|
||||
getClosestOdd(getHeight().convertToPixels()));
|
||||
return new Rectangle2D.Double(0f, 0f, getLength().convertToPixels(),
|
||||
getClosestOdd(getWidth().convertToPixels()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorateComponentBody(Graphics2D g2d) {
|
||||
g2d.setColor(markerColor);
|
||||
int width = getWidth().convertToPixels();
|
||||
int width = getLength().convertToPixels();
|
||||
int markerWidth = MARKER_WIDTH.convertToPixels();
|
||||
g2d.fillRect(width - markerWidth, 0, markerWidth, getClosestOdd(getHeight()
|
||||
g2d.fillRect(width - markerWidth, 0, markerWidth, getClosestOdd(getWidth()
|
||||
.convertToPixels()));
|
||||
}
|
||||
|
||||
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package org.diylc.components.semiconductors;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
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.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "LED", author = "Branislav Stojkovic", category = "Semiconductors", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Light Emitting Diode", zOrder = IDIYComponent.COMPONENT)
|
||||
public class LED extends AbstractLeadedComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Size DEFAULT_SIZE = new Size(5d, SizeUnit.mm);
|
||||
public static Color BODY_COLOR = Color.decode("#5DFC0A");
|
||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||
|
||||
private String value = "";
|
||||
|
||||
public LED() {
|
||||
super();
|
||||
this.bodyColor = BODY_COLOR;
|
||||
this.borderColor = BORDER_COLOR;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
g2d.setColor(LEAD_COLOR);
|
||||
g2d.drawLine(0, height / 2, width, height / 2);
|
||||
|
||||
int margin = 4 * width / 32;
|
||||
Area area = new Area(new Ellipse2D.Double(margin, margin, width - 2 * margin, width - 2
|
||||
* margin));
|
||||
area.intersect(new Area(new Rectangle2D.Double(margin, margin, width - 5 * margin / 2,
|
||||
width - 2 * margin)));
|
||||
g2d.setColor(BODY_COLOR);
|
||||
g2d.fill(area);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.draw(area);
|
||||
g2d
|
||||
.drawOval(margin * 2 - 1, margin * 2 - 1, width - 4 * margin + 2, width - 4
|
||||
* margin + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultWidth() {
|
||||
return DEFAULT_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Size getDefaultLength() {
|
||||
return DEFAULT_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Shape getBodyShape() {
|
||||
int size = getClosestOdd((int) (getLength().convertToPixels() * 1.2));
|
||||
Area area = new Area(new Ellipse2D.Double(0, 0, size, size));
|
||||
area.intersect(new Area(new Rectangle2D.Double(0, 0, getLength().convertToPixels() * 1.15,
|
||||
size)));
|
||||
return area;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorateComponentBody(Graphics2D g2d) {
|
||||
int size = getClosestOdd((int) (getLength().convertToPixels() * 1.2));
|
||||
int innerSize = getClosestOdd(getLength().convertToPixels());
|
||||
int x = (size - innerSize) / 2;
|
||||
Shape s = new Ellipse2D.Double(x, x, innerSize, innerSize);
|
||||
g2d.setColor(getBorderColor());
|
||||
g2d.draw(s);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Size")
|
||||
@Override
|
||||
public Size getLength() {
|
||||
return super.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Size getWidth() {
|
||||
return super.getWidth();
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -207,7 +207,9 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
||||
int margin = 3 * width / 32;
|
||||
Area area = new Area(new Ellipse2D.Double(margin / 2, margin, width - 2 * margin, width - 2
|
||||
* margin));
|
||||
area.subtract(new Area(new Rectangle2D.Double(0, 0, 2 * margin, height)));
|
||||
// area.subtract(new Area(new Rectangle2D.Double(0, 0, 2 * margin,
|
||||
// height)));
|
||||
area.intersect(new Area(new Rectangle2D.Double(2 * margin, 0, width, height)));
|
||||
g2d.setColor(BODY_COLOR);
|
||||
g2d.fill(area);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
|
||||
Reference in New Issue
Block a user