I should have imported these into Jskad/source, not Jskad/.
This commit is contained in:
dchandler 2002-09-28 00:51:54 +00:00
parent d0b090eff2
commit d305d5ca8d
57 changed files with 0 additions and 13609 deletions

View file

@ -1,75 +0,0 @@
Project = Project
ProjectDetails = Project Details
Speakers = Speakers
TimeCoding = Time Coding
AdjustTimeCode = Adjust Time Code
In = Start
Out = Stop
PlaySegment = Play Segment
NewProject = New Project
TitleColon = Title:
TypeNewTitleColon = Type new title:
NoMedia = No media
MediaColon = Media:
NoTranscript = No transcript
TranscriptColon = Transcript:
KeyboardInputMethod = Keyboard Input Method
TranscriberName = Transcriber Name
TranscriberTask = Transcriber Task
Add = Add
FaceColon = Face:
NameColon = Name:
EnterNewSpeakerInfo = Enter new speaker info
Edit = Edit
EditSpeakerInfo = Edit speaker info
Remove = Remove
SureDeleteSpeaker = Are you sure you want to delete this speaker?
Warning = Warning!
Face = Face
Name = Name
SaveCurrent = Save the current transcript
OpenExisting = Open an existing transcript
WhatToDo = What do you want to do?
ChooseOne = Choose an option
Play = Play
Pause = Pause
Mode = Mode
Edit = Edit
ReadOnly = Read-only
View = View
Previous = Previous
Current = Current
Next = Next
SuppressTimes = Hide times
Search = Search
FindText = Find text
ReplaceText = Replace text
FindSpeaker = Find speaker
FindTime = Find time
Cut = Cut
Copy = Copy
Paste = Paste
SelectAll = Select all
InsertSpeaker = Insert speaker
InsertOneTime = Insert a time
InsertTwoTimes = Insert two times
New = New
Open = Open
Close = Close
Save = Save
SaveAs = Save as
Quit = Quit
Keyboard = Keyboard
Preferences = Preferences
FindHeading = Search
FindReplaceHeading = Search and Replace
FindWhat = Find what
ReplaceWith = Replace with
ReplaceQ = Replace?
FindNextYesNo = Find next?
StartFromBeginning = You've reached the end of the document. Do you want to continue searching from the beginning?
TextFound = Text found.
Replace = Replace
ReplaceAll = Replace all
NoReplace = Don't replace
Cancel = Cancel

View file

@ -1,75 +0,0 @@
Project = Project Details
ProjectDetails = Projekt
Speakers = Sprecher
TimeCoding = Zeitcode
AdjustTimeCode = Zeitcode regulieren
In = Start
Out = Stop
PlaySegment = Abschnitt abspielen
NewProject = Neues Projekt
TitleColon = Titel:
TypeNewTitleColon = Neue Titeleingabe
NoMedia = Keine Audio/Video-Medien
MediaColon = Audio/Video-Medien:
NoTranscript = Keine Transkription
TranscriptColon = Text-Transkription:
KeyboardInputMethod = Tastatur Eingabemethode
TranscriberName = Transkribierer-Name:
TranscriberTask = Transkribierer-Aufgabe:
Add = Hinzufügen
FaceColon = Gesicht
NameColon = Name:
EnterNewSpeakerInfo = Eingabe neue Sprecher-Information
Edit = Bearbeiten
EditSpeakerInfo = Bearbeiten der Srecher-Information
Remove = Entfernen
SureDeleteSpeaker = Wollen Sie wirklich diesen Sprecher löschen?
Warning = Warnung!
Face = Gesicht
Name = Name
SaveCurrent = Gegenwärtige Transkription speichern
OpenExisting = Bereits bearbeitete Transkription öffnen
WhatToDo = Was möchten Sie tun?
ChooseOne = Wählen Sie eine Möglichkeit
Play = Abspielen
Pause = Pause
Mode = Moduswahl
Edit = Bearbeiten der Transkription
ReadOnly = Sichten der Transkription
View = Sichten
Previous = Vorhergehender Satz
Current = Gegenwärtiger Satz
Next = Nächster Satz
SuppressTimes = Entfernen der Zeitzeichen
Search = Search
FindText = Text finden
ReplaceText = Text ersetzen
FindSpeaker = Sprecher finden
FindTime = Zeitabschnitt finden
Cut = Schneiden
Copy = Kopieren
Paste = Einfügen
SelectAll = Alles auswählen
InsertSpeaker = Sprecher einfügen
InsertOneTime = Einmal einfügen
InsertTwoTimes = Zweimal einfügen
New = Neu
Open = Öffnen
Close = Schließen
Save = Speichern
SaveAs = Speichern als
Quit = Quit
Keyboard = Tastatur Eingabemethode
Preferences = Präferenzen
FindHeading = Search
FindReplaceHeading = Search and Replace
FindWhat = Find what
ReplaceWith = Replace with
ReplaceQ = Replace?
FindNextYesNo = Find next?
StartFromBeginning = You've reached the end of the document. Do you want to continue searching from the beginning?
TextFound = Text found.
Replace = Replace
ReplaceAll = Replace all
NoReplace = Don't replace
Cancel = Cancel

View file

@ -1,34 +0,0 @@
Project = \u9879\u76ee
Speakers = \u5bf9\u8bdd\u8005
TimeCoding = \u65f6\u95f4\u4ee3\u7801
AdjustTimeCode = \u8c03\u6574\u65f6\u95f4
In =\u5f00\u59cb
Out = \u7ed3\u675f
PlaySegment = \u663e\u793a\u7a97\u53e3
NewProject =\u65e0\u65b0\u9879\u76ee\u6587\u4ef6
TitleColon = \u9898\u76ee
TypeNewTitleColon = \u65b0\u9898\u76ee
NoMedia = \u65e0\u5a92\u4f53\u6587\u4ef6
MediaColon = \u5a92\u4f53
NoTranscript = \u65e0\u6587\u672c\u6587\u4ef6
TranscriptColon = \u6587\u5b57
KeyboardInputMethod = \u952e\u76d8\u5e03\u5c40
TranscriberName = \u8bb0\u5f55\u8005
TranscriberTask = \u8bb0\u5f55\u5185\u5bb9
Add = \u589e\u52a0
FaceColon = \u9009\u62e9\u8138\u5f62
NameColon = \u53d6\u540d
EnterNewSpeakerInfo = \u589e\u52a0\u65b0\u7528\u6237\u7a97\u53e3
Edit = \u7f16\u8f91
EditSpeakerInfo = \u7f16\u8f91\u7a97\u53e3
Remove = \u5220\u9664
SureDeleteSpeaker = \u786e\u5b9e\u5220\u9664\u5417\uff1f
Warning = \u8b66\u544a\uff01
Face = \u8138
Name = \u540d
SaveCurrent = \u4fdd\u5b58
OpenExisting =\u6253\u5f00
WhatToDo =\u9009\u62e9
ChooseOne =\u9009\u62e9\u4e4b\u4e00
Play = \u64ad\u653e
Pause = \u6682\u505c

View file

@ -1,34 +0,0 @@
Project = 项目
Speakers = 对话者
TimeCoding = 时间代码
AdjustTimeCode = 调整时间
In =开始
Out = 结束
PlaySegment = 显示窗口
NewProject =无新项目文件
TitleColon = 题目
TypeNewTitleColon = 新题目
NoMedia = 无媒体文件
MediaColon = 媒体
NoTranscript = 无文本文件
TranscriptColon = 文字
KeyboardInputMethod = 键盘布局
TranscriberName = 记录者
TranscriberTask = 记录内容
Add = 增加
FaceColon = 选择脸形
NameColon = 取名
EnterNewSpeakerInfo = 增加新用户窗口
Edit = 编辑
EditSpeakerInfo = 编辑窗口
Remove = 删除
SureDeleteSpeaker = 确实删除吗?
Warning = 警告!
Face = 脸
Name = 名
SaveCurrent = 保存
OpenExisting =打开
WhatToDo =选择
ChooseOne =选择之一
Play = 播放
Pause = 暂停

File diff suppressed because it is too large Load diff

View file

@ -1,405 +0,0 @@
package org.thdl.quilldriver;
import java.util.*;
import java.net.*;
import javax.media.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
/*-----------------------------------------------------------------------*/
public class QDPlayer extends Panel implements ControllerListener
{
private EventListenerList listenerList = new EventListenerList();
public URL mediaURL;
private Vector orderStartID, orderEndID;
private Stack pileStart, pileEnd;
private Hashtable hashStart, hashEnd;
private Player player = null;
private Component visualComponent = null;
private Component controlComponent = null;
private Panel panel = null;
private JPanel vPanel = null;
private Container parent = null;
private java.util.Timer timer = null;
private Time stopTime = null;
private Time pauseTime = null;
private boolean stillLoadingVideo = false;
private boolean isMediaAudio = false;
private boolean isSized = false;
private Float to = null;
/*-----------------------------------------------------------------------*/
public QDPlayer(Container p, URL sound) {
parent = p;
makeMedia(sound);
}
public void makeMedia(URL sound) {
if (mediaURL != null) {
cmd_stop();
destroy();
}
mediaURL = sound;
start();
}
public URL getURL() {
return mediaURL;
}
public void destroy() {
player.close();
}
public void start() {
openPlayer();
}
public Component popVisualComponent()
{
vPanel.remove(visualComponent);
invalidate();
validate();
repaint();
return visualComponent;
}
public void restoreVisualComponent()
{
vPanel.add("Center", visualComponent);
invalidate();
validate();
repaint();
}
public Component getVisualComponent()
{
return visualComponent;
}
public Component getControlComponent()
{
return controlComponent;
}
/*-----------------------------------------------------------------------*/
public boolean cmd_isSized() {
return isSized;
}
public boolean cmd_isRealized() {
return player.getState() == Controller.Realized;
}
public String cmd_firstS() {
return (String)orderStartID.elementAt(0);
}
public boolean cmd_stop() {
if (player == null)
return false;
try {
player.stop();
return true;
} catch (NotRealizedError err) {
System.out.println("NotRealizedError");
return false;
}
}
public boolean cmd_isID(String theID) {
System.out.println(hashStart.containsKey(theID));
return hashStart.containsKey(theID);
}
public boolean cmd_play() {
if (stillLoadingVideo || player == null)
return false;
if (player.getState() == Controller.Started)
return true;
if (pauseTime == null)
player.setMediaTime(new Time(0.0));
else
player.setMediaTime(pauseTime);
if (player.getTargetState() < Player.Started) {
player.setStopTime(Clock.RESET);
player.prefetch();
}
player.start();
return true;
}
public boolean cmd_playFrom(Integer from) {
if (stillLoadingVideo)
return false;
if (play(from, null))
return true;
else
return false;
}
public boolean cmd_play(Integer from, Integer to) {
if (stillLoadingVideo)
return false;
if (play(from, to))
return true;
else
return false;
}
/*-----------------------------------------------------------------------*/
public int getLastTime() {
Time t = player.getDuration();
long l = t.getNanoseconds();
return new Long(l / 1000000).intValue();
}
public int when() {
if (player == null)
return -1;
if (player.getState() < Controller.Realized)
return -1;
long currTime = player.getMediaNanoseconds();
return new Long(currTime / 1000000).intValue();
}
private boolean play(Integer from, Integer to) {
if (player == null)
return false;
final Time startTime = new Time(from.longValue() * 1000000);
try {
if (player.getState() == Controller.Started)
player.stop();
while (player.getState() == Controller.Unrealized)
;
// player.stop();
if (to == null) {
stopTime = null;
player.setStopTime(Clock.RESET);
} else {
stopTime = new Time(to.longValue() * 1000000);
player.setStopTime(stopTime);
}
player.setMediaTime(startTime);
player.prefetch();
player.start();
return true;
} catch(NotRealizedError err) {
System.out.println("NotRealizedError");
return false;
}
}
/*-----------------------------------------------------------------------*/
public void openPlayer() {
try {
player = Manager.createPlayer(mediaURL);
player.addControllerListener(this);
} catch (javax.media.NoPlayerException e) {
System.err.println("noplayer exception");
e.printStackTrace();
return;
} catch (java.io.IOException ex) {
System.err.println("IO exception");
ex.printStackTrace();
return;
}
if (player != null)
player.realize();
}
public synchronized void controllerUpdate(ControllerEvent event) {
if (player == null)
return;
if (event instanceof RealizeCompleteEvent) {
System.out.println("received RealizeCompleteEvent event");
if (visualComponent == null) {
if (panel == null) {
setLayout(new GridLayout(1,1));
vPanel = new JPanel();
vPanel.setLayout( new BorderLayout() );
if ((visualComponent = player.getVisualComponent())!= null)
vPanel.add("Center", visualComponent);
else {
isMediaAudio = true;
stillLoadingVideo = false;
}
if (!stillLoadingVideo)
{
if ((controlComponent = player.getControlPanelComponent()) != null) {
if (visualComponent == null) //no video
vPanel.setPreferredSize(new Dimension(400,25));
vPanel.add("South", controlComponent);
}
}
add(vPanel);
}
}
parent.invalidate();
parent.validate();
parent.repaint();
isSized = true;
if (stillLoadingVideo)
player.start();
} else if (event instanceof StartEvent) {
StartEvent se = (StartEvent)event;
Time t = se.getMediaTime();
long longt = t.getNanoseconds();
Float from = new Float(longt);
float f = (from.floatValue() / 1000000000);
from = new Float(f);
t = player.getStopTime();
longt = t.getNanoseconds();
to = new Float(longt);
f = (to.floatValue() / 1000000000);
to = new Float(f);
if (timer != null)
{
timer.cancel();
timer = null;
}
timer = new java.util.Timer(true);
timer.schedule(new TimerTask() {
public void run() {
//this is specifically for the MPG stop time bug
if (stopTime != null)
if (player.getMediaTime().getNanoseconds() > stopTime.getNanoseconds())
player.stop();
}}, 0, 15);
} else if (event instanceof StopEvent) {
pauseTime = player.getMediaTime();
/*messy problems require messy solutions:
if the slider is present, dragging it while playing creates
a RestartingEvent, and if I set the media time here it messes up
and barely plays at all (maybe because it cancels the previously
set media time? - I don't know).
but it seems that if you press the play/pause button on the
control widget, then you need to set the media time upon stop
(probably because of problem noted below, namely that you get
weird results if you do player.start() without setting the media
time.*/
if (!(event instanceof RestartingEvent))
player.setMediaTime(pauseTime);
// player.setStopTime(Clock.RESET);
stopTime = null;
System.out.println("received StopEvent");
if (timer != null)
{
timer.cancel();
timer = null;
}
if (stillLoadingVideo)
{
System.out.println("received EndOfMediaEvent");
stillLoadingVideo = false;
player.stop();
if ((controlComponent = player.getControlPanelComponent()) != null) {
if (visualComponent == null) //no video
vPanel.setPreferredSize(new Dimension(400,25));
vPanel.add("South", controlComponent);
}
parent.invalidate();
parent.validate();
parent.repaint();
}
} else if ( event instanceof CachingControlEvent) {
CachingControlEvent e = (CachingControlEvent) event;
System.out.println("got CachingControlEvent: " + e);
if (!isMediaAudio)
stillLoadingVideo = true;
} else if (event instanceof ControllerErrorEvent) {
player = null;
System.err.println("*** ControllerErrorEvent *** " + ((ControllerErrorEvent)event).getMessage());
} else if (event instanceof PrefetchCompleteEvent) {
if (panel != null) {
panel.invalidate();
}
parent.invalidate();
parent.validate();
parent.repaint();
}
}
};
/*
After pause the MPEG video and playing it again it gets faster
Author: vladshtr
In Reply To: After pause the MPEG video and playing it again it gets faster
Mar 1, 2001 6:25 PM
Reply 1 of 1
The problem is in the setting the Meida time.
The safety way is to always set new media time with the
following method: setMediaTime(Time time); .... if you want to
use it after
-player.stop(); used as real stop you can use setMediaTime(new
Time(0.0));
-player.stop(); used as real pause you have to use the
combination:
player.stop();
Time currentTime = player.getMediaTime();
//........
player.setMediaTime(currentTime);
player.start();
Re: (urgent) when you pause and resume, video plays at rate > 1
Author: seertenedos
In Reply To: (urgent) when you pause and resume, video plays at rate > 1
Aug 11, 2002 11:36 PM
Reply 1 of 1
I found a solution for this problem for those that are interested.
what you have to do is store the time just before you pause and then set the
time just before you play. here is a copy of my pause and play methods
// Start the player
private void play() {
if (player != null)
{
if (pauseTime != null)
{
player.setMediaTime(pauseTime);
}
if (player.getTargetState() < Player.Started)
player.prefetch();
player.start();
}
}
// Pause the player
private void pause() {
if (player != null)
pauseTime = player.getMediaTime();
player.stop();
}
that should solve your pause play problems!
> The problem is below. It seems quite a few people are
> having this problem but i have not seen a solution
> around. I really need a solution to this problem as
> the whole point of my application is that it plays
> divx and mpeg videos. At the moment i have divx
> movies playing through the mpeg demuxer as the avi one
> stuffed up the audio. I think that is the reason it
> affects both divx and mpeg. My application is due in
> one week and my client is not going to be very happy
> if this problem happens every time they pause then
> play the video.
> The player is for divx movies. If anyone knows how to
> solve this problem or how to make it so you can pause
> and resume divx movies please respond.
>
> Pause and Resume playback.
> The video plays at a high rate and there is no audio.
> Problem doesn't appear while seeking.
>
>
>
>
*/

