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


Java Project.setTool方法代码示例

本文整理汇总了Java中com.cburch.logisim.proj.Project.setTool方法的典型用法代码示例。如果您正苦于以下问题:Java Project.setTool方法的具体用法?Java Project.setTool怎么用?Java Project.setTool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cburch.logisim.proj.Project的用法示例。


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

示例1: selectSelectTool

import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
private void selectSelectTool(Project proj) {
	for (Library sub : proj.getLogisimFile().getLibraries()) {
		if (sub instanceof Base) {
			Base base = (Base) sub;
			Tool tool = base.getTool("Edit Tool");
			if (tool != null)
				proj.setTool(tool);
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:11,代码来源:LayoutEditHandler.java

示例2: keyPressed

import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void keyPressed(Canvas canvas, KeyEvent event) {
	processKeyEvent(canvas, event, KeyConfigurationEvent.KEY_PRESSED);

	if (!event.isConsumed() && event.getModifiersEx() == 0) {
		switch (event.getKeyCode()) {
		case KeyEvent.VK_UP:
			setFacing(canvas, Direction.NORTH);
			break;
		case KeyEvent.VK_DOWN:
			setFacing(canvas, Direction.SOUTH);
			break;
		case KeyEvent.VK_LEFT:
			setFacing(canvas, Direction.WEST);
			break;
		case KeyEvent.VK_RIGHT:
			setFacing(canvas, Direction.EAST);
			break;
		case KeyEvent.VK_BACK_SPACE:
			if (lastAddition != null && canvas.getProject().getLastAction() == lastAddition) {
				canvas.getProject().undoAction();
				lastAddition = null;
			}
			break;
		case KeyEvent.VK_DELETE:
		case KeyEvent.VK_ESCAPE:
			if (state == SHOW_GHOST) {
				Project proj = canvas.getProject();
				Tool next = determineNext(proj);
				if (next != null) {
					proj.setTool(next);
					Action act = SelectionActions.dropAll(canvas.getSelection());
					if (act != null) {
						proj.doAction(act);
					}
				}
			}
			break;
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:42,代码来源:AddTool.java

示例3: mouseReleased

import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void mouseReleased(Canvas canvas, Graphics g, MouseEvent e) {
	Component added = null;
	if (state == SHOW_ADD) {
		Circuit circ = canvas.getCircuit();
		if (!canvas.getProject().getLogisimFile().contains(circ))
			return;
		if (shouldSnap)
			Canvas.snapToGrid(e);
		moveTo(canvas, g, e.getX(), e.getY());

		Location loc = Location.create(e.getX(), e.getY());
		AttributeSet attrsCopy = (AttributeSet) attrs.clone();
		ComponentFactory source = getFactory();
		if (source == null)
			return;
		Component c = source.createComponent(loc, attrsCopy);

		if (circ.hasConflict(c)) {
			canvas.setErrorMessage(Strings.getter("exclusiveError"));
			return;
		}

		Bounds bds = c.getBounds(g);
		if (bds.getX() < 0 || bds.getY() < 0) {
			canvas.setErrorMessage(Strings.getter("negativeCoordError"));
			return;
		}

		try {
			CircuitMutation mutation = new CircuitMutation(circ);
			mutation.add(c);
			Action action = mutation.toAction(Strings.getter("addComponentAction", factory.getDisplayGetter()));
			canvas.getProject().doAction(action);
			lastAddition = action;
			added = c;
		} catch (CircuitException ex) {
			JOptionPane.showMessageDialog(canvas.getProject().getFrame(), ex.getMessage());
		}
		setState(canvas, SHOW_GHOST);
	} else if (state == SHOW_ADD_NO) {
		setState(canvas, SHOW_NONE);
	}

	Project proj = canvas.getProject();
	Tool next = determineNext(proj);
	if (next != null) {
		proj.setTool(next);
		Action act = SelectionActions.dropAll(canvas.getSelection());
		if (act != null) {
			proj.doAction(act);
		}
		if (added != null)
			canvas.getSelection().add(added);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:57,代码来源:AddTool.java


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