Source Code Cross Referenced for AudioClipRecordable.java in  » Testing » jacareto » jacareto » record » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jacareto » jacareto.record 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.record;
025:
026:        import jacareto.cleverphl.gui.InfoDialog;
027:        import jacareto.system.Environment;
028:
029:        import java.io.IOException;
030:
031:        import javax.sound.sampled.AudioFileFormat;
032:        import javax.sound.sampled.AudioSystem;
033:        import javax.sound.sampled.UnsupportedAudioFileException;
034:
035:        /**
036:         * This class represents an audio clip.
037:         *
038:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>, Oliver Specht
039:         * @version $revision$
040:         */
041:        public class AudioClipRecordable extends MediaClipRecordable {
042:            /** The duration */
043:            private long duration;
044:
045:            /**
046:             * Creates a new audio clip recordable with no file reference.
047:             *
048:             * @param env Environment
049:             */
050:            public AudioClipRecordable(Environment env) {
051:                this (env, "");
052:            }
053:
054:            /**
055:             * Creates a new audio clio recordable.
056:             *
057:             * @param env the environment
058:             * @param filename the name of the audio file
059:             */
060:            public AudioClipRecordable(Environment env, String filename) {
061:                super (env);
062:                setFilename(filename);
063:                determineDuration();
064:            }
065:
066:            /**
067:             * <p>
068:             * Only to be used for JUnit tests!
069:             * </p>
070:             * Creates a new audio clip recordable with default values and no environment. The environment
071:             * should be defined with the method {@link
072:             * jacareto.system.EnvironmentMember#setEnvironment(Environment)} before environment instances
073:             * will be accessed.
074:             */
075:            public AudioClipRecordable() {
076:                this (null);
077:            }
078:
079:            public boolean determineDuration() {
080:                if (!this 
081:                        .getFilename()
082:                        .equals(
083:                                getLanguage()
084:                                        .getString(
085:                                                "Recordables.MediaClipRecordable.DefaultFilename"))) {
086:                    try {
087:                        AudioFileFormat aff = AudioSystem
088:                                .getAudioFileFormat(getFile());
089:                        javax.sound.sampled.AudioFormat format = aff
090:                                .getFormat();
091:
092:                        this .setDuration((long) ((aff.getFrameLength() / format
093:                                .getFrameRate()) * 1000));
094:
095:                        return true;
096:                    } catch (UnsupportedAudioFileException e) {
097:                        InfoDialog dialog;
098:                        dialog = new InfoDialog(
099:                                getLanguage().getString(
100:                                        "CleverPHL.InfoDialog.Title"),
101:                                getLanguage()
102:                                        .getString(
103:                                                "Recordables.MediaClipRecordable.ErrorUnsupportedFileFormat"));
104:                        dialog.setModal(true);
105:                        dialog
106:                                .setTitle(getLanguage()
107:                                        .getString(
108:                                                "Recordables.MediaClipRecordable.ErrorUnsupportedFileFormatTitle"));
109:                        dialog.setVisible(true);
110:
111:                        return false;
112:                    } catch (IOException e) {
113:                        InfoDialog dialog;
114:                        dialog = new InfoDialog(
115:                                getLanguage().getString(
116:                                        "CleverPHL.InfoDialog.Title"),
117:                                getLanguage()
118:                                        .getString(
119:                                                "Recordables.MediaClipRecordable.ErrorIO"));
120:                        dialog.setModal(true);
121:                        dialog
122:                                .setTitle(getLanguage()
123:                                        .getString(
124:                                                "Recordables.MediaClipRecordable.ErrorIOTitle"));
125:                        dialog.setVisible(true);
126:
127:                        return false;
128:                    }
129:                }
130:
131:                return false;
132:            }
133:
134:            /**
135:             * Returns the name of this element
136:             *
137:             * @return the name
138:             */
139:            public String getElementName() {
140:                return getLanguage().getString(
141:                        "Recordables.AudioClipRecordable.Name");
142:            }
143:
144:            /**
145:             * Returns a description of the Recordable.
146:             *
147:             * @return the description
148:             */
149:            public String getElementDescription() {
150:                return getLanguage().getString(
151:                        "Recordables.AudioClipRecordable.Description");
152:            }
153:
154:            /**
155:             * Returns a String which describes the content of the Recordable shortly.
156:             *
157:             * @return a string with a short description of the Recordable
158:             */
159:            public String toShortString() {
160:                return getElementName() + " (" + filename + ")";
161:            }
162:
163:            /**
164:             * Returns the duration of the audio clip in ms
165:             *
166:             * @return long the duration
167:             */
168:            public long getDuration() {
169:                return this .duration;
170:            }
171:
172:            /**
173:             * Sets the duration of this element. Is normally called by {@link #determineDuration()}.
174:             *
175:             * @param duration long the duration of the audio clip
176:             */
177:            public void setDuration(long duration) {
178:                this .duration = duration;
179:            }
180:
181:            /**
182:             * AudioClips don't have a processing time, because they are being replayed by  the {@link
183:             * jacareto.replay.MediaClipReplayer} which handles the processing etc.
184:             *
185:             * @return boolean false
186:             */
187:            public boolean hasProcTime() {
188:                return false;
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.