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.struct;
025:
026: import jacareto.parse.RecordTokenizer;
027: import jacareto.record.MouseEventRecordable;
028: import jacareto.system.Environment;
029:
030: import java.awt.event.MouseEvent;
031:
032: /**
033: * This structure element stands for a mouse exit.
034: *
035: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
036: * @version 1.01
037: */
038: public class MouseExited extends StructureElement {
039: /** The name of the component which has been exited. */
040: private String componentName;
041:
042: /**
043: * Creates a new "mouse exited" structure element. The last child must be the mouse exited
044: * event recordable.
045: *
046: * @param env the environment
047: * @param children the child structure elements
048: */
049: public MouseExited(Environment env, StructureElement[] children) {
050: super (env, children);
051:
052: // children[0] ? (also in the parse-method?)
053: this .componentName = ((MouseEventRecordable) children[children.length - 1])
054: .getSourceName();
055: }
056:
057: /**
058: * Creates a new "mouse exited" structure element.
059: *
060: * @param env the environment
061: * @param children the child structure elements
062: * @param componentName DOCUMENT ME!
063: */
064: public MouseExited(Environment env, StructureElement[] children,
065: String componentName) {
066: super (env, children);
067: this .componentName = componentName;
068: }
069:
070: /**
071: * Parses a record which is tokenized by the given record tokenizer.
072: *
073: * @param env DOCUMENT ME!
074: * @param recordTokenizer the record tokenizer
075: *
076: * @return a structure element, or <code>null</code> if this class cannot parse the record at
077: * the current position
078: */
079: public static StructureElement parse(Environment env,
080: RecordTokenizer recordTokenizer) {
081: int counter = 0;
082: StructureElement element;
083:
084: do {
085: element = recordTokenizer.get(counter);
086: counter++;
087: } while (element instanceof MouseEventRecordable
088: && (((MouseEventRecordable) element).getID() == MouseEvent.MOUSE_EXITED));
089:
090: // one too far
091: counter--;
092:
093: if (counter > 0) {
094: StructureElement[] children = new StructureElement[counter];
095:
096: for (int i = 0; i < counter; i++) {
097: children[i] = recordTokenizer.get(i);
098: }
099:
100: recordTokenizer.forward(counter);
101:
102: String componentName = ((MouseEventRecordable) children[children.length - 1])
103: .getSourceName();
104:
105: //return new MouseExited (env, children);
106: return new MouseExited(env, children, componentName);
107: } else {
108: return null;
109: }
110: }
111:
112: /**
113: * Returns the name of the element.
114: *
115: * @return the name
116: */
117: public String getElementName() {
118: return language.getString("Structures.MouseExited.Name");
119: }
120:
121: /**
122: * Returns a description of the element.
123: *
124: * @return the description
125: */
126: public String getElementDescription() {
127: return language.getString("Structures.MouseExited.Description");
128: }
129:
130: /**
131: * Returns a String which describes the content of the element shortly.
132: *
133: * @return a string with a short description of the element
134: */
135: public String toShortString() {
136: return getElementName();
137: }
138:
139: /**
140: * Returns the name of the component which has been exited.
141: *
142: * @return DOCUMENT ME!
143: */
144: public String getComponentName() {
145: return componentName;
146: }
147:
148: /**
149: * Clones the element.
150: *
151: * @return DOCUMENT ME!
152: */
153: public Object clone() {
154: StructureElement[] clonedChildren = getClonedChildren();
155:
156: return new MouseExited(env, clonedChildren, componentName);
157: }
158: }
|