View file

@ -1,159 +0,0 @@
package org.thdl.quilldriver;
import java.io.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.text.rtf.*;
public class QDShell extends JFrame {
ResourceBundle messages = null;
QD qd = null;
public static void main(String[] args) {
try {
PrintStream ps = new PrintStream(new FileOutputStream("qd.log"));
System.setErr(ps);
System.setOut(ps);
}
catch (Exception e) {
}
Locale locale;
if (args.length == 2) {
locale = new Locale(new String(args[0]), new String(args[1]));
Locale[] locales = Locale.getAvailableLocales();
for (int k=0; k<locales.length; k++)
if (locales[k].equals(locale)) {
JComponent.setDefaultLocale(locale);
break;
}
}
else
locale = Locale.getDefault();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
}
QDShell qdsh = new QDShell(locale);
qdsh.setVisible(true);
}
public QDShell(Locale locale) {
setTitle("QuillDriver");
/*
// Code for Merlin
if (getToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH))
{
setLocation(0,0);
setSize(getToolkit().getScreenSize().width,getToolkit().getScreenSize().height);
setVisible(true);
setExtendedState(Frame.MAXIMIZED_BOTH);
} else {
*/
Dimension gs = getToolkit().getScreenSize();
setLocation(0,0);
setSize(new Dimension(gs.width, gs.height));
setVisible(true);
// }
messages = ResourceBundle.getBundle("MessageBundle", locale);
setJMenuBar(getQDShellMenu());
qd = new QD(messages);
getContentPane().add(qd);
addWindowListener(new WindowAdapter () {
public void windowClosing (WindowEvent e) {
qd.getSave();
//should only system exit if no cancel!!
System.exit(0);
}
});
}
public JMenuBar getQDShellMenu() {
JMenu projectMenu = new JMenu(messages.getString("Project"));
JMenuItem newItem = new JMenuItem(messages.getString("New"));
JMenuItem openItem = new JMenuItem(messages.getString("Open"));
openItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
qd.getOpen();
}
});
JMenuItem closeItem = new JMenuItem(messages.getString("Close"));
JMenuItem saveItem = new JMenuItem(messages.getString("Save"));
saveItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
qd.getSave();
}
});
JMenuItem quitItem = new JMenuItem(messages.getString("Quit"));
quitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
qd.getSave();
//should only system exit if no cancel!!
System.exit(0);
}
});
projectMenu.add(newItem);
projectMenu.add(openItem);
projectMenu.add(closeItem);
projectMenu.addSeparator();
projectMenu.add(saveItem);
projectMenu.addSeparator();
projectMenu.add(quitItem);
//Tibetan-specific value: remove in non-Tibetan version
//non-Tibetan specific version would have Transcription Language option here instead
JRadioButton wylieButton = new JRadioButton("THDL Extended Wylie");
JRadioButton sambhotaButton = new JRadioButton("Sambhota Keymap One");
JRadioButton tcc1Button = new JRadioButton("TCC Keyboard 1");
JRadioButton tcc2Button = new JRadioButton("TCC Keyboard 2");
wylieButton.setActionCommand("wylie");
sambhotaButton.setActionCommand("sambhota1");
tcc1Button.setActionCommand("tcc1");
tcc2Button.setActionCommand("tcc2");
RadioListener l = new RadioListener();
wylieButton.addActionListener(l);
sambhotaButton.addActionListener(l);
tcc1Button.addActionListener(l);
tcc2Button.addActionListener(l);
wylieButton.setSelected(true);
ButtonGroup bg = new ButtonGroup();
bg.add(wylieButton);
bg.add(sambhotaButton);
bg.add(tcc1Button);
bg.add(tcc2Button);
JPanel buttons = new JPanel(new GridLayout(0,1));
buttons.add(wylieButton);
buttons.add(sambhotaButton);
buttons.add(tcc1Button);
buttons.add(tcc2Button);
JMenu keyboardMenu = new JMenu(messages.getString("Keyboard"));
keyboardMenu.add(buttons);
JMenu preferencesMenu = new JMenu(messages.getString("Preferences"));
preferencesMenu.add(keyboardMenu);
JMenuBar bar = new JMenuBar();
bar.add(projectMenu);
bar.add(preferencesMenu);
return bar;
}
class RadioListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
qd.changeKeyboard(e);
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 854 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 948 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -1,7 +0,0 @@
package org.thdl.savant;
public interface AnnotationPlayer extends java.util.EventListener
{
public void startAnnotation(String id);
public void stopAnnotation(String id);
}

View file

@ -1,313 +0,0 @@
package org.thdl.savant;
import java.awt.Font;
import java.awt.Label;
import java.awt.Color;
import java.awt.Frame;
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.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;
public class Savant extends JDesktopPane
{
protected SoundPanel 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 videoPanel = null;
protected JPanel textPanel = null;
protected JScrollPane vocabPanel = null;
protected URL extras = null;
protected int orientation = 0;
public final int TOP_TO_BOTTOM = 1;
public final int LEFT_TO_RIGHT = 2;
public Savant()
{
setBackground(new JFrame().getBackground());
setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
setLayout(new BorderLayout());
String labelString = "Please wait while Savant loads this transcript and media.";
JLabel label = new JLabel(labelString, SwingConstants.CENTER);
label.setFont(new Font("Serif", Font.PLAIN, 14));
add("Center", label);
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);
if (vocabFrame != null)
{
textFrame.setSize(getSize().width / 2, getSize().height - videoFrame.getSize().height);
vocabFrame.setLocation(textFrame.getSize().width, videoFrame.getSize().height);
vocabFrame.setSize(getSize().width - textFrame.getSize().width, getSize().height - videoFrame.getSize().height);
} else
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);
if (vocabFrame != null)
{
vocabFrame.setLocation(0, videoFrame.getSize().height);
vocabFrame.setSize(videoFrame.getSize().width, getSize().height - videoFrame.getSize().height);
}
break;
default:
break;
}
}
});
}
public void close()
{
if (sp != null)
sp.destroy();
}
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();
}
}
public void open(final TranscriptView[] views, final URL video, final URL vocabulary)
{
videoPanel = new JPanel(new GridLayout(1,1));
textPanel = new JPanel(new BorderLayout());
sp = new SoundPanel(this, video, views[0].getT1s(), views[0].getT2s(), views[0].getIDs());
tp = new TwoWayTextPlayer(sp, views[0], Color.cyan);
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 ActionListener() {
public void actionPerformed(ActionEvent e)
{
JComboBox jcb = (JComboBox)e.getSource();
setTranscriptView(views[jcb.getSelectedIndex()]);
}
});
jp.add(viewOptions);
extras = vocabulary;
textPanel.add("Center", tp);
textPanel.add("North", jp);
sp.addAnnotationPlayer(tp);
sp.start();
final Timer timer = new Timer(true);
timer.schedule(new TimerTask() {
public void run()
{
if (sp.cmd_isSized())
{
timer.cancel();
//(String title, boolean resizable, boolean closable, boolean maximizable, boolean iconifiable)
videoFrame = new JInternalFrame(null, false, false, false, false);
textFrame = new JInternalFrame("Transcript", false, false, false, true);
textFrame.setVisible(true);
videoFrame.setVisible(true);
if (vocabulary != null)
{
try {
JTextPane vocabPane = new JTextPane();
MouseListener[] mls = (MouseListener[])(vocabPane.getListeners(MouseListener.class));
for (int i=0; i<mls.length; i++)
vocabPane.removeMouseListener(mls[i]);
vocabPane.setEditable(false);
vocabPanel = new JScrollPane(vocabPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
InputStream in = extras.openStream();
RTFEditorKit rtf = new RTFEditorKit();
rtf.read(in, vocabPane.getDocument(), 0);
vocabPane.getCaret().setDot(0);
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (BadLocationException ble) {
ble.printStackTrace();
}
vocabFrame = new JInternalFrame("About the Video", false, false, false, true);
vocabFrame.setContentPane(vocabPanel);
vocabFrame.setVisible(true);
}
videoPanel.add(sp);
videoFrame.setContentPane(videoPanel);
videoFrame.pack();
videoFrame.setMaximumSize(videoFrame.getSize());
textFrame.setContentPane(textPanel);
if (videoFrame.getSize().height < 100) //must be audio file, so frame top to bottom
{
orientation = TOP_TO_BOTTOM;
videoFrame.setTitle("Audio");
videoFrame.setLocation(getSize().width/2 - videoFrame.getSize().width/2, 0);
textFrame.setLocation(0, videoFrame.getSize().height);
if (vocabulary != null)
{
textFrame.setSize(getSize().width / 2, getSize().height - videoFrame.getSize().height);
vocabFrame.setLocation(textFrame.getSize().width, videoFrame.getSize().height);
vocabFrame.setSize(getSize().width - textFrame.getSize().width, getSize().height - videoFrame.getSize().height);
} else
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("Video");
videoFrame.setLocation(0,0);
textFrame.setLocation(videoFrame.getSize().width, 0);
textFrame.setSize(getSize().width - videoFrame.getSize().width, getSize().height);
if (vocabulary != null)
{
vocabFrame.setLocation(0, videoFrame.getSize().height);
vocabFrame.setSize(videoFrame.getSize().width, getSize().height - videoFrame.getSize().height);
}
}
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();
fullScreen.setUndecorated(true);
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();
fullScreen.setExtendedState(Frame.MAXIMIZED_BOTH);
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;
}
}
});
}
removeAll();
setLayout(null);
add(videoFrame, JLayeredPane.POPUP_LAYER);
invalidate();
validate();
repaint();
add(textFrame, JLayeredPane.DEFAULT_LAYER);
invalidate();
validate();
repaint();
if (vocabulary != null)
{
add(vocabFrame, JLayeredPane.DEFAULT_LAYER);
invalidate();
validate();
repaint();
}
}
}}, 0, 50);
}
public void setTranscriptView(TranscriptView view)
{
textPanel.invalidate();
textPanel.remove(tp);
tp.reset();
tp = new TwoWayTextPlayer(sp, view, Color.cyan);
sp.addAnnotationPlayer(tp);
textPanel.add("Center", tp);
textPanel.validate();
textPanel.repaint();
}
}

