Search in sources :

Example 36 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class ComponentDrawContext method drawPins.

public void drawPins(Component comp) {
    Color curColor = g.getColor();
    for (EndData e : comp.getEnds()) {
        Location pt = e.getLocation();
        if (getShowState()) {
            CircuitState state = getCircuitState();
            g.setColor(state.getValue(pt).getColor());
        } else {
            g.setColor(Color.BLACK);
        }
        g.fillOval(pt.getX() - PIN_OFFS, pt.getY() - PIN_OFFS, PIN_RAD, PIN_RAD);
    }
    g.setColor(curColor);
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) Color(java.awt.Color) Location(com.cburch.logisim.data.Location)

Example 37 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class WireUtil method mergeExclusive.

// Merge all parallel endpoint-to-endpoint wires within the given set.
public static Collection<? extends Component> mergeExclusive(Collection<? extends Component> toMerge) {
    if (toMerge.size() <= 1)
        return toMerge;
    HashSet<Component> ret = new HashSet<Component>(toMerge);
    CircuitPoints points = computeCircuitPoints(toMerge);
    HashSet<Wire> wires = new HashSet<Wire>();
    for (Location loc : points.getSplitLocations()) {
        Collection<? extends Component> at = points.getComponents(loc);
        if (at.size() == 2) {
            Iterator<? extends Component> atIt = at.iterator();
            Component o0 = atIt.next();
            Component o1 = atIt.next();
            if (o0 instanceof Wire && o1 instanceof Wire) {
                Wire w0 = (Wire) o0;
                Wire w1 = (Wire) o1;
                if (w0.is_x_equal == w1.is_x_equal) {
                    wires.add(w0);
                    wires.add(w1);
                }
            }
        }
    }
    points = null;
    ret.removeAll(wires);
    while (!wires.isEmpty()) {
        Iterator<Wire> it = wires.iterator();
        Wire w = it.next();
        Location e0 = w.e0;
        Location e1 = w.e1;
        it.remove();
        boolean found;
        do {
            found = false;
            for (it = wires.iterator(); it.hasNext(); ) {
                Wire cand = it.next();
                if (cand.e0.equals(e1)) {
                    e1 = cand.e1;
                    found = true;
                    it.remove();
                } else if (cand.e1.equals(e0)) {
                    e0 = cand.e0;
                    found = true;
                    it.remove();
                }
            }
        } while (found);
        ret.add(Wire.create(e0, e1));
    }
    return ret;
}
Also used : Component(com.cburch.logisim.comp.Component) HashSet(java.util.HashSet) Location(com.cburch.logisim.data.Location)

Example 38 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class AppearanceAnchor method toSvgElement.

@Override
public Element toSvgElement(Document doc) {
    Location loc = getLocation();
    Element ret = doc.createElement("circ-anchor");
    ret.setAttribute("x", "" + (loc.getX() - RADIUS));
    ret.setAttribute("y", "" + (loc.getY() - RADIUS));
    ret.setAttribute("width", "" + 2 * RADIUS);
    ret.setAttribute("height", "" + 2 * RADIUS);
    ret.setAttribute("facing", facing.toString());
    return ret;
}
Also used : Element(org.w3c.dom.Element) Location(com.cburch.logisim.data.Location)

Example 39 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class AppearanceAnchor method contains.

@Override
public boolean contains(Location loc, boolean assumeFilled) {
    if (super.isInCircle(loc, RADIUS)) {
        return true;
    } else {
        Location center = getLocation();
        Location end = center.translate(facing, RADIUS + INDICATOR_LENGTH);
        if (facing == Direction.EAST || facing == Direction.WEST) {
            return Math.abs(loc.getY() - center.getY()) < 2 && (loc.getX() < center.getX()) != (loc.getX() < end.getX());
        } else {
            return Math.abs(loc.getX() - center.getX()) < 2 && (loc.getY() < center.getY()) != (loc.getY() < end.getY());
        }
    }
}
Also used : Location(com.cburch.logisim.data.Location)

Example 40 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class AppearanceAnchor method getHandles.

@Override
public List<Handle> getHandles(HandleGesture gesture) {
    Location c = getLocation();
    Location end = c.translate(facing, RADIUS + INDICATOR_LENGTH);
    return UnmodifiableList.create(new Handle[] { new Handle(this, c), new Handle(this, end) });
}
Also used : Location(com.cburch.logisim.data.Location) Handle(com.cburch.draw.model.Handle)

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