format java code in marytts-client

incantation:
$ mvn com.googlecode.maven-java-formatter-plugin:maven-java-formatter-plugin:format -pl marytts-client
This commit is contained in:
Ingmar Steiner 2014-12-19 13:09:01 +01:00
Родитель b1e6548ed5
Коммит f1ff6ad856
21 изменённых файлов: 5536 добавлений и 5564 удалений

Просмотреть файл

@ -1,6 +1,6 @@
/**
* Copyright 2007 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
/**
* Copyright 2007 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
*
* This file is part of MARY TTS.
*
@ -17,46 +17,74 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package marytts.client;
/**
* Data for an audio effect control.
*
* @author Oytun T&uumlrk
*
*/
public class AudioEffectControlData {
private String effectName;
private String helpText;
private String exampleParams;
private String params;
private boolean isSelected;
public AudioEffectControlData(String strEffectNameIn, String strExampleParams, String strHelpTextIn)
{
init(strEffectNameIn, strExampleParams, strHelpTextIn);
}
public void init(String strEffectNameIn, String strExampleParamsIn, String strHelpTextIn)
{
setEffectName(strEffectNameIn);
setExampleParams(strExampleParamsIn);
setHelpText(strHelpTextIn);
setEffectParamsToExample();
}
public void setEffectName(String strEffectName) { effectName = strEffectName; }
public String getEffectName() { return effectName; }
public void setHelpText(String strHelpText) { helpText = strHelpText; }
public String getHelpText() { return helpText; }
public void setParams(String strParams) { params = strParams; }
public String getParams() { return params; }
public void setExampleParams(String strExampleParams) { exampleParams = strExampleParams; }
public String getExampleParams() { return exampleParams; }
public void setEffectParamsToExample() { setParams(exampleParams); }
public void setSelected(boolean bSelected) { isSelected = bSelected; }
public boolean getSelected() { return isSelected; }
}
package marytts.client;
/**
* Data for an audio effect control.
*
* @author Oytun T&uumlrk
*
*/
public class AudioEffectControlData {
private String effectName;
private String helpText;
private String exampleParams;
private String params;
private boolean isSelected;
public AudioEffectControlData(String strEffectNameIn, String strExampleParams, String strHelpTextIn) {
init(strEffectNameIn, strExampleParams, strHelpTextIn);
}
public void init(String strEffectNameIn, String strExampleParamsIn, String strHelpTextIn) {
setEffectName(strEffectNameIn);
setExampleParams(strExampleParamsIn);
setHelpText(strHelpTextIn);
setEffectParamsToExample();
}
public void setEffectName(String strEffectName) {
effectName = strEffectName;
}
public String getEffectName() {
return effectName;
}
public void setHelpText(String strHelpText) {
helpText = strHelpText;
}
public String getHelpText() {
return helpText;
}
public void setParams(String strParams) {
params = strParams;
}
public String getParams() {
return params;
}
public void setExampleParams(String strExampleParams) {
exampleParams = strExampleParams;
}
public String getExampleParams() {
return exampleParams;
}
public void setEffectParamsToExample() {
setParams(exampleParams);
}
public void setSelected(boolean bSelected) {
isSelected = bSelected;
}
public boolean getSelected() {
return isSelected;
}
}

Просмотреть файл

@ -1,6 +1,6 @@
/**
* Copyright 2007 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
/**
* Copyright 2007 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
*
* This file is part of MARY TTS.
*
@ -17,140 +17,139 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package marytts.client;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
*
* An AudioEffectControlGUI consists of a checkbox, a text pane, a text field, and a button.
* <p>
* The checkbox indicates whether the effect will be applied or not.
* <p>
* The label contains the name of the effect.
* <p>
* The text field contains the parameters of the effect.
* <p>
* The button shows help information about the usage of the effect when clicked.
* <p>
*
* @author Oytun T&uumlrk
*/
public class AudioEffectControlGUI {
private AudioEffectControlData data; //All data this control has about the audio effect
public JPanel mainPanel;
public JCheckBox chkEnabled;
public JTextField txtParams;
public JButton btnHelp;
private boolean isVisible; //This can be used for not showing a specific effect for specific voices
public boolean isHelpWindowOpen;
private JFrame helpWindow; //Window to show help context
//Create a Mary audio effect with help text
public AudioEffectControlGUI(AudioEffectControlData dataIn)
{
data = dataIn;
mainPanel = new JPanel();
chkEnabled = new JCheckBox();
txtParams = new JTextField("Parameters");
btnHelp = new JButton("?");
isVisible = true;
isHelpWindowOpen = false;
}
public void setVisible(boolean bShow) { isVisible = bShow; }
public boolean getVisible() { return isVisible; }
public AudioEffectControlData getData() { return data; }
public void show()
{
mainPanel.removeAll();
mainPanel.validate();
if (isVisible)
{
GridBagLayout g = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
mainPanel.setLayout(g);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
g.setConstraints(chkEnabled, c);
chkEnabled.setPreferredSize(new Dimension(100,25));
chkEnabled.setText(data.getEffectName());
chkEnabled.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
data.setSelected(((JCheckBox)e.getSource()).isSelected());
}
});
mainPanel.add(chkEnabled);
c.gridx = 1;
g.setConstraints(chkEnabled, c);
txtParams.setPreferredSize(new Dimension(150,25));
txtParams.setText(data.getParams());
mainPanel.add(txtParams);
c.gridx = GridBagConstraints.RELATIVE;
g.setConstraints(btnHelp, c);
btnHelp.setPreferredSize(new Dimension(45,25));
mainPanel.add(btnHelp);
btnHelp.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!isHelpWindowOpen)
{
isHelpWindowOpen = true;
helpWindow = new JFrame("Help: " + chkEnabled.getText() + " Effect");
JTextArea helpTextArea = new JTextArea(data.getHelpText());
helpTextArea.setEditable(false);
helpWindow.getContentPane().add(helpTextArea, BorderLayout.WEST);
helpWindow.pack();
helpWindow.setLocation(btnHelp.getLocation().x, btnHelp.getLocation().y);
helpWindow.setVisible(true);
helpWindow.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent winEvt) {
// Perhaps ask user if they want to save any unsaved files first.
isHelpWindowOpen = false;
}
});
}
else
{
if (helpWindow!=null)
helpWindow.requestFocus();
}
}
});
}
mainPanel.validate();
}
}
package marytts.client;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
*
* An AudioEffectControlGUI consists of a checkbox, a text pane, a text field, and a button.
* <p>
* The checkbox indicates whether the effect will be applied or not.
* <p>
* The label contains the name of the effect.
* <p>
* The text field contains the parameters of the effect.
* <p>
* The button shows help information about the usage of the effect when clicked.
* <p>
*
* @author Oytun T&uumlrk
*/
public class AudioEffectControlGUI {
private AudioEffectControlData data; // All data this control has about the audio effect
public JPanel mainPanel;
public JCheckBox chkEnabled;
public JTextField txtParams;
public JButton btnHelp;
private boolean isVisible; // This can be used for not showing a specific effect for specific voices
public boolean isHelpWindowOpen;
private JFrame helpWindow; // Window to show help context
// Create a Mary audio effect with help text
public AudioEffectControlGUI(AudioEffectControlData dataIn) {
data = dataIn;
mainPanel = new JPanel();
chkEnabled = new JCheckBox();
txtParams = new JTextField("Parameters");
btnHelp = new JButton("?");
isVisible = true;
isHelpWindowOpen = false;
}
public void setVisible(boolean bShow) {
isVisible = bShow;
}
public boolean getVisible() {
return isVisible;
}
public AudioEffectControlData getData() {
return data;
}
public void show() {
mainPanel.removeAll();
mainPanel.validate();
if (isVisible) {
GridBagLayout g = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
mainPanel.setLayout(g);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
g.setConstraints(chkEnabled, c);
chkEnabled.setPreferredSize(new Dimension(100, 25));
chkEnabled.setText(data.getEffectName());
chkEnabled.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
data.setSelected(((JCheckBox) e.getSource()).isSelected());
}
});
mainPanel.add(chkEnabled);
c.gridx = 1;
g.setConstraints(chkEnabled, c);
txtParams.setPreferredSize(new Dimension(150, 25));
txtParams.setText(data.getParams());
mainPanel.add(txtParams);
c.gridx = GridBagConstraints.RELATIVE;
g.setConstraints(btnHelp, c);
btnHelp.setPreferredSize(new Dimension(45, 25));
mainPanel.add(btnHelp);
btnHelp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!isHelpWindowOpen) {
isHelpWindowOpen = true;
helpWindow = new JFrame("Help: " + chkEnabled.getText() + " Effect");
JTextArea helpTextArea = new JTextArea(data.getHelpText());
helpTextArea.setEditable(false);
helpWindow.getContentPane().add(helpTextArea, BorderLayout.WEST);
helpWindow.pack();
helpWindow.setLocation(btnHelp.getLocation().x, btnHelp.getLocation().y);
helpWindow.setVisible(true);
helpWindow.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent winEvt) {
// Perhaps ask user if they want to save any unsaved files first.
isHelpWindowOpen = false;
}
});
} else {
if (helpWindow != null)
helpWindow.requestFocus();
}
}
});
}
mainPanel.validate();
}
}

Просмотреть файл

