Warning: Can't use blame annotator:
svn blame failed on trunk/src/scriptbuilder/structures/ScriptEvent.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/ScriptEvent.java @ 7

Revision 7, 4.9 KB checked in by bmcguffin, 9 years ago (diff)

Renamed Interfaces in structures.events package from "*Interface" to "I_*"

RevLine 
1package scriptbuilder.structures;
2
3import java.util.Observable;
4import scriptbuilder.structures.events.*;
5
6/**
7 * A single script event. It has an event type, and a duration (in seconds) of
8 * at least 1. It is comparable based on event type.
9 *
10 * @author Greg Eddington <geddingt@calpoly.edu>
11 * @author Bryan McGuffin
12 * @version 2017/06/30
13 */
14public abstract class ScriptEvent extends Observable implements I_ScriptEvent
15{
16
17    /**
18     * Compare the Script Events based on their type enum.
19     *
20     * @param o the other script event to be compared
21     * @return -1, 0, or 1 depending on if this event's type comes before,
22     * simultaneously, or after the other event's type in the enum list
23     */
24    @Override
25    public int compareTo(Object a)
26    {
27        ScriptEvent o = (ScriptEvent) a;
28        return this.type.compareTo(o.type);
29    }
30   
31    @Override
32    public int getLength()
33    {
34        return length;
35    }
36
37    /**
38     * The different possible event types, ordered by event domain and then
39     * alphabetically. The string parameter of each type is the name of a .png
40     * image which will be used as an icon to represent that event type.
41     */
42    public static enum ScriptEventType
43    {
44        AUDIO_EVENT("Audio"),
45        CAD_EVENT("CAD"),
46        CCTV_EVENT("CCTV"),
47        CHP_RADIO_EVENT("CHPRadio"),
48        PARAMICS_EVENT("Paramics"),
49        TOW_EVENT("Tow"),
50        UNIT_EVENT("Unit"),
51        WITNESS_EVENT("Witness"),
52        MAINTENANCE_RADIO_EVENT("MaintenanceRadio"),
53        TMT_RADIO_EVENT("TMTRadio"),
54        TELEPHONE_EVENT("Telephone"),
55        ATMS_EVAL_EVENT("ATMSEval"),
56        ACTIVITY_LOG_EVAL_EVENT("ActivityLogEval"),
57        CAD_EVAL_EVENT("CADEval"),
58        CMS_EVAL_EVENT("CMSEval"),
59        FACILITATOR_EVAL_EVENT("FacilitatorEval"),
60        RADIO_EVAL_EVENT("RadioEval");
61
62        /**
63         * The file name of a PNG image to be used as the icon for this event
64         * type.
65         */
66        public String IMAGE_NAME;
67
68        private ScriptEventType(String image)
69        {
70            this.IMAGE_NAME = image;
71        }
72    }
73
74    /**
75     * The Event type, from the enum of ScriptEventType.
76     */
77    private ScriptEventType type;
78
79    /**
80     * Number of seconds this event lasts
81     */
82    public int length;
83
84    /**
85     * Constructor with type and length parameters.
86     *
87     * @param type The type of event.
88     * @param l the duration of the event in seconds.
89     */
90    public ScriptEvent(ScriptEventType type, int l)
91    {
92        this.type = type;
93        this.length = l;
94    }
95
96    /**
97     * Constructor with no length parameter. Event length will default to 1
98     * second.
99     *
100     * @param type The type of event.
101     */
102    public ScriptEvent(ScriptEventType type)
103    {
104        this.type = type;
105        this.length = 1;
106    }
107
108    /**
109     * Get the event type of this ScriptEvent.
110     *
111     * @return The enum type of the event
112     */
113    public ScriptEventType getScriptEventType()
114    {
115        return type;
116    }
117
118    /**
119     * Get the string representation of this event. This string will be used in
120     * the tooltip text when the user hover the mouse over this event.
121     *
122     * @return A string containing this event's type, and a STUB where its
123     * description will go later.
124     */
125    @Override
126    public String toString()
127    {
128        return this.type.toString() + " - [Event Description]";
129    }
130   
131    public static I_ScriptEvent factoryByType(ScriptEventType t)
132    {
133        switch(t)
134        {
135            case AUDIO_EVENT:
136                return new AudioEvent();
137            case CAD_EVENT:
138                return new CADEvent();
139            case CCTV_EVENT:
140                return new CCTVEvent();
141            case CHP_RADIO_EVENT:
142                return new CHPRadioEvent();
143            case PARAMICS_EVENT:
144                return new ParamicsEvent();
145            case TOW_EVENT:
146                return new TowEvent();
147            case UNIT_EVENT:
148                return new UnitEvent();
149            case WITNESS_EVENT:
150                return new WitnessEvent();
151            case MAINTENANCE_RADIO_EVENT:
152                return new MaintenanceRadioEvent();
153            case TMT_RADIO_EVENT:
154                return new TMTRadioEvent();
155            case TELEPHONE_EVENT:
156                return new TelephoneEvent();
157            case ATMS_EVAL_EVENT:
158                return new ATMSEvaluationEvent();
159            case ACTIVITY_LOG_EVAL_EVENT:
160                return new ActivityLogEvaluationEvent();
161            case CAD_EVAL_EVENT:
162                return new CADEvaluationEvent();
163            case CMS_EVAL_EVENT:
164                return new CMSEvaluationEvent();
165            case FACILITATOR_EVAL_EVENT:
166                return new FacilitatorEvaluationEvent();
167            case RADIO_EVAL_EVENT:
168                return new RadioEvaluationEvent();
169            default:
170                return new TelephoneEvent();
171        }           
172    }
173}
Note: See TracBrowser for help on using the repository browser.