View file

@ -1,36 +0,0 @@
package org.thdl.savant;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.filechooser.*;
public class SavantFileView extends FileView {
public String getName(File f) {
if (f.isDirectory())
return null;
Properties p = new Properties();
try {
p.load(new FileInputStream(f));
return p.getProperty("TITLE");
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return null;
}
public String getDescription(File f) {
return null;
}
public Boolean isTraversable(File f) {
return null; // let the L&F FileView figure this out
}
public String getTypeDescription(File f) {
return null;
}
/*
public Icon getIcon(File f) {
}
*/
}

View file

@ -1,330 +0,0 @@
package org.thdl.savant;
import java.io.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.text.rtf.*;
import org.thdl.savant.ucuchi.*;
import org.thdl.savant.tib.*;
public class SavantShell extends JFrame
{
private static int numberOfSavantsOpen = 0;
private static JScrollPane helpPane;
private static JScrollPane aboutPane;
private static String mediaPath = null;
private JFileChooser fileChooser;
private javax.swing.filechooser.FileFilter savantFilter;
private Savant savant = null;
public static void main(String[] args) {
try {
java.io.PrintStream ps = new java.io.PrintStream(new java.io.FileOutputStream("savant.log"));
System.setErr(ps);
System.setOut(ps);
}
catch (Exception e) {
}
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {}
RTFEditorKit rtf = new RTFEditorKit();
InputStream in1 = SavantShell.class.getResourceAsStream("savanthelp.rtf");
InputStream in2 = SavantShell.class.getResourceAsStream("aboutsavant.rtf");
DefaultStyledDocument doc1 = new DefaultStyledDocument();
DefaultStyledDocument doc2 = new DefaultStyledDocument();
try {
rtf.read(in1, doc1, 0);
rtf.read(in2, doc2, 0);
} catch (BadLocationException ioe) {
return;
} catch (IOException ioe) {
System.out.println("can't find savanthelp or aboutsavant");
return;
}
JTextPane pane1 = new JTextPane(doc1);
JTextPane pane2 = new JTextPane(doc2);
pane1.setEditable(false);
pane2.setEditable(false);
helpPane = new JScrollPane(pane1);
aboutPane = new JScrollPane(pane2);
SavantShell ssh = new SavantShell();
ssh.setVisible(true);
ssh.initFileChooser();
}
public void initFileChooser() {
fileChooser = new JFileChooser();
fileChooser.setFileView(new SavantFileView());
savantFilter = new SavantFilter();
fileChooser.addChoosableFileFilter(savantFilter);
}
public void setFileChooser(JFileChooser fc) {
fileChooser = fc;
}
private class SavantFilter extends javax.swing.filechooser.FileFilter {
// accepts all directories and all savant files
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String fName = f.getName();
int i = fName.lastIndexOf('.');
if (i < 0)
return false;
else {
String ext = fName.substring(i+1).toLowerCase();
if (ext.equals("savant"))
return true;
else
return false;
}
}
//the description of this filter
public String getDescription() {
return "Savant data (.savant)";
}
}
public SavantShell()
{
setTitle("Savant");
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenuItem openItem = new JMenuItem("Open");
openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,2));
openItem.addActionListener(new ActionListener() {
public void actionPerformed(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();
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
});
JMenuItem closeItem = new JMenuItem("Close");
closeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,2));
closeItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (savant != null)
{
if (numberOfSavantsOpen < 2)
{
savant.close();
savant = null;
getContentPane().removeAll();
setTitle("Savant");
invalidate();
validate();
repaint();
} else {
savant.close();
dispose();
}
numberOfSavantsOpen--;
}
}
});
fileMenu.add(openItem);
fileMenu.add(closeItem);
JMenu infoMenu = new JMenu("Information");
JMenuItem helpItem = new JMenuItem("Help");
helpItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JFrame h = new JFrame("Help");
h.setSize(500,400);
Container c = h.getContentPane();
c.addComponentListener(new ComponentAdapter()
{
public void componentResized(ComponentEvent e)
{
helpPane.setSize(e.getComponent().getSize());
}
});
helpPane.setSize(c.getSize());
c.add(helpPane);
h.setLocation(100,100);
h.setVisible(true);
}
});
JMenuItem aboutItem = new JMenuItem("About");
aboutItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JFrame h = new JFrame("About");
h.setSize(500,400);
Container c = h.getContentPane();
c.addComponentListener(new ComponentAdapter()
{
public void componentResized(ComponentEvent e)
{
aboutPane.setSize(e.getComponent().getSize());
}
});
aboutPane.setSize(c.getSize());
c.add(aboutPane);
h.setLocation(100,100);
h.setVisible(true);
}
});
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(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 (getToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH))
{
setLocation(0,0);
setSize(getToolkit().getScreenSize().width,getToolkit().getScreenSize().height);
setVisible(true);
setExtendedState(Frame.MAXIMIZED_BOTH);
} else {
Dimension gs = getToolkit().getScreenSize();
setLocation(0,0);
setSize(new Dimension(gs.width, gs.height));
setVisible(true);
}
/* Code for JDK 1.3, including Mac OS X
Dimension gs = g.getToolkit().getScreenSize();
g.setLocation(0,0);
g.setSize(new Dimension(gs.width, gs.height));
*/
}
public void newSavantWindow(String project, String titleName, URL trn, URL vid, URL abt)
{
if (numberOfSavantsOpen == 0)
openSavant(project, titleName, trn, vid, abt);
else {
SavantShell scp = new SavantShell();
scp.setVisible(true);
scp.openSavant(project, titleName, trn, vid, abt);
scp.setFileChooser(fileChooser);
}
numberOfSavantsOpen++;
}
public void openSavant(String project, String titleName, URL trn, URL vid, URL abt)
{
setTitle(titleName);
savant = new Savant();
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")) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String fonts[] = ge.getAvailableFontFamilyNames();
int i=0;
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 visit www.thdl.org to download and "+
"install the Tibetan Machine Web fonts.",
"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,458 +0,0 @@
/*-----------------------------------------------------------------------*/
package org.thdl.savant;
import java.util.*;
import java.net.*;
import javax.media.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
/*-----------------------------------------------------------------------*/
public class SoundPanel extends Panel implements ControllerListener
{
private EventListenerList listenerList = new EventListenerList();
public URL mediaURL;
private Vector orderStartID, orderEndID;
private Stack pileStart, pileEnd;
private Hashtable hashStart, hashEnd;
private Player player = null;
private Component visualComponent = null;
private Component controlComponent = null;
private Panel panel = null;
private JPanel vPanel = null;
private Container parent = null;
private java.util.Timer timer = null;
private Time stopTime = null;
private Time pauseTime = null;
private boolean stillLoadingVideo = false;
private boolean isMediaAudio = false;
private boolean isSized = false;
private Float to = null;
/*-----------------------------------------------------------------------*/
public SoundPanel(Container p, URL sound, String starts, String ends, String ids) {
parent = p;
System.out.println("soundpanel - "+sound.toString());
mediaURL = sound;
String TAB_STARTS = starts;
String TAB_ENDS = ends;
String TAB_IDS = ids;
hashStart = new Hashtable();
hashEnd = new Hashtable();
pileStart = new Stack();
pileEnd = new Stack();
StringTokenizer stIDS = new StringTokenizer(TAB_IDS, ",");
StringTokenizer stSTARTS = new StringTokenizer(TAB_STARTS, ",");
StringTokenizer stENDS = new StringTokenizer(TAB_ENDS, ",");
while ((stIDS.hasMoreTokens()) && (stSTARTS.hasMoreTokens()) && (stENDS.hasMoreTokens())) {
String sID = stIDS.nextToken();
String sStart = stSTARTS.nextToken();
String sEnd = stENDS.nextToken();
try {
Float start = new Float(sStart);
hashStart.put(sID, start);
} catch (NumberFormatException err) {
hashStart.put(sID, new Float(0));
}
try {
Float end = new Float(sEnd);
hashEnd.put(sID, end);
} catch (NumberFormatException err) {
hashEnd.put(sID, new Float(0));
}
}
Vector saveOrder = new Vector();
for (Enumeration e = hashStart.keys() ; e.hasMoreElements() ;) {
Object o = e.nextElement();
saveOrder.addElement(o);
}
orderStartID = new Vector();
while (saveOrder.size() > 0) {
int num = getMinusStart(saveOrder);
orderStartID.addElement(saveOrder.elementAt(num));
saveOrder.removeElementAt(num);
}
saveOrder = new Vector();
for (Enumeration e = hashEnd.keys() ; e.hasMoreElements() ;) {
Object o = e.nextElement();
saveOrder.addElement(o);
}
orderEndID = new Vector();
while (saveOrder.size() > 0) {
int num = getMinusEnd(saveOrder);
orderEndID.addElement(saveOrder.elementAt(num));
saveOrder.removeElementAt(num);
}
}
public void destroy() {
player.close();
}
public void stop() {
player.stop();
player.deallocate();
}
public void start() {
openPlayer();
}
private int getMinusStart(Vector v) {
int index = 0;
String first = (String)v.elementAt(index);
Float minus = (Float)hashStart.get(first);
for (int i=0;i<v.size();i++) {
String s = (String)v.elementAt(i);
Float f = (Float)hashStart.get(s);
if (minus.floatValue() > f.floatValue()) {
minus = f;
index = i;
}
}
return index;
}
private int getMinusEnd(Vector v) {
int index = 0;
String first = (String)v.elementAt(index);
Float minus = (Float)hashEnd.get(first);
for (int i=0;i<v.size();i++) {
String s = (String)v.elementAt(i);
Float f = (Float)hashEnd.get(s);
if (minus.floatValue() > f.floatValue()) {
minus = f;
index = i;
}
}
return index;
}
public void addAnnotationPlayer(AnnotationPlayer ap)
{
listenerList.add(AnnotationPlayer.class, ap);
}
public void removeAnnotationPlayer(AnnotationPlayer ap)
{
listenerList.remove(AnnotationPlayer.class, ap);
}
public Component popVisualComponent()
{
vPanel.remove(visualComponent);
invalidate();
validate();
repaint();
return visualComponent;
}
public void restoreVisualComponent()
{
vPanel.add("Center", visualComponent);
invalidate();
validate();
repaint();
}
public Component getVisualComponent()
{
return visualComponent;
}
public Component getControlComponent()
{
return controlComponent;
}
/*-----------------------------------------------------------------------*/
public boolean cmd_isSized() {
return isSized;
}
public boolean cmd_isRealized() {
return player.getState() == Controller.Realized;
}
public String cmd_firstS() {
return (String)orderStartID.elementAt(0);
}
public boolean cmd_stop() {
if (player == null)
return false;
try {
player.stop();
return true;
} catch (NotRealizedError err) {
System.out.println("NotRealizedError");
return false;
}
}
public boolean cmd_isID(String theID) {
System.out.println(hashStart.containsKey(theID));
return hashStart.containsKey(theID);
}
public boolean cmd_playFrom(String fromID) {
if (stillLoadingVideo)
return false;
Float from = (Float)hashStart.get(fromID);
// String toID = (String)orderEndID.elementAt(orderEndID.size()-1);
// Float to = (Float)hashEnd.get(toID);
if (play(from, null))
return true;
else
return false;
}
public boolean cmd_playS(String fromID) {
if (stillLoadingVideo)
return false;
Float from = (Float)hashStart.get(fromID);
Float to = (Float)hashEnd.get(fromID);
if (play(from, to))
return true;
else
return false;
}
public void cmd_nextEvent() {
Float when = new Float(when());
if (!pileStart.empty()) {
String id = (String)pileStart.peek();
Float f = (Float)hashStart.get(id);
if (when.floatValue() >= f.floatValue()) {
id = (String)pileStart.pop();
fireStartAnnotation(id);
}
}
if (!pileEnd.empty()) {
String id = (String)pileEnd.peek();
Float f = (Float)hashEnd.get(id);
if (when.floatValue() >= f.floatValue()) {
id = (String)pileEnd.pop();
fireStopAnnotation(id);
}
}
}
/*-----------------------------------------------------------------------*/
private void vide_Pile() {
while (!pileEnd.empty()) { //vider la pile des items qui ne sont pas
String id = (String)pileEnd.pop(); //encore fini
if (pileStart.search(id) == -1) {
fireStopAnnotation(id);
}
}
}
private void remplisPileStart(Float start, Float end) {
vide_Pile();
pileStart.removeAllElements();
pileEnd.removeAllElements();
for (int i=orderEndID.size()-1; i!=-1; i--) {
String id = (String)orderEndID.elementAt(i);
Float f = (Float)hashEnd.get(id);
if ((f.floatValue() > start.floatValue()) && (f.floatValue() <= end.floatValue())) {
pileEnd.push(id);
}
}
for (int i=orderStartID.size()-1; i!=-1; i--) {
String id = (String)orderStartID.elementAt(i);
Float f = (Float)hashStart.get(id);
if ((f.floatValue() >= start.floatValue()) && (f.floatValue() < end.floatValue())) {
pileStart.push(id);
}
}
}
private void fireStartAnnotation(String id)
{
//see javadocs on EventListenerList for how following array is structured
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2)
{
if (listeners[i]==AnnotationPlayer.class)
((AnnotationPlayer)listeners[i+1]).startAnnotation(id);
}
}
private void fireStopAnnotation(String id)
{
//see javadocs on EventListenerList for how following array is structured
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2)
{
if (listeners[i]==AnnotationPlayer.class)
((AnnotationPlayer)listeners[i+1]).stopAnnotation(id);
}
}
/*-----------------------------------------------------------------------*/
private String when() {
if (player == null)
return "-1";
if (player.getState() != Controller.Started)
return "-1";
long currTime = player.getMediaNanoseconds();
Float time = new Float(currTime);
float f = (time.floatValue() / 1000000000);
return Float.toString(f);
}
private boolean play(Float from, Float to) {
if (player == null)
return false;
final Time startTime = new Time((long)(from.floatValue() * 1000000000));
try {
if (player.getState() == Controller.Started)
player.stop();
while (player.getState() == Controller.Unrealized)
;
// player.stop();
if (to == null) {
stopTime = null;
player.setStopTime(Clock.RESET);
} else {
stopTime = new Time((long)(to.floatValue() * 1000000000));
player.setStopTime(stopTime);
}
player.setMediaTime(startTime);
player.prefetch();
player.start();
return true;
} catch(NotRealizedError err) {
System.out.println("NotRealizedError");
return false;
}
}
/*-----------------------------------------------------------------------*/
public void openPlayer() {
try {
player = Manager.createPlayer(mediaURL);
player.addControllerListener(this);
} catch (javax.media.NoPlayerException e) {
System.err.println("noplayer exception");
e.printStackTrace();
return;
} catch (java.io.IOException ex) {
System.err.println("IO exception");
ex.printStackTrace();
return;
}
if (player != null)
player.realize();
}
public synchronized void controllerUpdate(ControllerEvent event) {
if (player == null)
return;
if (event instanceof RealizeCompleteEvent) {
System.out.println("received RealizeCompleteEvent event");
if (visualComponent == null) {
if (panel == null) {
setLayout(new GridLayout(1,1));
vPanel = new JPanel();
vPanel.setLayout( new BorderLayout() );
if ((visualComponent = player.getVisualComponent())!= null)
vPanel.add("Center", visualComponent);
else {
isMediaAudio = true;
stillLoadingVideo = false;
}
if (!stillLoadingVideo)
{
if ((controlComponent = player.getControlPanelComponent()) != null) {
if (visualComponent == null) //no video
vPanel.setPreferredSize(new Dimension(400,25));
vPanel.add("South", controlComponent);
}
}
add(vPanel);
}
}
parent.invalidate();
parent.validate();
parent.repaint();
isSized = true;
if (stillLoadingVideo)
player.start();
} else if (event instanceof StartEvent) {
StartEvent se = (StartEvent)event;
Time t = se.getMediaTime();
long longt = t.getNanoseconds();
Float from = new Float(longt);
float f = (from.floatValue() / 1000000000);
from = new Float(f);
t = player.getStopTime();
longt = t.getNanoseconds();
to = new Float(longt);
f = (to.floatValue() / 1000000000);
to = new Float(f);
remplisPileStart(from, to);
if (timer != null)
{
timer.cancel();
timer = null;
}
timer = new java.util.Timer(true);
timer.schedule(new TimerTask() {
public void run() {
//this is specifically for the MPG stop time bug
if (stopTime != null)
if (player.getMediaTime().getNanoseconds() > stopTime.getNanoseconds())
player.stop();
cmd_nextEvent();
}}, 0, 15);
} else if (event instanceof StopEvent) {
pauseTime = player.getMediaTime();
/*messy problems require messy solutions:
if the slider is present, dragging it while playing creates
a RestartingEvent, and if I set the media time here it messes up
and barely plays at all (maybe because it cancels the previously
set media time? - I don't know).
but it seems that if you press the play/pause button on the
control widget, then you need to set the media time upon stop
(probably because of problem noted below, namely that you get
weird results if you do player.start() without setting the media
time.*/
if (!(event instanceof RestartingEvent))
player.setMediaTime(pauseTime);
stopTime = null;
System.out.println("received StopEvent");
if (timer != null)
{
timer.cancel();
timer = null;
}
if (stillLoadingVideo)
{
System.out.println("received EndOfMediaEvent");
stillLoadingVideo = false;
player.stop();
if ((controlComponent = player.getControlPanelComponent()) != null) {
if (visualComponent == null) //no video
vPanel.setPreferredSize(new Dimension(400,25));
vPanel.add("South", controlComponent);
}
parent.invalidate();
parent.validate();
parent.repaint();
}
} else if ( event instanceof CachingControlEvent) {
CachingControlEvent e = (CachingControlEvent) event;
System.out.println("got CachingControlEvent: " + e);
if (!isMediaAudio)
stillLoadingVideo = true;
} else if (event instanceof ControllerErrorEvent) {
player = null;
System.err.println("*** ControllerErrorEvent *** " + ((ControllerErrorEvent)event).getMessage());
} else if (event instanceof PrefetchCompleteEvent) {
if (panel != null) {
panel.invalidate();
}
parent.invalidate();
parent.validate();
parent.repaint();
}
}
};

