Fix the issue with tube symbol mirroring

This commit is contained in:
bancika
2020-04-04 13:33:08 +02:00
parent 99212d2b9c
commit 8cbdae162e
5 changed files with 33 additions and 49 deletions
@@ -2856,11 +2856,15 @@
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Fix the issue with theme configuration that causes the app to fail to start and some components to fail to render</description>
<description>Choosing a default theme in the Config menut causes the app to fail to start and some components to fail to render</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Fix the issue tube socket pins that can be dragged independently from the socket</description>
<description>Fixed the issue with tube symbol mirroring</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Fixed tube socket pins that can be dragged independently from the socket</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
Binary file not shown.
@@ -25,7 +25,8 @@ import java.awt.Point;
import java.awt.geom.AffineTransform;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.Orientation;
import org.diylc.common.Orientation;
import org.diylc.components.semiconductors.SymbolFlipping;
import org.diylc.components.tube.AbstractTubeSymbol;
import org.diylc.core.IDIYComponent;
@@ -70,55 +71,34 @@ public class TubeSymbolTransformer implements IComponentTransformer {
@Override
public void mirror(IDIYComponent<?> component, Point center, int direction) {
AbstractTubeSymbol tube = (AbstractTubeSymbol) component;
Orientation o = tube.getOrientation();
SymbolFlipping flip = tube.getFlip();
if (direction == IComponentTransformer.HORIZONTAL) {
int dx = 2 * (center.x - tube.getControlPoint(0).x);
int dy = 0;
Orientation o = tube.getOrientation();
switch (o) {
case DEFAULT:
o = Orientation._180;
break;
case _90:
break;
case _180:
o = Orientation.DEFAULT;
break;
case _270:
break;
}
for (int i = 0; i < tube.getControlPointCount(); i++) {
Point p = tube.getControlPoint(i);
tube.setControlPoint(new Point(p.x + dx, p.y + dy), i);
}
tube.setOrientation(o);
if (o == Orientation.DEFAULT || o == Orientation._180) {
if (flip == SymbolFlipping.NONE)
tube.setFlip(SymbolFlipping.X);
else if (flip == SymbolFlipping.X)
tube.setFlip(SymbolFlipping.NONE);
} else if (o == Orientation._90 || o == Orientation._270) {
if (flip == SymbolFlipping.NONE)
tube.setFlip(SymbolFlipping.Y);
else if (flip == SymbolFlipping.Y)
tube.setFlip(SymbolFlipping.NONE);
}
} else {
int dx = 0;
int dy = 2 * (center.y - tube.getControlPoint(0).y);
Orientation o = tube.getOrientation();
switch (o) {
case DEFAULT:
break;
case _90:
o = Orientation._270;
break;
case _180:
break;
case _270:
o = Orientation._90;
break;
if (o == Orientation.DEFAULT || o == Orientation._180) {
if (flip == SymbolFlipping.NONE)
tube.setFlip(SymbolFlipping.Y);
else if (flip == SymbolFlipping.Y)
tube.setFlip(SymbolFlipping.NONE);
} else if (o == Orientation._90 || o == Orientation._270) {
if (flip == SymbolFlipping.NONE)
tube.setFlip(SymbolFlipping.X);
else if (flip == SymbolFlipping.X)
tube.setFlip(SymbolFlipping.NONE);
}
for (int i = 0; i < tube.getControlPointCount(); i++) {
Point p = tube.getControlPoint(i);
tube.setControlPoint(new Point(p.x + dx, p.y + dy), i);
}
tube.setOrientation(o);
}
}
}
Binary file not shown.
Binary file not shown.