3 import java.io.IOException;
4 import saccubus.converter.Converter;
5 import java.awt.BorderLayout;
6 import java.awt.Dimension;
7 import java.awt.GridBagConstraints;
8 import java.awt.GridBagLayout;
9 import java.awt.GridLayout;
10 import java.awt.Image;
11 import java.awt.Insets;
12 import java.awt.Toolkit;
13 import java.awt.dnd.DnDConstants;
14 import java.awt.dnd.DropTarget;
15 import java.awt.event.ActionEvent;
16 import java.awt.event.ActionListener;
17 import java.awt.event.KeyEvent;
18 import java.awt.event.WindowAdapter;
19 import java.awt.event.WindowEvent;
21 import java.util.logging.Level;
22 import java.util.logging.Logger;
23 import javax.swing.BorderFactory;
24 import javax.swing.ButtonGroup;
25 import javax.swing.GroupLayout;
26 import javax.swing.JButton;
27 import javax.swing.JCheckBox;
28 import javax.swing.JComboBox;
29 import javax.swing.JFileChooser;
30 import javax.swing.JFrame;
31 import javax.swing.JLabel;
32 import javax.swing.JMenu;
33 import javax.swing.JMenuBar;
34 import javax.swing.JMenuItem;
35 import javax.swing.JOptionPane;
36 import javax.swing.JPanel;
37 import javax.swing.JPasswordField;
38 import javax.swing.JRadioButton;
39 import javax.swing.JTabbedPane;
40 import javax.swing.JTextField;
41 import javax.swing.LayoutStyle.ComponentPlacement;
42 import javax.swing.SwingUtilities;
43 import nicobrowser.entity.NicoContent;
44 import nicobrowser.main.Main;
45 import org.apache.commons.lang.StringUtils;
46 import saccubus.ConvertStopFlag.State;
47 import saccubus.converter.profile.FfmpegOption;
48 import saccubus.converter.profile.NgSetting;
49 import saccubus.net.TextProgressListener;
50 import saccubus.properties.BasicSetting;
51 import saccubus.properties.ConvertSetting;
52 import saccubus.properties.InputCommentSetting;
53 import saccubus.properties.InputVideoSetting;
54 import saccubus.properties.SProperties;
55 import saccubus.properties.InputTcommentSetting;
56 import saccubus.properties.MovieSetting;
57 import saccubus.properties.OutputVideoSetting;
58 import saccubus.util.FileDropTarget;
59 import saccubus.util.PopupRightClick;
60 import yukihane.nicovideo.NicoDBFinder;
68 * 説明: ニコニコ動画の動画をコメントつきで保存
72 * 著作権: Copyright (c) 2007 PSI
82 public class MainFrame extends JFrame {
84 private static final long serialVersionUID = 2564486741331062989L;
85 public static final String PRODUCT_NAME = "いんきゅばす";
86 public static final String VERSION = "1.7.1 (NicoBrowser" + Main.VERSION + ")";
87 public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
89 // TODO GUIが無いためフィールドに保持.
92 BorderLayout borderLayout1 = new BorderLayout();
93 JMenuBar jMenuBar1 = new JMenuBar();
94 JMenu jMenuFile = new JMenu();
95 JMenuItem jMenuFileExit = new JMenuItem();
96 JMenu jMenuHelp = new JMenu();
97 JMenuItem jMenuHelpAbout = new JMenuItem();
98 JLabel statusBar = new JLabel();
99 JTabbedPane mainTabbedPane = new JTabbedPane();
100 JPanel SavingInfoTabPanel = new JPanel();
101 JPanel FFMpegTabPanel = new JPanel();
103 private JPanel videoInfoPanel = new JPanel();
104 private JPanel opPanel = new JPanel();
105 private JLabel videoIdLabel = new JLabel();
106 private JTextField videoIdField = new JTextField();
107 private JLabel wayBackLabel = new JLabel();
108 private JTextField wayBackField = new JTextField();
109 private JCheckBox reduceCommentCheckBox = new JCheckBox();
110 private JButton doButton = new JButton();
111 public static final String DoButtonDefString = "変換";
112 public static final String DoButtonStopString = "停止";
113 public static final String DoButtonWaitString = "待機";
114 JPanel UserInfoPanel = new JPanel();
115 GridBagLayout gridBagLayout3 = new GridBagLayout();
117 JLabel mailAddressLabel = new JLabel();
118 JTextField mailAddressField = new JTextField();
119 JLabel passwordLabel = new JLabel();
120 JPasswordField passwordField = new JPasswordField();
121 GridBagLayout gridBagLayout4 = new GridBagLayout();
122 GridBagLayout gridBagLayout6 = new GridBagLayout();
123 ButtonGroup CommentSaveButtonGroup = new ButtonGroup();
124 ButtonGroup ConvSaveButtonGroup = new ButtonGroup();
126 private class FfmpegOptionCheckBoxListener implements ActionListener{
129 public void actionPerformed(ActionEvent e) {
130 setFFMpegOptionCheckbox();
133 private final FfmpegOptionCheckBoxListener ffmpegOptionCheckBoxListener = new FfmpegOptionCheckBoxListener();
135 private void setFFMpegOptionCheckbox() {
136 boolean resizable = (resizeCheckBox.isEnabled() && resizeCheckBox.isSelected());
137 resizeWidthField.setEnabled(resizable);
138 resizeHeigitField.setEnabled(resizable);
139 adjustRatioCheckBox.setEnabled(resizable);
143 private void setNames() {
144 mainTabbedPane.setName("mainTabbedPane");
146 mailAddressField.setName("mailAddressField");
147 passwordField.setName("passwordField");
149 ffmpegPathField.setName("ffmpegPathField");
150 vhookPathField.setName("vhookPathField");
152 mainOptionField.setName("mainOptionField");
153 inputOptionField.setName("inputOptionField");
154 outputOptionField.setName("outputOptionField");
156 fontPathField.setName("fontPathField");
157 fontIndexField.setName("fontIndexField");
158 showConvVideoCheckBox.setName("showConvVideoCheckBox");
164 videoSaveInfoPanel = savePanel.getVideoSaveInfoPanel();
167 setDefaultCloseOperation(EXIT_ON_CLOSE);
171 SProperties setting = SProperties.loadSetting(null,
173 this.setSetting(setting);
174 } catch (Exception exception) {
175 exception.printStackTrace();
180 * メイン画面最上部(ID/URL, 過去ログ, 変換ボタン)のパネルを初期化します.
182 private void initVideoInfoPanel() {
184 videoIdLabel.setText("URL/ID");
185 wayBackLabel.setText("過去ログ");
186 videoIdField.setText("http://www.nicovideo.jp/watch/");
187 reduceCommentCheckBox.setText("旧仕様コメント数");
189 final GroupLayout oppLayout = new GroupLayout(opPanel);
190 opPanel.setLayout(oppLayout);
192 oppLayout.setHorizontalGroup(oppLayout.createSequentialGroup()
193 .addGroup(oppLayout.createParallelGroup()
194 .addComponent(videoIdLabel)
195 .addComponent(wayBackLabel))
196 .addGroup(oppLayout.createParallelGroup()
197 .addComponent(videoIdField)
198 .addGroup(oppLayout.createSequentialGroup()
199 .addComponent(wayBackField)
200 .addComponent(reduceCommentCheckBox)))
203 oppLayout.setVerticalGroup(oppLayout.createSequentialGroup()
204 .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
205 .addComponent(videoIdLabel)
206 .addComponent(videoIdField))
207 .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
208 .addComponent(wayBackLabel)
209 .addComponent(wayBackField)
210 .addComponent(reduceCommentCheckBox))
213 doButton.setText(DoButtonDefString);
214 doButton.addActionListener(new MainFrame_DoButton_actionAdapter(this));
216 final GroupLayout vipLayout = new GroupLayout(videoInfoPanel);
217 videoInfoPanel.setLayout(vipLayout);
219 vipLayout.setHorizontalGroup(vipLayout.createSequentialGroup()
220 .addComponent(opPanel).addComponent(doButton));
222 vipLayout.setVerticalGroup(vipLayout.createParallelGroup()
223 .addComponent(opPanel).addComponent(doButton, 10, 20, 50));
229 * @throws java.lang.Exception
231 private void jbInit() throws Exception {
233 initVideoInfoPanel();
235 GridBagConstraints gridBagConstraints74 = new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
236 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
237 gridBagConstraints74.gridwidth = 2;
238 GridBagConstraints gridBagConstraints73 = new GridBagConstraints();
239 gridBagConstraints73.fill = GridBagConstraints.HORIZONTAL;
240 gridBagConstraints73.gridy = 6;
241 gridBagConstraints73.weightx = 1.0;
242 gridBagConstraints73.gridwidth = 4;
243 gridBagConstraints73.insets = new Insets(0, 0, 0, 5);
244 gridBagConstraints73.gridx = 1;
245 GridBagConstraints gridBagConstraints72 = new GridBagConstraints();
246 gridBagConstraints72.gridx = 0;
247 gridBagConstraints72.anchor = GridBagConstraints.WEST;
248 gridBagConstraints72.insets = new Insets(0, 5, 0, 5);
249 gridBagConstraints72.fill = GridBagConstraints.NONE;
250 gridBagConstraints72.gridwidth = 1;
251 gridBagConstraints72.gridy = 6;
252 ShadowKindLabel = new JLabel();
253 ShadowKindLabel.setText("影の種類");
254 ShadowKindLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
255 GridBagConstraints gridBagConstraints66 = new GridBagConstraints();
256 gridBagConstraints66.gridx = 0;
257 gridBagConstraints66.insets = new Insets(0, 5, 5, 5);
258 gridBagConstraints66.anchor = GridBagConstraints.WEST;
259 gridBagConstraints66.gridwidth = 2;
260 gridBagConstraints66.gridy = 1;
261 ViewCommentLabel = new JLabel();
262 ViewCommentLabel.setText("表示コメント数");
263 GridBagConstraints gridBagConstraints65 = new GridBagConstraints();
264 gridBagConstraints65.fill = GridBagConstraints.HORIZONTAL;
265 gridBagConstraints65.gridy = 1;
266 gridBagConstraints65.weightx = 1.0;
267 gridBagConstraints65.gridwidth = 6;
268 gridBagConstraints65.insets = new Insets(0, 5, 5, 5);
269 gridBagConstraints65.gridx = 3;
270 GridBagConstraints gridBagConstraints64 = new GridBagConstraints(1, 1,
271 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
272 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
273 gridBagConstraints64.gridy = 3;
274 gridBagConstraints64.fill = GridBagConstraints.HORIZONTAL;
275 gridBagConstraints64.gridx = 4;
276 GridBagConstraints gridBagConstraints63 = new GridBagConstraints(0, 4,
277 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
278 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
279 gridBagConstraints63.gridy = 7;
280 gridBagConstraints63.gridx = 0;
281 gridBagConstraints63.gridwidth = 5;
282 GridBagConstraints gridBagConstraints62 = new GridBagConstraints(0, 3,
283 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
284 GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0);
285 gridBagConstraints62.gridy = 5;
286 gridBagConstraints62.gridx = 1;
287 gridBagConstraints62.fill = GridBagConstraints.HORIZONTAL;
288 gridBagConstraints62.insets = new Insets(0, 0, 5, 5);
289 gridBagConstraints62.gridwidth = 4;
290 GridBagConstraints gridBagConstraints61 = new GridBagConstraints(0, 2,
291 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
292 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
293 gridBagConstraints61.gridy = 5;
294 gridBagConstraints61.gridx = 0;
295 gridBagConstraints61.fill = GridBagConstraints.VERTICAL;
296 gridBagConstraints61.anchor = GridBagConstraints.WEST;
297 gridBagConstraints61.gridwidth = 1;
298 GridBagConstraints gridBagConstraints60 = new GridBagConstraints(0, 1,
299 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
300 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0);
301 gridBagConstraints60.gridy = 3;
302 gridBagConstraints60.gridx = 1;
303 gridBagConstraints60.fill = GridBagConstraints.HORIZONTAL;
304 gridBagConstraints60.insets = new Insets(0, 0, 0, 5);
305 gridBagConstraints60.gridwidth = 3;
306 GridBagConstraints gridBagConstraints59 = new GridBagConstraints(0, 0,
307 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
308 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0);
309 gridBagConstraints59.gridy = 3;
310 gridBagConstraints59.insets = new Insets(5, 5, 5, 5);
311 gridBagConstraints59.gridx = 0;
312 gridBagConstraints59.fill = GridBagConstraints.NONE;
313 gridBagConstraints59.anchor = GridBagConstraints.WEST;
314 gridBagConstraints59.weightx = 0.0;
315 gridBagConstraints59.gridwidth = 1;
316 GridBagConstraints gridBagConstraints58 = new GridBagConstraints();
317 gridBagConstraints58.gridx = 0;
318 gridBagConstraints58.anchor = GridBagConstraints.WEST;
319 gridBagConstraints58.insets = new Insets(0, 5, 5, 5);
320 gridBagConstraints58.gridwidth = 5;
321 gridBagConstraints58.weightx = 1.0;
322 gridBagConstraints58.fill = GridBagConstraints.HORIZONTAL;
323 gridBagConstraints58.gridy = 0;
325 GridBagConstraints gridBagConstraints54 = new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
326 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
327 gridBagConstraints54.gridwidth = 3;
329 GridBagConstraints gridBagConstraints33 = new GridBagConstraints();
330 gridBagConstraints33.gridx = 0;
331 gridBagConstraints33.fill = GridBagConstraints.HORIZONTAL;
332 gridBagConstraints33.weightx = 1.0;
333 gridBagConstraints33.insets = new Insets(0, 5, 5, 5);
334 gridBagConstraints33.gridwidth = 5;
335 gridBagConstraints33.gridy = 9;
337 GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
338 gridBagConstraints14.gridx = 0;
339 gridBagConstraints14.anchor = GridBagConstraints.WEST;
340 gridBagConstraints14.fill = GridBagConstraints.HORIZONTAL;
341 gridBagConstraints14.weightx = 1.0;
342 gridBagConstraints14.gridwidth = 5;
343 gridBagConstraints14.insets = new Insets(0, 5, 0, 5);
344 gridBagConstraints14.gridy = 8;
345 GridBagConstraints gridBagConstraints7 = new GridBagConstraints(0, 0,
346 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
347 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
348 gridBagConstraints7.weighty = 0.0;
349 GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
350 gridBagConstraints6.gridx = 0;
351 gridBagConstraints6.weighty = 1.0;
352 gridBagConstraints6.weightx = 1.0;
353 gridBagConstraints6.insets = new Insets(0, 5, 0, 5);
354 gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL;
355 gridBagConstraints6.anchor = GridBagConstraints.NORTH;
356 gridBagConstraints6.gridy = 1;
357 GridBagConstraints gridBagConstraints1 = new GridBagConstraints(0, 1,
358 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
359 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
360 gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
361 gridBagConstraints1.anchor = GridBagConstraints.NORTH;
362 gridBagConstraints1.weighty = 1.0;
364 this.setIconImage(WinIcon);
365 contentPane = (JPanel) this.getContentPane();
366 contentPane.setLayout(borderLayout1);
367 setSize(new Dimension(400, 450));
368 setTitle(PRODUCT_NAME + " " + VERSION);
369 this.addWindowListener(new MainFrame_this_windowAdapter(this));
370 statusBar.setText(" ");
371 jMenuFile.setText("ファイル");
372 jMenuFileExit.setText("終了");
373 jMenuFileExit.addActionListener(new MainFrame_jMenuFileExit_ActionAdapter(
375 jMenuHelp.setText("ヘルプ");
376 jMenuHelpAbout.setText("バージョン情報");
377 jMenuHelpAbout.addActionListener(new MainFrame_jMenuHelpAbout_ActionAdapter(
379 SavingInfoTabPanel.setLayout(new GridLayout());
380 UserInfoPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "ユーザ設定"));
381 UserInfoPanel.setLayout(gridBagLayout3);
382 mailAddressLabel.setText("メールアドレス");
383 passwordLabel.setText("パスワード");
385 setListenerToSavePanelButton();
387 FFMpegTabPanel.setLayout(gridBagLayout6);
388 PathSettingPanel.setBorder(BorderFactory.createTitledBorder(
389 BorderFactory.createEtchedBorder(), "プログラムの位置の設定"));
390 PathSettingPanel.setLayout(gridBagLayout7);
391 FFmpegPathLabel.setText("FFmpeg");
392 SettingFFmpegPathButton.setText("参照");
393 SettingFFmpegPathButton.addActionListener(new MainFrame_SettingFFmpegPathButton_actionAdapter(
395 VhookPathLabel.setText("拡張vhookライブラリ");
396 SettingVhookPathButton.setText("参照");
397 SettingVhookPathButton.addActionListener(new MainFrame_SettingVhookPathButton_actionAdapter(
399 VhookSettingPanel.setLayout(gridBagLayout8);
400 VhookSettingPanel.setBorder(BorderFactory.createTitledBorder(
401 BorderFactory.createEtchedBorder(), "拡張vhookライブラリの設定"));
402 FFmpegSettingPanel.setBorder(BorderFactory.createTitledBorder(
403 BorderFactory.createEtchedBorder(), "FFmpegの設定"));
404 FFmpegSettingPanel.setLayout(gblFFmpegSettingPanel);
405 FontPathLabel.setText("フォントパス");
406 SettingFontPathButton.setText("参照");
407 SettingFontPathButton.addActionListener(new MainFrame_SettingFontPathButton_actionAdapter(
409 showConvVideoCheckBox.setText("変換中の画像を表示する");
411 extOptionLabel.setText("出力動画の拡張子");
412 inputOptionLabel.setText("入力オプション");
413 outputOptionLabel.setText("出力オプション");
414 mainOptionLabel.setText("メインオプション");
415 avfilterOptionLabel.setText("avfilterオプション");
417 FontIndexLabel.setText("フォント番号");
419 BasicInfoTabPanel.setLayout(gridBagLayout12);
420 jMenuBar1.add(jMenuFile);
421 jMenuFile.add(jMenuFileExit);
422 jMenuBar1.add(jMenuHelp);
423 jMenuHelp.add(jMenuHelpAbout);
424 setJMenuBar(jMenuBar1);
426 contentPane.add(statusBar, BorderLayout.SOUTH);
427 contentPane.add(mainTabbedPane, java.awt.BorderLayout.CENTER);
428 contentPane.add(videoInfoPanel, java.awt.BorderLayout.NORTH);
429 UserInfoPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1,
430 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
431 new Insets(0, 5, 5, 5), 0, 0));
432 UserInfoPanel.add(mailAddressField, new GridBagConstraints(1, 0, 1, 1,
433 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
434 new Insets(0, 5, 5, 5), 0, 0));
435 UserInfoPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1,
436 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
437 new Insets(0, 5, 5, 0), 0, 0));
438 UserInfoPanel.add(mailAddressLabel, new GridBagConstraints(0, 0, 1, 1,
439 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
440 new Insets(0, 5, 5, 0), 0, 0));
441 PathSettingPanel.add(ffmpegPathField, new GridBagConstraints(0, 1, 1,
442 1, 1.0, 0.0, GridBagConstraints.CENTER,
443 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));
444 PathSettingPanel.add(SettingFFmpegPathButton, gridBagConstraints74);
445 PathSettingPanel.add(FFmpegPathLabel, new GridBagConstraints(0, 0, 2,
446 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
447 new Insets(0, 5, 5, 5), 0, 0));
448 PathSettingPanel.add(vhookPathField, new GridBagConstraints(0, 3, 1, 1,
449 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
450 new Insets(0, 5, 5, 5), 0, 0));
451 PathSettingPanel.add(SettingVhookPathButton, new GridBagConstraints(1,
452 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
453 GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
454 PathSettingPanel.add(VhookPathLabel, gridBagConstraints54);
457 final GroupLayout layout = new GroupLayout(FFmpegSettingPanel);
458 FFmpegSettingPanel.setLayout(layout);
460 layout.setHorizontalGroup(layout.createParallelGroup()
461 .addComponent(getFFmpegOptionComboBoxPanel())
462 .addGroup(layout.createSequentialGroup()
463 .addGroup(layout.createParallelGroup()
464 .addComponent(extOptionLabel)
465 .addComponent(mainOptionLabel)
466 .addComponent(inputOptionLabel)
467 .addComponent(outputOptionLabel)
468 .addComponent(avfilterOptionLabel)
470 .addPreferredGap(ComponentPlacement.RELATED)
471 .addGroup(layout.createParallelGroup()
472 .addComponent(extOptionField)
473 .addComponent(mainOptionField)
474 .addComponent(inputOptionField)
475 .addComponent(outputOptionField)
476 .addComponent(avfilterOptionField)
479 .addGroup(layout.createParallelGroup()
480 .addGroup(layout.createSequentialGroup()
481 .addComponent(resizeCheckBox)
482 .addPreferredGap(ComponentPlacement.UNRELATED)
483 .addComponent(resizeWidthLabel)
484 .addPreferredGap(ComponentPlacement.RELATED)
485 .addComponent(resizeWidthField)
486 .addPreferredGap(ComponentPlacement.UNRELATED)
487 .addComponent(resizeHeightLabel)
488 .addPreferredGap(ComponentPlacement.RELATED)
489 .addComponent(resizeHeigitField)
492 .addGroup(layout.createSequentialGroup()
494 .addComponent(adjustRatioCheckBox))
495 .addGroup(layout.createSequentialGroup()
500 layout.setVerticalGroup(layout.createSequentialGroup()
501 .addComponent(getFFmpegOptionComboBoxPanel())
502 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
503 .addComponent(extOptionLabel)
504 .addComponent(extOptionField))
505 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
506 .addComponent(mainOptionLabel)
507 .addComponent(mainOptionField))
508 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
509 .addComponent(inputOptionLabel)
510 .addComponent(inputOptionField))
511 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
512 .addComponent(outputOptionLabel)
513 .addComponent(outputOptionField))
514 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
515 .addComponent(avfilterOptionLabel)
516 .addComponent(avfilterOptionField))
517 .addGroup(layout.createSequentialGroup()
518 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
519 .addComponent(resizeCheckBox)
520 .addComponent(resizeWidthLabel)
521 .addComponent(resizeWidthField)
522 .addComponent(resizeHeightLabel)
523 .addComponent(resizeHeigitField))
524 .addComponent(adjustRatioCheckBox)
528 resizeCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
529 adjustRatioCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
530 setFFMpegOptionCheckbox();
534 mainTabbedPane.add(BasicInfoTabPanel, "基本設定");
535 mainTabbedPane.add(SavingInfoTabPanel, "保存設定");
536 mainTabbedPane.add(FFMpegTabPanel, "動画設定");
537 mainTabbedPane.addTab("変換設定", null, getConvertingSettingPanel(), null);
538 SavingInfoTabPanel.add(savePanel);
539 BasicInfoTabPanel.add(UserInfoPanel, gridBagConstraints7);
540 BasicInfoTabPanel.add(getProxyInfoPanel(), gridBagConstraints6);
541 VhookSettingPanel.add(FontPathLabel, gridBagConstraints59);
542 VhookSettingPanel.add(showConvVideoCheckBox, gridBagConstraints63);
543 VhookSettingPanel.add(fontPathField, gridBagConstraints60);
544 VhookSettingPanel.add(fontIndexField, gridBagConstraints62);
545 VhookSettingPanel.add(FontIndexLabel, gridBagConstraints61);
546 VhookSettingPanel.add(SettingFontPathButton, gridBagConstraints64);
547 VhookSettingPanel.add(getFixFontSizeCheckBox(), gridBagConstraints14);
548 VhookSettingPanel.add(getOpaqueCommentCheckBox(), gridBagConstraints33);
549 VhookSettingPanel.add(getNotUseVhookCheckBox(), gridBagConstraints58);
550 VhookSettingPanel.add(getViewCommentField(), gridBagConstraints65);
551 VhookSettingPanel.add(ViewCommentLabel, gridBagConstraints66);
552 VhookSettingPanel.add(ShadowKindLabel, gridBagConstraints72);
553 VhookSettingPanel.add(getShadowComboBox(), gridBagConstraints73);
555 FFMpegTabPanel.add(PathSettingPanel, new GridBagConstraints(0, 0, 1, 1,
556 1.0, 0.0, GridBagConstraints.NORTHEAST,
557 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
558 FFMpegTabPanel.add(FFmpegSettingPanel, gridBagConstraints1);
562 * 保存設定パネル内のボタンにアクションリスナを割り当てる.
564 private void setListenerToSavePanelButton() {
566 al = new InputVideoPanelButtonListener();
567 videoSaveInfoPanel.getShowSavingVideoFolderDialogButton().addActionListener(al);
568 videoSaveInfoPanel.getShowSavingVideoFileDialogButton().addActionListener(al);
569 videoSaveInfoPanel.getNibrFileChooserButton().addActionListener(al);
571 al = new VideoUseRadioButtonListener();
572 videoSaveInfoPanel.getVideoNoSaveButton().addActionListener(al);
573 videoSaveInfoPanel.getVideoSaveButton().addActionListener(al);
574 videoSaveInfoPanel.getVideoUseNiBrButton().addActionListener(al);
576 al = new InputCommentPanelButtonListener();
577 savePanel.getShowSavingCommentFolderDialogButton().addActionListener(al);
578 savePanel.getShowSavingCommentFileDialogButton().addActionListener(al);
580 al = new OutputVideoPanelButtonListener();
581 savePanel.getShowSavingConvertedVideoFolderDialogButton().addActionListener(al);
582 savePanel.getShowSavingConvertedVideoFileDialogButton().addActionListener(al);
585 private void setPopup() {
586 mainOptionField.addMouseListener(new PopupRightClick(
587 this.mainOptionField));
588 inputOptionField.addMouseListener(new PopupRightClick(
589 this.inputOptionField));
590 outputOptionField.addMouseListener(new PopupRightClick(
591 this.outputOptionField));
592 savePanel.getCommentNumField().addMouseListener(new PopupRightClick(
593 savePanel.getCommentNumField()));
595 savePanel.getCommentSavedFileField().addMouseListener(new PopupRightClick(
596 savePanel.getCommentSavedFileField()));
597 savePanel.getCommentSavedFolderField().addMouseListener(new PopupRightClick(
598 savePanel.getCommentSavedFolderField()));
600 savePanel.getConvertedVideoSavedFileField().addMouseListener(new PopupRightClick(
601 savePanel.getConvertedVideoSavedFileField()));
602 savePanel.getConvertedVideoSavedFolderField().addMouseListener(new PopupRightClick(
603 savePanel.getConvertedVideoSavedFolderField()));
605 videoSaveInfoPanel.getVideoSavedFileField().addMouseListener(new PopupRightClick(
606 videoSaveInfoPanel.getVideoSavedFileField()));
607 videoSaveInfoPanel.getVideoSavedFolderField().addMouseListener(new PopupRightClick(
608 videoSaveInfoPanel.getVideoSavedFolderField()));
609 videoSaveInfoPanel.getNibrFileField().addMouseListener(
610 new PopupRightClick(videoSaveInfoPanel.getNibrFileField()));
612 ffmpegPathField.addMouseListener(new PopupRightClick(
613 this.ffmpegPathField));
614 vhookPathField.addMouseListener(new PopupRightClick(this.vhookPathField));
615 videoIdField.addMouseListener(new PopupRightClick(
617 viewCommentField.addMouseListener(new PopupRightClick(
618 this.viewCommentField));
619 fontPathField.addMouseListener(new PopupRightClick(this.fontPathField));
620 mailAddressField.addMouseListener(new PopupRightClick(this.mailAddressField));
621 passwordField.addMouseListener(new PopupRightClick(this.passwordField));
622 wayBackField.addMouseListener(new PopupRightClick(this.wayBackField));
624 proxyTextField.addMouseListener(new PopupRightClick(this.proxyTextField));
625 proxyPortTextField.addMouseListener(new PopupRightClick(
626 this.proxyPortTextField));
628 fontIndexField.addMouseListener(new PopupRightClick(this.fontIndexField));
630 ngWordTextField.addMouseListener(new PopupRightClick(
631 this.ngWordTextField));
632 ngIdTextField.addMouseListener(new PopupRightClick(this.ngIdTextField));
635 private void setDropTarget() {
636 addTarget(videoSaveInfoPanel.getVideoSavedFileField(), false);
637 addTarget(videoSaveInfoPanel.getVideoSavedFolderField(), true);
638 addTarget(videoSaveInfoPanel.getNibrFileField(), false);
640 addTarget(savePanel.getCommentSavedFileField(), false);
641 addTarget(savePanel.getCommentSavedFolderField(), true);
643 addTarget(savePanel.getConvertedVideoSavedFileField(), false);
644 addTarget(savePanel.getConvertedVideoSavedFolderField(), true);
646 addTarget(ffmpegPathField, false);
647 addTarget(vhookPathField, false);
648 addTarget(fontPathField, false);
653 * テキストフィールドに対しドロップを行った場合にファイルもしくはディレクトリの文字列を設定できるようにする.
654 * @param c 設定対象のテキストフィールドオブジェクト.
655 * @param isDir ディレクトリを設定する場合はtrue, ファイルの場合はfalse.
656 * @return ドロップターゲット(用途無し).
658 private DropTarget addTarget(JTextField c, boolean isDir) {
659 return new DropTarget(c, DnDConstants.ACTION_COPY, new FileDropTarget(
662 private File CurrentDir = new File(".");
663 private JPanel PathSettingPanel = new JPanel();
664 private JLabel FFmpegPathLabel = new JLabel();
665 private GridBagLayout gridBagLayout7 = new GridBagLayout();
666 private JTextField ffmpegPathField = new JTextField();
667 private JButton SettingFFmpegPathButton = new JButton();
668 private JLabel VhookPathLabel = new JLabel();
669 private JTextField vhookPathField = new JTextField();
670 private JButton SettingVhookPathButton = new JButton();
671 private JPanel VhookSettingPanel = new JPanel();
672 private GridBagLayout gridBagLayout8 = new GridBagLayout();
673 private JPanel FFmpegSettingPanel = new JPanel();
674 private GridBagLayout gblFFmpegSettingPanel = new GridBagLayout();
675 private JLabel FontPathLabel = new JLabel();
676 private JTextField fontPathField = new JTextField();
677 private JButton SettingFontPathButton = new JButton();
678 private JCheckBox showConvVideoCheckBox = new JCheckBox();
680 private void showSaveDialog(String title, JTextField field, boolean isSave,
682 JFileChooser chooser = new JFileChooser(CurrentDir);
683 chooser.setDialogTitle(title);
686 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
689 code = chooser.showSaveDialog(this);
691 code = chooser.showOpenDialog(this);
693 if (code == JFileChooser.APPROVE_OPTION) {
695 CurrentDir = chooser.getSelectedFile();
696 field.setText(CurrentDir.getAbsolutePath());
698 File selected = chooser.getSelectedFile();
699 CurrentDir = chooser.getCurrentDirectory();
700 field.setText(selected.getAbsolutePath());
705 private SProperties getSetting() {
706 SProperties setting = new SProperties(
708 getInputVideoSetting(),
709 getInputCommentSetting(),
710 getTcommentSetting(),
711 getOutputVideoSetting(),
713 getConvertSetting());
719 * @param setting 反映する設定.
721 private void setSetting(SProperties setting) {
723 final BasicSetting basic = setting.getBasicSetting();
724 tempDir = basic.getTempDir();
725 mailAddressField.setText(basic.getUser().getMail());
726 passwordField.setText(basic.getUser().getPassword());
728 useProxyCheckBox.setSelected(basic.isProxyUse());
729 proxyTextField.setText(basic.getProxyHost());
730 int proxy_port = basic.getProxyPort();
731 if (proxy_port >= 0 && proxy_port <= 65535) {
732 proxyPortTextField.setText(Integer.toString(proxy_port));
734 proxyPortTextField.setText("");
738 final InputVideoSetting inVideo = setting.getInputVideoSetting();
739 JRadioButton activeButton;
740 switch (inVideo.getProcessKind()) {
742 activeButton = videoSaveInfoPanel.getVideoNoSaveButton();
745 activeButton = videoSaveInfoPanel.getVideoUseNiBrButton();
749 activeButton = videoSaveInfoPanel.getVideoSaveButton();
752 activeButton.doClick();
754 videoSaveInfoPanel.getVideoSavedFileField().setText(inVideo.getFile().getPath());
755 videoSaveInfoPanel.getVideoSavedFolderField().setText(inVideo.getFolder().getPath());
756 videoSaveInfoPanel.getDelVideoCheckBox().setSelected(inVideo.isDeleteAfterConvert());
757 final boolean videoFixName = inVideo.isAutoNaming();
758 videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
759 videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
760 videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath());
763 final InputCommentSetting inputComment = setting.getInputCommentSetting();
764 savePanel.getSavingCommentCheckBox().setSelected(inputComment.getProcessKind());
765 savePanel.getCommentSavedFileField().setText(inputComment.getFile().getPath());
766 savePanel.getDelCommentCheckBox().setSelected(inputComment.isDeleteAfterConvert());
767 savePanel.getCommentSavedFolderField().setText(inputComment.getFolder().getPath());
768 savePanel.getCommentNumField().setText(Integer.toString(inputComment.getNumOfComment()));
769 savePanel.getFixCommentNumCheckBox().setSelected(inputComment.isSelfAdjustNumOfComment());
770 boolean commentFixName = inputComment.isAutoNaming();
771 savePanel.getCommentSaveFileRadioButton().setSelected(!commentFixName);
772 savePanel.getCommentSaveFolderRadioButton().setSelected(commentFixName);
775 InputTcommentSetting tcom = setting.getInputTcommentSetting();
776 savePanel.setTcommentDownload(tcom.getProcessKind());
777 savePanel.setTcommentDelete(tcom.isDeleteAfterConvert());
778 savePanel.setTcommentAutoFileName(tcom.isAutoNaming());
779 savePanel.setTcommentDirectoryName(tcom.getFolder().getPath());
780 savePanel.setTcommentFileName(tcom.getFile().getPath());
783 final OutputVideoSetting outputVideo = setting.getOutputVideoSetting();
784 savePanel.getSavingConvertedVideoCheckBox().setSelected(outputVideo.getProcessKind());
785 savePanel.getAddCommentCheckBox().setSelected(outputVideo.isAddComment());
786 savePanel.getAddTcommentCheckBox().setSelected(outputVideo.isAddTcomment());
787 savePanel.getConvertedVideoSavedFileField().setText(outputVideo.getFile().getPath());
788 savePanel.getConvertedVideoSavedFolderField().setText(outputVideo.getFolder().getPath());
789 savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(outputVideo.isCutIdName());
790 boolean convFixName = outputVideo.isAutoNaming();
791 savePanel.getConvSaveFileRadioButton().setSelected(!convFixName);
792 savePanel.getConvSaveFolderRadioButton().setSelected(convFixName);
795 final MovieSetting movie = setting.getMovieSetting();
796 ffmpegPathField.setText(movie.getFfmpeg().toString());
797 vhookPathField.setText(movie.getVhook().toString());
798 extOptionField.setText(movie.getFfmpegOption().getExtOption());
799 mainOptionField.setText(movie.getFfmpegOption().getMainOption());
800 inputOptionField.setText(movie.getFfmpegOption().getInOption());
801 outputOptionField.setText(movie.getFfmpegOption().getOutOption());
802 avfilterOptionField.setText(movie.getFfmpegOption().getAvfilterOption());
803 resizeCheckBox.setSelected(movie.getFfmpegOption().isResize());
804 resizeWidthField.setText(Integer.toString(movie.getFfmpegOption().getResizeWidth()));
805 resizeHeigitField.setText(Integer.toString(movie.getFfmpegOption().getResizeHeight()));
806 adjustRatioCheckBox.setSelected(movie.getFfmpegOption().isAdjustRatio());
807 FFmpegOptionModel.reload(movie.getOptionFile());
810 final ConvertSetting conv = setting.getConvertSetting();
811 disableVhookCheckBox.setSelected(conv.isVhookDisabled());
812 viewCommentField.setText(Integer.toString(conv.getMaxNumOfComment()));
813 fontPathField.setText(conv.getFont().toString());
814 fontIndexField.setText(Integer.toString(conv.getFontIndex()));
815 shadowComboBox.setSelectedIndex(conv.getShadowIndex());
816 showConvVideoCheckBox.setSelected(conv.isShowConverting());
817 fixFontSizeCheckBox.setSelected(conv.isSelfAdjustFontSize());
818 opaqueCommentCheckBox.setSelected(conv.isCommentOpaque());
819 ngWordTextField.setText(conv.getNgSetting().getWord());
820 ngIdTextField.setText(conv.getNgSetting().getId());
824 * [ファイル|終了] アクションが実行されました。
829 void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
831 SProperties setting = getSetting();
832 SProperties.saveSetting(setting);
833 } catch (Throwable t) {
834 Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "設定保存に失敗", t);
840 * [ヘルプ|バージョン情報] アクションが実行されました。
845 void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
846 MainFrame_AboutBox dlg = new MainFrame_AboutBox(this);
848 dlg.setLocationRelativeTo(this);
849 dlg.setVisible(true);
853 private Converter Converter = null;
855 private final JLabel extOptionLabel = new JLabel();
856 private final JTextField extOptionField = new JTextField();
857 private JLabel mainOptionLabel = new JLabel();
858 private JTextField mainOptionField = new JTextField();
859 private JLabel inputOptionLabel = new JLabel();
860 private JTextField inputOptionField = new JTextField();
861 private JLabel outputOptionLabel = new JLabel();
862 private JTextField outputOptionField = new JTextField();
863 private final JLabel avfilterOptionLabel = new JLabel();
864 private final JTextField avfilterOptionField = new JTextField();
865 private final JCheckBox resizeCheckBox = new JCheckBox("次のサイズに収まるよう縮小(-s)");
866 private final JLabel resizeWidthLabel = new JLabel("横");
867 private final JTextField resizeWidthField = new NumberFormattedTextField();
868 private final JLabel resizeHeightLabel = new JLabel("縦");
869 private final JTextField resizeHeigitField = new NumberFormattedTextField();
870 private final JCheckBox adjustRatioCheckBox = new JCheckBox("アスペクト比を維持");
872 private JLabel FontIndexLabel = new JLabel();
873 private JTextField fontIndexField = new JTextField();
874 private JPanel BasicInfoTabPanel = new JPanel();
875 private GridBagLayout gridBagLayout12 = new GridBagLayout();
876 private JPanel ConvertingSettingPanel = null;
877 private JPanel NGWordSettingPanel = null;
878 private JLabel NGWordLabel = null;
879 private JTextField ngWordTextField = null;
880 private JLabel NGIDLabel = null;
881 private JTextField ngIdTextField = null;
883 private JPanel ProxyInfoPanel = null;
884 private JCheckBox useProxyCheckBox = null;
885 private JLabel proxyLabel = null;
886 private JTextField proxyTextField = null;
887 private JLabel proxyPortLabel = null;
888 private JTextField proxyPortTextField = null;
890 private JCheckBox fixFontSizeCheckBox = null;
891 private JCheckBox opaqueCommentCheckBox = null;
892 private final SavePanel savePanel = new SavePanel();
893 private final VideoSaveInfoPanel videoSaveInfoPanel;
894 private JComboBox FFmpegOptionComboBox = null;
895 private JButton FFmpegOptionReloadButton = null;
896 private JPanel FFmpegOptionComboBoxPanel = null;
898 public void DoButton_actionPerformed(ActionEvent e) {
899 if (Converter == null || Converter.isConverted()) {
902 } catch (Exception ex) {
903 String text = ex.getMessage();
904 if (StringUtils.isEmpty(text)) {
905 text = "予期しないエラーのため中断しました。";
907 ex.printStackTrace();
908 statusBar.setText(text);
910 } else { /* 開始しているので、ストップする。 */
911 final ConvertStopFlag flag = Converter.getStopFlag();
912 if (!flag.needStop()) { /* まだストップしていない。 */
918 private void executeConvert() throws IOException {
921 // NicoBrowserファイルを利用する場合は、ファイル名からビデオIDを特定.
922 if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
924 String fileName = videoSaveInfoPanel.getNibrFileField().getText();
925 NicoDBFinder finder = NicoDBFinder.getInstance();
926 NicoContent info = finder.findNicoContent(fileName);
928 url = info.getNicoId();
932 } catch (Exception ex) {
933 JOptionPane.showMessageDialog(this, ex.getMessage(), "エラー", JOptionPane.ERROR_MESSAGE);
937 url = videoIdField.getText();
940 TextProgressListener sl = new TextProgressListener() {
942 public void setText(final String text) {
943 SwingUtilities.invokeLater(new Runnable() {
946 statusBar.setText(text);
952 ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
954 public void changeState(final State s) {
955 SwingUtilities.invokeLater(new Runnable() {
960 doButton.setText(DoButtonWaitString);
963 doButton.setText(DoButtonDefString);
970 Converter = new Converter(url, wayBackField.getText(), getSetting().toProfile(), sl,
971 new ConvertStopFlag(scl));
972 doButton.setText(DoButtonStopString);
973 new Thread(Converter).start();
978 public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
979 showSaveDialog("FFmpegへのパス", ffmpegPathField, false, false);
982 public void SettingVhookPathButton_actionPerformed(ActionEvent e) {
983 showSaveDialog("拡張vhookライブラリへのパス", vhookPathField, false, false);
986 public void SettingFontPathButton_actionPerformed(ActionEvent e) {
987 showSaveDialog("フォントへのパス", fontPathField, false, false);
990 public void this_windowClosing(WindowEvent e) {
991 this.jMenuFileExit_actionPerformed(null);
995 * This method initializes ConvertingSettingPanel
997 * @return javax.swing.JPanel
999 private JPanel getConvertingSettingPanel() {
1000 if (ConvertingSettingPanel == null) {
1001 GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
1002 gridBagConstraints11.weighty = 1.0;
1003 gridBagConstraints11.weightx = 1.0;
1004 gridBagConstraints11.insets = new Insets(0, 5, 0, 5);
1005 gridBagConstraints11.gridy = 1;
1006 gridBagConstraints11.gridx = 0;
1007 gridBagConstraints11.anchor = GridBagConstraints.NORTH;
1008 gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
1009 GridBagConstraints gridBagConstraints = new GridBagConstraints(0,
1010 2, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
1011 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
1012 gridBagConstraints.gridx = 0;
1013 gridBagConstraints.anchor = GridBagConstraints.CENTER;
1014 gridBagConstraints.weighty = 0.0;
1015 gridBagConstraints.gridy = 0;
1016 ConvertingSettingPanel = new JPanel();
1017 ConvertingSettingPanel.setLayout(new GridBagLayout());
1018 ConvertingSettingPanel.add(getNGWordSettingPanel(),
1019 gridBagConstraints11);
1020 ConvertingSettingPanel.add(VhookSettingPanel, gridBagConstraints);
1022 return ConvertingSettingPanel;
1026 * This method initializes NGWordSettingPanel
1028 * @return javax.swing.JPanel
1030 private JPanel getNGWordSettingPanel() {
1031 if (NGWordSettingPanel == null) {
1032 GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
1033 gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
1034 gridBagConstraints5.gridy = 1;
1035 gridBagConstraints5.weightx = 1.0;
1036 gridBagConstraints5.insets = new Insets(0, 5, 5, 5);
1037 gridBagConstraints5.gridx = 1;
1038 GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
1039 gridBagConstraints4.gridx = 0;
1040 gridBagConstraints4.anchor = GridBagConstraints.WEST;
1041 gridBagConstraints4.insets = new Insets(0, 5, 5, 0);
1042 gridBagConstraints4.gridy = 1;
1043 NGIDLabel = new JLabel();
1044 NGIDLabel.setText("NG ID");
1045 GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
1046 gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
1047 gridBagConstraints3.gridy = 0;
1048 gridBagConstraints3.weightx = 1.0;
1049 gridBagConstraints3.insets = new Insets(0, 5, 5, 5);
1050 gridBagConstraints3.gridx = 1;
1051 GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
1052 gridBagConstraints2.gridx = 0;
1053 gridBagConstraints2.insets = new Insets(0, 5, 5, 0);
1054 gridBagConstraints2.gridy = 0;
1055 NGWordLabel = new JLabel();
1056 NGWordLabel.setText("NGワード");
1057 NGWordSettingPanel = new JPanel();
1058 NGWordSettingPanel.setLayout(new GridBagLayout());
1059 NGWordSettingPanel.setBorder(BorderFactory.createTitledBorder(null,
1060 "NGワード・ID設定(半角スペース区切りで複数入力)"));
1061 NGWordSettingPanel.add(NGWordLabel, gridBagConstraints2);
1062 NGWordSettingPanel.add(getNGWordTextField(), gridBagConstraints3);
1063 NGWordSettingPanel.add(NGIDLabel, gridBagConstraints4);
1064 NGWordSettingPanel.add(getNGIDTextField(), gridBagConstraints5);
1066 return NGWordSettingPanel;
1070 * This method initializes NGWordTextField
1072 * @return javax.swing.JTextField
1074 private JTextField getNGWordTextField() {
1075 if (ngWordTextField == null) {
1076 ngWordTextField = new JTextField();
1077 ngWordTextField.setName("ngWordTextField");
1079 return ngWordTextField;
1083 * This method initializes NGIDTextField
1085 * @return javax.swing.JTextField
1087 private JTextField getNGIDTextField() {
1088 if (ngIdTextField == null) {
1089 ngIdTextField = new JTextField();
1090 ngIdTextField.setName("ngIdTextField");
1092 return ngIdTextField;
1096 * This method initializes ProxyInfoPanel
1098 * @return javax.swing.JPanel
1100 private JPanel getProxyInfoPanel() {
1101 if (ProxyInfoPanel == null) {
1102 GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
1103 gridBagConstraints13.gridx = 0;
1104 gridBagConstraints13.gridwidth = 2;
1105 gridBagConstraints13.weightx = 1.0;
1106 gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL;
1107 gridBagConstraints13.insets = new Insets(0, 5, 0, 5);
1108 gridBagConstraints13.gridy = 0;
1109 GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
1110 gridBagConstraints12.fill = GridBagConstraints.HORIZONTAL;
1111 gridBagConstraints12.gridy = 2;
1112 gridBagConstraints12.weightx = 1.0;
1113 gridBagConstraints12.insets = new Insets(5, 0, 5, 5);
1114 gridBagConstraints12.gridx = 1;
1115 GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
1116 gridBagConstraints10.gridx = 0;
1117 gridBagConstraints10.insets = new Insets(5, 5, 5, 5);
1118 gridBagConstraints10.gridy = 2;
1119 proxyPortLabel = new JLabel();
1120 proxyPortLabel.setText("ポート番号");
1121 GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
1122 gridBagConstraints9.fill = GridBagConstraints.BOTH;
1123 gridBagConstraints9.gridy = 1;
1124 gridBagConstraints9.weightx = 1.0;
1125 gridBagConstraints9.insets = new Insets(0, 0, 0, 5);
1126 gridBagConstraints9.gridx = 1;
1127 GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
1128 gridBagConstraints8.gridx = 0;
1129 gridBagConstraints8.insets = new Insets(0, 5, 0, 5);
1130 gridBagConstraints8.fill = GridBagConstraints.NONE;
1131 gridBagConstraints8.anchor = GridBagConstraints.EAST;
1132 gridBagConstraints8.gridy = 1;
1133 proxyLabel = new JLabel();
1134 proxyLabel.setText("プロキシ");
1135 ProxyInfoPanel = new JPanel();
1136 ProxyInfoPanel.setLayout(new GridBagLayout());
1137 ProxyInfoPanel.setBorder(BorderFactory.createTitledBorder(null,
1139 ProxyInfoPanel.add(proxyLabel, gridBagConstraints8);
1140 ProxyInfoPanel.add(getProxyTextField(), gridBagConstraints9);
1141 ProxyInfoPanel.add(proxyPortLabel, gridBagConstraints10);
1142 ProxyInfoPanel.add(getProxyPortTextField(), gridBagConstraints12);
1143 ProxyInfoPanel.add(getUseProxyCheckBox(), gridBagConstraints13);
1145 return ProxyInfoPanel;
1149 * This method initializes ProxyTextField
1151 * @return javax.swing.JTextField
1153 private JTextField getProxyTextField() {
1154 if (proxyTextField == null) {
1155 proxyTextField = new JTextField();
1156 proxyTextField.setName("proxyTextField");
1158 return proxyTextField;
1162 * This method initializes ProxyPortTextField
1164 * @return javax.swing.JTextField
1166 private JTextField getProxyPortTextField() {
1167 if (proxyPortTextField == null) {
1168 proxyPortTextField = new JTextField();
1169 proxyPortTextField.setName("proxyPortTextField");
1171 return proxyPortTextField;
1175 * This method initializes UseProxyCheckBox
1177 * @return javax.swing.JCheckBox
1179 private JCheckBox getUseProxyCheckBox() {
1180 if (useProxyCheckBox == null) {
1181 useProxyCheckBox = new JCheckBox();
1182 useProxyCheckBox.setText("プロキシを使う");
1183 useProxyCheckBox.setName("useProxyCheckBox");
1185 return useProxyCheckBox;
1189 * This method initializes FixFontSizeCheckBox
1191 * @return javax.swing.JCheckBox
1193 private JCheckBox getFixFontSizeCheckBox() {
1194 if (fixFontSizeCheckBox == null) {
1195 fixFontSizeCheckBox = new JCheckBox();
1196 fixFontSizeCheckBox.setText("フォントサイズを画面にあわせて自動調整する");
1197 fixFontSizeCheckBox.setName("fixFontSizeCheckBox");
1199 return fixFontSizeCheckBox;
1203 * This method initializes OpaqueCommentCheckBox
1205 * @return javax.swing.JCheckBox
1207 private JCheckBox getOpaqueCommentCheckBox() {
1208 if (opaqueCommentCheckBox == null) {
1209 opaqueCommentCheckBox = new JCheckBox();
1210 opaqueCommentCheckBox.setText("全てのコメントを不透明にする");
1211 opaqueCommentCheckBox.setName("opaqueCommentCheckBox");
1213 return opaqueCommentCheckBox;
1216 * This method initializes FFmpegOptionComboBox
1218 * @return javax.swing.JComboBox
1220 private final OptionComboBoxModel FFmpegOptionModel = new OptionComboBoxModel();
1221 private JCheckBox disableVhookCheckBox = null;
1222 private JTextField viewCommentField = null;
1223 private JLabel ViewCommentLabel = null;
1224 private JLabel ShadowKindLabel = null;
1225 private JComboBox shadowComboBox = null;
1227 private JComboBox getFFmpegOptionComboBox() {
1228 if (FFmpegOptionComboBox == null) {
1229 FFmpegOptionComboBox = new JComboBox(FFmpegOptionModel);
1230 FFmpegOptionComboBox.addActionListener(new java.awt.event.ActionListener() {
1232 public void actionPerformed(java.awt.event.ActionEvent e) {
1233 if (FFmpegOptionModel.isFile()) {// ファイル
1234 setFFMpegOptionEnabled(false);
1236 setFFMpegOptionEnabled(true);
1237 setFFMpegOptionCheckbox();
1241 private void setFFMpegOptionEnabled(boolean enable) {
1242 extOptionField.setEnabled(enable);
1243 mainOptionField.setEnabled(enable);
1244 inputOptionField.setEnabled(enable);
1245 outputOptionField.setEnabled(enable);
1246 avfilterOptionField.setEnabled(enable);
1247 resizeCheckBox.setEnabled(enable);
1248 resizeWidthField.setEnabled(enable);
1249 resizeHeigitField.setEditable(enable);
1250 adjustRatioCheckBox.setEnabled(enable);
1254 return FFmpegOptionComboBox;
1258 * This method initializes FFmpegOptionReloadButton
1260 * @return javax.swing.JButton
1262 private JButton getFFmpegOptionReloadButton() {
1263 if (FFmpegOptionReloadButton == null) {
1264 FFmpegOptionReloadButton = new JButton();
1265 FFmpegOptionReloadButton.setText("更新");
1266 FFmpegOptionReloadButton.addActionListener(new java.awt.event.ActionListener() {
1268 public void actionPerformed(java.awt.event.ActionEvent e) {
1269 FFmpegOptionModel.reload();
1273 return FFmpegOptionReloadButton;
1277 * This method initializes FFmpegOptionComboBoxPanel
1279 * @return javax.swing.JPanel
1281 private JPanel getFFmpegOptionComboBoxPanel() {
1282 if (FFmpegOptionComboBoxPanel == null) {
1283 GridBagConstraints gridBagConstraints47 = new GridBagConstraints();
1284 gridBagConstraints47.fill = GridBagConstraints.BOTH;
1285 gridBagConstraints47.gridx = -1;
1286 gridBagConstraints47.gridy = -1;
1287 gridBagConstraints47.insets = new Insets(0, 0, 5, 5);
1288 GridBagConstraints gridBagConstraints46 = new GridBagConstraints();
1289 gridBagConstraints46.fill = GridBagConstraints.HORIZONTAL;
1290 gridBagConstraints46.gridwidth = 3;
1291 gridBagConstraints46.gridx = -1;
1292 gridBagConstraints46.gridy = -1;
1293 gridBagConstraints46.weightx = 1.0;
1294 gridBagConstraints46.insets = new Insets(0, 5, 5, 5);
1295 FFmpegOptionComboBoxPanel = new JPanel();
1296 FFmpegOptionComboBoxPanel.setLayout(new GridBagLayout());
1297 FFmpegOptionComboBoxPanel.add(getFFmpegOptionComboBox(),
1298 gridBagConstraints46);
1299 FFmpegOptionComboBoxPanel.add(getFFmpegOptionReloadButton(),
1300 gridBagConstraints47);
1302 return FFmpegOptionComboBoxPanel;
1306 * This method initializes NotUseVhookCheckBox
1308 * @return javax.swing.JCheckBox
1310 private JCheckBox getNotUseVhookCheckBox() {
1311 if (disableVhookCheckBox == null) {
1312 disableVhookCheckBox = new JCheckBox();
1313 disableVhookCheckBox.setText("拡張vhookライブラリを無効にする(デバッグ用)");
1314 disableVhookCheckBox.setName("disableVhookCheckBox");
1316 return disableVhookCheckBox;
1320 * This method initializes ViewCommentField
1322 * @return javax.swing.JTextField
1324 private JTextField getViewCommentField() {
1325 if (viewCommentField == null) {
1326 viewCommentField = new JTextField();
1327 viewCommentField.setName("viewCommentField");
1329 return viewCommentField;
1333 * This method initializes ShadowComboBox
1335 * @return javax.swing.JComboBox
1337 private JComboBox getShadowComboBox() {
1338 if (shadowComboBox == null) {
1339 shadowComboBox = new JComboBox(SProperties.ShadowKindArray);
1340 shadowComboBox.setName("shadowComboBox");
1342 return shadowComboBox;
1345 private BasicSetting getBasicSetting() {
1346 String mail = mailAddressField.getText();
1347 String pass = String.valueOf(passwordField.getPassword());
1348 boolean proxyUse = useProxyCheckBox.isSelected();
1349 String proxyHost = proxyTextField.getText();
1352 proxyPort = Integer.parseInt(proxyPortTextField.getText());
1353 } catch (NumberFormatException e) {
1356 // TODO 作業用ディレクトリの設定GUI無し
1357 return new BasicSetting(tempDir, mail, pass, proxyUse, proxyHost, proxyPort);
1360 private InputVideoSetting getInputVideoSetting() {
1362 if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) {
1363 kind = VideoSaveKind.NO_SAVE;
1364 } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) {
1365 kind = VideoSaveKind.NICOBROWSER;
1367 kind = VideoSaveKind.SAVE;
1369 boolean autoNaming = videoSaveInfoPanel.getSaveFolderRadioButton().isSelected();
1370 String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
1371 String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
1372 boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
1373 String nibrFile = videoSaveInfoPanel.getNibrFileField().getText();
1375 return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
1378 private InputCommentSetting getInputCommentSetting() {
1379 boolean download = savePanel.getSavingCommentCheckBox().isSelected();
1380 String file = savePanel.getCommentSavedFileField().getText();
1383 back_comment = Integer.parseInt(savePanel.getCommentNumField().getText());
1384 } catch (NumberFormatException ex) {
1387 boolean delete = savePanel.getDelCommentCheckBox().isSelected();
1388 boolean autoNaming = savePanel.getCommentSaveFolderRadioButton().isSelected();
1389 String folder = savePanel.getCommentSavedFolderField().getText();
1390 boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
1392 return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
1397 * 画面入力値から投稿者コメント設定を作成する.
1398 * @return 作成した投稿者コメント設定.
1400 private InputTcommentSetting getTcommentSetting() {
1401 boolean down = savePanel.isTcommentDownload();
1402 boolean del = savePanel.isTcommentDelete();
1403 boolean naming = savePanel.isTcommentAutoFileName();
1404 String dir = savePanel.getTcommentDirectoryName();
1405 String f = savePanel.getTcommentFileName();
1406 return new InputTcommentSetting(down, naming, dir, f, del);
1409 private OutputVideoSetting getOutputVideoSetting() {
1410 boolean process = savePanel.getSavingConvertedVideoCheckBox().isSelected();
1411 boolean addComment = savePanel.getAddCommentCheckBox().isSelected();
1412 boolean addTcomment = savePanel.getAddTcommentCheckBox().isSelected();
1413 String file = savePanel.getConvertedVideoSavedFileField().getText();
1414 boolean cutId = savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected();
1415 boolean autoNaming = savePanel.getConvSaveFolderRadioButton().isSelected();
1416 String folder = savePanel.getConvertedVideoSavedFolderField().getText();
1418 return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment,
1422 private MovieSetting getMovieSetting() {
1423 String ffmpeg = ffmpegPathField.getText();
1424 String vhook = vhookPathField.getText();
1425 String ext = extOptionField.getText();
1426 String main = mainOptionField.getText();
1427 String in = inputOptionField.getText();
1428 String out = outputOptionField.getText();
1429 String avfilter = avfilterOptionField.getText();
1430 boolean resize = resizeCheckBox.isSelected();
1431 String width = resizeWidthField.getText();
1432 String height = resizeHeigitField.getText();
1433 boolean adjust = adjustRatioCheckBox.isSelected();
1434 File optionFile = FFmpegOptionModel.getSelectedFile();
1436 FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust);
1437 return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
1440 private ConvertSetting getConvertSetting() {
1441 boolean vhookDisabled = disableVhookCheckBox.isSelected();
1442 int maxComment = 30;
1444 maxComment = Integer.parseInt(viewCommentField.getText());
1445 } catch (NumberFormatException ex) {
1447 File font = new File(fontPathField.getText());
1448 int fontIndex = Integer.parseInt(fontIndexField.getText());
1449 int shadowIndex = shadowComboBox.getSelectedIndex();
1450 boolean showConv = showConvVideoCheckBox.isSelected();
1451 boolean adjustFont = fixFontSizeCheckBox.isSelected();
1452 boolean commentOpaque = opaqueCommentCheckBox.isSelected();
1453 NgSetting ngSetting = new NgSetting(ngWordTextField.getText(), ngIdTextField.getText());
1455 return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
1456 commentOpaque, ngSetting);
1459 private class InputVideoPanelButtonListener implements ActionListener {
1461 public void actionPerformed(ActionEvent e) {
1462 final Object source = e.getSource();
1463 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1469 if (source == panel.getShowSavingVideoFolderDialogButton()) {
1470 title = "動画の保存先(フォルダ)";
1471 field = panel.getVideoSavedFolderField();
1474 } else if (source == panel.getShowSavingVideoFileDialogButton()) {
1475 title = "動画の保存先(ファイル)";
1476 field = panel.getVideoSavedFileField();
1479 } else if (source == panel.getNibrFileChooserButton()) {
1480 title = "NicoBrowserファイル選択";
1481 field = panel.getNibrFileField();
1487 showSaveDialog(title, field, isSave, isDir);
1491 private class InputCommentPanelButtonListener implements ActionListener {
1493 public void actionPerformed(ActionEvent e) {
1494 final Object source = e.getSource();
1499 if (source == savePanel.getShowSavingCommentFolderDialogButton()) {
1500 title = "コメントの保存先(フォルダ)";
1501 field = savePanel.getCommentSavedFolderField();
1504 } else if (source == savePanel.getShowSavingCommentFileDialogButton()) {
1505 title = "コメントの保存先(ファイル)";
1506 field = savePanel.getCommentSavedFileField();
1512 showSaveDialog(title, field, isSave, isDir);
1516 private class OutputVideoPanelButtonListener implements ActionListener {
1518 public void actionPerformed(ActionEvent e) {
1519 final Object source = e.getSource();
1524 if (source == savePanel.getShowSavingConvertedVideoFolderDialogButton()) {
1525 title = "コメント付き動画の保存先(フォルダ)";
1526 field = savePanel.getConvertedVideoSavedFolderField();
1529 } else if (source == savePanel.getShowSavingConvertedVideoFileDialogButton()) {
1530 title = "コメント付き動画の保存先(ファイル)";
1531 field = savePanel.getConvertedVideoSavedFileField();
1537 showSaveDialog(title, field, isSave, isDir);
1541 private class VideoUseRadioButtonListener implements ActionListener {
1543 public void actionPerformed(ActionEvent e) {
1544 Object source = e.getSource();
1545 if (source == videoSaveInfoPanel.getVideoUseNiBrButton()) {
1552 private void maskBase() {
1556 private void maskExt() {
1560 private void mask(boolean b) {
1561 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1562 videoIdField.setEditable(b);
1563 panel.getDelVideoCheckBox().setEnabled(b);
1565 panel.getSaveFolderRadioButton().setEnabled(b);
1566 panel.getVideoSavedFolderField().setEnabled(b);
1567 panel.getShowSavingVideoFolderDialogButton().setEnabled(b);
1569 panel.getSaveFileRadioButton().setEnabled(b);
1570 panel.getVideoSavedFileField().setEnabled(b);
1571 panel.getShowSavingVideoFileDialogButton().setEnabled(b);
1573 panel.getNibrFileField().setEnabled(!b);
1574 panel.getNibrFileChooserButton().setEnabled(!b);
1579 class MainFrame_this_windowAdapter extends WindowAdapter {
1581 private MainFrame adaptee;
1583 MainFrame_this_windowAdapter(MainFrame adaptee) {
1584 this.adaptee = adaptee;
1588 public void windowClosing(WindowEvent e) {
1589 adaptee.this_windowClosing(e);
1593 class MainFrame_SettingFontPathButton_actionAdapter implements ActionListener {
1595 private MainFrame adaptee;
1597 MainFrame_SettingFontPathButton_actionAdapter(MainFrame adaptee) {
1598 this.adaptee = adaptee;
1601 public void actionPerformed(ActionEvent e) {
1602 adaptee.SettingFontPathButton_actionPerformed(e);
1606 class MainFrame_SettingVhookPathButton_actionAdapter implements ActionListener {
1608 private MainFrame adaptee;
1610 MainFrame_SettingVhookPathButton_actionAdapter(MainFrame adaptee) {
1611 this.adaptee = adaptee;
1614 public void actionPerformed(ActionEvent e) {
1615 adaptee.SettingVhookPathButton_actionPerformed(e);
1619 class MainFrame_SettingFFmpegPathButton_actionAdapter implements ActionListener {
1621 private MainFrame adaptee;
1623 MainFrame_SettingFFmpegPathButton_actionAdapter(MainFrame adaptee) {
1624 this.adaptee = adaptee;
1627 public void actionPerformed(ActionEvent e) {
1628 adaptee.SettingFFmpegPathButton_actionPerformed(e);
1632 class MainFrame_DoButton_actionAdapter implements ActionListener {
1634 private MainFrame adaptee;
1636 MainFrame_DoButton_actionAdapter(MainFrame adaptee) {
1637 this.adaptee = adaptee;
1640 public void actionPerformed(ActionEvent e) {
1641 adaptee.DoButton_actionPerformed(e);
1645 class MainFrame_jMenuFileExit_ActionAdapter implements ActionListener {
1649 MainFrame_jMenuFileExit_ActionAdapter(MainFrame adaptee) {
1650 this.adaptee = adaptee;
1653 public void actionPerformed(ActionEvent actionEvent) {
1654 adaptee.jMenuFileExit_actionPerformed(actionEvent);
1658 class MainFrame_jMenuHelpAbout_ActionAdapter implements ActionListener {
1662 MainFrame_jMenuHelpAbout_ActionAdapter(MainFrame adaptee) {
1663 this.adaptee = adaptee;
1666 public void actionPerformed(ActionEvent actionEvent) {
1667 adaptee.jMenuHelpAbout_actionPerformed(actionEvent);