View file

@ -1,104 +0,0 @@
package org.thdl.savant;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.event.MouseListener;
public class TextHighlightPlayer extends JPanel implements AnnotationPlayer
{
protected JTextComponent text;
protected Hashtable hashStart, hashEnd, highlights;
protected Highlighter highlighter;
protected Highlighter.HighlightPainter highlightPainter;
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);
try
{
Rectangle rect = text.modelToView(end);
text.scrollRectToVisible(rect);
text.repaint();
} catch (BadLocationException ble) {}
}
catch (BadLocationException ble)
{
ble.printStackTrace();
}
}
private void unhighlight(String id)
{
if (highlights.containsKey(id))
{
highlighter.removeHighlight(highlights.get(id));
highlights.remove(id);
}
}
}

View file

@ -1,93 +0,0 @@
package org.thdl.savant;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
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();
}
}
private void unhighlight(String id)
{
if (highlights.containsKey(id))
{
highlighter.removeHighlight(highlights.get(id));
highlights.remove(id);
}
}
}

View file

@ -1,13 +0,0 @@
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,106 +0,0 @@
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;
public class TwoWayTextPlayer extends TextHighlightPlayer
{
protected TreeMap orderedOffsets = null;
protected SoundPanel sound = null;
protected long doubleClickDelay = 300L;
protected long lastClickTime;
protected Point lastClickPoint = null;
public TwoWayTextPlayer(SoundPanel 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();
}
}
});
}
public void reset()
{
sound.removeAnnotationPlayer(this);
highlighter.removeAllHighlights();
}
public JTextComponent getTextComponent()
{
return text;
}
}

View file

