use of de.neemann.digital.draw.elements.Movable in project Digital by hneemann.
the class ModifySetBits method modify.
@Override
public void modify(Circuit circuit, ElementLibrary library) {
ArrayList<Movable> list = circuit.getElementsToMove(min, max);
for (Movable m : list) if (m instanceof VisualElement) {
VisualElement ve = (VisualElement) m;
try {
ElementTypeDescription td = library.getElementType(ve.getElementName());
if (td != null) {
if (td.getAttributeList().contains(Keys.BITS))
ve.setAttribute(Keys.BITS, bits);
}
} catch (ElementNotFoundException e) {
e.printStackTrace();
}
}
circuit.modified();
}
use of de.neemann.digital.draw.elements.Movable 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