📄 interlinearpreviewdlg.java
字号:
gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; //gbc.gridwidth = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.WEST; whatPanel.add(tierTemplateRadioButton, gbc); gbc = new GridBagConstraints(); gbc.gridy = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; optionsPanel.add(whatPanel, gbc); // fill and add "how" panel gbc = new GridBagConstraints(); gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; howPanel.add(widthLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; howPanel.add(widthTextField, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; howPanel.add(heightLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; howPanel.add(heightTextField, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; howPanel.add(blockWrapLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; howPanel.add(blockWrapComboBox, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; howPanel.add(lineWrapLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; //gbc.fill = GridBagConstraints.HORIZONTAL; //gbc.weightx = 1.0; //howPanel.add(lineWrapComboBox, gbc); howPanel.add(lineWrapCheckBox, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; howPanel.add(sortingLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 4; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; howPanel.add(sortingComboBox, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; howPanel.add(lineSpacingLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 5; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; howPanel.add(lineSpacingTextField, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; howPanel.add(blockSpacingLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; howPanel.add(blockSpacingTextField, gbc); if (interlinearizer.getOutputMode() == Interlinear.INTERLINEAR_TEXT) { insertTabCheckBox = new JCheckBox(); insertTabCheckBox.addItemListener(this); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 7; gbc.gridwidth = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; howPanel.add(insertTabCheckBox, gbc); } gbc = new GridBagConstraints(); gbc.gridy = 2; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; optionsPanel.add(howPanel, gbc); // button panel gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; buttonPanel.add(applyChangesButton, gbc); if (interlinearizer.getOutputMode() == Interlinear.PRINT) { gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; buttonPanel.add(pageSetupButton, gbc); } gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; buttonPanel.add(printButton, gbc); gbc = new GridBagConstraints(); gbc.gridy = 3; gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; optionsPanel.add(buttonPanel, gbc); // add the options panel gbc = new GridBagConstraints(); gbc.insets = insets; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.VERTICAL; gbc.weighty = 1.0; getContentPane().add(optionsPanel, gbc); // apply localized strings updateForLocale(); // add listeners fontSizesButton.addActionListener(this); upButton.addActionListener(this); downButton.addActionListener(this); applyChangesButton.addActionListener(this); sortingComboBox.addItemListener(this); if (interlinearizer.getOutputMode() == Interlinear.PRINT) { printButton.addActionListener(this); pageSetupButton.addActionListener(this); } else if (interlinearizer.getOutputMode() == Interlinear.INTERLINEAR_TEXT) { printButton.addActionListener(this); fontSizesButton.setEnabled(false); lineSpacingTextField.setEnabled(false); } else if (interlinearizer.getOutputMode() == Interlinear.HTML) { printButton.addActionListener(this); } tierTable.getSelectionModel().addListSelectionListener(this); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { savePreferences(); interlinearizer.savePreferences(); } }); } /** * Pack, size and set location. */ protected void postInit() { pack(); int w = 550; int h = 400; setSize((getSize().width < w) ? w : getSize().width, (getSize().height < h) ? h : getSize().height); setLocationRelativeTo(getParent()); //setResizable(false); } /** * Initialise some default parameter values. */ private void setDefaultValues() { curSortMode = interlinearizer.getSortingStyle(); selectionOnlyCheckBox.setSelected(interlinearizer.isSelectionOnly()); showTierLabelCheckBox.setSelected(interlinearizer.isTierLabelsShown()); showTimeCodeCheckBox.setSelected(interlinearizer.isTimeCodeShown()); if (interlinearizer.getOutputMode() == Interlinear.PRINT) { showEmptySlotsCheckBox.setSelected(false); showEmptySlotsCheckBox.setEnabled(true); } else if (interlinearizer.getOutputMode() == Interlinear.HTML) { showEmptySlotsCheckBox.setSelected(true); showEmptySlotsCheckBox.setEnabled(false); } else { showEmptySlotsCheckBox.setSelected(false); showEmptySlotsCheckBox.setEnabled(false); } if (interlinearizer.getEmptyLineStyle() == Interlinear.HIDE_EMPTY_LINES) { hideLinesRadioButton.setSelected(true); } else { tierTemplateRadioButton.setSelected(true); } if (interlinearizer.getBlockWrapStyle() == Interlinear.BLOCK_BOUNDARY) { blockWrapComboBox.setSelectedItem(blockWrapBlockBoundary); } else if (interlinearizer.getBlockWrapStyle() == Interlinear.EACH_BLOCK) { blockWrapComboBox.setSelectedItem(blockWrapEachBlock); } else if (interlinearizer.getBlockWrapStyle() == Interlinear.NO_WRAP) { blockWrapComboBox.setSelectedItem(blockWrapNone); } else if (interlinearizer.getBlockWrapStyle() == Interlinear.WITHIN_BLOCKS) { blockWrapComboBox.setSelectedItem(blockWrapWithinBlock); } int initialWidth = interlinearizer.getWidth(); int initialHeigth = interlinearizer.getHeight(); if (initialWidth > 0) { widthTextField.setText("" + initialWidth); } else { widthTextField.setText("" + 0); } if (initialHeigth > 0) { heightTextField.setText("" + initialHeigth); } else { heightTextField.setText("" + 0); } if (interlinearizer.getOutputMode() == Interlinear.PRINT) { // width and height is determined by page setup, so fix it widthTextField.setEnabled(false); widthTextField.setBackground(Constants.DEFAULTBACKGROUNDCOLOR); heightTextField.setEnabled(false); heightTextField.setBackground(Constants.DEFAULTBACKGROUNDCOLOR); } else { heightTextField.setText(""); heightTextField.setEnabled(false); heightTextField.setBackground(Constants.DEFAULTBACKGROUNDCOLOR); lineSpacingTextField.setText(""); lineSpacingTextField.setBackground(Constants.DEFAULTBACKGROUNDCOLOR); } lineWrapCheckBox.setSelected(interlinearizer.getLineWrapStyle() == Interlinear.NEXT_LINE); if (interlinearizer.getOutputMode() == Interlinear.INTERLINEAR_TEXT) { insertTabCheckBox.setSelected(interlinearizer.isInsertTabs()); } } /** * Extract candidate tiers for export and add them to the table. Take saved * preferences into account. */ protected void extractTiers() { if (model != null) { for (int i = model.getRowCount() - 1; i >= 0; i--) { model.removeRow(i); } if (interlinearizer.getTranscription() != null) { Vector v = interlinearizer.getTranscription().getTiers(); ArrayList visTiers = interlinearizer.getVisibleTiers(); ArrayList sortedTiers = null; ArrayList allTiers = new ArrayList(); TierImpl t; String tierName; Integer fontSize; // read preferences Object sorted = Preferences.get(interlinearizer.prefTierOrder, interlinearizer.getTranscription()); if (sorted instanceof ArrayList) { sortedTiers = (ArrayList) sorted; for (int i = 0; i < sortedTiers.size(); i++) { t = (TierImpl) interlinearizer.getTranscription() .getTierWithId((String) sortedTiers.get( i)); if (t != null) { allTiers.add(t); } } } for (int i = 0; i < v.size(); i++) { t = (TierImpl) v.get(i); if (!allTiers.contains(t)) { allTiers.add(t); } } for (int i = 0; i < allTiers.size(); i++) { t = (TierImpl) allTiers.get(i); tierName = t.getName(); fontSize = new Integer(interlinearizer.getFontSize(tierName)); //fontSizes.put(tierName, fontSize); model.addRow(new Object[] { new Boolean(visTiers.contains(t)), tierName, fontSize }); } } if (model.getRowCount() > 1) { upButton.setEnabled(true); downButton.setEnabled(true); } else { upButton.setEnabled(false); downButton.setEnabled(false); } } else { upButton.setEnabled(false); downButton.setEnabled(false); } } /** * Save some user prefs to the preferences file. */ public void savePreferences() { ArrayList allTiers = new ArrayList(); if (model != null) { String name = null; int tierCol = model.findColumn(TIER_NAME_COLUMN); for (int i = 0; i < model.getRowCount(); i++) { name = (String) model.getValueAt(i, tierCol); allTiers.add(name); } Preferences.set(interlinearizer.prefTierOrder, allTiers,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -