View Javadoc

1   /*
2    * @(#)$Id: RejectEventHandler.java 689 2009-07-22 00:10:27Z bsigner $
3    *
4    * Author       :   Ueli Kurmann, igesture@uelikurmann.ch
5    *
6    * Purpose      : 
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date             Who         Reason
13   *
14   * Nov 24, 2006     ukurmann    Initial Release
15   * Mar 24, 2007     bsigner     Cleanup
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  package org.ximtec.igesture.app.showcaseapp.eventhandler;
27  
28  import java.io.IOException;
29  
30  import javax.sound.sampled.AudioSystem;
31  import javax.sound.sampled.UnsupportedAudioFileException;
32  
33  import org.sigtec.sound.SoundTool;
34  import org.ximtec.igesture.core.ResultSet;
35  import org.ximtec.igesture.event.GestureAction;
36  
37  /**
38   * @version 1.0 Nov 2006
39   * @author Ueli Kurmann, igesture@uelikurmann.ch
40   * @author Beat Signer, signer@inf.ethz.ch
41   */
42  public class RejectEventHandler implements GestureAction {
43  
44  	private static final String RESOURCES_SOUND_RINGOUT_WAV = "sound/ringout.wav";
45  
46  	private String filename;
47  
48  	public RejectEventHandler(String filename) {
49  		this.filename = filename;
50  	}
51  
52  	public RejectEventHandler() {
53  		this(RESOURCES_SOUND_RINGOUT_WAV);
54  	}
55  
56  	public void actionPerformed(ResultSet resultSet) {
57  		try {
58  			SoundTool.play(AudioSystem.getAudioInputStream(ClassLoader
59  					.getSystemResourceAsStream(filename)));
60  		} catch (UnsupportedAudioFileException e) {
61  			e.printStackTrace();
62  		} catch (IOException e) {
63  			e.printStackTrace();
64  		}
65  	} // run
66  
67  }