Archive for December, 2007

String inputText = (Anonymous web server) textInputArea.getText(); if (inputText.length() > 0)

Wednesday, December 12th, 2007

String inputText = textInputArea.getText(); if (inputText.length() > 0) playerModel.play(inputText); for the Speak button and textInputArea.setText(”"); for the Clear button. Figure 5.2 shows how the finished PlayerPanel looks in the Visual Editor. The large empty area in the center is reserved for the Face component; to the left and right of this area are spacers. 95 Project One: Duke Speaks Figure 5.2 Integration The graphical design of the user interface of your application is now nearly completed. What is still missing is the integration of the Face component, the initialization of the sliders, and making the content pane visible to the application. You need to embed the Face component into the centerPanel as follows: private javax.swing.JPanel getCenterPanel() { if(centerPanel == null) { centerPanel = new javax.swing.JPanel(); centerPanel.setLayout(new java.awt.GridLayout(1,1)); centerPanel.add(face); } return centerPanel; }
With our Unix hosting accounts you have total control of your Web site content from anywhere in the world.For more information please follow link Unix Web Hosting.

Events In addition, you need to implement some (Php hosting)

Tuesday, December 11th, 2007

Events In addition, you need to implement some event processing for each slider. To do so, apply the Events > stateChanged context function to each slider and replace the pregenerated instruction System.out.println() with playerModel.setVolume((float) volumeSlider.getValue()); for the volumeSlider, playerModel.setSpeakingRate((float) speedSlider.getValue()); for the speedSlider, playerModel.setPitch((float) pitchSlider.getValue()); for the pitchSlider, and playerModel.setRange((float) rangeSlider.getValue()); for the rangeSlider. Labels For the corresponding labels you should set an appropriate text (as discussed in Chapter 3) in the text attribute. In addition, set an appropriate mnemonic code in the displayedMnemonic attribute. However, this definition alone is not sufficient. It does not make sense that the label gets the focus when the defined mnemonic key accelerator is pressed. Instead, the corresponding slider should get the focus. You can achieve this via the setLabelFor() method, for example: rangeLabel.setLabelFor(rangeSlider); By doing so, you could later control the application completely without a mouse and thus improve the accessibility. However, at the moment, the above instruction does not make much sense, because you cannot be sure that the specified rangeSlider instance already exists. You should, therefore, defer the implementation of this instruction to a later time (see below in method getContentPane()). Text The same is true for the textAreaLabel belonging to the text input area. For the textInputArea component the number of lines should be set to five, the lineWrap attribute should be set to true, and under text an appropriate example text should be specified. Buttons For the buttons specify the labeling (text), a tooltip (toolTipText), a mnemonic (displayedMnemonic), and optionally a different background color (background). Here, too, you need to generate appropriate event processing via Events > actionPerformed and to replace the generated System.out.println() instructions with 94 Chapter 5
We are the the largest streaming host company, and we provide professional audio & video web hosting streaming using Real Networks, QuickTime, Flash and Windows Media.We strongly recommend you to visit and check web hosting streaming services.

Web host music - Layouts Most of these panels use BorderLayouts or

Monday, December 10th, 2007

Layouts Most of these panels use BorderLayouts or GridLayouts, but for the buttonPanel a FlowLayout is used. In the BorderLayouts the most important element is placed into the Center area; all other elements are placed into the North, South, East, or West areas. For example, each slider sits in the Center area of its panel, while the corresponding label is placed into the North area. The centerPanel component has a GridLayout of the size 1×1. The single grid field will later contain the Face component. Using the GridLayout guarantees that the Face component is correctly resized when the size of the window changes. Also the leftSlidersPanel and rightSlidersPanel panels are equipped with GridLayouts. One grid cell is filled with an empty label that acts as spacer. The following table shows which Layout is used for which component. Panel Layout Row Column contentPanel BorderLayout - - controlAreaPanel GridLayout 1 3 leftSlidersPanel GridLayout 1 3 volumePanel BorderLayout - - speedPanel BorderLayout - - centerPanel GridLayout 1 1 rightSlidersPanel GridLayout 1 3 pitchPanel BorderLayout - - rangePanel BorderLayout - - textAreaAndButtonsPanel BorderLayout - - buttonPanel FlowLayout - - Sliders The sliders also need some adjustments in the Properties view. First, you must set their orientation to VERTICAL. Then you must specify the minimum and maximum values and the scaling (minorTickSpacing and majorTickSpacing), and you must indicate that the track, scale, and labels must be drawn, that is, you must set the paintLabels, paintTicks, and paintTrack attributes to true. You should also specify an appropriate tooltip under toolTipText. The following table shows the bounding and scaling attributes of the various sliders. Slider Minimum Maximum minorTick majorTick volumeSlider 0 10 1 5 speedSlider 0 400 50 100 pitchSlider 50 200 25 50 rangeSlider 0 50 5 10 93 Project One: Duke Speaks
Our stuff is composed of devoted and highly-tainted professionals, creating a mix of powerful and high-quality web hosting perl services, check web hosting perl.

// The JPanel (Http web server) instance for the face private

Sunday, December 9th, 2007

// The JPanel instance for the face private JPanel face; public PlayerPanel(PlayerModel playerModel, JPanel face) { super(); // Save parameters into fields this.playerModel = playerModel; this.face = face; } } Listing 5.6 (Continued) Visual Editor Now you can close the Java Editor and open the same class again with the Visual Editor. Figure 5.1 shows the hierarchy of GUI elements. First, place a JPanel component into the design area and pull it up to 600 by 500 pixels, or enter this size in the Size entry in the Properties View. Then you can subdivide this content pane into additional JPanels in order to place the face and sliders for volume, speed, pitch, and variation on top of it. In addition, you need a field for text input, a few buttons, and, of course, the necessary event processing for these control elements. 92 Chapter 5 Figure 5.1
Our facility is located in Orlando, Florida. Our Orlando web hosting data center gives you assurance that your website will work smoothly . Check more in Orlando Web Hosting.

// Set speaking rate in Voice instance voice.setRate(wordsPerMin); (Apache web server tutorial)

Saturday, December 8th, 2007

// Set speaking rate in Voice instance voice.setRate(wordsPerMin); } /** * @see PlayerModel#getPitch() */ public float getPitch() { // Get pitch from Voice instance return voice.getPitch(); } /** * @see PlayerModel#setPitch(float) */ public void setPitch(float pitch) { // Set pitch in Voice instance voice.setPitch(pitch); } /** * @see PlayerModel#getRange() */ public float getRange() { // Get variation from Voice instance return voice.getPitchRange(); } /** * @see PlayerModel#setRange(float) */ public void setRange(float range) { // Set variation in Voice instance voice.setPitchRange(range); } } Listing 5.5 (Continued) The Presentation After defining the domain model you can implement the visible part of the user interface. This is done in the PlayerPanel class, which is implemented as a subclass of the Swing JPanel class in the com.bdaum.dukeSpeaks package. To implement this class you can use the Visual Editor for Java (VE) that was already discussed in Chapter 3. After creating the PlayerPanel class in the usual way, define the instance fields and the constructor (Listing 5.6). public class PlayerPanel { // The data model private PlayerModel playerModel; 91 Project One: Duke Speaks Listing 5.6 (Continues)
Our unmatched NT experience allows us to provide the most reliable and affordable hosting for our customers, just check NT Web Hosting services.

Php web hosting - } /** * @see PlayerModel#play(String) */ public void

