mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-26 14:31:02 -04:00
modifies data bit only if necessary.
This commit is contained in:
parent
67b3538ea7
commit
4dadff6e62
@ -1022,7 +1022,9 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
int bits = Integer.decode(num);
|
||||
Vector c1 = mouseControllerSelect.corner1;
|
||||
Vector c2 = mouseControllerSelect.corner2;
|
||||
modify(new ModifySetBits(c1, c2, bits));
|
||||
ModifySetBits modifySetBits = new ModifySetBits(c1, c2, bits);
|
||||
if (modifySetBits.isSomethingToDo(circuit, library))
|
||||
modify(modifySetBits);
|
||||
removeHighLighted();
|
||||
mouseNormal.activate();
|
||||
} catch (NumberFormatException ex) {
|
||||
|
@ -54,6 +54,32 @@ public class ModifySetBits implements Modification {
|
||||
circuit.modified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are relevant elements in the rectangle
|
||||
*
|
||||
* @param circuit the circuit
|
||||
* @param library the library
|
||||
* @return true if there are components with a bits attribute
|
||||
*/
|
||||
public boolean isSomethingToDo(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))
|
||||
if (ve.getElementAttributes().get(Keys.BITS) != bits)
|
||||
return true;
|
||||
}
|
||||
} catch (ElementNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Lang.get("mod_set_N_BitsToSelection", bits);
|
||||
|
Loading…
x
Reference in New Issue
Block a user