Initial revision
75
source/MessageBundle.properties
Normal file
|
@ -0,0 +1,75 @@
|
|||
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
|
75
source/MessageBundle_de_DE.properties
Normal file
|
@ -0,0 +1,75 @@
|
|||
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
|
34
source/MessageBundle_zh_CN.properties
Normal file
|
@ -0,0 +1,34 @@
|
|||
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
|
34
source/chinesebundle.txt
Normal file
|
@ -0,0 +1,34 @@
|
|||
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 = 暂停
|
1651
source/org/thdl/quilldriver/QD.java
Normal file
405
source/org/thdl/quilldriver/QDPlayer.java
Normal file
|
@ -0,0 +1,405 @@
|
|||
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.
|
||||
>
|
||||
>
|
||||
>
|
||||
>
|
||||
|
||||
*/
|
159
source/org/thdl/quilldriver/QDShell.java
Normal file
|
@ -0,0 +1,159 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
BIN
source/org/thdl/quilldriver/clock.gif
Normal file
After Width: | Height: | Size: 774 B |
BIN
source/org/thdl/quilldriver/face01a.jpg
Normal file
After Width: | Height: | Size: 992 B |
BIN
source/org/thdl/quilldriver/face02a.jpg
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
source/org/thdl/quilldriver/face03a.jpg
Normal file
After Width: | Height: | Size: 854 B |
BIN
source/org/thdl/quilldriver/face04a.jpg
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
source/org/thdl/quilldriver/face05a.jpg
Normal file
After Width: | Height: | Size: 921 B |
BIN
source/org/thdl/quilldriver/face06a.jpg
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
source/org/thdl/quilldriver/face07a.jpg
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
source/org/thdl/quilldriver/face08a.jpg
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
source/org/thdl/quilldriver/face09a.jpg
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
source/org/thdl/quilldriver/face10a.jpg
Normal file
After Width: | Height: | Size: 948 B |
BIN
source/org/thdl/quilldriver/face11a.jpg
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
source/org/thdl/quilldriver/face12a.jpg
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
source/org/thdl/quilldriver/face13a.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
7
source/org/thdl/savant/AnnotationPlayer.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package org.thdl.savant;
|
||||
|
||||
public interface AnnotationPlayer extends java.util.EventListener
|
||||
{
|
||||
public void startAnnotation(String id);
|
||||
public void stopAnnotation(String id);
|
||||
}
|
313
source/org/thdl/savant/Savant.java
Normal file
|
@ -0,0 +1,313 @@
|
|||
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();
|
||||
}
|
||||
}
|
36
source/org/thdl/savant/SavantFileView.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
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) {
|
||||
}
|
||||
*/
|
||||
}
|
330
source/org/thdl/savant/SavantShell.java
Normal file
|
@ -0,0 +1,330 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
458
source/org/thdl/savant/SoundPanel.java
Normal file
|
@ -0,0 +1,458 @@
|
|||
/*-----------------------------------------------------------------------*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
};
|
104
source/org/thdl/savant/TextHighlightPlayer.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
93
source/org/thdl/savant/TextPlayer.java
Normal file
|
@ -0,0 +1,93 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
13
source/org/thdl/savant/TranscriptView.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
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();
|
||||
}
|
106
source/org/thdl/savant/TwoWayTextPlayer.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
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;
|
||||
}
|
||||
}
|
196
source/org/thdl/savant/tib/English.java
Normal file
|
@ -0,0 +1,196 @@
|
|||
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();
|
||||
}
|
||||
}
|
205
source/org/thdl/savant/tib/Tibetan.java
Normal file
|
@ -0,0 +1,205 @@
|
|||
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();
|
||||
}
|
||||
}
|
213
source/org/thdl/savant/tib/TibetanEnglish.java
Normal file
|
@ -0,0 +1,213 @@
|
|||
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();
|
||||
}
|
||||
}
|
216
source/org/thdl/savant/tib/TibetanWylie.java
Normal file
|
@ -0,0 +1,216 @@
|
|||
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();
|
||||
}
|
||||
}
|
218
source/org/thdl/savant/tib/TibetanWylieEnglish.java
Normal file
|
@ -0,0 +1,218 @@
|
|||
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();
|
||||
}
|
||||
}
|
196
source/org/thdl/savant/tib/Wylie.java
Normal file
|
@ -0,0 +1,196 @@
|
|||
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();
|
||||
}
|
||||
}
|
209
source/org/thdl/savant/tib/WylieEnglish.java
Normal file
|
@ -0,0 +1,209 @@
|
|||
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();
|
||||
}
|
||||
}
|
225
source/org/thdl/savant/ucuchi/All.java
Normal file
|
@ -0,0 +1,225 @@
|
|||
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();
|
||||
}
|
||||
}
|
196
source/org/thdl/savant/ucuchi/English.java
Normal file
|
@ -0,0 +1,196 @@
|
|||
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();
|
||||
}
|
||||
}
|
195
source/org/thdl/savant/ucuchi/Quechua.java
Normal file
|
@ -0,0 +1,195 @@
|
|||
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();
|
||||
}
|
||||
}
|
217
source/org/thdl/savant/ucuchi/QuechuaEnglish.java
Normal file
|
@ -0,0 +1,217 @@
|
|||
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();
|
||||
}
|
||||
}
|
217
source/org/thdl/savant/ucuchi/SegmentedQuechua.java
Normal file
|
@ -0,0 +1,217 @@
|
|||
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();
|
||||
}
|
||||
}
|
140
source/org/thdl/tib/text/DuffCellRenderer.java
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
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é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);
|
||||
}
|
||||
}
|