[DEV] 2.4 tools
This commit is contained in:
48
java/common/Makefile
Normal file
48
java/common/Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
###########################################################################
|
||||
## ##
|
||||
## Centre for Speech Technology Research ##
|
||||
## University of Edinburgh, UK ##
|
||||
## Copyright (c) 1996 ##
|
||||
## All Rights Reserved. ##
|
||||
## ##
|
||||
## 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. ##
|
||||
## ##
|
||||
## THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. ##
|
||||
## ##
|
||||
###########################################################################
|
||||
|
||||
TOP=../..
|
||||
DIRNAME=java/common
|
||||
|
||||
BUILD_DIRS = cstr
|
||||
NEED_JAVA = true
|
||||
|
||||
FILES = Makefile
|
||||
|
||||
ALL = .sub_directories .javalib
|
||||
|
||||
-include Makefile.version
|
||||
include $(TOP)/config/common_make_rules
|
||||
|
||||
|
||||
48
java/common/cstr/Makefile
Normal file
48
java/common/cstr/Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
###########################################################################
|
||||
## ##
|
||||
## Centre for Speech Technology Research ##
|
||||
## University of Edinburgh, UK ##
|
||||
## Copyright (c) 1996 ##
|
||||
## All Rights Reserved. ##
|
||||
## ##
|
||||
## 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. ##
|
||||
## ##
|
||||
## THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. ##
|
||||
## ##
|
||||
###########################################################################
|
||||
|
||||
TOP=../../..
|
||||
DIRNAME=java/common/cstr
|
||||
|
||||
BUILD_DIRS = awt util est testPrograms
|
||||
NEED_JAVA = true
|
||||
|
||||
FILES = Makefile
|
||||
|
||||
ALL = .sub_directories
|
||||
|
||||
-include ../Makefile.version
|
||||
include $(TOP)/config/common_make_rules
|
||||
|
||||
|
||||
86
java/common/cstr/awt/ColorSelection.java
Normal file
86
java/common/cstr/awt/ColorSelection.java
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// A selection of colors from which colors can be selected. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.awt ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class ColorSelection
|
||||
|
||||
{
|
||||
protected Color [] colors;
|
||||
protected int pos;
|
||||
|
||||
public ColorSelection(Color [] cols)
|
||||
{
|
||||
colors = cols;
|
||||
pos=0;
|
||||
}
|
||||
|
||||
public ColorSelection(Color col)
|
||||
{
|
||||
colors = new Color [] {col};
|
||||
pos=0;
|
||||
}
|
||||
|
||||
public ColorSelection(String cols)
|
||||
{
|
||||
StringTokenizer tok = new StringTokenizer(cols, ",");
|
||||
int n = tok.countTokens();
|
||||
|
||||
colors = new Color[n];
|
||||
for(int i=0; i<n; i++)
|
||||
colors[i] = new XColor(tok.nextToken());
|
||||
|
||||
pos=0;
|
||||
}
|
||||
|
||||
public Color nextColor()
|
||||
{
|
||||
if (pos >= colors.length)
|
||||
pos -= colors.length;
|
||||
|
||||
if (pos >= colors.length)
|
||||
return Color.black;
|
||||
|
||||
return colors[pos++];
|
||||
}
|
||||
}
|
||||
146
java/common/cstr/awt/ImageCanvas.java
Normal file
146
java/common/cstr/awt/ImageCanvas.java
Normal file
@@ -0,0 +1,146 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// Date: Thu Apr 9 1998 \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
package cstr.awt;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class ImageCanvas extends Canvas
|
||||
{
|
||||
Image image;
|
||||
int pwidth, pheight;
|
||||
|
||||
private void init(Image im, double xscale, double yscale)
|
||||
{
|
||||
pwidth = (int)(im.getWidth(this)*xscale);
|
||||
pheight = (int)(im.getHeight(this)*yscale);
|
||||
|
||||
if (xscale != 1.0 || yscale != 1.0)
|
||||
{
|
||||
ImageFilter filter = new ReplicateScaleFilter(pwidth, pheight);
|
||||
|
||||
image = createImage(new FilteredImageSource(im.getSource(), filter));
|
||||
}
|
||||
else
|
||||
image = im;
|
||||
}
|
||||
|
||||
public ImageCanvas(Image touse, double xscale, double yscale)
|
||||
{
|
||||
super();
|
||||
|
||||
init(touse, xscale, yscale);
|
||||
}
|
||||
|
||||
public ImageCanvas(ImageProducer prod, double xscale, double yscale)
|
||||
{
|
||||
super();
|
||||
|
||||
init(createImage(prod), xscale, yscale);
|
||||
}
|
||||
|
||||
public ImageCanvas(Image touse, double scale)
|
||||
{
|
||||
super();
|
||||
|
||||
init(touse, scale, scale);
|
||||
}
|
||||
|
||||
public ImageCanvas(ImageProducer prod, double scale)
|
||||
{
|
||||
super();
|
||||
|
||||
init(createImage(prod), scale, scale);
|
||||
}
|
||||
|
||||
public ImageCanvas(Image touse)
|
||||
{
|
||||
super();
|
||||
|
||||
init(touse, 1.0, 1.0);
|
||||
}
|
||||
|
||||
public ImageCanvas(ImageProducer prod)
|
||||
{
|
||||
super();
|
||||
|
||||
init(createImage(prod), 1.0, 1.0);
|
||||
}
|
||||
|
||||
public boolean imageUpdate(Image img,
|
||||
int flags,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h)
|
||||
{
|
||||
int oh =pheight;
|
||||
int ow = pwidth;
|
||||
|
||||
if ((flags & ImageObserver.WIDTH) != 0)
|
||||
pwidth = w;
|
||||
if ((flags & ImageObserver.HEIGHT) != 0 )
|
||||
pheight = h;
|
||||
|
||||
if (pwidth!= ow || pheight != oh)
|
||||
setSize(pwidth, pheight);
|
||||
|
||||
repaint();
|
||||
return !((flags & ImageObserver.ALLBITS) != 0);
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
return new Dimension(pwidth, pheight);
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize()
|
||||
{
|
||||
return new Dimension(pwidth, pheight);
|
||||
}
|
||||
|
||||
public void update(Graphics g)
|
||||
{
|
||||
paint(g);
|
||||
}
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
g.drawImage(image, 0, 0, pwidth, pheight, this);
|
||||
}
|
||||
}
|
||||
46
java/common/cstr/awt/Makefile
Normal file
46
java/common/cstr/awt/Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
###########################################################################
|
||||
## ##
|
||||
## Centre for Speech Technology Research ##
|
||||
## University of Edinburgh, UK ##
|
||||
## Copyright (c) 1996 ##
|
||||
## All Rights Reserved. ##
|
||||
## ##
|
||||
## 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. ##
|
||||
## ##
|
||||
## THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. ##
|
||||
## ##
|
||||
###########################################################################
|
||||
|
||||
TOP=../../../..
|
||||
DIRNAME=java/common/cstr/awt
|
||||
|
||||
JAVA_CLASSES = ScrollWindow ImageCanvas XColor ColorSelection
|
||||
NEED_JAVA = true
|
||||
|
||||
FILES = Makefile $(JAVA_CLASSES:=.java)
|
||||
|
||||
ALL = .java
|
||||
|
||||
-include ../../Makefile.version
|
||||
include $(TOP)/config/common_make_rules
|
||||
134
java/common/cstr/awt/ScrollWindow.java
Normal file
134
java/common/cstr/awt/ScrollWindow.java
Normal file
@@ -0,0 +1,134 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// Date: Thu Apr 9 1998 \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
|
||||
package cstr.awt;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import cstr.est.*;
|
||||
|
||||
public class ScrollWindow extends Frame
|
||||
implements ActionListener, WindowListener
|
||||
{
|
||||
ScrollPane scroller;
|
||||
Canvas canvas;
|
||||
|
||||
private void init(String title, Component contents, int width, int height)
|
||||
{
|
||||
setTitle(title);
|
||||
setSize(width, height);
|
||||
|
||||
scroller = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
|
||||
scroller.add(contents);
|
||||
scroller.doLayout();
|
||||
|
||||
MenuBar mb = new MenuBar();
|
||||
setMenuBar(mb);
|
||||
|
||||
Menu cMenu = new Menu("Control", true);
|
||||
mb.add(cMenu);
|
||||
|
||||
MenuItem mItem = new MenuItem("Quit");
|
||||
mItem.addActionListener(this);
|
||||
cMenu.add(mItem);
|
||||
|
||||
addWindowListener(this);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add("Center", scroller);
|
||||
pack();
|
||||
}
|
||||
|
||||
public ScrollWindow(String name, Component contents)
|
||||
{
|
||||
super();
|
||||
init(name, contents, 500, 500);
|
||||
}
|
||||
|
||||
public ScrollWindow(String name, Component contents, int width, int height)
|
||||
{
|
||||
super();
|
||||
init(name, contents, width, height);
|
||||
}
|
||||
|
||||
public void quit()
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void quit(String s)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent event)
|
||||
{
|
||||
quit("action");
|
||||
}
|
||||
|
||||
public void windowClosing(WindowEvent event)
|
||||
{
|
||||
quit("close");
|
||||
}
|
||||
|
||||
public void windowOpened(WindowEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public void windowClosed(WindowEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public void windowIconified(WindowEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public void windowDeiconified(WindowEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public void windowActivated(WindowEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public void windowDeactivated(WindowEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
202
java/common/cstr/awt/XColor.java
Normal file
202
java/common/cstr/awt/XColor.java
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// Date: Thu Apr 9 1998 \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Extend awt.Color to understand X11 color names. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.awt ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class XColor extends Color
|
||||
{
|
||||
protected static String rgbFile;
|
||||
protected static Hashtable colors = new Hashtable(100);
|
||||
protected static Reader rgbStream;
|
||||
protected static StreamTokenizer rgbTok;
|
||||
|
||||
protected String name;
|
||||
|
||||
static
|
||||
{
|
||||
rgbFile = System.getProperty("est.rgbFile");
|
||||
}
|
||||
|
||||
public XColor(float r, float g, float b)
|
||||
{
|
||||
super(r,g,b);
|
||||
name=null;
|
||||
}
|
||||
|
||||
public XColor(int rgb)
|
||||
{
|
||||
super(rgb);
|
||||
name=null;
|
||||
}
|
||||
|
||||
public XColor(int r, int g, int b)
|
||||
{
|
||||
super(r,g,b);
|
||||
name=null;
|
||||
}
|
||||
|
||||
public XColor(String n)
|
||||
{
|
||||
super(x11ColorRGB(n));
|
||||
name=n;
|
||||
}
|
||||
|
||||
public XColor(String n, int i)
|
||||
{
|
||||
super(x11ColorRGBThrow(n));
|
||||
name=n;
|
||||
}
|
||||
|
||||
public static int x11ColorRGBThrow(String name)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
int c = x11ColorRGB(name);
|
||||
if (c<0)
|
||||
throw new IllegalArgumentException("Can't find color '"+name+"'");
|
||||
return c;
|
||||
}
|
||||
|
||||
public static int x11ColorRGB(String name)
|
||||
{
|
||||
|
||||
name = name.toLowerCase();
|
||||
|
||||
Integer rgbI = (Integer)colors.get(name);
|
||||
|
||||
if (rgbI != null)
|
||||
return rgbI.intValue();
|
||||
|
||||
if (name.startsWith("#"))
|
||||
try {
|
||||
return Integer.parseInt(name.substring(1), 16);
|
||||
} catch (NumberFormatException ex) {
|
||||
System.err.println("Can't parse color '"+name+"'");
|
||||
return 0;
|
||||
};
|
||||
|
||||
if (rgbStream == null)
|
||||
try {
|
||||
rgbStream = new FileReader(rgbFile);
|
||||
rgbTok = new StreamTokenizer(rgbStream);
|
||||
rgbTok.parseNumbers();
|
||||
rgbTok.ordinaryChar('\n');
|
||||
|
||||
} catch (FileNotFoundException ex) {
|
||||
System.err.println("can't open '" + rgbFile + "' " + ex.getMessage());
|
||||
}
|
||||
|
||||
int r=0;
|
||||
int g=0;
|
||||
int b=0;
|
||||
|
||||
String n="";
|
||||
|
||||
|
||||
try {
|
||||
while (1==1)
|
||||
{
|
||||
int t = rgbTok.nextToken();
|
||||
|
||||
if (t == rgbTok.TT_EOF)
|
||||
break;
|
||||
|
||||
if (t == '\n')
|
||||
continue;
|
||||
|
||||
if ( t == '!')
|
||||
{
|
||||
while (t != '\n' && t != rgbTok.TT_EOF)
|
||||
t = rgbTok.nextToken();
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( t == rgbTok.TT_NUMBER)
|
||||
r = (int)rgbTok.nval;
|
||||
|
||||
t = rgbTok.nextToken();
|
||||
if ( t == rgbTok.TT_NUMBER)
|
||||
g = (int)rgbTok.nval;
|
||||
|
||||
t = rgbTok.nextToken();
|
||||
if ( t == rgbTok.TT_NUMBER)
|
||||
b = (int)rgbTok.nval;
|
||||
|
||||
n="";
|
||||
while ((t = rgbTok.nextToken()) != '\n' && t != rgbTok.TT_EOF)
|
||||
{
|
||||
if (!n.equals(""))
|
||||
n = n + " ";
|
||||
|
||||
n = n + rgbTok.sval;
|
||||
}
|
||||
|
||||
int rgb = (r<<16)|(g<<8)|(b);
|
||||
colors.put(n.toLowerCase(), new Integer(rgb));
|
||||
|
||||
if (name.equals(n.toLowerCase()))
|
||||
return rgb;
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
System.err.println("Can't find color '"+name+"'");
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getName(Color c)
|
||||
{
|
||||
return "#"+Integer.toString(c.getRGB(), 16);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (name != null)
|
||||
return name;
|
||||
return getName(this);
|
||||
}
|
||||
|
||||
}
|
||||
47
java/common/cstr/est/Makefile
Normal file
47
java/common/cstr/est/Makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
###########################################################################
|
||||
## ##
|
||||
## Centre for Speech Technology Research ##
|
||||
## University of Edinburgh, UK ##
|
||||
## Copyright (c) 1996 ##
|
||||
## All Rights Reserved. ##
|
||||
## ##
|
||||
## 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. ##
|
||||
## ##
|
||||
## THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. ##
|
||||
## ##
|
||||
###########################################################################
|
||||
|
||||
TOP=../../../..
|
||||
DIRNAME=java/common/cstr/est
|
||||
|
||||
BUILD_DIRS = awt
|
||||
JAVA_CLASSES = SocketsFile ServerConnection
|
||||
NEED_JAVA = true
|
||||
|
||||
FILES = Makefile $(JAVA_CLASSES:=.java)
|
||||
|
||||
ALL = .sub_directories
|
||||
|
||||
include $(TOP)/config/common_make_rules
|
||||
|
||||
129
java/common/cstr/est/ServerConnection.java
Normal file
129
java/common/cstr/est/ServerConnection.java
Normal file
@@ -0,0 +1,129 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Wrapper around a socket which is connected to Fringe. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
package cstr.est;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class ServerConnection
|
||||
{
|
||||
private static String command_term = "//End//";
|
||||
private static String result_term = "//End//";
|
||||
|
||||
private Socket s;
|
||||
private BufferedReader reader;
|
||||
private BufferedWriter writer;
|
||||
|
||||
public ServerConnection(Socket sk)
|
||||
throws IOException
|
||||
{
|
||||
setSocket(sk);
|
||||
}
|
||||
|
||||
public void setSocket(Socket sk)
|
||||
throws IOException
|
||||
{
|
||||
s=sk;
|
||||
|
||||
try {
|
||||
if (s == null)
|
||||
throw new IOException("no socket");
|
||||
|
||||
Reader r = new InputStreamReader(s.getInputStream());
|
||||
reader = new BufferedReader(r);
|
||||
|
||||
Writer w = new OutputStreamWriter(s.getOutputStream());
|
||||
writer = new BufferedWriter(w);
|
||||
} catch (IOException e) {
|
||||
reader=null;
|
||||
writer=null;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
protected String readResult()
|
||||
throws IOException
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
StringBuffer res = new StringBuffer(100);
|
||||
String status = null;
|
||||
while (true)
|
||||
{
|
||||
String line = reader.readLine();
|
||||
if (line.startsWith(result_term))
|
||||
{
|
||||
status = line.substring(result_term.length());
|
||||
break;
|
||||
}
|
||||
res.append(line);
|
||||
}
|
||||
if (status.equals("OK"))
|
||||
return res.toString();
|
||||
else if (status.equals("ERROR"))
|
||||
return "!"+res.toString();
|
||||
else if (status.equals("VAL"))
|
||||
System.err.println("Warning, intermediate value '"+res.toString()+"'");
|
||||
else
|
||||
throw new IOException("Uknknown value type "+status);
|
||||
}
|
||||
}
|
||||
|
||||
public String sendCommand(String command)
|
||||
throws IOException
|
||||
{
|
||||
writer.write(command, 0, command.length());
|
||||
writer.newLine();
|
||||
writer.write(command_term, 0, command_term.length());
|
||||
writer.newLine();
|
||||
writer.flush();
|
||||
|
||||
String result = readResult();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String sendCommand(StringBuffer command)
|
||||
throws IOException
|
||||
{
|
||||
return sendCommand(command.toString());
|
||||
}
|
||||
}
|
||||
132
java/common/cstr/est/SocketsFile.java
Normal file
132
java/common/cstr/est/SocketsFile.java
Normal file
@@ -0,0 +1,132 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Interface to the file in ~/.fringe/ which contains pointers to \\
|
||||
// running fringe process \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
package cstr.est ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class SocketsFile
|
||||
{
|
||||
protected static Random random = new Random();
|
||||
protected String filename;
|
||||
|
||||
public SocketsFile(String fn)
|
||||
{
|
||||
filename=fn;
|
||||
}
|
||||
|
||||
public String setSocket(String type,
|
||||
String name,
|
||||
ServerSocket s)
|
||||
throws IOException
|
||||
{
|
||||
int port = s.getLocalPort();
|
||||
int cookie = random.nextInt();
|
||||
InetAddress address = s.getInetAddress();
|
||||
Properties props = new Properties();
|
||||
|
||||
try {
|
||||
InputStream is = new FileInputStream(filename);
|
||||
|
||||
props.load(is);
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
|
||||
props.put(name+".type", type);
|
||||
props.put(name+".host", address.getHostName());
|
||||
props.put(name+".address", address.getHostAddress());
|
||||
props.put(name+".cookie", Integer.toString(cookie));
|
||||
props.put(name+".port", Integer.toString(port));
|
||||
|
||||
OutputStream os = new FileOutputStream(filename);
|
||||
|
||||
props.save(os, "Fringe Sockets");
|
||||
|
||||
return Integer.toString(cookie);
|
||||
}
|
||||
|
||||
protected static void sendCookie(Socket s, String cookie)
|
||||
{
|
||||
try {
|
||||
Writer w = new OutputStreamWriter(s.getOutputStream());
|
||||
|
||||
w.write("//");
|
||||
w.write(cookie);
|
||||
w.write("\n");
|
||||
w.flush();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public Socket getSocket(String myType, String name)
|
||||
throws IOException
|
||||
{
|
||||
Socket s=null;
|
||||
Properties props = new Properties();
|
||||
|
||||
InputStream is = new FileInputStream(filename);
|
||||
|
||||
props.load(is);
|
||||
|
||||
String type = props.getProperty(name+".type");
|
||||
String hostname = props.getProperty(name+".host");
|
||||
String address = props.getProperty(name+".address");
|
||||
String portStr = props.getProperty(name+".port");
|
||||
String cookieStr = props.getProperty(name+".cookie");
|
||||
|
||||
if (!myType.equals(type))
|
||||
return null;
|
||||
|
||||
if (address != null && portStr != null)
|
||||
{
|
||||
int port = Integer.parseInt(portStr);
|
||||
|
||||
s = new Socket(address, port);
|
||||
}
|
||||
|
||||
if (s != null && cookieStr !=null && !cookieStr.equals("none"))
|
||||
sendCookie(s, cookieStr);
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
94
java/common/cstr/est/awt/Item_Content_Window.java
Normal file
94
java/common/cstr/est/awt/Item_Content_Window.java
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Window which displays an Item_Content object. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.est.awt ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
import cstr.est.*;
|
||||
|
||||
public class Item_Content_Window extends Container
|
||||
{
|
||||
protected Item_Content content;
|
||||
protected Item item;
|
||||
|
||||
public Item_Content_Window(Item_Content cont)
|
||||
{
|
||||
super();
|
||||
setLayout(new GridLayout(0,2));
|
||||
content=cont;
|
||||
item=cont.getItem();
|
||||
update();
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
removeAll();
|
||||
if (content != null)
|
||||
{
|
||||
String [] names = getFeatureNames(content);
|
||||
Label l;
|
||||
|
||||
for(int i=0; i<names.length; i++)
|
||||
{
|
||||
add(l=new Label(names[i], Label.RIGHT));
|
||||
l.setBackground(Color.white);
|
||||
add(l=new Label(item.getS(names[i],"NULL"), Label.LEFT));
|
||||
l.setBackground(Color.white);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String [] getFeatureNames(Item_Content content)
|
||||
{
|
||||
Vector names = new Vector(100);
|
||||
|
||||
content.getFeatures().getPaths(null, names, false, true);
|
||||
|
||||
String [] s = new String[names.size()];
|
||||
|
||||
for (int i=0; i<s.length; i++)
|
||||
s[i] = (String)names.elementAt(i);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
49
java/common/cstr/est/awt/Makefile
Normal file
49
java/common/cstr/est/awt/Makefile
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
###########################################################################
|
||||
## ##
|
||||
## Centre for Speech Technology Research ##
|
||||
## University of Edinburgh, UK ##
|
||||
## Copyright (c) 1996 ##
|
||||
## All Rights Reserved. ##
|
||||
## ##
|
||||
## 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. ##
|
||||
## ##
|
||||
## THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. ##
|
||||
## ##
|
||||
###########################################################################
|
||||
|
||||
TOP=../../../../..
|
||||
DIRNAME = java/common/cstr/est/awt
|
||||
|
||||
BUILD_DIRS =
|
||||
JAVA_CLASSES = Item_Content_Window WaveImageSource
|
||||
NEED_JAVA = true
|
||||
|
||||
FILES = $(JAVA_CLASSES:%=%.java) Makefile
|
||||
|
||||
ALL = .java .buildlib
|
||||
|
||||
-include ../../../Makefile.version
|
||||
include $(TOP)/config/common_make_rules
|
||||
|
||||
|
||||
218
java/common/cstr/est/awt/WaveImageSource.java
Normal file
218
java/common/cstr/est/awt/WaveImageSource.java
Normal file
@@ -0,0 +1,218 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// Date: Mon Sep 22 1997 \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// A class which implements the image producer interface using a Wave \\
|
||||
// as the source of the image. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
package cstr.est.awt;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
|
||||
import cstr.est.*;
|
||||
|
||||
public class WaveImageSource implements ImageProducer
|
||||
{
|
||||
static ColorModel cmodel;
|
||||
|
||||
static {
|
||||
cmodel = new IndexColorModel(24, 5, new byte[]
|
||||
{
|
||||
-1, -1, -1,
|
||||
-32, 110, 70,
|
||||
-64, 100, 60,
|
||||
-96, 90, 50,
|
||||
-127, 80, 40
|
||||
},
|
||||
0, false);
|
||||
}
|
||||
|
||||
Wave wave;
|
||||
int channel;
|
||||
int x;
|
||||
int chunk;
|
||||
int width;
|
||||
int height;
|
||||
int amplitude;
|
||||
|
||||
Vector consumers;
|
||||
|
||||
public WaveImageSource(Wave w, int c,
|
||||
int xoff, int xlen,
|
||||
int hsize, int vsize)
|
||||
{
|
||||
wave = w;
|
||||
channel=c;
|
||||
x = xoff;
|
||||
chunk = xlen;
|
||||
width = hsize;
|
||||
height = vsize;
|
||||
amplitude = w.amplitude(channel) + 100;
|
||||
|
||||
consumers = new Vector(1);
|
||||
}
|
||||
|
||||
public WaveImageSource(Wave w, int vsize)
|
||||
{
|
||||
this(w, 0, 0, w.num_samples(), w.num_samples(), vsize);
|
||||
}
|
||||
|
||||
public WaveImageSource(Wave w)
|
||||
{
|
||||
this(w, 0, 0, w.num_samples(), w.num_samples(), 150);
|
||||
}
|
||||
|
||||
public void addConsumer(ImageConsumer ic)
|
||||
{
|
||||
if (!consumers.contains(ic))
|
||||
consumers.addElement(ic);
|
||||
}
|
||||
|
||||
public boolean isConsumer(ImageConsumer ic)
|
||||
{
|
||||
return consumers.contains(ic);
|
||||
}
|
||||
|
||||
public void removeConsumer(ImageConsumer ic)
|
||||
{
|
||||
consumers.removeElement(ic);
|
||||
}
|
||||
|
||||
public void startProduction(ImageConsumer ic)
|
||||
{
|
||||
addConsumer(ic);
|
||||
produce();
|
||||
}
|
||||
|
||||
public void requestTopDownLeftRightResend(ImageConsumer ic)
|
||||
{
|
||||
produce();
|
||||
}
|
||||
|
||||
private void sendHints(int hints)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<consumers.size(); i++)
|
||||
{
|
||||
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
|
||||
if (ic != null)
|
||||
ic.setHints(hints);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendColorModel()
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<consumers.size(); i++)
|
||||
{
|
||||
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
|
||||
if (ic != null)
|
||||
ic.setColorModel(cmodel);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendDimensions()
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<consumers.size(); i++)
|
||||
{
|
||||
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
|
||||
if (ic != null)
|
||||
ic.setDimensions(chunk, height);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendLine(byte [] line, int l, int n)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<consumers.size(); i++)
|
||||
{
|
||||
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
|
||||
if (ic != null)
|
||||
ic.setPixels(0, l, chunk, n, cmodel, line, 0, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendComplete(int status)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<consumers.size(); i++)
|
||||
{
|
||||
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
|
||||
if (ic != null)
|
||||
ic.imageComplete(status);
|
||||
}
|
||||
}
|
||||
|
||||
protected void produce()
|
||||
{
|
||||
System.out.println("start prod");
|
||||
|
||||
sendHints(ImageConsumer.SINGLEFRAME
|
||||
| ImageConsumer.SINGLEPASS
|
||||
| ImageConsumer.TOPDOWNLEFTRIGHT);
|
||||
|
||||
sendColorModel();
|
||||
sendDimensions();
|
||||
|
||||
|
||||
int nlines=30;
|
||||
byte [] line = new byte[chunk*nlines];
|
||||
|
||||
System.out.println("start send");
|
||||
for(int l=0; l < height ; l+=nlines)
|
||||
{
|
||||
int n = height-l>nlines?nlines:height-l;
|
||||
System.out.println("g");
|
||||
wave.cpp_getScanlines(channel, line, l, n,
|
||||
x, chunk,
|
||||
width, height,
|
||||
amplitude);
|
||||
System.out.println("s");
|
||||
sendLine(line, l, n);
|
||||
}
|
||||
|
||||
System.out.println("end send");
|
||||
sendComplete(ImageConsumer.STATICIMAGEDONE);
|
||||
|
||||
System.out.println("end prod");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
47
java/common/cstr/testPrograms/Makefile
Normal file
47
java/common/cstr/testPrograms/Makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
###########################################################################
|
||||
## ##
|
||||
## Centre for Speech Technology Research ##
|
||||
## University of Edinburgh, UK ##
|
||||
## Copyright (c) 1996 ##
|
||||
## All Rights Reserved. ##
|
||||
## ##
|
||||
## 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. ##
|
||||
## ##
|
||||
## THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. ##
|
||||
## ##
|
||||
###########################################################################
|
||||
|
||||
TOP=../../../..
|
||||
DIRNAME=java/common/cstr/testPrograms
|
||||
|
||||
BUILD_DIRS =
|
||||
JAVA_CLASSES = WaveTest PlayWave
|
||||
NEED_JAVA=1
|
||||
|
||||
FILES = Makefile $(JAVA_CLASSES:=.java)
|
||||
|
||||
ALL = .java
|
||||
|
||||
-include ../../Makefile.version
|
||||
include $(TOP)/config/common_make_rules
|
||||
66
java/common/cstr/testPrograms/PlayWave.java
Normal file
66
java/common/cstr/testPrograms/PlayWave.java
Normal file
@@ -0,0 +1,66 @@
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Test program to play waveforms. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
package cstr.testPrograms;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.awt.*;
|
||||
|
||||
import cstr.est.*;
|
||||
|
||||
public class PlayWave
|
||||
{
|
||||
public static void main(String [] args)
|
||||
{
|
||||
File file = new File(args[0]);
|
||||
|
||||
try {
|
||||
Wave wv = new Wave(file);
|
||||
|
||||
wv.play();
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Error: "+ex+" "+ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
// If we get here play has finished, but stupid JMF
|
||||
// has left threads running so the *%!%!%!*!* interpreter won't
|
||||
// exit.
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
158
java/common/cstr/testPrograms/WaveTest.java
Normal file
158
java/common/cstr/testPrograms/WaveTest.java
Normal file
@@ -0,0 +1,158 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// Date: Friday 12th September 1997 \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Simple test program to see if wave class works. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.testPrograms;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.lang.*;
|
||||
import java.io.*;
|
||||
|
||||
import cstr.awt.*;
|
||||
import cstr.est.*;
|
||||
import cstr.est.awt.*;
|
||||
|
||||
|
||||
public class WaveTest
|
||||
{
|
||||
|
||||
public static void useage(String com)
|
||||
{
|
||||
System.out.println("Useage: WaveTest FILENAME " + com);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
public static int save(Wave wv, int pos, String[] args)
|
||||
{
|
||||
if (args.length - pos <3)
|
||||
useage("save NEWFILENAME FORMAT");
|
||||
|
||||
try {
|
||||
wv.save(args[pos+1], args[pos+2]);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Save Error: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
public static int display(Wave wv, int pos, String[] args)
|
||||
{
|
||||
if (args.length - pos <1)
|
||||
useage("display");
|
||||
|
||||
|
||||
ImageProducer prod = new WaveImageSource(wv, 0, 400, 500, 1500, 150);
|
||||
|
||||
ImageCanvas canvas = new ImageCanvas(prod);
|
||||
|
||||
ScrollWindow win = new ScrollWindow(wv.name(), canvas, 500, 250);
|
||||
|
||||
try {
|
||||
win.setVisible(true);
|
||||
} catch (AWTError e) {
|
||||
System.out.println("Exit: " + e.getMessage());
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int resample(Wave wv, int pos, String[] args)
|
||||
{
|
||||
if (args.length - pos < 2)
|
||||
useage("resample RATE");
|
||||
|
||||
int rate=0;
|
||||
|
||||
try {
|
||||
rate = Integer.decode(args[pos+1]).intValue();
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("Sample rate must be integer > 0 not " + args[pos+1]);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (rate <= 0)
|
||||
{
|
||||
System.out.println("Sample rate must be > 0");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
wv.resample(rate);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
System.runFinalizersOnExit(true);
|
||||
|
||||
Wave wv = new Wave();
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
useage("COMMAND {ARGS...} ...");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
wv.load(args[0]);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("Load Error: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
int pos=1;
|
||||
|
||||
while (pos < args.length)
|
||||
{
|
||||
if (args[pos].equals("save"))
|
||||
pos += save(wv, pos, args);
|
||||
else if (args[pos].equals("resample"))
|
||||
pos += resample(wv, pos, args);
|
||||
else if (args[pos].equals("display"))
|
||||
pos += display(wv, pos, args);
|
||||
else
|
||||
useage("save/resample/display ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
56
java/common/cstr/util/BadValueException.java
Normal file
56
java/common/cstr/util/BadValueException.java
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Exception thrown when an attempt to look for a value which is not \\
|
||||
// in an Enum. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
|
||||
public class BadValueException extends Exception
|
||||
{
|
||||
public BadValueException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BadValueException(String m)
|
||||
{
|
||||
super(m);
|
||||
}
|
||||
}
|
||||
117
java/common/cstr/util/Enum.java
Normal file
117
java/common/cstr/util/Enum.java
Normal file
@@ -0,0 +1,117 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Simple Enumerated type superclass. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class Enum
|
||||
{
|
||||
String name;
|
||||
String longName;
|
||||
Object info;
|
||||
int index;
|
||||
|
||||
abstract public EnumValues getValuesTable();
|
||||
|
||||
protected static EnumValues init(String n)
|
||||
{
|
||||
return new EnumValues(n);
|
||||
}
|
||||
|
||||
protected Enum(String s, String ls, Object o)
|
||||
{
|
||||
setup(s, ls, o);
|
||||
}
|
||||
|
||||
protected Enum(String s, String ls, boolean real)
|
||||
{
|
||||
setup(s, ls, real?null:Enum.class);
|
||||
}
|
||||
|
||||
protected void setup(String s, String ls, Object o)
|
||||
{
|
||||
name=s;
|
||||
longName=ls;
|
||||
info=o;
|
||||
|
||||
EnumValues values = getValuesTable();
|
||||
|
||||
index=values.add(this);
|
||||
}
|
||||
|
||||
protected void alias(String a)
|
||||
{
|
||||
EnumValues values = getValuesTable();
|
||||
values.add(this, a);
|
||||
}
|
||||
|
||||
protected static Enum getValue(String s, EnumValues values)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
return values.getValue(s);
|
||||
}
|
||||
|
||||
protected static Object getValues(EnumValues values)
|
||||
{
|
||||
return (Object)values.getValues();
|
||||
}
|
||||
|
||||
public boolean isReal()
|
||||
{
|
||||
return info != Enum.class;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String toString(boolean lng)
|
||||
{
|
||||
return lng?longName:name;
|
||||
}
|
||||
|
||||
public Object getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
103
java/common/cstr/util/EnumValues.java
Normal file
103
java/common/cstr/util/EnumValues.java
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Mechanics of an enumerated type. Wrapped in a class for inheritance \\
|
||||
// purposes. NOte this is a public class all of whose mechanics are \\
|
||||
// package local, we can get hold of these from anywhere, but can't \\
|
||||
// do a thing with them, in fact only cstr.util.Enum is supposed to go \\
|
||||
// near this. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
|
||||
public class EnumValues
|
||||
{
|
||||
protected String name;
|
||||
protected Hashtable table;
|
||||
protected int n;
|
||||
protected Enum [] values=null;
|
||||
|
||||
EnumValues(String n)
|
||||
{
|
||||
name=n;
|
||||
table=new Hashtable();
|
||||
}
|
||||
|
||||
int add(Enum v)
|
||||
{
|
||||
table.put(v.toString(),
|
||||
v);
|
||||
table.put(v.toString(true),
|
||||
v);
|
||||
if (v.info != Enum.class)
|
||||
return n++;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void add(Enum v, String a)
|
||||
{
|
||||
table.put(a,v);
|
||||
}
|
||||
|
||||
Enum getValue(String s)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
Enum v = (Enum)table.get(s);
|
||||
if (v==null)
|
||||
throw new IllegalArgumentException(name+":"+s);
|
||||
return v;
|
||||
}
|
||||
|
||||
Enum [] getValues()
|
||||
{
|
||||
if (values == null)
|
||||
{
|
||||
values = new Enum[n];
|
||||
Enumeration vs = table.elements();
|
||||
while (vs.hasMoreElements())
|
||||
{
|
||||
Enum e = (Enum)vs.nextElement();
|
||||
if (e.index >=0)
|
||||
values[e.index] = e;
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
46
java/common/cstr/util/Featured.java
Normal file
46
java/common/cstr/util/Featured.java
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Interface just for something with a name. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
package cstr.util;
|
||||
|
||||
import java.lang.*;
|
||||
|
||||
public interface Featured
|
||||
{
|
||||
public String getFeature(String n);
|
||||
}
|
||||
50
java/common/cstr/util/ImagePainter.java
Normal file
50
java/common/cstr/util/ImagePainter.java
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Something which can paint of course. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
|
||||
public interface ImagePainter extends Painter
|
||||
{
|
||||
public ImageProducer make_image(Rectangle r);
|
||||
}
|
||||
47
java/common/cstr/util/Keyed.java
Normal file
47
java/common/cstr/util/Keyed.java
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Interface just for something with a unique key. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util;
|
||||
|
||||
import java.lang.*;
|
||||
|
||||
public interface Keyed
|
||||
{
|
||||
public Object getKey();
|
||||
}
|
||||
109
java/common/cstr/util/LongHash.java
Normal file
109
java/common/cstr/util/LongHash.java
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Like a Hashtable but for keys of type long. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
|
||||
public final class LongHash
|
||||
{
|
||||
LongBucket [] buckets;
|
||||
|
||||
public LongHash()
|
||||
{
|
||||
this(20);
|
||||
}
|
||||
|
||||
public LongHash(int n)
|
||||
{
|
||||
buckets = new LongBucket[n];
|
||||
}
|
||||
|
||||
private void debugDump()
|
||||
{
|
||||
System.out.println("");
|
||||
for(int i=0; i<buckets.length; i++)
|
||||
{
|
||||
int n=0;
|
||||
for(LongBucket bk=buckets[i]; bk!=null; bk=bk.next)
|
||||
n++;
|
||||
System.out.print("["+n+"]");
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
public void put(long k, Object v)
|
||||
{
|
||||
int b = doHash(k, buckets.length);
|
||||
buckets[b] = new LongBucket(k, v, buckets[b]);
|
||||
// debugDump();
|
||||
}
|
||||
|
||||
public Object get(long k)
|
||||
{
|
||||
int b = doHash(k, buckets.length);
|
||||
|
||||
for(LongBucket bk=buckets[b]; bk!=null; bk=bk.next)
|
||||
if (bk.key==k)
|
||||
return bk.value;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private int doHash(long k, int l)
|
||||
{
|
||||
return (int)((k>>4)%l);
|
||||
}
|
||||
|
||||
private final class LongBucket
|
||||
{
|
||||
long key;
|
||||
Object value;
|
||||
LongBucket next;
|
||||
|
||||
public LongBucket(long k, Object v, LongBucket n)
|
||||
{
|
||||
key=k;
|
||||
value=v;
|
||||
next=n;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
48
java/common/cstr/util/Makefile
Normal file
48
java/common/cstr/util/Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
###########################################################################
|
||||
## ##
|
||||
## Centre for Speech Technology Research ##
|
||||
## University of Edinburgh, UK ##
|
||||
## Copyright (c) 1996 ##
|
||||
## All Rights Reserved. ##
|
||||
## ##
|
||||
## 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. ##
|
||||
## ##
|
||||
## THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. ##
|
||||
## ##
|
||||
###########################################################################
|
||||
|
||||
TOP=../../../..
|
||||
DIRNAME=java/common/cstr/util
|
||||
|
||||
BUILD_DIRS =
|
||||
JAVA_CLASSES = SparseArray LongHash Featured Named Keyed \
|
||||
TraceStream Trace Painter ImagePainter PaintPainter PaintCache \
|
||||
BadValueException EnumValues Enum
|
||||
|
||||
FILES = Makefile $(JAVA_CLASSES:=.java)
|
||||
|
||||
ALL = .java
|
||||
|
||||
-include ../../Makefile.version
|
||||
include $(TOP)/config/common_make_rules
|
||||
47
java/common/cstr/util/Named.java
Normal file
47
java/common/cstr/util/Named.java
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Interface just for something with a name. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
package cstr.util;
|
||||
|
||||
import java.lang.*;
|
||||
|
||||
public interface Named
|
||||
{
|
||||
public String getName();
|
||||
public void setName(String Name);
|
||||
}
|
||||
402
java/common/cstr/util/PaintCache.java
Normal file
402
java/common/cstr/util/PaintCache.java
Normal file
@@ -0,0 +1,402 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// An abstration which stands between a component and the AWT to cache \\
|
||||
// the information painted in an array of images. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class PaintCache
|
||||
{
|
||||
protected Image [] chunks;
|
||||
protected Thread [] threads;
|
||||
protected int chunkSize;
|
||||
protected int numChunks;
|
||||
protected Painter painter;
|
||||
protected Component comp;
|
||||
protected int width;
|
||||
protected int height;
|
||||
protected int running;
|
||||
protected int topPriority;
|
||||
Image dummy;
|
||||
|
||||
public PaintCache(Component c, Painter p)
|
||||
{
|
||||
this(c, p, 400);
|
||||
}
|
||||
|
||||
public PaintCache(Component c, Painter p, int cs)
|
||||
{
|
||||
comp=c;
|
||||
painter=p;
|
||||
chunkSize=cs;
|
||||
chunks=null;
|
||||
running=0;
|
||||
topPriority=Thread.currentThread().getPriority()-1;
|
||||
}
|
||||
|
||||
protected void finalize()
|
||||
{
|
||||
if (threads!=null)
|
||||
for(int i=0; i<threads.length; i++)
|
||||
if (threads[i]!= null)
|
||||
threads[i].stop();
|
||||
}
|
||||
|
||||
public synchronized void updated(int w, int h)
|
||||
{
|
||||
if (w != width || h != height)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
|
||||
if (threads!=null)
|
||||
for(int i=0; i<threads.length; i++)
|
||||
if (threads[i]!= null)
|
||||
threads[i].stop();
|
||||
|
||||
running=0;
|
||||
|
||||
numChunks = w / chunkSize+1;
|
||||
if (numChunks*chunkSize < w)
|
||||
numChunks++;
|
||||
|
||||
chunks = new Image[numChunks+1];
|
||||
threads = new Thread[numChunks+1];
|
||||
|
||||
dummy = comp.createImage(chunkSize, height);
|
||||
Graphics ig = dummy.getGraphics();
|
||||
|
||||
ig.setColor(Color.red);
|
||||
|
||||
ig.drawLine(0,0,chunkSize,height);
|
||||
ig.drawLine(0,height,chunkSize,0);
|
||||
}
|
||||
}
|
||||
|
||||
protected synchronized Image dummyImage()
|
||||
{
|
||||
return dummy;
|
||||
}
|
||||
|
||||
protected synchronized void dumpP()
|
||||
{
|
||||
System.out.print("Threads: ");
|
||||
for(int i=0; i<threads.length; i++)
|
||||
if (threads[i]!= null && threads[i].isAlive())
|
||||
System.out.print(threads[i].getPriority());
|
||||
else
|
||||
System.out.print("_");
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
public synchronized void zap(int i)
|
||||
{
|
||||
if (i<threads.length && threads[i] == Thread.currentThread())
|
||||
{
|
||||
int op=threads[i].getPriority();
|
||||
threads[i]=null;
|
||||
int maxi=-1, max=0;
|
||||
|
||||
for(int ti=0; ti<threads.length; ti++)
|
||||
if (threads[ti]!= null && threads[ti].isAlive())
|
||||
{
|
||||
int p = threads[ti].getPriority();
|
||||
// if (p>Thread.MIN_PRIORITY && p < op)
|
||||
//threads[ti].setPriority(p+1);
|
||||
if (p>max)
|
||||
{
|
||||
max=p;
|
||||
maxi=ti;
|
||||
}
|
||||
}
|
||||
if (maxi>=0)
|
||||
{
|
||||
// System.out.println("top="+maxi+"="+topPriority);
|
||||
threads[maxi].setPriority(topPriority);
|
||||
}
|
||||
|
||||
// dumpP();
|
||||
}
|
||||
}
|
||||
|
||||
protected synchronized void checkChunk(int i, Graphics g)
|
||||
{
|
||||
if (i<chunks.length)
|
||||
{
|
||||
if (chunks[i] == null)
|
||||
{
|
||||
if (painter instanceof ImagePainter)
|
||||
{
|
||||
ImagePainter ipainter = (ImagePainter)painter;
|
||||
|
||||
chunks[i] = dummy;
|
||||
|
||||
Rectangle r = new Rectangle(i*chunkSize, 0,
|
||||
chunkSize, height);
|
||||
|
||||
Thread pt = new Thread(new IPaintingThread(i,
|
||||
ipainter,
|
||||
r,
|
||||
this,
|
||||
g,
|
||||
chunkSize,
|
||||
height));
|
||||
|
||||
|
||||
threads[i]=pt;
|
||||
pt.start();
|
||||
pt.setPriority(Thread.MIN_PRIORITY);
|
||||
}
|
||||
else
|
||||
{
|
||||
PaintPainter ppainter = (PaintPainter)painter;
|
||||
chunks[i] = comp.createImage(chunkSize, height);
|
||||
|
||||
Graphics ig = chunks[i].getGraphics();
|
||||
|
||||
ig.setColor(Color.red);
|
||||
|
||||
ig.drawLine(0,0,chunkSize,height);
|
||||
ig.drawLine(0,height,chunkSize,0);
|
||||
|
||||
ig.setColor(g.getColor());
|
||||
|
||||
Rectangle r = new Rectangle(i*chunkSize, 0, chunkSize, height);
|
||||
|
||||
Thread pt = new Thread(new PaintingThread(i,
|
||||
ppainter,
|
||||
r,
|
||||
ig,
|
||||
this,
|
||||
g,
|
||||
chunkSize,
|
||||
height));
|
||||
|
||||
|
||||
threads[i]=pt;
|
||||
pt.start();
|
||||
pt.setPriority(Thread.MIN_PRIORITY);
|
||||
}
|
||||
}
|
||||
else if (threads[i] != null && threads[i].isAlive())
|
||||
{
|
||||
for(int ti=0; ti<threads.length; ti++)
|
||||
{
|
||||
Thread t = threads[ti];
|
||||
if (t != null && t.isAlive())
|
||||
{
|
||||
int p;
|
||||
if (i!=ti)
|
||||
{
|
||||
int op = t.getPriority();
|
||||
if (op> Thread.MIN_PRIORITY)
|
||||
// p= topPriority-1;
|
||||
p= Thread.MIN_PRIORITY+1;
|
||||
else
|
||||
p =Thread.MIN_PRIORITY;
|
||||
}
|
||||
else
|
||||
p = topPriority;
|
||||
// p = Thread.MAX_PRIORITY;
|
||||
|
||||
if (p>=Thread.MIN_PRIORITY)
|
||||
t.setPriority(p);
|
||||
}
|
||||
}
|
||||
// dumpP();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
Rectangle r = g.getClipBounds();
|
||||
|
||||
int c1 = r.x / chunkSize;
|
||||
int cn = (r.x+r.width) / chunkSize;
|
||||
|
||||
if (cn >= chunks.length)
|
||||
cn = chunks.length-1;
|
||||
|
||||
if ( c1 == cn)
|
||||
{
|
||||
checkChunk(c1, g);
|
||||
int ix = r.x % chunkSize;
|
||||
g.drawImage(chunks[c1],
|
||||
r.x, r.y, r.x+r.width, r.y+r.height,
|
||||
ix, r.y, ix+r.width, r.y+r.height,
|
||||
comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
int ix = r.x % chunkSize;
|
||||
int wx = r.x;
|
||||
int w = chunkSize - ix;
|
||||
checkChunk(c1, g);
|
||||
g.drawImage(chunks[c1],
|
||||
wx, r.y, wx+w, r.y+r.height,
|
||||
ix, r.y, ix+w, r.y+r.height,
|
||||
comp);
|
||||
|
||||
for(int c = c1+1; c < cn; c++)
|
||||
{
|
||||
ix = 0;
|
||||
wx = c * chunkSize;
|
||||
w = chunkSize;
|
||||
|
||||
checkChunk(c, g);
|
||||
g.drawImage(chunks[c],
|
||||
wx, r.y, wx+w, r.y+r.height,
|
||||
ix, r.y, ix+w, r.y+r.height,
|
||||
comp);
|
||||
}
|
||||
|
||||
ix = 0;
|
||||
wx = cn * chunkSize;
|
||||
w = (r.x + r.width) % chunkSize;
|
||||
|
||||
checkChunk(cn, g);
|
||||
g.drawImage(chunks[cn],
|
||||
wx, r.y, wx+w, r.y+r.height,
|
||||
ix, r.y, ix+w, r.y+r.height,
|
||||
comp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected synchronized void blit(Graphics g, int i)
|
||||
{
|
||||
g.setClip(0,0, width, height);
|
||||
if (i<chunks.length)
|
||||
g.drawImage(chunks[i],
|
||||
i*chunkSize, 0,
|
||||
Color.green,
|
||||
null);
|
||||
}
|
||||
|
||||
class PaintingThread implements Runnable
|
||||
{
|
||||
int index;
|
||||
PaintPainter painter;
|
||||
Rectangle rect;
|
||||
Graphics ig;
|
||||
PaintCache parent;
|
||||
Graphics g;
|
||||
int w,h;
|
||||
|
||||
public PaintingThread(int i,
|
||||
PaintPainter i_painter,
|
||||
Rectangle i_rect,
|
||||
Graphics i_ig,
|
||||
PaintCache i_parent,
|
||||
Graphics i_g,
|
||||
int i_w,
|
||||
int i_h)
|
||||
{
|
||||
index=i;
|
||||
painter=i_painter;
|
||||
rect=i_rect;
|
||||
ig=i_ig.create();
|
||||
parent=i_parent;
|
||||
g=i_g.create();
|
||||
w=i_w;
|
||||
h=i_h;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
// System.out.println("start "+rect.x);
|
||||
painter.real_paint(ig, rect);
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
parent.zap(index);
|
||||
parent.blit(g, index);
|
||||
// System.out.println("end "+rect.x);
|
||||
}
|
||||
}
|
||||
|
||||
class IPaintingThread implements Runnable
|
||||
{
|
||||
int index;
|
||||
ImagePainter painter;
|
||||
Rectangle rect;
|
||||
PaintCache parent;
|
||||
Graphics g;
|
||||
int w,h;
|
||||
|
||||
public IPaintingThread(int i,
|
||||
ImagePainter i_painter,
|
||||
Rectangle i_rect,
|
||||
PaintCache i_parent,
|
||||
Graphics i_g,
|
||||
int i_w,
|
||||
int i_h)
|
||||
{
|
||||
index=i;
|
||||
painter=i_painter;
|
||||
rect=i_rect;
|
||||
parent=i_parent;
|
||||
g=i_g.create();
|
||||
w=i_w;
|
||||
h=i_h;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
ImageProducer src = painter.make_image(rect);
|
||||
|
||||
if (src==null)
|
||||
chunks[index] = parent.dummyImage();
|
||||
else
|
||||
chunks[index] = comp.createImage(src);
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
parent.zap(index);
|
||||
parent.blit(g, index);
|
||||
// System.out.println("end "+rect.x);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
50
java/common/cstr/util/PaintPainter.java
Normal file
50
java/common/cstr/util/PaintPainter.java
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Something which can paint of course. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
|
||||
public interface PaintPainter extends Painter
|
||||
{
|
||||
public void real_paint(Graphics g, Rectangle r);
|
||||
}
|
||||
49
java/common/cstr/util/Painter.java
Normal file
49
java/common/cstr/util/Painter.java
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Something which can paint of course. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
public interface Painter
|
||||
{
|
||||
public void paint(Graphics g);
|
||||
}
|
||||
103
java/common/cstr/util/SparseArray.java
Normal file
103
java/common/cstr/util/SparseArray.java
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// Date: Tue Feb 17 1998 \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// An array with only a few entries. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class SparseArray
|
||||
{
|
||||
int [] keys;
|
||||
Object [] vals;
|
||||
int used;
|
||||
int size;
|
||||
|
||||
public SparseArray(int initn)
|
||||
{
|
||||
used=0;
|
||||
size = initn;
|
||||
keys = new int[size];
|
||||
vals = new Object[size];
|
||||
}
|
||||
|
||||
public SparseArray()
|
||||
{
|
||||
this(10);
|
||||
}
|
||||
|
||||
public void put(int n, Object v)
|
||||
{
|
||||
for(int i=0; i<used; i++)
|
||||
if (keys[i] == n)
|
||||
{
|
||||
vals[i] = v;
|
||||
return;
|
||||
}
|
||||
|
||||
if (used == size)
|
||||
{
|
||||
size+=10;
|
||||
int [] newk = new int[size];
|
||||
Object [] newv = new Object[size];
|
||||
|
||||
for(int j=0; j<used; j++)
|
||||
{
|
||||
newk[j] = keys[j];
|
||||
newv[j] = vals[j];
|
||||
}
|
||||
|
||||
keys=newk;
|
||||
vals=newv;
|
||||
}
|
||||
keys[used] = n;
|
||||
vals[used] = v;
|
||||
used++;
|
||||
}
|
||||
|
||||
public Object get(int n)
|
||||
{
|
||||
for(int i=0; i<used; i++)
|
||||
if (keys[i] == n)
|
||||
return vals[i];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
163
java/common/cstr/util/Trace.java
Normal file
163
java/common/cstr/util/Trace.java
Normal file
@@ -0,0 +1,163 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// Simple Trace package. Multiple tracing streams which can be turned \\
|
||||
// on and off. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
public final class Trace
|
||||
{
|
||||
protected static Hashtable streams= new Hashtable(5);
|
||||
protected static boolean enabled=false;
|
||||
protected static TraceStream def_st;
|
||||
|
||||
static {
|
||||
init("Trace");
|
||||
def_st=(TraceStream)streams.get("Trace");
|
||||
def_st.setOn(true);
|
||||
}
|
||||
|
||||
public static void init(String which)
|
||||
{
|
||||
StringTokenizer tok = new StringTokenizer(which, ",");
|
||||
while (tok.hasMoreElements())
|
||||
{
|
||||
String name=tok.nextToken();
|
||||
streams.put(name, new TraceStream(name, false, false));
|
||||
}
|
||||
}
|
||||
|
||||
public static void setEnable(boolean e)
|
||||
{
|
||||
enabled=e;
|
||||
}
|
||||
|
||||
public static void setOn(String which, boolean o)
|
||||
{
|
||||
TraceStream st=(TraceStream)streams.get(which);
|
||||
if (st!=null)
|
||||
{
|
||||
st.setOn(o);
|
||||
if (o)
|
||||
enabled=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pl("Unknown Trace Stream "+which);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setOn(boolean o)
|
||||
{
|
||||
def_st.setOn(o);
|
||||
if (o)
|
||||
enabled=true;
|
||||
}
|
||||
|
||||
public static void setSave(String which, boolean s)
|
||||
{
|
||||
TraceStream st=(TraceStream)streams.get(which);
|
||||
if (st!=null)
|
||||
st.setSave(s);
|
||||
else
|
||||
{
|
||||
p("Unknown Trace Stream "+which);
|
||||
nl();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSave(boolean s)
|
||||
{
|
||||
def_st.setSave(s);
|
||||
}
|
||||
|
||||
public static void p(String which, String what)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
TraceStream st=(TraceStream)streams.get(which);
|
||||
if (st==null)
|
||||
st = def_st;
|
||||
st.p(what);
|
||||
}
|
||||
}
|
||||
|
||||
public static void pl(String which, String what)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
TraceStream st=(TraceStream)streams.get(which);
|
||||
if (st==null)
|
||||
st = def_st;
|
||||
st.pl(what);
|
||||
}
|
||||
}
|
||||
|
||||
public static void nl(String which)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
TraceStream st=(TraceStream)streams.get(which);
|
||||
if (st==null)
|
||||
st = def_st;
|
||||
st.nl();
|
||||
}
|
||||
}
|
||||
|
||||
public static void p(String what)
|
||||
{
|
||||
def_st.print(what);
|
||||
}
|
||||
|
||||
public static void pl(String what)
|
||||
{
|
||||
def_st.pl(what);
|
||||
}
|
||||
|
||||
public static void nl()
|
||||
{
|
||||
def_st.nl();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
130
java/common/cstr/util/TraceStream.java
Normal file
130
java/common/cstr/util/TraceStream.java
Normal file
@@ -0,0 +1,130 @@
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Centre for Speech Technology Research \\
|
||||
// University of Edinburgh, UK \\
|
||||
// Copyright (c) 1996,1997 \\
|
||||
// All Rights Reserved. \\
|
||||
// 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. \\
|
||||
// THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
// \\
|
||||
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
|
||||
// -------------------------------------------------------------------- \\
|
||||
// A single stream of trace output. \\
|
||||
// \\
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
|
||||
|
||||
package cstr.util ;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
|
||||
// Record for a single stream
|
||||
|
||||
public final class TraceStream
|
||||
{
|
||||
protected String name;
|
||||
protected boolean off;
|
||||
protected boolean bol;
|
||||
protected Vector saved;
|
||||
|
||||
public TraceStream(String n)
|
||||
{
|
||||
this(n, false, false);
|
||||
}
|
||||
|
||||
public TraceStream(String n, boolean o, boolean s)
|
||||
{
|
||||
name=n;
|
||||
setOn(o);
|
||||
setSave(s);
|
||||
bol=true;
|
||||
Trace.streams.put(name, this);
|
||||
}
|
||||
|
||||
public void setOn(boolean o)
|
||||
{
|
||||
off=!o;
|
||||
}
|
||||
|
||||
public void setSave(boolean s)
|
||||
{
|
||||
if (s && saved==null)
|
||||
saved=new Vector(5);
|
||||
|
||||
if (!s && saved != null)
|
||||
{
|
||||
Vector pending=saved;
|
||||
saved=null;
|
||||
for(int i=0; i<pending.size(); i++)
|
||||
print((String)pending.elementAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void print(String s)
|
||||
{
|
||||
if (off) return;
|
||||
|
||||
if (bol)
|
||||
{
|
||||
bol=false;
|
||||
print(name);
|
||||
print(": ");
|
||||
}
|
||||
|
||||
if (saved!=null)
|
||||
saved.addElement(s);
|
||||
else
|
||||
{
|
||||
System.out.print(s);
|
||||
if (s.endsWith("\n"))
|
||||
bol=true;
|
||||
}
|
||||
}
|
||||
|
||||
public void nl()
|
||||
{
|
||||
if (Trace.enabled)
|
||||
print("\n");
|
||||
}
|
||||
|
||||
public void p(String what)
|
||||
{
|
||||
if (Trace.enabled)
|
||||
print(what);
|
||||
}
|
||||
|
||||
public void pl(String what)
|
||||
{
|
||||
if (Trace.enabled)
|
||||
{
|
||||
print(what);
|
||||
nl();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user