source: trunk/src/org/expeditee/stats/CometStats.java@ 309

Last change on this file since 309 was 115, checked in by ra33, 16 years ago

added functionality for dockable @v's

File size: 2.7 KB
Line 
1package org.expeditee.stats;
2
3import java.sql.Time;
4
5import org.expeditee.gui.Frame;
6import org.expeditee.io.Logger;
7
8public class CometStats extends Stats{
9 protected int _sessions = 0;
10
11 protected String _name = null;
12
13 protected long _active = 0;
14
15 protected long _dark = 0;
16
17 public CometStats(Frame topFrame) {
18 _name = topFrame.getName();
19
20 _active = getFrameActiveTime().getTime()
21 + topFrame.getActiveTime().getTime();
22 _dark = getFrameDarkTime().getTime()
23 + topFrame.getDarkTime().getTime();
24 _sessions = topFrame.getVersion() + 1;
25 }
26
27 @Override
28 public String toString() {
29 Time total = new Time(_active + _dark);
30 Time active = new Time(_active);
31 Time dark = new Time(_dark);
32
33 StringBuffer sb = new StringBuffer();
34 sb.append(SessionStats.getDate());
35 sb.append("CometStats: ").append(_name).append('\n');
36 sb.append("Versions: ").append(_sessions).append('\n');
37 sb.append(String.format(" %c Current %c Average %c Total", SessionStats.COLUMN_SEPARATOR_CHAR,SessionStats.COLUMN_SEPARATOR_CHAR,SessionStats.COLUMN_SEPARATOR_CHAR)).append('\n');
38
39
40 StringBuffer rowSeparator = new StringBuffer();
41 rowSeparator.append(getBufferedString(10, ROW_SEPARATOR_CHAR));
42 for(int i=0;i<3;i++){
43 rowSeparator.append(ROW_COLUMN_SEPARATOR).append(getBufferedString(8, ROW_SEPARATOR_CHAR));
44 }
45 sb.append(rowSeparator).append('\n');
46
47
48 Time averageActive = new Time((long) (0.5 + active.getTime()
49 / (1.0 * _sessions)));
50 Time averageDark = new Time((long) (0.5 + dark.getTime()
51 / (1.0 * _sessions)));
52 Time averageTotal = new Time((long) (0.5 + total.getTime()
53 / (1.0 * _sessions)));
54 Time currentActive = SessionStats.getFrameActiveTime();
55 Time currentDark = SessionStats.getFrameDarkTime();
56 Time currentTotal = SessionStats.getFrameTotalTime();
57
58 sb.append("ActiveTime").append(COLUMN_SEPARATOR).append(Logger.EasyTimeFormat(currentActive))
59 .append(COLUMN_SEPARATOR).append(
60 Logger.EasyTimeFormat(averageActive)).append(
61 COLUMN_SEPARATOR).append(Logger.EasyTimeFormat(active))
62 .append('\n');
63 sb.append(" DarkTime").append(COLUMN_SEPARATOR).append(Logger.EasyTimeFormat(currentDark))
64 .append(COLUMN_SEPARATOR).append(
65 Logger.EasyTimeFormat(averageDark)).append(
66 COLUMN_SEPARATOR).append(Logger.EasyTimeFormat(dark))
67 .append('\n');
68 sb.append(" TotalTime").append(COLUMN_SEPARATOR).append(Logger.EasyTimeFormat(currentTotal))
69 .append(COLUMN_SEPARATOR).append(
70 Logger.EasyTimeFormat(averageTotal)).append(
71 COLUMN_SEPARATOR).append(Logger.EasyTimeFormat(total)).append('\n');
72 sb.append(rowSeparator.toString().replace(ROW_COLUMN_SEPARATOR_CHAR, BOTTOM_COLUMN_SEPARATOR_CHAR));
73 return sb.toString();
74 }
75}
Note: See TracBrowser for help on using the repository browser.