01: /*
02: * Jacareto Copyright (c) 2002-2005
03: * Applied Computer Science Research Group, Darmstadt University of
04: * Technology, Institute of Mathematics & Computer Science,
05: * Ludwigsburg University of Education, and Computer Based
06: * Learning Research Group, Aachen University. All rights reserved.
07: *
08: * Jacareto is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * Jacareto is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public
19: * License along with Jacareto; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: package jacareto.struct;
25:
26: import jacareto.system.Environment;
27:
28: /**
29: * This root element counts some structure elements.
30: *
31: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
32: * @version 1.0
33: */
34: public class CounterRootElement extends RootElement {
35: private String[] counterNames = { "drags", "dragtime", "clicks" };
36: private int[] counters = { 0, 0, 0 };
37:
38: /**
39: * Creates a new counter root structure element.
40: *
41: * @param env the environment
42: * @param children the child structure elements
43: */
44: public CounterRootElement(Environment env,
45: StructureElement[] children) {
46: super (env, children);
47: calculateValues();
48: }
49:
50: private void calculateValues() {
51: StructureElement[] dragChildren = getChildren("jacareto.struct.MouseDrag");
52: counters[0] = dragChildren.length;
53: counters[1] = 0;
54:
55: for (int i = 0; i < dragChildren.length; i++) {
56: counters[1] += dragChildren[i].getDuration();
57: }
58:
59: StructureElement[] clickChildren = getChildren("jacareto.struct.MouseClick");
60: counters[2] = clickChildren.length;
61: }
62:
63: /**
64: * Returns the names of the counters.
65: *
66: * @return the names as string array
67: */
68: public String[] getCounterNames() {
69: return counterNames;
70: }
71:
72: /**
73: * Returns the counters.
74: *
75: * @return the counters as integer array
76: */
77: public int[] getCounters() {
78: return counters;
79: }
80:
81: /**
82: * Clones the element.
83: *
84: * @return DOCUMENT ME!
85: */
86: public Object clone() {
87: StructureElement[] clonedChildren = getClonedChildren();
88:
89: return new CounterRootElement(env, clonedChildren);
90: }
91: }
|