/* 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): ______________________________________. */ package org.thdl.tib.scanner; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; import org.thdl.tib.input.*; import org.thdl.util.*; /** Graphical interfase to be used by applications and applets to input a Tibetan text (in Roman or Tibetan script) and display the words (in Roman or Tibetan script) with their definitions (in Roman script). Uses the THDL inputting system. @author Andrés Montano Pellegrini @see WindowScannerFilter @see AppletScannerFilter */ public class DuffScannerPanel extends ScannerPanel implements ItemListener { private TextArea fullDef, txtInput; private DuffPane duffInput; private JPanel inputPanel; private JScrollPane listDef; // private Font tibetanFont; private DictionaryTable table; private DictionaryTableModel model; boolean showingTibetan; private PreferenceWindow prefWindow; private Choice script, keyboard; /** the middleman that keeps code regarding Tibetan keyboards * clean */ final static JskadKeyboardManager keybdMgr; static { try { keybdMgr = new JskadKeyboardManager(JskadKeyboardFactory.getAllAvailableJskadKeyboards()); } catch (Exception e) { throw new ThdlLazyException(e); } } public DuffScannerPanel(String file) { super(file, true); Panel panel1, panel2, toolBar; int i; Font f; prefWindow = null; panel2 = new Panel(new BorderLayout()); panel1 = getDictPanel(); if (panel1!=null) panel2.add (panel1, BorderLayout.NORTH); panel1 = new Panel(new GridLayout(3,1)); /* Looks up tibcodes in directory of applet. In order to work through a proxy store all the applet classes toghether with tibcodes.ini in a jar file. */ duffInput = new StrictDuffPane(); f = new Font(duffInput.getRomanFontFamily(), Font.PLAIN, duffInput.getRomanFontSize()); JPanel jpanel = new JPanel(new GridLayout(1,1)); JScrollPane jsp = new JScrollPane(duffInput, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jpanel.add(jsp); inputPanel = new JPanel(new CardLayout()); inputPanel.add(jpanel, "1"); txtInput = new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY); txtInput.setFont(f); inputPanel.add(txtInput, "2"); panel1.add(inputPanel); fullDef = new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY); fullDef.setEditable(false); fullDef.setFont(f); model = new DictionaryTableModel(null); table = new DictionaryTable(model, fullDef); table.activateTibetan(true); table.setRomanFont(f); listDef = new JScrollPane(table); panel1.add(listDef); panel1.add(fullDef); panel2.add(panel1, BorderLayout.CENTER); add(panel2, BorderLayout.CENTER); showingTibetan = true; toolBar = getToolBar(); toolBar.setLayout(new FlowLayout()); toolBar.add(new Label("Display:")); script = new Choice(); script.add("Tibetan script"); script.add("Roman script"); toolBar.add(script); script.addItemListener(this); toolBar.add(new Label("Keyboard:")); keyboard = new Choice(); String keyboardNames[] = keybdMgr.getIdentifyingStrings(); for (i=0; i 0) s = s.substring(0,posEnter);*/ duffInput.newDocument(); if (!s.equals("")) duffInput.toTibetanMachineWeb(s, 0); table.activateTibetan(true); cl.first(inputPanel); showingTibetan = true; } if (enabled && showingTibetan) { txtInput.setText(duffInput.getWylie(new boolean[] { false })); table.activateTibetan(false); cl.last(inputPanel); showingTibetan = false; } table.repaint(); } public void setPreferences(Frame owner) { Font f; if (prefWindow==null) prefWindow = new PreferenceWindow(this, duffInput); prefWindow.show(); f = new Font(prefWindow.getRomanFont(), Font.PLAIN, prefWindow.getRomanFontSize()); fullDef.setFont(f); txtInput.setFont(f); table.setTibetanFontSize(prefWindow.getTibetanFontSize()); table.setRomanFont(f); table.repaint(); } }