Search in sources :

Example 76 with Location

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);
}
Also used : Graphics(java.awt.Graphics) Location(com.cburch.logisim.data.Location)

Example 77 with Location

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);
}
Also used : Graphics(java.awt.Graphics) Location(com.cburch.logisim.data.Location)

Example 78 with Location

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);
    }
}
Also used : Location(com.cburch.logisim.data.Location)

Example 79 with Location

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);
    }
}
Also used : Handle(com.cburch.draw.model.Handle) Location(com.cburch.logisim.data.Location)

Example 80 with Location

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;
}
Also used : Element(org.w3c.dom.Element) Location(com.cburch.logisim.data.Location)

Aggregations

Location (com.cburch.logisim.data.Location)169 Direction (com.cburch.logisim.data.Direction)39 Graphics (java.awt.Graphics)35 Component (com.cburch.logisim.comp.Component)26 Bounds (com.cburch.logisim.data.Bounds)24 ArrayList (java.util.ArrayList)23 CanvasObject (com.cburch.draw.model.CanvasObject)17 BitWidth (com.cburch.logisim.data.BitWidth)16 Wire (com.cburch.logisim.circuit.Wire)13 HashMap (java.util.HashMap)10 Handle (com.cburch.draw.model.Handle)9 AttributeSet (com.cburch.logisim.data.AttributeSet)9 Value (com.cburch.logisim.data.Value)9 Instance (com.cburch.logisim.instance.Instance)9 Port (com.cburch.logisim.instance.Port)9 Color (java.awt.Color)9 Graphics2D (java.awt.Graphics2D)9 HashSet (java.util.HashSet)9 Circuit (com.cburch.logisim.circuit.Circuit)8 EndData (com.cburch.logisim.comp.EndData)7