RecordingDialog.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00017 package com.generalrobotix.ui.view.tdview;
00018 
00019 import java.awt.*;
00020 import javax.swing.*;
00021 
00022 import com.generalrobotix.ui.grxui.Activator;
00023 import com.generalrobotix.ui.util.FileInput;
00024 import com.generalrobotix.ui.util.MessageBundle;
00025 import com.generalrobotix.ui.util.ModalDialog;
00026 
00027 @SuppressWarnings("serial") //$NON-NLS-1$
00028 public class RecordingDialog extends ModalDialog {
00029 
00030 //       --------------------------------------------------------------------
00031     // Instance variables
00032         private static final Dimension[] imageSize_ =
00033          new Dimension[] {
00034              new Dimension(320, 240),
00035              new Dimension(640, 480),
00036              new Dimension(800, 600),
00037          };
00038         private static final double[] playbackRate_ =
00039                  new double[] { 4, 2, 1, 0.5, 0.25 };
00040         private static final String[] playbackRateString_ =
00041                  new String[] { "x 4", "x 2", "x 1", "x 1/2", "x 1/4" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
00042          
00043     private FileInput fileInput_;
00044     private JComboBox imSizeCombo_;
00045     private JComboBox playbackRateCombo_;
00046     private JTextField frameRateField_;
00047     private JTextField startTimeField_;
00048     private JTextField endTimeField_;
00049     private double logEndTime_;
00050     public RecordingDialog(Frame owner, double endTime) {
00051         super(
00052             owner,
00053             MessageBundle.get("RecordingDialog.dialog.title.recording"), //$NON-NLS-1$
00054             MessageBundle.get("RecordingDialog.dialog.message.recording"), //$NON-NLS-1$
00055             OK_CANCEL_TYPE
00056         );
00057 
00058                 fileInput_ = new FileInput(new String[] { "mov" }, Activator.getDefault().getPreferenceStore().getString("PROJECT_DIR")); //$NON-NLS-1$ //$NON-NLS-2$
00059                 imSizeCombo_ = new JComboBox(_makeSizeStrings(imageSize_));
00060         playbackRateCombo_ = new JComboBox(playbackRateString_);
00061         playbackRateCombo_.setSelectedIndex(2);
00062         frameRateField_ = new JTextField("10"); //$NON-NLS-1$
00063         startTimeField_ = new JTextField("0.0");
00064         endTimeField_ = new JTextField(String.format("%.5f", endTime));
00065         logEndTime_ = endTime;
00066         
00067         addInputComponent(MessageBundle.get("RecordingDialog.label.fileName"), fileInput_, MULTILINE_CAPTION, true); //$NON-NLS-1$
00068         addInputComponent(MessageBundle.get("RecordingDialog.label.imageSize"), imSizeCombo_, MULTILINE_CAPTION, true); //$NON-NLS-1$
00069         addInputComponent(MessageBundle.get("RecordingDialog.label.playRate"), playbackRateCombo_, MULTILINE_CAPTION, true); //$NON-NLS-1$
00070         addInputComponent(MessageBundle.get("RecordingDialog.label.frameRate"), frameRateField_, MULTILINE_CAPTION, true); //$NON-NLS-1$
00071         addInputComponent(MessageBundle.get("RecordingDialog.label.startTime"), startTimeField_, INLINE_CAPTION, true);
00072         addInputComponent(MessageBundle.get("RecordingDialog.label.endTime"), endTimeField_, INLINE_CAPTION, true);
00073                 setInputAreaWidth(300);
00074          }
00075     
00076     public double getStartTime(){
00077         double startTime;
00078         try{
00079                 startTime = Double.parseDouble(startTimeField_.getText());
00080         }catch (NumberFormatException e){
00081                 startTime = 0.0;
00082         }
00083         if(startTime < 0.0)
00084                 startTime = 0.0;
00085         return startTime;
00086     }
00087     
00088     public double getEndTime(){
00089         double endTime;
00090         try{
00091                 endTime = Double.parseDouble(endTimeField_.getText());
00092         }catch (NumberFormatException e){
00093                 endTime = 0.0;
00094         }
00095         if(endTime > logEndTime_)
00096                 endTime = logEndTime_;
00097         return endTime;
00098     }
00099 
00100     public String getFileName() {
00101         return fileInput_.getFileName();
00102     }
00103 
00104     public Dimension getImageSize() {
00105                 return new Dimension(imageSize_[imSizeCombo_.getSelectedIndex()]);
00106             }
00107 
00108             public double getPlaybackRate() throws NumberFormatException {
00109                 return playbackRate_[playbackRateCombo_.getSelectedIndex()];
00110             }
00111 
00112             public int getFrameRate() throws NumberFormatException {
00113                 return Integer.parseInt(frameRateField_.getText()); 
00114             }
00115 
00116             private String[] _makeSizeStrings(Dimension[] size) {
00117                 String[] sizeString = new String[size.length];
00118                 for (int i = 0; i < size.length; i ++) {
00119                     StringBuffer buf = new StringBuffer();
00120                     buf.append(size[i].width);
00121                     buf.append('x');
00122                     buf.append(size[i].height);
00123                     sizeString[i] = buf.toString();
00124                 }
00125                 return sizeString;
00126             }
00127          
00128         }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:19