add isPolarized to component interface

This commit is contained in:
Bane Stojkovic
2025-05-18 21:38:04 +02:00
parent 8895909452
commit 5456f2819b
18 changed files with 94 additions and 0 deletions
@@ -199,4 +199,13 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
* @param project
*/
void createdIn(Project project);
/**
* Returns whether this component is polarized (direction matters for electronic function).
* Default implementation returns true, components that are not polarized should override this.
* @return true if the component is polarized, false otherwise
*/
default boolean isPolarized() {
return true;
}
}
@@ -350,4 +350,9 @@ public class FuseHolderPanel extends AbstractMultiPartComponent<String> {
Rectangle2D bounds = getBody()[0].getBounds2D();
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -155,4 +155,9 @@ public class AirCoreInductor extends AbstractLeadedComponent<Inductance> {
public void setResistance(Resistance resistance) {
this.resistance = resistance;
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -280,4 +280,9 @@ public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacita
return new Color((int) r, (int) g, (int) b, (int) a);
}
@Override
public boolean isPolarized() {
return polarized;
}
}
@@ -104,4 +104,9 @@ public class AxialFilmCapacitor extends AbstractFilmCapacitor implements IDatash
public boolean getFlipStanding() {
return super.getFlipStanding();
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -96,6 +96,11 @@ public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance>
this.polarized = polarized;
}
@Override
public boolean isPolarized() {
return polarized;
}
public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
g2d.setColor(LEAD_COLOR);
@@ -133,4 +133,9 @@ public class CrystalOscillator extends AbstractLeadedComponent<Frequency> implem
protected Size getDefaultWidth() {
return DEFAULT_WIDTH;
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -109,4 +109,9 @@ public class FuseSymbol extends AbstractSchematicLeadedSymbol<Current> {
protected boolean useShapeRectAsPosition() {
return false;
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -151,4 +151,9 @@ public class InductorSymbol extends AbstractSchematicLeadedSymbol<Inductance> {
public void setCore(boolean core) {
this.core = core;
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -116,4 +116,9 @@ public class RadialCeramicDiskCapacitor extends AbstractRadialComponent<Capacita
protected Shape getBodyShape() {
return new Ellipse2D.Double(0f, 0f, getLength().convertToPixels(), getClosestOdd(getWidth().convertToPixels()));
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -323,4 +323,9 @@ public class RadialElectrolytic extends AbstractRadialComponent<Capacitance> imp
}
return new Ellipse2D.Double(0f, 0f, getClosestOdd(diameter), getClosestOdd(diameter));
}
@Override
public boolean isPolarized() {
return polarized;
}
}
@@ -151,4 +151,9 @@ public class RadialFilmCapacitor extends AbstractFilmCapacitor implements IDatas
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -219,4 +219,9 @@ public class RadialInductor extends AbstractRadialComponent<Inductance> {
public void setLip(Size lip) {
this.lip = lip;
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -147,4 +147,9 @@ public class RadialMicaCapacitor extends AbstractRadialComponent<Capacitance> im
a.add(new Area(new Ellipse2D.Double(length - width, 0, width, width)));
return a;
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -221,6 +221,11 @@ public class Resistor extends AbstractLeadedComponent<Resistance> implements IGe
return super.getFlipStanding();
}
@Override
public boolean isPolarized() {
return false;
}
public enum ResistorShape {
Tubular, Tubular_Beveled, Standard;
@@ -160,6 +160,11 @@ public class ResistorSymbol extends AbstractSchematicLeadedSymbol<Resistance> {
public enum DrawStyle {
ANSI, IEC
}
@Override
public boolean isPolarized() {
return false;
}
}
@@ -244,4 +244,9 @@ public class TantalumCapacitor extends AbstractRadialComponent<Capacitance> {
}
return new Ellipse2D.Double(0f, 0f, getClosestOdd(diameter), getClosestOdd(diameter));
}
@Override
public boolean isPolarized() {
return true;
}
}
@@ -165,4 +165,9 @@ public class ToroidalInductor extends AbstractLeadedComponent<Inductance> implem
public void setResistance(Resistance resistance) {
this.resistance = resistance;
}
@Override
public boolean isPolarized() {
return false;
}
}