projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Made wires with logicWidth!=1 thicker
[Mograsim.git]
/
net.mograsim.logic.model
/
src
/
net
/
mograsim
/
logic
/
model
/
model
/
wires
/
GUIWire.java
diff --git
a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java
b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java
index
f59355c
..
c564571
100644
(file)
--- a/
net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java
+++ b/
net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java
@@
-18,6
+18,7
@@
import net.mograsim.logic.core.wires.Wire.ReadEnd;
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.preferences.ColorDefinition;
import net.mograsim.preferences.ColorManager;
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.preferences.ColorDefinition;
import net.mograsim.preferences.ColorManager;
+import net.mograsim.preferences.Preferences;
/**
* A wire connecting exactly two {@link Pin}s.
/**
* A wire connecting exactly two {@link Pin}s.
@@
-61,7
+62,6
@@
public class GUIWire
*/
private double[] effectivePath;
*/
private double[] effectivePath;
- private final List<Runnable> redrawListeners;
private final List<Consumer<GUIWire>> pathChangedListeners;
/**
private final List<Consumer<GUIWire>> pathChangedListeners;
/**
@@
-244,28
+244,27
@@
public class GUIWire
this.path = path == null ? null : Arrays.copyOf(path, path.length);
this.bounds = new Rectangle(0, 0, -1, -1);
this.path = path == null ? null : Arrays.copyOf(path, path.length);
this.bounds = new Rectangle(0, 0, -1, -1);
- redrawListeners = new ArrayList<>();
pathChangedListeners = new ArrayList<>();
pathChangedListeners = new ArrayList<>();
- logicObs = (i) ->
callRedrawListeners
();
+ logicObs = (i) ->
model.requestRedraw
();
pin1.addPinMovedListener(p -> pinMoved());
pin2.addPinMovedListener(p -> pinMoved());
recalculateEffectivePath();
pin1.addPinMovedListener(p -> pinMoved());
pin2.addPinMovedListener(p -> pinMoved());
recalculateEffectivePath();
- model.wireCreated(this);
+ model.wireCreated(this
, this::destroyed
);
}
/**
}
/**
- * Destroys this wire. This method i
mplicitly calls {@link ViewModelModifiable#wireDestroyed(GUIWire) wireDestroyed()} for the model
- *
this component
is a part of.
+ * Destroys this wire. This method i
s called from {@link ViewModelModifiable#wireDestroyed(GUIWire) wireDestroyed()} of the model this
+ *
wire
is a part of.
*
* @author Daniel Kirschten
*/
*
* @author Daniel Kirschten
*/
- p
ublic void destroy
()
+ p
rivate void destroyed
()
{
{
- model.wireDestroyed(this);
+ // nothing to do
}
// pins
}
// pins
@@
-298,7
+297,7
@@
public class GUIWire
private void pinMoved()
{
recalculateEffectivePath();
private void pinMoved()
{
recalculateEffectivePath();
-
callRedrawListeners
();
+
model.requestRedraw
();
}
// "graphical" operations
}
// "graphical" operations
@@
-369,7
+368,12
@@
public class GUIWire
ColorDefinition wireColor = BitVectorFormatter.formatAsColor(end);
if (wireColor != null)
gc.setForeground(ColorManager.current().toColor(wireColor));
ColorDefinition wireColor = BitVectorFormatter.formatAsColor(end);
if (wireColor != null)
gc.setForeground(ColorManager.current().toColor(wireColor));
+ if (logicWidth == 1)
+ gc.setLineWidth(Preferences.current().getDouble("net.mograsim.logic.model.linewidth.wire.singlebit"));
+ else
+ gc.setLineWidth(Preferences.current().getDouble("net.mograsim.logic.model.linewidth.wire.multibit"));
gc.drawPolyline(effectivePath);
gc.drawPolyline(effectivePath);
+ gc.setLineWidth(Preferences.current().getDouble("net.mograsim.logic.model.linewidth.default"));
}
// operations concerning the path
}
// operations concerning the path
@@
-392,7
+396,7
@@
public class GUIWire
this.path = deepPathCopy(path);
recalculateEffectivePath();
callPathChangedListeners();
this.path = deepPathCopy(path);
recalculateEffectivePath();
callPathChangedListeners();
-
callRedrawListeners
();
+
model.requestRedraw
();
}
public Point getPathPoint(int index)
}
public Point getPathPoint(int index)
@@
-405,7
+409,7
@@
public class GUIWire
path[index] = pointCopy(p);
recalculateEffectivePath();
callPathChangedListeners();
path[index] = pointCopy(p);
recalculateEffectivePath();
callPathChangedListeners();
-
callRedrawListeners
();
+
model.requestRedraw
();
}
public void insertPathPoint(Point p, int index)
}
public void insertPathPoint(Point p, int index)
@@
-421,6
+425,8
@@
public class GUIWire
System.arraycopy(oldPath, index, path, index + 1, oldPath.length - index);
path[index] = pointCopy(p);
}
System.arraycopy(oldPath, index, path, index + 1, oldPath.length - index);
path[index] = pointCopy(p);
}
+ recalculateEffectivePath();
+ callPathChangedListeners();
}
public void removePathPoint(int index)
}
public void removePathPoint(int index)
@@
-435,6
+441,8
@@
public class GUIWire
if (index < oldPath.length - 1)
System.arraycopy(oldPath, index + 1, path, index, oldPath.length - index - 1);
}
if (index < oldPath.length - 1)
System.arraycopy(oldPath, index + 1, path, index, oldPath.length - index - 1);
}
+ recalculateEffectivePath();
+ callPathChangedListeners();
}
public double[] getEffectivePath()
}
public double[] getEffectivePath()
@@
-510,13
+518,10
@@
public class GUIWire
// listeners
// @formatter:off
// listeners
// @formatter:off
- public void addRedrawListener (Runnable listener) {redrawListeners .add (listener);}
public void addPathChangedListener (Consumer<GUIWire> listener) {pathChangedListeners.add (listener);}
public void addPathChangedListener (Consumer<GUIWire> listener) {pathChangedListeners.add (listener);}
- public void removeRedrawListener (Runnable listener) {redrawListeners .remove(listener);}
public void removePathChangedListener(Consumer<GUIWire> listener) {pathChangedListeners.remove(listener);}
public void removePathChangedListener(Consumer<GUIWire> listener) {pathChangedListeners.remove(listener);}
- private void callRedrawListeners () {redrawListeners .forEach(l -> l.run ( ));}
private void callPathChangedListeners() {pathChangedListeners.forEach(l -> l.accept(this));}
// @formatter:on
private void callPathChangedListeners() {pathChangedListeners.forEach(l -> l.accept(this));}
// @formatter:on