mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-29 07:50:29 -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
|
* row bits in led matrix
|
||||||
*/
|
*/
|
||||||
public static final Key.KeyBits ROW_DATA_BITS
|
public static final Key.KeyBits ROW_DATA_BITS
|
||||||
= new Key.KeyBits("rowDataBits", 8);;
|
= new Key.KeyBits("rowDataBits", 8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* column address bits in led matrix
|
* column address bits in led matrix
|
||||||
*/
|
*/
|
||||||
public static final Key.KeyBits COL_ADDR_BITS
|
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.WIDTH);
|
||||||
ATTR_LIST.add(Keys.BACKGROUND_COLOR);
|
ATTR_LIST.add(Keys.BACKGROUND_COLOR);
|
||||||
ATTR_LIST.add(Keys.DESCRIPTION);
|
ATTR_LIST.add(Keys.DESCRIPTION);
|
||||||
|
ATTR_LIST.add(Keys.LOCKED_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int version = 1;
|
private int version = 1;
|
||||||
|
@ -133,20 +133,22 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
pasteAction = new AbstractAction(Lang.get("menu_paste")) {
|
pasteAction = new AbstractAction(Lang.get("menu_paste")) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
if (!isLocked()) {
|
||||||
try {
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
Object data = clipboard.getData(DataFlavor.stringFlavor);
|
try {
|
||||||
if (data instanceof String) {
|
Object data = clipboard.getData(DataFlavor.stringFlavor);
|
||||||
Vector posVector = getPosVector(lastMousePos.x, lastMousePos.y);
|
if (data instanceof String) {
|
||||||
ArrayList<Movable> elements = CircuitTransferable.createList(data, shapeFactory, posVector);
|
Vector posVector = getPosVector(lastMousePos.x, lastMousePos.y);
|
||||||
if (elements != null) {
|
ArrayList<Movable> elements = CircuitTransferable.createList(data, shapeFactory, posVector);
|
||||||
removeHighLighted();
|
if (elements != null) {
|
||||||
mouseInsertList.activate(elements, posVector);
|
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();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLocked() {
|
||||||
|
return circuit.getAttributes().get(Keys.LOCKED_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
private class MouseDispatcher extends MouseAdapter implements MouseMotionListener {
|
private class MouseDispatcher extends MouseAdapter implements MouseMotionListener {
|
||||||
private Vector pos;
|
private Vector pos;
|
||||||
private boolean isMoved;
|
private boolean isMoved;
|
||||||
@ -767,17 +773,19 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
Vector pos = getPosVector(e);
|
Vector pos = getPosVector(e);
|
||||||
|
|
||||||
if (e.getButton() == MouseEvent.BUTTON3) {
|
if (e.getButton() == MouseEvent.BUTTON3) {
|
||||||
VisualElement vp = getVisualElement(pos, true);
|
if (!isLocked()) {
|
||||||
if (vp != null)
|
VisualElement vp = getVisualElement(pos, true);
|
||||||
editAttributes(vp, e);
|
if (vp != null)
|
||||||
|
editAttributes(vp, e);
|
||||||
|
}
|
||||||
} else if (e.getButton() == MouseEvent.BUTTON1) {
|
} else if (e.getButton() == MouseEvent.BUTTON1) {
|
||||||
VisualElement vp = getVisualElement(pos, false);
|
VisualElement vp = getVisualElement(pos, false);
|
||||||
if (vp != null) {
|
if (vp != null) {
|
||||||
if (circuit.isPinPos(raster(pos), vp) && !e.isControlDown())
|
if (circuit.isPinPos(raster(pos), vp) && !e.isControlDown()) {
|
||||||
mouseWire.activate(pos);
|
if (!isLocked()) mouseWire.activate(pos);
|
||||||
else
|
} else
|
||||||
mouseMoveElement.activate(vp, pos);
|
mouseMoveElement.activate(vp, pos);
|
||||||
} else {
|
} else if (!isLocked()) {
|
||||||
if (e.isControlDown()) {
|
if (e.isControlDown()) {
|
||||||
Wire wire = circuit.getWireAt(pos, SIZE2);
|
Wire wire = circuit.getWireAt(pos, SIZE2);
|
||||||
if (wire != null)
|
if (wire != null)
|
||||||
@ -845,7 +853,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void clicked(MouseEvent e) {
|
void clicked(MouseEvent e) {
|
||||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
if (e.getButton() == MouseEvent.BUTTON1 && !isLocked()) {
|
||||||
circuit.add(element);
|
circuit.add(element);
|
||||||
hasChanged();
|
hasChanged();
|
||||||
}
|
}
|
||||||
@ -889,16 +897,19 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void clicked(MouseEvent e) {
|
void clicked(MouseEvent e) {
|
||||||
visualElement.setPos(raster(visualElement.getPos()));
|
if (!isLocked())
|
||||||
|
visualElement.setPos(raster(visualElement.getPos()));
|
||||||
mouseNormal.activate();
|
mouseNormal.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void moved(MouseEvent e) {
|
void moved(MouseEvent e) {
|
||||||
Vector pos = getPosVector(e);
|
if (!isLocked()) {
|
||||||
visualElement.setPos(raster(pos.add(delta)));
|
Vector pos = getPosVector(e);
|
||||||
circuit.modified();
|
visualElement.setPos(raster(pos.add(delta)));
|
||||||
hasChanged();
|
circuit.modified();
|
||||||
|
hasChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -908,22 +919,28 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
circuit.delete(visualElement);
|
if (!isLocked()) {
|
||||||
mouseNormal.activate();
|
circuit.delete(visualElement);
|
||||||
isManualScale = true;
|
mouseNormal.activate();
|
||||||
|
isManualScale = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rotate() {
|
public void rotate() {
|
||||||
visualElement.rotate();
|
if (!isLocked()) {
|
||||||
circuit.modified();
|
visualElement.rotate();
|
||||||
hasChanged();
|
circuit.modified();
|
||||||
|
hasChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void escapePressed() {
|
public void escapePressed() {
|
||||||
visualElement.setPos(raster(initialPos));
|
if (!isLocked()) {
|
||||||
visualElement.setRotation(initialRot);
|
visualElement.setPos(raster(initialPos));
|
||||||
|
visualElement.setRotation(initialRot);
|
||||||
|
}
|
||||||
mouseNormal.activate();
|
mouseNormal.activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1075,7 +1092,8 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
@Override
|
@Override
|
||||||
boolean dragged(MouseEvent e) {
|
boolean dragged(MouseEvent e) {
|
||||||
if (wasReleased) {
|
if (wasReleased) {
|
||||||
mouseMoveSelected.activate(corner1, corner2, getPosVector(e));
|
if (!isLocked())
|
||||||
|
mouseMoveSelected.activate(corner1, corner2, getPosVector(e));
|
||||||
} else {
|
} else {
|
||||||
corner2 = getPosVector(e);
|
corner2 = getPosVector(e);
|
||||||
if ((e.getModifiersEx() & CTRL_DOWN_MASK) != 0) {
|
if ((e.getModifiersEx() & CTRL_DOWN_MASK) != 0) {
|
||||||
@ -1118,14 +1136,18 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
circuit.delete(Vector.min(corner1, corner2), Vector.max(corner1, corner2));
|
if (!isLocked()) {
|
||||||
mouseNormal.activate();
|
circuit.delete(Vector.min(corner1, corner2), Vector.max(corner1, corner2));
|
||||||
isManualScale = true;
|
mouseNormal.activate();
|
||||||
|
isManualScale = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotate() {
|
public void rotate() {
|
||||||
mouseMoveSelected.activate(corner1, corner2, lastMousePos);
|
if (!isLocked()) {
|
||||||
mouseMoveSelected.rotate();
|
mouseMoveSelected.activate(corner1, corner2, lastMousePos);
|
||||||
|
mouseMoveSelected.rotate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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_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">Adressbits der Spalten</string>
|
||||||
<string name="key_colAddrBits_tt">Adressiert die einzelnen Spalten. Drei Bits bedeuten also acht 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_Logic">Logisch</string>
|
||||||
<string name="lib_arithmetic">Arithmetik</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_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">Address bits of columns</string>
|
||||||
<string name="key_colAddrBits_tt">Addresses the individual columns. Three bits means eight 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_Logic">Logic</string>
|
||||||
<string name="lib_arithmetic">Arithmetic</string>
|
<string name="lib_arithmetic">Arithmetic</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user