📄 interlinearpreviewdlg.java
字号:
/* * File: InterlinearPreviewDlg.java * Project: MPI Linguistic Application * Date: 02 May 2007 * * Copyright (C) 2001-2007 Max Planck Institute for Psycholinguistics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package mpi.eudico.client.annotator.interlinear;import mpi.eudico.client.annotator.Constants;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.annotator.Preferences;import mpi.eudico.client.annotator.commands.Command;import mpi.eudico.client.annotator.commands.ELANCommandFactory;import mpi.eudico.client.annotator.commands.PrintCommand;import mpi.eudico.client.annotator.gui.ClosableDialog;import mpi.eudico.client.annotator.gui.TextExportFileChooser;import mpi.eudico.client.annotator.tier.TierExportTableModel;import mpi.eudico.client.annotator.util.ElanFileFilter;import mpi.eudico.client.annotator.util.FileExtension;import mpi.eudico.client.util.CheckBoxTableCellRenderer;import mpi.eudico.client.util.TierSorter;import mpi.eudico.server.corpora.clomimpl.abstr.TierImpl;import java.awt.Dimension;import java.awt.FontMetrics;import java.awt.Frame;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.File;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.Vector;//import javax.print.*;//import javax.print.attribute.*;//import javax.print.attribute.standard.*;//import javax.print.event.*;import javax.swing.ButtonGroup;import javax.swing.DefaultCellEditor;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComboBox;import javax.swing.JDialog;import javax.swing.JFileChooser;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.border.TitledBorder;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import javax.swing.filechooser.FileFilter;/** * A dialog that shows a preview for interlinear printing or text export. * Contains numerous ui elements for configuring the output parameters. * * @author mpi */public class InterlinearPreviewDlg extends ClosableDialog implements ActionListener, ListSelectionListener, ItemListener { private Interlinear interlinearizer; private int curSortMode; // ui private PreviewPanel previewPanel; private JPanel optionsPanel; private JPanel whatPanel; private JPanel tierSelectionPanel; private JPanel howPanel; private JPanel buttonPanel; private JTable tierTable; private TierExportTableModel model; // tier panel private JButton fontSizesButton; private JButton upButton; private JButton downButton; //private HashMap fontSizes; // whatPanel private JCheckBox selectionOnlyCheckBox; private JCheckBox showTierLabelCheckBox; private JCheckBox showTimeCodeCheckBox; private JComboBox timeCodeFormatComboBox; private JCheckBox showEmptySlotsCheckBox; private JRadioButton hideLinesRadioButton; private JRadioButton tierTemplateRadioButton; // howPanel private JLabel widthLabel; private JTextField widthTextField; private JLabel heightLabel; private JTextField heightTextField; private JLabel blockWrapLabel; private JComboBox blockWrapComboBox; private JLabel lineWrapLabel; //private JComboBox lineWrapComboBox; private JCheckBox lineWrapCheckBox; private JLabel sortingLabel; private JComboBox sortingComboBox; private JLabel lineSpacingLabel; private JTextField lineSpacingTextField; private JLabel blockSpacingLabel; private JTextField blockSpacingTextField; private JCheckBox insertTabCheckBox; // button panel private JButton applyChangesButton; private JButton printButton; private JButton pageSetupButton; // localized option strings private String tcStyleHhMmSsMs; private String tcStyleSsMs; private String tcStyleMs; private String blockWrapNone; private String blockWrapWithinBlock; private String blockWrapBlockBoundary; private String blockWrapEachBlock; private String sortingAsFile; private String sortingTierHierarchy; private String sortingLinguisticType; private String sortingParticipant; /** the character encoding for the text file */ private String charEncoding = "UTF-8"; /** column id for the include in export checkbox column, invisible */ private final String PRINT_COLUMN = "export"; /** column id for the tier name column, invisible */ private final String TIER_NAME_COLUMN = "tier"; /** column id for the font size column, invisible */ private final String FONT_SIZE_COLUMN = "fontsize"; /** * Creates a new InterlinearPreviewDlg instance * * @param frame the parent frame * @param modal the modal property * @param interlinearizer the Interlinear object */ public InterlinearPreviewDlg(Frame frame, boolean modal, Interlinear interlinearizer) { super(frame, modal); this.interlinearizer = interlinearizer; initComponents(); setDefaultValues(); extractTiers(); doApplyChanges(); postInit(); } /** * Initializes UI elements. */ protected void initComponents() { previewPanel = new PreviewPanel(interlinearizer); optionsPanel = new JPanel(); tierSelectionPanel = new JPanel(); whatPanel = new JPanel(); howPanel = new JPanel(); buttonPanel = new JPanel(); fontSizesButton = new JButton(); upButton = new JButton(); downButton = new JButton(); //fontSizes = new HashMap(); // then: other components selectionOnlyCheckBox = new JCheckBox(); showTierLabelCheckBox = new JCheckBox(); showTimeCodeCheckBox = new JCheckBox(); timeCodeFormatComboBox = new JComboBox(); showEmptySlotsCheckBox = new JCheckBox(); showEmptySlotsCheckBox.setEnabled(false); hideLinesRadioButton = new JRadioButton(); tierTemplateRadioButton = new JRadioButton(); // components of howPanel widthLabel = new JLabel(); widthTextField = new JTextField(4); heightLabel = new JLabel(); heightTextField = new JTextField(4); blockWrapLabel = new JLabel(); blockWrapComboBox = new JComboBox(); lineWrapLabel = new JLabel(); //lineWrapComboBox = new JComboBox(); lineWrapCheckBox = new JCheckBox(); sortingLabel = new JLabel(); sortingComboBox = new JComboBox(); lineSpacingLabel = new JLabel(); lineSpacingTextField = new JTextField(2); blockSpacingLabel = new JLabel(); blockSpacingTextField = new JTextField(2); // components of buttonPanel applyChangesButton = new JButton(); printButton = new JButton(); if (interlinearizer.getOutputMode() == Interlinear.PRINT) { pageSetupButton = new JButton(); } // tier table and scrollpane, panel try { ImageIcon upIcon = new ImageIcon(this.getClass().getResource("/toolbarButtonGraphics/navigation/Up16.gif")); ImageIcon downIcon = new ImageIcon(this.getClass().getResource("/toolbarButtonGraphics/navigation/Down16.gif")); upButton.setIcon(upIcon); downButton.setIcon(downIcon); } catch (Exception ex) { upButton.setText("Up"); downButton.setText("Down"); } model = new TierExportTableModel(); model.setColumnIdentifiers(new String[] { PRINT_COLUMN, TIER_NAME_COLUMN, FONT_SIZE_COLUMN }); tierTable = new JTable(model); Dimension tableDim = new Dimension(50, 100); tierTable.getColumn(PRINT_COLUMN).setCellEditor(new DefaultCellEditor( new JCheckBox())); tierTable.getColumn(PRINT_COLUMN).setCellRenderer(new CheckBoxTableCellRenderer()); tierTable.getColumn(PRINT_COLUMN).setMaxWidth(30); tierTable.getColumn(FONT_SIZE_COLUMN).setMaxWidth(30); tierTable.setShowVerticalLines(false); tierTable.setTableHeader(null); JScrollPane tierScrollPane = new JScrollPane(tierTable); tierScrollPane.setPreferredSize(tableDim); // layout getContentPane().setLayout(new GridBagLayout()); optionsPanel.setLayout(new GridBagLayout()); tierSelectionPanel.setLayout(new GridBagLayout()); whatPanel.setLayout(new GridBagLayout()); howPanel.setLayout(new GridBagLayout()); buttonPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc; Insets insets = new Insets(2, 2, 2, 2); // add the preview panel gbc = new GridBagConstraints(); gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; getContentPane().add(previewPanel, gbc); // fill and add the tier selection panel gbc = new GridBagConstraints(); gbc.gridwidth = 3; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; tierSelectionPanel.add(tierScrollPane, gbc); gbc = new GridBagConstraints(); gbc.gridy = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; tierSelectionPanel.add(upButton, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; tierSelectionPanel.add(downButton, gbc); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.EAST; tierSelectionPanel.add(fontSizesButton, gbc); gbc = new GridBagConstraints(); gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; optionsPanel.add(tierSelectionPanel, gbc); // fill and add the "what" panel gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; //gbc.gridwidth = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; whatPanel.add(selectionOnlyCheckBox, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; //gbc.gridwidth = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; whatPanel.add(showTierLabelCheckBox, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; //gbc.gridwidth = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; whatPanel.add(showTimeCodeCheckBox, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; //gbc.gridwidth = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; whatPanel.add(timeCodeFormatComboBox, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; //gbc.gridwidth = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; whatPanel.add(showEmptySlotsCheckBox, gbc); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(hideLinesRadioButton); buttonGroup.add(tierTemplateRadioButton); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; //gbc.gridwidth = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; whatPanel.add(hideLinesRadioButton, gbc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -