本文整理汇总了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);
}
}
示例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);
}
}
示例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));
}
}
示例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));
}
}
示例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();
}
示例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();
}
示例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);
}
}
示例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));
}
}
示例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();
}
示例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();
}
示例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));
}
}
示例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();
}
示例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();
}
示例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();
}
}
示例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);
}
}