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


Java Selection类代码示例

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


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

示例1: cancelMousePress

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void cancelMousePress(Canvas canvas) {
	List<CanvasObject> before = beforePressSelection;
	Handle handle = beforePressHandle;
	beforePressSelection = null;
	beforePressHandle = null;
	if (before != null) {
		curAction = IDLE;
		Selection sel = canvas.getSelection();
		sel.clearDrawsSuppressed();
		sel.setMovingShapes(Collections.<CanvasObject>emptySet(), 0, 0);
		sel.clearSelected();
		sel.setSelected(before, true);
		sel.setHandleSelected(handle);
		repaintArea(canvas);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:SelectTool.java

示例2: keyTyped

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void keyTyped(Canvas canvas, KeyEvent e) {
	char ch = e.getKeyChar();
	Selection selected = canvas.getSelection();
	if ((ch == '\u0008' || ch == '\u007F') && !selected.isEmpty()) {
		ArrayList<CanvasObject> toRemove = new ArrayList<CanvasObject>();
		for (CanvasObject shape : selected.getSelected()) {
			if (shape.canRemove()) {
				toRemove.add(shape);
			}
		}
		if (!toRemove.isEmpty()) {
			e.consume();
			CanvasModel model = canvas.getModel();
			canvas.doAction(new ModelRemoveAction(model, toRemove));
			selected.clearSelected();
			repaintArea(canvas);
		}
	} else if (ch == '\u001b' && !selected.isEmpty()) {
		selected.clearSelected();
		repaintArea(canvas);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:24,代码来源:SelectTool.java

示例3: delete

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void delete() {
	Selection sel = canvas.getSelection();
	int n = sel.getSelected().size();
	List<CanvasObject> select = new ArrayList<CanvasObject>(n);
	List<CanvasObject> remove = new ArrayList<CanvasObject>(n);
	Location anchorLocation = null;
	Direction anchorFacing = null;
	for (CanvasObject o : sel.getSelected()) {
		if (o.canRemove()) {
			remove.add(o);
		} else {
			select.add(o);
			if (o instanceof AppearanceAnchor) {
				AppearanceAnchor anchor = (AppearanceAnchor) o;
				anchorLocation = anchor.getLocation();
				anchorFacing = anchor.getFacing();
			}
		}
	}

	if (!remove.isEmpty()) {
		canvas.getProject().doAction(new SelectionAction(canvas, Strings.getter("deleteSelectionAction"), remove,
				null, select, anchorLocation, anchorFacing));
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:27,代码来源:AppearanceEditHandler.java

示例4: duplicate

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void duplicate() {
	Selection sel = canvas.getSelection();
	int n = sel.getSelected().size();
	List<CanvasObject> select = new ArrayList<CanvasObject>(n);
	List<CanvasObject> clones = new ArrayList<CanvasObject>(n);
	for (CanvasObject o : sel.getSelected()) {
		if (o.canRemove()) {
			CanvasObject copy = o.clone();
			copy.translate(10, 10);
			clones.add(copy);
			select.add(copy);
		} else {
			select.add(o);
		}
	}

	if (!clones.isEmpty()) {
		canvas.getProject().doAction(new SelectionAction(canvas, Strings.getter("duplicateSelectionAction"), null,
				clones, select, null, null));
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:AppearanceEditHandler.java

示例5: doIt

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void doIt(Project proj) {
	Selection sel = canvas.getSelection();
	sel.clearSelected();
	if (toRemove != null)
		canvasModel.removeObjects(toRemove.keySet());
	int dest = AppearanceCanvas.getMaxIndex(canvasModel) + 1;
	if (toAdd != null)
		canvasModel.addObjects(dest, toAdd);

	AppearanceAnchor anchor = findAnchor(canvasModel);
	if (anchor != null && anchorNewLocation != null) {
		anchorOldLocation = anchor.getLocation();
		anchor.translate(anchorNewLocation.getX() - anchorOldLocation.getX(),
				anchorNewLocation.getY() - anchorOldLocation.getY());
	}
	if (anchor != null && anchorNewFacing != null) {
		anchorOldFacing = anchor.getFacing();
		anchor.setValue(AppearanceAnchor.FACING, anchorNewFacing);
	}
	sel.setSelected(newSelection, true);
	canvas.repaint();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:24,代码来源:SelectionAction.java

示例6: undo

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void undo(Project proj) {
	AppearanceAnchor anchor = findAnchor(canvasModel);
	if (anchor != null && anchorOldLocation != null) {
		anchor.translate(anchorOldLocation.getX() - anchorNewLocation.getX(),
				anchorOldLocation.getY() - anchorNewLocation.getY());
	}
	if (anchor != null && anchorOldFacing != null) {
		anchor.setValue(AppearanceAnchor.FACING, anchorOldFacing);
	}
	Selection sel = canvas.getSelection();
	sel.clearSelected();
	if (toAdd != null)
		canvasModel.removeObjects(toAdd);
	if (toRemove != null)
		canvasModel.addObjects(toRemove);
	sel.setSelected(oldSelection, true);
	canvas.repaint();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:SelectionAction.java

示例7: cancelMousePress

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void cancelMousePress(Canvas canvas) {
	List<CanvasObject> before = beforePressSelection;
	Handle handle = beforePressHandle;
	beforePressSelection = null;
	beforePressHandle = null;
	if (before != null) {
		curAction = IDLE;
		Selection sel = canvas.getSelection();
		sel.clearDrawsSuppressed();
		sel.setMovingShapes(Collections.<CanvasObject> emptySet(), 0, 0);
		sel.clearSelected();
		sel.setSelected(before, true);
		sel.setHandleSelected(handle);
		repaintArea(canvas);
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:18,代码来源:SelectTool.java

示例8: duplicate

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void duplicate() {
	Selection sel = canvas.getSelection();
	int n = sel.getSelected().size();
	List<CanvasObject> select = new ArrayList<CanvasObject>(n);
	List<CanvasObject> clones = new ArrayList<CanvasObject>(n);
	for (CanvasObject o : sel.getSelected()) {
		if (o.canRemove()) {
			CanvasObject copy = o.clone();
			copy.translate(10, 10);
			clones.add(copy);
			select.add(copy);
		} else {
			select.add(o);
		}
	}

	if (!clones.isEmpty()) {
		canvas.getProject().doAction(
				new SelectionAction(canvas, Strings
						.getter("duplicateSelectionAction"), null, clones,
						select, null, null));
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:25,代码来源:AppearanceEditHandler.java

示例9: doIt

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void doIt(Project proj) {
	Selection sel = canvas.getSelection();
	sel.clearSelected();
	if (toRemove != null)
		canvasModel.removeObjects(toRemove.keySet());
	int dest = AppearanceCanvas.getMaxIndex(canvasModel) + 1;
	if (toAdd != null)
		canvasModel.addObjects(dest, toAdd);

	AppearanceAnchor anchor = findAnchor(canvasModel);
	if (anchor != null && anchorNewLocation != null) {
		anchorOldLocation = anchor.getLocation();
		anchor.translate(
				anchorNewLocation.getX() - anchorOldLocation.getX(),
				anchorNewLocation.getY() - anchorOldLocation.getY());
	}
	if (anchor != null && anchorNewFacing != null) {
		anchorOldFacing = anchor.getFacing();
		anchor.setValue(AppearanceAnchor.FACING, anchorNewFacing);
	}
	sel.setSelected(newSelection, true);
	canvas.repaint();
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:25,代码来源:SelectionAction.java

示例10: undo

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void undo(Project proj) {
	AppearanceAnchor anchor = findAnchor(canvasModel);
	if (anchor != null && anchorOldLocation != null) {
		anchor.translate(
				anchorOldLocation.getX() - anchorNewLocation.getX(),
				anchorOldLocation.getY() - anchorNewLocation.getY());
	}
	if (anchor != null && anchorOldFacing != null) {
		anchor.setValue(AppearanceAnchor.FACING, anchorOldFacing);
	}
	Selection sel = canvas.getSelection();
	sel.clearSelected();
	if (toAdd != null)
		canvasModel.removeObjects(toAdd);
	if (toRemove != null)
		canvasModel.addObjects(toRemove);
	sel.setSelected(oldSelection, true);
	canvas.repaint();
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:21,代码来源:SelectionAction.java

示例11: duplicate

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void duplicate() {
	Selection sel = canvas.getSelection();
	int n = sel.getSelected().size();
	List<CanvasObject> select = new ArrayList<CanvasObject>(n);
	List<CanvasObject> clones = new ArrayList<CanvasObject>(n);
	for (CanvasObject o : sel.getSelected()) {
		if (o.canRemove()) {
			CanvasObject copy = o.clone();
			copy.translate(10, 10);
			clones.add(copy);
			select.add(copy);
		} else {
			select.add(o);
		}
	}
	
	if (!clones.isEmpty()) {
		canvas.getProject().doAction(new SelectionAction(canvas,
			Strings.getter("duplicateSelectionAction"), null, clones, select,
			null, null));
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:24,代码来源:AppearanceEditHandler.java

示例12: doIt

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void doIt(Project proj) {
	Selection sel = canvas.getSelection();
	sel.clearSelected();
	if (toRemove != null) canvasModel.removeObjects(toRemove.keySet());
	int dest = AppearanceCanvas.getMaxIndex(canvasModel) + 1;
	if (toAdd != null) canvasModel.addObjects(dest, toAdd);

	AppearanceAnchor anchor = findAnchor(canvasModel);
	if (anchor != null && anchorNewLocation != null) {
		anchorOldLocation = anchor.getLocation();
		anchor.translate(anchorNewLocation.getX() - anchorOldLocation.getX(),
				anchorNewLocation.getY() - anchorOldLocation.getY());
	}
	if (anchor != null && anchorNewFacing != null) {
		anchorOldFacing = anchor.getFacing();
		anchor.setValue(AppearanceAnchor.FACING, anchorNewFacing);
	}
	sel.setSelected(newSelection, true);
	canvas.repaint();
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:22,代码来源:SelectionAction.java

示例13: undo

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void undo(Project proj) {
	AppearanceAnchor anchor = findAnchor(canvasModel);
	if (anchor != null && anchorOldLocation != null) {
		anchor.translate(anchorOldLocation.getX() - anchorNewLocation.getX(),
				anchorOldLocation.getY() - anchorNewLocation.getY());
	}
	if (anchor != null && anchorOldFacing != null) {
		anchor.setValue(AppearanceAnchor.FACING, anchorOldFacing);
	}
	Selection sel = canvas.getSelection();
	sel.clearSelected();
	if (toAdd != null) canvasModel.removeObjects(toAdd);
	if (toRemove != null) canvasModel.addObjects(toRemove);
	sel.setSelected(oldSelection, true);
	canvas.repaint();
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:18,代码来源:SelectionAction.java

示例14: paint

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public void paint(Graphics g, Selection selection) {
	Set<CanvasObject> suppressed = selection.getDrawsSuppressed();
	for (CanvasObject shape : getObjectsFromBottom()) {
		Graphics dup = g.create();
		if (suppressed.contains(shape)) {
			selection.drawSuppressed(dup, shape);
		} else {
			shape.paint(dup, null);
		}
		dup.dispose();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:14,代码来源:Drawing.java

示例15: getTitle

import com.cburch.draw.canvas.Selection; //导入依赖的package包/类
@Override
public String getTitle() {
	Selection sel = canvas.getSelection();
	Class<? extends CanvasObject> commonClass = null;
	int commonCount = 0;
	CanvasObject firstObject = null;
	int totalCount = 0;
	for (CanvasObject obj : sel.getSelected()) {
		if (firstObject == null) {
			firstObject = obj;
			commonClass = obj.getClass();
			commonCount = 1;
		} else if (obj.getClass() == commonClass) {
			commonCount++;
		} else {
			commonClass = null;
		}
		totalCount++;
	}

	if (firstObject == null) {
		return null;
	} else if (commonClass == null) {
		return Strings.get("selectionVarious", "" + totalCount);
	} else if (commonCount == 1) {
		return Strings.get("selectionOne", firstObject.getDisplayName());
	} else {
		return Strings.get("selectionMultiple", firstObject.getDisplayName(), "" + commonCount);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:31,代码来源:AttrTableSelectionModel.java


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