mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Added air-core inductor variation
This commit is contained in:
@@ -305,6 +305,10 @@
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added new 'Dial Scale' variations - 'Ticks + Numeric (0/5.5/11)' a'la Friedman and another variation of 'Ticks' with more pronounced 9/12/3 o'clock indices</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Core' property to 'Radial Inductor' component that allows selection between Ferrite and Air core inductor models'</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Envelope' property to tube symbol components which can be used to display one side of the outer envelope dashed indicating section A or section B of a tube</description>
|
||||
|
||||
@@ -259,15 +259,15 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
if (bodyColor != null) {
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||
if (getBodyColor() != null) {
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBodyColor());
|
||||
|
||||
drawingObserver.startTracking();
|
||||
|
||||
if (!outlineMode && ConfigurationManager.getInstance().readBoolean(IPlugInPort.HI_QUALITY_RENDER_KEY, false)) {
|
||||
Point2D p1 = new Point2D.Double(length / 2, 0);
|
||||
Point2D p2 = new Point2D.Double(length / 2, width);
|
||||
ShadedPaint paint = theta > 0 && theta < Math.PI ? new ShadedPaint(p2, p1, bodyColor) : new ShadedPaint(p1, p2, bodyColor);
|
||||
ShadedPaint paint = theta > 0 && theta < Math.PI ? new ShadedPaint(p2, p1, getBodyColor()) : new ShadedPaint(p1, p2, getBodyColor());
|
||||
Paint oldPaint = g2d.getPaint();
|
||||
g2d.setPaint(paint);
|
||||
g2d.fill(shape);
|
||||
@@ -299,17 +299,17 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor;
|
||||
: getBorderColor();
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
|
||||
// if we are not filling the shape with color we need to ensure that we track the outline (e.g. with schematic symbols)
|
||||
if (bodyColor == null)
|
||||
if (getBodyColor() == null)
|
||||
drawingObserver.startTracking();
|
||||
|
||||
g2d.draw(shape);
|
||||
|
||||
if (bodyColor == null)
|
||||
if (getBodyColor() == null)
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
if (decorateAboveBorder()) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.diylc.components.passive;
|
||||
|
||||
public enum InductorCore {
|
||||
|
||||
Ferrite("Ferrite"),
|
||||
Air("Air");
|
||||
|
||||
private String name;
|
||||
|
||||
private InductorCore(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
+99
-19
@@ -23,7 +23,7 @@ package org.diylc.components.passive;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Area;
|
||||
@@ -42,6 +42,7 @@ import org.diylc.core.measures.Inductance;
|
||||
import org.diylc.core.measures.Resistance;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Inductor (Radial)", author = "Branislav Stojkovic", category = "Passive",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "L",
|
||||
@@ -50,6 +51,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
public class RadialInductor extends AbstractRadialComponent<Inductance> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final int LAYER_COUNT = 20;
|
||||
|
||||
public static Size DEFAULT_SIZE = new Size(1d / 4, SizeUnit.in);
|
||||
public static Color BODY_COLOR = Color.darkGray;
|
||||
@@ -66,6 +68,8 @@ public class RadialInductor extends AbstractRadialComponent<Inductance> {
|
||||
private boolean folded = false;
|
||||
private Size height = HEIGHT;
|
||||
private Size lip = LIP;
|
||||
private InductorCore core = InductorCore.Ferrite;
|
||||
private Size innerDiameter = new Size(1d / 8, SizeUnit.in);
|
||||
|
||||
public RadialInductor() {
|
||||
super();
|
||||
@@ -82,22 +86,48 @@ public class RadialInductor extends AbstractRadialComponent<Inductance> {
|
||||
|
||||
@Override
|
||||
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||
if (!getFolded())
|
||||
if (!getFolded()) {
|
||||
if (core == InductorCore.Air) {
|
||||
double diameter = getClosestOdd(getLength().convertToPixels());
|
||||
double innerDiam = getInnerDiameter().convertToPixels();
|
||||
|
||||
double rIn = innerDiam / 2.0;
|
||||
double rOut = diameter / 2.0;
|
||||
double radialStep = (rOut - rIn) / 19.8;
|
||||
double strokeWidth = radialStep * 0.8;
|
||||
|
||||
Stroke stroke = ObjectCache.getInstance().fetchBasicStroke((float) strokeWidth);
|
||||
Area copper = new Area();
|
||||
|
||||
for (int i = 0; i < LAYER_COUNT; i++) {
|
||||
double rCenter = rIn + 0.4 * radialStep + i * radialStep;
|
||||
double currentDiam = rCenter * 2;
|
||||
Shape circle = stroke.createStrokedShape(new Ellipse2D.Double((diameter - currentDiam) / 2, (diameter - currentDiam) / 2, currentDiam, currentDiam));
|
||||
copper.add(new Area(circle));
|
||||
}
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fill(copper);
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.draw(copper);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Area body = new Area(getBodyShape());
|
||||
int leadThickness = (int) getLeadThickness();
|
||||
double lip = getLip().convertToPixels();
|
||||
Stroke stroke = ObjectCache.getInstance().fetchBasicStroke(leadThickness / 2);
|
||||
Rectangle rect = body.getBounds();
|
||||
double lip = core == InductorCore.Ferrite ? getLip().convertToPixels() : 0;
|
||||
Rectangle2D rect = body.getBounds2D();
|
||||
|
||||
double h = rect.getHeight() - 2 * lip;
|
||||
double step = h / 19.8;
|
||||
double strokeWidth = step * 0.8;
|
||||
Stroke stroke = ObjectCache.getInstance().fetchBasicStroke((float) strokeWidth);
|
||||
|
||||
Area copper = new Area();
|
||||
for (double y = lip + leadThickness / 2; y < rect.height - lip - leadThickness; y += leadThickness * 0.9d) {
|
||||
double margin;
|
||||
if (y < leadThickness || y > rect.height - leadThickness)
|
||||
margin = -leadThickness / 4;
|
||||
else
|
||||
margin = leadThickness / 4;
|
||||
Line2D line = new Line2D.Double(-margin + lip, y - rect.height / 2, rect.width - lip + margin, y - rect.height / 2);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
double y = lip + 0.4 * step + i * step;
|
||||
double margin = step / 4;
|
||||
double yOffset = rect.getHeight() / 2 + LEAD_THICKNESS.convertToPixels() / 2;
|
||||
Line2D line = new Line2D.Double(-margin + lip, y - yOffset, rect.getWidth() - lip + margin, y - yOffset);
|
||||
Shape s = stroke.createStrokedShape(line);
|
||||
copper.add(new Area(s));
|
||||
}
|
||||
@@ -153,6 +183,45 @@ public class RadialInductor extends AbstractRadialComponent<Inductance> {
|
||||
return super.getLength();
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public InductorCore getCore() {
|
||||
return core;
|
||||
}
|
||||
|
||||
public void setCore(InductorCore core) {
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Inner Diameter")
|
||||
public Size getInnerDiameter() {
|
||||
if (innerDiameter == null) {
|
||||
innerDiameter = new Size(1d / 8, SizeUnit.in);
|
||||
}
|
||||
return innerDiameter;
|
||||
}
|
||||
|
||||
public void setInnerDiameter(Size innerDiameter) {
|
||||
this.innerDiameter = innerDiameter;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
@Override
|
||||
public Color getBodyColor() {
|
||||
if (core == InductorCore.Air) {
|
||||
return Constants.TRANSPARENT_COLOR;
|
||||
}
|
||||
return super.getBodyColor();
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border")
|
||||
@Override
|
||||
public Color getBorderColor() {
|
||||
if (core == InductorCore.Air) {
|
||||
return Constants.TRANSPARENT_COLOR;
|
||||
}
|
||||
return super.getBorderColor();
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public boolean getFolded() {
|
||||
return folded;
|
||||
@@ -178,17 +247,28 @@ public class RadialInductor extends AbstractRadialComponent<Inductance> {
|
||||
protected Shape getBodyShape() {
|
||||
double height = (int) getHeight().convertToPixels();
|
||||
double diameter = (int) getLength().convertToPixels();
|
||||
double lip = getLip().convertToPixels();
|
||||
double lip = core == InductorCore.Ferrite ? getLip().convertToPixels() : 0;
|
||||
if (folded) {
|
||||
Area body = new Area(new RoundRectangle2D.Double(0f, -height / 2 - LEAD_THICKNESS.convertToPixels() / 2,
|
||||
getClosestOdd(diameter), getClosestOdd(height), EDGE_RADIUS.convertToPixels(), EDGE_RADIUS.convertToPixels()));
|
||||
body.subtract(new Area(new Rectangle2D.Double(0f, -height / 2 + lip - LEAD_THICKNESS.convertToPixels() / 2,
|
||||
lip, height - 2 * lip)));
|
||||
body.subtract(new Area(new Rectangle2D.Double(diameter - lip, -height / 2 + lip - LEAD_THICKNESS.convertToPixels() / 2,
|
||||
lip * 2, height - 2 * lip)));
|
||||
if (lip > 0) {
|
||||
body.subtract(new Area(new Rectangle2D.Double(0f, -height / 2 + lip - LEAD_THICKNESS.convertToPixels() / 2,
|
||||
lip, height - 2 * lip)));
|
||||
body.subtract(new Area(new Rectangle2D.Double(diameter - lip, -height / 2 + lip - LEAD_THICKNESS.convertToPixels() / 2,
|
||||
lip * 2, height - 2 * lip)));
|
||||
}
|
||||
return body;
|
||||
}
|
||||
return new Ellipse2D.Double(0f, 0f, getClosestOdd(diameter), getClosestOdd(diameter));
|
||||
Shape outer = new Ellipse2D.Double(0f, 0f, getClosestOdd(diameter), getClosestOdd(diameter));
|
||||
if (core == InductorCore.Air) {
|
||||
double innerDiam = getInnerDiameter().convertToPixels();
|
||||
double od = getClosestOdd(diameter);
|
||||
Shape inner = new Ellipse2D.Double((od - innerDiam) / 2, (od - innerDiam) / 2, innerDiam, innerDiam);
|
||||
Area donut = new Area(outer);
|
||||
donut.subtract(new Area(inner));
|
||||
return donut;
|
||||
}
|
||||
return outer;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
|
||||
Reference in New Issue
Block a user