@ -1,196 +0,0 @@
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.*;
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();
}
}
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();
}
}
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,205 +0,0 @@
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.*;
public class Tibetan 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 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();
}
}
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;
TibetanDocument.DuffData[] dd;
TibetanDocument doc = new TibetanDocument(new StyleContext());
TibetanDocument.DuffData[] space = TibetanDocument.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 = TibetanDocument.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 = TibetanDocument.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 = TibetanDocument.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 = TibetanDocument.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 JTextPane(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
}
catch (InvalidWylieException iwe)
{
iwe.printStackTrace();
}
}
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,213 +0,0 @@
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.*;
public class TibetanEnglish 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 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();
}
}
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;
TibetanDocument.DuffData[] dd;
TibetanDocument.DuffData[] space = TibetanDocument.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 = TibetanDocument.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 = TibetanDocument.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 JTextPane(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
}
catch (InvalidWylieException iwe)
{
iwe.printStackTrace();
}
}
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,216 +0,0 @@
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.*;
public class TibetanWylie 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 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();
}
}
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;
TibetanDocument.DuffData[] dd;
TibetanDocument.DuffData[] space = TibetanDocument.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 = TibetanDocument.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 = TibetanDocument.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 JTextPane(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
}
catch (InvalidWylieException iwe)
{
iwe.printStackTrace();
}
}
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 @@
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.*;
public class TibetanWylieEnglish 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 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();
}
}
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;
TibetanDocument.DuffData[] dd;
TibetanDocument.DuffData[] space = TibetanDocument.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 = TibetanDocument.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 = TibetanDocument.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 JTextPane(doc);
idBuffer.toString();
t1Buffer.toString();
t2Buffer.toString();
startBuffer.toString();
endBuffer.toString();
}
catch (BadLocationException ble)
{
ble.printStackTrace();
}
catch (InvalidWylieException iwe)
{
iwe.printStackTrace();
}
}
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,196 +0,0 @@
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.*;
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();
}
}
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;
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
{
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();
}
}
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,209 +0,0 @@
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.*;
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();
}
}
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;
TibetanDocument.DuffData[] dd;
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();
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();
}
}
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,225 +0,0 @@
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.*;
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();
}
}
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;
int wherestart;
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();
}
}
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,196 +0,0 @@
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.*;
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();
}
}
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();
}
}
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,195 +0,0 @@
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.*;
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();
}
}
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();
}
}
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 @@
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.*;
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();
}
}
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;
int wherestart;
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();
}
}
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 @@
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.*;
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();
}
}
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();
}
}
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();
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,932 +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.tib.input;
import java.io.*;
import java.net.URL;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import javax.swing.plaf.basic.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.text.rtf.*;
import org.thdl.tib.text.*;
/**
* A simple Tibetan text editor. Jskad editors lack most of the
* functionality of a word-processor, but they do provide
* multiple keyboard input methods, as well as
* conversion routines to go back and forth between Extended
* Wylie and TibetanMachineWeb.
* <p>
* Jskad embeds {@link DuffPane DuffPane}, which is the editing
* window where the keyboard logic and most functionality is housed.
* <p>
* Depending on the object passed to the constructor,
* a Jskad object can be used in either an application or an
* applet.
* @author Edward Garrett, Tibetan and Himalayan Digital Library
* @version 1.0
*/
public class Jskad extends JPanel implements DocumentListener {
private String fontName = "";
private JComboBox fontFamilies, fontSizes;
private JFileChooser fileChooser;
private javax.swing.filechooser.FileFilter rtfFilter;
private javax.swing.filechooser.FileFilter txtFilter;
private int fontSize = 0;
private Object parentObject = null;
private static int numberOfTibsRTFOpen = 0;
private static int x_size;
private static int y_size;
private TibetanKeyboard sambhota1Keyboard = null, duff1Keyboard = null, duff2Keyboard = null;
/**
* The text editing window which this Jskad object embeds.
*/
public DuffPane dp;
/**
* Has the document been saved since it was last changed?
*/
public boolean hasChanged = false;
/**
* The filename, if any, associated with this instance of Jskad.
*/
public String fileName = null;
/**
* @param parent the object that embeds this instance of Jskad.
* Supported objects include JFrames and JApplets. If the parent
* is a JApplet then the File menu is omitted from the menu bar.
*/
public Jskad(final Object parent) {
parentObject = parent;
numberOfTibsRTFOpen++;
JMenuBar menuBar = new JMenuBar();
if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) {
fileChooser = new JFileChooser();
rtfFilter = new RTFFilter();
txtFilter = new TXTFilter();
fileChooser.addChoosableFileFilter(rtfFilter);
JMenu fileMenu = new JMenu("File");
JMenuItem newItem = new JMenuItem("New");
// newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,2)); //Ctrl-n
newItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
newFile();
}
});
fileMenu.add(newItem);
JMenuItem openItem = new JMenuItem("Open");
// openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,2)); //Ctrl-o
openItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openFile();
}
});
fileMenu.add(openItem);
if (parentObject instanceof JFrame) {
JMenuItem closeItem = new JMenuItem("Close");
closeItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!hasChanged || hasChanged && checkSave()) {
numberOfTibsRTFOpen--;
if (numberOfTibsRTFOpen == 0)
System.exit(0);
else {
final JFrame parentFrame = (JFrame)parentObject;
parentFrame.dispose();
}
}
}
});
fileMenu.add(closeItem);
}
JMenuItem saveItem = new JMenuItem("Save");
// saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,2)); //Ctrl-s
saveItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (fileName == null)
saveAsFile();
else
saveFile();
}
});
fileMenu.addSeparator();
fileMenu.add(saveItem);
JMenuItem saveAsItem = new JMenuItem("Save as");
saveAsItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
saveAsFile();
}
});
fileMenu.add(saveAsItem);
menuBar.add(fileMenu);
}
JMenu editMenu = new JMenu("Edit");
if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) {
JMenuItem cutItem = new JMenuItem("Cut");
cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,2)); //Ctrl-x
cutItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cutSelection();
}
});
editMenu.add(cutItem);
JMenuItem copyItem = new JMenuItem("Copy");
copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,2)); //Ctrl-c
copyItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
copySelection();
}
});
editMenu.add(copyItem);
JMenuItem pasteItem = new JMenuItem("Paste");
pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,2)); //Ctrl-v
pasteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
pasteSelection();
}
});
editMenu.add(pasteItem);
editMenu.addSeparator();
JMenuItem selectallItem = new JMenuItem("Select All");
selectallItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,2)); //Ctrl-a
selectallItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dp.setSelectionStart(0);
dp.setSelectionEnd(dp.getDocument().getLength());
}
});
editMenu.add(selectallItem);
}
JMenuItem preferencesItem = new JMenuItem("Preferences");
preferencesItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
getPreferences();
}
});
editMenu.addSeparator();
editMenu.add(preferencesItem);
menuBar.add(editMenu);
JMenu toolsMenu = new JMenu("Tools");
JMenuItem TMWWylieItem = new JMenuItem("Convert Tibetan to Wylie");
TMWWylieItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
toWylie();
}
});
toolsMenu.add(TMWWylieItem);
JMenuItem wylieTMWItem = new JMenuItem("Convert Wylie to Tibetan");
wylieTMWItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
toTibetan();
}
});
toolsMenu.add(wylieTMWItem);
if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) {
JMenuItem importItem = new JMenuItem("Import Wylie as Tibetan");
importItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
importWylie();
}
});
toolsMenu.addSeparator();
toolsMenu.add(importItem);
}
menuBar.add(toolsMenu);
JMenu infoMenu = new JMenu("Info");
JMenuItem aboutItem = new JMenuItem("About");
aboutItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(Jskad.this,
"Copyright 2001 Tibetan and Himalayan Digital Library\n"+
"Programmed by Edward Garrett\n\n"+
"This software is protected by the terms of the\n"+
"THDL Open Community License, Version 1.0.\n"+
"It uses Tibetan Computer Company (http://www.tibet.dk/tcc/)\n"+
"fonts created by Tony Duff and made available by the\n"+
"Trace Foundation (http://trace.org/). Jskad also includes\n"+
"software written and copyrighted by Wildcrest Associates\n"+
"(http://www.wildcrest.com).\n\n"+
"For more information, or to download the source code\n"+
"for Jskad, see our web site:\n"+
" http://www.thdl.org/",
"About Jskad 1.0",
JOptionPane.PLAIN_MESSAGE);
}
});
infoMenu.add(aboutItem);
menuBar.add(infoMenu);
JToolBar toolBar = new JToolBar();
toolBar.setBorder(null);
toolBar.addSeparator();
toolBar.add(new JLabel("Input mode:"));
toolBar.addSeparator();
String[] input_modes = {"Tibetan","Roman"};
final JComboBox inputmethods = new JComboBox(input_modes);
inputmethods.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switch (inputmethods.getSelectedIndex()) {
case 0: //Tibetan
if (dp.isRomanMode())
dp.toggleLanguage();
break;
case 1: //Roman
if (!dp.isRomanMode() && dp.isRomanEnabled())
dp.toggleLanguage();
break;
}
}
});
toolBar.add(inputmethods);
toolBar.add(Box.createHorizontalGlue());
toolBar.add(new JLabel("Keyboard:"));
toolBar.addSeparator();
String[] keyboard_options = {"Extended Wylie","TCC Keyboard #1","TCC Keyboard #2","Sambhota Keymap One"};
final JComboBox keyboards = new JComboBox(keyboard_options);
keyboards.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switch (keyboards.getSelectedIndex()) {
case 0: //Extended Wylie
installKeyboard("wylie");
break;
case 1: //TCC 1
if (duff1Keyboard == null)
duff1Keyboard = installKeyboard("tcc1");
else
dp.registerKeyboard(duff1Keyboard);
break;
case 2: //TCC 2
if (duff2Keyboard == null)
duff2Keyboard = installKeyboard("tcc2");
else
dp.registerKeyboard(duff2Keyboard);
break;
case 3: //Sambhota
if (sambhota1Keyboard == null)
sambhota1Keyboard = installKeyboard("sambhota1");
else
dp.registerKeyboard(sambhota1Keyboard);
break;
}
}
});
toolBar.add(keyboards);
toolBar.add(Box.createHorizontalGlue());
dp = new DuffPane();
JScrollPane sp = new JScrollPane(dp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
dp.getDocument().addDocumentListener(this);
if (parentObject instanceof JFrame) {
final JFrame parentFrame = (JFrame)parentObject;
parentFrame.setJMenuBar(menuBar);
parentFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
parentFrame.addWindowListener(new WindowAdapter () {
public void windowClosing (WindowEvent e) {
if (!hasChanged || hasChanged && checkSave()) {
numberOfTibsRTFOpen--;
if (numberOfTibsRTFOpen == 0)
System.exit(0);
else
parentFrame.dispose();
}
}
});
}
else if (parentObject instanceof JInternalFrame) {
final JInternalFrame parentFrame = (JInternalFrame)parentObject;
parentFrame.setJMenuBar(menuBar);
}
else if (parentObject instanceof JApplet) {
JApplet parentApplet = (JApplet)parentObject;
parentApplet.setJMenuBar(menuBar);
dp.disableCutAndPaste();
}
setLayout(new BorderLayout());
add("North", toolBar);
add("Center", sp);
}
private void getPreferences() {
GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontNames = genv.getAvailableFontFamilyNames();
JPanel tibetanPanel;
JComboBox tibetanFontSizes;
tibetanPanel = new JPanel();
tibetanPanel.setBorder(BorderFactory.createTitledBorder("Set Tibetan Font Size"));
tibetanFontSizes = new JComboBox(new String[] {"8","10","12","14","16","18","20","22","24","26","28","30","32","34","36","48","72"});
tibetanFontSizes.setMaximumSize(tibetanFontSizes.getPreferredSize());
tibetanFontSizes.setSelectedItem(String.valueOf(dp.getTibetanFontSize()));
tibetanFontSizes.setEditable(true);
tibetanPanel.add(tibetanFontSizes);
JPanel romanPanel;
JComboBox romanFontFamilies;
JComboBox romanFontSizes;
romanPanel = new JPanel();
romanPanel.setBorder(BorderFactory.createTitledBorder("Set non-Tibetan Font and Size"));
romanFontFamilies = new JComboBox(fontNames);
romanFontFamilies.setMaximumSize(romanFontFamilies.getPreferredSize());
romanFontFamilies.setSelectedItem(dp.getRomanFontFamily());
romanFontFamilies.setEditable(true);
romanFontSizes = new JComboBox(new String[] {"8","10","12","14","16","18","20","22","24","26","28","30","32","34","36","48","72"});
romanFontSizes.setMaximumSize(romanFontSizes.getPreferredSize());
romanFontSizes.setSelectedItem(String.valueOf(dp.getRomanFontSize()));
romanFontSizes.setEditable(true);
romanPanel.setLayout(new GridLayout(1,2));
romanPanel.add(romanFontFamilies);
romanPanel.add(romanFontSizes);
JPanel preferencesPanel = new JPanel();
preferencesPanel.setLayout(new GridLayout(2,1));
preferencesPanel.add(tibetanPanel);
preferencesPanel.add(romanPanel);
JOptionPane pane = new JOptionPane(preferencesPanel);
JDialog dialog = pane.createDialog(this, "Preferences");
dialog.show();
int size;
try {
size = Integer.parseInt(tibetanFontSizes.getSelectedItem().toString());
}
catch (NumberFormatException ne) {
size = dp.getTibetanFontSize();
}
dp.setTibetanFontSize(size);
String font = romanFontFamilies.getSelectedItem().toString();
try {
size = Integer.parseInt(romanFontSizes.getSelectedItem().toString());
}
catch (NumberFormatException ne) {
size = dp.getRomanFontSize();
}
dp.setRomanAttributeSet(font, size);
}
private void newFile() {
if (dp.getDocument().getLength()>0 && parentObject instanceof JFrame) {
JFrame parentFrame = (JFrame)parentObject;
JFrame newFrame = new JFrame("Jskad");
Point point = parentFrame.getLocationOnScreen();
newFrame.setSize(parentFrame.getSize().width, parentFrame.getSize().height);
newFrame.setLocation(point.x+50, point.y+50);
newFrame.getContentPane().add(new Jskad(newFrame));
newFrame.setVisible(true);
}
else {
if (parentObject instanceof JFrame) {
JFrame parentFrame = (JFrame)parentObject;
parentFrame.setTitle("Jskad");
}
else if (parentObject instanceof JInternalFrame) {
JInternalFrame parentFrame = (JInternalFrame)parentObject;
parentFrame.setTitle("Jskad");
}
dp.newDocument();
dp.getDocument().addDocumentListener(Jskad.this);
hasChanged = false;
}
}
private void openFile() {
fileChooser = new JFileChooser();
fileChooser.addChoosableFileFilter(rtfFilter);
if (dp.getDocument().getLength()>0 && parentObject instanceof JFrame) {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
if (fileChooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
return;
}
final File fileChosen = fileChooser.getSelectedFile();
final String f_name = fileChosen.getAbsolutePath();
try {
JFrame parentFrame = (JFrame)parentObject;
InputStream in = new FileInputStream(fileChosen);
JFrame newFrame = new JFrame(f_name);
Point point = parentFrame.getLocationOnScreen();
newFrame.setSize(x_size, y_size);
newFrame.setLocation(point.x+50, point.y+50);
Jskad newRTF = new Jskad(newFrame);
newFrame.getContentPane().add(newRTF);
newRTF.dp.rtfEd.read(in, newRTF.dp.getDocument(), 0);
newRTF.dp.getDocument().addDocumentListener(newRTF);
in.close();
newFrame.setTitle(f_name);
newRTF.fileName = new String(f_name);
newRTF.hasChanged = false;
newRTF.dp.getCaret().setDot(0);
newFrame.setVisible(true);
}
catch (FileNotFoundException fnfe) {
}
catch (IOException ioe) {
}
catch (BadLocationException ble) {
}
}
else {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
if (fileChooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
return;
}
final File fileChosen = fileChooser.getSelectedFile();
final String f_name = fileChosen.getAbsolutePath();
try {
InputStream in = new FileInputStream(fileChosen);
dp.newDocument();
dp.rtfEd.read(in, dp.getDocument(), 0);
in.close();
dp.getCaret().setDot(0);
dp.getDocument().addDocumentListener(Jskad.this);
hasChanged = false;
fileName = new String(f_name);
if (parentObject instanceof JFrame) {
JFrame parentFrame = (JFrame)parentObject;
parentFrame.setTitle(fileName);
}
else if (parentObject instanceof JInternalFrame) {
JInternalFrame parentFrame = (JInternalFrame)parentObject;
parentFrame.setTitle(fileName);
}
}
catch (FileNotFoundException fnfe) {
}
catch (IOException ioe) {
}
catch (BadLocationException ble) {
}
}
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
private void saveFile() {
String s = getSave(fileName);
if (null != s) {
if (parentObject instanceof JFrame) {
JFrame parentFrame = (JFrame)parentObject;
parentFrame.setTitle(s);
fileName = new String(s);
}
else if (parentObject instanceof JInternalFrame) {
JInternalFrame parentFrame = (JInternalFrame)parentObject;
parentFrame.setTitle(s);
fileName = new String(s);
}
}
}
private void saveAsFile() {
String s = getSaveAs();
if (null != s) {
if (parentObject instanceof JFrame) {
JFrame parentFrame = (JFrame)parentObject;
parentFrame.setTitle(s);
fileName = new String(s);
}
else if (parentObject instanceof JInternalFrame) {
JInternalFrame parentFrame = (JInternalFrame)parentObject;
parentFrame.setTitle(s);
fileName = new String(s);
}
}
}
private boolean checkSave() {
int saveFirst = JOptionPane.showConfirmDialog(this, "Do you want to save your changes?", "Please select", JOptionPane.YES_NO_CANCEL_OPTION);
switch (saveFirst) {
case JOptionPane.NO_OPTION: //don't save but do continue
return true;
case JOptionPane.YES_OPTION: //save and continue
if (fileName == null) {
saveAsFile();
}
else
saveFile();
return true;
default:
return false;
}
}
private String getSave(String f_name) {
File fileChosen = new File(f_name);
try {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fileChosen));
dp.rtfEd.write(out, dp.getDocument(), 0, dp.getDocument().getLength());
out.flush();
out.close();
hasChanged = false;
} catch (IOException exception) {
exception.printStackTrace();
return null;
} catch (BadLocationException ble) {
ble.printStackTrace();
}
return f_name;
}
private String getSaveAs() {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
if (fileName == null)
fileChooser.setSelectedFile(null);
else
fileChooser.setSelectedFile(new File(fileName));
if (fileChooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
return null;
}
File fileChosen = fileChooser.getSelectedFile();
String fileName = fileChosen.getAbsolutePath();
int i = fileName.lastIndexOf('.');
if (i < 0)
fileName += ".rtf";
else
fileName = fileName.substring(0, i) + ".rtf";
getSave(fileName);
fileChooser.rescanCurrentDirectory();
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
return fileName;
}
private void cutSelection() {
dp.copy(dp.getSelectionStart(), dp.getSelectionEnd(), true);
}
private void copySelection() {
dp.copy(dp.getSelectionStart(), dp.getSelectionEnd(), false);
}
private void pasteSelection() {
dp.paste(dp.getCaret().getDot());
}
private void toTibetan() {
Jskad.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
dp.toTibetanMachineWeb();
Jskad.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
private void toWylie() {
Jskad.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
dp.toWylie(dp.getSelectionStart(), dp.getSelectionEnd());
Jskad.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
private void importWylie() {
fileChooser.removeChoosableFileFilter(rtfFilter);
fileChooser.addChoosableFileFilter(txtFilter);
if (fileChooser.showDialog(Jskad.this, "Import Wylie") != JFileChooser.APPROVE_OPTION) {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
fileChooser.removeChoosableFileFilter(txtFilter);
fileChooser.addChoosableFileFilter(rtfFilter);
return;
}
File txt_fileChosen = fileChooser.getSelectedFile();
fileChooser.rescanCurrentDirectory();
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
fileChooser.removeChoosableFileFilter(txtFilter);
fileChooser.addChoosableFileFilter(rtfFilter);
if (fileChooser.showDialog(Jskad.this, "Save as Tibetan") != JFileChooser.APPROVE_OPTION) {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
return;
}
File rtf_fileChosen = fileChooser.getSelectedFile();
fileChooser.rescanCurrentDirectory();
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
String rtf_fileName = rtf_fileChosen.getAbsolutePath();
int i = rtf_fileName.lastIndexOf('.');
if (i < 0)
rtf_fileName += ".rtf";
else
rtf_fileName = fileName.substring(0, i) + ".rtf";
try {
BufferedReader in = new BufferedReader(new FileReader(txt_fileChosen));
DuffPane dp2 = new DuffPane();
try {
String val = in.readLine();
while (val != null) {
dp2.toTibetanMachineWeb(val + "\n", dp2.getCaret().getDot());
val = in.readLine();
}
TibetanDocument t_doc = (TibetanDocument)dp2.getDocument();
t_doc.writeRTFOutputStream(new FileOutputStream(new File(rtf_fileName)));
}
catch (IOException ioe) {
System.out.println("problem reading or writing file");
}
}
catch (FileNotFoundException fnfe) {
System.out.println("problem reading file");
}
}
private TibetanKeyboard installKeyboard(String name) {
TibetanKeyboard tk = null;
if (!name.equalsIgnoreCase("wylie")) {
URL keyboard_url = null;
if (name.equalsIgnoreCase("sambhota1"))
keyboard_url = TibetanMachineWeb.class.getResource("sambhota_keyboard_1.ini");
else if (name.equalsIgnoreCase("tcc1"))
keyboard_url = TibetanMachineWeb.class.getResource("tcc_keyboard_1.ini");
else if (name.equalsIgnoreCase("tcc2"))
keyboard_url = TibetanMachineWeb.class.getResource("tcc_keyboard_2.ini");
if (null != keyboard_url) {
try {
tk = new TibetanKeyboard(keyboard_url);
}
catch (TibetanKeyboard.InvalidKeyboardException ike) {
System.out.println("invalid keyboard file or file not found");
return null;
}
}
else
return null;
}
dp.registerKeyboard(tk);
return tk;
}
/**
* Allows use of Jskad as dependent JFrame.
* Once you've called this method, users will
* be able to close Jskad without shutting
* down your superordinate application.
*/
public void makeDependent() {
numberOfTibsRTFOpen++;
}
/**
* Fills the editing pane with content. If the
* editing pane already has content, this method does nothing.
*
* @param wylie the string of wylie you want to
* put in the editing pane
*/
public void setContent(String wylie) {
if (dp.getDocument().getLength() > 0)
return;
dp.newDocument();
dp.toTibetanMachineWeb(wylie, 0);
}
/**
* Enables typing of Roman (non-Tibetan) text along
* with Tibetan.
*/
public void enableRoman() {
dp.enableRoman();
}
/**
* Disables typing of Roman (non-Tibetan) text.
*/
public void disableRoman() {
dp.disableRoman();
}
/*
private void showAttributes(int pos) {
dp.skipUpdate = true;
AttributeSet attr = dp.getDocument().getCharacterElement(pos).getAttributes();
String name = StyleConstants.getFontFamily(attr);
if (!fontName.equals(name)) {
fontName = name;
fontFamilies.setSelectedItem(name);
}
int size = StyleConstants.getFontSize(attr);
if (fontSize != size) {
fontSize = size;
fontSizes.setSelectedItem(Integer.toString(fontSize));
}
dp.skipUpdate = false;
}
*/
/**
* Required for implementations of DocumentListener.
* Does nothing.
*/
public void changedUpdate(DocumentEvent de) {
}
/**
* Required for implementations of DocumentListener.
* Informs the object that a change in the document
* has occurred.
*
* @param de a DocumentEvent
*/
public void insertUpdate(DocumentEvent de) {
hasChanged = true;
}
/**
* Required for implementations of DocumentListener.
* Informs the object that a change in the document
* has occurred.
*
* @param de a DocumentEvent
*/
public void removeUpdate(DocumentEvent de) {
hasChanged = true;
}
private class RTFFilter extends javax.swing.filechooser.FileFilter {
// Accept all directories and all RTF files.
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String fName = f.getName();
int i = fName.lastIndexOf('.');
if (i < 0)
return false;
else {
String ext = fName.substring(i+1).toLowerCase();
if (ext.equals("rtf"))
return true;
else
return false;
}
}
//the description of this filter
public String getDescription() {
return "Rich Text Format (.rtf)";
}
}
private class TXTFilter extends javax.swing.filechooser.FileFilter {
// Accept all directories and all TXT files.
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String fName = f.getName();
int i = fName.lastIndexOf('.');
if (i < 0)
return false;
else {
String ext = fName.substring(i+1).toLowerCase();
if (ext.equals("txt"))
return true;
else
return false;
}
}
//the description of this filter
public String getDescription() {
return "Text file (.txt)";
}
}
/**
* Runs Jskad.
* System output, including errors, is redirected to jskad.log.
* If you discover a bug, please send us an email, making sure
* to include the jskad.log file as an attachment.
*/
public static void main(String[] args) {
try {
PrintStream ps = new PrintStream(new FileOutputStream("jskad.log"));
System.setErr(ps);
System.setOut(ps);
}
catch (Exception e) {
}
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
}
JFrame f = new JFrame("Jskad");
Dimension d = f.getToolkit().getScreenSize();
x_size = d.width/4*3;
y_size = d.height/4*3;
f.setSize(x_size, y_size);
f.setLocation(d.width/8, d.height/8);
f.getContentPane().add(new Jskad(f));
f.setVisible(true);
}
}

