use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class CircuitState method setValueByWire.
void setValueByWire(Location p, Value v) {
// for CircuitWires - to set value at point
boolean changed;
if (v == Value.NIL) {
Object old = values.remove(p);
changed = (old != null && old != Value.NIL);
} else {
Object old = values.put(p, v);
changed = !v.equals(old);
}
if (changed) {
boolean found = false;
for (Component comp : circuit.getComponents(p)) {
if (!(comp instanceof Wire) && !(comp instanceof Splitter)) {
found = true;
markComponentAsDirty(comp);
}
}
if (found && base != null)
base.locationTouched(this, p);
}
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class Circuit method draw.
//
// Graphics methods
//
public void draw(ComponentDrawContext context, Collection<Component> hidden) {
Graphics g = context.getGraphics();
Graphics g_copy = g.create();
context.setGraphics(g_copy);
wires.draw(context, hidden);
if (hidden == null || hidden.size() == 0) {
for (Component c : comps) {
Graphics g_new = g.create();
context.setGraphics(g_new);
g_copy.dispose();
g_copy = g_new;
c.draw(context);
}
} else {
for (Component c : comps) {
if (!hidden.contains(c)) {
Graphics g_new = g.create();
context.setGraphics(g_new);
g_copy.dispose();
g_copy = g_new;
try {
c.draw(context);
} catch (RuntimeException e) {
// this is a JAR developer error - display it and move
// on
e.printStackTrace();
}
}
}
}
context.setGraphics(g);
g_copy.dispose();
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class Circuit method IsExistingLabel.
private static boolean IsExistingLabel(String Name, AttributeSet me, Set<Component> comps, Boolean ShowDialog) {
if (Name.isEmpty())
return false;
for (Component comp : comps) {
if (!comp.getAttributeSet().equals(me) && !(comp.getFactory() instanceof Tunnel)) {
String Label = (comp.getAttributeSet().containsAttribute(StdAttr.LABEL)) ? comp.getAttributeSet().getValue(StdAttr.LABEL) : "";
if (Label.toUpperCase().equals(Name.toUpperCase())) {
if (ShowDialog) {
String msg = com.cburch.logisim.circuit.Strings.get("UsedLabelNameError");
JOptionPane.showMessageDialog(null, "\"" + Name + "\" : " + msg);
}
return true;
}
}
}
/* we do not have to check the wires as (1) Wire is a reserved keyword, and (2) they cannot have a label */
return false;
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class Circuit method ClearAnnotationLevel.
//
// Annotation module for all components that require a non-zero-length label
public void ClearAnnotationLevel() {
Annotated = false;
MyNetList.clear();
for (Component comp : this.getNonWires()) {
if (comp.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory sub = (SubcircuitFactory) comp.getFactory();
sub.getSubcircuit().ClearAnnotationLevel();
}
}
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class CircuitChange method execute.
void execute(CircuitMutator mutator, ReplacementMap prevReplacements) {
switch(type) {
case CLEAR:
mutator.clear(circuit);
prevReplacements.reset();
break;
case ADD:
prevReplacements.add(comp);
break;
case ADD_ALL:
for (Component comp : comps) prevReplacements.add(comp);
break;
case REMOVE:
prevReplacements.remove(comp);
break;
case REMOVE_ALL:
for (Component comp : comps) prevReplacements.remove(comp);
break;
case REPLACE:
prevReplacements.append((ReplacementMap) newValue);
break;
case SET:
mutator.replace(circuit, prevReplacements);
prevReplacements.reset();
mutator.set(circuit, comp, attr, newValue);
break;
case SET_FOR_CIRCUIT:
mutator.replace(circuit, prevReplacements);
prevReplacements.reset();
mutator.setForCircuit(circuit, attr, newValue);
break;
default:
throw new IllegalArgumentException("unknown change type " + type);
}
}
Aggregations