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 |
|
---|
17 | public ItemSpecificGestureData(Item item)
|
---|
18 | {
|
---|
19 | super();
|
---|
20 | _currentItem = item;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public ItemSpecificGestureData()
|
---|
24 | {
|
---|
25 | super();
|
---|
26 | init();
|
---|
27 | }
|
---|
28 |
|
---|
29 | public ItemSpecificGestureData(Point position)
|
---|
30 | {
|
---|
31 | super(position);
|
---|
32 | init();
|
---|
33 | }
|
---|
34 |
|
---|
35 | public ItemSpecificGestureData(ItemSpecificGestureData other)
|
---|
36 | {
|
---|
37 | super(other);
|
---|
38 | if (other != null) {
|
---|
39 | _currentItem = other._currentItem;
|
---|
40 | if (other._currentItems != null) {
|
---|
41 | _currentItems = new LinkedHashSet<Item>(other._currentItems.size());
|
---|
42 | _currentItems.addAll(other._currentItems);
|
---|
43 | }
|
---|
44 | if (other._enclosure != null) {
|
---|
45 | _enclosure = new LinkedHashSet<Item>(other._enclosure.size());
|
---|
46 | _enclosure.addAll(other._enclosure);
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | public Item getCurrentItem()
|
---|
52 | {
|
---|
53 | return _currentItem;
|
---|
54 | }
|
---|
55 |
|
---|
56 | public Text getCurrentTextItem()
|
---|
57 | {
|
---|
58 | if (_currentItem instanceof Text) return (Text) _currentItem;
|
---|
59 |
|
---|
60 | return null;
|
---|
61 | }
|
---|
62 |
|
---|
63 | public Collection<Item> getCurrentItems()
|
---|
64 | {
|
---|
65 | return _currentItems;
|
---|
66 | }
|
---|
67 |
|
---|
68 | public Collection<Item> getEnclosure()
|
---|
69 | {
|
---|
70 | return _enclosure;
|
---|
71 | }
|
---|
72 |
|
---|
73 | private void init()
|
---|
74 | {
|
---|
75 | _currentItem = FrameUtils.getCurrentItem();
|
---|
76 | _currentItems = FrameUtils.getCurrentItems(_currentItem);
|
---|
77 | _enclosure = FrameUtils.getEnclosingLineEnds();
|
---|
78 | }
|
---|
79 |
|
---|
80 | @Override
|
---|
81 | public GestureData clone()
|
---|
82 | {
|
---|
83 | return new ItemSpecificGestureData(this);
|
---|
84 | }
|
---|
85 | }
|
---|