File: Monitor.java

package info (click to toggle)
freetts 1.2.2-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 65,244 kB
  • sloc: java: 21,305; xml: 1,340; sh: 969; lisp: 587; ansic: 241; makefile: 25; awk: 11
file content (88 lines) | stat: -rw-r--r-- 2,232 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
 * Copyright 2001 Sun Microsystems, Inc.
 * 
 * See the file "license.terms" for information on usage and
 * redistribution of this file, and for a DISCLAIMER OF ALL 
 * WARRANTIES.
 */
import java.awt.Component;
import java.awt.Container;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.speech.synthesis.Synthesizer;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import javax.swing.border.TitledBorder;

import com.sun.speech.engine.synthesis.SynthesizerMonitor;
import com.sun.speech.engine.EngineEventPanel;

/**
 * Implements the GUI for a SynthesizerMonitor.
 */
public class Monitor extends JPanel {
    
    private SynthesizerMonitor monitor;
    private Synthesizer synthesizer;
    private int width = 600;
    private int height = 300;


    /**
     * Constructs a Monitor for the given synthesizer
     *
     * @param synthesizer the synthesizer it monitors
     * @param synthesizerName name of the synthesizer
     */
    public Monitor(Synthesizer synthesizer, String synthesizerName) {
	TitledBorder titledBorder = new TitledBorder(synthesizerName);
	setBorder(titledBorder);
	setPreferredSize(new Dimension(width, height));
	setSize(width, height);
	this.synthesizer = synthesizer;
	this.monitor = new SynthesizerMonitor(synthesizer);
	createMonitorPanel();
    }


    /**
     * Populates this Monitor JPanel.
     */
    private void createMonitorPanel() {
	GridBagLayout gridbag = new GridBagLayout();
	setLayout(gridbag);

	GridBagConstraints c = new GridBagConstraints();
	c.anchor = GridBagConstraints.WEST;
	c.insets = new Insets(4,4,4,4);
	c.gridx = 0;
	c.gridy = 0;        
	c.weightx = 1.0;
	c.fill = GridBagConstraints.BOTH;

	Component sp = monitor.getStatePanel();
	gridbag.setConstraints(sp, c);
	add(sp);

	EngineEventPanel eventPanel = 
	    (EngineEventPanel) monitor.getEventPanel();

	c.gridy = 1;
	c.weighty = 1.0;
	gridbag.setConstraints(eventPanel, c);
	add(eventPanel);
	validate();
    }
}