package org.expeditee.gio.gesture.data; import java.util.Collection; import java.util.LinkedHashSet; import org.expeditee.core.Point; import org.expeditee.gui.FrameUtils; import org.expeditee.items.Item; import org.expeditee.items.Text; public class ItemSpecificGestureData extends GestureData { protected Item _currentItem; protected Collection _currentItems; protected Collection _enclosure; public ItemSpecificGestureData(Item item) { super(); _currentItem = item; } public ItemSpecificGestureData() { super(); init(); } public ItemSpecificGestureData(Point position) { super(position); init(); } public ItemSpecificGestureData(ItemSpecificGestureData other) { super(other); if (other != null) { _currentItem = other._currentItem; if (other._currentItems != null) { _currentItems = new LinkedHashSet(other._currentItems.size()); _currentItems.addAll(other._currentItems); } if (other._enclosure != null) { _enclosure = new LinkedHashSet(other._enclosure.size()); _enclosure.addAll(other._enclosure); } } } public Item getCurrentItem() { return _currentItem; } public Text getCurrentTextItem() { if (_currentItem instanceof Text) return (Text) _currentItem; return null; } public Collection getCurrentItems() { return _currentItems; } public Collection getEnclosure() { return _enclosure; } private void init() { _currentItem = FrameUtils.getCurrentItem(); _currentItems = FrameUtils.getCurrentItems(_currentItem); _enclosure = FrameUtils.getEnclosingLineEnds(); } @Override public GestureData clone() { return new ItemSpecificGestureData(this); } }