Savant and QuillDriver are being removed from THDL Tools

and moved to a new site: Tools for Field Linguistics.
This commit is contained in:
eg3p 2003-03-13 20:00:51 +00:00
parent 6cc0c5e99b
commit c280d0fc96
28 changed files with 0 additions and 4676 deletions

View file

@ -1 +0,0 @@
*~

View file

@ -1,27 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
// testing testing
package org.thdl.savant;
public interface AnnotationPlayer extends java.util.EventListener
{
public void startAnnotation(String id);
public void stopAnnotation(String id);
}

View file

@ -1,230 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Field;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import javax.swing.JFrame;
import org.thdl.util.ThdlLazyException;
/**
* @author David Chandler
*
* This class provides functionality that is not present in Java's JDK
* 1.2. Because we want to compile and run on a Java 2/1.2 system, we
* must use the Java Reflection API to provide functionality specific
* to Java 2/1.3 or later. At present, I haven't tested on a 1.2 box,
* but I have tested on a 1.3.1_04 box.
*
* If your code will break if some functionality here is not present,
* test the return value of the function and throw an exception.
* Avoid such code like the plague.
*
* This code is all written for one-shot operations thus-far. If you
* plan on executing a piece of code many times, you need to set up
* the reflection mechanism first, and then re-use it again and again.
* This is a two-step process. Three steps if you explicitly
* deconstruct the mechanism.
*
* This class is not instantiable. */
public final class JdkVersionHacks {
/** Don't instantiate this class. */
private JdkVersionHacks() { }
/** Calls f.setUndecorated(true) if possible. Returns true if
successful. */
public static boolean undecorateJFrame(JFrame f) {
/* If we're using JDK 1.4, execute
f.setUndecorated(true). Otherwise, don't. */
boolean success = false;
Method setUndecoratedMethod = null;
try {
setUndecoratedMethod
= JFrame.class.getMethod("setUndecorated",
new Class[] {
Boolean.TYPE
});
} catch (NoSuchMethodException ex) {
/* We're not using JDK 1.4 or later. */
} catch (SecurityException ex) {
/* We'll never know if we're using JDK 1.4 or later. */
handleSecurityException(ex);
return false;
}
if (setUndecoratedMethod != null) {
try {
setUndecoratedMethod.invoke(f, new Object[] { Boolean.TRUE });
success = true;
/* We shouldn't get any of these exceptions: */
} catch (IllegalAccessException ex) {
throw new ThdlLazyException(ex);
} catch (IllegalArgumentException ex) {
throw new ThdlLazyException(ex);
} catch (InvocationTargetException ex) {
throw new ThdlLazyException(ex);
}
}
return success;
}
/** Calls f.setExtendedState(Frame.MAXIMIZED_BOTH) if possible.
Returns true if successful. */
public static boolean maximizeJFrameInBothDirections(JFrame f) {
/* If we're using JDK 1.4, execute
f.setExtendedState(Frame.MAXIMIZED_BOTH). Otherwise,
don't. */
boolean success = false;
Method setExtendedStateMethod = null;
try {
setExtendedStateMethod
= JFrame.class.getMethod("setExtendedState",
new Class[] {
Integer.TYPE
});
} catch (NoSuchMethodException ex) {
/* We're not using JDK 1.4 or later. */
return false;
} catch (SecurityException ex) {
/* We'll never know if we're using JDK 1.4 or later. */
handleSecurityException(ex);
return false;
}
try {
setExtendedStateMethod.invoke(f,
new Object[] {
maximizedBothOption()
});
success = true;
} catch (NoSuchFieldException ex) {
/* We're not using JDK 1.4 or later. */
return false;
/* We shouldn't get any of these exceptions: */
} catch (IllegalAccessException ex) {
throw new ThdlLazyException(ex);
} catch (IllegalArgumentException ex) {
throw new ThdlLazyException(ex);
} catch (InvocationTargetException ex) {
throw new ThdlLazyException(ex);
}
return success;
}
/** Returns true iff maximizeJFrameInBothDirections(f) will
actually have an effect. */
public static boolean maximizedBothSupported(Toolkit tk) {
// Execute
// f.getToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)
// if possible.
Method isFSSMethod = null;
try {
isFSSMethod
= JFrame.class.getMethod("isFrameStateSupported",
new Class[] {
Integer.TYPE
});
} catch (NoSuchMethodException ex) {
/* We're not using JDK 1.4 or later. */
return false;
} catch (SecurityException ex) {
/* We'll never know if we're using JDK 1.4 or later. */
handleSecurityException(ex);
return false;
}
try {
return ((Boolean)isFSSMethod.invoke(tk,
new Object[] {
maximizedBothOption()
})).booleanValue();
} catch (NoSuchFieldException ex) {
/* We're not using JDK 1.4 or later. */
return false;
/* We shouldn't get any of these exceptions: */
} catch (IllegalAccessException ex) {
throw new ThdlLazyException(ex);
} catch (IllegalArgumentException ex) {
throw new ThdlLazyException(ex);
} catch (InvocationTargetException ex) {
throw new ThdlLazyException(ex);
}
}
/** Coming soon: Does what the user desires (via the options he or
she has set) with this SecurityException, one encountered
during the process of reflection.
Currently: does nothing.
FIXME */
private static void handleSecurityException(SecurityException ex)
throws SecurityException
{
if (false /* FIXME: I want this exception when debugging: THDLUtils.getBooleanOption("EagerlyThrowExceptions") */)
throw ex;
}
/** Returns the value of Frame.MAXIMIZED_BOTH, wrapped in an
Integer.
@throws NoSuchFieldException the field does not exist or
cannot be accessed because security settings are too limiting */
private static Object maximizedBothOption()
throws NoSuchFieldException
{
Field maxBothOptionField = null;
try {
maxBothOptionField = Frame.class.getField("MAXIMIZED_BOTH");
/* Don't catch NoSuchFieldException */
} catch (SecurityException ex) {
/* We'll never know if we're using JDK 1.4 or later. */
handleSecurityException(ex);
throw new NoSuchFieldException("java.awt.Frame.MAXIMIZED_BOTH");
}
try {
return maxBothOptionField.get(null);
} catch (IllegalAccessException ex) {
throw new ThdlLazyException(ex);
} catch (IllegalArgumentException ex) {
throw new ThdlLazyException(ex);
} catch (NullPointerException ex) {
throw new ThdlLazyException(ex);
} catch (ExceptionInInitializerError ex) {
throw new ThdlLazyException(ex);
}
}
};

View file

