front_processing/extern/TUIO_JAVA/src/TUIO/TuioContainer.java
author bastiena
Mon, 24 Sep 2012 12:54:23 +0200
changeset 119 18784c67a338
parent 28 9ccef81f02ab
permissions -rw-r--r--
Fusion
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     1
/*
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     2
 TUIO Java backend - part of the reacTIVision project
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     3
 http://reactivision.sourceforge.net/
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     4
 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     5
 Copyright (c) 2005-2009 Martin Kaltenbrunner <mkalten@iua.upf.edu>
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     6
 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     7
 This program is free software; you can redistribute it and/or modify
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     8
 it under the terms of the GNU General Public License as published by
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
     9
 the Free Software Foundation; either version 2 of the License, or
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    10
 (at your option) any later version.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    11
 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    12
 This program is distributed in the hope that it will be useful,
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    15
 GNU General Public License for more details.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    16
 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    17
 You should have received a copy of the GNU General Public License
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    18
 along with this program; if not, write to the Free Software
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    19
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    20
 */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    21
 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    22
 /*
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    23
    Modified by alexandre.bastien@iri.centrepompidou.fr to manage 3D.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    24
*/
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    25
 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    26
package TUIO;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    27
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    28
import java.util.*;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    29
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    30
/**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    31
 * The abstract TuioContainer class defines common attributes that apply to both subclasses {@link TuioObject} and {@link TuioCursor}.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    32
 *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    33
 * @author Martin Kaltenbrunner
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    34
 * @version 1.4
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    35
 */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    36
