use of com.cburch.logisim.util.StringGetter in project logisim-evolution by reds-heig.
the class WiringTool method performShortening.
private boolean performShortening(Canvas canvas, Location drag0, Location drag1) {
Wire shorten = willShorten(drag0, drag1);
if (shorten == null) {
return false;
} else {
CircuitMutation xn = new CircuitMutation(canvas.getCircuit());
StringGetter actName;
Wire result = getShortenResult(shorten, drag0, drag1);
if (result == null) {
xn.remove(shorten);
actName = Strings.getter("removeComponentAction", shorten.getFactory().getDisplayGetter());
} else {
xn.replace(shorten, result);
actName = Strings.getter("shortenWireAction");
}
canvas.getProject().doAction(xn.toAction(actName));
return true;
}
}
use of com.cburch.logisim.util.StringGetter in project logisim-evolution by reds-heig.
the class InstanceComponent method getToolTip.
public String getToolTip(ComponentUserEvent e) {
int x = e.getX();
int y = e.getY();
int i = -1;
for (EndData end : endArray) {
i++;
if (end.getLocation().manhattanDistanceTo(x, y) < 10) {
Port p = portList.get(i);
return p.getToolTip();
}
}
StringGetter defaultTip = factory.getDefaultToolTip();
return defaultTip == null ? null : defaultTip.toString();
}
use of com.cburch.logisim.util.StringGetter in project logisim-evolution by reds-heig.
the class WiringTool method mouseReleased.
@Override
public void mouseReleased(Canvas canvas, Graphics g, MouseEvent e) {
if (!exists)
return;
Canvas.snapToGrid(e);
int curX = e.getX();
int curY = e.getY();
if (computeMove(curX, curY)) {
cur = Location.create(curX, curY);
}
if (hasDragged) {
exists = false;
super.mouseReleased(canvas, g, e);
ArrayList<Wire> ws = new ArrayList<Wire>(2);
if (cur.getY() == start.getY() || cur.getX() == start.getX()) {
Wire w = Wire.create(cur, start);
w = checkForRepairs(canvas, w, w.getEnd0());
w = checkForRepairs(canvas, w, w.getEnd1());
if (performShortening(canvas, start, cur)) {
return;
}
if (w.getLength() > 0)
ws.add(w);
} else {
Location m;
if (direction == HORIZONTAL) {
m = Location.create(cur.getX(), start.getY());
} else {
m = Location.create(start.getX(), cur.getY());
}
Wire w0 = Wire.create(start, m);
Wire w1 = Wire.create(m, cur);
w0 = checkForRepairs(canvas, w0, start);
w1 = checkForRepairs(canvas, w1, cur);
if (w0.getLength() > 0)
ws.add(w0);
if (w1.getLength() > 0)
ws.add(w1);
}
if (ws.size() > 0) {
CircuitMutation mutation = new CircuitMutation(canvas.getCircuit());
mutation.addAll(ws);
StringGetter desc;
if (ws.size() == 1)
desc = Strings.getter("addWireAction");
else
desc = Strings.getter("addWiresAction");
Action act = mutation.toAction(desc);
canvas.getProject().doAction(act);
lastAction = act;
}
}
}
Aggregations