View file

@ -1,35 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001 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 inputting Tibetan text.
<p>
Designed for use with the Tibetan Computer
Company's free cross-platform TibetanMachineWeb fonts, this package
contains methods for inputting Tibetan using various keyboard
input methods, including true Wylie-based input, as well as
user-defined keyboards.
<p>
The package includes a simple Tibetan text editor, Jskad,
which can be run as an local application or embedded in a
web page. Jskad supports a wide range of functions, including
conversion back and forth between TibetanMachineWeb and
Extended Wylie.
<p>
<h2>Related Documentation</h2>
@see org.thdl.tib.text
</body>
</html>

View file

@ -1,140 +0,0 @@
/*
The contents of this file are subject to the AMP 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 AMP web site
(http://www.tibet.iteso.mx/Guatemala/).
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 Andres Montano Pellegrini. Portions
created by Andres Montano Pellegrini are Copyright 2001 Andres Montano
Pellegrini. All Rights Reserved.
Contributor(s): Edward Garrett.
*/
package org.thdl.tib.text;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import javax.swing.border.*;
import javax.swing.text.*;
import org.thdl.tib.input.DuffPane;
import org.thdl.tib.text.*;
import org.thdl.tib.text.TibetanDocument.DuffData;
import java.io.Serializable;
/** Used by DictionaryTable to display a Tibetan word or phrase
(in either Roman or Tibetan script) in a single cell.
@author Andr&eacute;s Montano Pellegrini
@see DictionaryTable
*/
public class DuffCellRenderer extends DuffPane implements TableCellRenderer, Serializable
{
protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
// We need a place to store the color the DuffPane should be returned
// to after its foreground and background colors have been set
// to the selection background color.
// These ivars will be made protected when their names are finalized.
private Color unselectedForeground;
private Color unselectedBackground;
public DuffCellRenderer()
{
super();
setOpaque(true);
setBorder(noFocusBorder);
}
/**
* Overrides <code>JComponent.setForeground</code> to assign
* the unselected-foreground color to the specified color.
*
* @param c set the foreground color to this value
*/
public void setForeground(Color c) {
super.setForeground(c);
unselectedForeground = c;
}
/**
* Overrides <code>JComponent.setForeground</code> to assign
* the unselected-background color to the specified color.
*
* @param c set the background color to this value
*/
public void setBackground(Color c) {
super.setBackground(c);
unselectedBackground = c;
}
/**
* Notification from the <code>UIManager</code> that the look and feel
* [L&F] has changed.
* Replaces the current UI object with the latest version from the
* <code>UIManager</code>.
*
* @see JComponent#updateUI
*/
public void updateUI() {
super.updateUI();
setForeground(null);
setBackground(null);
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column)
{
if (isSelected)
{
super.setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
}
else
{
super.setForeground((unselectedForeground != null) ? unselectedForeground : table.getForeground());
super.setBackground((unselectedBackground != null) ? unselectedBackground : table.getBackground());
}
if (hasFocus) {
setBorder( UIManager.getBorder("Table.focusCellHighlightBorder") );
if (table.isCellEditable(row, column)) {
super.setForeground( UIManager.getColor("Table.focusCellForeground") );
super.setBackground( UIManager.getColor("Table.focusCellBackground") );
}
} else {
setBorder(noFocusBorder);
}
setValue(value);
// ---- begin optimization to avoid painting background ----
Color back = getBackground();
boolean colorMatch = (back != null) && ( back.equals(table.getBackground()) ) && table.isOpaque();
setOpaque(!colorMatch);
// ---- end optimization to aviod painting background ----
return this;
}
public void setValue(Object value)
{
TibetanDocument doc = (TibetanDocument) getDocument();
try
{
doc.remove(0, doc.getLength());
}
catch (Exception e)
{
System.out.println(e);
}
doc.insertDuff(0, (DuffData []) value);
}
}

View file

