001: /*
002: * Jacareto Copyright (c) 2002-2005
003: * Applied Computer Science Research Group, Darmstadt University of
004: * Technology, Institute of Mathematics & Computer Science,
005: * Ludwigsburg University of Education, and Computer Based
006: * Learning Research Group, Aachen University. All rights reserved.
007: *
008: * Jacareto is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * Jacareto is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public
019: * License along with Jacareto; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package jacareto.record;
025:
026: import jacareto.system.Environment;
027:
028: /**
029: * This class represents input events which can be recorded.
030: *
031: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
032: * @version 1.0
033: */
034: public abstract class InputEventRecordable extends
035: ComponentEventRecordable {
036: /** The modifiers. */
037: private int modifiers;
038:
039: /** The time the event has occured. */
040: private long when;
041:
042: /** Whether the event is consumed or not. */
043: private boolean isConsumed;
044:
045: /**
046: * Creates a new input event recordable with the specified values.
047: *
048: * @param env the environment
049: * @param ID the event id
050: * @param sourceName the name of the event's source
051: * @param sourceClass the classname of the event's source
052: * @param duration the duration
053: * @param procTime DOCUMENT ME!
054: * @param componentName the component's name
055: * @param rootName the name of the root component
056: * @param modifiers the modifiers of the event
057: * @param when the time when the event has occured
058: * @param isConsumed whether the event is consumed or not
059: */
060: public InputEventRecordable(Environment env, int ID,
061: String sourceName, String sourceClass, long duration,
062: long procTime, String componentName, String rootName,
063: int modifiers, long when, boolean isConsumed) {
064: super (env, ID, sourceName, sourceClass, duration, procTime,
065: componentName, rootName);
066: setModifiers(modifiers);
067: setWhen(when);
068: setConsumed(isConsumed);
069: }
070:
071: /**
072: * Creates a input event recordable with default values and no environment. The environment
073: * should be defined with the method {@link
074: * jacareto.system.EnvironmentMember#setEnvironment(Environment)} before environment instances
075: * will be accessed.
076: */
077: public InputEventRecordable() {
078: this (null, 0, "", "", 0, 0, "", "", 0, 0, false);
079: }
080:
081: /**
082: * Sets the modifiers.
083: *
084: * @param modifiers the modifiers
085: */
086: public void setModifiers(int modifiers) {
087: this .modifiers = modifiers;
088: fireValuesChanged();
089: }
090:
091: /**
092: * Returns the modifiers.
093: *
094: * @return the modifiers
095: */
096: public int getModifiers() {
097: return modifiers;
098: }
099:
100: /**
101: * Sets the time when the event has occured.
102: *
103: * @param when the time when the event has occured
104: */
105: public void setWhen(long when) {
106: this .when = when;
107: fireValuesChanged();
108: }
109:
110: /**
111: * Returns the time the event has occured.
112: *
113: * @return when the event has occurder
114: */
115: public long getWhen() {
116: return when;
117: }
118:
119: /**
120: * Sets whether the event is consumed or not.
121: *
122: * @param isConsumed DOCUMENT ME!
123: */
124: public void setConsumed(boolean isConsumed) {
125: this .isConsumed = isConsumed;
126: fireValuesChanged();
127: }
128:
129: /**
130: * Returns whether the event is consumed or not
131: *
132: * @return DOCUMENT ME!
133: */
134: public boolean isConsumed() {
135: return isConsumed;
136: }
137:
138: /**
139: * Returns a string representation of the input event recordable.
140: *
141: * @return the string representation
142: */
143: public String toString() {
144: return "InputEventRecordable[" + getSourceName() + ",ID="
145: + getID() + ",when=" + getWhen() + ",modifiers="
146: + getModifiers() + "," + getDuration() + "]";
147: }
148: }
|