@ -1,101 +1,95 @@
/**
* Copyright 2007 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
*
* This file is part of MARY TTS.
*
* MARY TTS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package marytts.client;
import marytts.util.string.StringUtils;
/**
* Data for a set of audio effects, i.e. "an audio effects box".
*
* @author Oytun T&uumlrk
*
*/
public class AudioEffectsBoxData {
private AudioEffectControlData[] effectControlsData;
//availableEffects is one large string produced by the server in the following format:
// <EffectSeparator>charEffectSeparator</EffectSeparator>
// <Effect>
// <Name>effect´s name</Name>
// <SampleParam>example parameters string</SampleParam>
// <HelpText>help text string</HelpText>
// </Effect>
// <Effect>
// <Name>effect´s name</effectName>
// <SampleParam>example parameters string</SampleParam>
// <HelpText>help text string</HelpText>
// </Effect>
// ...
// <Effect>
// <Name>effect´s name</effectName>
// <SampleParam>example parameters string</SampleParam>
// <HelpText>help text string</HelpText>
// </Effect>
public AudioEffectsBoxData(String availableEffects)
{
effectControlsData = null;
if (availableEffects!=null && availableEffects.length()>0)
parseAvailableEffects(availableEffects);
}
public AudioEffectControlData getControlData(int index)
{
if (effectControlsData!=null && index>=0 && index<effectControlsData.length)
return effectControlsData[index];
else
return null;
}
public boolean hasEffects()
{
return effectControlsData!=null;
}
//Parse the XML-like full effect set string from the server
protected int parseAvailableEffects(String availableEffects)
{
String[] effectLines = StringUtils.toStringArray(availableEffects);
effectControlsData = new AudioEffectControlData[effectLines.length];
for (int i=0; i< effectLines.length; i++) {
String strEffectName, strParams;
int iSpace = effectLines[i].indexOf(' ');
if (iSpace != -1) {
strEffectName = effectLines[i].substring(0, iSpace);
strParams = effectLines[i].substring(iSpace+1);
} else { // no params
strEffectName = effectLines[i];
strParams = "";
}
effectControlsData[i] = new AudioEffectControlData(strEffectName, strParams, null);
}
return getTotalEffects();
}
public int getTotalEffects()
{
if (effectControlsData!=null)
return effectControlsData.length;
else
return 0;
}
}
/**
* Copyright 2007 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
*
* This file is part of MARY TTS.
*
* MARY TTS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package marytts.client;
import marytts.util.string.StringUtils;
/**
* Data for a set of audio effects, i.e. "an audio effects box".
*
* @author Oytun T&uumlrk
*
*/
public class AudioEffectsBoxData {
private AudioEffectControlData[] effectControlsData;
// availableEffects is one large string produced by the server in the following format:
// <EffectSeparator>charEffectSeparator</EffectSeparator>
// <Effect>
// <Name>effect´s name</Name>
// <SampleParam>example parameters string</SampleParam>
// <HelpText>help text string</HelpText>
// </Effect>
// <Effect>
// <Name>effect´s name</effectName>
// <SampleParam>example parameters string</SampleParam>
// <HelpText>help text string</HelpText>
// </Effect>
// ...
// <Effect>
// <Name>effect´s name</effectName>
// <SampleParam>example parameters string</SampleParam>
// <HelpText>help text string</HelpText>
// </Effect>
public AudioEffectsBoxData(String availableEffects) {
effectControlsData = null;
if (availableEffects != null && availableEffects.length() > 0)
parseAvailableEffects(availableEffects);
}
public AudioEffectControlData getControlData(int index) {
if (effectControlsData != null && index >= 0 && index < effectControlsData.length)
return effectControlsData[index];
else
return null;
}
public boolean hasEffects() {
return effectControlsData != null;
}
// Parse the XML-like full effect set string from the server
protected int parseAvailableEffects(String availableEffects) {
String[] effectLines = StringUtils.toStringArray(availableEffects);
effectControlsData = new AudioEffectControlData[effectLines.length];
for (int i = 0; i < effectLines.length; i++) {
String strEffectName, strParams;
int iSpace = effectLines[i].indexOf(' ');
if (iSpace != -1) {
strEffectName = effectLines[i].substring(0, iSpace);
strParams = effectLines[i].substring(iSpace + 1);
} else { // no params
strEffectName = effectLines[i];
strParams = "";
}
effectControlsData[i] = new AudioEffectControlData(strEffectName, strParams, null);
}
return getTotalEffects();
}
public int getTotalEffects() {
if (effectControlsData != null)
return effectControlsData.length;
else
return 0;
}
}

Просмотреть файл

@ -1,140 +1,130 @@
/**
* Copyright 2007 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
*
* This file is part of MARY TTS.
*
* MARY TTS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package marytts.client;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
* GUI for a set of audio effects.
*
* @author Oytun T&uumlrk
*/
public class AudioEffectsBoxGUI {
private AudioEffectsBoxData data;
public AudioEffectControlGUI[] effectControls;
public JPanel mainPanel;
public JLabel effectsBoxLabel;
public JScrollPane scrollPane;
public JPanel effectControlsPanel;
public AudioEffectsBoxGUI(String availableEffects)
{
data = new AudioEffectsBoxData(availableEffects);
if (availableEffects!=null && !availableEffects.equals(""))
{
mainPanel = new JPanel();
effectsBoxLabel = new JLabel("Audio Effects:");
effectControlsPanel = new JPanel();
if (data.getTotalEffects()>0)
{
effectControls = new AudioEffectControlGUI[data.getTotalEffects()];
for (int i=0; i<effectControls.length; i++)
effectControls[i] = new AudioEffectControlGUI(data.getControlData(i));
}
else
effectControls = null;
}
else
effectControls = null;
}
public AudioEffectsBoxData getData() { return data; }
public boolean hasEffects()
{
return data.hasEffects();
}
public void show()
{
mainPanel.removeAll();
mainPanel.validate();
effectControlsPanel.removeAll();
effectControlsPanel.validate();
GridBagLayout g = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
mainPanel.setLayout(g);
c.fill = GridBagConstraints.VERTICAL;
g.setConstraints(mainPanel, c);
c.gridx = 0;
c.gridy = 0;
c.ipadx = 200;
c.ipady = 20;
c.fill = GridBagConstraints.CENTER;
g.setConstraints(effectsBoxLabel, c);
mainPanel.add(effectsBoxLabel);
c.gridx = 0;
c.gridy = 1;
c.ipadx = 0;
c.ipady = 0;
g.setConstraints(effectControlsPanel, c);
mainPanel.add(effectControlsPanel);
if (effectControls!=null && effectControls.length>0)
{
effectControlsPanel.setLayout(g);
c.gridx = 0;
c.fill = GridBagConstraints.BOTH;
int totalShown = 0;
for (int i=0; i<effectControls.length; i++)
{
if (effectControls[i].getVisible())
{
c.gridy = totalShown;
g.setConstraints(effectControls[i].mainPanel, c);
effectControlsPanel.add(effectControls[i].mainPanel);
effectControls[i].show();
totalShown++;
}
}
}
//Add the scroll pane
c.gridx = 0;
c.gridy = 1;
c.ipadx = 300;
c.ipady = 105;
scrollPane = new JScrollPane(effectControlsPanel);
scrollPane.setViewportView(effectControlsPanel);
g.setConstraints(scrollPane, c);
mainPanel.add(scrollPane);
effectControlsPanel.validate();
mainPanel.validate();
}
}
/**
* Copyright 2007 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
*
* This file is part of MARY TTS.
*
* MARY TTS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package marytts.client;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
* GUI for a set of audio effects.
*
* @author Oytun T&uumlrk
*/
public class AudioEffectsBoxGUI {
private AudioEffectsBoxData data;
public AudioEffectControlGUI[] effectControls;
public JPanel mainPanel;
public JLabel effectsBoxLabel;
public JScrollPane scrollPane;
public JPanel effectControlsPanel;
public AudioEffectsBoxGUI(String availableEffects) {
data = new AudioEffectsBoxData(availableEffects);
if (availableEffects != null && !availableEffects.equals("")) {
mainPanel = new JPanel();
effectsBoxLabel = new JLabel("Audio Effects:");
effectControlsPanel = new JPanel();
if (data.getTotalEffects() > 0) {
effectControls = new AudioEffectControlGUI[data.getTotalEffects()];
for (int i = 0; i < effectControls.length; i++)
effectControls[i] = new AudioEffectControlGUI(data.getControlData(i));
} else
effectControls = null;
} else
effectControls = null;
}
public AudioEffectsBoxData getData() {
return data;
}
public boolean hasEffects() {
return data.hasEffects();
}
public void show() {
mainPanel.removeAll();
mainPanel.validate();
effectControlsPanel.removeAll();
effectControlsPanel.validate();
GridBagLayout g = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
mainPanel.setLayout(g);
c.fill = GridBagConstraints.VERTICAL;
g.setConstraints(mainPanel, c);
c.gridx = 0;
c.gridy = 0;
c.ipadx = 200;
c.ipady = 20;
c.fill = GridBagConstraints.CENTER;
g.setConstraints(effectsBoxLabel, c);
mainPanel.add(effectsBoxLabel);
c.gridx = 0;
c.gridy = 1;
c.ipadx = 0;
c.ipady = 0;
g.setConstraints(effectControlsPanel, c);
mainPanel.add(effectControlsPanel);
if (effectControls != null && effectControls.length > 0) {
effectControlsPanel.setLayout(g);
c.gridx = 0;
c.fill = GridBagConstraints.BOTH;
int totalShown = 0;
for (int i = 0; i < effectControls.length; i++) {
if (effectControls[i].getVisible()) {
c.gridy = totalShown;
g.setConstraints(effectControls[i].mainPanel, c);
effectControlsPanel.add(effectControls[i].mainPanel);
effectControls[i].show();
totalShown++;
}
}
}
// Add the scroll pane
c.gridx = 0;
c.gridy = 1;
c.ipadx = 300;
c.ipady = 105;
scrollPane = new JScrollPane(effectControlsPanel);
scrollPane.setViewportView(effectControlsPanel);
g.setConstraints(scrollPane, c);
mainPanel.add(scrollPane);
effectControlsPanel.validate();
mainPanel.validate();
}
}

