1 | package org.expeditee.gio.gesture.data;
|
---|
2 |
|
---|
3 | import java.util.Collection;
|
---|
4 | import java.util.LinkedHashSet;
|
---|
5 |
|
---|
6 | import org.expeditee.core.Point;
|
---|
7 | import org.expeditee.gui.FrameUtils;
|
---|
8 | import org.expeditee.items.Item;
|
---|
9 | import org.expeditee.items.Text;
|
---|
10 |
|
---|
11 | public class ItemSpecificGestureData extends GestureData {
|
---|
12 |
|
---|
13 | protected Item _currentItem;
|
---|
14 | protected Collection<Item> _currentItems;
|
---|
15 | protected Collection<Item> _enclosure;
|
---|
16 | protected boolean _shiftDown;
|
---|
17 |
|
---|
18 | public ItemSpecificGestureData(Item item, boolean isShiftDown)
|
---|
19 | {
|
---|
20 | super();
|
---|
21 | _currentItem = item;
|
---|
22 | _shiftDown = isShiftDown;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public ItemSpecificGestureData(boolean isShiftDown)
|
---|
26 | {
|
---|
27 | super();
|
---|
28 | init();
|
---|
29 | _shiftDown = isShiftDown;
|
---|
30 | }
|
---|
31 |
|
---|
32 | public ItemSpecificGestureData(Point position)
|
---|
33 | {
|
---|
34 | super(position);
|
---|
35 | init();
|
---|
36 | }
|
---|
37 |
|
---|
38 | public ItemSpecificGestureData(ItemSpecificGestureData other)
|
---|
39 | {
|
---|
40 | super(other);
|
---|
41 | if (other != null) {
|
---|
42 | _currentItem = other._currentItem;
|
---|
43 | if (other._currentItems != null) {
|
---|
44 | _currentItems = new LinkedHashSet<Item>(other._currentItems.size());
|
---|
45 | _currentItems.addAll(other._currentItems);
|
---|
46 | }
|
---|
47 | if (other._enclosure != null) {
|
---|
48 | _enclosure = new LinkedHashSet<Item>(other._enclosure.size());
|
---|
49 | _enclosure.addAll(other._enclosure);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | public Item getCurrentItem()
|
---|
55 | {
|
---|
56 | return _currentItem;
|
---|
57 | }
|
---|
58 |
|
---|
59 | public Text getCurrentTextItem()
|
---|
60 | {
|
---|
61 | if (_currentItem instanceof Text) return (Text) _currentItem;
|
---|
62 |
|
---|
63 | return null;
|
---|
64 | }
|
---|
65 |
|
---|
66 | public Collection<Item> getCurrentItems()
|
---|
67 | {
|
---|
68 | return _currentItems;
|
---|
69 | }
|
---|
70 |
|
---|
71 | public Collection<Item> getEnclosure()
|
---|
72 | {
|
---|
73 | return _enclosure;
|
---|
74 | }
|
---|
75 |
|
---|
76 | private void init()
|
---|
77 | {
|
---|
78 | _currentItem = FrameUtils.getCurrentItem();
|
---|
79 | _currentItems = FrameUtils.getCurrentItems(_currentItem);
|
---|
80 | _enclosure = FrameUtils.getEnclosingLineEnds();
|
---|
81 | }
|
---|
82 |
|
---|
83 | @Override
|
---|
84 | public GestureData clone()
|
---|
85 | {
|
---|
86 | return new ItemSpecificGestureData(this);
|
---|
87 | }
|
---|
88 |
|
---|
89 | public boolean isShiftDown() {
|
---|
90 | return _shiftDown;
|
---|
91 | }
|
---|
92 | }
|
---|