use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.
the class CircuitHDLGeneratorFactory method GetComponentDeclarationSection.
@Override
public ArrayList<String> GetComponentDeclarationSection(Netlist TheNetlist, AttributeSet attrs) {
ArrayList<String> Components = new ArrayList<String>();
Set<String> InstantiatedComponents = new HashSet<String>();
for (NetlistComponent Gate : TheNetlist.GetNormalComponents()) {
String CompName = Gate.GetComponent().getFactory().getHDLName(Gate.GetComponent().getAttributeSet());
if (!InstantiatedComponents.contains(CompName)) {
InstantiatedComponents.add(CompName);
HDLGeneratorFactory Worker = Gate.GetComponent().getFactory().getHDLGenerator(VHDL, Gate.GetComponent().getAttributeSet());
if (Worker != null) {
if (!Worker.IsOnlyInlined(VHDL)) {
Components.addAll(Worker.GetComponentInstantiation(TheNetlist, Gate.GetComponent().getAttributeSet(), CompName, VHDL));
}
}
}
}
InstantiatedComponents.clear();
for (NetlistComponent Gate : TheNetlist.GetSubCircuits()) {
String CompName = Gate.GetComponent().getFactory().getHDLName(Gate.GetComponent().getAttributeSet());
if (!InstantiatedComponents.contains(CompName)) {
InstantiatedComponents.add(CompName);
HDLGeneratorFactory Worker = Gate.GetComponent().getFactory().getHDLGenerator(VHDL, Gate.GetComponent().getAttributeSet());
SubcircuitFactory sub = (SubcircuitFactory) Gate.GetComponent().getFactory();
if (Worker != null) {
Components.addAll(Worker.GetComponentInstantiation(sub.getSubcircuit().getNetList(), Gate.GetComponent().getAttributeSet(), CompName, VHDL));
}
}
}
return Components;
}
use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.
the class ToolboxManip method doubleClicked.
public void doubleClicked(ProjectExplorerEvent event) {
Object clicked = event.getTarget();
if (clicked instanceof ProjectExplorerToolNode) {
Tool baseTool = ((ProjectExplorerToolNode) clicked).getValue();
if (baseTool instanceof AddTool) {
AddTool tool = (AddTool) baseTool;
ComponentFactory source = tool.getFactory();
if (source instanceof SubcircuitFactory) {
SubcircuitFactory circFact = (SubcircuitFactory) source;
proj.setCurrentCircuit(circFact.getSubcircuit());
proj.getFrame().setEditorView(Frame.EDIT_LAYOUT);
if (lastSelected != null) {
proj.setTool(lastSelected);
} else {
Library base = proj.getLogisimFile().getLibrary("Base");
if (base != null)
proj.setTool(base.getTool("Edit Tool"));
}
}
}
}
}
use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.
the class SimulationTreeCircuitNode method computeChildren.
// returns true if changed
private boolean computeChildren() {
ArrayList<TreeNode> newChildren = new ArrayList<TreeNode>();
ArrayList<Component> subcircs = new ArrayList<Component>();
for (Component comp : circuitState.getCircuit().getNonWires()) {
if (comp.getFactory() instanceof SubcircuitFactory) {
subcircs.add(comp);
} else {
TreeNode toAdd = model.mapComponentToNode(comp);
if (toAdd != null) {
newChildren.add(toAdd);
}
}
}
Collections.sort(newChildren, new CompareByName());
Collections.sort(subcircs, this);
for (Component comp : subcircs) {
SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
CircuitState state = factory.getSubstate(circuitState, comp);
SimulationTreeCircuitNode toAdd = null;
for (TreeNode o : children) {
if (o instanceof SimulationTreeCircuitNode) {
SimulationTreeCircuitNode n = (SimulationTreeCircuitNode) o;
if (n.circuitState == state) {
toAdd = n;
break;
}
}
}
if (toAdd == null) {
toAdd = new SimulationTreeCircuitNode(model, this, state, comp);
}
newChildren.add(toAdd);
}
if (!children.equals(newChildren)) {
children = newChildren;
return true;
} else {
return false;
}
}
use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.
the class Dependencies method processCircuit.
private void processCircuit(Circuit circ) {
circ.addCircuitListener(myListener);
for (Component comp : circ.getNonWires()) {
if (comp.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
depends.addEdge(circ, factory.getSubcircuit());
}
}
}
use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.
the class ToolboxManip method selectionChanged.
public void selectionChanged(ProjectExplorerEvent event) {
Object selected = event.getTarget();
if (selected instanceof ProjectExplorerToolNode) {
Tool tool = ((ProjectExplorerToolNode) selected).getValue();
if (selected instanceof AddTool) {
AddTool addTool = (AddTool) tool;
ComponentFactory source = addTool.getFactory();
if (source instanceof SubcircuitFactory) {
SubcircuitFactory circFact = (SubcircuitFactory) source;
Circuit circ = circFact.getSubcircuit();
if (proj.getCurrentCircuit() == circ) {
AttrTableModel m = new AttrTableCircuitModel(proj, circ);
proj.getFrame().setAttrTableModel(m);
return;
}
}
}
// This was causing the selection to lag behind double-clicks,
// commented-out
// lastSelected = proj.getTool();
proj.setTool(tool);
proj.getFrame().viewAttributes(tool);
}
}
Aggregations