@ -1,165 +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.tib.text;
import java.util.StringTokenizer;
/**
* A wrapper for the primitive data types
* that combine to represent a Tibetan glyph in the
* TibetanMachineWeb family of fonts.
*
* A DuffCode consists of a font number, a character, and
* a character number. A font identification and a character
* (or character number) are sufficient to uniquely identify
* any TibetanMachineWeb glyph.
* @author Edward Garrett, Tibetan and Himalayan Digital Library
* @version 1.0
*/
public class DuffCode {
/**
* the font number in which this glyph can be found,
* from 1 (TibetanMachineWeb) to 10 (TibetanMachineWeb9).
*/
public int fontNum;
/**
* the character value of this glyph
*/
public char character;
/**
* the character value of this glyph, as an integer
*/
public int charNum;
/**
* Called by {@link TibetanMachineWeb} to generate
* DuffCodes from the 'tibwn.ini' initialization file.
* This constructor expects to receive a string such as "1,33" or "33,1",
* i.e. a sequence of two numbers separated by a comma. These numbers
* represent a character: one number is its identifying font number,
* and the other is the ASCII code of the character.
*
* @param s the string to parse
* @param leftToRight should be true if the first number is the font number,
* false if the second number is the font number
*/
public DuffCode(String s, boolean leftToRight) {
StringTokenizer st = new StringTokenizer(s,",");
try {
String val1 = st.nextToken();
String val2 = st.nextToken();
Integer num1 = new Integer(val1);
Integer num2 = new Integer(val2);
if (leftToRight) {
fontNum = num1.intValue();
charNum = num2.intValue();
character = (char)charNum;
}
else {
fontNum = num2.intValue();
charNum = num1.intValue();
character = (char)charNum;
}
}
catch (NumberFormatException e) {
}
}
/**
* Called to create DuffCodes on the fly
* from an identifying font number and an ASCII character.
*
* @param font the identifying number of the font
* @param ch a character
*/
public DuffCode(int font, char ch) {
fontNum = font;
character = ch;
charNum = (int)ch;
}
/**
* Gets the font number of this glyph.
* @return the identifying font number for this DuffCode
*/
public int getFontNum() {
return fontNum;
}
/**
* Gets the character for this glyph, as an integer.
* @return the identifying character, converted to an
* integer, for this DuffCode
*/
public int getCharNum() {
return charNum;
}
/**
* Gets the character for this glyph.
* @return the identifying character for this DuffCode
*/
public char getCharacter() {
return character;
}
/**
* Assigns a hashcode based on the font number and character for this glyph.
* The hashcode for a DuffCode with font=1 and character='c'
* is defined as the hash code of the string '1-c'.
*
* @return the hash code for this object
*/
public int hashCode() {
StringBuffer sb = new StringBuffer();
sb.append(new Integer(fontNum).toString());
sb.append('-');
sb.append(character);
String s = sb.toString();
return s.hashCode();
}
/**
* Evaluates two DuffCodes as equal iff their
* font numbers and characters are identical.
*
* @param o the object (DuffCode) you want to compare
* @return true if this object is equal to o, false if not
*/
public boolean equals(Object o) {
if (o instanceof DuffCode) {
DuffCode dc = (DuffCode)o;
if (fontNum == dc.fontNum && charNum == dc.charNum)
return true;
}
return false;
}
/**
* @return a string representation of this object
*/
public String toString() {
return "fontNum="+fontNum+";charNum="+charNum+";character="+new Character(character).toString();
}
}

View file

