View Javadoc

1   /*
2    * @(#)$Id: AddGestureSampleAction.java 787 2010-03-27 15:06:04Z bpuype $
3    *
4    * Author   : Ueli Kurmann, igesture@uelikurmann.ch
5    *                                   
6    *                                   
7    * Purpose  : 
8    *
9    * -----------------------------------------------------------------------
10   *
11   * Revision Information:
12   *
13   * Date       Who     Reason
14   *
15   * 23.03.2008 ukurmann  Initial Release
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  
27  package org.ximtec.igesture.tool.view.admin.action;
28  
29  import java.awt.event.ActionEvent;
30  
31  import org.sigtec.util.Constant;
32  import org.ximtec.igesture.core.DefaultSampleDescriptor;
33  import org.ximtec.igesture.core.Gesture;
34  import org.ximtec.igesture.core.GestureSample;
35  import org.ximtec.igesture.core.GestureSample3D;
36  import org.ximtec.igesture.core.SampleDescriptor;
37  import org.ximtec.igesture.io.GestureDevice;
38  import org.ximtec.igesture.tool.GestureConstants;
39  import org.ximtec.igesture.tool.core.Controller;
40  import org.ximtec.igesture.tool.core.LocateableAction;
41  import org.ximtec.igesture.tool.service.SwingMouseReaderService;
42  
43  
44  public class AddGestureSampleAction extends LocateableAction {
45  
46     DefaultSampleDescriptor descriptor;
47     GestureDevice<?,?> gestureDevice;
48  
49  
50     public AddGestureSampleAction(Controller controller, DefaultSampleDescriptor descriptor, GestureDevice<?, ?> device) {
51        super(GestureConstants.GESTURE_SAMPLE_ADD, controller.getLocator());
52        this.descriptor = descriptor;
53        this.gestureDevice = device;
54     }
55  
56  
57     @Override
58     public void actionPerformed(ActionEvent action) {
59        
60        if(gestureDevice.getGesture() != null){
61           Gesture<?> note = gestureDevice.getGesture();
62           gestureDevice.clear();
63           note.setName(Constant.EMPTY_STRING);
64           if(note instanceof GestureSample){
65              descriptor.addSample((GestureSample)note);
66           }else if(note instanceof GestureSample3D){
67          	 System.out.println("STILL TO IMPLEMENT");
68          	 descriptor.addSample((GestureSample3D)note);
69           }else{
70              throw new IllegalStateException();
71           }
72        }
73     }
74  
75  }