mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Editable pin spacing for all radial components
Folded elytics
This commit is contained in:
Binary file not shown.
+3
-3
@@ -5,7 +5,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
|
||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractRadialComponent;
|
||||||
import org.diylc.core.CreationMethod;
|
import org.diylc.core.CreationMethod;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
@@ -17,11 +17,11 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
import org.diylc.core.measures.VoltageUnit;
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Ceramic Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Standard radial ceramic capacitor", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Ceramic Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Standard radial ceramic capacitor", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class RadialCeramicDiskCapacitor extends AbstractLeadedComponent<Capacitance> {
|
public class RadialCeramicDiskCapacitor extends AbstractRadialComponent<Capacitance> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static Size DEFAULT_WIDTH = new Size(1d / 2, SizeUnit.in);
|
public static Size DEFAULT_WIDTH = new Size(1d / 4, SizeUnit.in);
|
||||||
public static Size DEFAULT_HEIGHT = new Size(1d / 8, SizeUnit.in);
|
public static Size DEFAULT_HEIGHT = new Size(1d / 8, SizeUnit.in);
|
||||||
public static Color BODY_COLOR = Color.decode("#F0E68C");
|
public static Color BODY_COLOR = Color.decode("#F0E68C");
|
||||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
|
|||||||
+72
-17
@@ -6,11 +6,12 @@ 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;
|
||||||
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractRadialComponent;
|
||||||
import org.diylc.core.CreationMethod;
|
import org.diylc.core.CreationMethod;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.Theme;
|
import org.diylc.core.Theme;
|
||||||
@@ -24,25 +25,29 @@ import org.diylc.core.measures.VoltageUnit;
|
|||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@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)
|
@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 RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
public class RadialElectrolytic extends AbstractRadialComponent<Capacitance> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static Size DEFAULT_SIZE = new Size(1d / 2, SizeUnit.in);
|
public static Size DEFAULT_SIZE = new Size(1d / 4, SizeUnit.in);
|
||||||
public static Color BODY_COLOR = Color.decode("#EAADEA");
|
public static Color BODY_COLOR = Color.decode("#EAADEA");
|
||||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
public static Color MARKER_COLOR = Color.gray;
|
public static Color MARKER_COLOR = Color.gray;
|
||||||
public static Color TICK_COLOR = Color.white;
|
public static Color TICK_COLOR = Color.white;
|
||||||
|
public static Size HEIGHT = new Size(0.4d, SizeUnit.in);
|
||||||
|
public static Size EDGE_RADIUS = new Size(1d, SizeUnit.mm);
|
||||||
|
|
||||||
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private Voltage voltage = Voltage._63V;
|
private Voltage voltage = Voltage._63V;
|
||||||
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(
|
||||||
VoltageUnit.V);
|
63d, VoltageUnit.V);
|
||||||
|
|
||||||
private Color markerColor = MARKER_COLOR;
|
private Color markerColor = MARKER_COLOR;
|
||||||
private Color tickColor = TICK_COLOR;
|
private Color tickColor = TICK_COLOR;
|
||||||
private boolean polarized = true;
|
private boolean polarized = true;
|
||||||
|
private boolean folded = false;
|
||||||
|
private Size height = HEIGHT;
|
||||||
|
|
||||||
public RadialElectrolytic() {
|
public RadialElectrolytic() {
|
||||||
super();
|
super();
|
||||||
@@ -92,16 +97,18 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
|||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
g2d.setColor(BODY_COLOR);
|
g2d.setColor(BODY_COLOR);
|
||||||
int margin = 3;
|
int margin = 3;
|
||||||
Ellipse2D body = new Ellipse2D.Double(margin, margin, getClosestOdd(width - 2 * margin),
|
Ellipse2D body = new Ellipse2D.Double(margin, margin,
|
||||||
getClosestOdd(width - 2 * margin));
|
getClosestOdd(width - 2 * margin), getClosestOdd(width - 2
|
||||||
|
* margin));
|
||||||
g2d.fill(body);
|
g2d.fill(body);
|
||||||
Area marker = new Area(body);
|
Area marker = new Area(body);
|
||||||
marker.subtract(new Area(new Rectangle2D.Double(margin, margin, width - 4 * margin,
|
marker.subtract(new Area(new Rectangle2D.Double(margin, margin, width
|
||||||
getClosestOdd(width - 2 * margin))));
|
- 4 * margin, getClosestOdd(width - 2 * margin))));
|
||||||
g2d.setColor(MARKER_COLOR);
|
g2d.setColor(MARKER_COLOR);
|
||||||
g2d.fill(marker);
|
g2d.fill(marker);
|
||||||
g2d.setColor(TICK_COLOR);
|
g2d.setColor(TICK_COLOR);
|
||||||
g2d.drawLine(width - 2 * margin, height / 2 - 2, width - 2 * margin, height / 2 + 2);
|
g2d.drawLine(width - 2 * margin, height / 2 - 2, width - 2 * margin,
|
||||||
|
height / 2 + 2);
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.draw(body);
|
g2d.draw(body);
|
||||||
// g2d.setColor(COVER_COLOR.darker());
|
// g2d.setColor(COVER_COLOR.darker());
|
||||||
@@ -115,29 +122,51 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||||
|
int height = (int) getHeight().convertToPixels();
|
||||||
if (polarized) {
|
if (polarized) {
|
||||||
int totalDiameter = getClosestOdd(getLength().convertToPixels());
|
int totalDiameter = getClosestOdd(getLength().convertToPixels());
|
||||||
if (!outlineMode) {
|
if (!outlineMode) {
|
||||||
|
if (folded) {
|
||||||
Area area = new Area(getBodyShape());
|
Area area = new Area(getBodyShape());
|
||||||
area.subtract(new Area(new Rectangle2D.Double(0, 0, totalDiameter * 0.8,
|
area.subtract(new Area(new Rectangle2D.Double(0, -height,
|
||||||
totalDiameter)));
|
totalDiameter * 0.8, height * 2)));
|
||||||
|
g2d.setColor(markerColor);
|
||||||
|
g2d.fill(area);
|
||||||
|
} else {
|
||||||
|
Area area = new Area(getBodyShape());
|
||||||
|
area.subtract(new Area(new Rectangle2D.Double(0, 0,
|
||||||
|
totalDiameter * 0.8, totalDiameter)));
|
||||||
g2d.setColor(markerColor);
|
g2d.setColor(markerColor);
|
||||||
g2d.fill(area);
|
g2d.fill(area);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Color finalTickColor;
|
Color finalTickColor;
|
||||||
if (outlineMode) {
|
if (outlineMode) {
|
||||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
Theme theme = (Theme) ConfigurationManager.getInstance()
|
||||||
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
.readObject(IPlugInPort.THEME_KEY,
|
||||||
|
Constants.DEFAULT_THEME);
|
||||||
finalTickColor = theme.getOutlineColor();
|
finalTickColor = theme.getOutlineColor();
|
||||||
} else {
|
} else {
|
||||||
finalTickColor = tickColor;
|
finalTickColor = tickColor;
|
||||||
}
|
}
|
||||||
g2d.setColor(finalTickColor);
|
g2d.setColor(finalTickColor);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||||
|
if (folded) {
|
||||||
|
int tickLength = height / 7;
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
g2d.drawLine((int) (totalDiameter * 0.92), -height / 2
|
||||||
|
+ tickLength + i * tickLength * 2,
|
||||||
|
(int) (totalDiameter * 0.92), -height / 2
|
||||||
|
+ tickLength + i * tickLength * 2
|
||||||
|
+ tickLength);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
g2d.drawLine((int) (totalDiameter * 0.9), totalDiameter / 2
|
g2d.drawLine((int) (totalDiameter * 0.9), totalDiameter / 2
|
||||||
- (int) (totalDiameter * 0.05), (int) (totalDiameter * 0.9), totalDiameter / 2
|
- (int) (totalDiameter * 0.05),
|
||||||
|
(int) (totalDiameter * 0.9), totalDiameter / 2
|
||||||
+ (int) (totalDiameter * 0.05));
|
+ (int) (totalDiameter * 0.05));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// int coverDiameter = getClosestOdd(totalDiameter * 3 / 4);
|
// int coverDiameter = getClosestOdd(totalDiameter * 3 / 4);
|
||||||
// g2d.setColor(coverColor);
|
// g2d.setColor(coverColor);
|
||||||
// int position = (totalDiameter - coverDiameter) / 2;
|
// int position = (totalDiameter - coverDiameter) / 2;
|
||||||
@@ -200,9 +229,35 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
|||||||
this.polarized = polarized;
|
this.polarized = polarized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public boolean getFolded() {
|
||||||
|
return folded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFolded(boolean folded) {
|
||||||
|
this.folded = folded;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Size getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeight(Size height) {
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shape getBodyShape() {
|
protected Shape getBodyShape() {
|
||||||
return new Ellipse2D.Double(0f, 0f, getClosestOdd(getLength().convertToPixels()),
|
double height = (int) getHeight().convertToPixels();
|
||||||
getClosestOdd(getLength().convertToPixels()));
|
double diameter = (int) getLength().convertToPixels();
|
||||||
|
if (folded) {
|
||||||
|
return new RoundRectangle2D.Double(0f, -height / 2
|
||||||
|
- LEAD_THICKNESS.convertToPixels() / 2,
|
||||||
|
getClosestOdd(diameter), getClosestOdd(height), EDGE_RADIUS
|
||||||
|
.convertToPixels(), EDGE_RADIUS.convertToPixels());
|
||||||
|
}
|
||||||
|
return new Ellipse2D.Double(0f, 0f, getClosestOdd(diameter),
|
||||||
|
getClosestOdd(diameter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-7
@@ -5,7 +5,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractRadialComponent;
|
||||||
import org.diylc.core.CreationMethod;
|
import org.diylc.core.CreationMethod;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
@@ -17,20 +17,20 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
import org.diylc.core.measures.VoltageUnit;
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Film Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Radial film capacitor, similar to Sprague Orange Drop", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Film Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Radial film capacitor, similar to Sprague Orange Drop", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
public class RadialFilmCapacitor extends AbstractRadialComponent<Capacitance> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static Size DEFAULT_WIDTH = new Size(1d, SizeUnit.in);
|
public static Size DEFAULT_WIDTH = new Size(1d / 4, SizeUnit.in);
|
||||||
public static Size DEFAULT_HEIGHT = new Size(1d / 4, SizeUnit.in);
|
public static Size DEFAULT_HEIGHT = new Size(1d / 8, SizeUnit.in);
|
||||||
public static Color BODY_COLOR = Color.decode("#FF8000");
|
public static Color BODY_COLOR = Color.decode("#FF8000");
|
||||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
|
|
||||||
private Capacitance value = new Capacitance(123d, CapacitanceUnit.nF);
|
private Capacitance value = new Capacitance(123d, CapacitanceUnit.nF);
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private Voltage voltage = Voltage._63V;
|
private Voltage voltage = Voltage._63V;
|
||||||
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(
|
||||||
VoltageUnit.V);
|
63d, VoltageUnit.V);
|
||||||
|
|
||||||
public RadialFilmCapacitor() {
|
public RadialFilmCapacitor() {
|
||||||
super();
|
super();
|
||||||
@@ -100,7 +100,8 @@ public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
|||||||
@Override
|
@Override
|
||||||
protected Shape getBodyShape() {
|
protected Shape getBodyShape() {
|
||||||
double radius = getWidth().convertToPixels() * 0.7;
|
double radius = getWidth().convertToPixels() * 0.7;
|
||||||
return new RoundRectangle2D.Double(0f, 0f, getLength().convertToPixels(),
|
return new RoundRectangle2D.Double(0f, 0f, getLength()
|
||||||
|
.convertToPixels(),
|
||||||
getClosestOdd(getWidth().convertToPixels()), radius, radius);
|
getClosestOdd(getWidth().convertToPixels()), radius, radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user