- Timestamp:
- 07/28/2017 04:37:57 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/scriptbuilder/structures/TimeSlice.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/TimeSlice.java
r16 r21 1 1 package scriptbuilder.structures; 2 2 3 import java.text.SimpleDateFormat; 3 4 import java.util.ArrayList; 4 5 import java.util.Collections; 6 import java.util.Date; 5 7 import java.util.List; 8 import java.util.TimeZone; 6 9 import scriptbuilder.gui.ScriptBuilderGuiConstants; 7 10 import scriptbuilder.structures.events.I_ScriptEvent; … … 16 19 * @version 2017/06/30 17 20 */ 18 public class TimeSlice implements Comparable 21 public class TimeSlice implements Comparable, I_XML_Writable 19 22 { 20 23 21 //Events which occur at this instance 24 /** 25 * Reference to the incident which contains this timeslice. 26 */ 27 private ScriptIncident thisIncident; 28 22 29 /** 23 30 * List of Script Events which begin at this instance. … … 33 40 * that this timeslice occurs 34 41 */ 35 public TimeSlice(int seconds )42 public TimeSlice(int seconds, ScriptIncident inc) 36 43 { 37 44 this.seconds = seconds; 38 45 events = new ArrayList<I_ScriptEvent>(); 46 thisIncident = inc; 39 47 } 40 48 … … 183 191 return 0; 184 192 } 185 186 } 187 188 /** 189 * Stub method. Converts the contents of this timeslice to a correctly 193 } 194 195 /** 196 * Converts the contents of this timeslice to a correctly 190 197 * formatted <ScriptEvent> XML element. 191 198 * 192 199 * @return XML conversion of this timeslice. 193 200 */ 201 @Override 194 202 public String toXML() 195 203 { 196 // stub 197 return "<EVENT GROUP>STUB</EVENT GROUP>"; 204 System.out.println("Seconds:: " + seconds); 205 String output = openTag(ELEMENT.SCRIPT_EVENT.tag); 206 SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); 207 df.setTimeZone(TimeZone.getTimeZone("GMT")); 208 output += openTag(ELEMENT.TIME_INDEX.tag) + df.format(new Date(seconds * 1000)) 209 + closeTag(ELEMENT.TIME_INDEX.tag); 210 211 output += openTag(ELEMENT.INCIDENT.tag + " LogNum=\"" + thisIncident.number + "\""); 212 output += thisIncident.name + closeTag(ELEMENT.INCIDENT.tag); 213 214 for (I_ScriptEvent ev : events) 215 { 216 if (ev instanceof I_XML_Writable) 217 { 218 I_XML_Writable ex = (I_XML_Writable) ev; 219 output += ex.toXML(); 220 } 221 } 222 output += closeTag(ELEMENT.SCRIPT_EVENT.tag); 223 System.out.println(output); 224 return output; 225 } 226 227 @Override 228 public String openTag(String s) 229 { 230 return "<" + s + ">\n"; 231 } 232 233 @Override 234 public String closeTag(String s) 235 { 236 return "</" + s + ">\n"; 237 } 238 239 @Override 240 public String emptyTag(String s) 241 { 242 return "<" + s + "/>\n"; 198 243 } 199 244 }
Note: See TracChangeset
for help on using the changeset viewer.
