mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-15 15:58:41 -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;
|
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() {
|
public void modified() {
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
@ -216,10 +216,15 @@ public class CircuitComponent extends JComponent {
|
|||||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||||
if (wire != null) {
|
if (wire != null) {
|
||||||
circuit.add(wire);
|
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);
|
||||||
}
|
}
|
||||||
Vector startPos = raster(getPosVector(e));
|
|
||||||
wire = new Wire(startPos, startPos);
|
|
||||||
repaint();
|
repaint();
|
||||||
} else {
|
} else {
|
||||||
if (wire != null) {
|
if (wire != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user