Friday, December 7th, 2007

} /** * @see PlayerModel#play(String) */ public void play(final String text) { // do nothing if player runs already. if (playing) return; // Set semaphore to true playing = true; // The speech process runs in a separate thread // that is managed by the SwingWorker instance worker final SwingWorker worker = new SwingWorker() { public Object construct() { // This is where Duke speaks voice.speak(text); return null; } }; worker.start(); // Reset semaphore playing = false; } /** * @see PlayerModel#getVolume() */ public float getVolume() { // Get volume from Voice instance // and convert to scale range 0-10 float adjustedVolume = voice.getVolume(); return (adjustedVolume < 0.5) ? 0f : (float) ((adjustedVolume - 0.5) * 20); } /** * @see PlayerModel#setVolume(float) */ public void setVolume(float volume) { // Set volume in Voice instance // convert from scale range 0-10 to Voice range 0.5-1.0 float adjustedVolume = (float) (volume / 20 + 0.5); voice.setVolume(adjustedVolume); } /** * @see PlayerModel#getSpeakingRate() */ public float getSpeakingRate() { // Get speaking rate from Voice instance return voice.getRate(); } /** * @see PlayerModel#setSpeakingRate(float) */ public void setSpeakingRate(float wordsPerMin) { 90 Chapter 5 Listing 5.5 (Continues)
The UK has been a member of the European Union since 1973. The attitude of the present government towards further integration is conservative, with the official opposition favoring a return of some powers and competencies to the UK.From our experience, we can recommend Cheap UK Web Hosting services.

public void setSpeakingRate(float wordsPerMin); /** (Web hosting directory) * Returns the

Thursday, December 6th, 2007

public void setSpeakingRate(float wordsPerMin); /** * Returns the baseline pitch for the current synthesis voice. * * @return the baseline pitch for the current synthesis voice */ public float getPitch(); /** * Sets the baseline pitch for the current synthesis voice. * * @param pitch the baseline pitch */ public void setPitch(float pitch); /** * Returns the pitch range for the current synthesis voice. * * @return the pitch range for the current synthesis voice */ public float getRange(); /** * Sets the pitch range for the current synthesis voice. * * @param range the pitch range */ public void setRange(float range); /** * Performs text-to-speech on the given text. * * @param text the text to perform TTS */ public void play(String text); } The PlayerModelImpl.java class package com.bdaum.dukeSpeaks; import com.sun.speech.freetts.Voice; public class PlayerModelImpl implements PlayerModel { // The Voice instance used in this model private Voice voice; // Semaphore for inhibiting double playing private boolean playing = false; /** * Method PlayerModelImpl. * @param voice a FreeTTS voice object. */ public PlayerModelImpl(Voice voice) { this.voice = voice; 89 Project One: Duke Speaks Listing 5.5 (Continues)
Our facility is located in Orlando, Florida. Our Orlando web hosting data center gives you assurance that your website will work smoothly . Check more in Orlando Web Hosting.

. When you opt to (Web hosting directory) create the PlayerModel

Wednesday, December 5th, 2007

. When you opt to create the PlayerModel interface first, you can specify the interface later when you create the PlayerModelImpl class. Eclipse will then generate all the method stubs for you. This method is particularly interesting if you already have a clear idea of the domain model s API. . Otherwise, when you opt to create the PlayerModelImpl implementation first, you can later easily generate the PlayerModel interface from the implementation with the help of the Refactor > Extract Interface context function. This technique is recommended when the API of the model is shaped during the implementation. Actually, in the beginning you can work without an interface entirely. You simply use the methods of the implementation. Later, when your domain model has matured and is stable, you can derive the interface with the mentioned context function. This function will also replace all implementation methods references with references to interface methods, provided this does not lead to compilation problems. The main task of a PlayerModel instance (Listing 5.5) is to encapsulate a FreeTTS Voice and to provide access methods to control volume, speed, pitch, and variation. In addition, there is a play() method that runs the speak() method of the Voice instance in a separate thread. For this task you can use a SwingWorker instance, so that the speech process does not lock up the GUI. The SwingWorker class that is called from the play() method does not belong to the javax.swing packages, but you can obtain it from http://java.sun.com/docs/books/tutorial/uiswing/ misc/ threads.html or as part of this example s source code from www.wrox.com. The PlayerModel.java interface package com.bdaum.dukeSpeaks; public interface PlayerModel { /** * Returns the volume. * * @return the volume, or -1 if unknown, or an error occurred */ public float getVolume(); /** * Sets the volume. * * @param volume set the volume of the synthesizer */ public void setVolume(float volume); /** * Returns the speaking rate. * * @return the speaking rate, or -1 if unknown or an error occurred */ public float getSpeakingRate(); /** * Sets the speaking rate in the number of words per minute. * * @param wordsPerMin the speaking rate */ 88 Chapter 5 Listing 5.5 (Continues)
MySQL web hosting will be off your worry about list if you sign up with us,just trust us and go check MySQL Web Hosting services.

Tomcat web hosting - int eyeInner = eyeDia / 2; int eyeY

Tuesday, December 4th, 2007

int eyeInner = eyeDia / 2; int eyeY = height / 4; int eyeX = midX - eyeDia / 3; int eyeOff = width / 6; int noseY = height / 3; int noseLength = height / 4; int noseWidth = width / 12; // Draw eyes g.setColor(Color.blue); g.drawOval(midX - eyeOff - eyeDia / 3, eyeY, eyeDia, eyeDia); g.drawOval(midX + eyeOff - eyeDia / 3, eyeY, eyeDia, eyeDia); // Draw eye pupils int ey = eyeY + ((int) (eyeDia * eyePos)); g.fillOval(eyeX - eyeOff, ey, eyeInner, eyeInner); g.fillOval(eyeX + eyeOff, ey, eyeDia / 2, eyeDia / 2); // Draw nose g.drawPolyline( new int[] { midX, midX + noseWidth, midX }, new int[] { noseY, noseY + noseLength, noseY + noseLength }, 3); // Compute mouth dimensions int mw = (int) (width * mouthWidth / 4); int mh = (int) (height * mouthHeight / 4); int mx = midX - mw / 2; int my = midY - mh / 4; // Draw mouth g.fillOval(mx, my, mw, mh); } } The Control Panel Now you can begin to construct the control panel. This unit must contain the animated face in its center, below the face a field for text entry, at the left and right of the face sliders for adjusting volume, speed, pitch, and variation. Two new classes and one interface are needed to implement this control unit: . The PlayerModel interface specifies the interface of the control panel s domain model. . This interface is implemented by the PlayerModelImpl class. . The PlayerPanel class implements the presentation of the data and the various control instruments with the help of Swing. So, the typical MVC design pattern (Model-View-Controller) is used here. PlayerPanel acts as both a viewer and a controller. The Model When implementing the domain model you have the choice of writing the implementation class first or starting with the definition of the interface. In fact, you could omit the interface altogether, but having a separate interface adds some flexibility: 87 Project One: Duke Speaks
Sbc yahoo internet provider is a name that we will not do any shame to. We are as good in what we do. Our sbc yahoo web hosting team will work hard to meet and satisfy all your web hosting needs.Try us out!

Business web site - case ‘u’ : mouthWidth = 0.5f; mouthHeight =

Tuesday, December 4th, 2007

case ‘u’ : mouthWidth = 0.5f; mouthHeight = 0.5f; break; // Ah’s case ‘a’ : mouthWidth = 0.75f; mouthHeight = 0.75f; break; // Eh’s and Ih’s case ‘e’ : case ‘i’ : mouthWidth = 1f; mouthHeight = 0.1f; break; // Alles andere default : mouthWidth = 0.6f; mouthHeight = 0.3f; break; } } repaint(); } The paintComponent() method is called when the Face component is redrawn. The graphical context is passed as a parameter. Via a type cast (Graphics2D) you convert it into a Java2D context. Then you enable anti-aliasing and employ the usual graphical methods such as fillOval(), drawOval(), or drawPolyline() to draw the face. The size and position of the mouth and the eye pupils depend on the values previously computed from the transmitted phonemes. /** * @see javax.swing.JComponent#paintComponent(Graphics) */ protected void paintComponent(Graphics cg) { super.paintComponent(cg); // Cast for Java2D Graphics2D g = (Graphics2D) cg; // Compute component size Dimension d = getSize(); int width = (int) d.getWidth(); int height = (int) d.getHeight(); // Switch off Antialiasing g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Draw face g.setColor(Color.white); g.fillOval(0, 0, width, height); // Some face dimensions int midX = width / 2; int midY = height * 3 / 4; int eyeDia = height / 10; 86 Chapter 5