@ -1,388 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant;
import java.awt.Font;
import java.awt.Label;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Cursor;
import java.awt.Window;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Iterator;
import java.util.List;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Timer;
import java.util.TimerTask;
import java.util.ResourceBundle;
import java.io.CharArrayWriter;
import java.io.CharArrayReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.rtf.RTFEditorKit;
import org.thdl.media.*;
import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlActionListener;
import org.thdl.util.ThdlI18n;
public class Savant extends JDesktopPane
{
protected SmartMoviePanel sp = null;
protected TwoWayTextPlayer tp = null;
protected JInternalFrame videoFrame = null;
protected JInternalFrame textFrame = null;
protected JInternalFrame vocabFrame = null;
protected JFrame fullScreen = null;
protected boolean isFullScreen = false;
protected Dimension fullScreenSize = null;
protected JPanel textPanel = null;
protected JScrollPane vocabPanel = null;
protected URL mediaURL = null;
protected URL extras = null;
protected TranscriptView[] transcriptViews;
protected int orientation = 0;
protected ResourceBundle messages;
public final int TOP_TO_BOTTOM = 1;
public final int LEFT_TO_RIGHT = 2;
public Savant()
{
messages = ThdlI18n.getResourceBundle();
setBackground(new JFrame().getBackground());
setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
//(String title, boolean resizable, boolean closable, boolean maximizable, boolean iconifiable)
videoFrame = new JInternalFrame(null, false, false, false, false);
videoFrame.setVisible(true);
videoFrame.setLocation(0,0);
videoFrame.setSize(0,0);
add(videoFrame, JLayeredPane.POPUP_LAYER);
invalidate();
validate();
repaint();
textFrame = new JInternalFrame(messages.getString("Transcript"), false, false, false, true);
textPanel = new JPanel(new BorderLayout());
textFrame.setVisible(true);
textFrame.setLocation(0,0);
textFrame.setSize(0,0);
textFrame.setContentPane(textPanel);
add(textFrame, JLayeredPane.DEFAULT_LAYER);
invalidate();
validate();
repaint();
addComponentListener(new ComponentAdapter()
{
public void componentResized(ComponentEvent ce)
{
switch (orientation) {
case TOP_TO_BOTTOM:
videoFrame.setLocation(getSize().width/2 - videoFrame.getSize().width/2, 0);
textFrame.setLocation(0, videoFrame.getSize().height);
textFrame.setSize(getSize().width, getSize().height - videoFrame.getSize().height);
break;
case LEFT_TO_RIGHT:
videoFrame.setLocation(0,0);
textFrame.setLocation(videoFrame.getSize().width, 0);
textFrame.setSize(getSize().width - videoFrame.getSize().width, getSize().height);
break;
default:
break;
}
}
});
}
public void close()
{
if (sp != null) {
try {
sp.destroy();
} catch (SmartMoviePanelException smpe) {
smpe.printStackTrace();
}
}
}
public void open(TranscriptView[] views, String video, String vocabulary)
{
try {
if (vocabulary == null)
open(views, new URL(video), null);
else
open(views, new URL(video), new URL(vocabulary));
} catch (MalformedURLException murle) {
murle.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public void setMediaPlayer(SmartMoviePanel smp) {
if (sp == smp)
return;
if (sp != null) {
try {
sp.destroy();
videoFrame.getContentPane().removeAll();
} catch (SmartMoviePanelException smpe) {
smpe.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
sp = smp;
sp.setParentContainer(Savant.this);
if (mediaURL != null) {
String t1s = convertTimesForSmartMoviePanel(transcriptViews[0].getT1s());
String t2s = convertTimesForSmartMoviePanel(transcriptViews[0].getT2s());
sp.initForSavant(t1s, t2s, transcriptViews[0].getIDs());
sp.addAnnotationPlayer(tp);
try {
sp.loadMovie(mediaURL);
startTimer();
} catch (SmartMoviePanelException smpe) {
smpe.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
}
private void startTimer() {
final java.util.Timer timer = new java.util.Timer(true);
timer.schedule(new TimerTask() {
public void run()
{
if (sp.isInitialized())
{
System.out.println("initialized");
timer.cancel();
videoFrame.getContentPane().add(sp);
videoFrame.pack();
videoFrame.setMaximumSize(videoFrame.getSize());
if (videoFrame.getSize().height < 100) //must be audio file, so frame top to bottom
{
orientation = TOP_TO_BOTTOM;
videoFrame.setTitle(messages.getString("Audio"));
videoFrame.setLocation(getSize().width/2 - videoFrame.getSize().width/2, 0);
textFrame.setLocation(0, videoFrame.getSize().height);
textFrame.setSize(getSize().width, getSize().height - videoFrame.getSize().height);
} else { //must be video file, so frame left to right
orientation = LEFT_TO_RIGHT;
videoFrame.setTitle(messages.getString("Video"));
videoFrame.setLocation(0,0);
textFrame.setLocation(videoFrame.getSize().width, 0);
textFrame.setSize(getSize().width - videoFrame.getSize().width, getSize().height);
}
invalidate();
validate();
repaint();
Window rootWindow = (Window)SwingUtilities.getAncestorOfClass(Window.class, Savant.this);
rootWindow.setCursor(null);
}
}}, 0, 50);
}
public SmartMoviePanel getMediaPlayer() {
return sp;
}
private String convertTimesForSmartMoviePanel(String s) {
StringBuffer sBuff = new StringBuffer();
StringTokenizer sTok = new StringTokenizer(s, ",");
while (sTok.hasMoreTokens()) {
sBuff.append(String.valueOf(new Float(Float.parseFloat(sTok.nextToken()) * 1000).intValue()));
sBuff.append(',');
}
return sBuff.toString();
}
public void open(TranscriptView[] views, URL video, final URL vocabulary)
{
/* FIXME eventually
w/Savant and SoundPanel times were in seconds. QuillDriver's
SmartMoviePanel uses milliseconds instead, so here I convert
(for the time being anyway - eventually we need the same
time code format for both QD and Savant. */
String t1s = convertTimesForSmartMoviePanel(views[0].getT1s());
String t2s = convertTimesForSmartMoviePanel(views[0].getT2s());
if (sp == null) {
JOptionPane.showConfirmDialog(Savant.this, messages.getString("SupportedMediaError"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
return;
}
sp.initForSavant(t1s, t2s, views[0].getIDs());
tp = new TwoWayTextPlayer(sp, views[0], Color.cyan);
transcriptViews = views;
JPanel jp = new JPanel();
String[] viewNames = new String[views.length];
for (int i=0; i<views.length; i++)
viewNames[i] = new String(views[i].getTitle());
JComboBox viewOptions = new JComboBox(viewNames);
viewOptions.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e)
{
JComboBox jcb = (JComboBox)e.getSource();
setTranscriptView(transcriptViews[jcb.getSelectedIndex()]);
}
});
jp.add(viewOptions);
textPanel.add("Center", tp);
textPanel.add("North", jp);
sp.addAnnotationPlayer(tp);
try {
sp.loadMovie(video);
mediaURL = video;
startTimer();
} catch (SmartMoviePanelException smpe) {
smpe.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public void setTranscriptView(TranscriptView view)
{
textPanel.invalidate();
textPanel.remove(tp);
tp.reset();
tp = new TwoWayTextPlayer(sp, view, Color.cyan);
sp.addAnnotationPlayer(tp);
if (sp.isPlaying())
sp.launchAnnotationTimer();
textPanel.add("Center", tp);
textPanel.validate();
textPanel.repaint();
}
}
/*
if (sp.getVisualComponent() != null)
{ //video, so can be full screen
sp.getVisualComponent().addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
java.awt.Component visual = null;
if (fullScreen == null)
{
fullScreen = new JFrame();
We don't do anything special if this fails:
JdkVersionHacks.undecorateJFrame(fullScreen);
fullScreen.getContentPane().setBackground(Color.black);
Dimension screenSize = fullScreen.getToolkit().getScreenSize();
Dimension videoSize = sp.getVisualComponent().getPreferredSize();
// Dimension controlSize = sp.getControlComponent().getPreferredSize();
int videoWidth = videoSize.width;
int videoHeight = videoSize.height;
float vWidth = new Integer(videoWidth).floatValue();
float vHeight = new Integer(videoHeight).floatValue();
float xFactor = vHeight / vWidth;
int fullVideoWidth = screenSize.width;
float product = fullVideoWidth * xFactor;
int fullVideoHeight = new Float(product).intValue();
fullScreenSize = new Dimension(fullVideoWidth, fullVideoHeight);
fullScreen.getContentPane().setLayout(null);
}
if (isFullScreen)
{
fullScreen.dispose();
invalidate();
validate();
repaint();
fullScreen.getContentPane().removeAll();
sp.restoreVisualComponent();
invalidate();
validate();
repaint();
isFullScreen = false;
} else {
visual = sp.popVisualComponent();
fullScreen.show();
FIXME: In SavantShell, we test
to see if MAXIMIZE_BOTH is
supported, but we don't
here.
Ignore failure:
JdkVersionHacks.maximizeJFrameInBothDirections(fullScreen);
fullScreen.getContentPane().add(visual);
visual.setLocation(0, (fullScreen.getSize().height - fullScreenSize.height)/2);
visual.setSize(fullScreenSize);
fullScreen.getContentPane().invalidate();
fullScreen.getContentPane().validate();
fullScreen.getContentPane().repaint();
isFullScreen = true;
}
}
});
}
*/

View file

@ -1,113 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.filechooser.*;
import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlOptions;
/**
* The SavantFileView "sees through" a <code>*.savant</code> file and
* returns the title associated with it. A <code>*.savant</code> file
* is a properties file like the following:
* <pre>
* #Tue May 14 16:07:15 EDT 2002
* TRANSCRIPT=MST4.xml
* PROJECT=THDL
* MEDIA=MST4.mpg
* TITLE=MST Chapter 4 (video)
* </pre>
* @author Edward Garrett */
public class SavantFileView extends FileView {
/** When opening a file, this is the only extension Savant cares
about. This is case-insensitive. */
public final static String getDotSavant() {
return ThdlOptions.getStringOption("thdl.savant.file.extension",
".savant");
}
/** This loads <code>*.savant</code> files as properties files and
returns an associated TITLE attribute. For any other type of
file, or for a properties file that does not specify a
non-empty-string TITLE attribute, this returns null. */
public String getName(File f) {
if (f.isDirectory())
return null;
/* Unless a developer has chosen to do otherwise, examine only
*.savant files. If you don't do this, you waste a lot of
time, making any file chooser that uses this class
unresponsive. In addition, you'll cause the floppy drive
to spin up every time you refresh or cd in the file
chooser. */
if (!ThdlOptions.getBooleanOption("thdl.treat.all.files.as.dot.savant.files.regardless.of.extension")) { /* FIXME */
if (!f.getName().toLowerCase().endsWith(getDotSavant()))
return null;
}
Properties p = new Properties();
try {
p.load(new FileInputStream(f));
String ttl = p.getProperty("TITLE");
if (ttl.equals(""))
return null; /* We never want the user to see nothing
at all, so let the L&F file view
handle this. */
else
return ttl;
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (IOException ioe) {
ioe.printStackTrace();
ThdlDebug.noteIffyCode();
}
return null;
}
/** Returns null always, which lets the default look-and-feel's
* FileView take over.
* @return null */
public String getDescription(File f) {
return null; // let the L&F FileView figure this out
}
/** Returns null always, which lets the default look-and-feel's
* FileView take over.
* @return null */
public Boolean isTraversable(File f) {
return null; // let the L&F FileView figure this out
}
/** Returns null always, which lets the default look-and-feel's
* FileView take over.
* @return null */
public String getTypeDescription(File f) {
return null; // let the L&F FileView figure this out
}
/* FIXME: why not same as above? */
/*
public Icon getIcon(File f) {
}
*/
}

View file

@ -1,390 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant;
import java.io.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.text.rtf.*;
import org.thdl.savant.ucuchi.*;
import org.thdl.savant.tib.*;
import org.thdl.media.*;
import org.thdl.util.TeeStream;
import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlActionListener;
import org.thdl.util.RTFPane;
import org.thdl.util.SimpleFrame;
import org.thdl.util.ThdlI18n;
import org.thdl.util.ThdlOptions;
public class SavantShell extends JFrame
{
private static int numberOfSavantsOpen = 0;
private static JScrollPane helpPane = null;
private static JScrollPane aboutPane = null;
private static String mediaPath = null;
private static JFileChooser fileChooser;
private Savant savant = null;
static Locale locale = null;
ResourceBundle messages = null;
public static void main(String[] args) {
try {
ThdlDebug.attemptToSetUpLogFile("savant", ".log");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) { ThdlDebug.noteIffyCode(); }
try {
helpPane = new RTFPane(SavantShell.class, "savanthelp.rtf");
aboutPane = new RTFPane(SavantShell.class, "aboutsavant.rtf");
} catch (FileNotFoundException e) {
System.out.println("Can't find " + e.getMessage() + ".");
System.exit(1);
} catch (IOException e) {
System.out.println("Can't find one of savanthelp.rtf or aboutsavant.rtf.");
System.exit(1);
} catch (BadLocationException e) {
System.out.println("Error reading one of savanthelp.rtf or aboutsavant.rtf.");
System.exit(1);
} catch (Exception e) {
/* Carry on. A security exception, probably. */
ThdlDebug.noteIffyCode();
}
if (args.length == 2) {
locale = new Locale(new String(args[0]), new String(args[1]));
ThdlI18n.setLocale(locale);
}
initFileChooser();
SavantShell ssh = new SavantShell();
ssh.setVisible(true);
} catch (NoClassDefFoundError err) {
ThdlDebug.handleClasspathError("Savant's CLASSPATH", err);
}
}
public static void initFileChooser() {
fileChooser = new JFileChooser();
fileChooser.setFileView(new SavantFileView());
fileChooser.addChoosableFileFilter(new FileFilter() {
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
return f.getName().toLowerCase().endsWith(SavantFileView.getDotSavant());
}
//the description of this filter
public String getDescription() {
return "Savant data (.savant)";
}
});
}
/** Closes one open title, if there is one open. Returns true if
one was closed, or false if no titles are open. */
private boolean closeOneSavantTitle() {
if (savant != null) {
ThdlDebug.verify("There should be one or more Savant titles open: ",
numberOfSavantsOpen >= 1);
if (numberOfSavantsOpen < 2) {
savant.close();
savant = null;
getContentPane().removeAll();
setTitle("Savant");
invalidate();
validate();
repaint();
} else {
savant.close();
dispose();
}
numberOfSavantsOpen--;
return true;
} else {
ThdlDebug.verify("There should be zero Savant titles open: ",
numberOfSavantsOpen == 0);
return false;
}
}
public SavantShell()
{
setTitle("Savant");
messages = ThdlI18n.getResourceBundle();
savant = new Savant();
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu(messages.getString("File"));
JMenuItem openItem = new JMenuItem(messages.getString("Open"));
openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,java.awt.Event.CTRL_MASK));
openItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
if (fileChooser.showOpenDialog(SavantShell.this) != JFileChooser.APPROVE_OPTION)
return;
Properties p = new Properties();
try {
File fileChosen = fileChooser.getSelectedFile();
p.load(new FileInputStream(fileChosen));
String path = "file:" + fileChosen.getParent() + File.separatorChar;
newSavantWindow(p.getProperty("PROJECT"), p.getProperty("TITLE"), new URL(path + p.getProperty("TRANSCRIPT")), new URL(path + p.getProperty("MEDIA")), null);
} catch (MalformedURLException murle) {
murle.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (IOException ioe) {
ioe.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
});
JMenuItem closeItem = new JMenuItem(messages.getString("Close"));
closeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,java.awt.Event.CTRL_MASK));
closeItem.addActionListener(new ThdlActionListener()
{
public void theRealActionPerformed(ActionEvent e)
{
// Return value doesn't matter:
closeOneSavantTitle();
}
});
JMenuItem quitItem = new JMenuItem(messages.getString("Quit"));
quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,java.awt.Event.CTRL_MASK));
quitItem.addActionListener(new ThdlActionListener()
{
public void theRealActionPerformed(ActionEvent e)
{
// Close all Savant titles:
while (closeOneSavantTitle())
;
// Exit normally:
System.exit(0);
}
});
/* Hey developers: To test ThdlActionListener, use this:
JMenuItem errorThrowerItem = new JMenuItem("ErrorThrower");
errorThrowerItem.addActionListener(new ThdlActionListener()
{
public void theRealActionPerformed(ActionEvent e)
{
throw new Error("Testing ThdlActionListener");
}
});
fileMenu.add(errorThrowerItem);
*/
fileMenu.add(openItem);
fileMenu.add(closeItem);
fileMenu.addSeparator();
fileMenu.add(quitItem);
JMenu mediaPlayerMenu = new JMenu(messages.getString("MediaPlayer"));
java.util.List moviePlayers = SmartPlayerFactory.getAllAvailableSmartPlayers();
for (int i=0; i<moviePlayers.size(); i++) {
final SmartMoviePanel mPlayer = (SmartMoviePanel)moviePlayers.get(i);
JMenuItem mItem = new JMenuItem(mPlayer.getIdentifyingName());
mItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
savant.setMediaPlayer(mPlayer);
}
});
mediaPlayerMenu.add(mItem);
}
JMenu preferencesMenu = new JMenu(messages.getString("Preferences"));
if (moviePlayers.size() > 0) {
SmartMoviePanel defaultPlayer = (SmartMoviePanel)moviePlayers.get(0);
savant.setMediaPlayer(defaultPlayer); //set savant media player to default
if (moviePlayers.size() > 1)
preferencesMenu.add(mediaPlayerMenu);
}
JMenu infoMenu = new JMenu(messages.getString("InfoShort"));
JMenuItem helpItem = new JMenuItem(messages.getString("Help"));
helpItem.addActionListener(new ThdlActionListener()
{
public void theRealActionPerformed(ActionEvent e)
{
new SimpleFrame(messages.getString("Help"), helpPane);
}
});
JMenuItem aboutItem = new JMenuItem(messages.getString("About"));
aboutItem.addActionListener(new ThdlActionListener()
{
public void theRealActionPerformed(ActionEvent e)
{
new SimpleFrame(messages.getString("About"), aboutPane);
}
});
infoMenu.add(helpItem);
infoMenu.add(aboutItem);
//make heavyweight to mix better with jmf video player
fileMenu.getPopupMenu().setLightWeightPopupEnabled(false);
infoMenu.getPopupMenu().setLightWeightPopupEnabled(false);
menuBar.add(fileMenu);
menuBar.add(preferencesMenu);
menuBar.add(infoMenu);
setJMenuBar(menuBar);
addWindowListener(new WindowAdapter () {
public void windowClosing (WindowEvent e) {
if (numberOfSavantsOpen < 2)
System.exit(0);
if (savant != null)
savant.close();
numberOfSavantsOpen--;
}
});
// Code for Merlin
if (JdkVersionHacks.maximizedBothSupported(getToolkit())) {
setLocation(0,0);
setSize(getToolkit().getScreenSize().width,getToolkit().getScreenSize().height);
setVisible(true);
// call setExtendedState(Frame.MAXIMIZED_BOTH) if possible:
if (!JdkVersionHacks.maximizeJFrameInBothDirections(this)) {
throw new Error("badness at maximum: the frame state is supported, but setting that state failed. JdkVersionHacks has a bug.");
}
} else {
Dimension gs = getToolkit().getScreenSize();
setLocation(0,0);
setSize(new Dimension(gs.width, gs.height));
setVisible(true);
}
}
public void newSavantWindow(String project, String titleName, URL trn, URL vid, URL abt)
{
try {
if (numberOfSavantsOpen == 0) {
setCursor(new Cursor(Cursor.WAIT_CURSOR));
openSavant(project, titleName, trn, vid, abt);
} else {
SavantShell scp = new SavantShell();
scp.setVisible(true);
setCursor(new Cursor(Cursor.WAIT_CURSOR));
scp.openSavant(project, titleName, trn, vid, abt);
}
numberOfSavantsOpen++;
} catch (NoClassDefFoundError err) {
ThdlDebug.handleClasspathError("Savant's CLASSPATH", err);
}
}
public void openSavant(String project, String titleName, URL trn, URL vid, URL abt)
{
setTitle(titleName);
setContentPane(savant);
validate();
savant.paintImmediately(0,0,savant.getWidth(),savant.getHeight());
InputStreamReader isr = null;
try {
InputStream in = trn.openStream();
isr = new InputStreamReader(in, "UTF8");
} catch (IOException ioe) {
System.out.println("input stream error");
return;
}
if (project.equals("Ucuchi")) {
TranscriptView[] views = new TranscriptView[5];
views[0] = new org.thdl.savant.ucuchi.Quechua(isr);
views[1] = new org.thdl.savant.ucuchi.SegmentedQuechua(views[0].getDocument());
views[2] = new org.thdl.savant.ucuchi.English(views[0].getDocument());
views[3] = new org.thdl.savant.ucuchi.QuechuaEnglish(views[0].getDocument());
views[4] = new org.thdl.savant.ucuchi.All(views[0].getDocument());
savant.open(views, vid, abt);
return;
}
if (project.equals("THDL")) {
// See if we have the TMW fonts available. If we do,
// allow showing Tibetan as well as Wylie and English.
int i=0;
if (!ThdlOptions.getBooleanOption("thdl.rely.on.system.tmw.fonts")) {
// We do have the TMW fonts available because we
// manually loaded them.
i = -1;
} else {
// DLC FIXME: scan for this in TibetanMachineWeb.java
// before manually loading the TMW fonts.
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String fonts[] = ge.getAvailableFontFamilyNames();
for (; i<fonts.length; i++) {
if (fonts[i].equals("TibetanMachineWeb"))
{
i=-1;
break;
}
}
}
if (i!=-1) {
JOptionPane.showMessageDialog(this,
"If you want to see text in Tibetan script, "+
"please set the option " +
"thdl.rely.on.system.tmw.fonts" +
" to false.",
"Note", JOptionPane.INFORMATION_MESSAGE);
TranscriptView[] views = new TranscriptView[3];
views[0] = new org.thdl.savant.tib.Wylie(isr);
views[1] = new org.thdl.savant.tib.English(views[0].getDocument());
views[2] = new org.thdl.savant.tib.WylieEnglish(views[0].getDocument());
savant.open(views, vid, abt);
} else {
TranscriptView[] views = new TranscriptView[7];
views[0] = new org.thdl.savant.tib.Tibetan(isr);
views[1] = new org.thdl.savant.tib.TibetanWylieEnglish(views[0].getDocument());
views[2] = new org.thdl.savant.tib.TibetanEnglish(views[0].getDocument());
views[3] = new org.thdl.savant.tib.TibetanWylie(views[0].getDocument());
views[4] = new org.thdl.savant.tib.WylieEnglish(views[0].getDocument());
views[5] = new org.thdl.savant.tib.English(views[0].getDocument());
views[6] = new org.thdl.savant.tib.Wylie(views[0].getDocument());
savant.open(views, vid, abt);
}
}
}
}

