List of usage examples for org.jdom2 Element getChildText
public String getChildText(final String cname)
From source file:isjexecact.AppSettings.java
/** * Carrega os valores do arquivo de configurao para AppSeting ambiente. *//from ww w . j a va2 s .co m * @throws org.jdom2.JDOMException * @throws java.io.IOException */ public void loadDefaultSetings() throws JDOMException, IOException { SAXBuilder builder = new SAXBuilder(); //Document doc = builder.build("c:/TMPGED/teste.xml"); Document doc = builder.build(appFileName); Element xmllei = doc.getRootElement(); List<Element> lista = xmllei.getChildren(); for (Element e : lista) { setValue(e.getAttributeValue("id"), e.getChildText("valor")); // System.out.println("Chave: "+ e.getAttributeValue("id")); // System.out.println("Valor: " + e.getChildText("valor")); } }
From source file:jmri.jmrit.vsdecoder.ConfigurableSound.java
License:Open Source License
public void setXml(Element e, VSDFile vf) { this.setName(this.getName() + e.getAttributeValue("name")); log.debug("ConfigurableSound: " + e.getAttributeValue("name")); //log.debug(" start file: " + e.getChildText("start-file")); if (((start_file = e.getChildText("start-file")) != null) && !(start_file.equals(""))) { use_start_sound = true;/*from w w w . j a v a2 s . c om*/ } else { use_start_sound = false; } //log.debug(" mid file: " + e.getChildText("mid-file")); if (((mid_file = e.getChildText("mid-file")) != null) && !(mid_file.equals(""))) { use_mid_sound = true; } else { use_mid_sound = false; } //log.debug(" end file: " + e.getChildText("end-file")); if (((end_file = e.getChildText("end-file")) != null) && !(end_file.equals(""))) { use_end_sound = true; } else { use_end_sound = false; } //log.debug(" short file: " + e.getChildText("short-file")); if (((short_file = e.getChildText("short-file")) != null) && !(short_file.equals(""))) { use_short_sound = true; } else { use_short_sound = false; } //log.debug(" start sound dur: " + e.getChildText("start-sound-duration")); String ssd = e.getChildText("start-sound-duration"); if ((ssd != null) && !(ssd.equals(""))) { start_sound_duration = Integer.parseInt(ssd); } else { start_sound_duration = 0; } //log.debug(" gain: " + e.getChildText("gain")); String g = e.getChildText("gain"); if ((g != null) && !(g.equals(""))) { gain = Float.parseFloat(g); } else { gain = default_gain; } /* log.debug("Use: start = " + use_start_sound + "mid = " + use_mid_sound + "end = " + use_end_sound + "short = " + use_short_sound); */ // Reboot the sound initialized = false; this.init(vf); }
From source file:jmri.jmrit.vsdecoder.Diesel2Sound.java
License:Open Source License
@Override public void setXml(Element e, VSDFile vf) { Element el; String fn;/*from ww w.ja va 2 s . co m*/ NotchSound sb; // Handle the common stuff. super.setXml(e, vf); log.debug("Diesel EngineSound: " + e.getAttribute("name").getValue()); notch_sounds = new HashMap<Integer, NotchSound>(); // Get the notch sounds Iterator<Element> itr = (e.getChildren("notch-sound")).iterator(); int i = 0; while (itr.hasNext()) { el = itr.next(); fn = el.getChildText("file"); int nn = Integer.parseInt(el.getChildText("notch")); //log.debug("Notch: " + nn + " File: " + fn); sb = new NotchSound(vf, fn, "Engine_n" + i, "Engine_" + i); sb.setLooped(true); sb.setFadeTimes(this.getFadeInTime(), this.getFadeOutTime()); sb.setGain(setXMLGain(el)); sb.setNextNotch(el.getChildText("next-notch")); sb.setPrevNotch(el.getChildText("prev-notch")); sb.setAccelLimit(el.getChildText("accel-limit")); sb.setDecelLimit(el.getChildText("decel-limit")); if (el.getChildText("accel-file") != null) { sb.setAccelSound( new SoundBite(vf, el.getChildText("accel-file"), "Engine_na" + i, "Engine_na" + i)); } else { sb.setAccelSound(null); } if (el.getChildText("decel-file") != null) { sb.setDecelSound( new SoundBite(vf, el.getChildText("decel-file"), "Engine_nd" + i, "Engine_nd" + i)); } else { sb.setDecelSound(null); } // Store in the list. notch_sounds.put(nn, sb); i++; } // Get the start and stop sounds el = e.getChild("start-sound"); if (el != null) { fn = el.getChild("file").getValue(); //log.debug("Start sound: " + fn); start_sound = new SoundBite(vf, fn, "Engine_start", "Engine_Start"); // Handle gain start_sound.setGain(setXMLGain(el)); start_sound.setFadeTimes(this.getFadeInTime(), this.getFadeOutTime()); start_sound.setLooped(false); } el = e.getChild("shutdown-sound"); if (el != null) { fn = el.getChild("file").getValue(); //log.debug("Shutdown sound: " + fn); shutdown_sound = new SoundBite(vf, fn, "Engine_shutdown", "Engine_Shutdown"); shutdown_sound.setLooped(false); // Handle gain shutdown_sound.setGain(setXMLGain(el)); shutdown_sound.setFadeTimes(this.getFadeInTime(), this.getFadeOutTime()); } }
From source file:jmri.jmrit.vsdecoder.Diesel3Sound.java
License:Open Source License
@Override public void setXml(Element e, VSDFile vf) { Element el;/*w ww .j av a2 s. c o m*/ String fn; D3Notch sb; // Handle the common stuff. super.setXml(e, vf); //log.debug("Diesel EngineSound: " + e.getAttribute("name").getValue()); _soundName = this.getName() + ":LoopSound"; log.debug("Diesel3: name: " + this.getName() + " soundName " + _soundName); notch_sounds = new HashMap<Integer, D3Notch>(); String in = e.getChildText("idle-notch"); Integer idle_notch = null; if (in != null) { idle_notch = Integer.parseInt(in); } else { // leave idle_notch null for now. We'll use it at the end to trigger a "grandfathering" action log.warn("No Idle Notch Specified!"); } // Get the notch sounds Iterator<Element> itr = (e.getChildren("notch-sound")).iterator(); int i = 0; while (itr.hasNext()) { el = itr.next(); sb = new D3Notch(); int nn = Integer.parseInt(el.getChildText("notch")); sb.setNotch(nn); if ((idle_notch != null) && (nn == idle_notch)) { sb.setIdleNotch(true); log.debug("This Notch (" + nn + ") is Idle."); } List<Element> elist = el.getChildren("file"); int j = 0; for (Element fe : elist) { fn = fe.getText(); //AudioBuffer b = D3Notch.getBuffer(vf, fn, "Engine_n" + i + "_" + j, "Engine_" + i + "_" + j); //log.debug("Buffer created: " + b + " name: " + b.getSystemName()); //sb.addLoopBuffer(b); List<AudioBuffer> l = D3Notch.getBufferList(vf, fn, "Engine_n" + i + "_" + j, "Engine_" + i + "_" + j); log.debug("Buffers Created: "); for (AudioBuffer b : l) { log.debug("\tSubBuffer: " + b.getSystemName()); } sb.addLoopBuffers(l); j++; } //log.debug("Notch: " + nn + " File: " + fn); // Gain is broken, for the moment. Buffers don't have gain. Sources do. //_sound.setGain(setXMLGain(el)); //_sound.setGain(default_gain); sb.setNextNotch(el.getChildText("next-notch")); sb.setPrevNotch(el.getChildText("prev-notch")); sb.setAccelLimit(el.getChildText("accel-limit")); sb.setDecelLimit(el.getChildText("decel-limit")); if (el.getChildText("accel-file") != null) { sb.setAccelBuffer( D3Notch.getBuffer(vf, el.getChildText("accel-file"), "Engine_na" + i, "Engine_na" + i)); } else { sb.setAccelBuffer(null); } if (el.getChildText("decel-file") != null) { sb.setDecelBuffer( D3Notch.getBuffer(vf, el.getChildText("decel-file"), "Engine_nd" + i, "Engine_nd" + i)); } else { sb.setDecelBuffer(null); } // Store in the list. notch_sounds.put(nn, sb); i++; } // Get the start and stop sounds el = e.getChild("start-sound"); if (el != null) { fn = el.getChild("file").getValue(); //log.debug("Start sound: " + fn); start_buffer = D3Notch.getBuffer(vf, fn, "Engine_start", "Engine_Start"); } el = e.getChild("shutdown-sound"); if (el != null) { fn = el.getChild("file").getValue(); //log.debug("Shutdown sound: " + fn); stop_buffer = D3Notch.getBuffer(vf, fn, "Engine_shutdown", "Engine_Shutdown"); } // Handle "grandfathering the idle notch indication // If the VSD designer did not explicitly designate an idle notch... // Find the Notch with the lowest notch number, and make it the idle notch. // If there's a tie, this will take the first value, but the notches /should/ // all have unique notch numbers. if (idle_notch == null) { D3Notch min_notch = null; // No, this is not a terribly efficient "min" operation. But that's OK. for (D3Notch n : notch_sounds.values()) { if ((min_notch == null) || (n.getNotch() < min_notch.getNotch())) { min_notch = n; } } log.debug("No Idle Notch Specified. Choosing Notch (" + (min_notch != null ? min_notch.getNotch() : "min_notch not set") + ") to be the Idle Notch."); if (min_notch != null) { min_notch.setIdleNotch(true); } else { log.warn("Could not set idle notch because min_notch was still null"); } } // Kick-start the loop thread. this.startThread(); }
From source file:jmri.jmrit.vsdecoder.DieselSound.java
License:Open Source License
@Override public void setXml(Element e, VSDFile vf) { Element el; //int num_notches; String fn;/*from ww w .ja v a 2 s . c om*/ SoundBite sb; // Handle the common stuff. super.setXml(e, vf); log.debug("Diesel EngineSound: " + e.getAttribute("name").getValue()); notch_sounds = new HashMap<Integer, SoundBite>(); transition_sounds = new ArrayList<NotchTransition>(); // Get the notch sounds Iterator<Element> itr = (e.getChildren("notch-sound")).iterator(); int i = 0; while (itr.hasNext()) { el = itr.next(); fn = el.getChildText("file"); int nn = Integer.parseInt(el.getChildText("notch")); //log.debug("Notch: " + nn + " File: " + fn); sb = new SoundBite(vf, fn, "Engine_n" + i, "Engine_" + i); sb.setLooped(true); sb.setFadeTimes(this.getFadeInTime(), this.getFadeOutTime()); sb.setGain(setXMLGain(el)); // Store in the list. notch_sounds.put(nn, sb); i++; } // Get the notch transitions itr = (e.getChildren("notch-transition")).iterator(); i = 0; NotchTransition nt; while (itr.hasNext()) { el = itr.next(); fn = el.getChildText("file"); nt = new NotchTransition(vf, fn, "Engine_nt" + i, "Engine_nt" + i); nt.setPrevNotch(Integer.parseInt(el.getChildText("prev-notch"))); nt.setNextNotch(Integer.parseInt(el.getChildText("next-notch"))); //log.debug("Transition: prev=" + nt.getPrevNotch() + " next=" + nt.getNextNotch() + " File: " + fn); nt.setLooped(false); nt.setFadeTimes(this.getFadeInTime(), this.getFadeOutTime()); // Handle gain nt.setGain(setXMLGain(el)); transition_sounds.add(nt); i++; } // Get the start and stop sounds el = e.getChild("start-sound"); if (el != null) { fn = el.getChild("file").getValue(); //log.debug("Start sound: " + fn); start_sound = new SoundBite(vf, fn, "Engine_start", "Engine_Start"); // Handle gain start_sound.setGain(setXMLGain(el)); start_sound.setFadeTimes(this.getFadeInTime(), this.getFadeOutTime()); start_sound.setLooped(false); } el = e.getChild("shutdown-sound"); if (el != null) { fn = el.getChild("file").getValue(); //log.debug("Shutdown sound: " + fn); shutdown_sound = new SoundBite(vf, fn, "Engine_shutdown", "Engine_Shutdown"); shutdown_sound.setLooped(false); // Handle gain shutdown_sound.setGain(setXMLGain(el)); shutdown_sound.setFadeTimes(this.getFadeInTime(), this.getFadeOutTime()); } }
From source file:jmri.jmrit.vsdecoder.EngineSound.java
License:Open Source License
protected float setXMLGain(Element e) { String g = e.getChildText("gain"); log.debug(" gain: " + g); if ((g != null) && !(g.equals(""))) { return (Float.parseFloat(g)); } else {/*from w ww .j av a 2 s . c om*/ return (default_gain); } }
From source file:jmri.jmrit.vsdecoder.EngineSound.java
License:Open Source License
public void setXml(Element e, VSDFile vf) { // Do only the stuff common... if (this.getName() == null) { this.setName(e.getAttributeValue("name")); }//from w w w . j ava 2s. c o m //log.debug("EngineSound: " + this.getName()); this.setFadeInTime(e.getChildText("fade-in-time")); this.setFadeOutTime(e.getChildText("fade-out-time")); log.debug("Name: " + this.getName() + "Fade-In-Time: " + this.getFadeInTime() + " Fade-Out-Time: " + this.getFadeOutTime()); }
From source file:jmri.jmrit.vsdecoder.Steam1Sound.java
License:Open Source License
@Override public void setXml(Element e, VSDFile vf) { Element el;// w ww . j a va2 s .c o m String fn, n; S1Notch sb; // Handle the common stuff super.setXml(e, vf); _soundName = this.getName(); log.debug("Steam1: name: {}, soundName: {}", this.getName(), _soundName); // Required values top_speed = Integer.parseInt(e.getChildText("top-speed")); log.debug("top speed forward: {} MPH", top_speed); // Optional value // Steam locos can have different top speed reverse. n = e.getChildText("top-speed-reverse"); // Optional value. if (n != null) { top_speed_reverse = Integer.parseInt(n); } else { top_speed_reverse = top_speed; // Default for top_speed_reverse! } log.debug("top speed reverse: {} MPH", top_speed_reverse); driver_diameter_float = Float.parseFloat(e.getChildText("driver-diameter-float")); log.debug("driver diameter: {} inches", driver_diameter_float); num_cylinders = Integer.parseInt(e.getChildText("cylinders")); log.debug("Number of cylinders defined: {}", num_cylinders); // Optional value // Allows to adjust speed n = e.getChildText("exponent"); // Optional value if (n != null) { exponent = Float.parseFloat(n); } else { exponent = 1.0f; // Default } log.debug("exponent: {}", exponent); // Optional value // Acceleration and deceleration rate n = e.getChildText("accel-rate"); // Optional value if (n != null) { accel_rate = Integer.parseInt(n); } else { accel_rate = 35; // Default } log.debug("accel rate: {}", accel_rate); n = e.getChildText("decel-rate"); // Optional value if (n != null) { decel_rate = Integer.parseInt(n); } else { decel_rate = 18; // Default } log.debug("decel rate: {}", decel_rate); n = e.getChildText("brake-time"); // Optional value if (n != null) { brake_time = Integer.parseInt(n); } else { brake_time = 0; // Default } log.debug("brake time: {}", brake_time); // Optional value // auto-start is_auto_start = setXMLAutoStart(e); log.debug("config auto-start: {}", is_auto_start); // Optional value // Allows to adjust OpenAL attenuation // Sounds with distance to listener position lower than reference-distance will not have attenuation engine_rd = setXMLReferenceDistance(e); // Handle reference distance log.debug("engine-sound referenceDistance: {}", engine_rd); // Optional value // Allows to adjust the engine gain n = e.getChildText("engine-gain"); if ((n != null) && (!n.isEmpty())) { engine_gain = Float.parseFloat(n); // Make some restrictions, since engine_gain is used for calculations later if ((engine_gain < default_gain - 0.4f) || (engine_gain > default_gain + 0.2f)) { log.info("Invalid engine gain {} was set to default {}", engine_gain, default_gain); engine_gain = default_gain; } } else { engine_gain = default_gain; } log.debug("engine gain: {}", engine_gain); // Optional value // Defines how many rpms in 0.5 seconds will trigger decel actions like braking n = e.getChildText("decel-trigger-rpms"); if (n != null) { decel_trigger_rpms = Integer.parseInt(n); } else { decel_trigger_rpms = 999; // Default (need a value) } log.debug("number of rpms to trigger decelerating actions: {}", decel_trigger_rpms); // Get the sounds. // Note: each sound must have equal attributes, e.g. 16-bit, 44100 Hz // Get the files and create a buffer and byteBuffer for each file // For each notch there must be <num_cylinders * 2> chuff files notch_sounds = new HashMap<>(); int i = 0; // notch number (index) int j = 0; // chuff or coast number (index) int fmt = 0; // Sound sample format int nn = 1; // notch number (visual) // Get the notch-sounds. Iterator<Element> itr = (e.getChildren("s1notch-sound")).iterator(); while (itr.hasNext()) { el = itr.next(); sb = new S1Notch(); sb.setNotch(nn); // Get the chuff sounds List<Element> elist = el.getChildren("notch-file"); j = 0; for (Element fe : elist) { fn = fe.getText(); log.debug("notch: {}, file: {}", nn, fn); AudioBuffer b = S1Notch.getBuffer(vf, fn, _soundName + "_NOTCH_" + i + "_" + j, _soundName + "_NOTCH_" + i + "_" + j); log.debug("buffer created: {}, name: {}, format: {}", b, b.getSystemName(), b.getFormat()); sb.addChuffBuffer(b); if (fmt == 0) { // Get the format of the (first) WAV file // Since all WAV files of the notches MUST have the same format, // I asume this format for all WAV files for now fmt = AudioUtil.getWavFormat(S1Notch.getWavStream(vf, fn)); log.debug("fmt: {}", fmt); } ByteBuffer data = AudioUtil.getWavData(S1Notch.getWavStream(vf, fn)); sb.addChuffData(data); j++; } log.debug("Number of chuff sounds for notch {} defined: {}", nn, j); // Create a filler Buffer for queueing and a ByteBuffer for length modification fn = el.getChildText("notchfiller-file"); if (fn != null) { log.debug("notch filler file: {}", fn); AudioBuffer bnf = S1Notch.getBuffer(vf, el.getChildText("notchfiller-file"), _soundName + "_NOTCHFILLER_" + i, _soundName + "_NOTCHFILLER_" + i); log.debug("buffer created: {}, name: {}, format: {}", bnf, bnf.getSystemName(), bnf.getFormat()); sb.setNotchFillerBuffer(bnf); sb.setNotchFillerData(AudioUtil.getWavData(S1Notch.getWavStream(vf, fn))); } else { log.debug("no notchfiller available."); sb.setNotchFillerBuffer(null); } // Coasting sound and helpers are bound to first notch only // VSDFile validation makes sure that there is at least one notch if (nn == 1) { // Get the coasting sounds j = 0; List<Element> elistc = el.getChildren("coast-file"); for (Element fe : elistc) { fn = fe.getText(); log.debug("coasting file: {}", fn); AudioBuffer bc = S1Notch.getBuffer(vf, fn, _soundName + "_COAST_" + j, _soundName + "_COAST_" + j); log.debug("buffer created: {}, name: {}, format: {}", bc, bc.getSystemName(), bc.getFormat()); sb.addCoastBuffer(bc); // WAV in Buffer for queueing ByteBuffer datac = AudioUtil.getWavData(S1Notch.getWavStream(vf, fn)); sb.addCoastData(datac); // WAV data in ByteBuffer for length modification j++; } log.debug("Number of coasting sounds for notch {} defined: {}", nn, j); // Create a filler Buffer for queueing and a ByteBuffer for length modification fn = el.getChildText("coastfiller-file"); if (fn != null) { log.debug("coasting filler file: {}", fn); AudioBuffer bcf = S1Notch.getBuffer(vf, fn, _soundName + "_COASTFILLER", _soundName + "_COASTFILLER"); log.debug("buffer created: {}, name: {}, format: {}", bcf, bcf.getSystemName(), bcf.getFormat()); sb.setCoastFillerBuffer(bcf); sb.setCoastFillerData(AudioUtil.getWavData(S1Notch.getWavStream(vf, fn))); } else { log.debug("no coastfiller available."); sb.setCoastFillerBuffer(null); } // Add some helper Buffers. They are needed for creating // variable sound clips in length. Ten helper buffers should // serve well for that purpose. These buffers are bound to notch 1 for (int jk = 0; jk < 10; jk++) { AudioBuffer bh = S1Notch.getBufferHelper(_soundName + "_BUFFERHELPER_" + jk, _soundName + "_BUFFERHELPER_" + jk); log.debug("buffer helper created: {}, name: {}", bh, bh.getSystemName()); sb.addHelper(bh); } } sb.setMinLimit(Integer.parseInt(el.getChildText("min-rpm"))); sb.setMaxLimit(Integer.parseInt(el.getChildText("max-rpm"))); sb.setBufferFmt(fmt); log.debug("sample format for notch {}: {}", nn, fmt); // Store in the list notch_sounds.put(nn, sb); i++; nn++; } log.debug("Number of notches defined: {}", notch_sounds.size()); // Get the trigger sounds // Note: other than notch sounds, trigger sounds can have different attributes trigger_sounds = new HashMap<>(); // Get the idle sound el = e.getChild("idle-sound"); if (el != null) { fn = el.getChild("sound-file").getValue(); log.debug("idle sound: {}", fn); idle_sound = new SoundBite(vf, fn, _soundName + "_IDLE", _soundName + "_Idle"); idle_sound.setGain(setXMLGain(el)); // Handle gain log.debug("idle sound gain: {}", idle_sound.getGain()); idle_sound.setLooped(true); idle_sound.setFadeTimes(500, 500); idle_sound.setReferenceDistance(setXMLReferenceDistance(el)); // Handle reference distance log.debug("idle-sound reference distance: {}", idle_sound.getReferenceDistance()); trigger_sounds.put("idle", idle_sound); log.debug("trigger idle sound: {}", trigger_sounds.get("idle")); } // Get the boiling sound el = e.getChild("boiling-sound"); if (el != null) { fn = el.getChild("sound-file").getValue(); log.debug("boiling-sound: {}", fn); boiling_sound = new SoundBite(vf, fn, name + "_BOILING", name + "_Boiling"); boiling_sound.setGain(setXMLGain(el)); // Handle gain log.debug("boiling-sound gain: {}", boiling_sound.getGain()); boiling_sound.setLooped(true); boiling_sound.setFadeTimes(500, 500); boiling_sound.setReferenceDistance(setXMLReferenceDistance(el)); log.debug("boiling-sound reference distance: {}", boiling_sound.getReferenceDistance()); trigger_sounds.put("boiling", boiling_sound); log.debug("trigger boiling sound: {}", trigger_sounds.get("boiling")); } // Get the brake sound el = e.getChild("brake-sound"); if (el != null) { fn = el.getChild("sound-file").getValue(); log.debug("brake sound: {}", fn); brake_sound = new SoundBite(vf, fn, _soundName + "_BRAKE", _soundName + "_Brake"); brake_sound.setGain(setXMLGain(el)); log.debug("brake sound gain: {}", brake_sound.getGain()); brake_sound.setLooped(false); brake_sound.setFadeTimes(500, 500); brake_sound.setReferenceDistance(setXMLReferenceDistance(el)); log.debug("brake-sound reference distance: {}", brake_sound.getReferenceDistance()); trigger_sounds.put("brake", brake_sound); log.debug("trigger brake sound: {}", trigger_sounds.get("brake")); } // Get the pre-arrival sound el = e.getChild("pre-arrival-sound"); if (el != null) { fn = el.getChild("sound-file").getValue(); log.debug("pre-arrival sound: {}", fn); pre_arrival_sound = new SoundBite(vf, fn, _soundName + "_PRE-ARRIVAL", _soundName + "_Pre-arrival"); pre_arrival_sound.setGain(setXMLGain(el)); log.debug("pre-arrival sound gain: {}", pre_arrival_sound.getGain()); pre_arrival_sound.setLooped(false); pre_arrival_sound.setFadeTimes(500, 500); pre_arrival_sound.setReferenceDistance(setXMLReferenceDistance(el)); log.debug("pre-arrival-sound reference distance: {}", pre_arrival_sound.getReferenceDistance()); trigger_sounds.put("pre_arrival", pre_arrival_sound); log.debug("trigger pre_arrival sound : {}", trigger_sounds.get("pre_arrival")); } // Kick-start the loop thread this.startThread(); // Check auto-start setting autoStartCheck(); }
From source file:jmri.jmrit.vsdecoder.SteamSound.java
License:Open Source License
@Override public void setXml(Element e, VSDFile vf) { Element el;/*from w w w .j av a 2s .com*/ //int num_rpms; String fn; SoundBite sb; super.setXml(e, vf); log.debug("Steam EngineSound: " + e.getAttribute("name").getValue()); String n = e.getChild("top-speed").getValue(); if (n != null) { top_speed = Integer.parseInt(n); //log.debug("Top speed: " + top_speed + " MPH"); } n = e.getChildText("driver-diameter"); if (n != null) { driver_diameter = Integer.parseInt(n); //log.debug("Driver diameter: " + driver_diameter + " inches"); } n = e.getChildText("cylinders"); if (n != null) { num_cylinders = Integer.parseInt(n); //log.debug("Num Cylinders: " + num_cylinders); } // For now, num_rpms is not used. /* n = e.getChild("rpm-steps").getValue(); if (n != null) { num_rpms = Integer.parseInt(n); //log.debug("Number of rpm steps: " + num_rpms); } */ rpm_sounds = new ArrayList<RPMSound>(); // Get the RPM steps Iterator<Element> itr = (e.getChildren("rpm-step")).iterator(); int i = 0; while (itr.hasNext()) { el = itr.next(); fn = el.getChildText("file"); int min_r = Integer.parseInt(el.getChildText("min-rpm")); int max_r = Integer.parseInt(el.getChildText("max-rpm")); //log.debug("Notch: " + nn + " File: " + fn); sb = new SoundBite(vf, fn, "Steam_n" + i, "Steam_" + i); sb.setLooped(true); sb.setFadeTimes(100, 100); sb.setGain(setXMLGain(el)); // Store in the list. boolean chuff = false; Element c; if ((c = el.getChild("use-chuff-gen")) != null) { log.debug("Use Chuff Generator " + c.toString()); chuff = true; } rpm_sounds.add(new RPMSound(sb, min_r, max_r, chuff)); i++; } /* // Get the start and stop sounds el = e.getChild("start-sound"); if (el != null) { fn = el.getChild("file").getValue(); log.debug("Start sound: " + fn); start_sound = new SoundBite(vf, fn, "Engine_start", "Engine_Start"); // Handle gain start_sound.setGain(setXMLGain(el)); start_sound.setLooped(false); } */ }
From source file:jmri.jmrit.vsdecoder.VSDFile.java
License:Open Source License
protected boolean validateOptionalFile(Element el, String name, Boolean required) { String s = el.getChildText(name); if ((s != null) && (getFile(s) == null)) { log.debug("File " + s + " for element " + name + " in Element " + el.getAttributeValue("name") + " not found."); return (false); }//w w w . ja v a 2 s. c o m return (true); }