当前位置: 首页>>代码示例>>Java>>正文


Java SubcircuitFactory类代码示例

本文整理汇总了Java中com.cburch.logisim.circuit.SubcircuitFactory的典型用法代码示例。如果您正苦于以下问题:Java SubcircuitFactory类的具体用法?Java SubcircuitFactory怎么用?Java SubcircuitFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SubcircuitFactory类属于com.cburch.logisim.circuit包,在下文中一共展示了SubcircuitFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: libraryChanged

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void libraryChanged(LibraryEvent event) {
	int action = event.getAction();
	if (action == LibraryEvent.REMOVE_LIBRARY) {
		Library unloaded = (Library) event.getData();
		if (tool != null && unloaded.containsFromSource(tool)) {
			setTool(null);
		}
	} else if (action == LibraryEvent.REMOVE_TOOL) {
		Object data = event.getData();
		if (data instanceof AddTool) {
			Object factory = ((AddTool) data).getFactory();
			if (factory instanceof SubcircuitFactory) {
				SubcircuitFactory fact = (SubcircuitFactory) factory;
				if (fact.getSubcircuit() == getCurrentCircuit()) {
					setCurrentCircuit(file.getMainCircuit());
				}
			}
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:Project.java

示例2: getTotal

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
private static Count getTotal(List<Count> counts, Set<Circuit> exclude) {
	Count ret = new Count(null);
	for (Count count : counts) {
		ComponentFactory factory = count.getFactory();
		Circuit factoryCirc = null;
		if (factory instanceof SubcircuitFactory) {
			factoryCirc = ((SubcircuitFactory) factory).getSubcircuit();
		}
		if (exclude == null || !exclude.contains(factoryCirc)) {
			ret.simpleCount += count.simpleCount;
			ret.uniqueCount += count.uniqueCount;
			ret.recursiveCount += count.recursiveCount;
		}
	}
	return ret;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:17,代码来源:FileStatistics.java

示例3: removeCircuit

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public void removeCircuit(Circuit circuit) {
	if (tools.size() <= 1) {
		throw new RuntimeException("Cannot remove last circuit");
	}

	int index = getCircuits().indexOf(circuit);
	if (index >= 0) {
		Tool circuitTool = tools.remove(index);

		if (main == circuit) {
			AddTool dflt_tool = tools.get(0);
			SubcircuitFactory factory = (SubcircuitFactory) dflt_tool.getFactory();
			setMainCircuit(factory.getSubcircuit());
		}
		fireEvent(LibraryEvent.REMOVE_TOOL, circuitTool);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:LogisimFile.java

示例4: mousePressed

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
	// verify the addition would be valid
	Circuit circ = canvas.getCircuit();
	if (!canvas.getProject().getLogisimFile().contains(circ)) {
		canvas.setErrorMessage(Strings.getter("cannotModifyError"));
		return;
	}
	if (factory instanceof SubcircuitFactory) {
		SubcircuitFactory circFact = (SubcircuitFactory) factory;
		Dependencies depends = canvas.getProject().getDependencies();
		if (!depends.canAdd(circ, circFact.getSubcircuit())) {
			canvas.setErrorMessage(Strings.getter("circularError"));
			return;
		}
	}

	if (shouldSnap)
		Canvas.snapToGrid(e);
	moveTo(canvas, g, e.getX(), e.getY());
	setState(canvas, SHOW_ADD);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:AddTool.java

示例5: findComponentFactory

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
private static ComponentFactory findComponentFactory(ComponentFactory factory, ArrayList<Library> libs,
		boolean acceptNameMatch) {
	String name = factory.getName();
	for (Library lib : libs) {
		for (Tool tool : lib.getTools()) {
			if (tool instanceof AddTool) {
				AddTool addTool = (AddTool) tool;
				if (name.equals(addTool.getName())) {
					ComponentFactory fact = addTool.getFactory(true);
					if (acceptNameMatch) {
						return fact;
					} else if (fact == factory) {
						return fact;
					} else if (fact.getClass() == factory.getClass() && !(fact instanceof SubcircuitFactory)) {
						return fact;
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:SelectionActions.java

示例6: doubleClicked

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void doubleClicked(ProjectExplorer.Event event) {
	Object clicked = event.getTarget();
	if (clicked instanceof AddTool) {
		AddTool tool = (AddTool) clicked;
		ComponentFactory source = tool.getFactory();
		if (source instanceof SubcircuitFactory) {
			SubcircuitFactory circFact = (SubcircuitFactory) source;
			proj.setCurrentCircuit(circFact.getSubcircuit());
			proj.getFrame().setEditorView(Frame.EDIT_LAYOUT);
			proj.getFrame().getCanvas().autoZoomCenter();
			if (lastSelected != null)
				proj.setTool(lastSelected);
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:17,代码来源:ToolboxManip.java

示例7: menuRequested

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public JPopupMenu menuRequested(ProjectExplorer.Event event) {
	Object clicked = event.getTarget();
	if (clicked instanceof AddTool) {
		AddTool tool = (AddTool) clicked;
		ComponentFactory source = tool.getFactory();
		if (source instanceof SubcircuitFactory) {
			Circuit circ = ((SubcircuitFactory) source).getSubcircuit();
			return Popups.forCircuit(proj, tool, circ);
		} else {
			return null;
		}
	} else if (clicked instanceof Tool) {
		return null;
	} else if (clicked == proj.getLogisimFile()) {
		return Popups.forProject(proj);
	} else if (clicked instanceof Library) {
		boolean is_top = event.getTreePath().getPathCount() <= 2;
		return Popups.forLibrary(proj, (Library) clicked, is_top);
	} else {
		return null;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:24,代码来源:ToolboxManip.java

示例8: selectionChanged

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void selectionChanged(ProjectExplorer.Event event) {
	Object selected = event.getTarget();
	if (selected instanceof Tool) {
		if (selected instanceof AddTool) {
			AddTool addTool = (AddTool) selected;
			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;
				}
			}
		}

		lastSelected = proj.getTool();
		Tool tool = (Tool) selected;
		proj.setTool(tool);
		proj.getFrame().viewAttributes(tool);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:25,代码来源:ToolboxManip.java

示例9: SelectionItem

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public SelectionItem(Model model, Component[] path, Component comp, Object option) {
	this.model = model;
	this.path = path;
	this.comp = comp;
	this.option = option;
	computeDescriptors();

	if (path != null) {
		model.getCircuitState().getCircuit().addCircuitListener(this);
		for (int i = 0; i < path.length; i++) {
			path[i].getAttributeSet().addAttributeListener(this);
			SubcircuitFactory circFact = (SubcircuitFactory) path[i].getFactory();
			circFact.getSubcircuit().addCircuitListener(this);
		}
	}
	comp.getAttributeSet().addAttributeListener(this);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:SelectionItem.java

示例10: libraryChanged

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public void libraryChanged(LibraryEvent event) {
	int action = event.getAction();
	if (action == LibraryEvent.REMOVE_LIBRARY) {
		Library unloaded = (Library) event.getData();
		if (tool != null && unloaded.containsFromSource(tool)) {
			setTool(null);
		}
	} else if (action == LibraryEvent.REMOVE_TOOL) {
		Object data = event.getData();
		if (data instanceof AddTool) {
			Object factory = ((AddTool) data).getFactory();
			if (factory instanceof SubcircuitFactory) {
				SubcircuitFactory fact = (SubcircuitFactory) factory;
				if (fact.getSubcircuit() == getCurrentCircuit()) {
					setCurrentCircuit(file.getMainCircuit());
				}
			}
		}
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:21,代码来源:Project.java

示例11: removeCircuit

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public void removeCircuit(Circuit circuit) {
	if (tools.size() <= 1) {
		throw new RuntimeException("Cannot remove last circuit");
	}

	int index = getCircuits().indexOf(circuit);
	if (index >= 0) {
		Tool circuitTool = tools.remove(index);

		if (main == circuit) {
			AddTool dflt_tool = tools.get(0);
			SubcircuitFactory factory = (SubcircuitFactory) dflt_tool
					.getFactory();
			setMainCircuit(factory.getSubcircuit());
		}
		fireEvent(LibraryEvent.REMOVE_TOOL, circuitTool);
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:19,代码来源:LogisimFile.java

示例12: setValueRequested

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的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));
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:24,代码来源:AttrTableToolModel.java

示例13: findComponentFactory

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
private static ComponentFactory findComponentFactory(
		ComponentFactory factory, ArrayList<Library> libs,
		boolean acceptNameMatch) {
	String name = factory.getName();
	for (Library lib : libs) {
		for (Tool tool : lib.getTools()) {
			if (tool instanceof AddTool) {
				AddTool addTool = (AddTool) tool;
				if (name.equals(addTool.getName())) {
					ComponentFactory fact = addTool.getFactory(true);
					if (acceptNameMatch) {
						return fact;
					} else if (fact == factory) {
						return fact;
					} else if (fact.getClass() == factory.getClass()
							&& !(fact instanceof SubcircuitFactory)) {
						return fact;
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:25,代码来源:SelectionActions.java

示例14: deleteRequested

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public void deleteRequested(ProjectExplorerEvent event) {
	Object request = event.getTarget();
	if (request instanceof ProjectExplorerLibraryNode) {
		Library lib = ((ProjectExplorerLibraryNode) request).getValue();
		ProjectLibraryActions.doUnloadLibrary(proj, lib);
	} else if (request instanceof ProjectExplorerToolNode) {
		Tool tool = ((ProjectExplorerToolNode) request).getValue();
		if (tool instanceof AddTool) {
			ComponentFactory factory = ((AddTool) tool).getFactory();
			if (factory instanceof SubcircuitFactory) {
				SubcircuitFactory circFact = (SubcircuitFactory) factory;
				ProjectCircuitActions.doRemoveCircuit(proj,
						circFact.getSubcircuit());
			}
		}
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:18,代码来源:ToolboxManip.java

示例15: doubleClicked

import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
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"));
				}
			}
		}
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:23,代码来源:ToolboxManip.java


注:本文中的com.cburch.logisim.circuit.SubcircuitFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。