Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.Wire$EndList


    public void draw(Canvas canvas, ComponentDrawContext context) {
        Graphics g = context.getGraphics();
        if (exists) {
            Location e0 = start;
            Location e1 = cur;
            Wire shortenBefore = willShorten(start, cur);
            if (shortenBefore != null) {
                Wire shorten = getShortenResult(shortenBefore, start, cur);
                if (shorten == null) {
                    return;
                } else {
                    e0 = shorten.getEnd0();
                    e1 = shorten.getEnd1();
                }
            }
            int x0 = e0.getX();
            int y0 = e0.getY();
            int x1 = e1.getX();
View Full Code Here


            rect.grow(3, 3);

            cur = Location.create(curX, curY);
            super.mouseDragged(canvas, g, e);

            Wire shorten = null;
            if (startShortening) {
                for (Wire w : canvas.getCircuit().getWires(start)) {
                    if (w.contains(cur)) {
                        { shorten = w;
                    }
View Full Code Here

            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) {
View Full Code Here

        }
        return w;
    }

    private Wire willShorten(Location drag0, Location drag1) {
        Wire shorten = shortening;
        if (shorten == null) {
            return null;
        } else if (shorten.endsAt(drag0) || shorten.endsAt(drag1)) {
            return shorten;
        } else {
            return null;
        }
    }
View Full Code Here

            return e0.equals(e1) ? null : Wire.create(e0, e1);
        }
    }

    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());
            String actName;
            Wire result = getShortenResult(shorten, drag0, drag1);
            if (result == null) {
                xn.remove(shorten);
                actName = getFromLocale("removeComponentAction", shorten.getFactory().getDisplayGetter());
            } else {
                xn.replace(shorten, result);
View Full Code Here

                }
            }
            if (found) {
                List<Wire> wirePath;
                Location wirePathStart;
                Wire lastOnPath = findWire(circuit, loc, selected, null);
                if (lastOnPath == null) {
                    wirePath = Collections.emptyList();
                    wirePathStart = loc;
                } else {
                    wirePath = new ArrayList<Wire>();
                    Location cur = loc;
                    for (Wire w = lastOnPath; w != null;
                            w = findWire(circuit, cur, selected, w)) {
                        wirePath.add(w);
                        cur = w.getOtherEnd(cur);
                    }
                    Collections.reverse(wirePath);
                    wirePathStart = cur;
                }

                Direction dir = null;
                if (lastOnPath != null) {
                    Location other = lastOnPath.getOtherEnd(loc);
                    int dx = loc.getX() - other.getX();
                    int dy = loc.getY() - other.getY();
                    if (Math.abs(dx) > Math.abs(dy)) {
                        dir = dx > 0 ? Direction.EAST : Direction.WEST;
                    } else {
View Full Code Here

        return conns;
    }

    private static Wire findWire(Circuit circ, Location loc,
            Set<Component> ignore, Wire ignoreW) {
        Wire ret = null;
        for (Component comp : circ.getComponents(loc)) {
            if (!ignore.contains(comp) && comp != ignoreW) {
                if (ret == null && comp instanceof Wire) {
                    ret = (Wire) comp;
                } else {
View Full Code Here

        if (canvas != null && canvas.getSelection() != null) {
            Collection<Component> sel = canvas.getSelection().getComponents();
            if (sel != null) {
                for (Component c : sel) {
                    if (c instanceof Wire) {
                        Wire w = (Wire) c;
                        if (w.contains(loc) && !w.endsAt(loc)) {
                            return select;
                        }

                    }
                }
            }
        }

        Circuit circ = canvas.getCircuit();
        Collection<? extends Component> at = circ.getComponents(loc);
        if (at != null && at.size() > 0) {
            return wiring;
        }


        for (Wire w : circ.getWires()) {
            if (w.contains(loc)) {
                { return wiring;
            }
}
        }
        return select;
View Full Code Here

TOP

Related Classes of com.cburch.logisim.circuit.Wire$EndList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.