mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Added support for rotating and mirroring potentiometer symbol and
transistor symbols
This commit is contained in:
@@ -3014,6 +3014,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added support for automated regression testing of core functionalities which should reduce regression bugs in the long run</description>
|
<description>Added support for automated regression testing of core functionalities which should reduce regression bugs in the long run</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Added support for rotating and mirroring potentiometer symbol and transistor symbols</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added mirrored pin display options for "DIL IC"</description>
|
<description>Added mirrored pin display options for "DIL IC"</description>
|
||||||
|
|||||||
Binary file not shown.
@@ -32,13 +32,15 @@ import java.awt.geom.Rectangle2D;
|
|||||||
|
|
||||||
import org.diylc.components.Abstract3LegSymbol;
|
import org.diylc.components.Abstract3LegSymbol;
|
||||||
import org.diylc.components.semiconductors.SymbolFlipping;
|
import org.diylc.components.semiconductors.SymbolFlipping;
|
||||||
|
import org.diylc.components.transform.ThreeLegTransformer;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.KeywordPolicy;
|
import org.diylc.core.annotations.KeywordPolicy;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Potentiometer", author = "MCbx", category = "Schematic Symbols",
|
@ComponentDescriptor(name = "Potentiometer", author = "MCbx", category = "Schematic Symbols",
|
||||||
instanceNamePrefix = "VR", description = "Potentiometer symbol",
|
instanceNamePrefix = "VR", description = "Potentiometer symbol",
|
||||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic")
|
zOrder = IDIYComponent.COMPONENT, transformer = ThreeLegTransformer.class, keywordPolicy = KeywordPolicy.SHOW_TAG,
|
||||||
|
keywordTag = "Schematic")
|
||||||
public class PotentiometerSymbol extends Abstract3LegSymbol {
|
public class PotentiometerSymbol extends Abstract3LegSymbol {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ import java.awt.geom.Area;
|
|||||||
import java.awt.geom.GeneralPath;
|
import java.awt.geom.GeneralPath;
|
||||||
|
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.components.Abstract3LegSymbol;
|
import org.diylc.components.Abstract3LegSymbol;
|
||||||
|
import org.diylc.components.transform.ThreeLegTransformer;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
@@ -38,7 +39,7 @@ import org.diylc.core.annotations.KeywordPolicy;
|
|||||||
|
|
||||||
@ComponentDescriptor(name = "BJT", author = "Branislav Stojkovic", category = "Schematic Symbols",
|
@ComponentDescriptor(name = "BJT", author = "Branislav Stojkovic", category = "Schematic Symbols",
|
||||||
instanceNamePrefix = "Q", description = "Bipolar junction transistor schematic symbol",
|
instanceNamePrefix = "Q", description = "Bipolar junction transistor schematic symbol",
|
||||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
zOrder = IDIYComponent.COMPONENT, transformer = ThreeLegTransformer.class, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
||||||
public class BJTSymbol extends Abstract3LegSymbol {
|
public class BJTSymbol extends Abstract3LegSymbol {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ import java.awt.Shape;
|
|||||||
import java.awt.geom.GeneralPath;
|
import java.awt.geom.GeneralPath;
|
||||||
|
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.components.Abstract3LegSymbol;
|
import org.diylc.components.Abstract3LegSymbol;
|
||||||
|
import org.diylc.components.transform.ThreeLegTransformer;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
@@ -36,7 +37,7 @@ import org.diylc.core.annotations.KeywordPolicy;
|
|||||||
|
|
||||||
@ComponentDescriptor(name = "JFET", author = "Branislav Stojkovic", category = "Schematic Symbols",
|
@ComponentDescriptor(name = "JFET", author = "Branislav Stojkovic", category = "Schematic Symbols",
|
||||||
instanceNamePrefix = "Q", description = "JFET transistor schematic symbol",
|
instanceNamePrefix = "Q", description = "JFET transistor schematic symbol",
|
||||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
zOrder = IDIYComponent.COMPONENT, transformer = ThreeLegTransformer.class, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
||||||
public class JFETSymbol extends Abstract3LegSymbol {
|
public class JFETSymbol extends Abstract3LegSymbol {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ import java.awt.Shape;
|
|||||||
import java.awt.geom.GeneralPath;
|
import java.awt.geom.GeneralPath;
|
||||||
|
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.components.Abstract3LegSymbol;
|
import org.diylc.components.Abstract3LegSymbol;
|
||||||
|
import org.diylc.components.transform.ThreeLegTransformer;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
@@ -36,7 +37,7 @@ import org.diylc.core.annotations.KeywordPolicy;
|
|||||||
|
|
||||||
@ComponentDescriptor(name = "MOSFET", author = "Branislav Stojkovic", category = "Schematic Symbols",
|
@ComponentDescriptor(name = "MOSFET", author = "Branislav Stojkovic", category = "Schematic Symbols",
|
||||||
instanceNamePrefix = "Q", description = "MOSFET transistor schematic symbol",
|
instanceNamePrefix = "Q", description = "MOSFET transistor schematic symbol",
|
||||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
zOrder = IDIYComponent.COMPONENT, transformer = ThreeLegTransformer.class, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
||||||
public class MOSFETSymbol extends Abstract3LegSymbol {
|
public class MOSFETSymbol extends Abstract3LegSymbol {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
DIY Layout Creator (DIYLC).
|
||||||
|
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||||
|
|
||||||
|
This file is part of DIYLC.
|
||||||
|
|
||||||
|
DIYLC is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
DIYLC is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package org.diylc.components.transform;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
|
import org.diylc.common.IComponentTransformer;
|
||||||
|
import org.diylc.common.Orientation;
|
||||||
|
import org.diylc.components.Abstract3LegSymbol;
|
||||||
|
import org.diylc.components.semiconductors.SymbolFlipping;
|
||||||
|
import org.diylc.core.IDIYComponent;
|
||||||
|
|
||||||
|
public class ThreeLegTransformer implements IComponentTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRotate(IDIYComponent<?> component) {
|
||||||
|
return Abstract3LegSymbol.class.isAssignableFrom(component.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMirror(IDIYComponent<?> component) {
|
||||||
|
return Abstract3LegSymbol.class.isAssignableFrom(component.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mirroringChangesCircuit() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rotate(IDIYComponent<?> component, Point center, int direction) {
|
||||||
|
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.x, center.y);
|
||||||
|
for (int index = 0; index < component.getControlPointCount(); index++) {
|
||||||
|
Point p = new Point(component.getControlPoint(index));
|
||||||
|
rotate.transform(p, p);
|
||||||
|
component.setControlPoint(p, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Abstract3LegSymbol a3l = (Abstract3LegSymbol) component;
|
||||||
|
Orientation o = a3l.getOrientation();
|
||||||
|
int oValue = o.ordinal();
|
||||||
|
oValue += direction;
|
||||||
|
if (oValue < 0)
|
||||||
|
oValue = Orientation.values().length - 1;
|
||||||
|
if (oValue >= Orientation.values().length)
|
||||||
|
oValue = 0;
|
||||||
|
o = Orientation.values()[oValue];
|
||||||
|
a3l.setOrientation(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mirror(IDIYComponent<?> component, Point center, int direction) {
|
||||||
|
Abstract3LegSymbol a3l = (Abstract3LegSymbol) component;
|
||||||
|
|
||||||
|
Orientation o = a3l.getOrientation();
|
||||||
|
SymbolFlipping flip = a3l.getFlip();
|
||||||
|
|
||||||
|
if (direction == IComponentTransformer.HORIZONTAL) {
|
||||||
|
if (o == Orientation.DEFAULT || o == Orientation._180) {
|
||||||
|
if (flip == SymbolFlipping.NONE)
|
||||||
|
a3l.setFlip(SymbolFlipping.X);
|
||||||
|
else if (flip == SymbolFlipping.X)
|
||||||
|
a3l.setFlip(SymbolFlipping.NONE);
|
||||||
|
} else if (o == Orientation._90 || o == Orientation._270) {
|
||||||
|
if (flip == SymbolFlipping.NONE)
|
||||||
|
a3l.setFlip(SymbolFlipping.Y);
|
||||||
|
else if (flip == SymbolFlipping.Y)
|
||||||
|
a3l.setFlip(SymbolFlipping.NONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (o == Orientation.DEFAULT || o == Orientation._180) {
|
||||||
|
if (flip == SymbolFlipping.NONE)
|
||||||
|
a3l.setFlip(SymbolFlipping.Y);
|
||||||
|
else if (flip == SymbolFlipping.Y)
|
||||||
|
a3l.setFlip(SymbolFlipping.NONE);
|
||||||
|
} else if (o == Orientation._90 || o == Orientation._270) {
|
||||||
|
if (flip == SymbolFlipping.NONE)
|
||||||
|
a3l.setFlip(SymbolFlipping.X);
|
||||||
|
else if (flip == SymbolFlipping.X)
|
||||||
|
a3l.setFlip(SymbolFlipping.NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user