/* The contents of this file are subject to the THDL Open Community License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License on the THDL web site (http://www.thdl.org/). Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific terms governing rights and limitations under the License. The Initial Developer of this software is the Tibetan and Himalayan Digital Library (THDL). Portions created by the THDL are Copyright 2001 THDL. All Rights Reserved. Contributor(s): ______________________________________. */ package org.thdl.savant; import java.awt.Font; import java.awt.Label; import java.awt.Color; import java.awt.Frame; import java.awt.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; import org.thdl.util.ThdlDebug; import org.thdl.util.ThdlActionListener; 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(); ThdlDebug.noteIffyCode(); } } 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