Просмотреть файл

@ -17,7 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package marytts.client;
package marytts.client;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@ -26,105 +27,93 @@ import java.io.InputStreamReader;
import java.util.StringTokenizer;
import marytts.client.http.MaryHttpClient;
/**
* Copyright 2006 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
*
* Permission is hereby granted, free of charge, to use and distribute
* this software and its documentation without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of this work, and to
* permit persons to whom this work is furnished to do so, subject to
* the following conditions:
*
* 1. The code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* 2. Any modifications must be clearly marked as such.
* 3. Original authors' names are not deleted.
* 4. The authors' names are not used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* DFKI GMBH AND THE CONTRIBUTORS TO THIS WORK DISCLAIM ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DFKI GMBH NOR THE
* CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
public class BatchSynth
{
/**
* Generate a set of audio files from text. Example call:
* java -cp maryclient.jar -Dserver.host=localhost -Dserver.port=59125 -Dvoice=kevin16 marytts.client.BatchSynth target/dir path/to/texts.txt
* The text file must contain a target audio file name and the corresponding text in each line.
* @param args first argument, the output directory;
* the rest, file names containing text files. Each text file contains, in each line, a file name followed by the sentence to generate as a .wav file.
*/
public static void main(String[] args) throws Exception
{
File globalOutputDir = new File(args[0]);
MaryHttpClient mary = new MaryHttpClient();
String voice = System.getProperty("voice", "us1");
boolean haveBasename = "true".equals(System.getProperty("lines-contain-basename", "true")); // default: true, for backward compatibility
String inputFormat = "TEXT";
String locale = System.getProperty("locale", "en_US");
String outputFormat = System.getProperty("output.type", "AUDIO");
String extension = outputFormat.equals("AUDIO") ? ".wav" : "." + outputFormat.toLowerCase();
long globalStartTime = System.currentTimeMillis();
int globalCounter = 0;
for (int i=1; i<args.length; i++) {
long genreStartTime = System.currentTimeMillis();
int genreCounter = 0;
File texts = new File(args[i]);
String genre = texts.getName().substring(0, texts.getName().lastIndexOf('.'));
File outputDir = new File(globalOutputDir.getPath()+"/"+genre);
outputDir.mkdir();
BufferedReader textReader = new BufferedReader(new InputStreamReader(new FileInputStream(texts), "utf-8"));
String line;
while ((line = textReader.readLine()) != null) {
line = line.trim();
if (line.length() == 0) continue;
long startTime = System.currentTimeMillis();
if (line.trim().startsWith("(")) {
line = line.substring(line.indexOf("(")+1, line.lastIndexOf(")"));
}
StringTokenizer st = new StringTokenizer(line);
String basename;
String sentence;
if (haveBasename) {
basename = st.nextToken();
sentence = line.substring(line.indexOf(basename)+basename.length()+1).trim();
} else {
basename = genre + genreCounter;
sentence = line.trim();
}
//remove all backslashes
sentence = sentence.replaceAll("\\\\","");
FileOutputStream audio = new FileOutputStream(outputDir+"/"+basename+extension);
mary.process(sentence, inputFormat, outputFormat, locale, "WAVE", voice, audio);
audio.close();
long endTime = System.currentTimeMillis();
System.out.println(basename+" synthesized in "+ ((float)(endTime-startTime)/1000.) + " s");
globalCounter++;
genreCounter++;
}
long genreEndTime = System.currentTimeMillis();
System.out.println("Genre '"+genre+"' ("+genreCounter+" sentences) synthesized in "+ ((float)(genreEndTime-genreStartTime)/1000.) + " s");
}
long globalEndTime = System.currentTimeMillis();
System.out.println("Total: "+globalCounter+" sentences synthesized in "+ ((float)(globalEndTime-globalStartTime)/1000.) + " s");
}
}
/**
* Copyright 2006 DFKI GmbH. All Rights Reserved. Use is subject to license terms.
*
* Permission is hereby granted, free of charge, to use and distribute this software and its documentation without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* this work, and to permit persons to whom this work is furnished to do so, subject to the following conditions:
*
* 1. The code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Any modifications
* must be clearly marked as such. 3. Original authors' names are not deleted. 4. The authors' names are not used to endorse or
* promote products derived from this software without specific prior written permission.
*
* DFKI GMBH AND THE CONTRIBUTORS TO THIS WORK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DFKI GMBH NOR THE CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, INDIRECT
* OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
public class BatchSynth {
/**
* Generate a set of audio files from text. Example call: java -cp maryclient.jar -Dserver.host=localhost -Dserver.port=59125
* -Dvoice=kevin16 marytts.client.BatchSynth target/dir path/to/texts.txt The text file must contain a target audio file name
* and the corresponding text in each line.
*
* @param args
* first argument, the output directory; the rest, file names containing text files. Each text file contains, in
* each line, a file name followed by the sentence to generate as a .wav file.
*/
public static void main(String[] args) throws Exception {
File globalOutputDir = new File(args[0]);
MaryHttpClient mary = new MaryHttpClient();
String voice = System.getProperty("voice", "us1");
boolean haveBasename = "true".equals(System.getProperty("lines-contain-basename", "true")); // default: true, for backward
// compatibility
String inputFormat = "TEXT";
String locale = System.getProperty("locale", "en_US");
String outputFormat = System.getProperty("output.type", "AUDIO");
String extension = outputFormat.equals("AUDIO") ? ".wav" : "." + outputFormat.toLowerCase();
long globalStartTime = System.currentTimeMillis();
int globalCounter = 0;
for (int i = 1; i < args.length; i++) {
long genreStartTime = System.currentTimeMillis();
int genreCounter = 0;
File texts = new File(args[i]);
String genre = texts.getName().substring(0, texts.getName().lastIndexOf('.'));
File outputDir = new File(globalOutputDir.getPath() + "/" + genre);
outputDir.mkdir();
BufferedReader textReader = new BufferedReader(new InputStreamReader(new FileInputStream(texts), "utf-8"));
String line;
while ((line = textReader.readLine()) != null) {
line = line.trim();
if (line.length() == 0)
continue;
long startTime = System.currentTimeMillis();
if (line.trim().startsWith("(")) {
line = line.substring(line.indexOf("(") + 1, line.lastIndexOf(")"));
}
StringTokenizer st = new StringTokenizer(line);
String basename;
String sentence;
if (haveBasename) {
basename = st.nextToken();
sentence = line.substring(line.indexOf(basename) + basename.length() + 1).trim();
} else {
basename = genre + genreCounter;
sentence = line.trim();
}
// remove all backslashes
sentence = sentence.replaceAll("\\\\", "");
FileOutputStream audio = new FileOutputStream(outputDir + "/" + basename + extension);
mary.process(sentence, inputFormat, outputFormat, locale, "WAVE", voice, audio);
audio.close();
long endTime = System.currentTimeMillis();
System.out.println(basename + " synthesized in " + ((float) (endTime - startTime) / 1000.) + " s");
globalCounter++;
genreCounter++;
}
long genreEndTime = System.currentTimeMillis();
System.out.println("Genre '" + genre + "' (" + genreCounter + " sentences) synthesized in "
+ ((float) (genreEndTime - genreStartTime) / 1000.) + " s");
}
long globalEndTime = System.currentTimeMillis();
System.out.println("Total: " + globalCounter + " sentences synthesized in "
+ ((float) (globalEndTime - globalStartTime) / 1000.) + " s");
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,6 +1,6 @@
/**
* Copyright 2000-2006 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
/**
* Copyright 2000-2006 DFKI GmbH.
* All Rights Reserved. Use is subject to license terms.
*
* This file is part of MARY TTS.
*
@ -17,45 +17,41 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package marytts.client;
import java.awt.FlowLayout;
import java.io.IOException;
import javax.swing.JApplet;
import marytts.util.http.Address;
/**
* @author Marc Schr&ouml;der
*
*/
public class MaryInterfaceApplet extends JApplet
{
private MaryGUIClient maryExpertInterface;
public void init()
{
String host = getCodeBase().getHost();
if (host == null || host.equals("")) {
host = "mary.dfki.de";
}
System.out.println("Connecting to "+host);
int port = 59125;
try {
maryExpertInterface = new MaryGUIClient(new Address(host, port), this);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(maryExpertInterface);
} catch (IOException ioe) {
System.err.println("Cannot connect to MARY server on "+host+":"+port);
ioe.printStackTrace();
}
}
public void destroy()
{
}
}
package marytts.client;
import java.awt.FlowLayout;
import java.io.IOException;
import javax.swing.JApplet;
import marytts.util.http.Address;
/**
* @author Marc Schr&ouml;der
*
*/
public class MaryInterfaceApplet extends JApplet {
private MaryGUIClient maryExpertInterface;
public void init() {
String host = getCodeBase().getHost();
if (host == null || host.equals("")) {
host = "mary.dfki.de";
}
System.out.println("Connecting to " + host);
int port = 59125;
try {
maryExpertInterface = new MaryGUIClient(new Address(host, port), this);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(maryExpertInterface);
} catch (IOException ioe) {
System.err.println("Cannot connect to MARY server on " + host + ":" + port);
ioe.printStackTrace();
}
}
public void destroy() {
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -33,61 +33,60 @@ import javax.sound.sampled.UnsupportedAudioFileException;
import marytts.client.MaryClient;
import marytts.util.http.Address;
/**
* A MaryClient that runs in a thread of its own. Requests for synthesis
* are scheduled through <code>scheduleRequest()</code>, which is not
* synchronized. Only the last unprocessed request is remembered.
*
* @author Marc Schr&ouml;der
* A MaryClient that runs in a thread of its own. Requests for synthesis are scheduled through <code>scheduleRequest()</code>,
* which is not synchronized. Only the last unprocessed request is remembered.
*
* @author Marc Schr&ouml;der
*/
public class AsynchronousThreadedMaryClient extends Thread {
private int r;
private AudioFileReceiver emoSpeak;
private marytts.client.MaryClient processor;
private boolean inputAvailable = false;
private String latestRequest = null;
private MaryClient.Voice latestRequestVoice = null;
private AudioInputStream latestAudio = null;
private boolean exitRequested = false;
/** Creates new AsynchronousThreadedMaryClient */
public AsynchronousThreadedMaryClient(AudioFileReceiver emoSpeak)
throws IOException, UnknownHostException {
this.emoSpeak = emoSpeak;
processor = MaryClient.getMaryClient();
}
private int r;
private AudioFileReceiver emoSpeak;
private marytts.client.MaryClient processor;
private boolean inputAvailable = false;
private String latestRequest = null;
private MaryClient.Voice latestRequestVoice = null;
private AudioInputStream latestAudio = null;
private boolean exitRequested = false;
/** Constructor to be used by applets */
public AsynchronousThreadedMaryClient(AudioFileReceiver emoSpeak,
String serverHost, int serverPort, boolean printProfilingInfo, boolean beQuiet)
throws IOException, UnknownHostException {
this.emoSpeak = emoSpeak;
processor = MaryClient.getMaryClient(new Address(serverHost, serverPort), printProfilingInfo, beQuiet);
}
/** Creates new AsynchronousThreadedMaryClient */
public AsynchronousThreadedMaryClient(AudioFileReceiver emoSpeak) throws IOException, UnknownHostException {
this.emoSpeak = emoSpeak;
processor = MaryClient.getMaryClient();
}
/**
* Schedule the latest request. Any previous, unprocessed requests
* are deleted.
* @param prosodyxmlString the maryxml data to be synthesised.
* @param voice the synthesis voice to use
* @param requestNumber request number
*/
public synchronized void scheduleRequest(String prosodyxmlString, MaryClient.Voice voice, int requestNumber) {
latestRequest = prosodyxmlString;
latestRequestVoice = voice;
inputAvailable = true;
this.r = requestNumber;
notifyAll();
}
public synchronized void requestExit() {
exitRequested = true;
notifyAll();
}
/** Constructor to be used by applets */
public AsynchronousThreadedMaryClient(AudioFileReceiver emoSpeak, String serverHost, int serverPort,
boolean printProfilingInfo, boolean beQuiet) throws IOException, UnknownHostException {
this.emoSpeak = emoSpeak;
processor = MaryClient.getMaryClient(new Address(serverHost, serverPort), printProfilingInfo, beQuiet);
}
// Call the mary client
private void processInput()
/**
* Schedule the latest request. Any previous, unprocessed requests are deleted.
*
* @param prosodyxmlString
* the maryxml data to be synthesised.
* @param voice
* the synthesis voice to use
* @param requestNumber
* request number
*/
public synchronized void scheduleRequest(String prosodyxmlString, MaryClient.Voice voice, int requestNumber) {
latestRequest = prosodyxmlString;
latestRequestVoice = voice;
inputAvailable = true;
this.r = requestNumber;
notifyAll();
}
public synchronized void requestExit() {
exitRequested = true;
notifyAll();
}
// Call the mary client
private void processInput()
throws IOException, UnknownHostException, UnsupportedAudioFileException {
java.io.ByteArrayOutputStream os = new ByteArrayOutputStream();
assert latestRequestVoice != null;
@ -101,59 +100,56 @@ public class AsynchronousThreadedMaryClient extends Thread {
byte[] bytes = os.toByteArray();
latestAudio = AudioSystem.getAudioInputStream(new ByteArrayInputStream(bytes));
}
public String getHost()
{
return processor.getHost();
}
public int getPort()
{
return processor.getPort();
}
public Vector getServerVoices() throws IOException
{
return processor.getGeneralDomainVoices();
}
public Vector getServerVoices(Locale locale) throws IOException
{
return processor.getGeneralDomainVoices(locale);
}
public String getHost() {
return processor.getHost();
}
private synchronized void doWait() {
try {
wait();
} catch (InterruptedException e) {}
}
public void run() {
while (!exitRequested) {
if (inputAvailable) {
// heuristic sleep value, waiting for more reasonable new mouse position:
try {
sleep(200);
} catch (InterruptedException e) {}
inputAvailable = false;
int r1 = r;
long t0 = System.currentTimeMillis();
try {
processInput();
long t = System.currentTimeMillis() - t0;
System.err.println("MaryClient has processed request no." + r1 + " in " + t + " ms.");
emoSpeak.setNextAudio(latestAudio);
} catch (Exception e) {
System.err.println("Problem creating synthesis audio:");
e.printStackTrace();
emoSpeak.setNextAudio(null);
}
} else {
doWait();
System.err.println("MaryClient waking up from wait.");
}
}
System.err.println("MaryClient exiting.");
}
public int getPort() {
return processor.getPort();
}
public Vector getServerVoices() throws IOException {
return processor.getGeneralDomainVoices();
}
public Vector getServerVoices(Locale locale) throws IOException {
return processor.getGeneralDomainVoices(locale);
}
private synchronized void doWait() {
try {
wait();
} catch (InterruptedException e) {
}
}
public void run() {
while (!exitRequested) {
if (inputAvailable) {
// heuristic sleep value, waiting for more reasonable new mouse position:
try {
sleep(200);
} catch (InterruptedException e) {
}
inputAvailable = false;
int r1 = r;
long t0 = System.currentTimeMillis();
try {
processInput();
long t = System.currentTimeMillis() - t0;
System.err.println("MaryClient has processed request no." + r1 + " in " + t + " ms.");
emoSpeak.setNextAudio(latestAudio);
} catch (Exception e) {
System.err.println("Problem creating synthesis audio:");
e.printStackTrace();
emoSpeak.setNextAudio(null);
}
} else {
doWait();
System.err.println("MaryClient waking up from wait.");
}
}
System.err.println("MaryClient exiting.");
}
}

Просмотреть файл

@ -20,12 +20,11 @@
package marytts.tools.emospeak;
/**
*
* @author schroed
*
* @author schroed
*/
public interface AudioFileReceiver {
public void setNextAudio(javax.sound.sampled.AudioInputStream audioInputStream);
}
public void setNextAudio(javax.sound.sampled.AudioInputStream audioInputStream);
}

Просмотреть файл

@ -23,57 +23,56 @@ import java.io.IOException;
import java.net.UnknownHostException;
/**
*
* @author Marc Schr&ouml;der
*
* @author Marc Schr&ouml;der
*/
public class EmoSpeak extends javax.swing.JFrame
{
/** Creates new form EmoSpeak */
public EmoSpeak() throws Exception {
super("OpenMary EmoSpeak");
initComponents();
emoSpeakPanel1.initialiseMenu();
}
/** This method is called from within the constructor to
* initialize the form.
*/
private void initComponents() throws IOException, UnknownHostException {
emoSpeakPanel1 = new EmoSpeakPanel(true, System.getProperty("server.host", "cling.dfki.uni-sb.de"), Integer.getInteger("server.port", 59125).intValue());
public class EmoSpeak extends javax.swing.JFrame {
/** Creates new form EmoSpeak */
public EmoSpeak() throws Exception {
super("OpenMary EmoSpeak");
initComponents();
emoSpeakPanel1.initialiseMenu();
}
getContentPane().setLayout(new java.awt.FlowLayout());
/**
* This method is called from within the constructor to initialize the form.
*/
private void initComponents() throws IOException, UnknownHostException {
emoSpeakPanel1 = new EmoSpeakPanel(true, System.getProperty("server.host", "cling.dfki.uni-sb.de"), Integer.getInteger(
"server.port", 59125).intValue());
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
getContentPane().setLayout(new java.awt.FlowLayout());
getContentPane().add(emoSpeakPanel1);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(550, 630));
setLocation((screenSize.width-550)/2,(screenSize.height-630)/2);
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
emoSpeakPanel1.requestExit();
System.exit(0);
}
getContentPane().add(emoSpeakPanel1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(550, 630));
setLocation((screenSize.width - 550) / 2, (screenSize.height - 630) / 2);
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
emoSpeakPanel1.requestExit();
System.exit(0);
}
/**
* @param args
* the command line arguments
*/
public static void main(String args[]) throws Exception {
new EmoSpeak().setVisible(true);
}
// Variables declaration - do not modify
private marytts.tools.emospeak.EmoSpeakPanel emoSpeakPanel1;
// End of variables declaration
/**
* @param args the command line arguments
*/
public static void main(String args[]) throws Exception {
new EmoSpeak().setVisible(true);
}
// Variables declaration - do not modify
private marytts.tools.emospeak.EmoSpeakPanel emoSpeakPanel1;
// End of variables declaration
}

Просмотреть файл

@ -19,47 +19,44 @@
*/
package marytts.tools.emospeak;
/**
*
* @author schroed
*
* @author schroed
*/
public class EmoSpeakApplet extends javax.swing.JApplet {
public void init() {
initComponents();
emoSpeakPanel1.initialiseMenu();
}
/** This method is called from within the init() method to
* initialize the form.
*/
private void initComponents() {
String host = getCodeBase().getHost();
if (host == null || host.equals("")) {
host = "localhost";
}
try {
emoSpeakPanel1 = new EmoSpeakPanel(false, host, 59125);
} catch (Exception e) {
System.err.println("Cannot initialise EmoSpeakPanel:");
e.printStackTrace();
}
public void init() {
initComponents();
emoSpeakPanel1.initialiseMenu();
}
getContentPane().setLayout(new java.awt.FlowLayout());
/**
* This method is called from within the init() method to initialize the form.
*/
private void initComponents() {
String host = getCodeBase().getHost();
if (host == null || host.equals("")) {
host = "localhost";
}
try {
emoSpeakPanel1 = new EmoSpeakPanel(false, host, 59125);
} catch (Exception e) {
System.err.println("Cannot initialise EmoSpeakPanel:");
e.printStackTrace();
}
getContentPane().add(emoSpeakPanel1);
getContentPane().setLayout(new java.awt.FlowLayout());
}
// Variables declaration
private EmoSpeakPanel emoSpeakPanel1;
// End of variables declaration
public void destroy() {
emoSpeakPanel1.requestExit();
}
getContentPane().add(emoSpeakPanel1);
}
// Variables declaration
private EmoSpeakPanel emoSpeakPanel1;
// End of variables declaration
public void destroy() {
emoSpeakPanel1.requestExit();
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -26,132 +26,119 @@ import javax.xml.transform.TransformerConfigurationException;
import marytts.util.MaryUtils;
/**
*
*
* @author Marc Schr&ouml;der
*/
public class EmoTransformer extends Thread {
private int r;
private ProsodyXMLDisplayer emoSpeak;
private int r;
private ProsodyXMLDisplayer emoSpeak;
private javax.xml.transform.TransformerFactory tFactory = null;
private javax.xml.transform.Templates stylesheet = null;
private javax.xml.transform.Transformer transformer = null;
private javax.xml.parsers.DocumentBuilderFactory dbFactory = null;
private javax.xml.parsers.DocumentBuilder docBuilder = null;
private javax.xml.transform.TransformerFactory tFactory = null;
private javax.xml.transform.Templates stylesheet = null;
private javax.xml.transform.Transformer transformer = null;
private javax.xml.parsers.DocumentBuilderFactory dbFactory = null;
private javax.xml.parsers.DocumentBuilder docBuilder = null;
private org.w3c.dom.Document emotionDocument = null;
private org.w3c.dom.Document emotionDocument = null;
private boolean inputAvailable = false;
private int activation;
private int evaluation;
private int power;
private String text;
private String maryxmlString;
private Locale locale;
private boolean exitRequested = false;
/** Creates new EmoTransformer */
public EmoTransformer(ProsodyXMLDisplayer emoSpeak)
throws TransformerConfigurationException, ParserConfigurationException
{
this.emoSpeak = emoSpeak;
// Try to find a suitable XSLT transformer
tFactory = javax.xml.transform.TransformerFactory.newInstance();
/* if (false && tFactory instanceof org.apache.xalan.processor.TransformerFactoryImpl) {
Hashtable xalanEnv = (new org.apache.xalan.xslt.EnvironmentCheck()).getEnvironmentHash();
String xalan2Version = (String) xalanEnv.get("version.xalan2x");
if (xalan2Version == null || xalan2Version.equals(""))
xalan2Version = (String) xalanEnv.get("version.xalan2");
if (xalan2Version != null && !xalan2Version.equals(""))
System.err.println("Using " + xalan2Version);
} else {
*/
System.err.println("Using XSL processor " + tFactory.getClass().getName());
// }
javax.xml.transform.stream.StreamSource stylesheetStream =
new javax.xml.transform.stream.StreamSource (
EmoTransformer.class.getResourceAsStream("emotion-to-mary.xsl")
);
stylesheet = tFactory.newTemplates( stylesheetStream );
dbFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
docBuilder = dbFactory.newDocumentBuilder();
transformer = stylesheet.newTransformer();
private boolean inputAvailable = false;
private int activation;
private int evaluation;
private int power;
private String text;
private String maryxmlString;
private Locale locale;
}
private boolean exitRequested = false;
/**
* Asynchronously set the latest emotion values. Overwrites any
* previous, unprocessed data.
*/
public synchronized void setEmotionValues(int activation, int evaluation, int power, String text, Locale locale, int r) {
this.activation = activation;
this.evaluation = evaluation;
this.power = power;
this.text = text;
this.locale = locale;
inputAvailable = true;
this.r = r;
notifyAll();
}
public synchronized void requestExit() {
exitRequested = true;
notifyAll();
}
/** Creates new EmoTransformer */
public EmoTransformer(ProsodyXMLDisplayer emoSpeak) throws TransformerConfigurationException, ParserConfigurationException {
this.emoSpeak = emoSpeak;
// Try to find a suitable XSLT transformer
tFactory = javax.xml.transform.TransformerFactory.newInstance();
/*
* if (false && tFactory instanceof org.apache.xalan.processor.TransformerFactoryImpl) { Hashtable xalanEnv = (new
* org.apache.xalan.xslt.EnvironmentCheck()).getEnvironmentHash(); String xalan2Version = (String)
* xalanEnv.get("version.xalan2x"); if (xalan2Version == null || xalan2Version.equals("")) xalan2Version = (String)
* xalanEnv.get("version.xalan2"); if (xalan2Version != null && !xalan2Version.equals("")) System.err.println("Using " +
* xalan2Version); } else {
*/
System.err.println("Using XSL processor " + tFactory.getClass().getName());
// }
javax.xml.transform.stream.StreamSource stylesheetStream = new javax.xml.transform.stream.StreamSource(
EmoTransformer.class.getResourceAsStream("emotion-to-mary.xsl"));
stylesheet = tFactory.newTemplates(stylesheetStream);
dbFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
docBuilder = dbFactory.newDocumentBuilder();
transformer = stylesheet.newTransformer();
private void createEmotionDocument() {
emotionDocument = docBuilder.getDOMImplementation().
createDocument(null, "emotion", null);
org.w3c.dom.Element e = emotionDocument.getDocumentElement();
e.setAttributeNS("http://www.w3.org/XML/1998/namespace", "lang", MaryUtils.locale2xmllang(locale));
e.setAttribute("activation", String.valueOf(activation));
e.setAttribute("evaluation", String.valueOf(evaluation));
e.setAttribute("power", String.valueOf(power));
e.appendChild(emotionDocument.createTextNode(text));
}
private void transformToMaryXML()
throws javax.xml.transform.TransformerException
{
javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource (emotionDocument);
java.io.StringWriter sw = new java.io.StringWriter();
javax.xml.transform.stream.StreamResult streamResult = new javax.xml.transform.stream.StreamResult (sw);
transformer.transform(domSource, streamResult);
maryxmlString = sw.toString();
}
private synchronized void doWait() {
try {
wait();
} catch (InterruptedException e) {}
}
public void run() {
while (!exitRequested) {
if (inputAvailable) {
inputAvailable = false;
try {
int r1 = r;
System.err.println("EmoTransformer about to process request no. " + r1);
createEmotionDocument();
transformToMaryXML();
System.err.println("EmoTransformer has processed.");
emoSpeak.updateProsodyXML(maryxmlString, r1);
} catch (javax.xml.transform.TransformerException e) {
e.printStackTrace();
}
} else {
doWait();
System.err.println("EmoTransformer waking up from wait.");
}
}
System.err.println("EmoTransformer exiting.");
}
}
/**
* Asynchronously set the latest emotion values. Overwrites any previous, unprocessed data.
*/
public synchronized void setEmotionValues(int activation, int evaluation, int power, String text, Locale locale, int r) {
this.activation = activation;
this.evaluation = evaluation;
this.power = power;
this.text = text;
this.locale = locale;
inputAvailable = true;
this.r = r;
notifyAll();
}
public synchronized void requestExit() {
exitRequested = true;
notifyAll();
}
private void createEmotionDocument() {
emotionDocument = docBuilder.getDOMImplementation().createDocument(null, "emotion", null);
org.w3c.dom.Element e = emotionDocument.getDocumentElement();
e.setAttributeNS("http://www.w3.org/XML/1998/namespace", "lang", MaryUtils.locale2xmllang(locale));
e.setAttribute("activation", String.valueOf(activation));
e.setAttribute("evaluation", String.valueOf(evaluation));
e.setAttribute("power", String.valueOf(power));
e.appendChild(emotionDocument.createTextNode(text));
}
private void transformToMaryXML() throws javax.xml.transform.TransformerException {
javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource(emotionDocument);
java.io.StringWriter sw = new java.io.StringWriter();
javax.xml.transform.stream.StreamResult streamResult = new javax.xml.transform.stream.StreamResult(sw);
transformer.transform(domSource, streamResult);
maryxmlString = sw.toString();
}
private synchronized void doWait() {
try {
wait();
} catch (InterruptedException e) {
}
}
public void run() {
while (!exitRequested) {
if (inputAvailable) {
inputAvailable = false;
try {
int r1 = r;
System.err.println("EmoTransformer about to process request no. " + r1);
createEmotionDocument();
transformToMaryXML();
System.err.println("EmoTransformer has processed.");
emoSpeak.updateProsodyXML(maryxmlString, r1);
} catch (javax.xml.transform.TransformerException e) {
e.printStackTrace();
}
} else {
doWait();
System.err.println("EmoTransformer waking up from wait.");
}
}
System.err.println("EmoTransformer exiting.");
}
}

Просмотреть файл

@ -20,206 +20,200 @@
package marytts.tools.emospeak;
/**
*
* @author schroed
*
* @author schroed
*/
public class JFeeltraceCircle extends javax.swing.JPanel {
private boolean isCircular = true; // global setting
private int circleSize;
private boolean isCircular = true; // global setting
private int circleSize;
private int cursorDiameter = 30;
public int getCursorDiameter() { return cursorDiameter; }
public void setCursorDiameter(int d) { cursorDiameter = d; }
private java.awt.geom.RectangularShape feeltraceShape;
private int cursorDiameter = 30;
private TwoDimensionalModel normalizedModel =
new RectangularTwoDimensionalModel(0,0,-100,100,-100,100);
public int getCursorDiameter() {
return cursorDiameter;
}
private java.awt.Dimension requestedSize = new java.awt.Dimension(200, 200);
public void setRequestedSize(java.awt.Dimension requestedSize)
{
this.requestedSize = requestedSize;
}
public java.awt.Dimension getRequestedSize()
{
return requestedSize;
}
public void setCursorDiameter(int d) {
cursorDiameter = d;
}
/** Creates new form JFeeltraceCircle */
public JFeeltraceCircle(boolean isCircular,
java.awt.Dimension requestedSize) {
this.isCircular = isCircular;
this.requestedSize = requestedSize;
initComponents();
customInitComponents();
}
/** Creates new form JFeeltraceCircle */
public JFeeltraceCircle() {
initComponents();
customInitComponents();
}
private java.awt.geom.RectangularShape feeltraceShape;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
setLayout(new java.awt.BorderLayout());
addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
formMousePressed(evt);
}
});
addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(java.awt.event.MouseEvent evt) {
formMouseDragged(evt);
}
});
}//GEN-END:initComponents
private TwoDimensionalModel normalizedModel = new RectangularTwoDimensionalModel(0, 0, -100, 100, -100, 100);
private void formMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMousePressed
setFeeltraceCursor(evt.getPoint());
repaint();
}//GEN-LAST:event_formMousePressed
private java.awt.Dimension requestedSize = new java.awt.Dimension(200, 200);
private void formMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseDragged
setFeeltraceCursor(evt.getPoint());
repaint();
}//GEN-LAST:event_formMouseDragged
public void setRequestedSize(java.awt.Dimension requestedSize) {
this.requestedSize = requestedSize;
}
private void customInitComponents() {
if (isCircular) {
feeltraceShape = new java.awt.geom.Ellipse2D.Float();
} else { // square
feeltraceShape = new java.awt.geom.Rectangle2D.Float();
}
normalizedModel.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent e) {
repaint();
}
});
public java.awt.Dimension getRequestedSize() {
return requestedSize;
}
}
protected void paintComponent(java.awt.Graphics graphics) {
super.paintComponent(graphics);
java.awt.Insets insets = getInsets();
int currentWidth = getWidth() - insets.left - insets.right;
int currentHeight = getHeight() - insets.top - insets.bottom;
int offsetX = insets.left;
int offsetY = insets.top;
if (currentWidth >= currentHeight) {
circleSize = currentHeight;
offsetX += (currentWidth - circleSize) / 2;
} else {
circleSize = currentWidth;
offsetY += (currentHeight - circleSize) / 2;
}
if (isCircular) {
graphics.setColor(java.awt.Color.white);
graphics.fillOval(offsetX,offsetY,circleSize,circleSize);
graphics.setColor(java.awt.Color.black);
graphics.drawOval(offsetX,offsetY,circleSize,circleSize);
graphics.drawLine(offsetX,offsetY+circleSize/2,
offsetX+circleSize,offsetY+circleSize/2);
graphics.drawLine(offsetX+circleSize/2,offsetY,
offsetX+circleSize/2,offsetY+circleSize);
} else { // square
graphics.setColor(java.awt.Color.white);
graphics.fillRect(offsetX,offsetY,circleSize,circleSize);
graphics.setColor(java.awt.Color.black);
graphics.drawRect(offsetX,offsetY,circleSize,circleSize);
graphics.drawLine(offsetX,offsetY+circleSize/2,
offsetX+circleSize,offsetY+circleSize/2);
graphics.drawLine(offsetX+circleSize/2,offsetY,
offsetX+circleSize/2,offsetY+circleSize);
}
feeltraceShape.setFrame(offsetX, offsetY, circleSize, circleSize);
// And now the cursor
int x = (int) (feeltraceShape.getCenterX() +
normalizedModel.getX() *
(feeltraceShape.getMaxX() - feeltraceShape.getCenterX()) /
normalizedModel.getMaxX());
int y = (int) (feeltraceShape.getCenterY() -
normalizedModel.getY() *
(feeltraceShape.getMaxY() - feeltraceShape.getCenterY()) /
normalizedModel.getMaxY());
graphics.setColor(java.awt.Color.green);
graphics.fillOval(x - cursorDiameter/2, y - cursorDiameter/2,
cursorDiameter, cursorDiameter);
}
/** Creates new form JFeeltraceCircle */
public JFeeltraceCircle(boolean isCircular, java.awt.Dimension requestedSize) {
this.isCircular = isCircular;
this.requestedSize = requestedSize;
initComponents();
customInitComponents();
}
/**
* Define the location of the cursor;
* the actual drawing is done in paintComponents().
*/
private void setFeeltraceCursor(java.awt.Point p) {
java.awt.Point newLocation;
if (feeltraceShape.contains(p)) {
newLocation = p;
} else {
if (isCircular) {
double px = p.getX() - feeltraceShape.getCenterX();
double py = p.getY() - feeltraceShape.getCenterY();
// Determine angle, paint cursor at extreme possible
// value at that angle
if (py == 0) {
newLocation = new java.awt.Point((int)feeltraceShape.getCenterX() + circleSize,
(int)feeltraceShape.getCenterY());
} else {
// these formulae follow from a little drawing:
double y = (circleSize/2) /Math.sqrt(1 + px*px/(py*py));
if (py < 0) y = -y;
double x = px/py * y;
newLocation = new java.awt.Point((int) (feeltraceShape.getCenterX() + x),
(int) (feeltraceShape.getCenterY() + y));
}
} else {
// ignore out-of-bounds for rectangle
return;
}
}
// In the Y normalisation, add a - sign, because top=+100, bottom=-100
normalizedModel.setXY((int)((newLocation.getX() - feeltraceShape.getCenterX()) /
(feeltraceShape.getMaxX() - feeltraceShape.getCenterX()) * normalizedModel.getMaxX()),
-(int)((newLocation.getY() - feeltraceShape.getCenterY()) /
(feeltraceShape.getMaxY() - feeltraceShape.getCenterY()) * normalizedModel.getMaxY()));
/** Creates new form JFeeltraceCircle */
public JFeeltraceCircle() {
initComponents();
customInitComponents();
}
}
public void setNormalizedLocation(int x, int y) {
normalizedModel.setXY(x,y);
}
public void setNormalizedX(int x) {
normalizedModel.setX(x);
}
public void setNormalizedY(int y) {
normalizedModel.setY(y);
}
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of
* this method is always regenerated by the Form Editor.
*/
private void initComponents() {// GEN-BEGIN:initComponents
public int getNormalizedX() {
return normalizedModel.getX();
}
public int getNormalizedY() {
return normalizedModel.getY();
}
setLayout(new java.awt.BorderLayout());
public TwoDimensionalModel getNormalizedModel() {
return normalizedModel;
}
addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
formMousePressed(evt);
}
});
addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(java.awt.event.MouseEvent evt) {
formMouseDragged(evt);
}
});
}// GEN-END:initComponents
private void formMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_formMousePressed
setFeeltraceCursor(evt.getPoint());
repaint();
}// GEN-LAST:event_formMousePressed
private void formMouseDragged(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_formMouseDragged
setFeeltraceCursor(evt.getPoint());
repaint();
}// GEN-LAST:event_formMouseDragged
private void customInitComponents() {
if (isCircular) {
feeltraceShape = new java.awt.geom.Ellipse2D.Float();
} else { // square
feeltraceShape = new java.awt.geom.Rectangle2D.Float();
}
normalizedModel.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent e) {
repaint();
}
});
}
protected void paintComponent(java.awt.Graphics graphics) {
super.paintComponent(graphics);
java.awt.Insets insets = getInsets();
int currentWidth = getWidth() - insets.left - insets.right;
int currentHeight = getHeight() - insets.top - insets.bottom;
int offsetX = insets.left;
int offsetY = insets.top;
if (currentWidth >= currentHeight) {
circleSize = currentHeight;
offsetX += (currentWidth - circleSize) / 2;
} else {
circleSize = currentWidth;
offsetY += (currentHeight - circleSize) / 2;
}
if (isCircular) {
graphics.setColor(java.awt.Color.white);
graphics.fillOval(offsetX, offsetY, circleSize, circleSize);
graphics.setColor(java.awt.Color.black);
graphics.drawOval(offsetX, offsetY, circleSize, circleSize);
graphics.drawLine(offsetX, offsetY + circleSize / 2, offsetX + circleSize, offsetY + circleSize / 2);
graphics.drawLine(offsetX + circleSize / 2, offsetY, offsetX + circleSize / 2, offsetY + circleSize);
} else { // square
graphics.setColor(java.awt.Color.white);
graphics.fillRect(offsetX, offsetY, circleSize, circleSize);
graphics.setColor(java.awt.Color.black);
graphics.drawRect(offsetX, offsetY, circleSize, circleSize);
graphics.drawLine(offsetX, offsetY + circleSize / 2, offsetX + circleSize, offsetY + circleSize / 2);
graphics.drawLine(offsetX + circleSize / 2, offsetY, offsetX + circleSize / 2, offsetY + circleSize);
}
feeltraceShape.setFrame(offsetX, offsetY, circleSize, circleSize);
// And now the cursor
int x = (int) (feeltraceShape.getCenterX() + normalizedModel.getX()
* (feeltraceShape.getMaxX() - feeltraceShape.getCenterX()) / normalizedModel.getMaxX());
int y = (int) (feeltraceShape.getCenterY() - normalizedModel.getY()
* (feeltraceShape.getMaxY() - feeltraceShape.getCenterY()) / normalizedModel.getMaxY());
graphics.setColor(java.awt.Color.green);
graphics.fillOval(x - cursorDiameter / 2, y - cursorDiameter / 2, cursorDiameter, cursorDiameter);
}
/**
* Define the location of the cursor; the actual drawing is done in paintComponents().
*/
private void setFeeltraceCursor(java.awt.Point p) {
java.awt.Point newLocation;
if (feeltraceShape.contains(p)) {
newLocation = p;
} else {
if (isCircular) {
double px = p.getX() - feeltraceShape.getCenterX();
double py = p.getY() - feeltraceShape.getCenterY();
// Determine angle, paint cursor at extreme possible
// value at that angle
if (py == 0) {
newLocation = new java.awt.Point((int) feeltraceShape.getCenterX() + circleSize,
(int) feeltraceShape.getCenterY());
} else {
// these formulae follow from a little drawing:
double y = (circleSize / 2) / Math.sqrt(1 + px * px / (py * py));
if (py < 0)
y = -y;
double x = px / py * y;
newLocation = new java.awt.Point((int) (feeltraceShape.getCenterX() + x),
(int) (feeltraceShape.getCenterY() + y));
}
} else {
// ignore out-of-bounds for rectangle
return;
}
}
// In the Y normalisation, add a - sign, because top=+100, bottom=-100
normalizedModel.setXY(
(int) ((newLocation.getX() - feeltraceShape.getCenterX())
/ (feeltraceShape.getMaxX() - feeltraceShape.getCenterX()) * normalizedModel.getMaxX()),
-(int) ((newLocation.getY() - feeltraceShape.getCenterY())
/ (feeltraceShape.getMaxY() - feeltraceShape.getCenterY()) * normalizedModel.getMaxY()));
}
public void setNormalizedLocation(int x, int y) {
normalizedModel.setXY(x, y);
}
public void setNormalizedX(int x) {
normalizedModel.setX(x);
}
public void setNormalizedY(int y) {
normalizedModel.setY(y);
}
public int getNormalizedX() {
return normalizedModel.getX();
}
public int getNormalizedY() {
return normalizedModel.getY();
}
public TwoDimensionalModel getNormalizedModel() {
return normalizedModel;
}
}