abstract class TuioContainer extends TuioPoint {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    37
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    38
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    39
     * The unique session ID number that is assigned to each TUIO object or cursor.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    40
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    41
    protected long session_id;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    42
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    43
     * The X-axis velocity value.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    44
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    45
    protected float x_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    46
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    47
     * The Y-axis velocity value.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    48
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    49
    protected float y_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    50
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    51
     * The motion speed value.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    52
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    53
    protected float motion_speed;    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    54
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    55
     * The motion acceleration value.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    56
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    57
    protected float motion_accel;        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    58
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    59
     * A Vector of TuioPoints containing all the previous positions of the TUIO component.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    60
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    61
    protected Vector<TuioPoint> path;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    62
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    63
     * Defines the ADDED state.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    64
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    65
    public static final int TUIO_ADDED = 0;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    66
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    67
     * Defines the ACCELERATING state.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    68
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    69
    public static final int TUIO_ACCELERATING = 1;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    70
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    71
     * Defines the DECELERATING state.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    72
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    73
    public static final int TUIO_DECELERATING = 2;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    74
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    75
     * Defines the STOPPED state.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    76
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    77
    public static final int TUIO_STOPPED = 3;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    78
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    79
     * Defines the REMOVED state.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    80
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    81
    public static final int TUIO_REMOVED = 4;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    82
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    83
     * Reflects the current state of the TuioComponent
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    84
     */ 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    85
    protected int state;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    86
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    87
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    88
     * This constructor takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    89
     * Session ID, X and Y coordinate to the newly created TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    90
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    91
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    92
     * @param    si    the Session ID to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    93
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    94
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    95
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    96
    TuioContainer(TuioTime ttime, long si, float xp, float yp) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    97
        super(ttime,xp,yp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    98
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
    99
        session_id = si;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   100
        x_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   101
        y_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   102
        motion_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   103
        motion_accel = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   104
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   105
        path = new Vector<TuioPoint>();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   106
        path.addElement(new TuioPoint(currentTime,xpos,ypos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   107
        state = TUIO_ADDED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   108
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   109
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   110
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   111
     * This constructor takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   112
     * Session ID, X, Y and Z coordinate to the newly created TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   113
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   114
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   115
     * @param    si    the Session ID to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   116
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   117
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   118
     * @param    zp    the Z coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   119
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   120
    TuioContainer(TuioTime ttime, long si, float xp, float yp, float zp) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   121
        super(ttime,xp,yp, zp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   122
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   123
        session_id = si;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   124
        x_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   125
        y_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   126
        motion_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   127
        motion_accel = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   128
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   129
        path = new Vector<TuioPoint>();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   130
        path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   131
        state = TUIO_ADDED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   132
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   133
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   134
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   135
     * This constructor takes the provided Session ID, X and Y coordinate 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   136
     * and assigs these values to the newly created TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   137
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   138
     * @param    si    the Session ID to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   139
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   140
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   141
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   142
    TuioContainer(long si, float xp, float yp) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   143
        super(xp,yp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   144
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   145
        session_id = si;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   146
        x_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   147
        y_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   148
        motion_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   149
        motion_accel = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   150
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   151
        path = new Vector<TuioPoint>();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   152
        path.addElement(new TuioPoint(currentTime,xpos,ypos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   153
        state = TUIO_ADDED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   154
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   155
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   156
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   157
     * This constructor takes the provided Session ID, X, Y and Z coordinate 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   158
     * and assigs these values to the newly created TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   159
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   160
     * @param    si    the Session ID to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   161
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   162
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   163
     * @param    zp    the Z coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   164
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   165
    TuioContainer(long si, float xp, float yp, float zp) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   166
        super(xp,yp,zp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   167
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   168
        session_id = si;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   169
        x_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   170
        y_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   171
        motion_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   172
        motion_accel = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   173
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   174
        path = new Vector<TuioPoint>();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   175
        path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   176
        state = TUIO_ADDED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   177
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   178
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   179
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   180
     * This constructor takes the atttibutes of the provided TuioContainer 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   181
     * and assigs these values to the newly created TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   182
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   183
     * @param    tcon    the TuioContainer to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   184
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   185
    TuioContainer(TuioContainer tcon) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   186
        super(tcon);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   187
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   188
        session_id = tcon.getSessionID();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   189
        x_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   190
        y_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   191
        motion_speed = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   192
        motion_accel = 0.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   193
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   194
        path = new Vector<TuioPoint>();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   195
        path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   196
        state = TUIO_ADDED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   197
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   198
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   199
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   200
     * Takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   201
     * X and Y coordinate to the private TuioContainer attributes.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   202
     * The speed and accleration values are calculated accordingly.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   203
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   204
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   205
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   206
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   207
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   208
    public void update(TuioTime ttime, float xp, float yp) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   209
        TuioPoint lastPoint = path.lastElement();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   210
        super.update(ttime,xp,yp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   211
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   212
        TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime());
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   213
        float dt = diffTime.getTotalMilliseconds()/1000.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   214
        float dx = this.xpos - lastPoint.getX();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   215
        float dy = this.ypos - lastPoint.getY();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   216
        float dist = (float)Math.sqrt(dx*dx+dy*dy);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   217
        float last_motion_speed = this.motion_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   218
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   219
        this.x_speed = dx/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   220
        this.y_speed = dy/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   221
        this.motion_speed = dist/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   222
        this.motion_accel = (motion_speed - last_motion_speed)/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   223
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   224
        path.addElement(new TuioPoint(currentTime,xpos,ypos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   225
        if (motion_accel>0) state = TUIO_ACCELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   226
        else if (motion_accel<0) state = TUIO_DECELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   227
        else state = TUIO_STOPPED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   228
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   229
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   230
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   231
     * Takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   232
     * X, Y and Z coordinate to the private TuioContainer attributes.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   233
     * The speed and accleration values are calculated accordingly.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   234
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   235
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   236
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   237
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   238
     * @param    zp    the Z coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   239
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   240
    public void update(TuioTime ttime, float xp, float yp, float zp) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   241
        TuioPoint lastPoint = path.lastElement();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   242
        super.update(ttime,xp,yp,zp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   243
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   244
        TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime());
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   245
        float dt = diffTime.getTotalMilliseconds()/1000.0f;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   246
        float dx = this.xpos - lastPoint.getX();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   247
        float dy = this.ypos - lastPoint.getY();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   248
        float dz = this.zpos - lastPoint.getZ();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   249
        float dist = (float)Math.sqrt(dx*dx+dy*dy+dz*dz);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   250
        float last_motion_speed = this.motion_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   251
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   252
        this.x_speed = dx/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   253
        this.y_speed = dy/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   254
        this.motion_speed = dist/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   255
        this.motion_accel = (motion_speed - last_motion_speed)/dt;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   256
        
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   257
        path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   258
        if (motion_accel>0) state = TUIO_ACCELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   259
        else if (motion_accel<0) state = TUIO_DECELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   260
        else state = TUIO_STOPPED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   261
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   262
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   263
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   264
     * This method is used to calculate the speed and acceleration values of
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   265
     * TuioContainers with unchanged positions.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   266
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   267
    public void stop(TuioTime ttime) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   268
        update(ttime,xpos,ypos,zpos);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   269
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   270
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   271
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   272
     * Takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   273
     * X and Y coordinate, X and Y velocity and acceleration
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   274
     * to the private TuioContainer attributes.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   275
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   276
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   277
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   278
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   279
     * @param    xs    the X velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   280
     * @param    ys    the Y velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   281
     * @param    ma    the acceleration to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   282
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   283
    public void update(TuioTime ttime, float xp, float yp , float xs, float ys, float ma) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   284
        super.update(ttime,xp,yp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   285
        x_speed = xs;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   286
        y_speed = ys;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   287
        motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   288
        motion_accel = ma;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   289
        path.addElement(new TuioPoint(currentTime,xpos,ypos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   290
        if (motion_accel>0) state = TUIO_ACCELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   291
        else if (motion_accel<0) state = TUIO_DECELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   292
        else state = TUIO_STOPPED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   293
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   294
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   295
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   296
     * Takes a TuioTime argument and assigns it along with the provided 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   297
     * X, Y and Z coordinate, X and Y velocity and acceleration
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   298
     * to the private TuioContainer attributes.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   299
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   300
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   301
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   302
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   303
     * @param    zp    the Z coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   304
     * @param    xs    the X velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   305
     * @param    ys    the Y velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   306
     * @param    ma    the acceleration to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   307
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   308
    public void update(TuioTime ttime, float xp, float yp, float zp , float xs, float ys, float ma) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   309
        super.update(ttime,xp,yp,zp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   310
        x_speed = xs;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   311
        y_speed = ys;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   312
        motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   313
        motion_accel = ma;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   314
        path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   315
        if (motion_accel>0) state = TUIO_ACCELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   316
        else if (motion_accel<0) state = TUIO_DECELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   317
        else state = TUIO_STOPPED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   318
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   319
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   320
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   321
     * Assigns the provided X and Y coordinate, X and Y velocity and acceleration
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   322
     * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   323
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   324
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   325
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   326
     * @param    xs    the X velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   327
     * @param    ys    the Y velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   328
     * @param    ma    the acceleration to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   329
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   330
    public void update(float xp, float yp,float xs,float ys,float ma) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   331
        super.update(xp,yp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   332
        x_speed = xs;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   333
        y_speed = ys;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   334
        motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   335
        motion_accel = ma;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   336
        path.addElement(new TuioPoint(currentTime,xpos,ypos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   337
        if (motion_accel>0) state = TUIO_ACCELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   338
        else if (motion_accel<0) state = TUIO_DECELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   339
        else state = TUIO_STOPPED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   340
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   341
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   342
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   343
     * Assigns the provided X, Y and Z coordinate, X and Y velocity and acceleration
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   344
     * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   345
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   346
     * @param    xp    the X coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   347
     * @param    yp    the Y coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   348
     * @param    zp    the Z coordinate to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   349
     * @param    xs    the X velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   350
     * @param    ys    the Y velocity to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   351
     * @param    ma    the acceleration to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   352
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   353
    public void update(float xp, float yp, float zp,float xs,float ys,float ma) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   354
        super.update(xp,yp,zp);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   355
        x_speed = xs;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   356
        y_speed = ys;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   357
        motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   358
        motion_accel = ma;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   359
        path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   360
        if (motion_accel>0) state = TUIO_ACCELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   361
        else if (motion_accel<0) state = TUIO_DECELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   362
        else state = TUIO_STOPPED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   363
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   364
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   365
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   366
     * Takes the atttibutes of the provided TuioContainer 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   367
     * and assigs these values to this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   368
     * The TuioTime time stamp of this TuioContainer remains unchanged.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   369
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   370
     * @param    tcon    the TuioContainer to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   371
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   372
    public void update (TuioContainer tcon) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   373
        super.update(tcon);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   374
        x_speed = tcon.getXSpeed();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   375
        y_speed = tcon.getYSpeed();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   376
        motion_speed = tcon.getMotionSpeed();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   377
        motion_accel = tcon.getMotionAccel();
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   378
        path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos));
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   379
        if (motion_accel>0) state = TUIO_ACCELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   380
        else if (motion_accel<0) state = TUIO_DECELERATING;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   381
        else state = TUIO_STOPPED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   382
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   383
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   384
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   385
     * Assigns the REMOVE state to this TuioContainer and sets
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   386
     * its TuioTime time stamp to the provided TuioTime argument.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   387
     *
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   388
     * @param    ttime    the TuioTime to assign
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   389
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   390
    public void remove(TuioTime ttime) {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   391
        currentTime = new TuioTime(ttime);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   392
        state = TUIO_REMOVED;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   393
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   394
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   395
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   396
     * Returns the Session ID of this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   397
     * @return    the Session ID of this TuioContainer
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   398
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   399
    public long getSessionID() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   400
        return session_id;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   401
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   402
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   403
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   404
     * Returns the X velocity of this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   405
     * @return    the X velocity of this TuioContainer
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   406
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   407
    public float getXSpeed() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   408
        return x_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   409
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   410
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   411
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   412
     * Returns the Y velocity of this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   413
     * @return    the Y velocity of this TuioContainer
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   414
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   415
    public float getYSpeed() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   416
        return y_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   417
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   418
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   419
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   420
     * Returns the position of this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   421
     * @return    the position of this TuioContainer
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   422
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   423
    public TuioPoint getPosition() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   424
        return new TuioPoint(xpos,ypos,zpos);
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   425
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   426
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   427
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   428
     * Returns the path of this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   429
     * @return    the path of this TuioContainer
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   430
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   431
    public Vector<TuioPoint> getPath() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   432
        return path;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   433
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   434
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   435
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   436
     * Returns the motion speed of this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   437
     * @return    the motion speed of this TuioContainer
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   438
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   439
    public float getMotionSpeed() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   440
        return motion_speed;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   441
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   442
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   443
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   444
     * Returns the motion acceleration of this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   445
     * @return    the motion acceleration of this TuioContainer
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   446
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   447
    public float getMotionAccel() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   448
        return motion_accel;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   449
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   450
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   451
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   452
     * Returns the TUIO state of this TuioContainer.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   453
     * @return    the TUIO state of this TuioContainer
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   454
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   455
    public int getTuioState() {
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   456
        return state;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   457
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   458
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   459
    /**
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   460
     * Returns true of this TuioContainer is moving.
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   461
     * @return    true of this TuioContainer is moving
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   462
     */
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   463
    public boolean isMoving() { 
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   464
        if ((state==TUIO_ACCELERATING) || (state==TUIO_DECELERATING)) return true;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   465
        else return false;
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   466
    }
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   467
    
9ccef81f02ab Charset set to UTF-8 without bom
bastiena
parents: 10
diff changeset
   468
}