use of net.pms.newgui.components.CustomJTextField in project UniversalMediaServer by UniversalMediaServer.
the class TranscodingTab method buildSubtitlesSetupPanel.
private JComponent buildSubtitlesSetupPanel() {
String colSpec = FormLayoutUtil.getColSpec("left:pref, 3dlu, p:grow, 3dlu, right:p:grow, 3dlu, p:grow, 3dlu, right:p:grow,3dlu, p:grow, 3dlu, right:p:grow,3dlu, pref:grow", orientation);
FormLayout layout = new FormLayout(colSpec, "$lgap, 11*(pref, 3dlu), pref");
final PanelBuilder builder = new PanelBuilder(layout);
builder.border(Borders.DLU4);
CellConstraints cc = new CellConstraints();
builder.addLabel(Messages.getString("MEncoderVideo.9"), FormLayoutUtil.flip(cc.xy(1, 2), colSpec, orientation));
defaultsubs = new CustomJTextField(configuration.getSubtitlesLanguages());
defaultsubs.setToolTipText(Messages.getString("TrTab2.76"));
defaultsubs.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setSubtitlesLanguages(defaultsubs.getText());
}
});
builder.add(defaultsubs, FormLayoutUtil.flip(cc.xyw(3, 2, 5), colSpec, orientation));
builder.addLabel(Messages.getString("MEncoderVideo.94"), FormLayoutUtil.flip(cc.xy(9, 2, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
forcedsub = new JTextField(configuration.getForcedSubtitleLanguage());
forcedsub.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setForcedSubtitleLanguage(forcedsub.getText());
}
});
builder.add(forcedsub, FormLayoutUtil.flip(cc.xy(11, 2), colSpec, orientation));
builder.addLabel(Messages.getString("MEncoderVideo.95"), FormLayoutUtil.flip(cc.xy(13, 2, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
forcedtags = new JTextField(configuration.getForcedSubtitleTags());
forcedtags.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setForcedSubtitleTags(forcedtags.getText());
}
});
builder.add(forcedtags, FormLayoutUtil.flip(cc.xy(15, 2), colSpec, orientation));
builder.addLabel(Messages.getString("MEncoderVideo.10"), FormLayoutUtil.flip(cc.xy(1, 4), colSpec, orientation));
defaultaudiosubs = new JTextField(configuration.getAudioSubLanguages());
defaultaudiosubs.setToolTipText(Messages.getString("TrTab2.77"));
defaultaudiosubs.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setAudioSubLanguages(defaultaudiosubs.getText());
}
});
builder.add(defaultaudiosubs, FormLayoutUtil.flip(cc.xyw(3, 4, 13), colSpec, orientation));
builder.addLabel(Messages.getString("MEncoderVideo.37"), FormLayoutUtil.flip(cc.xyw(1, 6, 2), colSpec, orientation));
alternateSubFolder = new JTextField(configuration.getAlternateSubtitlesFolder());
alternateSubFolder.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setAlternateSubtitlesFolder(alternateSubFolder.getText());
}
});
builder.add(alternateSubFolder, FormLayoutUtil.flip(cc.xyw(3, 6, 12), colSpec, orientation));
folderSelectButton = new JButton("...");
folderSelectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser chooser;
try {
chooser = new JFileChooser();
} catch (Exception ee) {
chooser = new JFileChooser(new RestrictedFileSystemView());
}
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("FoldTab.28"));
if (returnVal == JFileChooser.APPROVE_OPTION) {
alternateSubFolder.setText(chooser.getSelectedFile().getAbsolutePath());
configuration.setAlternateSubtitlesFolder(chooser.getSelectedFile().getAbsolutePath());
}
}
});
builder.add(folderSelectButton, FormLayoutUtil.flip(cc.xy(15, 6), colSpec, orientation));
builder.addLabel(Messages.getString("TrTab2.95"), FormLayoutUtil.flip(cc.xy(1, 8), colSpec, orientation));
String[] keys = new String[] { "", "cp874", "cp932", "cp936", "cp949", "cp950", "cp1250", "cp1251", "cp1252", "cp1253", "cp1254", "cp1255", "cp1256", "cp1257", "cp1258", "ISO-2022-CN", "ISO-2022-JP", "ISO-2022-KR", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-11", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15", "ISO-8859-16", "Big5", "EUC-JP", "EUC-KR", "GB18030", "IBM420", "IBM424", "KOI8-R", "Shift_JIS", "TIS-620" };
String[] values = new String[] { Messages.getString("General.2"), Messages.getString("CharacterSet.874"), Messages.getString("CharacterSet.932"), Messages.getString("CharacterSet.936"), Messages.getString("CharacterSet.949"), Messages.getString("CharacterSet.950"), Messages.getString("CharacterSet.1250"), Messages.getString("CharacterSet.1251"), Messages.getString("CharacterSet.1252"), Messages.getString("CharacterSet.1253"), Messages.getString("CharacterSet.1254"), Messages.getString("CharacterSet.1255"), Messages.getString("CharacterSet.1256"), Messages.getString("CharacterSet.1257"), Messages.getString("CharacterSet.1258"), Messages.getString("CharacterSet.2022-CN"), Messages.getString("CharacterSet.2022-JP"), Messages.getString("CharacterSet.2022-KR"), Messages.getString("CharacterSet.8859-1"), Messages.getString("CharacterSet.8859-2"), Messages.getString("CharacterSet.8859-3"), Messages.getString("CharacterSet.8859-4"), Messages.getString("CharacterSet.8859-5"), Messages.getString("CharacterSet.8859-6"), Messages.getString("CharacterSet.8859-7"), Messages.getString("CharacterSet.8859-8"), Messages.getString("CharacterSet.8859-9"), Messages.getString("CharacterSet.8859-10"), Messages.getString("CharacterSet.8859-11"), Messages.getString("CharacterSet.8859-13"), Messages.getString("CharacterSet.8859-14"), Messages.getString("CharacterSet.8859-15"), Messages.getString("CharacterSet.8859-16"), Messages.getString("CharacterSet.Big5"), Messages.getString("CharacterSet.EUC-JP"), Messages.getString("CharacterSet.EUC-KR"), Messages.getString("CharacterSet.GB18030"), Messages.getString("CharacterSet.IBM420"), Messages.getString("CharacterSet.IBM424"), Messages.getString("CharacterSet.KOI8-R"), Messages.getString("CharacterSet.ShiftJIS"), Messages.getString("CharacterSet.TIS-620") };
final KeyedComboBoxModel<String, String> subtitleCodePageModel = new KeyedComboBoxModel<>(keys, values);
subtitleCodePage = new CustomJComboBox<>(subtitleCodePageModel);
subtitleCodePage.setToolTipText(Messages.getString("TrTab2.94"));
subtitleCodePageModel.setSelectedKey(configuration.getSubtitlesCodepage());
subtitleCodePage.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
configuration.setSubtitlesCodepage(subtitleCodePageModel.getSelectedKey());
}
}
});
subtitleCodePage.setEditable(false);
builder.add(subtitleCodePage, FormLayoutUtil.flip(cc.xyw(3, 8, 7), colSpec, orientation));
fribidi = new JCheckBox(Messages.getString("MEncoderVideo.23"), configuration.isMencoderSubFribidi());
fribidi.setContentAreaFilled(false);
fribidi.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setMencoderSubFribidi(e.getStateChange() == ItemEvent.SELECTED);
}
});
builder.add(GuiUtil.getPreferredSizeComponent(fribidi), FormLayoutUtil.flip(cc.xyw(11, 8, 4), colSpec, orientation));
builder.addLabel(Messages.getString("MEncoderVideo.24"), FormLayoutUtil.flip(cc.xy(1, 10), colSpec, orientation));
defaultfont = new JTextField(configuration.getFont());
defaultfont.setToolTipText(Messages.getString("TrTab2.97"));
defaultfont.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setFont(defaultfont.getText());
}
});
builder.add(defaultfont, FormLayoutUtil.flip(cc.xyw(3, 10, 12), colSpec, orientation));
fontselect = new CustomJButton("...");
fontselect.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new FontFileFilter());
int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("MEncoderVideo.25"));
if (returnVal == JFileChooser.APPROVE_OPTION) {
defaultfont.setText(chooser.getSelectedFile().getAbsolutePath());
configuration.setFont(chooser.getSelectedFile().getAbsolutePath());
}
}
});
builder.add(fontselect, FormLayoutUtil.flip(cc.xy(15, 10), colSpec, orientation));
builder.addLabel(Messages.getString("MEncoderVideo.12"), FormLayoutUtil.flip(cc.xy(1, 12), colSpec, orientation));
builder.addLabel(Messages.getString("MEncoderVideo.133"), FormLayoutUtil.flip(cc.xy(1, 12, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
ass_scale = new JTextField(configuration.getAssScale());
ass_scale.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setAssScale(ass_scale.getText());
}
});
builder.addLabel(Messages.getString("MEncoderVideo.13"), FormLayoutUtil.flip(cc.xy(5, 12), colSpec, orientation));
ass_outline = new JTextField(configuration.getAssOutline());
ass_outline.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setAssOutline(ass_outline.getText());
}
});
builder.addLabel(Messages.getString("MEncoderVideo.14"), FormLayoutUtil.flip(cc.xy(9, 12), colSpec, orientation));
ass_shadow = new JTextField(configuration.getAssShadow());
ass_shadow.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setAssShadow(ass_shadow.getText());
}
});
builder.addLabel(Messages.getString("MEncoderVideo.15"), FormLayoutUtil.flip(cc.xy(13, 12), colSpec, orientation));
ass_margin = new JTextField(configuration.getAssMargin());
ass_margin.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setAssMargin(ass_margin.getText());
}
});
builder.add(ass_scale, FormLayoutUtil.flip(cc.xy(3, 12), colSpec, orientation));
builder.add(ass_outline, FormLayoutUtil.flip(cc.xy(7, 12), colSpec, orientation));
builder.add(ass_shadow, FormLayoutUtil.flip(cc.xy(11, 12), colSpec, orientation));
builder.add(ass_margin, FormLayoutUtil.flip(cc.xy(15, 12), colSpec, orientation));
autoloadExternalSubtitles = new JCheckBox(Messages.getString("MEncoderVideo.22"), configuration.isAutoloadExternalSubtitles());
autoloadExternalSubtitles.setToolTipText(Messages.getString("TrTab2.78"));
autoloadExternalSubtitles.setContentAreaFilled(false);
autoloadExternalSubtitles.setEnabled(!configuration.isForceExternalSubtitles());
autoloadExternalSubtitles.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setAutoloadExternalSubtitles((e.getStateChange() == ItemEvent.SELECTED));
}
});
builder.add(GuiUtil.getPreferredSizeComponent(autoloadExternalSubtitles), FormLayoutUtil.flip(cc.xyw(1, 14, 11), colSpec, orientation));
subColor = new JButton();
subColor.setText(Messages.getString("MEncoderVideo.31"));
subColor.setBackground(configuration.getSubsColor());
subColor.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JColorChooser jColorChooser = new JColorChooser(subColor.getBackground());
Locale locale = PMS.getLocale();
jColorChooser.setLocale(locale);
jColorChooser.setComponentOrientation(ComponentOrientation.getOrientation(locale));
JDialog dialog = JColorChooser.createDialog(looksFrame, Messages.getString("MEncoderVideo.125"), true, jColorChooser, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Color newColor = jColorChooser.getColor();
if (newColor != null) {
subColor.setBackground(newColor);
configuration.setSubsColor(newColor);
// Subtitle color has been changed so all temporary subtitles must be deleted
SubtitleUtils.deleteSubs();
}
}
}, null);
dialog.setVisible(true);
dialog.dispose();
}
});
builder.add(subColor, FormLayoutUtil.flip(cc.xyw(13, 14, 3), colSpec, orientation));
forceExternalSubtitles = new JCheckBox(Messages.getString("TrTab2.87"), configuration.isForceExternalSubtitles());
forceExternalSubtitles.setToolTipText(Messages.getString("TrTab2.88"));
forceExternalSubtitles.setContentAreaFilled(false);
forceExternalSubtitles.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setForceExternalSubtitles((e.getStateChange() == ItemEvent.SELECTED));
if (configuration.isForceExternalSubtitles()) {
autoloadExternalSubtitles.setSelected(true);
}
autoloadExternalSubtitles.setEnabled(!configuration.isForceExternalSubtitles());
}
});
builder.add(GuiUtil.getPreferredSizeComponent(forceExternalSubtitles), FormLayoutUtil.flip(cc.xyw(1, 16, 11), colSpec, orientation));
useEmbeddedSubtitlesStyle = new JCheckBox(Messages.getString("MEncoderVideo.36"), configuration.isUseEmbeddedSubtitlesStyle());
useEmbeddedSubtitlesStyle.setToolTipText(Messages.getString("TrTab2.89"));
useEmbeddedSubtitlesStyle.setContentAreaFilled(false);
useEmbeddedSubtitlesStyle.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setUseEmbeddedSubtitlesStyle(e.getStateChange() == ItemEvent.SELECTED);
}
});
builder.add(GuiUtil.getPreferredSizeComponent(useEmbeddedSubtitlesStyle), FormLayoutUtil.flip(cc.xyw(1, 18, 11), colSpec, orientation));
Integer[] depth = { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 };
builder.addLabel(Messages.getString("TrTab2.90"), FormLayoutUtil.flip(cc.xy(1, 20), colSpec, orientation));
depth3D = new JComboBox<>(depth);
depth3D.setSelectedItem(configuration.getDepth3D());
depth3D.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
configuration.setDepth3D((int) e.getItem());
}
}
});
builder.add(depth3D, FormLayoutUtil.flip(cc.xy(3, 20), colSpec, orientation));
final JPanel panel = builder.getPanel();
GuiUtil.enableContainer(panel, !configuration.isDisableSubtitles());
disableSubs.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// If "Disable Subtitles" is not selected, subtitles are enabled
GuiUtil.enableContainer(panel, e.getStateChange() != ItemEvent.SELECTED);
}
});
panel.applyComponentOrientation(orientation);
return panel;
}
Aggregations