Просмотреть файл

@ -18,192 +18,191 @@
*
*/
package marytts.tools.emospeak;
import java.awt.Graphics;
import javax.swing.BoundedRangeModel;
import javax.swing.JPanel;
/**
*
* @author Marc Schr&ouml;der
*
* @author Marc Schr&ouml;der
*/
public class JFeeltracePanel extends JPanel {
private boolean showPower = true;
public boolean showPower() {
return showPower;
}
public void setShowPower(boolean showPower)
{
this.showPower = showPower;
}
public TwoDimensionalModel feeltraceModel() {
return jFeeltraceCircle1.getNormalizedModel();
}
private BoundedRangeModel powerModel =
new javax.swing.DefaultBoundedRangeModel(0,0,-100,100);
public BoundedRangeModel powerModel() {
return powerModel;
}
/** Creates new form JFeeltracePanel */
public JFeeltracePanel(boolean showPower) {
this.showPower = showPower;
initComponents();
customInitComponents();
}
/** Creates new form JFeeltracePanel */
public JFeeltracePanel() {
initComponents();
customInitComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
java.awt.GridBagConstraints gridBagConstraints;
private boolean showPower = true;
slPower = new javax.swing.JSlider();
lMaxPower = new javax.swing.JLabel();
lMinPower = new javax.swing.JLabel();
lMaxActivation = new javax.swing.JLabel();
lMinEvaluation = new javax.swing.JLabel();
lMaxEvaluation = new javax.swing.JLabel();
lMinActivation = new javax.swing.JLabel();
jFeeltraceCircle1 = new JFeeltraceCircle();
public boolean showPower() {
return showPower;
}
setLayout(new java.awt.GridBagLayout());
public void setShowPower(boolean showPower) {
this.showPower = showPower;
}
setPreferredSize(new java.awt.Dimension(500, 350));
slPower.setMinimum(-100);
slPower.setOrientation(javax.swing.JSlider.VERTICAL);
slPower.setValue(0);
slPower.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
slPowerStateChanged(evt);
}
});
public TwoDimensionalModel feeltraceModel() {
return jFeeltraceCircle1.getNormalizedModel();
}
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
add(slPower, gridBagConstraints);
private BoundedRangeModel powerModel = new javax.swing.DefaultBoundedRangeModel(0, 0, -100, 100);
lMaxPower.setText("very dominant");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 0;
add(lMaxPower, gridBagConstraints);
public BoundedRangeModel powerModel() {
return powerModel;
}
lMinPower.setText("very submissive");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 2;
add(lMinPower, gridBagConstraints);
/** Creates new form JFeeltracePanel */
public JFeeltracePanel(boolean showPower) {
this.showPower = showPower;
initComponents();
customInitComponents();
}
lMaxActivation.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lMaxActivation.setText("very active");
lMaxActivation.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
lMaxActivation.setAlignmentX(0.5F);
lMaxActivation.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
add(lMaxActivation, gridBagConstraints);
/** Creates new form JFeeltracePanel */
public JFeeltracePanel() {
initComponents();
customInitComponents();
}
lMinEvaluation.setText("<html>very<br>negative</html>");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
add(lMinEvaluation, gridBagConstraints);
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of
* this method is always regenerated by the Form Editor.
*/
private void initComponents() {// GEN-BEGIN:initComponents
java.awt.GridBagConstraints gridBagConstraints;
lMaxEvaluation.setText("<html>very<br>positive</html>");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 1;
add(lMaxEvaluation, gridBagConstraints);
slPower = new javax.swing.JSlider();
lMaxPower = new javax.swing.JLabel();
lMinPower = new javax.swing.JLabel();
lMaxActivation = new javax.swing.JLabel();
lMinEvaluation = new javax.swing.JLabel();
lMaxEvaluation = new javax.swing.JLabel();
lMinActivation = new javax.swing.JLabel();
jFeeltraceCircle1 = new JFeeltraceCircle();
lMinActivation.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lMinActivation.setText("very passive");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
add(lMinActivation, gridBagConstraints);
setLayout(new java.awt.GridBagLayout());
jFeeltraceCircle1.setFont(new java.awt.Font("Dialog", 0, 11));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 0.1;
gridBagConstraints.weighty = 0.1;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
add(jFeeltraceCircle1, gridBagConstraints);
setPreferredSize(new java.awt.Dimension(500, 350));
slPower.setMinimum(-100);
slPower.setOrientation(javax.swing.JSlider.VERTICAL);
slPower.setValue(0);
slPower.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
slPowerStateChanged(evt);
}
});
}//GEN-END:initComponents
private void slPowerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_slPowerStateChanged
powerModel.setValue(slPower.getValue());
}//GEN-LAST:event_slPowerStateChanged
private void customInitComponents() {
verifyPowerVisible();
feeltraceModel().addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent e) {
updateFeeltraceDisplays();
}
});
if (showPower) {
powerModel.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent e) {
updatePowerDisplays();
}
});
}
}
protected void paintComponent(Graphics graphics) {
verifyPowerVisible();
super.paintComponent(graphics);
}
public void verifyPowerVisible() {
lMaxPower.setVisible(showPower);
lMinPower.setVisible(showPower);
slPower.setVisible(showPower);
}
private void updateFeeltraceDisplays() {
}
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
add(slPower, gridBagConstraints);
lMaxPower.setText("very dominant");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 0;
add(lMaxPower, gridBagConstraints);
lMinPower.setText("very submissive");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 2;
add(lMinPower, gridBagConstraints);
lMaxActivation.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lMaxActivation.setText("very active");
lMaxActivation.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
lMaxActivation.setAlignmentX(0.5F);
lMaxActivation.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
add(lMaxActivation, gridBagConstraints);
lMinEvaluation.setText("<html>very<br>negative</html>");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
add(lMinEvaluation, gridBagConstraints);
lMaxEvaluation.setText("<html>very<br>positive</html>");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 1;
add(lMaxEvaluation, gridBagConstraints);
lMinActivation.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lMinActivation.setText("very passive");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
add(lMinActivation, gridBagConstraints);
jFeeltraceCircle1.setFont(new java.awt.Font("Dialog", 0, 11));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 0.1;
gridBagConstraints.weighty = 0.1;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
add(jFeeltraceCircle1, gridBagConstraints);
}// GEN-END:initComponents
private void slPowerStateChanged(javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_slPowerStateChanged
powerModel.setValue(slPower.getValue());
}// GEN-LAST:event_slPowerStateChanged
private void customInitComponents() {
verifyPowerVisible();
feeltraceModel().addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent e) {
updateFeeltraceDisplays();
}
});
if (showPower) {
powerModel.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent e) {
updatePowerDisplays();
}
});
}
}
protected void paintComponent(Graphics graphics) {
verifyPowerVisible();
super.paintComponent(graphics);
}
public void verifyPowerVisible() {
lMaxPower.setVisible(showPower);
lMinPower.setVisible(showPower);
slPower.setVisible(showPower);
}
private void updateFeeltraceDisplays() {
}
private void updatePowerDisplays() {
slPower.setValue(powerModel.getValue());
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel lMinActivation;
private javax.swing.JLabel lMaxEvaluation;
private javax.swing.JSlider slPower;
private javax.swing.JLabel lMinEvaluation;
private javax.swing.JLabel lMinPower;
private javax.swing.JLabel lMaxActivation;
private javax.swing.JLabel lMaxPower;
private JFeeltraceCircle jFeeltraceCircle1;
// End of variables declaration//GEN-END:variables
private void updatePowerDisplays() {
slPower.setValue(powerModel.getValue());
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel lMinActivation;
private javax.swing.JLabel lMaxEvaluation;
private javax.swing.JSlider slPower;
private javax.swing.JLabel lMinEvaluation;
private javax.swing.JLabel lMinPower;
private javax.swing.JLabel lMaxActivation;
private javax.swing.JLabel lMaxPower;
private JFeeltraceCircle jFeeltraceCircle1;
// End of variables declaration//GEN-END:variables
}

Просмотреть файл

@ -20,12 +20,11 @@
package marytts.tools.emospeak;
/**
*
* @author schroed
*
* @author schroed
*/
public interface ProsodyXMLDisplayer {
void updateProsodyXML(String prosodyxmlString, int r1);
}
void updateProsodyXML(String prosodyxmlString, int r1);
}

