transformers for to92, dilIC and pot.

This commit is contained in:
bancika
2017-01-09 12:50:43 +01:00
parent 43262cea6a
commit 5daa7c7bc9
16 changed files with 329 additions and 13 deletions
@@ -15,6 +15,11 @@ public class DefaultTransformer implements IComponentTransformer {
public boolean canMirror(IDIYComponent<?> component) {
return false;
}
@Override
public boolean mirroringChangesCircuit() {
return false;
}
@Override
public void rotate(IDIYComponent<?> component, Point center, int direction) {
@@ -15,6 +15,8 @@ public interface IComponentTransformer {
boolean canRotate(IDIYComponent<?> component);
boolean canMirror(IDIYComponent<?> component);
boolean mirroringChangesCircuit();
void rotate(IDIYComponent<?> component, Point center, int direction);
@@ -16,6 +16,11 @@ public class SimpleComponentTransformer implements IComponentTransformer {
public boolean canMirror(IDIYComponent<?> component) {
return true;
}
@Override
public boolean mirroringChangesCircuit() {
return false;
}
@Override
public void rotate(IDIYComponent<?> component, Point center, int direction) {
@@ -1185,6 +1185,7 @@ public class Presenter implements IPlugInPort {
Point center = getCenterOf(components, snapToGrid);
boolean canMirror = true;
boolean changesCircuit = false;
for (IDIYComponent<?> component : components) {
ComponentType type =
ComponentProcessor.getInstance().extractComponentTypeFrom(
@@ -1193,22 +1194,27 @@ public class Presenter implements IPlugInPort {
canMirror = false;
break;
}
if (type.getTransformer() != null && type.getTransformer().mirroringChangesCircuit())
changesCircuit = true;
}
if (!canMirror)
if (view.showConfirmDialog("Selection contains components that cannot be mirrored. Do you want to exclude them?",
"Mirror Selection", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) != IView.YES_OPTION)
return;
if (changesCircuit)
if (view.showConfirmDialog("Mirroring operation will change the circuit. Do you want to continue?",
"Mirror Selection", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) != IView.YES_OPTION)
return;
for (IDIYComponent<?> component : components) {
ComponentType type =
ComponentProcessor.getInstance().extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass());
if (type.isStretchable() || component.getControlPointCount() == 1) {
drawingManager.invalidateComponent(component);
if (type.getTransformer() != null && type.getTransformer().canMirror(component)) {
type.getTransformer().mirror(component, center, direction);
}
drawingManager.invalidateComponent(component);
if (type.getTransformer() != null && type.getTransformer().canMirror(component)) {
type.getTransformer().mirror(component, center, direction);
}
}
}