Author: jerome
Date: 2008-08-16 08:14:18 +0200 (Sat, 16 Aug 2008)
New Revision: 1508

Added:
   
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
   software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/Ini.java
Modified:
   software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath
   
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ChatterTux.java
Log:
* Configuration interface.

Modified: 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath
===================================================================
--- software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath    
2008-08-15 21:06:52 UTC (rev 1507)
+++ software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath    
2008-08-16 06:14:18 UTC (rev 1508)
@@ -2,5 +2,6 @@
 <classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/TuxAPI"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>

Modified: 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ChatterTux.java
===================================================================
--- 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ChatterTux.java
   2008-08-15 21:06:52 UTC (rev 1507)
+++ 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ChatterTux.java
   2008-08-16 06:14:18 UTC (rev 1508)
@@ -132,7 +132,8 @@
                        this.ok.addMouseListener(new 
java.awt.event.MouseAdapter(){
                                public void 
mousePressed(java.awt.event.MouseEvent event){
                                        
if(group.getSelection().equals(configure.getModel())){
-                                               //Start configuration 
+                                               new ConfInterface(); //launch 
configuration interface.
+                                               frame.setVisible(false);
                                        }else 
if(group.getSelection().equals(startServer.getModel())){
                                                //Start chatter Tux
                                                ChatterTuxServer.start();

Added: 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
===================================================================
--- 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
                                (rev 0)
+++ 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
        2008-08-16 06:14:18 UTC (rev 1508)
@@ -0,0 +1,187 @@
+/* This file is part of "TuxDroid Chatter Tux tool".
+ *    Copyright 2008, kysoh
+ *    Author : Conan Jerome
+ *    eMail  : [EMAIL PROTECTED]
+ *    Site   : http://www.kysoh.com/
+ *
+ * "TuxDroid Chatter Tux tool" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "TuxDroid Chatter Tux tool" is distributed in the hope that it will be 
useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "TuxDroid Control Center"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+import javax.swing.AbstractListModel;
+import javax.swing.BorderFactory;
+import javax.swing.ComboBoxModel;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.JSpinner;
+import javax.swing.JComboBox;
+import javax.swing.SpinnerListModel;
+
+import com.tuxisalive.api.TuxAPI;
+import com.tuxisalive.api.TuxAPIConst;
+
+import java.awt.Dimension;
+import java.awt.Point;
+import java.io.File;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Chatter Tux configuration Object.
+ */
+public class ConfInterface {
+       
+       private JFrame frame;
+       private JPanel jContentPane;
+       private JPanel voiceConfigPanel;
+       private JPanel actionModifier;
+       
+       private JComboBox locutorSet;
+       private JSpinner pitchSet;
+       
+       private File iniFile = new 
File("c:\\tuxdroid\\bin\\chattertux\\ChatterTux.ini");
+       private String location;
+       
+       //** Configuration objects
+       Locale locale;
+       List<String> installedTuxLanguages;
+       List<String> availableLocutors;
+       int currentPitch = 120;
+       
+       //** Tux Object.
+       private TuxAPI api;
+
+       public ConfInterface(){
+               if(iniFile.isFile()){
+                       this.getFrame();
+                       locale = Locale.getDefault(); //Getting language.
+                       
+                       //Create tux api object.
+                       this.api = new TuxAPI("127.0.0.1", 270);
+                       api.event.handler.register("all", api, "onAllEvent");
+                       
+                       
api.event.handler.register(TuxAPIConst.ST_NAME_RADIO_STATE, this, 
+                                                                               
        "onRadioConnected", "True", null);
+                       
api.event.handler.register(TuxAPIConst.ST_NAME_RADIO_STATE, this, 
+                                                                       
"onRadioDisconnected", "False", null);
+                       //api connection.
+                       
api.server.autoConnect(TuxAPIConst.CLIENT_LEVEL_RESTRICTED, 
+                                                                       
"Chatter", "work");
+                       api.server.waitConnected(2.0);
+                       
+                       if(api.radio.getConnected()) 
this.onRadioConnected(null, null);
+                       
+               }else{
+                       String message = "Unable to find configuration file";
+                       String paneTitle = "ChatterTux Error";
+                       JOptionPane.showMessageDialog(null, message, paneTitle, 
JOptionPane.ERROR_MESSAGE);
+               }
+       }
+       
+       //Radio connected event.
+       public void onRadioConnected(String value, Double delay){
+               this.installedTuxLanguages = api.tts.getVoices();
+               //Setting combobox values here.
+               for(String val : this.installedTuxLanguages){
+                       this.locutorSet.addItem((String)val);
+               }
+               
+               this.currentPitch = api.tts.getPitch();
+               //Setting spinner values here.
+               this.pitchSet.setValue(this.currentPitch);
+       }
+       
+       //Radio diconnected event.
+       public void onRadioDisconnected(String value, Double delay){
+               
+       }
+       
+       //Gets frame.
+       public JFrame getFrame(){
+               if(this.frame == null){
+                       frame = new JFrame("Chatter Tux configuration");
+                       frame.setSize(new Dimension(400, 400));
+                       frame.setPreferredSize(frame.getSize());
+                       
+                       frame.add(this.getJContentPane());
+                       frame.setVisible(true);
+                       frame.pack();
+               }
+               return frame;
+       }
+       
+       //Gets content pane.
+       public JPanel getJContentPane(){
+               if(jContentPane == null){
+                       this.jContentPane = new JPanel();
+                       this.jContentPane.setLayout(null);
+                       
this.jContentPane.add(this.getVoiceConfigurationPanel());
+                       this.jContentPane.add(this.getActionsPanel());
+               }
+               return jContentPane;
+       }
+       
+       
+       //Gets voice configuration panel.
+       public JPanel getVoiceConfigurationPanel(){
+               if(this.voiceConfigPanel == null){
+                       this.voiceConfigPanel = new JPanel();
+                       
this.voiceConfigPanel.setBorder(BorderFactory.createTitledBorder("Voice 
Configuration"));
+                       this.voiceConfigPanel.setSize(new 
Dimension(this.frame.getWidth() - 24, 92));
+                       
this.voiceConfigPanel.setPreferredSize(this.voiceConfigPanel.getSize());
+                       this.voiceConfigPanel.setLayout(null);
+                       this.voiceConfigPanel.setLocation(new Point(4, 4));
+                       
+                       //Adding voice configuration components.
+                       this.locutorSet = new JComboBox();
+                       this.pitchSet = new JSpinner();
+                       this.locutorSet.setSize(new Dimension(150, 22));
+                       this.pitchSet.setSize(new Dimension(50, 22));
+                       
this.locutorSet.setPreferredSize(this.locutorSet.getSize());
+                       this.pitchSet.setPreferredSize(this.pitchSet.getSize());
+                       this.locutorSet.setLocation(new Point(20, 26));
+                       this.pitchSet.setLocation(new Point(20, 58));
+                       this.voiceConfigPanel.add(this.locutorSet);
+                       this.voiceConfigPanel.add(this.pitchSet);
+                       
+                       Integer[] values = new Integer[151];
+                       for(int i=50; i < 201; i++){
+                               values[i-50] = Integer.valueOf(i);
+                       }
+                       this.pitchSet.setModel(new SpinnerListModel(values));
+                       
+               }
+               return this.voiceConfigPanel;
+       }
+       
+
+       //Gets registered Tchatter Tux actions.
+       public JPanel getActionsPanel(){
+               if(this.actionModifier == null){
+                       this.actionModifier = new JPanel();
+                       
this.actionModifier.setBorder(BorderFactory.createTitledBorder("Registered 
actions"));
+                       this.actionModifier.setLayout(null);
+                       this.actionModifier.setSize(new 
Dimension(voiceConfigPanel.getSize()));
+                       
this.actionModifier.setPreferredSize(this.actionModifier.getSize());
+                       int x = this.voiceConfigPanel.getX() +4 
+this.voiceConfigPanel.getHeight();
+                       int y = this.voiceConfigPanel.getY() + 4 + 
this.voiceConfigPanel.getWidth();
+                       this.actionModifier.setLocation(new Point(x, y));
+               }
+               return this.actionModifier;
+       }
+       
+}

Added: 
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/Ini.java
===================================================================


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to