Просмотреть файл

@ -20,115 +20,130 @@
package marytts.tools.emospeak;
/**
*
* @author Marc Schr&ouml;der
*
* @author Marc Schr&ouml;der
*/
public class RectangularTwoDimensionalModel implements TwoDimensionalModel {
private int x;
private int y;
private int minX;
private int maxX;
private int minY;
private int maxY;
private java.util.List changeListeners = new java.util.ArrayList();
/** Creates new RectangularTwoDimensionalModel, with all values
* set to 0. */
public RectangularTwoDimensionalModel() {
this(0,0,0,0,0,0);
}
private int x;
private int y;
private int minX;
private int maxX;
private int minY;
private int maxY;
private java.util.List changeListeners = new java.util.ArrayList();
/** Creates new RectangularTwoDimensionalModel */
public RectangularTwoDimensionalModel(int x, int y, int minX, int maxX, int minY, int maxY) {
this.x = x;
this.y = y;
this.minX = minX;
this.maxX = maxX;
this.minY = minY;
this.maxY = maxY;
}
/**
* Creates new RectangularTwoDimensionalModel, with all values set to 0.
*/
public RectangularTwoDimensionalModel() {
this(0, 0, 0, 0, 0, 0);
}
/** Adds a ChangeListener to the model's listener list. */
public void addChangeListener(javax.swing.event.ChangeListener l) {
if (!changeListeners.contains(l))
changeListeners.add(l);
}
/** Removes a ChangeListener from the model's listener list. */
public void removeChangeListener(javax.swing.event.ChangeListener l) {
changeListeners.remove(l);
}
/** Creates new RectangularTwoDimensionalModel */
public RectangularTwoDimensionalModel(int x, int y, int minX, int maxX, int minY, int maxY) {
this.x = x;
this.y = y;
this.minX = minX;
this.maxX = maxX;
this.minY = minY;
this.maxY = maxY;
}
private void notifyChangeListeners() {
java.util.Iterator it = changeListeners.iterator();
javax.swing.event.ChangeEvent e = new javax.swing.event.ChangeEvent(this);
while (it.hasNext()) {
javax.swing.event.ChangeListener l = (javax.swing.event.ChangeListener) it.next();
l.stateChanged(e);
}
}
/** Set the Maximum X value. */
public void setMaxX(int maxX) {
this.maxX = maxX;
}
/** Set the Maximum Y value. */
public void setMaxY(int maxY) {
this.maxY = maxY;
}
/** Set the Minimum X value. */
public void setMinX(int minX) {
this.minX = minX;
}
/** Set the Minimum Y value. */
public void setMinY(int minY) {
this.minY = minY;
}
/** Set X value.
* If beyond the Max and Min range, value is ignored.
*/
public void setX(int x) {
if (minX <= x && x <= maxX) {
this.x = x;
notifyChangeListeners();
}
}
/** Jointly set x and y values.
* If one of the values is beyond the
* respective Max and Min range, both values are ignored.
*/
public void setXY(int x, int y) {
if (minX <= x && x <= maxX &&
minY <= y && y <= maxY) {
this.x = x;
this.y = y;
notifyChangeListeners();
}
}
/** Set Y value.
* If beyond the Max and Min range, value is ignored.
*/
public void setY(int y) {
if (minY <= y && y <= maxY) {
this.y = y;
notifyChangeListeners();
}
}
/** Get the X value. */
public int getX() { return x; }
/** Get the Y value. */
public int getY() { return y; }
public int getMaxX() { return maxX; }
public int getMinX() { return minX; }
public int getMaxY() { return maxY; }
public int getMinY() { return minY; }
/** Adds a ChangeListener to the model's listener list. */
public void addChangeListener(javax.swing.event.ChangeListener l) {
if (!changeListeners.contains(l))
changeListeners.add(l);
}
/** Removes a ChangeListener from the model's listener list. */
public void removeChangeListener(javax.swing.event.ChangeListener l) {
changeListeners.remove(l);
}
private void notifyChangeListeners() {
java.util.Iterator it = changeListeners.iterator();
javax.swing.event.ChangeEvent e = new javax.swing.event.ChangeEvent(this);
while (it.hasNext()) {
javax.swing.event.ChangeListener l = (javax.swing.event.ChangeListener) it.next();
l.stateChanged(e);
}
}
/** Set the Maximum X value. */
public void setMaxX(int maxX) {
this.maxX = maxX;
}
/** Set the Maximum Y value. */
public void setMaxY(int maxY) {
this.maxY = maxY;
}
/** Set the Minimum X value. */
public void setMinX(int minX) {
this.minX = minX;
}
/** Set the Minimum Y value. */
public void setMinY(int minY) {
this.minY = minY;
}
/**
* Set X value. If beyond the Max and Min range, value is ignored.
*/
public void setX(int x) {
if (minX <= x && x <= maxX) {
this.x = x;
notifyChangeListeners();
}
}
/**
* Jointly set x and y values. If one of the values is beyond the respective Max and Min range, both values are ignored.
*/
public void setXY(int x, int y) {
if (minX <= x && x <= maxX && minY <= y && y <= maxY) {
this.x = x;
this.y = y;
notifyChangeListeners();
}
}
/**
* Set Y value. If beyond the Max and Min range, value is ignored.
*/
public void setY(int y) {
if (minY <= y && y <= maxY) {
this.y = y;
notifyChangeListeners();
}
}
/** Get the X value. */
public int getX() {
return x;
}
/** Get the Y value. */
public int getY() {
return y;
}
public int getMaxX() {
return maxX;
}
public int getMinX() {
return minX;
}
public int getMaxY() {
return maxY;
}
public int getMinY() {
return minY;
}
}

