source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/events/AudioEvent.java @ 203

Revision 203, 1.9 KB checked in by jdalbey, 6 years ago (diff)

XMLWriter.java name changed to XMLBuilder. Add pretty printing methods (ticket #237).

Line 
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6package scriptbuilder.structures.events;
7
8import scriptbuilder.structures.ELEMENT;
9import scriptbuilder.structures.I_XML_Writable;
10import scriptbuilder.structures.ScriptEvent;
11import scriptbuilder.structures.XMLBuilder;
12
13/**
14 * Data model for an audio event. Audio events have a filepath leading to an
15 * audio file to be played, and a length in seconds of that file.
16 *
17 * @author Bryan McGuffin
18 */
19public class AudioEvent extends ScriptEvent implements I_XML_Writable
20{
21
22    /**
23     * Constructor.
24     */
25    public AudioEvent()
26    {
27        super(ScriptEventType.AUDIO_EVENT);
28    }
29   
30    /**
31     * Constructor with ID
32     * @param id AudioEvent ID
33     */
34    public AudioEvent(String id)
35    {
36        super(ScriptEventType.AUDIO_EVENT);
37        this.id = id;
38    }
39
40    /**
41     * Length of the audio to be played, in seconds.
42     */
43    public Integer audioLength = 0;
44
45    /**
46     * File path for the audio file. Perhaps should only be generated on save?
47     */
48    public String audioPath = "";
49   
50    /**
51     * id represents the audio file name that corresponds with the event
52     */
53     public String id = "";
54     
55    /**
56     * sets the audio path relative to the running directory.
57     * @param f filename
58     */
59   
60   
61   
62    public void setAudioFilePathRelative(String f)
63    {
64        audioPath = "audio/" + f + ".mp3";
65    }
66    /**
67     * sets audio path relative to the working directory using the id value.
68     */
69    public void setAudioFilePathRelative()
70    {
71        audioPath = "audio/" + id + ".mp3";
72    }
73   
74    @Override
75    public String toXML()
76    {
77        return XMLBuilder.emptyTag(ELEMENT.AUDIO.tag + " Length=\"" + audioLength + "\" Path=\"" + audioPath + "\"");
78    }
79}
Note: See TracBrowser for help on using the repository browser.