KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > piagetproject > property > WindowProperty


1 /*
2  * WindowProperty.java
3  *
4  * Created on July 27, 2005, 4:02 PM
5  *
6  * To change this template, choose Tools | Options and locate the template under
7  * the Source Creation and Management node. Right-click the template and choose
8  * Open. You can then make changes to the template in the Source Editor.
9  */

10
11 package org.netbeans.modules.piagetproject.property;
12
13 /**
14  *
15  * @author loicsegapelli
16  */

17 public class WindowProperty extends Property{
18     
19     long open, active;
20     
21     public WindowProperty(String JavaDoc key, String JavaDoc name, String JavaDoc value, String JavaDoc table){
22         super(key, table);
23         long [] myVal = getWindowTime((String JavaDoc)value);
24         open = myVal [0];
25         active = myVal [1];
26         if(name.equals(OUT)){
27             /*update static variable concerning total time using IDE*/
28             outTotal += myVal[1];
29         }
30         this.name = name;
31     }
32     
33
34     
35     private long [] getWindowTime(String JavaDoc time){
36         String JavaDoc s [] = time.split(" ");
37         long open = Long.parseLong(s[0]);
38         long acti = Long.parseLong(s[1]);
39         return new long[]{open, acti};
40     }
41     
42     public Object JavaDoc getValue(int counter){
43         double d1 = new Long JavaDoc(open).doubleValue() / counter;
44         double d2 = new Long JavaDoc(active).doubleValue() / counter;
45         
46         /* activeTotal = (time NB is opened) - (time IDE is NOT activated)*/
47         double activeTotal = new Long JavaDoc(ideTotal - outTotal).doubleValue()/counter;
48         d1 /= activeTotal;
49         d2 /= activeTotal;
50         return new double [] {d1, d2};
51     }
52     
53     protected void combineProperties(String JavaDoc key, String JavaDoc value){
54         long [] next = getWindowTime(value);
55         open += next[0];
56         active += next[1];
57     }
58     
59 }
60
Popular Tags