Просмотреть файл

@ -20,45 +20,54 @@
package marytts.tools.emospeak;
/**
*
* @author Marc Schr&ouml;der
*
* @author Marc Schr&ouml;der
*/
public interface TwoDimensionalModel {
/** Jointly set x and y values.
* If one of the values is beyond the
* respective Max and Min range, both values are ignored.
*/
public void setXY(int x, int y);
/** Set X value.
* If beyond the Max and Min range, value is ignored.
*/
public void setX(int x);
/** Set Y value.
* If beyond the Max and Min range, value is ignored.
*/
public void setY(int y);
/** Set the Maximum X value. */
public void setMaxX(int maxX);
/** Set the Minimum X value. */
public void setMinX(int minX);
/** Set the Maximum Y value. */
public void setMaxY(int maxY);
/** Set the Minimum Y value. */
public void setMinY(int minY);
/** Get the X value. */
public int getX();
/** Get the Y value. */
public int getY();
public int getMaxX();
public int getMinX();
public int getMaxY();
public int getMinY();
/** Adds a ChangeListener to the model's listener list. */
public void addChangeListener(javax.swing.event.ChangeListener l);
/** Removes a ChangeListener from the model's listener list. */
public void removeChangeListener(javax.swing.event.ChangeListener l);
/**
* Jointly set x and y values. If one of the values is beyond the respective Max and Min range, both values are ignored.
*/
public void setXY(int x, int y);
/**
* Set X value. If beyond the Max and Min range, value is ignored.
*/
public void setX(int x);
/**
* Set Y value. If beyond the Max and Min range, value is ignored.
*/
public void setY(int y);
/** Set the Maximum X value. */
public void setMaxX(int maxX);
/** Set the Minimum X value. */
public void setMinX(int minX);
/** Set the Maximum Y value. */
public void setMaxY(int maxY);
/** Set the Minimum Y value. */
public void setMinY(int minY);
/** Get the X value. */
public int getX();
/** Get the Y value. */
public int getY();
public int getMaxX();
public int getMinX();
public int getMaxY();
public int getMinY();
/** Adds a ChangeListener to the model's listener list. */
public void addChangeListener(javax.swing.event.ChangeListener l);
/** Removes a ChangeListener from the model's listener list. */
public void removeChangeListener(javax.swing.event.ChangeListener l);
}