mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-15 07:48:29 -04:00
better wiring mouse listener, wire ends if connected to a pin
This commit is contained in:
parent
5b11532520
commit
2a2f037421
@ -212,6 +212,18 @@ public class Circuit implements Drawable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isPinPos(Vector pos) {
|
||||
VisualElement el = getElementAt(pos);
|
||||
if (el == null) return false;
|
||||
|
||||
for (Pin p : el.getPins())
|
||||
if (p.getPos().equals(pos))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void modified() {
|
||||
modified = true;
|
||||
}
|
||||
|
@ -216,10 +216,15 @@ public class CircuitComponent extends JComponent {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
if (wire != null) {
|
||||
circuit.add(wire);
|
||||
repaint();
|
||||
}
|
||||
Vector startPos = raster(getPosVector(e));
|
||||
if (circuit.isPinPos(startPos))
|
||||
wire = null;
|
||||
else
|
||||
wire = new Wire(startPos, startPos);
|
||||
} else {
|
||||
Vector startPos = raster(getPosVector(e));
|
||||
wire = new Wire(startPos, startPos);
|
||||
}
|
||||
repaint();
|
||||
} else {
|
||||
if (wire != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user