@ -1,62 +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.tib.text;
/**
* Thrown whenever
* a process runs into invalid Extended Wylie. This is usually thrown
* while converting Wylie to
* TibetanMachineWeb when the converter runs into invalid Wylie.
* @author Edward Garrett, Tibetan and Himalayan Digital Library
* @version 1.0
*/
public class InvalidWylieException extends Exception {
private String wylie;
private int offset;
/**
* Creates an InvalidWylieException.
* @param s a string of Wylie text
* @param i the offset where problems for the process began
*/
public InvalidWylieException(String s, int i) {
wylie = s;
offset = i;
}
/**
* Gets the character that caused the problem.
* @return the character believed to be the problem for the process
*/
public char getCulprit() {
return wylie.charAt(offset);
}
/**
* Gets the character that caused the problem, in context.
* @return the string of text including and following the character
* believed to be the problem for the process
*/
public String getCulpritInContext() {
if (wylie.length() < offset+5)
return wylie.substring(offset, wylie.length());
else
return wylie.substring(offset, offset+5);
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,225 +0,0 @@
package org.thdl.tib.text;
import java.util.StringTokenizer;
public class TibetanHTML {
static String[] styleNames =
{"tmw","tmw1","tmw2","tmw3","tmw4","tmw5","tmw6","tmw7","tmw8","tmw9"};
public static String getStyles(String fontSize) {
return ".tmw {font: "+fontSize+"pt TibetanMachineWeb}\n"+
".tmw1 {font: "+fontSize+"pt TibetanMachineWeb1}\n"+
".tmw2 {font: "+fontSize+"pt TibetanMachineWeb2}\n"+
".tmw3 {font: "+fontSize+"pt TibetanMachineWeb3}\n"+
".tmw4 {font: "+fontSize+"pt TibetanMachineWeb4}\n"+
".tmw5 {font: "+fontSize+"pt TibetanMachineWeb5}\n"+
".tmw6 {font: "+fontSize+"pt TibetanMachineWeb6}\n"+
".tmw7 {font: "+fontSize+"pt TibetanMachineWeb7}\n"+
".tmw8 {font: "+fontSize+"pt TibetanMachineWeb8}\n"+
".tmw9 {font: "+fontSize+"pt TibetanMachineWeb9}\n";
}
public static String getHTMLX(String wylie) {
try {
StringBuffer buffer = new StringBuffer();
for (StringTokenizer tokenizer = new StringTokenizer(wylie, " \t\n", true); tokenizer.hasMoreElements();) {
String next = tokenizer.nextToken();
if (next.equals("\t") || next.equals("\n")) {
buffer.append("<wbr/>");
buffer.append(getHTML(TibetanDocument.getTibetanMachineWeb("_")));
buffer.append("<wbr/>");
}
else
buffer.append(getHTML(TibetanDocument.getTibetanMachineWeb(next)));
}
return buffer.toString();
} catch (InvalidWylieException ive) {
return "";
}
}
public static String getHTMLX(TibetanDocument.DuffData[] duffData) {
String[] styleNames =
{"tmw","tmw1","tmw2","tmw3","tmw4","tmw5","tmw6","tmw7","tmw8","tmw9"};
StringBuffer htmlBuffer = new StringBuffer();
htmlBuffer.append("<nobr>");
for (int i=0; i<duffData.length; i++) {
char[] c = duffData[i].text.toCharArray();
for (int k=0; k<c.length; k++) {
htmlBuffer.append("<span class=\"");
htmlBuffer.append(styleNames[duffData[i].font-1]);
htmlBuffer.append("\">");
if (c[k] > 32 && c[k] < 127) { //ie if it's not formatting
switch (c[k]) {
case '"':
htmlBuffer.append("&quot;");
break;
case '<':
htmlBuffer.append("&lt;");
break;
case '>':
htmlBuffer.append("&gt;");
break;
case '&':
htmlBuffer.append("&amp;");
break;
default:
htmlBuffer.append(c[k]);
break;
}
htmlBuffer.append("</span>");
String wylie = TibetanMachineWeb.getWylieForGlyph(duffData[i].font, c[k]);
if (TibetanMachineWeb.isWyliePunc(wylie))
htmlBuffer.append("<wbr/>");
} else {
htmlBuffer.append("</span><br/>");
}
}
}
htmlBuffer.append("</nobr>");
return htmlBuffer.toString();
}
public static String getIndentedHTML(String wylie) {
return getHTML("_" + wylie);
}
public static String getHTML(String wylie) {
try {
StringBuffer buffer = new StringBuffer();
for (StringTokenizer tokenizer = new StringTokenizer(wylie, " \t\n", true); tokenizer.hasMoreElements();) {
String next = tokenizer.nextToken();
if (next.equals("\t") || next.equals("\n")) {
buffer.append("<wbr/>");
buffer.append(getHTML(TibetanDocument.getTibetanMachineWeb("_")));
buffer.append("<wbr/>");
}
else
buffer.append(getHTML(TibetanDocument.getTibetanMachineWeb(next)));
}
return buffer.toString();
} catch (InvalidWylieException ive) {
return "";
}
}
public static String getHTML(TibetanDocument.DuffData[] duffData) {
String[] styleNames =
{"tmw","tmw1","tmw2","tmw3","tmw4","tmw5","tmw6","tmw7","tmw8","tmw9"};
StringBuffer htmlBuffer = new StringBuffer();
htmlBuffer.append("<nobr>");
for (int i=0; i<duffData.length; i++) {
htmlBuffer.append("<span class=\"");
htmlBuffer.append(styleNames[duffData[i].font-1]);
htmlBuffer.append("\">");
char[] c = duffData[i].text.toCharArray();
for (int k=0; k<c.length; k++) {
if (c[k] > 31 && c[k] < 127) { //ie if it's not formatting
switch (c[k]) {
case '"':
htmlBuffer.append("&quot;");
break;
case '<':
htmlBuffer.append("&lt;");
break;
case '>':
htmlBuffer.append("&gt;");
break;
case '&':
htmlBuffer.append("&amp;");
break;
default:
htmlBuffer.append(c[k]);
break;
}
String wylie = TibetanMachineWeb.getWylieForGlyph(duffData[i].font, c[k]);
if (TibetanMachineWeb.isWyliePunc(wylie))
htmlBuffer.append("<wbr/>");
} else {
htmlBuffer.append("<br/>");
}
}
htmlBuffer.append("</span>");
}
htmlBuffer.append("</nobr>");
return htmlBuffer.toString();
}
public static String getHTMLforJava(String wylie) {
//differences:
// as of 1.4.1, anyway, browser built into java does not accept <wbr/> and <br/>,
// only <wbr> and <br>
try {
StringBuffer buffer = new StringBuffer();
for (StringTokenizer tokenizer = new StringTokenizer(wylie, " \t\n", true); tokenizer.hasMoreElements();) {
String next = tokenizer.nextToken();
if (next.equals("\t") || next.equals("\n")) {
buffer.append("<wbr>");
buffer.append(getHTML(TibetanDocument.getTibetanMachineWeb("_")));
buffer.append("<wbr>");
}
else
buffer.append(getHTML(TibetanDocument.getTibetanMachineWeb(next)));
}
return buffer.toString();
} catch (InvalidWylieException ive) {
return "";
}
}
public static String getHTMLforJava(TibetanDocument.DuffData[] duffData) {
String[] fontNames = {
"TibetanMachineWeb","TibetanMachineWeb1", "TibetanMachineWeb2",
"TibetanMachineWeb3","TibetanMachineWeb4","TibetanMachineWeb5",
"TibetanMachineWeb6","TibetanMachineWeb7","TibetanMachineWeb8",
"TibetanMachineWeb9"};
StringBuffer htmlBuffer = new StringBuffer();
htmlBuffer.append("<nobr>");
for (int i=0; i<duffData.length; i++) {
htmlBuffer.append("<font size=\"36\" face=\"");
htmlBuffer.append(fontNames[duffData[i].font-1]);
htmlBuffer.append("\">");
char[] c = duffData[i].text.toCharArray();
for (int k=0; k<c.length; k++) {
if (c[k] > 31 && c[k] < 127) { //ie if it's not formatting
switch (c[k]) {
case '"':
htmlBuffer.append("&quot;");
break;
case '<':
htmlBuffer.append("&lt;");
break;
case '>':
htmlBuffer.append("&gt;");
break;
case '&':
htmlBuffer.append("&amp;");
break;
default:
htmlBuffer.append(c[k]);
break;
}
String wylie = TibetanMachineWeb.getWylieForGlyph(duffData[i].font, c[k]);
if (TibetanMachineWeb.isWyliePunc(wylie))
htmlBuffer.append("<wbr>");
} else {
htmlBuffer.append("<br>");
}
}
htmlBuffer.append("</font>");
}
htmlBuffer.append("</nobr>");
return htmlBuffer.toString();
}
}

View file

@ -1,391 +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.tib.text;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.net.URL;
/**
* An alternate (non-Extended Wylie) keyboard input
* method. A keyboard URL is passed to its constructor. This URL
* must follow a particular format, and include particular subparts.
* For example, the keyboard URL must specify values for various
* input parameters, as well as correspondences for the Wylie
* characters this keyboard allows the user to input. For an example,
* see the file 'sambhota_keyboard.ini' found in the same
* directory as this class.
* <p>
* It is normative practice for a null keyboard to be
* interpreted as the default Wylie keyboard.
* A non-null keyboard defines a transformation of the default
* Wylie keyboard, setting new values for each Wylie value, as
* well as (re-)defining various parameters.
*
* @author Edward Garrett, Tibetan and Himalayan Digital Library
* @version 1.0
*/
public class TibetanKeyboard {
private boolean hasDisambiguatingKey;
private char disambiguatingKey;
private boolean hasSanskritStackingKey;
private boolean hasTibetanStackingKey;
private boolean isStackingMedial;
private char stackingKey;
private boolean isAChenRequiredBeforeVowel;
private boolean isAChungConsonant;
private boolean hasAVowel;
private Map charMap;
private Map vowelMap;
private Map puncMap;
private int command;
private final int NO_COMMAND = 0;
private final int PARAMETERS = 1;
private final int CHARACTERS = 2;
private final int VOWELS = 3;
private final int PUNCTUATION = 4;
/**
* A generic Exception to indicate an invalid keyboard.
*/
public class InvalidKeyboardException extends Exception {
}
/**
* Opens the URL specified by the parameter,
* and tries to construct a keyboard from it. If the file is
* missing, or is invalid, an InvalidKeyboardException is
* thrown.
*
* @param url the URL of the keyboard
* @throws InvalidKeyboardException a valid keyboard cannot be
* constructed from this URL
*/
public TibetanKeyboard(URL url) throws InvalidKeyboardException {
try {
InputStreamReader isr = new InputStreamReader(url.openStream());
BufferedReader in = new BufferedReader(isr);
System.out.println("reading "+url.toString());
String line;
charMap = new HashMap();
vowelMap = new HashMap();
puncMap = new HashMap();
command = NO_COMMAND;
boolean bool;
while ((line = in.readLine()) != null) {
if (line.startsWith("<?")) { //line is command
if (line.equalsIgnoreCase("<?parameters?>"))
command = PARAMETERS;
else if (line.equalsIgnoreCase("<?characters?>"))
command = CHARACTERS;
else if (line.equalsIgnoreCase("<?vowels?>"))
command = VOWELS;
else if (line.equalsIgnoreCase("<?punctuation?>"))
command = PUNCTUATION;
}
else if (line.equals("")) //empty string
;
else {
StringTokenizer st = new StringTokenizer(line,"=");
String left = null, right = null;
if (st.hasMoreTokens())
left = st.nextToken();
if (st.hasMoreTokens())
right = st.nextToken();
switch (command) {
case NO_COMMAND:
break;
case PARAMETERS:
if (left == null)
throw new InvalidKeyboardException();
if (right == null)
break;
if (left.equals("stack key")) {
stackingKey = right.charAt(0);
break;
}
if (left.equals("disambiguating key")) {
disambiguatingKey = right.charAt(0);
break;
}
bool = new Boolean(right).booleanValue();
if (left.equalsIgnoreCase("has sanskrit stacking"))
hasSanskritStackingKey = bool;
if (left.equalsIgnoreCase("has tibetan stacking"))
hasTibetanStackingKey = bool;
if (left.equalsIgnoreCase("is stacking medial"))
isStackingMedial = bool;
if (left.equalsIgnoreCase("has disambiguating key"))
hasDisambiguatingKey = bool;
if (left.equalsIgnoreCase("needs achen before vowels"))
isAChenRequiredBeforeVowel = bool;
if (left.equalsIgnoreCase("has 'a' vowel"))
hasAVowel = bool;
if (left.equalsIgnoreCase("is achung consonant"))
isAChungConsonant = bool;
break;
case CHARACTERS:
if (left == null)
throw new InvalidKeyboardException();
if (right == null)
break;
charMap.put(right, left);
break;
case VOWELS:
if (left == null)
throw new InvalidKeyboardException();
if (right == null)
break;
vowelMap.put(right, left);
break;
case PUNCTUATION:
if (left == null)
throw new InvalidKeyboardException();
if (right == null)
break;
puncMap.put(right, left);
break;
}
}
}
}
catch (Exception e) {
throw new InvalidKeyboardException();
}
}
/**
* Does this keyboard have a disambiguating key?
* @return true if this keyboard has a disambiguating key, e.g.
* the period in Wylie 'g.y' vs. Wylie 'gy', false otherwise
*/
public boolean hasDisambiguatingKey() {
return hasDisambiguatingKey;
}
/**
* Gets the disambiguating key for this keyboard.
* @return the disambiguating key, assuming this keyboard has one
*/
public char getDisambiguatingKey() {
return disambiguatingKey;
}
/**
* Does this keyboard require a stacking key for Sanskrit stacks?
* @return true if this keyboard requires a
* stacking key for Sanskrit stacks
*/
public boolean hasSanskritStackingKey() {
return hasSanskritStackingKey;
}
/**
* Does this keyboard require a stacking key for Tibetan stacks?
* @return true if this keyboard requires a
* stacking key for Tibetan stacks
*/
public boolean hasTibetanStackingKey() {
return hasTibetanStackingKey;
}
/**
* Is stacking medial?
* @return true if this keyboard has stacking, and
* if that stacking is medial rather than pre/post.
* In other words, if you want a stack consisting
* of the (Wylie) characters 's', 'g', and 'r', and
* if the stack key is '+', then if you get the
* stack by typing 's+g+r', then this method returns
* true. If you get it by typing '+sgr' or '+sgr+',
* then the method returns false.
*/
public boolean isStackingMedial() {
return isStackingMedial;
}
/**
* Gets the stacking key.
* @return the stacking key, if there is one
*/
public char getStackingKey() {
return stackingKey;
}
/**
* Must achen be typed first if you want achen plus a vowel?
* @return true if it is necessary in this keyboard to
* type achen plus a vowel to get achen plus a vowel,
* or if you can (as in Wylie), simply type the vowel,
* and then automatically get achen plus the vowel,
* assuming there is no preceding consonant.
*/
public boolean isAChenRequiredBeforeVowel() {
return isAChenRequiredBeforeVowel;
}
/**
* Is achung treated as an ordinary consonant?
* @return true if achung is counted as a consonant,
* and thus treated as stackable like any other
* consonant; false if achung is treated as a vowel,
* as in Wylie.
*/
public boolean isAChungConsonant() {
return isAChungConsonant;
}
/**
* Does the keyboard have a key for the invisible 'a' vowel?
* @return true if this keyboard has a keystroke
* sequence for the invisible Wylie vowel 'a', false
* if there is no way to type this invisible vowel.
*/
public boolean hasAVowel() {
return hasAVowel;
}
/**
* Decides whether or not a string is a character in this keyboard.
* @return true if the parameter is a character
* in this keyboard. This method checks to see
* if the passed string has been mapped to a
* Wylie character - if not, then it returns false.
*
* @param s the possible character
*/
public boolean isChar(String s) {
if (charMap.containsKey(s))
return true;
else
return false;
}
/**
* Gets the Extended Wylie corresponding to this character.
* @return the Wylie value corresponding to this
* parameter, assuming it is in fact a character
* in this keyboard; if not, returns null.
*
* @param the possible character
*/
public String getWylieForChar(String s) {
if (!charMap.containsKey(s))
return null;
return (String)charMap.get(s);
}
/**
* Decides whether or not a string is a punctuation mark in this keyboard?
* @return true if the parameter is punctuation
* in this keyboard. This method checks to see if the
* passed string has been mapped to Wylie punctuation -
* if not, then it returns false.
*
* @param s the possible punctuation
*/
public boolean isPunc(String s) {
if (puncMap.containsKey(s))
return true;
else
return false;
}
/**
* Gets the Extended Wylie corresponding to this punctuation.
* @return the Wylie value corresponding to this
* parameter, assuming it is in fact punctuation
* in this keyboard; if not, returns null.
*
* @param s the possible punctuation
*/
public String getWylieForPunc(String s) {
if (!puncMap.containsKey(s))
return null;
return (String)puncMap.get(s);
}
/**
* Decides whether or not the string is a vowel in this keyboard.
* @return true if the parameter is a vowel
* in this keyboard. This method checks to see if the
* passed string has been mapped to a Wylie vowel -
* if not, then it returns false.
*
* @param s the possible vowel
*/
public boolean isVowel(String s) {
if (vowelMap.containsKey(s))
return true;
else
return false;
}
/**
* Gets the Extended Wylie corresponding to this vowel.
* @return the Wylie value corresponding to this
* parameter, assuming it is in fact a vowel
* in this keyboard; if not, returns null.
*
* @param the possible vowel
*/
public String getWylieForVowel(String s) {
if (!vowelMap.containsKey(s))
return null;
return (String)vowelMap.get(s);
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,38 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001 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 dealing with Tibetan text.
<p>
Designed for use with the Tibetan Computer
Company's free cross-platform TibetanMachineWeb fonts, this package
contains methods for getting the Extended Wylie
correspondences for each TibetanMachineWeb glyph, and for
convert back and forth between Extended
Wylie and TibetanMachineWeb.
<p>
This package provides a variety of ways to store TibetanMachineWeb data,
and includes methods to aid programmers who want to convert from
Extended Wylie to HTML or other formats.
<p>
Here, you can also find methods for installing and managing Tibetan
keyboards. Four keyboards have been provided in this release,
but users may also create their own keyboards.
<h2>Related Documentation</h2>
@see org.thdl.tib.input
</body>
</html>

View file

@ -1,112 +0,0 @@
Sambhota Keymap One
<?parameters?>
has sanskrit stacking=true
has tibetan stacking=true
is stacking medial=false
stack key=f
has disambiguating key=false
disambiguating key=
needs achen before vowels=true
has 'a' vowel=true
is achung consonant=true
<?characters?>
k=k
kh=K
g=g
ng=G
c=c
ch=C
j=j
ny=N
t=t
th=T
d=d
n=n
p=p
ph=P
b=b
m=m
ts=x
tsh=X
dz=D
w=w
zh=Z
z=z
'='
y=y
r=r
l=l
sh=S
s=s
h=h
a=A
T=q
Th=Q
D=v
N=V
Sh=B
0=0
1=1
2=2
3=3
4=4
5=5
6=6
7=7
8=8
9=9
<0=
<1=
<2=
<3=
<4=
<5=
<6=
<7=
<8=
<9=
>0=
>1=
>2=
>3=
>4=
>5=
>6=
>7=
>8=
>9=
<?vowels?>
a=a
i=i
u=u
e=e
o=o
I=
U=
ai=E
au=O
A=
-i=I
-I=
<?punctuation?>
_=.
=
/=,
|=-
!=
:=;
;=
@=#
#=$
$=
%=
(=(
)=)
H=:
M=&
`=%
&=@

View file

@ -1,115 +0,0 @@
Tibetan Computer Company Keyboard #1
Apparently the same as the Tibkey keyboard except:
- 'h' is a pre-post stack key, not a medial stack key
<?parameters?>
has sanskrit stacking=true
has tibetan stacking=true
is stacking medial=false
stack key=h
has disambiguating key=false
disambiguating key=
needs achen before vowels=true
has 'a' vowel=false
is achung consonant=true
<?characters?>
k=q
kh=w
g=e
ng=r
c=t
ch=y
j=u
ny=i
t=o
th=p
d=[
n=]
p=a
ph=s
b=d
m=f
ts=k
tsh=l
dz=;
w='
zh=z
z=x
'=c
y=v
r=m
l=,
sh=.
s=/
h=>
a=?
T=Q
Th=W
D=E
N=R
Sh=T
0=0
1=1
2=2
3=3
4=4
5=5
6=6
7=7
8=8
9=9
<0=
<1=
<2=
<3=
<4=
<5=
<6=
<7=
<8=
<9=
>0=
>1=
>2=
>3=
>4=
>5=
>6=
>7=
>8=
>9=
<?vowels?>
a=
i=g
u=j
e=b
o=n
I=
U=
ai=B
au=N
A=
-i=G
-I=
<?punctuation?>
_=
=
/=\
|=+
!=|
:=%
;=
@=!
#=@
$=
%=
(=(
)=)
H=:
M=*
`=`
&=$

View file

@ -1,112 +0,0 @@
Tibetan Computer Company Keyboard #2
<?parameters?>
has sanskrit stacking=true
has tibetan stacking=true
is stacking medial=false
stack key=a
has disambiguating key=false
disambiguating key=
needs achen before vowels=true
has 'a' vowel=false
is achung consonant=true
<?characters?>
k=q
kh=w
g=s
ng=e
c=b
ch=n
j=m
ny=,
t=o
th=p
d=j
n=k
p=r
ph=/
b=d
m=f
ts=;
tsh='
dz=[
w=]
zh=z
z=x
'=c
y=g
r=h
l=v
sh=.
s=l
h=G
a=H
T=O
Th=P
D=J
N=K
Sh=>
0=0
1=1
2=2
3=3
4=4
5=5
6=6
7=7
8=8
9=9
<0=
<1=
<2=
<3=
<4=
<5=
<6=
<7=
<8=
<9=
>0=
>1=
>2=
>3=
>4=
>5=
>6=
>7=
>8=
>9=
<?vowels?>
a=
i=t
u=u
e=y
o=i
I=
U=
ai=Y
au=I
A=
-i=T
-I=
<?punctuation?>
_=
=
/=\
|=+
!=|
:=%
;=
@=!
#=@
$=
%=
(=(
)=)
H=:
M=*
`=`
&=$

File diff suppressed because it is too large Load diff