use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.
the class Subtractor method paintInstance.
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
painter.drawBounds();
g.setColor(Color.GRAY);
painter.drawPort(IN0);
painter.drawPort(IN1);
painter.drawPort(OUT);
painter.drawPort(B_IN, "b in", Direction.NORTH);
painter.drawPort(B_OUT, "b out", Direction.SOUTH);
Location loc = painter.getLocation();
int x = loc.getX();
int y = loc.getY();
GraphicsUtil.switchToWidth(g, 2);
g.setColor(Color.BLACK);
g.drawLine(x - 15, y, x - 5, y);
GraphicsUtil.switchToWidth(g, 1);
}
use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.
the class Text method paintInstance.
@Override
public void paintInstance(InstancePainter painter) {
Location loc = painter.getLocation();
int x = loc.getX();
int y = loc.getY();
Graphics g = painter.getGraphics();
g.translate(x, y);
g.setColor(Color.BLACK);
paintGhost(painter);
g.translate(-x, -y);
}
use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.
the class Poly method getRandomPoint.
@Override
public final Location getRandomPoint(Bounds bds, Random rand) {
if (getPaintType() == DrawAttr.PAINT_STROKE) {
Location ret = getRandomBoundaryPoint(bds, rand);
int w = getStrokeWidth();
if (w > 1) {
int dx = rand.nextInt(w) - w / 2;
int dy = rand.nextInt(w) - w / 2;
ret = ret.translate(dx, dy);
}
return ret;
} else {
return super.getRandomPoint(bds, rand);
}
}
use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.
the class Poly method getHandles.
@Override
public List<Handle> getHandles(HandleGesture gesture) {
Handle[] hs = handles;
if (gesture == null) {
return UnmodifiableList.create(hs);
} else {
Handle g = gesture.getHandle();
Handle[] ret = new Handle[hs.length];
for (int i = 0, n = hs.length; i < n; i++) {
Handle h = hs[i];
if (h.equals(g)) {
int x = h.getX() + gesture.getDeltaX();
int y = h.getY() + gesture.getDeltaY();
Location r;
if (gesture.isShiftDown()) {
Location prev = hs[(i + n - 1) % n].getLocation();
Location next = hs[(i + 1) % n].getLocation();
if (!closed) {
if (i == 0)
prev = null;
if (i == n - 1)
next = null;
}
if (prev == null) {
r = LineUtil.snapTo8Cardinals(next, x, y);
} else if (next == null) {
r = LineUtil.snapTo8Cardinals(prev, x, y);
} else {
Location to = Location.create(x, y);
Location a = LineUtil.snapTo8Cardinals(prev, x, y);
Location b = LineUtil.snapTo8Cardinals(next, x, y);
int ad = a.manhattanDistanceTo(to);
int bd = b.manhattanDistanceTo(to);
r = ad < bd ? a : b;
}
} else {
r = Location.create(x, y);
}
ret[i] = new Handle(this, r);
} else {
ret[i] = h;
}
}
return UnmodifiableList.create(ret);
}
}
use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.
the class SvgCreator method createCurve.
public static Element createCurve(Document doc, Curve curve) {
Element elt = doc.createElement("path");
Location e0 = curve.getEnd0();
Location e1 = curve.getEnd1();
Location ct = curve.getControl();
elt.setAttribute("d", "M" + e0.getX() + "," + e0.getY() + " Q" + ct.getX() + "," + ct.getY() + " " + e1.getX() + "," + e1.getY());
populateFill(elt, curve);
return elt;
}
Aggregations