📄 interlinearpreviewdlg.java
字号:
interlinearizer.getTranscription()); } } /** * Update the UI elements according to the current Locale and the current * edit mode. */ private void updateForLocale() { setTitle(ElanLocale.getString("InterlinearizerOptionsDlg.Title")); tierSelectionPanel.setBorder(new TitledBorder(ElanLocale.getString( "InterlinearizerOptionsDlg.Tiers"))); whatPanel.setBorder(new TitledBorder(ElanLocale.getString( "InterlinearizerOptionsDlg.What"))); howPanel.setBorder(new TitledBorder(ElanLocale.getString( "InterlinearizerOptionsDlg.How"))); fontSizesButton.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.FontSizes")); selectionOnlyCheckBox.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.SelectionOnly")); showTierLabelCheckBox.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.ShowTierLabels")); showTimeCodeCheckBox.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.ShowTimeCode")); showEmptySlotsCheckBox.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.ShowEmptySlots")); tcStyleHhMmSsMs = ElanLocale.getString("TimeCodeFormat.TimeCode"); tcStyleSsMs = ElanLocale.getString("TimeCodeFormat.Seconds"); tcStyleMs = ElanLocale.getString("TimeCodeFormat.MilliSec"); timeCodeFormatComboBox.addItem(tcStyleHhMmSsMs); timeCodeFormatComboBox.addItem(tcStyleSsMs); timeCodeFormatComboBox.addItem(tcStyleMs); hideLinesRadioButton.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.HideLines")); tierTemplateRadioButton.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.TierTemplate")); // "how" panel widthLabel.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.Width")); heightLabel.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.Height")); blockWrapLabel.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.BlockWrap")); blockWrapNone = ElanLocale.getString( "InterlinearizerOptionsDlg.BlockWrap.None"); blockWrapWithinBlock = ElanLocale.getString( "InterlinearizerOptionsDlg.BlockWrap.WithinBlock"); blockWrapBlockBoundary = ElanLocale.getString( "InterlinearizerOptionsDlg.BlockWrap.BlockBoundary"); blockWrapEachBlock = ElanLocale.getString( "InterlinearizerOptionsDlg.BlockWrap.EachBlock"); blockWrapComboBox.addItem(blockWrapNone); blockWrapComboBox.addItem(blockWrapWithinBlock); blockWrapComboBox.addItem(blockWrapBlockBoundary); blockWrapComboBox.addItem(blockWrapEachBlock); lineWrapLabel.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.LineWrap")); sortingLabel.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.Sorting")); sortingAsFile = ElanLocale.getString( "InterlinearizerOptionsDlg.Sorting.AsFile"); sortingComboBox.addItem(sortingAsFile); sortingTierHierarchy = ElanLocale.getString( "InterlinearizerOptionsDlg.Sorting.TierHierarchy"); sortingComboBox.addItem(sortingTierHierarchy); sortingLinguisticType = ElanLocale.getString( "InterlinearizerOptionsDlg.Sorting.ByType"); sortingComboBox.addItem(sortingLinguisticType); sortingParticipant = ElanLocale.getString( "InterlinearizerOptionsDlg.Sorting.ByParticipant"); sortingComboBox.addItem(sortingParticipant); lineSpacingLabel.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.LineSpacing")); blockSpacingLabel.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.BlockSpacing")); if (insertTabCheckBox != null) { insertTabCheckBox.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.InsertTab")); } // components of buttonPanel applyChangesButton.setText(ElanLocale.getString( "InterlinearizerOptionsDlg.ApplyChanges")); if (interlinearizer.getOutputMode() == Interlinear.PRINT) { pageSetupButton.setText(ElanLocale.getString("Menu.File.PageSetup")); printButton.setText(ElanLocale.getString("Menu.File.Print")); } else { printButton.setText(ElanLocale.getString("Menu.File.SaveAs")); } } /** * Moves selected tiers up in the list of tiers. */ private void moveUp() { if ((tierTable == null) || (model == null) || (model.getRowCount() < 2)) { return; } int[] selected = tierTable.getSelectedRows(); for (int i = 0; i < selected.length; i++) { int row = selected[i]; if ((row > 0) && !tierTable.isRowSelected(row - 1)) { model.moveRow(row, row, row - 1); tierTable.changeSelection(row, 0, true, false); tierTable.changeSelection(row - 1, 0, true, false); } } } /** * Moves selected tiers up in the list of tiers. */ private void moveDown() { if ((tierTable == null) || (model == null) || (model.getRowCount() < 2)) { return; } int[] selected = tierTable.getSelectedRows(); for (int i = selected.length - 1; i >= 0; i--) { int row = selected[i]; if ((row < (model.getRowCount() - 1)) && !tierTable.isRowSelected(row + 1)) { model.moveRow(row, row, row + 1); tierTable.changeSelection(row, 0, true, false); tierTable.changeSelection(row + 1, 0, true, false); } } } /** * Sorting of the tiers in the table. */ private void sortTiersTable() { if ((tierTable == null) || (model == null) || (model.getRowCount() < 2)) { return; } // first store the current order ArrayList curOrder = new ArrayList(); String name = null; TierImpl t = null; int col = model.findColumn(TIER_NAME_COLUMN); for (int i = 0; i < model.getRowCount(); i++) { name = (String) model.getValueAt(i, col); t = (TierImpl) interlinearizer.getTranscription().getTierWithId(name); curOrder.add(t); } TierSorter sorter = new TierSorter(interlinearizer.getTranscription()); ArrayList newSort = null; switch (curSortMode) { case Interlinear.EXTERNALLY_SPECIFIED: newSort = sorter.sortTiers(sorter.UNSORTED); break; case Interlinear.TIER_HIERARCHY: newSort = sorter.sortTiers(sorter.BY_HIERARCHY, curOrder); break; case Interlinear.BY_LINGUISTIC_TYPE: newSort = sorter.sortTiers(sorter.BY_LINGUISTIC_TYPE, curOrder); break; case Interlinear.BY_PARTICIPANT: newSort = sorter.sortTiers(sorter.BY_PARTICIPANT, curOrder); break; default:} // apply new order to the table String cellName; for (int i = 0; i < newSort.size(); i++) { t = (TierImpl) newSort.get(i); name = t.getName(); for (int j = 0; j < model.getRowCount(); j++) { cellName = (String) model.getValueAt(j, col); if ((cellName != null) && cellName.equals(name)) { model.moveRow(j, j, i); break; } } } tierTable.clearSelection(); } /** * Returns the tiers that are marked visible in the tier table. * * @return the current visible tiers in the table, a list of TierImpl * objects */ private ArrayList getVisibleTierList() { ArrayList vt = new ArrayList(); if (model != null) { String name = null; Boolean vis = null; TierImpl t = null; int tierCol = model.findColumn(TIER_NAME_COLUMN); int visCol = model.findColumn(PRINT_COLUMN); for (int i = 0; i < model.getRowCount(); i++) { vis = (Boolean) model.getValueAt(i, visCol); if (vis.booleanValue()) { name = (String) model.getValueAt(i, tierCol); t = (TierImpl) interlinearizer.getTranscription() .getTierWithId(name); vt.add(t); } } } return vt; } /** * Update the Interlinear object with the current font sizes. */ private void applyFontSizes() { if (model != null) { String name = null; Integer size = null; int tierCol = model.findColumn(TIER_NAME_COLUMN); int sizeCol = model.findColumn(FONT_SIZE_COLUMN); for (int i = 0; i < model.getRowCount(); i++) { name = (String) model.getValueAt(i, tierCol); size = (Integer) model.getValueAt(i, sizeCol); if ((name != null) && (size != null)) { if (size.intValue() != interlinearizer.getFontSize(name)) { interlinearizer.setFontSize(name, size.intValue()); } } } } } /** * Change the font sizes. Pass a HashMap with tier names and font sizes to * the dialog. */ private void doSetFontSizes() { ArrayList fontNames = new ArrayList(); HashMap fontMap = new HashMap(); if (model != null) { int tierCol = model.findColumn(TIER_NAME_COLUMN); int fontCol = model.findColumn(FONT_SIZE_COLUMN); String name = null; Integer size = null; for (int i = 0; i < model.getRowCount(); i++) { name = (String) model.getValueAt(i, tierCol); size = (Integer) model.getValueAt(i, fontCol); fontNames.add(name); fontMap.put(name, size); } JDialog dlg = new TierFontSizeDlg(this, true, fontMap, fontNames); dlg.setLocationRelativeTo(tierTable); dlg.setVisible(true); // update the table Iterator tierIt = fontMap.keySet().iterator(); name = null; size = null; while (tierIt.hasNext()) { name = (String) tierIt.next(); if (name != null) { size = (Integer) fontMap.get(name); if (size != null) { Object ttName; for (int i = 0; i < model.getRowCount(); i++) { ttName = model.getValueAt(i, tierCol); if (name.equals(ttName)) { model.setValueAt(size, i, fontCol); break; } } } } } } } /** * Updates the interlinear layout and the preview after (possible) changes * in parameters. */ private void doApplyChanges() { // set parameters interlinearizer.setSelectionOnly(selectionOnlyCheckBox.isSelected()); interlinearizer.setTierLabelsShown(showTierLabelCheckBox.isSelected()); interlinearizer.setTimeCodeShown(showTimeCodeCheckBox.isSelected()); String tcStyleString = (String) timeCodeFormatComboBox.getSelectedItem(); if (tcStyleString.equals(tcStyleHhMmSsMs)) { interlinearizer.setTimeCodeType(Interlinear.HHMMSSMS); } else if (tcStyleString.equals(tcStyleSsMs)) { interlinearizer.setTimeCodeType(Interlinear.SSMS); } else if (tcStyleString.equals(tcStyleMs)) { interlinearizer.setTimeCodeType(Interlinear.MS); } interlinearizer.setEmptySlotsShown(showEmptySlotsCheckBox.isSelected()); if (hideLinesRadioButton.isSelected()) { interlinearizer.setEmptyLineStyle(Interlinear.HIDE_EMPTY_LINES); } else { interlinearizer.setEmptyLineStyle(Interlinear.TEMPLATE); } int imageWidth = 0; //int imageHeight = 0; if (interlinearizer.getOutputMode() == Interlinear.PRINT) { int pageWidth = new Double(PrintCommand.pageFormat.getImageableWidth()).intValue(); //width of printer page widthTextField.setText(new Integer(pageWidth).toString()); interlinearizer.setWidth(pageWidth); int pageHeight = new Double(PrintCommand.pageFormat.getImageableHeight()).intValue(); heightTextField.setText("" + pageHeight); interlinearizer.setPageHeight(pageHeight); } else { String widthText = widthTextField.getText(); try { imageWidth = Integer.parseInt(widthText); interlinearizer.setWidth(imageWidth); } catch (NumberFormatException nfe) { imageWidth = interlinearizer.getWidth(); widthTextField.setText("" + imageWidth); } } if (lineWrapCheckBox.isSelected()) { interlinearizer.setLineWrapStyle(Interlinear.NEXT_LINE); } else { interlinearizer.setLineWrapStyle(Interlinear.NO_WRAP); } String blockWrapString = (String) blockWrapComboBox.getSelectedItem(); if (blockWrapString.equals(blockWrapNone)) { interlinearizer.setBlockWrapStyle(Interlinear.NO_WRAP); } else if (blockWrapString.equals(blockWrapWithinBlock)) { interlinearizer.setBlockWrapStyle(Interlinear.WITHIN_BLOCKS); } else if (blockWrapString.equals(blockWrapBlockBoundary)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -