PageRenderTime 26ms CodeModel.GetById 12ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/extensions/org/mt4jx/input/inputProcessors/componentProcessors/Group3DProcessorNew/FingerTapGrouping/FingerTapSelection.java

http://mt4j.googlecode.com/
Java | 168 lines | 131 code | 37 blank | 0 comment | 5 complexity | fc108a6dd5fbd4f4e879d4468122a379 MD5 | raw file
  1package org.mt4jx.input.inputProcessors.componentProcessors.Group3DProcessorNew.FingerTapGrouping;
  2
  3import java.util.ArrayList;
  4
  5import org.mt4j.components.MTCanvas;
  6import org.mt4j.components.MTComponent;
  7import org.mt4j.input.inputData.InputCursor;
  8import org.mt4j.input.inputProcessors.componentProcessors.lassoProcessor.IdragClusterable;
  9import org.mt4jx.input.inputProcessors.componentProcessors.Group3DProcessorNew.Cluster;
 10import org.mt4jx.input.inputProcessors.componentProcessors.Group3DProcessorNew.ClusterDataManager;
 11import org.mt4jx.input.inputProcessors.componentProcessors.Group3DProcessorNew.ISelection;
 12
 13public class FingerTapSelection implements ISelection {
 14
 15	private ClusterDataManager clusterDataManager;
 16	
 17	private FingerTapSelectionManager selectionManager;
 18	
 19	private FingerTapState state = FingerTapState.NOELEMENTSELECTED;
 20	
 21	private InputCursor firstCursor;
 22	
 23	private MTComponent firstCursorComp;
 24	
 25	private ArrayList<InputCursor> currentlyPressedCursors = new ArrayList<InputCursor>();
 26	
 27	private ArrayList<MTComponent> selectedComps = new ArrayList<MTComponent>();
 28	
 29	private MTCanvas canvas;
 30	
 31	private Cluster currentlySelectedCluster;
 32	
 33	public FingerTapSelection(ClusterDataManager clusterDataManager,MTCanvas canvas,FingerTapSelectionManager selectionManager)
 34	{
 35		this.clusterDataManager = clusterDataManager;
 36		this.canvas = canvas;
 37		this.selectionManager = selectionManager;
 38	}
 39	public synchronized void addComponentToSelection(MTComponent comp)
 40	{
 41		if(!(selectedComps.contains(comp)))
 42		{
 43			selectedComps.add(comp);
 44		}
 45	}
 46	
 47	public boolean compIsInSelection(MTComponent comp)
 48	{
 49		return  selectedComps.contains(comp);
 50	}
 51	
 52	public synchronized void  removeCurrentlySelectedFromCanvas()
 53	{
 54		for(MTComponent comp : selectedComps)
 55		{
 56			this.canvas.removeChild(comp);
 57		}
 58	}
 59	
 60	public synchronized void removeComponentFromSelection(MTComponent comp)
 61	{
 62		if(selectedComps.contains(comp))
 63		{			
 64			selectedComps.remove(comp);			
 65		}		
 66	}
 67	
 68	public void addComponentToCanvas(MTComponent comp)
 69	{
 70		canvas.addChild(comp);
 71	}
 72	
 73	public void removeComponentFromCanvas(MTComponent comp)
 74	{
 75		canvas.removeChild(comp);
 76	}
 77	
 78	public ArrayList<MTComponent> getSelectedComponents() {
 79		return selectedComps;
 80	}
 81	
 82	public synchronized void setSelectedComponents(ArrayList<MTComponent> selectedComps)
 83	{
 84		this.selectedComps = selectedComps;
 85	}
 86
 87	public synchronized void setState(FingerTapState state) {
 88		this.state = state;		
 89		this.state.stateEntry(this);
 90	}
 91
 92	public FingerTapState getState() {
 93		return state;
 94	}
 95
 96	public void setClusterDataManager(ClusterDataManager clusterDataManager) {
 97		this.clusterDataManager = clusterDataManager;
 98	}
 99
100	public ClusterDataManager getClusterDataManager() {
101		return clusterDataManager;
102	}
103
104	public synchronized void setFirstCursor(InputCursor firstCursor) {
105		this.firstCursor = firstCursor;		
106	}
107
108	public InputCursor getFirstCursor() {
109		return firstCursor;
110	}
111	
112	public boolean isFirstCursor(InputCursor cursor)
113	{
114		if(firstCursor==cursor)
115		{
116			return true;
117		}
118		return false;
119	}
120
121	public synchronized void setCurrentlyPressedCursors(ArrayList<InputCursor> currentlyPressedCursors) {
122		this.currentlyPressedCursors = currentlyPressedCursors;
123	}
124
125	public  ArrayList<InputCursor> getCurrentlyPressedCursors() {
126		return currentlyPressedCursors;
127	}
128	
129	
130	public void createCluster()
131	{
132		ArrayList<MTComponent> components = new ArrayList<MTComponent>();
133		for(MTComponent comp : selectedComps)
134		{
135			
136				MTComponent component = (MTComponent)comp;
137				components.add(component);						
138		}
139		clusterDataManager.createCluster(components, true);
140	}
141	
142	public void setCurrentlySelectedCluster(Cluster currentlySelectedCluster) {
143		this.currentlySelectedCluster = currentlySelectedCluster;
144	}
145	public Cluster getCurrentlySelectedCluster() {
146		return currentlySelectedCluster;
147	}
148	public void setSelectionManager(FingerTapSelectionManager selectionManager) {
149		this.selectionManager = selectionManager;
150	}
151	public FingerTapSelectionManager getSelectionManager() {
152		return selectionManager;
153	}
154	public void setFirstCursorComp(MTComponent firstCursorComp) {
155		this.firstCursorComp = firstCursorComp;
156	}
157	public MTComponent getFirstCursorComp() {
158		return firstCursorComp;
159	}
160	
161	public MTComponent getComponentForCursor(InputCursor cursor)
162	{
163		return (MTComponent)canvas.getComponentAt(cursor.getStartPosX(), cursor.getStartPosY());
164	}
165	
166	
167
168}