本文整理汇总了Java中com.cburch.logisim.circuit.CircuitAttributes类的典型用法代码示例。如果您正苦于以下问题:Java CircuitAttributes类的具体用法?Java CircuitAttributes怎么用?Java CircuitAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CircuitAttributes类属于com.cburch.logisim.circuit包,在下文中一共展示了CircuitAttributes类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValueRequested
import com.cburch.logisim.circuit.CircuitAttributes; //导入依赖的package包/类
@Override
public void setValueRequested(Attribute<Object> attr, Object value) {
if (tool instanceof AddTool) {
AddTool mytool = (AddTool) tool;
if (mytool.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory fac = (SubcircuitFactory) mytool.getFactory();
if (attr.equals(CircuitAttributes.NAMED_CIRCUIT_BOX)||
attr.equals(CircuitAttributes.NAME_ATTR)) {
try {
CircuitMutation mutation = new CircuitMutation(fac.getSubcircuit());
mutation.setForCircuit(attr, value);
Action action = mutation.toAction(null);
proj.doAction(action);
} catch (CircuitException ex) {
JOptionPane.showMessageDialog(proj.getFrame(),
ex.getMessage());
}
return;
}
}
}
proj.doAction(ToolAttributeAction.create(tool, attr, value));
}
示例2: attributeValueChanged
import com.cburch.logisim.circuit.CircuitAttributes; //导入依赖的package包/类
@Override
public void attributeValueChanged(AttributeEvent e) {
Object attr = e.getAttribute();
if (attr == CircuitAttributes.CIRCUIT_LABEL_ATTR || attr == StdAttr.LABEL) {
model.fireNodeChanged(this);
}
}
示例3: circuitChanged
import com.cburch.logisim.circuit.CircuitAttributes; //导入依赖的package包/类
public void circuitChanged(CircuitEvent event) {
int act = event.getAction();
if (act == CircuitEvent.ACTION_CHECK_NAME) {
String oldname = (String) event.getData();
String newname = event.getCircuit().getName();
if (NameIsInUse(newname,event.getCircuit())) {
JOptionPane.showMessageDialog(null, "\""+newname+"\": "+Strings.get("circuitNameExists"),
"",JOptionPane.ERROR_MESSAGE);
event.getCircuit().getStaticAttributes().setValue(CircuitAttributes.NAME_ATTR, (String) oldname);;
}
}
}
示例4: attributeValueChanged
import com.cburch.logisim.circuit.CircuitAttributes; //导入依赖的package包/类
public void attributeValueChanged(AttributeEvent e) {
Object attr = e.getAttribute();
if (attr == CircuitAttributes.CIRCUIT_LABEL_ATTR
|| attr == StdAttr.LABEL) {
model.fireNodeChanged(this);
}
}
示例5: setValueRequested
import com.cburch.logisim.circuit.CircuitAttributes; //导入依赖的package包/类
@Override
public void setValueRequested(Attribute<Object> attr, Object value)
throws AttrTableSetException {
Selection selection = frame.getCanvas().getSelection();
Circuit circuit = frame.getCanvas().getCircuit();
if (selection.isEmpty() && circuit != null) {
AttrTableCircuitModel circuitModel = new AttrTableCircuitModel(
project, circuit);
circuitModel.setValueRequested(attr, value);
} else {
SetAttributeAction act = new SetAttributeAction(circuit,
Strings.getter("selectionAttributeAction"));
AutoLabel labler = null;
if (attr.equals(StdAttr.LABEL)) {
labler = new AutoLabel((String)value,circuit);
}
SortedSet<Component> comps = new TreeSet<Component>(new PositionComparator());
comps.addAll(selection.getComponents());
for (Component comp : comps) {
if (!(comp instanceof Wire)) {
if (comp.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory fac = (SubcircuitFactory) comp.getFactory();
if (attr.equals(CircuitAttributes.NAMED_CIRCUIT_BOX)||
attr.equals(CircuitAttributes.NAME_ATTR)) {
try {
CircuitMutation mutation = new CircuitMutation(fac.getSubcircuit());
mutation.setForCircuit(attr, value);
Action action = mutation.toAction(null);
project.doAction(action);
} catch (CircuitException ex) {
JOptionPane.showMessageDialog(project.getFrame(),
ex.getMessage());
}
return;
}
}
if (attr.equals(StdAttr.LABEL)) {
if (labler.hasNext(circuit)) {
if (comps.size()>1) {
act.set(comp, attr , labler.GetNext(circuit, comp.getFactory()));
} else {
if (getAttributeSet().getValue(StdAttr.LABEL).equals((String)value))
return;
else
act.set(comp, attr, labler.GetCurrent(circuit, comp.getFactory()));
}
} else act.set(comp, attr, "");
} else
act.set(comp, attr, value);
}
}
project.doAction(act);
}
}
示例6: IsNamedBoxShaped
import com.cburch.logisim.circuit.CircuitAttributes; //导入依赖的package包/类
public boolean IsNamedBoxShaped() {
return circuit.getStaticAttributes().getValue(CircuitAttributes.NAMED_CIRCUIT_BOX);
}
示例7: ProcessSubcircuit
import com.cburch.logisim.circuit.CircuitAttributes; //导入依赖的package包/类
private boolean ProcessSubcircuit(Component comp, FPGAReport Reporter) {
NetlistComponent Subcircuit = new NetlistComponent(comp);
SubcircuitFactory sub = (SubcircuitFactory) comp.getFactory();
Instance[] subPins = ((CircuitAttributes) comp.getAttributeSet())
.getPinInstances();
Netlist subNetlist = sub.getSubcircuit().getNetList();
for (EndData ThisPin : comp.getEnds()) {
Net Connection = FindConnectedNet(ThisPin.getLocation());
int PinId = comp.getEnds().indexOf(ThisPin);
int SubPortIndex = subNetlist.GetPortInfo(subPins[PinId]
.getAttributeValue(StdAttr.LABEL));
if (SubPortIndex < 0) {
Reporter.AddFatalError("BUG: Unable to find pin in sub-circuit\n ==> "+
this.getClass().getName().replaceAll("\\.","/")+":"+Thread.currentThread().getStackTrace()[2].getLineNumber()+"\n");
return false;
}
if (Connection != null) {
boolean PinIsSink = ThisPin.isInput();
Net RootNet = GetRootNet(Connection);
if (RootNet == null) {
Reporter.AddFatalError("BUG: Unable to find a root net for sub-circuit\n ==> "+
this.getClass().getName().replaceAll("\\.","/")+":"+Thread.currentThread().getStackTrace()[2].getLineNumber()+"\n");
return false;
}
for (byte bitid = 0; bitid < ThisPin.getWidth().getWidth(); bitid++) {
Byte RootNetBitIndex = GetRootNetIndex(Connection, bitid);
if (RootNetBitIndex < 0) {
Reporter.AddFatalError("BUG: Unable to find a root-net bit-index for sub-circuit\n ==> "+
this.getClass().getName().replaceAll("\\.","/")+":"+Thread.currentThread().getStackTrace()[2].getLineNumber()+"\n");
return false;
}
Subcircuit.getEnd(PinId).GetConnection(bitid)
.SetParrentNet(RootNet, RootNetBitIndex);
if (PinIsSink) {
RootNet.addSink(RootNetBitIndex,
Subcircuit.getEnd(PinId).GetConnection(bitid));
} else {
RootNet.addSource(RootNetBitIndex,
Subcircuit.getEnd(PinId).GetConnection(bitid));
}
/*
* Special handling for sub-circuits; we have to find out
* the connection to the corresponding net in the underlying
* net-list; At this point the underlying net-lists have
* already been generated.
*/
Subcircuit.getEnd(PinId).GetConnection(bitid)
.setChildsPortIndex(SubPortIndex);
}
} else {
for (byte bitid = 0; bitid < ThisPin.getWidth().getWidth(); bitid++) {
Subcircuit.getEnd(PinId).GetConnection(bitid)
.setChildsPortIndex(SubPortIndex);
}
}
}
MySubCircuits.add(Subcircuit);
return true;
}
示例8: attributeValueChanged
import com.cburch.logisim.circuit.CircuitAttributes; //导入依赖的package包/类
public void attributeValueChanged(AttributeEvent e) {
Object attr = e.getAttribute();
if (attr == CircuitAttributes.CIRCUIT_LABEL_ATTR || attr == StdAttr.LABEL) {
model.fireNodeChanged(this);
}
}