mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-26 14:31:02 -04:00
added a locked mode
This commit is contained in:
parent
aaa1409908
commit
f72983ea73
@ -312,12 +312,17 @@ public final class Keys {
|
||||
* row bits in led matrix
|
||||
*/
|
||||
public static final Key.KeyBits ROW_DATA_BITS
|
||||
= new Key.KeyBits("rowDataBits", 8);;
|
||||
= new Key.KeyBits("rowDataBits", 8);
|
||||
|
||||
/**
|
||||
* column address bits in led matrix
|
||||
*/
|
||||
public static final Key.KeyBits COL_ADDR_BITS
|
||||
= new Key.KeyBits("colAddrBits", 3);;
|
||||
= new Key.KeyBits("colAddrBits", 3);
|
||||
|
||||
/**
|
||||
* In locked mode the circuit can not be modified
|
||||
*/
|
||||
public static final Key<Boolean> LOCKED_MODE
|
||||
= new Key<>("lockedMode", false);
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ public class Circuit {
|
||||
ATTR_LIST.add(Keys.WIDTH);
|
||||
ATTR_LIST.add(Keys.BACKGROUND_COLOR);
|
||||
ATTR_LIST.add(Keys.DESCRIPTION);
|
||||
ATTR_LIST.add(Keys.LOCKED_MODE);
|
||||
}
|
||||
|
||||
private int version = 1;
|
||||
|
@ -133,20 +133,22 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
pasteAction = new AbstractAction(Lang.get("menu_paste")) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
try {
|
||||
Object data = clipboard.getData(DataFlavor.stringFlavor);
|
||||
if (data instanceof String) {
|
||||
Vector posVector = getPosVector(lastMousePos.x, lastMousePos.y);
|
||||
ArrayList<Movable> elements = CircuitTransferable.createList(data, shapeFactory, posVector);
|
||||
if (elements != null) {
|
||||
removeHighLighted();
|
||||
mouseInsertList.activate(elements, posVector);
|
||||
if (!isLocked()) {
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
try {
|
||||
Object data = clipboard.getData(DataFlavor.stringFlavor);
|
||||
if (data instanceof String) {
|
||||
Vector posVector = getPosVector(lastMousePos.x, lastMousePos.y);
|
||||
ArrayList<Movable> elements = CircuitTransferable.createList(data, shapeFactory, posVector);
|
||||
if (elements != null) {
|
||||
removeHighLighted();
|
||||
mouseInsertList.activate(elements, posVector);
|
||||
}
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
SwingUtilities.invokeLater(new ErrorMessage(Lang.get("msg_clipboardContainsNoImportableData")).setComponent(CircuitComponent.this));
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
SwingUtilities.invokeLater(new ErrorMessage(Lang.get("msg_clipboardContainsNoImportableData")).setComponent(CircuitComponent.this));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -640,6 +642,10 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
repaint();
|
||||
}
|
||||
|
||||
private boolean isLocked() {
|
||||
return circuit.getAttributes().get(Keys.LOCKED_MODE);
|
||||
}
|
||||
|
||||
private class MouseDispatcher extends MouseAdapter implements MouseMotionListener {
|
||||
private Vector pos;
|
||||
private boolean isMoved;
|
||||
@ -767,17 +773,19 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
Vector pos = getPosVector(e);
|
||||
|
||||
if (e.getButton() == MouseEvent.BUTTON3) {
|
||||
VisualElement vp = getVisualElement(pos, true);
|
||||
if (vp != null)
|
||||
editAttributes(vp, e);
|
||||
if (!isLocked()) {
|
||||
VisualElement vp = getVisualElement(pos, true);
|
||||
if (vp != null)
|
||||
editAttributes(vp, e);
|
||||
}
|
||||
} else if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
VisualElement vp = getVisualElement(pos, false);
|
||||
if (vp != null) {
|
||||
if (circuit.isPinPos(raster(pos), vp) && !e.isControlDown())
|
||||
mouseWire.activate(pos);
|
||||
else
|
||||
if (circuit.isPinPos(raster(pos), vp) && !e.isControlDown()) {
|
||||
if (!isLocked()) mouseWire.activate(pos);
|
||||
} else
|
||||
mouseMoveElement.activate(vp, pos);
|
||||
} else {
|
||||
} else if (!isLocked()) {
|
||||
if (e.isControlDown()) {
|
||||
Wire wire = circuit.getWireAt(pos, SIZE2);
|
||||
if (wire != null)
|
||||
@ -845,7 +853,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
|
||||
@Override
|
||||
void clicked(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1 && !isLocked()) {
|
||||
circuit.add(element);
|
||||
hasChanged();
|
||||
}
|
||||
@ -889,16 +897,19 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
|
||||
@Override
|
||||
void clicked(MouseEvent e) {
|
||||
visualElement.setPos(raster(visualElement.getPos()));
|
||||
if (!isLocked())
|
||||
visualElement.setPos(raster(visualElement.getPos()));
|
||||
mouseNormal.activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
void moved(MouseEvent e) {
|
||||
Vector pos = getPosVector(e);
|
||||
visualElement.setPos(raster(pos.add(delta)));
|
||||
circuit.modified();
|
||||
hasChanged();
|
||||
if (!isLocked()) {
|
||||
Vector pos = getPosVector(e);
|
||||
visualElement.setPos(raster(pos.add(delta)));
|
||||
circuit.modified();
|
||||
hasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -908,22 +919,28 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
circuit.delete(visualElement);
|
||||
mouseNormal.activate();
|
||||
isManualScale = true;
|
||||
if (!isLocked()) {
|
||||
circuit.delete(visualElement);
|
||||
mouseNormal.activate();
|
||||
isManualScale = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotate() {
|
||||
visualElement.rotate();
|
||||
circuit.modified();
|
||||
hasChanged();
|
||||
if (!isLocked()) {
|
||||
visualElement.rotate();
|
||||
circuit.modified();
|
||||
hasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void escapePressed() {
|
||||
visualElement.setPos(raster(initialPos));
|
||||
visualElement.setRotation(initialRot);
|
||||
if (!isLocked()) {
|
||||
visualElement.setPos(raster(initialPos));
|
||||
visualElement.setRotation(initialRot);
|
||||
}
|
||||
mouseNormal.activate();
|
||||
}
|
||||
}
|
||||
@ -1075,7 +1092,8 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
@Override
|
||||
boolean dragged(MouseEvent e) {
|
||||
if (wasReleased) {
|
||||
mouseMoveSelected.activate(corner1, corner2, getPosVector(e));
|
||||
if (!isLocked())
|
||||
mouseMoveSelected.activate(corner1, corner2, getPosVector(e));
|
||||
} else {
|
||||
corner2 = getPosVector(e);
|
||||
if ((e.getModifiersEx() & CTRL_DOWN_MASK) != 0) {
|
||||
@ -1118,14 +1136,18 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
circuit.delete(Vector.min(corner1, corner2), Vector.max(corner1, corner2));
|
||||
mouseNormal.activate();
|
||||
isManualScale = true;
|
||||
if (!isLocked()) {
|
||||
circuit.delete(Vector.min(corner1, corner2), Vector.max(corner1, corner2));
|
||||
mouseNormal.activate();
|
||||
isManualScale = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void rotate() {
|
||||
mouseMoveSelected.activate(corner1, corner2, lastMousePos);
|
||||
mouseMoveSelected.rotate();
|
||||
if (!isLocked()) {
|
||||
mouseMoveSelected.activate(corner1, corner2, lastMousePos);
|
||||
mouseMoveSelected.rotate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -590,6 +590,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="key_rowDataBits_tt">Gibt direkt die Zahl der Zeilen an, indem die Anzahl der Bits des Zeilenwortes festgegelgt wird.</string>
|
||||
<string name="key_colAddrBits">Adressbits der Spalten</string>
|
||||
<string name="key_colAddrBits_tt">Adressiert die einzelnen Spalten. Drei Bits bedeuten also acht Spalten.</string>
|
||||
<string name="key_lockedMode">Bearbeitung gesperrt</string>
|
||||
<string name="key_lockedMode_tt">Die Schaltung ist für die Bearbeitung gesperrt. Dioden und FG-FETs können jedoch konfiguriert werden.</string>
|
||||
|
||||
<string name="lib_Logic">Logisch</string>
|
||||
<string name="lib_arithmetic">Arithmetik</string>
|
||||
|
@ -580,6 +580,8 @@ The names of the variables may not be unique.</string>
|
||||
<string name="key_rowDataBits_tt">Specifies the number of rows by specifying the number of bits of the row word.</string>
|
||||
<string name="key_colAddrBits">Address bits of columns</string>
|
||||
<string name="key_colAddrBits_tt">Addresses the individual columns. Three bits means eight columns.</string>
|
||||
<string name="key_lockedMode">Modification locked</string>
|
||||
<string name="key_lockedMode_tt">The circuit is locked. It is possible to configure diodes and FGF-FETs.</string>
|
||||
|
||||
<string name="lib_Logic">Logic</string>
|
||||
<string name="lib_arithmetic">Arithmetic</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user