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


Java Project.getSelection方法代码示例

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


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

示例1: computeDxDy

import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
private void computeDxDy(Project proj, MouseEvent e, Graphics g) {
	Bounds bds = proj.getSelection().getBounds(g);
	int dx;
	int dy;
	if (bds == Bounds.EMPTY_BOUNDS) {
		dx = e.getX() - start.getX();
		dy = e.getY() - start.getY();
	} else {
		dx = Math.max(e.getX() - start.getX(), -bds.getX());
		dy = Math.max(e.getY() - start.getY(), -bds.getY());
	}

	Selection sel = proj.getSelection();
	if (sel.shouldSnap()) {
		dx = Canvas.snapXToGrid(dx);
		dy = Canvas.snapYToGrid(dy);
	}
	curDx = dx;
	curDy = dy;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:21,代码来源:SelectTool.java

示例2: computeEnabled

import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void computeEnabled() {
	Project proj = frame.getProject();
	Selection sel = proj == null ? null : proj.getSelection();
	boolean selEmpty = (sel == null ? true : sel.isEmpty());
	boolean canChange = proj != null && proj.getLogisimFile().contains(proj.getCurrentCircuit());

	boolean selectAvailable = false;
	for (Library lib : proj.getLogisimFile().getLibraries()) {
		if (lib instanceof Base)
			selectAvailable = true;
	}

	setEnabled(LogisimMenuBar.CUT, !selEmpty && selectAvailable && canChange);
	setEnabled(LogisimMenuBar.COPY, !selEmpty && selectAvailable);
	setEnabled(LogisimMenuBar.PASTE, selectAvailable && canChange && !Clipboard.isEmpty());
	setEnabled(LogisimMenuBar.DELETE, !selEmpty && selectAvailable && canChange);
	setEnabled(LogisimMenuBar.DUPLICATE, !selEmpty && selectAvailable && canChange);
	setEnabled(LogisimMenuBar.SELECT_ALL, selectAvailable);
	setEnabled(LogisimMenuBar.RAISE, false);
	setEnabled(LogisimMenuBar.LOWER, false);
	setEnabled(LogisimMenuBar.RAISE_TOP, false);
	setEnabled(LogisimMenuBar.LOWER_BOTTOM, false);
	setEnabled(LogisimMenuBar.ADD_CONTROL, false);
	setEnabled(LogisimMenuBar.REMOVE_CONTROL, false);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:27,代码来源:LayoutEditHandler.java

示例3: drawWithUserState

import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
private void drawWithUserState(Graphics base, Graphics g, Project proj) {
	Circuit circ = proj.getCurrentCircuit();
	Selection sel = proj.getSelection();
	Set<Component> hidden;
	Tool dragTool = canvas.getDragTool();
	if (dragTool == null) {
		hidden = NO_COMPONENTS;
	} else {
		hidden = dragTool.getHiddenComponents(canvas);
		if (hidden == null)
			hidden = NO_COMPONENTS;
	}

	// draw halo around component whose attributes we are viewing
	boolean showHalo = AppPreferences.ATTRIBUTE_HALO.getBoolean();
	if (showHalo && haloedComponent != null && haloedCircuit == circ && !hidden.contains(haloedComponent)) {
		GraphicsUtil.switchToWidth(g, 3);
		g.setColor(Canvas.HALO_COLOR);
		Bounds bds = haloedComponent.getBounds(g).expand(5);
		int w = bds.getWidth();
		int h = bds.getHeight();
		double a = Canvas.SQRT_2 * w;
		double b = Canvas.SQRT_2 * h;
		g.drawOval((int) Math.round(bds.getX() + w / 2.0 - a / 2.0),
				(int) Math.round(bds.getY() + h / 2.0 - b / 2.0), (int) Math.round(a), (int) Math.round(b));
		GraphicsUtil.switchToWidth(g, 1);
		g.setColor(Color.BLACK);
	}

	// draw circuit and selection
	CircuitState circState = proj.getCircuitState();
	boolean printerView = AppPreferences.PRINTER_VIEW.getBoolean();
	ComponentDrawContext context = new ComponentDrawContext(canvas, circ, circState, base, g, printerView);
	context.setHighlightedWires(highlightedWires);
	circ.draw(context, hidden);
	sel.draw(context, hidden);

	// draw tool
	Tool tool = dragTool != null ? dragTool : proj.getTool();
	if (tool != null && !canvas.isPopupMenuUp()) {
		Graphics gCopy = g.create();
		context.setGraphics(gCopy);
		tool.draw(canvas, context);
		gCopy.dispose();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:47,代码来源:CanvasPainter.java


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