View file

@ -1,137 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.event.MouseListener;
import java.awt.event.ComponentAdapter;
import org.thdl.util.ThdlDebug;
public class TextHighlightPlayer extends JPanel implements AnnotationPlayer
{
protected JTextComponent text;
protected Hashtable hashStart, hashEnd, highlights;
protected Highlighter highlighter;
protected Highlighter.HighlightPainter highlightPainter;
protected JViewport viewport;
public TextHighlightPlayer(TranscriptView view, Color highlightcolor)
{
text = view.getTextComponent();
text.setEditable(false);
MouseListener[] mls = (MouseListener[])(text.getListeners(MouseListener.class));
for (int i=0; i<mls.length; i++)
text.removeMouseListener(mls[i]);
hashStart = new Hashtable();
hashEnd = new Hashtable();
highlights = new Hashtable();
StringTokenizer stIDS = new StringTokenizer(view.getIDs(), ",");
StringTokenizer stSTARTS = new StringTokenizer(view.getStartOffsets(), ",");
StringTokenizer stENDS = new StringTokenizer(view.getEndOffsets(), ",");
while ((stIDS.hasMoreTokens()) && (stSTARTS.hasMoreTokens()) && (stENDS.hasMoreTokens())) {
String sID = stIDS.nextToken();
String sStart = stSTARTS.nextToken();
String sEnd = stENDS.nextToken();
try {
Integer start = new Integer(sStart);
hashStart.put(sID, start);
} catch (NumberFormatException err) {
hashStart.put(sID, new Integer(0));
}
try {
Integer end = new Integer(sEnd);
hashEnd.put(sID, end);
} catch (NumberFormatException err) {
hashEnd.put(sID, new Integer(0));
}
}
highlighter = text.getHighlighter();
highlightPainter = new DefaultHighlighter.DefaultHighlightPainter(highlightcolor);
setLayout(new GridLayout(1,1));
add(new JScrollPane(text));
}
public boolean isPlayableAnnotation(String id)
{
return hashStart.containsKey(id);
}
public void startAnnotation(String id)
{
if (isPlayableAnnotation(id))
highlight(id);
}
public void stopAnnotation(String id)
{
if (isPlayableAnnotation(id))
unhighlight(id);
}
private void highlight(String id)
{
try
{
Integer startInt = (Integer)hashStart.get(id);
Integer endInt = (Integer)hashEnd.get(id);
int start = startInt.intValue();
int end = endInt.intValue();
Object tag = highlighter.addHighlight(start, end, highlightPainter);
highlights.put(id, tag);
// scrolls highlighted text to middle of viewport
JViewport viewport = (JViewport)SwingUtilities.getAncestorOfClass(JViewport.class, text);
int halfViewHeight = viewport.getExtentSize().height / 2;
Rectangle textRectangle = text.modelToView(end);
int yFactor = textRectangle.y - halfViewHeight;
if (yFactor > 0) {
viewport.setViewPosition(new Point(0, yFactor));
text.repaint();
}
/* this does scrolling at the bottom of the text window
Rectangle rect = text.modelToView(end);
text.scrollRectToVisible(rect);
text.repaint();
*/
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
private void unhighlight(String id)
{
if (highlights.containsKey(id))
{
highlighter.removeHighlight(highlights.get(id));
highlights.remove(id);
}
}
}

View file

@ -1,114 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
import org.thdl.util.ThdlDebug;
public class TextPlayer extends JPanel implements AnnotationPlayer
{
private JTextComponent text;
private Hashtable hashStart, hashEnd, highlights;
private Highlighter highlighter;
private Highlighter.HighlightPainter highlightPainter;
public TextPlayer(JTextComponent textcomponent, Color highlightcolor, String ids, String startoffsets, String endoffsets)
{
text = textcomponent;
text.setEditable(false);
hashStart = new Hashtable();
hashEnd = new Hashtable();
highlights = new Hashtable();
StringTokenizer stIDS = new StringTokenizer(ids, ",");
StringTokenizer stSTARTS = new StringTokenizer(startoffsets, ",");
StringTokenizer stENDS = new StringTokenizer(endoffsets, ",");
while ((stIDS.hasMoreTokens()) && (stSTARTS.hasMoreTokens()) && (stENDS.hasMoreTokens())) {
String sID = stIDS.nextToken();
String sStart = stSTARTS.nextToken();
String sEnd = stENDS.nextToken();
try {
Integer start = new Integer(sStart);
hashStart.put(sID, start);
} catch (NumberFormatException err) {
hashStart.put(sID, new Integer(0));
}
try {
Integer end = new Integer(sEnd);
hashEnd.put(sID, end);
} catch (NumberFormatException err) {
hashEnd.put(sID, new Integer(0));
}
}
highlighter = text.getHighlighter();
highlightPainter = new DefaultHighlighter.DefaultHighlightPainter(highlightcolor);
setLayout(new GridLayout(1,1));
add(new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));
}
public boolean isPlayableAnnotation(String id)
{
return hashStart.containsKey(id);
}
public void startAnnotation(String id)
{
if (isPlayableAnnotation(id))
highlight(id);
}
public void stopAnnotation(String id)
{
if (isPlayableAnnotation(id))
unhighlight(id);
}
private void highlight(String id)
{
try
{
Integer startInt = (Integer)hashStart.get(id);
Integer endInt = (Integer)hashEnd.get(id);
int start = startInt.intValue();
int end = endInt.intValue();
Object tag = highlighter.addHighlight(start, end, highlightPainter);
highlights.put(id, tag);
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
private void unhighlight(String id)
{
if (highlights.containsKey(id))
{
highlighter.removeHighlight(highlights.get(id));
highlights.remove(id);
}
}
}

View file

@ -1,31 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant;
public interface TranscriptView
{
public String getTitle();
public javax.swing.text.JTextComponent getTextComponent();
public String getIDs();
public String getT1s();
public String getT2s();
public String getStartOffsets();
public String getEndOffsets();
public org.jdom.Document getDocument();
}

View file

@ -1,128 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant;
import java.awt.Color;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Timer;
import java.util.TimerTask;
import java.util.TreeMap;
import java.util.SortedMap;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import javax.swing.text.JTextComponent;
import org.thdl.media.SmartMoviePanel;
import org.thdl.util.ThdlDebug;
public class TwoWayTextPlayer extends TextHighlightPlayer
{
protected TreeMap orderedOffsets = null;
protected SmartMoviePanel sound = null;
protected long doubleClickDelay = 300L;
protected long lastClickTime;
protected Point lastClickPoint = null;
public TwoWayTextPlayer(SmartMoviePanel sp, TranscriptView view, Color highlightColor)
{
super(view, highlightColor);
sound = sp;
orderedOffsets = new TreeMap();
for (Enumeration e = hashEnd.keys() ; e.hasMoreElements() ;)
{
String id = (String)e.nextElement();
orderedOffsets.put(hashEnd.get(id), id);
}
for (Enumeration e = hashStart.keys() ; e.hasMoreElements() ;)
{
String id = (String)e.nextElement();
orderedOffsets.put(hashStart.get(id), id);
}
view.getTextComponent().addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
//note - can't use e.getClickCount() here
//because every double click event is
//preceded by a single click event, so
//no easy way to distinguish the two
try
{
final long currentClickTime = e.getWhen();
final Point currentClickPoint = e.getPoint();
if (lastClickPoint != null && currentClickPoint.equals(lastClickPoint))
{ //this could be the second click of a double click
if (currentClickTime - lastClickTime < doubleClickDelay)
{ //must be a double-click: play only one line
lastClickPoint = null; //makes sure second click won't be interpreted as single click also
int pos = text.viewToModel(currentClickPoint)+1;
Integer i = new Integer(pos);
SortedMap map = orderedOffsets.headMap(i);
final String id = (String)map.get(map.lastKey());
highlighter.removeAllHighlights();
sound.cmd_playS(id);
return;
}
}
//otherwise, this click can only be single click or first click
lastClickTime = currentClickTime;
lastClickPoint = new Point(currentClickPoint);
final Timer clickTimer = new Timer(true);
clickTimer.schedule(new TimerTask()
{
public void run()
{
if (lastClickPoint != null)
{ //must be a single click: play line onwards
int pos = text.viewToModel(currentClickPoint)+1;
Integer i = new Integer(pos);
SortedMap map = orderedOffsets.headMap(i);
final String id = (String)map.get(map.lastKey());
highlighter.removeAllHighlights();
sound.cmd_playFrom(id);
}
clickTimer.cancel();
}
}, doubleClickDelay);
}
catch (NoSuchElementException nsee)
{
nsee.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
});
}
public void reset()
{
sound.removeAnnotationPlayer(this);
highlighter.removeAllHighlights();
}
public JTextComponent getTextComponent()
{
return text;
}
}

View file

@ -1,24 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides classes and methods for displaying foreign-language text,
audio, and video side-by-side.
<p>
Savant works for only a couple of languages right now, but can
be extended to work with many more.
</body>
</html>

View file

@ -1,218 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.tib;
import java.awt.Color;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.tib.text.*;
import org.thdl.tib.input.*;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class English implements TranscriptView
{
private JTextPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public English(Document xml)
{
process(xml);
xmlDoc = xml;
}
public English(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "English";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
text = new JTextPane();
javax.swing.text.Document doc = text.getDocument();
String space = " ";
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue);
Position endPos = null;
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
String wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
doc.insertString(endPos.getOffset(), wylie, mas);
}
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
if (endPos == null)
{
doc.insertString(0, space, null);
endPos = doc.createPosition(doc.getLength());
} else {
doc.insertString(endPos.getOffset(), space, null);
}
thisStart = String.valueOf(endPos.getOffset());
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), null);
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", null);
doc.insertString(endPos.getOffset(), current.getAttributeValue("who"), mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), space, null);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), null);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
}
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,229 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.tib;
import java.awt.Color;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.tib.text.*;
import org.thdl.tib.input.*;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class Tibetan implements TranscriptView
{
private DuffPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public Tibetan(Document xml)
{
process(xml);
xmlDoc = xml;
}
public Tibetan(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Tibetan";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
Position endPos = null;
DuffData[] dd;
TibetanDocument doc = new TibetanDocument(new StyleContext());
DuffData[] space = TibTextUtils.getTibetanMachineWeb("_");
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue);
int counter = 0;
int wherestart = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
dd = TibTextUtils.getTibetanMachineWeb(current.getAttributeValue("who"));
if (endPos == null)
{
doc.insertDuff(0, dd);
endPos = doc.createPosition(doc.getLength());
doc.setCharacterAttributes(0, endPos.getOffset(), mas, false);
}
else
{
wherestart = endPos.getOffset();
doc.insertDuff(endPos.getOffset(), dd);
doc.setCharacterAttributes(wherestart, endPos.getOffset()-wherestart, mas, false);
}
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
if (endPos == null)
{
doc.insertDuff(0, space);
endPos = doc.createPosition(doc.getLength());
} else {
doc.insertDuff(endPos.getOffset(), space);
}
wherestart = endPos.getOffset();
dd = TibTextUtils.getTibetanMachineWeb(current.getText()); //from +"\n"
doc.insertDuff(endPos.getOffset(), dd);
startBuffer.append(String.valueOf(wherestart)+",");
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", null);
dd = TibTextUtils.getTibetanMachineWeb(current.getAttributeValue("who")); //from +"\n"
wherestart = endPos.getOffset();
doc.insertDuff(endPos.getOffset(), dd);
doc.setCharacterAttributes(wherestart, endPos.getOffset()-wherestart, mas, false);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertDuff(endPos.getOffset(), space);
counter++;
dd = TibTextUtils.getTibetanMachineWeb(current.getText()); //from "+\n"
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
doc.insertDuff(endPos.getOffset(), dd);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
}
text = new DuffPane();
text.setDocument(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
catch (InvalidWylieException iwe)
{
iwe.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,237 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.tib;
import java.awt.Color;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.tib.text.*;
import org.thdl.tib.input.*;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class TibetanEnglish implements TranscriptView
{
private DuffPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public TibetanEnglish(Document xml)
{
process(xml);
xmlDoc = xml;
}
public TibetanEnglish(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Tibetan and English";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
DuffData[] dd;
// DuffData[] space = TibTextUtils.getTibetanMachineWeb("_");
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue);
Position endPos = null;
// int wherestart;
TibetanDocument doc = new TibetanDocument(new StyleContext());
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
String wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
}
doc.insertString(endPos.getOffset(), "\n", null);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
dd = TibTextUtils.getTibetanMachineWeb(current.getText()+"\n");
if (endPos == null)
{
thisStart = "0";
doc.insertDuff(0, dd);
endPos = doc.createPosition(doc.getLength());
} else {
thisStart = String.valueOf(endPos.getOffset());
doc.insertDuff(endPos.getOffset(), dd);
}
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), null);
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", null);
String wylie = current.getAttributeValue("who");
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", null);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
dd = TibTextUtils.getTibetanMachineWeb(current.getText()+"\n");
doc.insertDuff(endPos.getOffset(), dd);
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), null);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
}
text = new DuffPane();
text.setDocument(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
catch (InvalidWylieException iwe)
{
iwe.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,240 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.tib;
import java.awt.Color;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.tib.text.*;
import org.thdl.tib.input.*;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class TibetanWylie implements TranscriptView
{
private DuffPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public TibetanWylie(Document xml)
{
process(xml);
xmlDoc = xml;
}
public TibetanWylie(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Tibetan and Wylie";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
String wylie;
DuffData[] dd;
// DuffData[] space = TibTextUtils.getTibetanMachineWeb("_");
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue);
Position endPos = null;
// int wherestart;
TibetanDocument doc = new TibetanDocument(new StyleContext());
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
}
doc.insertString(endPos.getOffset(), "\n", null);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
wylie = current.getText();
dd = TibTextUtils.getTibetanMachineWeb(wylie+"\n");
if (endPos == null)
{
thisStart = "0";
doc.insertDuff(0, dd);
endPos = doc.createPosition(doc.getLength());
} else {
thisStart = String.valueOf(endPos.getOffset());
doc.insertDuff(endPos.getOffset(), dd);
}
doc.insertString(endPos.getOffset(), wylie, null);
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", null);
wylie = current.getAttributeValue("who");
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", null);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
wylie = current.getText();
dd = TibTextUtils.getTibetanMachineWeb(wylie+"\n");
doc.insertDuff(endPos.getOffset(), dd);
doc.insertString(endPos.getOffset(), wylie, null);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
}
text = new DuffPane();
text.setDocument(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
catch (InvalidWylieException iwe)
{
iwe.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,242 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.tib;
import java.awt.Color;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.tib.text.*;
import org.thdl.tib.input.*;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class TibetanWylieEnglish implements TranscriptView
{
private DuffPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public TibetanWylieEnglish(Document xml)
{
process(xml);
xmlDoc = xml;
}
public TibetanWylieEnglish(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Tibetan, Wylie and English";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
DuffData[] dd;
// DuffData[] space = TibTextUtils.getTibetanMachineWeb("_");
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue);
MutableAttributeSet mas2 = new SimpleAttributeSet();
StyleConstants.setItalic(mas2, true);
Position endPos = null;
// int wherestart;
String wylie;
TibetanDocument doc = new TibetanDocument(new StyleContext());
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
}
doc.insertString(endPos.getOffset(), "\n", null);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
wylie = current.getText();
dd = TibTextUtils.getTibetanMachineWeb(wylie+"\n");
if (endPos == null)
{
thisStart = "0";
doc.insertDuff(0, dd);
endPos = doc.createPosition(doc.getLength());
} else {
thisStart = String.valueOf(endPos.getOffset());
doc.insertDuff(endPos.getOffset(), dd);
}
doc.insertString(endPos.getOffset(), wylie+"\n", mas2);
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), null);
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", null);
wylie = current.getAttributeValue("who");
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", null);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
wylie = current.getText();
dd = TibTextUtils.getTibetanMachineWeb(wylie+"\n");
doc.insertDuff(endPos.getOffset(), dd);
doc.insertString(endPos.getOffset(), wylie+"\n", mas2);
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), null);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
}
text = new DuffPane();
text.setDocument(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
catch (InvalidWylieException iwe)
{
iwe.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,218 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.tib;
import java.awt.Color;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.tib.text.*;
import org.thdl.tib.input.*;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class Wylie implements TranscriptView
{
private JTextPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public Wylie(Document xml)
{
process(xml);
xmlDoc = xml;
}
public Wylie(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Wylie";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
String space = " ";
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue);
Position endPos = null;
StyledDocument doc = new TibetanDocument(new StyleContext());
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
String wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
doc.insertString(endPos.getOffset(), wylie, mas);
}
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
if (endPos == null)
{
doc.insertString(0, space, null);
endPos = doc.createPosition(doc.getLength());
} else {
doc.insertString(endPos.getOffset(), space, null);
}
thisStart = String.valueOf(endPos.getOffset());
doc.insertString(endPos.getOffset(), current.getText(), null);
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", null);
doc.insertString(endPos.getOffset(), current.getAttributeValue("who"), mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), space, null);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
doc.insertString(endPos.getOffset(), current.getText(), null);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
}
text = new JTextPane(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,230 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.tib;
import java.awt.Color;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.tib.text.*;
import org.thdl.tib.input.*;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class WylieEnglish implements TranscriptView
{
private JTextPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public WylieEnglish(Document xml)
{
process(xml);
xmlDoc = xml;
}
public WylieEnglish(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Wylie and English";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue);
MutableAttributeSet mas2 = new SimpleAttributeSet();
StyleConstants.setItalic(mas2, true);
Position endPos = null;
// int wherestart;
String wylie;
StyledDocument doc = new TibetanDocument(new StyleContext());
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
}
doc.insertString(endPos.getOffset(), "\n", null);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
wylie = current.getText();
if (endPos == null)
{
thisStart = "0";
doc.insertString(0, wylie+"\n", null);
endPos = doc.createPosition(doc.getLength());
} else {
thisStart = String.valueOf(endPos.getOffset());
doc.insertString(endPos.getOffset(), wylie+"\n", mas2);
}
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), null);
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", null);
wylie = current.getAttributeValue("who");
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", null);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
wylie = current.getText();
doc.insertString(endPos.getOffset(), wylie+"\n", mas2);
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), null);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
}
text = new JTextPane(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,23 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides Savant with the power to display Tibetan language
text beside video or audio of Tibetan speakers.
<p>
Supports Wylie, English, and Tibetan.
</body>
</html>

View file

@ -1,246 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.ucuchi;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class All implements TranscriptView
{
private JTextPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public All(Document xml)
{
process(xml);
xmlDoc = xml;
}
public All(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Quechua, Segmented Quechua, Gloss and English";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
text = new JTextPane();
javax.swing.text.Document doc = text.getDocument();
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setBold(mas, true);
StyleConstants.setUnderline(mas, true);
StyleConstants.setFontFamily(mas, "Monospaced");
StyleConstants.setFontSize(mas, 14);
MutableAttributeSet mas2 = new SimpleAttributeSet();
StyleConstants.setItalic(mas2, true);
StyleConstants.setFontFamily(mas2, "Monospaced");
StyleConstants.setFontSize(mas2, 14);
MutableAttributeSet mas3 = new SimpleAttributeSet();
StyleConstants.setFontFamily(mas3, "Monospaced");
StyleConstants.setFontSize(mas3, 14);
Position endPos = null;
String wylie;
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
}
doc.insertString(endPos.getOffset(), "\n", null);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
thisStart = "0";
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "((pause))", mas3);
else {
wylie = current.getText();
if (endPos == null)
{
doc.insertString(0, wylie+"\n", null);
endPos = doc.createPosition(doc.getLength());
} else {
thisStart = String.valueOf(endPos.getOffset());
doc.insertString(endPos.getOffset(), wylie+"\n", mas3);
}
doc.insertString(endPos.getOffset(), current.getAttributeValue("seg")+"\n", mas3);
doc.insertString(endPos.getOffset(), current.getAttributeValue("gls")+"\n", mas3);
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), mas2);
}
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", null);
wylie = current.getAttributeValue("who");
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", null);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "((pause))", mas3);
else {
wylie = current.getText();
doc.insertString(endPos.getOffset(), wylie+"\n", mas3);
doc.insertString(endPos.getOffset(), current.getAttributeValue("seg")+"\n", mas3);
doc.insertString(endPos.getOffset(), current.getAttributeValue("gls")+"\n", mas3);
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), mas2);
}
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
doc.insertString(endPos.getOffset(), "\n", null);
}
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,218 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.ucuchi;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class English implements TranscriptView
{
private JTextPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public English(Document xml)
{
process(xml);
xmlDoc = xml;
}
public English(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "English";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
text = new JTextPane();
javax.swing.text.Document doc = text.getDocument();
MutableAttributeSet mas0 = new SimpleAttributeSet();
StyleConstants.setFontSize(mas0, 16);
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setBold(mas, true);
StyleConstants.setUnderline(mas, true);
StyleConstants.setFontSize(mas, 16);
Position endPos = null;
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
String wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
doc.insertString(endPos.getOffset(), wylie, mas);
}
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", mas0);
thisStart = String.valueOf(endPos.getOffset());
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "......", mas0);
else
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), mas0);
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n\n", mas0);
doc.insertString(endPos.getOffset(), current.getAttributeValue("who"), mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", mas0);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "......", mas0);
else
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), mas0);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
}
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,217 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.ucuchi;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class Quechua implements TranscriptView
{
private JTextPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public Quechua(Document xml)
{
process(xml);
xmlDoc = xml;
}
public Quechua(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Quechua";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
text = new JTextPane();
javax.swing.text.Document doc = text.getDocument();
MutableAttributeSet mas0 = new SimpleAttributeSet();
StyleConstants.setFontSize(mas0, 16);
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setBold(mas, true);
StyleConstants.setUnderline(mas, true);
StyleConstants.setFontSize(mas, 16);
Position endPos = null;
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
String wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
doc.insertString(endPos.getOffset(), wylie, mas);
}
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", mas0);
thisStart = String.valueOf(endPos.getOffset());
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "......", mas0);
else
doc.insertString(endPos.getOffset(), current.getText(), mas0);
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n\n", mas0);
doc.insertString(endPos.getOffset(), current.getAttributeValue("who"), mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", mas0);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "......", mas0);
else
doc.insertString(endPos.getOffset(), current.getText(), mas0);
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
}
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,238 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.ucuchi;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class QuechuaEnglish implements TranscriptView
{
private JTextPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public QuechuaEnglish(Document xml)
{
process(xml);
xmlDoc = xml;
}
public QuechuaEnglish(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Quechua and English";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
text = new JTextPane();
javax.swing.text.Document doc = text.getDocument();
MutableAttributeSet mas0 = new SimpleAttributeSet();
StyleConstants.setFontSize(mas0, 16);
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setBold(mas, true);
StyleConstants.setUnderline(mas, true);
StyleConstants.setFontSize(mas, 16);
MutableAttributeSet mas2 = new SimpleAttributeSet();
StyleConstants.setItalic(mas2, true);
StyleConstants.setFontSize(mas2, 16);
StyleConstants.setFontSize(mas2, 16);
Position endPos = null;
String wylie;
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
}
doc.insertString(endPos.getOffset(), "\n", mas0);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
thisStart = "0";
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "((pause))", mas0);
else {
wylie = current.getText();
if (endPos == null)
{
doc.insertString(0, wylie+"\n", mas0);
endPos = doc.createPosition(doc.getLength());
} else {
thisStart = String.valueOf(endPos.getOffset());
doc.insertString(endPos.getOffset(), wylie+"\n", mas0);
}
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), mas2);
}
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
while (iter.hasNext())
{
current = (Element)iter.next();
doc.insertString(endPos.getOffset(), "\n", mas0);
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n", mas0);
wylie = current.getAttributeValue("who");
// wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", mas0);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "((pause))", mas0);
else {
wylie = current.getText();
doc.insertString(endPos.getOffset(), wylie+"\n", mas0);
doc.insertString(endPos.getOffset(), current.getAttributeValue("eng"), mas2);
}
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
}
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,239 +0,0 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.savant.ucuchi;
import java.io.Reader;
import java.util.List;
import java.util.Iterator;
import java.util.StringTokenizer;
import javax.swing.JTextPane;
import javax.swing.text.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class SegmentedQuechua implements TranscriptView
{
private JTextPane text = null;
private Document xmlDoc = null;
private StringBuffer idBuffer = null;
private StringBuffer t1Buffer = null;
private StringBuffer t2Buffer = null;
private StringBuffer startBuffer = null;
private StringBuffer endBuffer = null;
public SegmentedQuechua(Document xml)
{
process(xml);
xmlDoc = xml;
}
public SegmentedQuechua(Reader source)
{
try
{
SAXBuilder builder = new SAXBuilder();
Document xml = builder.build(source);
process(xml);
xmlDoc = xml;
}
catch (JDOMException jdome)
{
jdome.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public String getTitle()
{
return "Segmented Quechua";
}
public void process(Document xml)
{
try {
Element root = xml.getRootElement();
List elements = root.getChildren();
Iterator iter = elements.iterator();
Element current = null;
text = new JTextPane();
javax.swing.text.Document doc = text.getDocument();
MutableAttributeSet mas0 = new SimpleAttributeSet();
StyleConstants.setFontSize(mas0, 16);
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setBold(mas, true);
StyleConstants.setUnderline(mas, true);
StyleConstants.setFontSize(mas, 16);
Position endPos = null;
idBuffer = new StringBuffer();
startBuffer = new StringBuffer();
endBuffer = new StringBuffer();
t1Buffer = new StringBuffer();
t2Buffer = new StringBuffer();
String thisStart, thisEnd, thisId;
int counter = 0;
if (iter.hasNext())
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
String wylie = current.getAttributeValue("who");
if (endPos == null)
{
doc.insertString(0, wylie, mas);
endPos = doc.createPosition(doc.getLength());
}
else
{
doc.insertString(endPos.getOffset(), wylie, mas);
}
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", mas0);
thisStart = String.valueOf(endPos.getOffset());
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "......", mas0);
else {
String segString = current.getAttributeValue("seg");
StringBuffer segBuffer = new StringBuffer();
StringTokenizer segTokenizer = new StringTokenizer(segString);
for (int i=0; segTokenizer.hasMoreTokens(); i++) {
String next = segTokenizer.nextToken();
if (i>0 && next.charAt(0)!='-')
segBuffer.append(' ');
segBuffer.append(next);
}
doc.insertString(endPos.getOffset(), segBuffer.toString(), mas0);
}
startBuffer.append(thisStart);
startBuffer.append(',');
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
idBuffer.append("s0,");
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
while (iter.hasNext())
{
current = (Element)iter.next();
while (current.getName().equals("spkr"))
{
doc.insertString(endPos.getOffset(), "\n\n", mas0);
doc.insertString(endPos.getOffset(), current.getAttributeValue("who"), mas);
if (iter.hasNext())
current = (org.jdom.Element)iter.next();
}
doc.insertString(endPos.getOffset(), "\n", mas0);
counter++;
thisStart = String.valueOf(endPos.getOffset());
startBuffer.append(thisStart);
startBuffer.append(',');
if (current.getAttributeValue("gls").equals("PAUSE"))
doc.insertString(endPos.getOffset(), "......", mas0);
else {
String segString = current.getAttributeValue("seg");
StringBuffer segBuffer = new StringBuffer();
StringTokenizer segTokenizer = new StringTokenizer(segString);
for (int i=0; segTokenizer.hasMoreTokens(); i++) {
String next = segTokenizer.nextToken();
if (i>0 && next.charAt(0)!='-')
segBuffer.append(' ');
segBuffer.append(next);
}
doc.insertString(endPos.getOffset(), segBuffer.toString(), mas0);
}
thisEnd = String.valueOf(endPos.getOffset());
endBuffer.append(thisEnd);
endBuffer.append(',');
thisId = "s"+String.valueOf(counter);
idBuffer.append(thisId);
idBuffer.append(',');
t1Buffer.append(current.getAttributeValue("start"));
t1Buffer.append(',');
t2Buffer.append(current.getAttributeValue("end"));
t2Buffer.append(',');
}
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
public JTextComponent getTextComponent()
{
return text;
}
public Document getDocument()
{
return xmlDoc;
}
public String getIDs()
{
return idBuffer.toString();
}
public String getT1s()
{
return t1Buffer.toString();
}
public String getT2s()
{
return t2Buffer.toString();
}
public String getStartOffsets()
{
return startBuffer.toString();
}
public String getEndOffsets()
{
return endBuffer.toString();
}
}

View file

@ -1,23 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides Savant with the power to display Quechua language
text beside video or audio of Quechua speakers.
<p>
Supports Quechua and English.
</body>
</html>