source: trunk/src/org/expeditee/gio/gesture/data/ItemSpecificGestureData.java@ 1097

Last change on this file since 1097 was 1097, checked in by davidb, 6 years ago

Newly structured files from Corey's work on logic/graphics separation

File size: 1.7 KB
Line 
1package org.expeditee.gio.gesture.data;
2
3import java.util.Collection;
4import java.util.LinkedHashSet;
5
6import org.expeditee.core.Point;
7import org.expeditee.gui.FrameUtils;
8import org.expeditee.items.Item;
9import org.expeditee.items.Text;
10
11public 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}
Note: See TracBrowser for help on using the repository browser.