package in.swapnilbhoite.projects.subtitlestudio;

/*
 * StopWatch.java
 */

public class StopWatch extends Thread 
{
    
    private long startTime = 0;
    private long stopTime = 0;
    private boolean running = false;
    public static int instance = 0;

    public void sstart() {
        this.startTime = System.currentTimeMillis() - correction;
        this.running = true;
    }

    public void sstop() {
        this.stopTime = System.currentTimeMillis();
        this.running = false;
    }

    //elaspsed time in milliseconds
    public long getElapsedTime() {
        long elapsed;
        if (running) {
             elapsed = (System.currentTimeMillis() - startTime);
        }
        else {
            elapsed = (stopTime - startTime);
        }
        return elapsed;
    }
    
    //elaspsed time in seconds
    public long getElapsedTimeSecs() {
        long elapsed;
        if (running) {
            elapsed = ((System.currentTimeMillis() - startTime) / 1000);
        }
        else {
            elapsed = ((stopTime - startTime) / 1000);
        }
        return elapsed;
    }
    
    public void displayTime()
    {
        this.start();
    }
    
    public void pauseSW()
    {
        correction = this.getElapsedTime();
        this.sstop();
    }
    
    public void resumeSW()
    {
        this.sstart();
    }
    
    @Override
    public void run()
    {
        this.sstart();
        
        if(instance == 0)
        {
            time1 = new MyTime();
            time2 = new MyTime();
            while(getElapsedTime() <= Creator.fileLength)
            {
                time1 = time1.toTime(getElapsedTime());
                Creator.jProgressBarPlayback.setValue((int)((100*getElapsedTime())/Creator.fileLength));
                Creator.jLabelDuration.setText(""+time1+" / "+time2.toTime(Creator.mediaPlayer.getLength()));
            }
        }
        else if(instance == 1)
        {
            //while(true)
                //Edit.jLabel5.setText(""+new MyTime().toTime(getElapsedTime()));
        }
    }
    MyTime time1, time2;
    long correction = 0;
}
@@ -50,32 +50,43 @@
 %0A%0A/*
-%0A * StopWatch.java
+*%0A *%0A * @author Swapnil Bhoite
 %0A */%0A
-%0A
 publ
@@ -123,15 +123,10 @@
 ead 
-%0A
 %7B%0A
-    
 %0A   
@@ -623,33 +623,32 @@
 ) %7B%0A            
- 
 elapsed = (Syste
@@ -688,32 +688,24 @@
 );%0A        %7D
-%0A       
  else %7B%0A    
@@ -782,28 +782,24 @@
 psed;%0A    %7D%0A
-    
 %0A    //elasp
@@ -980,32 +980,24 @@
 );%0A        %7D
-%0A       
  else %7B%0A    
@@ -1079,36 +1079,32 @@
  elapsed;%0A    %7D%0A
-    
 %0A    public void
@@ -1117,20 +1117,16 @@
 ayTime()
-%0A   
  %7B%0A     
@@ -1140,36 +1140,32 @@
 .start();%0A    %7D%0A
-    
 %0A    public void
@@ -1170,28 +1170,24 @@
 id pauseSW()
-%0A   
  %7B%0A        c
@@ -1245,28 +1245,24 @@
 op();%0A    %7D%0A
-    
 %0A    public 
@@ -1276,20 +1276,16 @@
 sumeSW()
-%0A   
  %7B%0A     
@@ -1308,20 +1308,16 @@
 ;%0A    %7D%0A
-    
 %0A    @Ov
@@ -1344,20 +1344,16 @@
 id run()
-%0A   
  %7B%0A     
@@ -1370,24 +1370,16 @@
 tart();%0A
-        
 %0A       
@@ -1381,16 +1381,17 @@
       if
+ 
 (instanc
@@ -1397,24 +1397,16 @@
 ce == 0)
-%0A       
  %7B%0A     
@@ -1485,16 +1485,17 @@
    while
+ 
 (getElap
@@ -1526,28 +1526,16 @@
 eLength)
-%0A           
  %7B%0A     
@@ -1648,14 +1648,17 @@
 int)
+ 
 ((100
-*
+ * 
 getE
@@ -1670,17 +1670,19 @@
 dTime())
-/
+ / 
 Creator.
@@ -1748,21 +1748,27 @@
 t(%22%22
-+
+ + 
 time1
-+
+ + 
 %22 / %22
-+
+ + 
 time
@@ -1838,24 +1838,16 @@
    %7D
-%0A       
  else if
 (ins
@@ -1842,16 +1842,17 @@
  else if
+ 
 (instanc
@@ -1858,24 +1858,16 @@
 ce == 1)
-%0A       
  %7B%0A     
@@ -1887,20 +1887,16 @@
 e(true)%0A
-    
         
@@ -2032,8 +2032,9 @@
 n = 0;%0A%7D
+%0A

Format StopWatch class