View Javadoc

1   /*
2    * @(#)$Id: GestureSample3D.java 2008-12-02 arthurvogels $
3    *
4    * Author       :   Arthur Vogels, arthur.vogels@gmail.com
5    *
6    * Purpose      :	Container for 3D gestures.
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date             Who         	Reason
13   *
14   * Dec 02, 2008     arthurvogels    Initial Release
15   *
16   * -----------------------------------------------------------------------
17   *
18   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
19   *
20   * This software is the proprietary information of ETH Zurich.
21   * Use is subject to license terms.
22   * 
23   */
24  
25  package org.ximtec.igesture.core;
26  
27  import java.util.List;
28  
29  import org.sigtec.ink.Note;
30  import org.ximtec.igesture.io.GestureDevice;
31  import org.ximtec.igesture.util.RecordedGesture3DTool;
32  import org.ximtec.igesture.util.additions3d.RecordedGesture3D;
33  
34  public class GestureSample3D extends DefaultDataObject implements Cloneable,
35  		Gesture<RecordedGesture3D> {
36  
37  	public static final String PROPERTY_NAME = "name";
38  	public static final String PROPERTY_GESTURE = "gesture";
39  	private RecordedGesture3D gesture;
40  	private String name;
41  	
42  	private GestureDevice<?,?> source;
43  
44  	/**
45  	 * Constructs a new GestureSample3D.
46  	 * 
47  	 * @param name
48  	 *            the name of the gesture sample.
49  	 * @param note
50  	 *            the recordedgesture3d of the gesture sample.
51  	 */
52  	public GestureSample3D(String name, RecordedGesture3D gesture) {
53  		super();
54  		setName(name);
55  		setGesture(gesture);
56  	}
57  	
58  	/**
59  	 * Constructs a new GestureSample3D.
60  	 * @param device	the source device of the gesture sample
61  	 * @param name		the name of the gesture sample
62  	 * @param gesture	the recordedgesture3d of the gesture sample
63  	 */
64  	public GestureSample3D(GestureDevice<?,?> device, String name, RecordedGesture3D gesture)
65  	{
66  		this(name,gesture);
67  		setSource(device);
68  	}
69  
70  	/**
71  	 * Sets the sample name.
72  	 * 
73  	 * @param name
74  	 *            the name to be set.
75  	 */
76  	public void setName(String name) {
77  		String oldValue = this.name;
78  		this.name = name;
79  		propertyChangeSupport.firePropertyChange(PROPERTY_NAME, oldValue, name);
80  	}
81  
82  	/**
83  	 * Returns the sample name
84  	 */
85  	public String getName() {
86  		return name;
87  	}
88  
89  	/**
90  	 * Sets the sample gesture.
91  	 * 
92  	 * @param gesture
93  	 *            the gesture to be set.
94  	 */
95  	public void setGesture(RecordedGesture3D gesture) {
96  		RecordedGesture3D oldValue = this.gesture;
97  		this.gesture = gesture;
98  		propertyChangeSupport.firePropertyChange(PROPERTY_GESTURE, oldValue,
99  				gesture);
100 	}
101 
102 	/**
103 	 * Returns the gesture sample.
104 	 */
105 	public RecordedGesture3D getGesture() {
106 		return this.gesture;
107 	}
108 
109 	/**
110 	 * Splits RecordedGesture3D gesture into three 2D planes. The XY-Plane is
111 	 * defined as the plane in 3D space where z=0. The YZ-Plane is defined as
112 	 * the plane in 3D space where x=0. The ZX-Plane is defined as the plane in
113 	 * 3D space where y=0.
114 	 * 
115 	 * @return The list of 2D gestures that are the planes. First XY, then YZ
116 	 *         and then ZX.
117 	 */
118 	public List<Gesture<Note>> splitToPlanes() {
119 		return RecordedGesture3DTool.splitToPlanes(getGesture());
120 	}
121 
122 	/* (non-Javadoc)
123 	 * @see org.ximtec.igesture.core.Gesture#getSource()
124 	 */
125 	@Override
126 	public GestureDevice<?, ?> getSource() {
127 		return source;
128 	}
129 
130 	/* (non-Javadoc)
131 	 * @see org.ximtec.igesture.core.Gesture#setSource(org.ximtec.igesture.io.GestureDevice)
132 	 */
133 	@Override
134 	public void setSource(GestureDevice<?, ?> device) {
135 		this.source = device;
136 	}
137 
138 }