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


Java Selection.getSelected方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例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:reds-heig,项目名称:logisim-evolution,代码行数:25,代码来源:AppearanceEditHandler.java

示例5: 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

示例6: 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

示例7: 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:reds-heig,项目名称:logisim-evolution,代码行数:32,代码来源:AttrTableSelectionModel.java

示例8: 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:reds-heig,项目名称:logisim-evolution,代码行数:29,代码来源:AppearanceEditHandler.java

示例9: 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:franciscaconcha,项目名称:ProyectoLogisim,代码行数:32,代码来源:AttrTableSelectionModel.java

示例10: 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:franciscaconcha,项目名称:ProyectoLogisim,代码行数:28,代码来源:AppearanceEditHandler.java

示例11: mousePressed

import com.cburch.draw.canvas.Selection; //导入方法依赖的package包/类
@Override
public void mousePressed(Canvas canvas, MouseEvent e) {
	beforePressSelection = new ArrayList<CanvasObject>(canvas.getSelection().getSelected());
	beforePressHandle = canvas.getSelection().getSelectedHandle();
	int mx = e.getX();
	int my = e.getY();
	boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
	dragStart = Location.create(mx, my);
	dragEffective = false;
	dragEnd = dragStart;
	lastMouseX = mx;
	lastMouseY = my;
	Selection selection = canvas.getSelection();
	selection.setHandleSelected(null);

	// see whether user is pressing within an existing handle
	int halfSize = getHandleSize(canvas) / 2;
	CanvasObject clicked = null;
	for (CanvasObject shape : selection.getSelected()) {
		List<Handle> handles = shape.getHandles(null);
		for (Handle han : handles) {
			int dx = han.getX() - mx;
			int dy = han.getY() - my;
			if (dx >= -halfSize && dx <= halfSize && dy >= -halfSize && dy <= halfSize) {
				if (shape.canMoveHandle(han)) {
					curAction = MOVE_HANDLE;
					curGesture = new HandleGesture(han, 0, 0, e.getModifiersEx());
					repaintArea(canvas);
					return;
				} else if (clicked == null) {
					clicked = shape;
				}
			}
		}
	}

	// see whether the user is clicking within a shape
	if (clicked == null) {
		clicked = getObjectAt(canvas.getModel(), e.getX(), e.getY(), false);
	}
	if (clicked != null) {
		if (shift && selection.isSelected(clicked)) {
			selection.setSelected(clicked, false);
			curAction = IDLE;
		} else {
			if (!shift && !selection.isSelected(clicked)) {
				selection.clearSelected();
			}
			selection.setSelected(clicked, true);
			selection.setMovingShapes(selection.getSelected(), 0, 0);
			curAction = MOVE_ALL;
		}
		repaintArea(canvas);
		return;
	}

	clicked = getObjectAt(canvas.getModel(), e.getX(), e.getY(), true);
	if (clicked != null && selection.isSelected(clicked)) {
		if (shift) {
			selection.setSelected(clicked, false);
			curAction = IDLE;
		} else {
			selection.setMovingShapes(selection.getSelected(), 0, 0);
			curAction = MOVE_ALL;
		}
		repaintArea(canvas);
		return;
	}

	if (shift) {
		curAction = RECT_TOGGLE;
	} else {
		selection.clearSelected();
		curAction = RECT_SELECT;
	}
	repaintArea(canvas);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:78,代码来源:SelectTool.java

示例12: mousePressed

import com.cburch.draw.canvas.Selection; //导入方法依赖的package包/类
@Override
public void mousePressed(Canvas canvas, MouseEvent e) {
	beforePressSelection = new ArrayList<CanvasObject>(canvas
			.getSelection().getSelected());
	beforePressHandle = canvas.getSelection().getSelectedHandle();
	int mx = e.getX();
	int my = e.getY();
	boolean shift = (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0;
	dragStart = Location.create(mx, my);
	dragEffective = false;
	dragEnd = dragStart;
	lastMouseX = mx;
	lastMouseY = my;
	Selection selection = canvas.getSelection();
	selection.setHandleSelected(null);

	// see whether user is pressing within an existing handle
	int halfSize = getHandleSize(canvas) / 2;
	CanvasObject clicked = null;
	for (CanvasObject shape : selection.getSelected()) {
		List<Handle> handles = shape.getHandles(null);
		for (Handle han : handles) {
			int dx = han.getX() - mx;
			int dy = han.getY() - my;
			if (dx >= -halfSize && dx <= halfSize && dy >= -halfSize
					&& dy <= halfSize) {
				if (shape.canMoveHandle(han)) {
					curAction = MOVE_HANDLE;
					curGesture = new HandleGesture(han, 0, 0,
							e.getModifiersEx());
					repaintArea(canvas);
					return;
				} else if (clicked == null) {
					clicked = shape;
				}
			}
		}
	}

	// see whether the user is clicking within a shape
	if (clicked == null) {
		clicked = getObjectAt(canvas.getModel(), e.getX(), e.getY(), false);
	}
	if (clicked != null) {
		if (shift && selection.isSelected(clicked)) {
			selection.setSelected(clicked, false);
			curAction = IDLE;
		} else {
			if (!shift && !selection.isSelected(clicked)) {
				selection.clearSelected();
			}
			selection.setSelected(clicked, true);
			selection.setMovingShapes(selection.getSelected(), 0, 0);
			curAction = MOVE_ALL;
		}
		repaintArea(canvas);
		return;
	}

	clicked = getObjectAt(canvas.getModel(), e.getX(), e.getY(), true);
	if (clicked != null && selection.isSelected(clicked)) {
		if (shift) {
			selection.setSelected(clicked, false);
			curAction = IDLE;
		} else {
			selection.setMovingShapes(selection.getSelected(), 0, 0);
			curAction = MOVE_ALL;
		}
		repaintArea(canvas);
		return;
	}

	if (shift) {
		curAction = RECT_TOGGLE;
	} else {
		selection.clearSelected();
		curAction = RECT_SELECT;
	}
	repaintArea(canvas);
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:81,代码来源:SelectTool.java

示例13: mousePressed

import com.cburch.draw.canvas.Selection; //导入方法依赖的package包/类
@Override
public void mousePressed(Canvas canvas, MouseEvent e) {
	beforePressSelection = new ArrayList<CanvasObject>(canvas.getSelection().getSelected());
	beforePressHandle = canvas.getSelection().getSelectedHandle();
	int mx = e.getX();
	int my = e.getY();
	boolean shift = (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0;
	dragStart = Location.create(mx, my);
	dragEffective = false;
	dragEnd = dragStart;
	lastMouseX = mx;
	lastMouseY = my;
	Selection selection = canvas.getSelection();
	selection.setHandleSelected(null);
	
	// see whether user is pressing within an existing handle
	int halfSize = getHandleSize(canvas) / 2;
	CanvasObject clicked = null;
	for (CanvasObject shape : selection.getSelected()) {
		List<Handle> handles = shape.getHandles(null);
		for (Handle han : handles) {
			int dx = han.getX() - mx;
			int dy = han.getY() - my;
			if (dx >= -halfSize && dx <= halfSize
					&& dy >= -halfSize && dy <= halfSize) {
				if (shape.canMoveHandle(han)) {
					curAction = MOVE_HANDLE;
					curGesture = new HandleGesture(han, 0, 0,
							e.getModifiersEx());
					repaintArea(canvas);
					return;
				} else if (clicked == null) {
					clicked = shape;
				}
			}
		}
	}

	// see whether the user is clicking within a shape
	if (clicked == null) {
		clicked = getObjectAt(canvas.getModel(), e.getX(), e.getY(), false);
	}
	if (clicked != null) {
		if (shift && selection.isSelected(clicked)) {
			selection.setSelected(clicked, false);
			curAction = IDLE;
		} else {
			if (!shift && !selection.isSelected(clicked)) {
				selection.clearSelected();
			}
			selection.setSelected(clicked, true);
			selection.setMovingShapes(selection.getSelected(), 0, 0);
			curAction = MOVE_ALL;
		}
		repaintArea(canvas);
		return;
	}
	
	clicked = getObjectAt(canvas.getModel(), e.getX(), e.getY(), true);
	if (clicked != null && selection.isSelected(clicked)) {
		if (shift) {
			selection.setSelected(clicked, false);
			curAction = IDLE;
		} else {
			selection.setMovingShapes(selection.getSelected(), 0, 0);
			curAction = MOVE_ALL;
		}
		repaintArea(canvas);
		return;
	}

	if (shift) {
		curAction = RECT_TOGGLE;
	} else {
		selection.clearSelected();
		curAction = RECT_SELECT;
	}
	repaintArea(canvas);
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:80,代码来源:SelectTool.java


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