Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * RecorderUI.java
- *
- * Created on __DATE__, __TIME__
- */
- package com.actura.app.capture;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.LinearGradientPaint;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.geom.Point2D;
- import java.io.File;
- import java.io.IOException;
- import javax.swing.Timer;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import javax.sound.sampled.AudioSystem;
- import javax.sound.sampled.AudioFileFormat;
- import javax.sound.sampled.AudioFormat;
- import javax.sound.sampled.AudioInputStream;
- import javax.sound.sampled.DataLine;
- import javax.sound.sampled.LineUnavailableException;
- import javax.sound.sampled.SourceDataLine;
- import javax.sound.sampled.UnsupportedAudioFileException;
- import javax.swing.BorderFactory;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import org.apache.log4j.Logger;
- import com.actura.app.util.ApplicationUtil;
- /**
- *
- * @author __USER__
- */
- public class RecorderUI extends javax.swing.JApplet implements Runnable {
- /*
- * state management constants
- */
- private static final int NORMAL_STATE = 0;
- private static final int RECORDING_STATE = 1;
- private static final int LISTENING_STATE = 2;
- private static final int SAVING_STATE = 3;
- private static final int RE_RECORDING_STATE = 4;
- private static final int STAGE1_STATE = 5;
- private static final int STAGE2_STATE = 6;
- private int currentCurrentState = NORMAL_STATE;
- /**
- * recording related constants and variables
- */
- private static int MAXIMUM_RECORD_TIME = 120;
- private int currentSecond = 1;
- private static Logger log = Logger.getLogger(RecorderUI.class
- .getSimpleName());
- /**
- *
- */
- private static final long serialVersionUID = 1685325421893969802L;
- private ActuraRecorder captureThread = null;
- private PCMFilePlayer playerThread = null;
- private Thread timerThread = null;
- private HashMap<String, String> parameterMap = new HashMap<String, String>();
- private File fileUnderProcessing = null;
- private int messageCount = 0;
- /** Initializes the applet RecorderUI */
- public void init() {
- try {
- initParameters();
- java.awt.EventQueue.invokeAndWait(new Runnable() {
- public void run() {
- initDimension();
- initGraphPanel();
- initCombo();
- initComponents();
- }
- });
- initActuraRecorder();
- } catch (Exception ex) {
- ex.printStackTrace();
- // TODO disable all command buttons
- }
- }
- public void initActuraRecorder() {
- try {
- java.awt.EventQueue.invokeAndWait(new Runnable() {
- public void run() {
- currentCurrentState = NORMAL_STATE;
- reRecordingPanel.setVisible(false);
- saveImageButton.setVisible(false);
- listeningPanel.setVisible(false);
- }
- });
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public void initCombo() {
- try {
- // do nothing
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public void initGraphPanel() {
- errorLabel = new JLabel("");
- }
- public void initDimension() {
- // TODO implement this
- }
- public void initParameters() {
- try {
- // prepare server data
- ApplicationUtil.prepareServerData(this, parameterMap);
- // prepare count
- setMessageCount(Integer.parseInt(parameterMap
- .get(ApplicationUtil.IVR_MESSAGECOUNT_KEY)));
- // set current file to be processed
- this.setFileUnderProcessing(ApplicationUtil.generateFile(
- getMessageCount(), parameterMap));
- } catch (IOException e) {
- e.printStackTrace();
- this.paintError(e.getMessage(), ApplicationUtil.ERROR);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- this.paintError(e.getMessage(), ApplicationUtil.ERROR);
- } catch (Exception e) {
- e.printStackTrace();
- this.paintError(e.getMessage(), ApplicationUtil.ERROR);
- }
- }
- public void incrementMessageCount() {
- this.messageCount++;
- }
- private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {
- stopPlayer();
- }
- private void recordButtonActionPerformed(java.awt.event.ActionEvent evt) {
- int currentCurrentState = getCurrentState();
- if (currentCurrentState == RecorderUI.RECORDING_STATE) {
- stopRecording(true);
- } else {
- startRecording();
- }
- }
- public void startRecording() {
- // initialize timer
- initializeTimer();
- // set currentCurrentState
- setCurrentState(RecorderUI.RECORDING_STATE);
- // start Recording
- captureThread = new ActuraRecorder(RecorderUtility
- .getDefaultTragetDataLine(), AudioFileFormat.Type.WAVE, this
- .getFileUnderProcessing());
- captureThread.start();
- // start Timer
- startTimer();
- // start Graph
- startDrawingGraph();
- // set text to stop
- recordButton.setText("Stop");
- }
- public void stopRecording(boolean isSwitchPanel) {
- // stop recording
- captureThread.stop();
- // set currentCurrentState
- setCurrentState(RecorderUI.NORMAL_STATE);
- // stop timer
- stopTimer();
- // stop Graph Drawing
- stopDrawingGraph();
- // set text to stop
- recordButton.setText("Record");
- if (isSwitchPanel) {
- recordingPanel.setVisible(false);
- reRecordingPanel.setVisible(true);
- }
- }
- public void stopRecordingFromTimer() {
- // stop capture thread
- captureThread.stop();
- // set currentCurrentState
- setCurrentState(RecorderUI.NORMAL_STATE);
- // stop Graph Drawing
- stopDrawingGraph();
- // set text to stop
- recordButton.setText("Record");
- recordingPanel.setVisible(false);
- reRecordingPanel.setVisible(true);
- initializeTimer();
- }
- public void startReRecording() {
- // initialize timer
- initializeTimer();
- // set currentCurrentState
- setCurrentState(RecorderUI.RE_RECORDING_STATE);
- // start Recording
- captureThread = new ActuraRecorder(RecorderUtility
- .getDefaultTragetDataLine(), AudioFileFormat.Type.WAVE, this
- .getFileUnderProcessing());
- captureThread.start();
- // start Timer
- startTimer();
- // start Graph
- startDrawingGraph();
- // set text to stop
- this.reRecordingButton.setText("Stop");
- }
- public void stopReRecording() {
- // stop recording
- captureThread.stop();
- // set currentCurrentState
- setCurrentState(RecorderUI.NORMAL_STATE);
- // stop timer
- stopTimer();
- // stop Graph Drawing
- stopDrawingGraph();
- // set text to stop
- reRecordingButton.setText("Record");
- }
- public void stopReRecordingFromTimer() {
- // stop capture thread
- captureThread.stop();
- // set currentCurrentState
- setCurrentState(RecorderUI.NORMAL_STATE);
- // stop Graph Drawing
- stopDrawingGraph();
- // set text to stop
- reRecordingButton.setText("Record");
- initializeTimer();
- }
- public void stopListening() {
- if (getCurrentState() == RecorderUI.LISTENING_STATE) {
- // switch panel
- this.timerPanel.setVisible(true);
- this.listeningPanel.setVisible(false);
- // switch button
- this.reRecordingButton.setEnabled(true);
- this.saveButton.setEnabled(true);
- this.listenButton.setText("Listen");
- this.setCurrentState(NORMAL_STATE);
- // according to player's state wise
- this.closePlayer();
- log.info(" player closed ");
- } else {
- // switch panel
- this.timerPanel.setVisible(false);
- this.listeningPanel.setVisible(true);
- log.info(" visibility of listeningPanel is"
- + this.listeningPanel.isVisible());
- // switch button
- this.reRecordingButton.setEnabled(false);
- this.saveButton.setEnabled(false);
- this.listenButton.setText("Close");
- this.setCurrentState(LISTENING_STATE);
- this.startPlayer();
- log.info(" now playing ");
- }
- }
- public void cancelSaving() {
- }
- public void initializeTimer() {
- this.currentSecond = 0;
- paintTimerLabel(0);
- }
- public void startTimer() {
- initializeTimer();
- timerThread = new Thread(this);
- timerThread.start();
- }
- public void stopTimer() {
- try {
- if (timerThread.isAlive()) {
- timerThread.join();
- initializeTimer();
- timerThread.interrupt();
- timerThread = null;
- }
- if (timerThread != null) {
- timerThread.join();
- initializeTimer();
- timerThread.interrupt();
- timerThread = null;
- }
- } catch (InterruptedException iex) {
- iex.printStackTrace();
- }
- }
- public void startDrawingGraph() {
- ((WaveformPanel) graphPanel).setAnimation(true);
- }
- public void stopDrawingGraph() {
- ((WaveformPanel) graphPanel).setAnimation(false);
- }
- class WaveformPanel extends JPanel {
- Timer graphTimer = null;
- AudioInfo helper = null;
- WaveformPanel() {
- setPreferredSize(new Dimension(200, 80));
- setBorder(BorderFactory.createLineBorder(Color.BLACK));
- graphTimer = new Timer(481, new TimerDrawing());
- }
- /**
- *
- */
- private static final long serialVersionUID = 969991141812736791L;
- protected final Color BACKGROUND_COLOR = Color.white;
- protected final Color REFERENCE_LINE_COLOR = Color.black;
- protected final Color WAVEFORM_COLOR = Color.red;
- private int offset = 0;
- private int readLen = 1000;
- private byte[] bytesRecorded = null; // new byte[readLen];
- private int increment = 0;
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- int lineHeight = getHeight() / 2;
- g.setColor(REFERENCE_LINE_COLOR);
- setBackground(Color.white);
- g.drawLine(0, lineHeight, (int) getWidth(), lineHeight);
- if (helper == null) {
- return;
- }
- drawWaveform(g, helper.getByteArray());
- }
- public int getIncrement(int[] samples, int width) {
- int pixelToPrint = Math.round(samples.length / 8);
- // System.out.println(" pixelToPrint " + pixelToPrint + " "+
- // (samples[0].length / 8));
- double xScale = ((double) width / (double) pixelToPrint);
- // System.out.println(" xScale " + xScale + " "
- // +(width/pixelToPrint));
- int increment = (int) Math.round(width / (width * xScale));
- increment = increment / 2;
- // System.out.println(" increment " + increment + " length "
- // + samples.length);
- return increment;
- }
- protected void drawWaveform(Graphics g, int[][] samples) {
- // Samples is a 2D int array (int[][]), where the first index is the
- // channel, the second is the sample for that channel
- if (samples != null) {
- Graphics2D g2d = (Graphics2D) g;
- int max = helper.sampleMax;
- int min = helper.sampleMin;
- int length = samples[0].length;
- int width = getWidth() - 1;
- int height = getHeight() - 1;
- int frame = 0;
- int oldX = 0;
- int oldY = height / 2;
- // min, max is the min/max range of the samples, ie the highest
- // and lowest samples
- int range = max + (min * -2);
- float scale = (float) height / (float) range;
- int minY = Math.round(((height / 2) + (min * scale)));
- int maxY = Math.round(((height / 2) + (max * scale)));
- LinearGradientPaint lgp = new LinearGradientPaint(
- new Point2D.Float(0, minY), new Point2D.Float(0, maxY),
- new float[] { 0f, 0.5f, 1f }, new Color[] { Color.BLUE,
- Color.RED, Color.BLUE });
- g2d.setPaint(lgp);
- int counter = 0;
- if (increment == 0) {
- increment = getIncrement(samples[0], width);
- }
- for (int i = 0; i < samples[0].length; i++) {
- int sample = samples[0][i];
- if (sample % 8 == 0) {
- int x = Math.round(((float) frame / (float) length)
- * width);
- int y = Math.round((height / 2) + (sample * scale));
- g2d.drawLine(oldX, oldY, x, y);
- if (x >= width) {
- x = 0;
- frame = 0;
- }
- oldX = x;
- oldY = y;
- }
- frame++;
- }
- }
- }
- public void setAnimation(boolean turnon) {
- if (turnon) {
- graphTimer.start();
- } else {
- graphTimer.stop();
- helper = null;
- repaint();
- }
- }
- class TimerDrawing implements ActionListener {
- @Override
- public void actionPerformed(ActionEvent e) {
- // captureThread.readRecorderByte(bytesRecorded, offset,
- // readLen);
- bytesRecorded = captureThread.getTempBuffer();
- if (helper != null) {
- helper.setBytes(bytesRecorded);
- } else {
- helper = new AudioInfo(bytesRecorded);
- }
- repaint();
- }
- }
- }
- private void listenButtonActionPerformed(java.awt.event.ActionEvent evt) {
- stopListening();
- }
- public int getCurrentState() {
- return currentCurrentState;
- }
- public void setCurrentState(int currentCurrentState) {
- this.currentCurrentState = currentCurrentState;
- }
- public int getMessageCount() {
- return messageCount;
- }
- public void setMessageCount(int messageCount) {
- this.messageCount = messageCount;
- }
- public File getFileUnderProcessing() {
- return fileUnderProcessing;
- }
- public void setFileUnderProcessing(File fileUnderProcessing) {
- this.fileUnderProcessing = fileUnderProcessing;
- }
- @Override
- public void run() {
- int recordingLimitInSeconds = RecorderUI.MAXIMUM_RECORD_TIME;
- while (getCurrentState() == RecorderUI.RECORDING_STATE
- || getCurrentState() == RecorderUI.RE_RECORDING_STATE) {
- recordingLimitInSeconds--;
- currentSecond++;
- // paint label
- paintTimerLabel(currentSecond);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException iex) {
- iex.printStackTrace();
- }
- if (recordingLimitInSeconds == 0) {
- // stop recording
- if (getCurrentState() == RecorderUI.RECORDING_STATE) {
- stopRecordingFromTimer();
- // paintTimerLabel(0);
- break;
- } else if (getCurrentState() == RecorderUI.RE_RECORDING_STATE) {
- stopReRecordingFromTimer();
- // paintTimerLabel(0);
- break;
- } else {
- // do nothing
- }
- }
- }
- }
- public void paintTimerLabel(int seconds) {
- if (seconds == 0) {
- // secondsLabel.setText(" ");
- timerLabel.setText("000");
- }
- if (seconds == 1) {
- secondsLabel.setText("Sec ");
- } else {
- secondsLabel.setText("Secs");
- }
- if (seconds > 0 && seconds < 10) {
- timerLabel.setText(("00" + seconds));
- } else if (seconds > 9 && seconds < 100) {
- timerLabel.setText(("0" + seconds));
- } else if (seconds > 99 && seconds < 121) {
- timerLabel.setText(("" + seconds));
- } else {
- // do nothing
- }
- }
- /***************************************************************/
- /* Player */
- /**************************************************************/
- class PCMFilePlayer implements Runnable {
- private File fileToPlay = null;
- private AudioInputStream in = null;
- private SourceDataLine line;
- private int frameSize = 0;
- private byte[] buffer = new byte[32 * 1024]; // 32k is arbitrary
- private Thread playThread = null;
- private boolean playing = false;
- private boolean notYetEOF = true;
- private boolean isPaused = false;
- private PlayerTimer playerTimerThread = null;
- PCMFilePlayer(File fileToPlay) throws IOException,
- UnsupportedAudioFileException, LineUnavailableException {
- this.fileToPlay = fileToPlay;
- // log.info(" PCM file " + this.fileToPlay.getAbsolutePath());
- in = javax.sound.sampled.AudioSystem
- .getAudioInputStream(this.fileToPlay);
- // validate audio file format
- AudioFormat format = in.getFormat();
- AudioFormat.Encoding formatEncoding = format.getEncoding();
- if (!(formatEncoding.equals(AudioFormat.Encoding.PCM_SIGNED) || formatEncoding
- .equals(AudioFormat.Encoding.PCM_SIGNED))) {
- throw new UnsupportedAudioFileException(this.fileToPlay
- + " is not a PCM Audio !,so can not play.");
- }
- log.info(" PCM Format");
- frameSize = format.getFrameSize();
- DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
- log.info(" got info ");
- line = (SourceDataLine) AudioSystem.getLine(info);
- log.info(" got source line");
- line.open();
- log.info(" line opened ...");
- playerTimerThread = new PlayerTimer(this.fileToPlay);
- }
- public void startPCMPlayer() {
- if (isPaused) {
- resumePCMPlayer();
- log.info(" resumed....");
- } else {
- playing = true;
- notYetEOF = true;
- playThread = new Thread(this);
- if (!playThread.isAlive()) {
- playThread.start();
- playerTimerThread.start();
- }
- line.start();
- }
- }
- public void resumePCMPlayer() {
- isPaused = false;
- playing = true;
- }
- public void stopPCMPlayer() throws InterruptedException {
- playing = false;
- isPaused = false;
- notYetEOF = false;
- if (!playThread.isAlive()) {
- playThread.interrupt();
- } else {
- playThread.join();
- playThread.interrupt();
- }
- log.info(" playThread is stopped......");
- if (!playerTimerThread.isAlive()) {
- playerTimerThread.interrupt();
- } else {
- playerTimerThread.join();
- playerTimerThread.interrupt();
- }
- log.info(" playTimerThread is stopped......");
- playerTimerThread = null;
- line.stop();
- }
- public void pausePCMPlayer() throws InterruptedException {
- isPaused = true;
- playing = false;
- }
- public boolean isPaused() {
- return isPaused;
- }
- @Override
- public void run() {
- int readPoint = 0;
- int bytesRead = 0;
- try {
- while (notYetEOF) {
- if (playing) {
- bytesRead = in.read(buffer, readPoint, buffer.length
- - readPoint);
- if (bytesRead == -1) {
- notYetEOF = false;
- log.info(" reached end of file");
- break;
- }
- // how many frames did we get ,
- // how many are left over
- int frames = bytesRead / frameSize;
- int leftOver = bytesRead % frameSize;
- // send to line
- line.write(buffer, readPoint, bytesRead - leftOver);
- // save the left over bytes
- System
- .arraycopy(buffer, bytesRead, buffer, 0,
- leftOver);
- readPoint = leftOver;
- }// ends if playing
- else {
- // if not playing
- try {
- Thread.sleep(10);
- } catch (InterruptedException iex) {
- iex.printStackTrace();
- }
- }
- }// ends while
- log.info(" reached of ");
- line.drain();
- line.stop();
- playing = false;
- } catch (IOException ioe) {
- ioe.printStackTrace();
- } finally {
- line.close();
- }
- }
- public File getFileToPlay() {
- return fileToPlay;
- }
- public void setFileToPlay(File fileToPlay) {
- this.fileToPlay = fileToPlay;
- }
- public SourceDataLine getLine() {
- return line;
- }
- public void setLine(SourceDataLine line) {
- this.line = line;
- }
- class PlayerTimer extends Thread {
- private File file = null;
- private int counter = 0;
- public PlayerTimer(File file) {
- this.file = file;
- }
- public void initializePlayerTimer() {
- playButton.setEnabled(true);
- stopButton.setEnabled(false);
- pauseButton.setEnabled(false);
- playerProgressbar.setValue(0);
- playerTimerLabel.setText("00:00");
- }
- public void run() {
- paintTotalTimeLabel();
- try {
- while (playing || isPaused) {
- if (isPaused) {
- Thread.sleep(10);
- } else {
- playerProgressbar.setValue(counter);
- paintPlayerLabel(counter, false);
- Thread.sleep(1000);
- counter++;
- }
- }
- log.info(" Finished Playing ");
- initializePlayerTimer();
- } catch (InterruptedException iex) {
- iex.printStackTrace();
- }
- } // ends run
- public void paintPlayerLabel(int second, boolean paintTotal) {
- String labelString = null;
- if (second == 0) {
- return;
- }
- // only minute
- if (second % 60 == 0) {
- int minute = second / 60;
- if (minute < 10) {
- labelString = "0" + minute + ":00";
- } else {
- labelString = minute + ":00";
- }
- } else if (second > 60) {
- int minute = (int) Math.floor(second / 60);
- if (minute < 10) {
- labelString = "0" + minute;
- } else {
- labelString = minute + "";
- }
- int remainingSecond = Math.abs(second - (minute * 60));
- if (remainingSecond < 10) {
- labelString += (":0" + remainingSecond);
- } else {
- labelString += (":" + remainingSecond);
- }
- } else {
- labelString = "00:"
- + ((second < 10) ? ("0" + second) : second);
- }
- if (paintTotal) {
- totalTimeLabel.setText(labelString);
- } else {
- playerTimerLabel.setText(labelString);
- }
- }// ends label painting
- public double getDurationOfWavInSeconds(File file) {
- AudioInputStream stream = null;
- try {
- stream = AudioSystem.getAudioInputStream(file);
- AudioFormat format = stream.getFormat();
- return file.length() / format.getSampleRate()
- / (format.getSampleSizeInBits() / 8.0)
- / format.getChannels();
- } catch (Exception e) {
- // log an error
- return -1;
- } finally {
- try {
- stream.close();
- } catch (Exception ex) {
- }
- }
- }
- public void paintTotalTimeLabel() {
- double fileInSeconds = getDurationOfWavInSeconds(this.file);
- int seconds = (int) Math.floor(fileInSeconds);
- paintPlayerLabel(seconds, true);
- playerProgressbar.setMinimum(0);
- playerProgressbar.setMaximum(seconds);
- }
- } // ends inner class
- } // ends player
- public void startPlayer() {
- try {
- if (playerThread != null && playerThread.isPaused()) {
- // keep this object
- } else {
- // create new object
- playerThread = new PCMFilePlayer(this.getFileUnderProcessing());
- log.info(" new instance of player is created : ");
- }
- playerThread.startPCMPlayer();
- playButton.setEnabled(false);
- stopButton.setEnabled(true);
- pauseButton.setEnabled(true);
- log.info(" playing ... ");
- } catch (IOException e) {
- e.printStackTrace();
- } catch (UnsupportedAudioFileException e) {
- e.printStackTrace();
- } catch (LineUnavailableException e) {
- e.printStackTrace();
- }
- }
- public void stopPlayer() {
- try {
- playerThread.stopPCMPlayer();
- playerThread = null;
- playButton.setEnabled(true);
- stopButton.setEnabled(false);
- pauseButton.setEnabled(false);
- log.info(" stopped ... ");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- public void pausePlayer() {
- try {
- playerThread.pausePCMPlayer();
- playButton.setEnabled(true);
- stopButton.setEnabled(false);
- pauseButton.setEnabled(false);
- log.info(" paused ... ");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- public void initializePlayer() {
- playButton.setEnabled(true);
- stopButton.setEnabled(true);
- pauseButton.setEnabled(true);
- }
- public void closePlayer() {
- if (playerThread.isPaused()) {
- playerThread.startPCMPlayer();
- }
- if (playerThread.playing) {
- stopPlayer();
- }
- initializePlayer();
- }
- public void paintError(String message, String type) {
- errorLabel.setText("");
- if (type.equals(ApplicationUtil.INFO)) {
- // blue color
- errorLabel.setForeground(Color.blue);
- } else {
- // red color
- errorLabel.setForeground(Color.blue);
- }
- errorLabel.setText(message);
- }
- //GEN-BEGIN:initComponents
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- containerPanel = new javax.swing.JPanel();
- containerFrame = new javax.swing.JPanel();
- messagePanel = new javax.swing.JPanel();
- errorLabel = new javax.swing.JLabel();
- saveImageButton = new javax.swing.JButton();
- jLayeredPane1 = new javax.swing.JLayeredPane();
- recordingPanel = new javax.swing.JPanel();
- recordButton = new javax.swing.JButton();
- cancelButton = new javax.swing.JButton();
- reRecordingPanel = new javax.swing.JPanel();
- reRecordingButton = new javax.swing.JButton();
- listenButton = new javax.swing.JButton();
- saveButton = new javax.swing.JButton();
- reCancelButton = new javax.swing.JButton();
- jLayeredPane2 = new javax.swing.JLayeredPane();
- listeningPanel = new javax.swing.JPanel();
- listeningButtonPanel1 = new javax.swing.JPanel();
- jLabel3 = new javax.swing.JLabel();
- playButton = new javax.swing.JButton();
- pauseButton = new javax.swing.JButton();
- stopButton = new javax.swing.JButton();
- totalTimeLabel = new javax.swing.JLabel();
- playerTimerLabel = new javax.swing.JLabel();
- playerProgressbar = new javax.swing.JProgressBar();
- timerPanel = new javax.swing.JPanel();
- timerLabel = new javax.swing.JLabel();
- secondsLabel = new javax.swing.JLabel();
- graphPanel = new WaveformPanel();
- containerFrame.setBorder(javax.swing.BorderFactory.createTitledBorder(
- javax.swing.BorderFactory.createTitledBorder(""),
- "Record Message",
- javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
- javax.swing.border.TitledBorder.DEFAULT_POSITION,
- new java.awt.Font("Tahoma", 1, 14)));
- messagePanel.setBorder(javax.swing.BorderFactory
- .createLineBorder(new java.awt.Color(0, 0, 0)));
- errorLabel.setFont(new java.awt.Font("Verdana", 0, 12));
- errorLabel.setForeground(new java.awt.Color(255, 0, 51));
- saveImageButton.setIcon(new javax.swing.ImageIcon(getClass()
- .getResource("/com/actura/app/capture/bigrotation2.gif"))); // NOI18N
- saveImageButton.setBorder(null);
- javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(
- messagePanel);
- messagePanel.setLayout(messagePanelLayout);
- messagePanelLayout
- .setHorizontalGroup(messagePanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- messagePanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .addComponent(saveImageButton)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED,
- 23, Short.MAX_VALUE)
- .addComponent(
- errorLabel,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 277,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap()));
- messagePanelLayout
- .setVerticalGroup(messagePanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- messagePanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .addGroup(
- messagePanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(
- errorLabel,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- 130,
- Short.MAX_VALUE)
- .addComponent(
- saveImageButton))
- .addContainerGap()));
- jLayeredPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
- recordButton.setText("Record");
- recordButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- recordButtonActionPerformed(evt);
- }
- });
- cancelButton.setText("Cancel");
- cancelButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- cancelButtonActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout recordingPanelLayout = new javax.swing.GroupLayout(
- recordingPanel);
- recordingPanel.setLayout(recordingPanelLayout);
- recordingPanelLayout
- .setHorizontalGroup(recordingPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- recordingPanelLayout
- .createSequentialGroup()
- .addGap(21, 21, 21)
- .addGroup(
- recordingPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(
- cancelButton)
- .addComponent(
- recordButton))
- .addContainerGap(22, Short.MAX_VALUE)));
- recordingPanelLayout
- .setVerticalGroup(recordingPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- recordingPanelLayout
- .createSequentialGroup()
- .addGap(23, 23, 23)
- .addComponent(recordButton)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(cancelButton)
- .addContainerGap(20, Short.MAX_VALUE)));
- recordingPanel.setBounds(10, 20, 110, 100);
- jLayeredPane1.add(recordingPanel,
- javax.swing.JLayeredPane.DEFAULT_LAYER);
- reRecordingButton.setText("Re Record");
- reRecordingButton
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- reRecordingButtonActionPerformed(evt);
- }
- });
- listenButton.setText("Listen");
- listenButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- listenButtonActionPerformed(evt);
- }
- });
- saveButton.setText("Save");
- saveButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- saveButtonActionPerformed(evt);
- }
- });
- reCancelButton.setText("Cancel");
- reCancelButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- reCancelButtonActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout reRecordingPanelLayout = new javax.swing.GroupLayout(
- reRecordingPanel);
- reRecordingPanel.setLayout(reRecordingPanelLayout);
- reRecordingPanelLayout
- .setHorizontalGroup(reRecordingPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- reRecordingPanelLayout
- .createSequentialGroup()
- .addGap(24, 24, 24)
- .addGroup(
- reRecordingPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(
- listenButton)
- .addComponent(
- reRecordingButton)
- .addGroup(
- reRecordingPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(
- reCancelButton)
- .addComponent(
- saveButton)))
- .addContainerGap(13, Short.MAX_VALUE)));
- reRecordingPanelLayout
- .setVerticalGroup(reRecordingPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- reRecordingPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .addComponent(reRecordingButton)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(listenButton)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(saveButton)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(reCancelButton)
- .addContainerGap(19, Short.MAX_VALUE)));
- reRecordingPanel.setBounds(10, 10, 120, 140);
- jLayeredPane1.add(reRecordingPanel,
- javax.swing.JLayeredPane.DEFAULT_LAYER);
- jLayeredPane2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
- listeningPanel.setBackground(new java.awt.Color(255, 255, 255));
- listeningPanel.setBorder(javax.swing.BorderFactory
- .createBevelBorder(javax.swing.border.BevelBorder.RAISED));
- listeningButtonPanel1.setBackground(new java.awt.Color(255, 255, 255));
- jLabel3.setFont(new java.awt.Font("Verdana", 1, 14));
- jLabel3.setForeground(java.awt.Color.orange);
- jLabel3.setText("Canary Voice");
- playButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(
- "/com/actura/app/capture/playbutton.PNG"))); // NOI18N
- playButton.setActionCommand("play");
- playButton.setBorder(javax.swing.BorderFactory
- .createLineBorder(new java.awt.Color(255, 153, 0)));
- playButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- playButtonActionPerformed(evt);
- }
- });
- pauseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(
- "/com/actura/app/capture/pausebutton.PNG"))); // NOI18N
- pauseButton.setActionCommand("pause");
- pauseButton.setBorder(javax.swing.BorderFactory
- .createLineBorder(new java.awt.Color(255, 204, 51)));
- pauseButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- pauseButtonActionPerformed(evt);
- }
- });
- stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(
- "/com/actura/app/capture/stopbutton.PNG"))); // NOI18N
- stopButton.setActionCommand("stop");
- stopButton.setBorder(javax.swing.BorderFactory
- .createLineBorder(new java.awt.Color(255, 204, 51)));
- stopButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- stopButtonActionPerformed(evt);
- }
- });
- totalTimeLabel.setFont(new java.awt.Font("Verdana", 1, 14));
- totalTimeLabel.setForeground(new java.awt.Color(255, 204, 51));
- totalTimeLabel.setText("00:00");
- javax.swing.GroupLayout listeningButtonPanel1Layout = new javax.swing.GroupLayout(
- listeningButtonPanel1);
- listeningButtonPanel1.setLayout(listeningButtonPanel1Layout);
- listeningButtonPanel1Layout
- .setHorizontalGroup(listeningButtonPanel1Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- listeningButtonPanel1Layout
- .createSequentialGroup()
- .addGroup(
- listeningButtonPanel1Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- listeningButtonPanel1Layout
- .createSequentialGroup()
- .addGap(
- 56,
- 56,
- 56)
- .addComponent(
- jLabel3,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 116,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(
- playButton,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 44,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(
- pauseButton,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 40,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(
- stopButton,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 32,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(
- totalTimeLabel,
- javax.swing.GroupLayout.Alignment.TRAILING,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 67,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap()));
- listeningButtonPanel1Layout
- .setVerticalGroup(listeningButtonPanel1Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- listeningButtonPanel1Layout
- .createSequentialGroup()
- .addContainerGap()
- .addGroup(
- listeningButtonPanel1Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- listeningButtonPanel1Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(
- jLabel3)
- .addComponent(
- playButton,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 31,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(
- listeningButtonPanel1Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- false)
- .addComponent(
- pauseButton,
- javax.swing.GroupLayout.Alignment.LEADING,
- 0,
- 0,
- Short.MAX_VALUE)
- .addComponent(
- stopButton,
- javax.swing.GroupLayout.Alignment.LEADING,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 31,
- Short.MAX_VALUE)))
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(totalTimeLabel)
- .addContainerGap(
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)));
- playerTimerLabel.setFont(new java.awt.Font("Arial", 1, 14));
- playerTimerLabel.setForeground(new java.awt.Color(51, 0, 255));
- playerTimerLabel.setText("00:00");
- javax.swing.GroupLayout listeningPanelLayout = new javax.swing.GroupLayout(
- listeningPanel);
- listeningPanel.setLayout(listeningPanelLayout);
- listeningPanelLayout
- .setHorizontalGroup(listeningPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- listeningPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .addGroup(
- listeningPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- listeningPanelLayout
- .createSequentialGroup()
- .addComponent(
- playerProgressbar,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- 226,
- Short.MAX_VALUE)
- .addGap(
- 18,
- 18,
- 18)
- .addComponent(
- playerTimerLabel,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 50,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(
- 34,
- 34,
- 34))
- .addGroup(
- listeningPanelLayout
- .createSequentialGroup()
- .addComponent(
- listeningButtonPanel1,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .addContainerGap()))));
- listeningPanelLayout
- .setVerticalGroup(listeningPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- listeningPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .addComponent(
- listeningButtonPanel1,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(
- listeningPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(
- playerTimerLabel)
- .addComponent(
- playerProgressbar,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)));
- listeningPanel.setBounds(20, 40, 0, 0);
- jLayeredPane2.add(listeningPanel,
- javax.swing.JLayeredPane.DEFAULT_LAYER);
- timerLabel.setFont(new java.awt.Font("Arial", 1, 18));
- timerLabel.setText("000");
- secondsLabel.setFont(new java.awt.Font("Verdana", 1, 11));
- secondsLabel.setForeground(java.awt.Color.orange);
- secondsLabel.setText("secs");
- graphPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
- javax.swing.GroupLayout graphPanelLayout = new javax.swing.GroupLayout(
- graphPanel);
- graphPanel.setLayout(graphPanelLayout);
- graphPanelLayout.setHorizontalGroup(graphPanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 369, Short.MAX_VALUE));
- graphPanelLayout.setVerticalGroup(graphPanelLayout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 85,
- Short.MAX_VALUE));
- javax.swing.GroupLayout timerPanelLayout = new javax.swing.GroupLayout(
- timerPanel);
- timerPanel.setLayout(timerPanelLayout);
- timerPanelLayout
- .setHorizontalGroup(timerPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- timerPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .addGroup(
- timerPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(
- graphPanel,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(
- timerPanelLayout
- .createSequentialGroup()
- .addComponent(
- timerLabel)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(
- secondsLabel)))
- .addGap(97, 97, 97)));
- timerPanelLayout.setVerticalGroup(timerPanelLayout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- timerPanelLayout.createSequentialGroup().addGroup(
- timerPanelLayout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(timerLabel,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 28,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(secondsLabel)).addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(graphPanel,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(21, Short.MAX_VALUE)));
- timerPanel.setBounds(10, 10, 390, 140);
- jLayeredPane2.add(timerPanel, javax.swing.JLayeredPane.DEFAULT_LAYER);
- javax.swing.GroupLayout containerFrameLayout = new javax.swing.GroupLayout(
- containerFrame);
- containerFrame.setLayout(containerFrameLayout);
- containerFrameLayout
- .setHorizontalGroup(containerFrameLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- containerFrameLayout
- .createSequentialGroup()
- .addGroup(
- containerFrameLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- containerFrameLayout
- .createSequentialGroup()
- .addComponent(
- messagePanel,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(
- jLayeredPane1,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 137,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(
- jLayeredPane2,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 448,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap()));
- containerFrameLayout
- .setVerticalGroup(containerFrameLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- containerFrameLayout
- .createSequentialGroup()
- .addGroup(
- containerFrameLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING,
- false)
- .addComponent(
- jLayeredPane1)
- .addComponent(
- messagePanel,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE))
- .addGap(18, 18, 18)
- .addComponent(
- jLayeredPane2,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 177,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap()));
- javax.swing.GroupLayout containerPanelLayout = new javax.swing.GroupLayout(
- containerPanel);
- containerPanel.setLayout(containerPanelLayout);
- containerPanelLayout.setHorizontalGroup(containerPanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(containerFrame,
- javax.swing.GroupLayout.PREFERRED_SIZE, 512,
- javax.swing.GroupLayout.PREFERRED_SIZE));
- containerPanelLayout.setVerticalGroup(containerPanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(containerFrame,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE));
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
- getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addComponent(
- containerPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE));
- layout.setVerticalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addComponent(
- containerPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE));
- }// </editor-fold>
- //GEN-END:initComponents
- private void reCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
- if (getCurrentState() == RE_RECORDING_STATE) {
- stopReRecording();
- } else if (getCurrentState() == LISTENING_STATE) {
- stopListening();
- } else if (getCurrentState() == SAVING_STATE) {
- // cancel saving
- cancelSaving();
- } else if (getCurrentState() == NORMAL_STATE) {
- // do nothing
- } else {
- throw new IllegalArgumentException(getCurrentState()
- + " is invalid state");
- }
- // delete file if exist
- if (this.getFileUnderProcessing() != null) {
- if (this.getFileUnderProcessing().exists()) {
- this.getFileUnderProcessing().delete();
- }
- }
- // switch between panels
- this.recordingPanel.setVisible(true);
- this.reRecordingPanel.setVisible(false);
- // set state to Normal
- this.setCurrentState(NORMAL_STATE);
- }
- private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- // disable button
- this.reRecordingButton.setEnabled(false);
- this.listenButton.setEnabled(false);
- // set state
- this.setCurrentState(SAVING_STATE);
- // visible image button
- this.saveImageButton.setVisible(true);
- // prepare file to save
- List<File> lists = new ArrayList<File>();
- lists.add(this.getFileUnderProcessing());
- // paint message to screen
- this.paintError(" Saving file....", ApplicationUtil.INFO);
- // preform save
- ApplicationUtil.saveWaveToServer(lists, parameterMap);
- // increment message counter
- this.incrementMessageCount();
- // set current file to new file
- this.setFileUnderProcessing(ApplicationUtil.generateFile(
- messageCount, parameterMap));
- // set state
- this.setCurrentState(NORMAL_STATE);
- // enable button
- this.reRecordingButton.setEnabled(false);
- this.listenButton.setEnabled(false);
- // paint message to screen
- this.paintError(" Saved Succesfully ", ApplicationUtil.INFO);
- this.saveImageButton.setVisible(false);
- // switch panels
- // switch between panels
- this.recordingPanel.setVisible(true);
- this.reRecordingPanel.setVisible(false);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- private void reRecordingButtonActionPerformed(java.awt.event.ActionEvent evt) {
- int currentCurrentState = getCurrentState();
- if (currentCurrentState == RecorderUI.RE_RECORDING_STATE) {
- stopReRecording();
- this.listenButton.setEnabled(true);
- this.saveButton.setEnabled(true);
- } else {
- startReRecording();
- this.listenButton.setEnabled(false);
- this.saveButton.setEnabled(false);
- }
- }
- void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {
- pausePlayer();
- }
- void playButtonActionPerformed(java.awt.event.ActionEvent evt) {
- startPlayer();
- }
- private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
- if (getCurrentState() == RecorderUI.RECORDING_STATE) {
- // stop recording without switching panel
- this.stopRecording(false);
- // delete any recorded file
- if (this.getFileUnderProcessing() != null) {
- if (this.getFileUnderProcessing().exists()) {
- this.getFileUnderProcessing().delete();
- }
- }
- } // ends recording if
- }
- //GEN-BEGIN:variables
- // Variables declaration - do not modify
- private javax.swing.JButton cancelButton;
- private javax.swing.JPanel containerFrame;
- private javax.swing.JPanel containerPanel;
- private javax.swing.JLabel errorLabel;
- private javax.swing.JPanel graphPanel;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLayeredPane jLayeredPane1;
- private javax.swing.JLayeredPane jLayeredPane2;
- private javax.swing.JButton listenButton;
- private javax.swing.JPanel listeningButtonPanel1;
- private javax.swing.JPanel listeningPanel;
- private javax.swing.JPanel messagePanel;
- private javax.swing.JButton pauseButton;
- private javax.swing.JButton playButton;
- private javax.swing.JProgressBar playerProgressbar;
- private javax.swing.JLabel playerTimerLabel;
- private javax.swing.JButton reCancelButton;
- private javax.swing.JButton reRecordingButton;
- private javax.swing.JPanel reRecordingPanel;
- private javax.swing.JButton recordButton;
- private javax.swing.JPanel recordingPanel;
- private javax.swing.JButton saveButton;
- private javax.swing.JButton saveImageButton;
- private javax.swing.JLabel secondsLabel;
- private javax.swing.JButton stopButton;
- private javax.swing.JLabel timerLabel;
- private javax.swing.JPanel timerPanel;
- private javax.swing.JLabel totalTimeLabel;
- // End of variables declaration//GEN-END:variables
- }
Advertisement
Add Comment
Please, Sign In to add comment