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