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);
}
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;
}
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;
}
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());
}
}
}
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) });
}
Aggregations