use of de.neemann.digital.draw.graphics.Transform in project Digital by hneemann.
the class ModifyMoveSelected method rotateElements.
/**
* Rotates the given elements
*
* @param elements the elements to rotate
* @param center the center position
*/
public static void rotateElements(ArrayList<Movable> elements, Vector center) {
Transform transform = new TransformRotate(center, 1) {
@Override
public Vector transform(Vector v) {
return super.transform(v.sub(center));
}
@Override
public VectorFloat transform(VectorFloat v) {
return super.transform(v.sub(center));
}
};
for (Movable m : elements) {
if (m instanceof VisualElement) {
VisualElement ve = (VisualElement) m;
ve.rotate();
ve.setPos(transform.transform(ve.getPos()));
} else if (m instanceof Wire) {
Wire w = (Wire) m;
w.p1 = transform.transform(w.p1);
w.p2 = transform.transform(w.p2);
} else {
Vector p = m.getPos();
Vector t = transform.transform(p);
m.move(t.sub(p));
}
}
}
Aggregations