front_processing/extern/TUIO_JAVA/src/TUIO/TuioTime.java
changeset 9 0f44b7360c8d
parent 0 6fefd4afe506
child 10 925b7ee746e3
--- a/front_processing/extern/TUIO_JAVA/src/TUIO/TuioTime.java	Thu Mar 22 16:00:17 2012 +0100
+++ b/front_processing/extern/TUIO_JAVA/src/TUIO/TuioTime.java	Thu Mar 22 18:15:53 2012 +0100
@@ -1,8 +1,8 @@
-/*
-	TUIO Java backend - part of the reacTIVision project
-	http://reactivision.sourceforge.net/
+/*
+    TUIO Java backend - part of the reacTIVision project
+    http://reactivision.sourceforge.net/
 
-	Copyright (c) 2005-2009 Martin Kaltenbrunner <mkalten@iua.upf.edu>
+    Copyright (c) 2005-2009 Martin Kaltenbrunner <mkalten@iua.upf.edu>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -33,204 +33,204 @@
  */ 
 public class TuioTime {
 
-	/**
-	 * the time since session start in seconds  
-	 */ 
-	private long seconds = 0;
-	/**
-	 * time fraction in microseconds  
-	 */ 
-	private long  micro_seconds = 0;
-	/**
-	 * the session start time in seconds
-	 */ 
-	private static long start_seconds = 0;
-	/**
-	 * start time fraction in microseconds
-	 */ 
-	private static long start_micro_seconds = 0;
-	
-	/**
-	 * The default constructor takes no arguments and sets   
-	 * the Seconds and Microseconds attributes of the newly created TuioTime both to zero.
-	 */
-	public TuioTime () {
-		this.seconds = 0;
-		this.micro_seconds = 0;
-	}
-	
-	/**
-	 * This constructor takes the provided time represented in total Milliseconds 
-	 * and assigs this value to the newly created TuioTime.
-	 *
-	 * @param  msec  the total time in Millseconds
-	 */
-	public TuioTime (long msec) {
-		this.seconds = msec/1000;
-		this.micro_seconds = 1000*(msec%1000);
-	}
-	
-	/**
-	 * This constructor takes the provided time represented in Seconds and Microseconds   
-	 * and assigs these value to the newly created TuioTime.
-	 *
-	 * @param  sec  the total time in seconds
-	 * @param  usec	the microseconds time component
-	 */	
-	public TuioTime (long sec, long usec) {
-		this.seconds = sec;
-		this.micro_seconds = usec;
-	}
+    /**
+     * the time since session start in seconds  
+     */ 
+    private long seconds = 0;
+    /**
+     * time fraction in microseconds  
+     */ 
+    private long  micro_seconds = 0;
+    /**
+     * the session start time in seconds
+     */ 
+    private static long start_seconds = 0;
+    /**
+     * start time fraction in microseconds
+     */ 
+    private static long start_micro_seconds = 0;
+    
+    /**
+     * The default constructor takes no arguments and sets   
+     * the Seconds and Microseconds attributes of the newly created TuioTime both to zero.
+     */
+    public TuioTime () {
+        this.seconds = 0;
+        this.micro_seconds = 0;
+    }
+    
+    /**
+     * This constructor takes the provided time represented in total Milliseconds 
+     * and assigs this value to the newly created TuioTime.
+     *
+     * @param  msec  the total time in Millseconds
+     */
+    public TuioTime (long msec) {
+        this.seconds = msec/1000;
+        this.micro_seconds = 1000*(msec%1000);
+    }
+    
+    /**
+     * This constructor takes the provided time represented in Seconds and Microseconds   
+     * and assigs these value to the newly created TuioTime.
+     *
+     * @param  sec  the total time in seconds
+     * @param  usec    the microseconds time component
+     */    
+    public TuioTime (long sec, long usec) {
+        this.seconds = sec;
+        this.micro_seconds = usec;
+    }
 
-	/**
-	 * This constructor takes the provided TuioTime   
-	 * and assigs its Seconds and Microseconds values to the newly created TuioTime.
-	 *
-	 * @param  ttime  the TuioTime used to copy
-	 */	
-	public TuioTime (TuioTime ttime) {
-		this.seconds = ttime.getSeconds();
-		this.micro_seconds = ttime.getMicroseconds();
-	}
-	
-	/**
-	 * Sums the provided time value represented in total Microseconds to this TuioTime.
-	 *
-	 * @param  us	the total time to add in Microseconds
-	 * @return the sum of this TuioTime with the provided argument in microseconds
-	*/	
-	public TuioTime add(long us) {
-		long sec = seconds + us/1000000;
-		long usec = micro_seconds + us%1000000;
-		return new TuioTime(sec,usec);
-	}
+    /**
+     * This constructor takes the provided TuioTime   
+     * and assigs its Seconds and Microseconds values to the newly created TuioTime.
+     *
+     * @param  ttime  the TuioTime used to copy
+     */    
+    public TuioTime (TuioTime ttime) {
+        this.seconds = ttime.getSeconds();
+        this.micro_seconds = ttime.getMicroseconds();
+    }
+    
+    /**
+     * Sums the provided time value represented in total Microseconds to this TuioTime.
+     *
+     * @param  us    the total time to add in Microseconds
+     * @return the sum of this TuioTime with the provided argument in microseconds
+    */    
+    public TuioTime add(long us) {
+        long sec = seconds + us/1000000;
+        long usec = micro_seconds + us%1000000;
+        return new TuioTime(sec,usec);
+    }
 
-	/**
-	 * Sums the provided TuioTime to the private Seconds and Microseconds attributes.  
-	 *
-	 * @param  ttime	the TuioTime to add
-	 * @return the sum of this TuioTime with the provided TuioTime argument
-	 */
-	public TuioTime add(TuioTime ttime) {
-		long sec = seconds + ttime.getSeconds();
-		long usec = micro_seconds + ttime.getMicroseconds();
-		sec += usec/1000000;
-		usec = usec%1000000;
-		return new TuioTime(sec,usec);
-	}
+    /**
+     * Sums the provided TuioTime to the private Seconds and Microseconds attributes.  
+     *
+     * @param  ttime    the TuioTime to add
+     * @return the sum of this TuioTime with the provided TuioTime argument
+     */
+    public TuioTime add(TuioTime ttime) {
+        long sec = seconds + ttime.getSeconds();
+        long usec = micro_seconds + ttime.getMicroseconds();
+        sec += usec/1000000;
+        usec = usec%1000000;
+        return new TuioTime(sec,usec);
+    }
 
-	/**
-	 * Subtracts the provided time represented in Microseconds from the private Seconds and Microseconds attributes.
-	 *
-	 * @param  us	the total time to subtract in Microseconds
-	 * @return the subtraction result of this TuioTime minus the provided time in Microseconds
-	 */		
-	public TuioTime subtract(long us) {
-		long sec = seconds - us/1000000;
-		long usec = micro_seconds - us%1000000;
-		
-		if (usec<0) {
-			usec += 1000000;
-			sec--;
-		}			
-		
-		return new TuioTime(sec,usec);
-	}
+    /**
+     * Subtracts the provided time represented in Microseconds from the private Seconds and Microseconds attributes.
+     *
+     * @param  us    the total time to subtract in Microseconds
+     * @return the subtraction result of this TuioTime minus the provided time in Microseconds
+     */        
+    public TuioTime subtract(long us) {
+        long sec = seconds - us/1000000;
+        long usec = micro_seconds - us%1000000;
+        
+        if (usec<0) {
+            usec += 1000000;
+            sec--;
+        }            
+        
+        return new TuioTime(sec,usec);
+    }
 
-	/**
-	 * Subtracts the provided TuioTime from the private Seconds and Microseconds attributes.
-	 *
-	 * @param  ttime	the TuioTime to subtract
-	 * @return the subtraction result of this TuioTime minus the provided TuioTime
-	 */	
-	public TuioTime subtract(TuioTime ttime) {
-		long sec = seconds - ttime.getSeconds();
-		long usec = micro_seconds - ttime.getMicroseconds();
-		
-		if (usec<0) {
-			usec += 1000000;
-			sec--;
-		}
-		
-		return new TuioTime(sec,usec);
-	}
+    /**
+     * Subtracts the provided TuioTime from the private Seconds and Microseconds attributes.
+     *
+     * @param  ttime    the TuioTime to subtract
+     * @return the subtraction result of this TuioTime minus the provided TuioTime
+     */    
+    public TuioTime subtract(TuioTime ttime) {
+        long sec = seconds - ttime.getSeconds();
+        long usec = micro_seconds - ttime.getMicroseconds();
+        
+        if (usec<0) {
+            usec += 1000000;
+            sec--;
+        }
+        
+        return new TuioTime(sec,usec);
+    }
 
-	/**
-	 * Takes a TuioTime argument and compares the provided TuioTime to the private Seconds and Microseconds attributes.
-	 *
-	 * @param  ttime	the TuioTime to compare
-	 * @return true if the two TuioTime have equal Seconds and Microseconds attributes
-	 */	
-	public boolean equals(TuioTime ttime) {
-		if ((seconds==ttime.getSeconds()) && (micro_seconds==ttime.getMicroseconds())) return true;
-		else return false;
-	}
+    /**
+     * Takes a TuioTime argument and compares the provided TuioTime to the private Seconds and Microseconds attributes.
+     *
+     * @param  ttime    the TuioTime to compare
+     * @return true if the two TuioTime have equal Seconds and Microseconds attributes
+     */    
+    public boolean equals(TuioTime ttime) {
+        if ((seconds==ttime.getSeconds()) && (micro_seconds==ttime.getMicroseconds())) return true;
+        else return false;
+    }
 
-	/**
-	 * Resets the seconds and micro_seconds attributes to zero.
-	 */
-	public void reset() {
-		seconds = 0;
-		micro_seconds = 0;
-	}
+    /**
+     * Resets the seconds and micro_seconds attributes to zero.
+     */
+    public void reset() {
+        seconds = 0;
+        micro_seconds = 0;
+    }
 
-	/**
-	 * Returns the TuioTime Seconds component.
-	 * @return the TuioTime Seconds component
-	 */	
-	public long getSeconds() {
-		return seconds;
-	}
+    /**
+     * Returns the TuioTime Seconds component.
+     * @return the TuioTime Seconds component
+     */    
+    public long getSeconds() {
+        return seconds;
+    }
 
-	/**
-	 * Returns the TuioTime Microseconds component.
-	 * @return the TuioTime Microseconds component
-	 */	
-	public long getMicroseconds() {
-		return micro_seconds;
-	}
+    /**
+     * Returns the TuioTime Microseconds component.
+     * @return the TuioTime Microseconds component
+     */    
+    public long getMicroseconds() {
+        return micro_seconds;
+    }
 
-	/**
-	 * Returns the total TuioTime in Milliseconds.
-	 * @return the total TuioTime in Milliseconds
-	 */	
-	public long getTotalMilliseconds() {
-		return seconds*1000+micro_seconds/1000;
-	}
+    /**
+     * Returns the total TuioTime in Milliseconds.
+     * @return the total TuioTime in Milliseconds
+     */    
+    public long getTotalMilliseconds() {
+        return seconds*1000+micro_seconds/1000;
+    }
 
-	/**
-	 * This static method globally resets the TUIO session time.
-	 */		
-	public static void initSession() {
-		TuioTime startTime = getSystemTime();
-		start_seconds = startTime.getSeconds();
-		start_micro_seconds = startTime.getMicroseconds();
-	}
+    /**
+     * This static method globally resets the TUIO session time.
+     */        
+    public static void initSession() {
+        TuioTime startTime = getSystemTime();
+        start_seconds = startTime.getSeconds();
+        start_micro_seconds = startTime.getMicroseconds();
+    }
 
-	/**
-	 * Returns the present TuioTime representing the time since session start.
-	 * @return the present TuioTime representing the time since session start
-	 */	
-	public static TuioTime getSessionTime() {
-		TuioTime sessionTime = getSystemTime().subtract(getStartTime());
-		return sessionTime;
-	
-	}
+    /**
+     * Returns the present TuioTime representing the time since session start.
+     * @return the present TuioTime representing the time since session start
+     */    
+    public static TuioTime getSessionTime() {
+        TuioTime sessionTime = getSystemTime().subtract(getStartTime());
+        return sessionTime;
+    
+    }
 
-	/**
-	 * Returns the absolut TuioTime representing the session start.
-	 * @return the absolut TuioTime representing the session start
-	 */	
-	public static TuioTime getStartTime() {
-		return new TuioTime(start_seconds,start_micro_seconds);
-	}
-		
-	/**
-	 * Returns the absolut TuioTime representing the current system time.
-	 * @return the absolut TuioTime representing the current system time
-	 */	
-	public static TuioTime getSystemTime() {
-		long usec = System.nanoTime()/1000;
-		return new TuioTime(usec/1000000,usec%1000000);
-	}
+    /**
+     * Returns the absolut TuioTime representing the session start.
+     * @return the absolut TuioTime representing the session start
+     */    
+    public static TuioTime getStartTime() {
+        return new TuioTime(start_seconds,start_micro_seconds);
+    }
+        
+    /**
+     * Returns the absolut TuioTime representing the current system time.
+     * @return the absolut TuioTime representing the current system time
+     */    
+    public static TuioTime getSystemTime() {
+        long usec = System.nanoTime()/1000;
+        return new TuioTime(usec/1000000,usec%1000000);
+    }
 }