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.concurrent.FutureTask;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import javax.swing.BorderFactory;
25 import javax.swing.ButtonGroup;
26 import javax.swing.GroupLayout;
27 import javax.swing.JButton;
28 import javax.swing.JCheckBox;
29 import javax.swing.JComboBox;
30 import javax.swing.JFileChooser;
31 import javax.swing.JFrame;
32 import javax.swing.JLabel;
33 import javax.swing.JMenu;
34 import javax.swing.JMenuBar;
35 import javax.swing.JMenuItem;
36 import javax.swing.JOptionPane;
37 import javax.swing.JPanel;
38 import javax.swing.JPasswordField;
39 import javax.swing.JRadioButton;
40 import javax.swing.JTabbedPane;
41 import javax.swing.JTextField;
42 import javax.swing.LayoutStyle.ComponentPlacement;
43 import javax.swing.SwingUtilities;
44 import nicobrowser.entity.NicoContent;
45 import nicobrowser.main.Main;
46 import org.apache.commons.lang.StringUtils;
47 import saccubus.ConvertStopFlag.State;
48 import saccubus.converter.classic.profile.FfmpegOption;
49 import saccubus.converter.classic.profile.NgSetting;
50 import saccubus.net.TextProgressListener;
51 import saccubus.properties.BasicSetting;
52 import saccubus.properties.ConvertSetting;
53 import saccubus.properties.InputCommentSetting;
54 import saccubus.properties.InputVideoSetting;
55 import saccubus.properties.SProperties;
56 import saccubus.properties.InputTcommentSetting;
57 import saccubus.properties.MovieSetting;
58 import saccubus.properties.OutputVideoSetting;
59 import saccubus.util.FileDropTarget;
60 import saccubus.util.PopupRightClick;
61 import yukihane.nicovideo.NicoDBFinder;
69 * 説明: ニコニコ動画の動画をコメントつきで保存
73 * 著作権: Copyright (c) 2007 PSI
83 public class MainFrame extends JFrame {
85 private static final long serialVersionUID = 2564486741331062989L;
86 public static final String PRODUCT_NAME = "いんきゅばす";
87 public static final String VERSION = "1.7.2 (NicoBrowser" + Main.VERSION + ")";
88 public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
90 // TODO GUIが無いためフィールドに保持.
93 BorderLayout borderLayout1 = new BorderLayout();
94 JMenuBar jMenuBar1 = new JMenuBar();
95 JMenu jMenuFile = new JMenu();
96 JMenuItem jMenuFileExit = new JMenuItem();
97 JMenu jMenuHelp = new JMenu();
98 JMenuItem jMenuHelpAbout = new JMenuItem();
99 JLabel statusBar = new JLabel();
100 JTabbedPane mainTabbedPane = new JTabbedPane();
101 JPanel SavingInfoTabPanel = new JPanel();
102 JPanel FFMpegTabPanel = new JPanel();
104 private JPanel videoInfoPanel = new JPanel();
105 private JPanel opPanel = new JPanel();
106 private JLabel videoIdLabel = new JLabel();
107 private JTextField videoIdField = new JTextField();
108 private JLabel wayBackLabel = new JLabel();
109 private JTextField wayBackField = new JTextField();
110 private JCheckBox reduceCommentCheckBox = new JCheckBox();
111 private JButton doButton = new JButton();
112 public static final String DoButtonDefString = "変換";
113 public static final String DoButtonStopString = "停止";
114 public static final String DoButtonWaitString = "待機";
115 JPanel UserInfoPanel = new JPanel();
116 GridBagLayout gridBagLayout3 = new GridBagLayout();
118 JLabel mailAddressLabel = new JLabel();
119 JTextField mailAddressField = new JTextField();
120 JLabel passwordLabel = new JLabel();
121 JPasswordField passwordField = new JPasswordField();
122 GridBagLayout gridBagLayout4 = new GridBagLayout();
123 GridBagLayout gridBagLayout6 = new GridBagLayout();
124 ButtonGroup CommentSaveButtonGroup = new ButtonGroup();
125 ButtonGroup ConvSaveButtonGroup = new ButtonGroup();
127 private class FfmpegOptionCheckBoxListener implements ActionListener{
130 public void actionPerformed(ActionEvent e) {
131 setFFMpegOptionCheckbox();
134 private final FfmpegOptionCheckBoxListener ffmpegOptionCheckBoxListener = new FfmpegOptionCheckBoxListener();
136 private void setFFMpegOptionCheckbox() {
137 boolean resizable = (resizeCheckBox.isEnabled() && resizeCheckBox.isSelected());
138 resizeWidthField.setEnabled(resizable);
139 resizeHeigitField.setEnabled(resizable);
140 adjustRatioCheckBox.setEnabled(resizable);
144 private void setNames() {
145 mainTabbedPane.setName("mainTabbedPane");
147 mailAddressField.setName("mailAddressField");
148 passwordField.setName("passwordField");
150 ffmpegPathField.setName("ffmpegPathField");
151 vhookPathField.setName("vhookPathField");
153 mainOptionField.setName("mainOptionField");
154 inputOptionField.setName("inputOptionField");
155 outputOptionField.setName("outputOptionField");
157 fontPathField.setName("fontPathField");
158 fontIndexField.setName("fontIndexField");
159 showConvVideoCheckBox.setName("showConvVideoCheckBox");
165 videoSaveInfoPanel = savePanel.getVideoSaveInfoPanel();
168 setDefaultCloseOperation(EXIT_ON_CLOSE);
172 SProperties setting = SProperties.loadSetting(null,
174 this.setSetting(setting);
175 } catch (Exception exception) {
176 exception.printStackTrace();
181 * メイン画面最上部(ID/URL, 過去ログ, 変換ボタン)のパネルを初期化します.
183 private void initVideoInfoPanel() {
185 videoIdLabel.setText("URL/ID");
186 wayBackLabel.setText("過去ログ");
187 videoIdField.setText("http://www.nicovideo.jp/watch/");
188 reduceCommentCheckBox.setText("旧仕様コメント数");
190 final GroupLayout oppLayout = new GroupLayout(opPanel);
191 opPanel.setLayout(oppLayout);
193 oppLayout.setHorizontalGroup(oppLayout.createSequentialGroup()
194 .addGroup(oppLayout.createParallelGroup()
195 .addComponent(videoIdLabel)
196 .addComponent(wayBackLabel))
197 .addGroup(oppLayout.createParallelGroup()
198 .addComponent(videoIdField)
199 .addGroup(oppLayout.createSequentialGroup()
200 .addComponent(wayBackField)
201 .addComponent(reduceCommentCheckBox)))
204 oppLayout.setVerticalGroup(oppLayout.createSequentialGroup()
205 .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
206 .addComponent(videoIdLabel)
207 .addComponent(videoIdField))
208 .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
209 .addComponent(wayBackLabel)
210 .addComponent(wayBackField)
211 .addComponent(reduceCommentCheckBox))
214 doButton.setText(DoButtonDefString);
215 doButton.addActionListener(new MainFrame_DoButton_actionAdapter(this));
217 final GroupLayout vipLayout = new GroupLayout(videoInfoPanel);
218 videoInfoPanel.setLayout(vipLayout);
220 vipLayout.setHorizontalGroup(vipLayout.createSequentialGroup()
221 .addComponent(opPanel).addComponent(doButton));
223 vipLayout.setVerticalGroup(vipLayout.createParallelGroup()
224 .addComponent(opPanel).addComponent(doButton, 10, 20, 50));
230 * @throws java.lang.Exception
232 private void jbInit() throws Exception {
234 initVideoInfoPanel();
236 GridBagConstraints gridBagConstraints74 = new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
237 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
238 gridBagConstraints74.gridwidth = 2;
239 GridBagConstraints gridBagConstraints73 = new GridBagConstraints();
240 gridBagConstraints73.fill = GridBagConstraints.HORIZONTAL;
241 gridBagConstraints73.gridy = 6;
242 gridBagConstraints73.weightx = 1.0;
243 gridBagConstraints73.gridwidth = 4;
244 gridBagConstraints73.insets = new Insets(0, 0, 0, 5);
245 gridBagConstraints73.gridx = 1;
246 GridBagConstraints gridBagConstraints72 = new GridBagConstraints();
247 gridBagConstraints72.gridx = 0;
248 gridBagConstraints72.anchor = GridBagConstraints.WEST;
249 gridBagConstraints72.insets = new Insets(0, 5, 0, 5);
250 gridBagConstraints72.fill = GridBagConstraints.NONE;
251 gridBagConstraints72.gridwidth = 1;
252 gridBagConstraints72.gridy = 6;
253 ShadowKindLabel = new JLabel();
254 ShadowKindLabel.setText("影の種類");
255 ShadowKindLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
256 GridBagConstraints gridBagConstraints66 = new GridBagConstraints();
257 gridBagConstraints66.gridx = 0;
258 gridBagConstraints66.insets = new Insets(0, 5, 5, 5);
259 gridBagConstraints66.anchor = GridBagConstraints.WEST;
260 gridBagConstraints66.gridwidth = 2;
261 gridBagConstraints66.gridy = 1;
262 ViewCommentLabel = new JLabel();
263 ViewCommentLabel.setText("表示コメント数");
264 GridBagConstraints gridBagConstraints65 = new GridBagConstraints();
265 gridBagConstraints65.fill = GridBagConstraints.HORIZONTAL;
266 gridBagConstraints65.gridy = 1;
267 gridBagConstraints65.weightx = 1.0;
268 gridBagConstraints65.gridwidth = 6;
269 gridBagConstraints65.insets = new Insets(0, 5, 5, 5);
270 gridBagConstraints65.gridx = 3;
271 GridBagConstraints gridBagConstraints64 = new GridBagConstraints(1, 1,
272 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
273 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
274 gridBagConstraints64.gridy = 3;
275 gridBagConstraints64.fill = GridBagConstraints.HORIZONTAL;
276 gridBagConstraints64.gridx = 4;
277 GridBagConstraints gridBagConstraints63 = new GridBagConstraints(0, 4,
278 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
279 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
280 gridBagConstraints63.gridy = 7;
281 gridBagConstraints63.gridx = 0;
282 gridBagConstraints63.gridwidth = 5;
283 GridBagConstraints gridBagConstraints62 = new GridBagConstraints(0, 3,
284 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
285 GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0);
286 gridBagConstraints62.gridy = 5;
287 gridBagConstraints62.gridx = 1;
288 gridBagConstraints62.fill = GridBagConstraints.HORIZONTAL;
289 gridBagConstraints62.insets = new Insets(0, 0, 5, 5);
290 gridBagConstraints62.gridwidth = 4;
291 GridBagConstraints gridBagConstraints61 = new GridBagConstraints(0, 2,
292 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
293 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
294 gridBagConstraints61.gridy = 5;
295 gridBagConstraints61.gridx = 0;
296 gridBagConstraints61.fill = GridBagConstraints.VERTICAL;
297 gridBagConstraints61.anchor = GridBagConstraints.WEST;
298 gridBagConstraints61.gridwidth = 1;
299 GridBagConstraints gridBagConstraints60 = new GridBagConstraints(0, 1,
300 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
301 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0);
302 gridBagConstraints60.gridy = 3;
303 gridBagConstraints60.gridx = 1;
304 gridBagConstraints60.fill = GridBagConstraints.HORIZONTAL;
305 gridBagConstraints60.insets = new Insets(0, 0, 0, 5);
306 gridBagConstraints60.gridwidth = 3;
307 GridBagConstraints gridBagConstraints59 = new GridBagConstraints(0, 0,
308 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
309 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0);
310 gridBagConstraints59.gridy = 3;
311 gridBagConstraints59.insets = new Insets(5, 5, 5, 5);
312 gridBagConstraints59.gridx = 0;
313 gridBagConstraints59.fill = GridBagConstraints.NONE;
314 gridBagConstraints59.anchor = GridBagConstraints.WEST;
315 gridBagConstraints59.weightx = 0.0;
316 gridBagConstraints59.gridwidth = 1;
317 GridBagConstraints gridBagConstraints58 = new GridBagConstraints();
318 gridBagConstraints58.gridx = 0;
319 gridBagConstraints58.anchor = GridBagConstraints.WEST;
320 gridBagConstraints58.insets = new Insets(0, 5, 5, 5);
321 gridBagConstraints58.gridwidth = 5;
322 gridBagConstraints58.weightx = 1.0;
323 gridBagConstraints58.fill = GridBagConstraints.HORIZONTAL;
324 gridBagConstraints58.gridy = 0;
326 GridBagConstraints gridBagConstraints54 = new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
327 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
328 gridBagConstraints54.gridwidth = 3;
330 GridBagConstraints gridBagConstraints33 = new GridBagConstraints();
331 gridBagConstraints33.gridx = 0;
332 gridBagConstraints33.fill = GridBagConstraints.HORIZONTAL;
333 gridBagConstraints33.weightx = 1.0;
334 gridBagConstraints33.insets = new Insets(0, 5, 5, 5);
335 gridBagConstraints33.gridwidth = 5;
336 gridBagConstraints33.gridy = 9;
338 GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
339 gridBagConstraints14.gridx = 0;
340 gridBagConstraints14.anchor = GridBagConstraints.WEST;
341 gridBagConstraints14.fill = GridBagConstraints.HORIZONTAL;
342 gridBagConstraints14.weightx = 1.0;
343 gridBagConstraints14.gridwidth = 5;
344 gridBagConstraints14.insets = new Insets(0, 5, 0, 5);
345 gridBagConstraints14.gridy = 8;
346 GridBagConstraints gridBagConstraints7 = new GridBagConstraints(0, 0,
347 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
348 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
349 gridBagConstraints7.weighty = 0.0;
350 GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
351 gridBagConstraints6.gridx = 0;
352 gridBagConstraints6.weighty = 1.0;
353 gridBagConstraints6.weightx = 1.0;
354 gridBagConstraints6.insets = new Insets(0, 5, 0, 5);
355 gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL;
356 gridBagConstraints6.anchor = GridBagConstraints.NORTH;
357 gridBagConstraints6.gridy = 1;
358 GridBagConstraints gridBagConstraints1 = new GridBagConstraints(0, 1,
359 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
360 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
361 gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
362 gridBagConstraints1.anchor = GridBagConstraints.NORTH;
363 gridBagConstraints1.weighty = 1.0;
365 this.setIconImage(WinIcon);
366 contentPane = (JPanel) this.getContentPane();
367 contentPane.setLayout(borderLayout1);
368 setSize(new Dimension(400, 450));
369 setTitle(PRODUCT_NAME + " " + VERSION);
370 this.addWindowListener(new MainFrame_this_windowAdapter(this));
371 statusBar.setText(" ");
372 jMenuFile.setText("ファイル");
373 jMenuFileExit.setText("終了");
374 jMenuFileExit.addActionListener(new MainFrame_jMenuFileExit_ActionAdapter(
376 jMenuHelp.setText("ヘルプ");
377 jMenuHelpAbout.setText("バージョン情報");
378 jMenuHelpAbout.addActionListener(new MainFrame_jMenuHelpAbout_ActionAdapter(
380 SavingInfoTabPanel.setLayout(new GridLayout());
381 UserInfoPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "ユーザ設定"));
382 UserInfoPanel.setLayout(gridBagLayout3);
383 mailAddressLabel.setText("メールアドレス");
384 passwordLabel.setText("パスワード");
386 setListenerToSavePanelButton();
388 FFMpegTabPanel.setLayout(gridBagLayout6);
389 PathSettingPanel.setBorder(BorderFactory.createTitledBorder(
390 BorderFactory.createEtchedBorder(), "プログラムの位置の設定"));
391 PathSettingPanel.setLayout(gridBagLayout7);
392 FFmpegPathLabel.setText("FFmpeg");
393 SettingFFmpegPathButton.setText("参照");
394 SettingFFmpegPathButton.addActionListener(new MainFrame_SettingFFmpegPathButton_actionAdapter(
396 VhookPathLabel.setText("拡張vhookライブラリ");
397 SettingVhookPathButton.setText("参照");
398 SettingVhookPathButton.addActionListener(new MainFrame_SettingVhookPathButton_actionAdapter(
400 VhookSettingPanel.setLayout(gridBagLayout8);
401 VhookSettingPanel.setBorder(BorderFactory.createTitledBorder(
402 BorderFactory.createEtchedBorder(), "拡張vhookライブラリの設定"));
403 FFmpegSettingPanel.setBorder(BorderFactory.createTitledBorder(
404 BorderFactory.createEtchedBorder(), "FFmpegの設定"));
405 FFmpegSettingPanel.setLayout(gblFFmpegSettingPanel);
406 FontPathLabel.setText("フォントパス");
407 SettingFontPathButton.setText("参照");
408 SettingFontPathButton.addActionListener(new MainFrame_SettingFontPathButton_actionAdapter(
410 showConvVideoCheckBox.setText("変換中の画像を表示する");
412 extOptionLabel.setText("出力動画の拡張子");
413 inputOptionLabel.setText("入力オプション");
414 outputOptionLabel.setText("出力オプション");
415 mainOptionLabel.setText("メインオプション");
416 avfilterOptionLabel.setText("avfilterオプション");
418 FontIndexLabel.setText("フォント番号");
420 BasicInfoTabPanel.setLayout(gridBagLayout12);
421 jMenuBar1.add(jMenuFile);
422 jMenuFile.add(jMenuFileExit);
423 jMenuBar1.add(jMenuHelp);
424 jMenuHelp.add(jMenuHelpAbout);
425 setJMenuBar(jMenuBar1);
427 contentPane.add(statusBar, BorderLayout.SOUTH);
428 contentPane.add(mainTabbedPane, java.awt.BorderLayout.CENTER);
429 contentPane.add(videoInfoPanel, java.awt.BorderLayout.NORTH);
430 UserInfoPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1,
431 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
432 new Insets(0, 5, 5, 5), 0, 0));
433 UserInfoPanel.add(mailAddressField, new GridBagConstraints(1, 0, 1, 1,
434 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
435 new Insets(0, 5, 5, 5), 0, 0));
436 UserInfoPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1,
437 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
438 new Insets(0, 5, 5, 0), 0, 0));
439 UserInfoPanel.add(mailAddressLabel, new GridBagConstraints(0, 0, 1, 1,
440 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
441 new Insets(0, 5, 5, 0), 0, 0));
442 PathSettingPanel.add(ffmpegPathField, new GridBagConstraints(0, 1, 1,
443 1, 1.0, 0.0, GridBagConstraints.CENTER,
444 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));
445 PathSettingPanel.add(SettingFFmpegPathButton, gridBagConstraints74);
446 PathSettingPanel.add(FFmpegPathLabel, new GridBagConstraints(0, 0, 2,
447 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
448 new Insets(0, 5, 5, 5), 0, 0));
449 PathSettingPanel.add(vhookPathField, new GridBagConstraints(0, 3, 1, 1,
450 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
451 new Insets(0, 5, 5, 5), 0, 0));
452 PathSettingPanel.add(SettingVhookPathButton, new GridBagConstraints(1,
453 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
454 GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
455 PathSettingPanel.add(VhookPathLabel, gridBagConstraints54);
458 final GroupLayout layout = new GroupLayout(FFmpegSettingPanel);
459 FFmpegSettingPanel.setLayout(layout);
461 layout.setHorizontalGroup(layout.createParallelGroup()
462 .addComponent(getFFmpegOptionComboBoxPanel())
463 .addGroup(layout.createSequentialGroup()
464 .addGroup(layout.createParallelGroup()
465 .addComponent(extOptionLabel)
466 .addComponent(mainOptionLabel)
467 .addComponent(inputOptionLabel)
468 .addComponent(outputOptionLabel)
469 .addComponent(avfilterOptionLabel)
471 .addPreferredGap(ComponentPlacement.RELATED)
472 .addGroup(layout.createParallelGroup()
473 .addComponent(extOptionField)
474 .addComponent(mainOptionField)
475 .addComponent(inputOptionField)
476 .addComponent(outputOptionField)
477 .addComponent(avfilterOptionField)
480 .addGroup(layout.createParallelGroup()
481 .addGroup(layout.createSequentialGroup()
482 .addComponent(resizeCheckBox)
483 .addPreferredGap(ComponentPlacement.UNRELATED)
484 .addComponent(resizeWidthLabel)
485 .addPreferredGap(ComponentPlacement.RELATED)
486 .addComponent(resizeWidthField)
487 .addPreferredGap(ComponentPlacement.UNRELATED)
488 .addComponent(resizeHeightLabel)
489 .addPreferredGap(ComponentPlacement.RELATED)
490 .addComponent(resizeHeigitField)
493 .addGroup(layout.createSequentialGroup()
495 .addComponent(adjustRatioCheckBox))
496 .addGroup(layout.createSequentialGroup()
501 layout.setVerticalGroup(layout.createSequentialGroup()
502 .addComponent(getFFmpegOptionComboBoxPanel())
503 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
504 .addComponent(extOptionLabel)
505 .addComponent(extOptionField))
506 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
507 .addComponent(mainOptionLabel)
508 .addComponent(mainOptionField))
509 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
510 .addComponent(inputOptionLabel)
511 .addComponent(inputOptionField))
512 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
513 .addComponent(outputOptionLabel)
514 .addComponent(outputOptionField))
515 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
516 .addComponent(avfilterOptionLabel)
517 .addComponent(avfilterOptionField))
518 .addGroup(layout.createSequentialGroup()
519 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
520 .addComponent(resizeCheckBox)
521 .addComponent(resizeWidthLabel)
522 .addComponent(resizeWidthField)
523 .addComponent(resizeHeightLabel)
524 .addComponent(resizeHeigitField))
525 .addComponent(adjustRatioCheckBox)
529 resizeCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
530 adjustRatioCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
531 setFFMpegOptionCheckbox();
535 mainTabbedPane.add(BasicInfoTabPanel, "基本設定");
536 mainTabbedPane.add(SavingInfoTabPanel, "保存設定");
537 mainTabbedPane.add(FFMpegTabPanel, "動画設定");
538 mainTabbedPane.addTab("変換設定", null, getConvertingSettingPanel(), null);
539 SavingInfoTabPanel.add(savePanel);
540 BasicInfoTabPanel.add(UserInfoPanel, gridBagConstraints7);
541 BasicInfoTabPanel.add(getProxyInfoPanel(), gridBagConstraints6);
542 VhookSettingPanel.add(FontPathLabel, gridBagConstraints59);
543 VhookSettingPanel.add(showConvVideoCheckBox, gridBagConstraints63);
544 VhookSettingPanel.add(fontPathField, gridBagConstraints60);
545 VhookSettingPanel.add(fontIndexField, gridBagConstraints62);
546 VhookSettingPanel.add(FontIndexLabel, gridBagConstraints61);
547 VhookSettingPanel.add(SettingFontPathButton, gridBagConstraints64);
548 VhookSettingPanel.add(getFixFontSizeCheckBox(), gridBagConstraints14);
549 VhookSettingPanel.add(getOpaqueCommentCheckBox(), gridBagConstraints33);
550 VhookSettingPanel.add(getNotUseVhookCheckBox(), gridBagConstraints58);
551 VhookSettingPanel.add(getViewCommentField(), gridBagConstraints65);
552 VhookSettingPanel.add(ViewCommentLabel, gridBagConstraints66);
553 VhookSettingPanel.add(ShadowKindLabel, gridBagConstraints72);
554 VhookSettingPanel.add(getShadowComboBox(), gridBagConstraints73);
556 FFMpegTabPanel.add(PathSettingPanel, new GridBagConstraints(0, 0, 1, 1,
557 1.0, 0.0, GridBagConstraints.NORTHEAST,
558 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
559 FFMpegTabPanel.add(FFmpegSettingPanel, gridBagConstraints1);
563 * 保存設定パネル内のボタンにアクションリスナを割り当てる.
565 private void setListenerToSavePanelButton() {
567 al = new InputVideoPanelButtonListener();
568 videoSaveInfoPanel.getShowSavingVideoFolderDialogButton().addActionListener(al);
569 videoSaveInfoPanel.getShowSavingVideoFileDialogButton().addActionListener(al);
570 videoSaveInfoPanel.getNibrFileChooserButton().addActionListener(al);
572 al = new VideoUseRadioButtonListener();
573 videoSaveInfoPanel.getVideoNoSaveButton().addActionListener(al);
574 videoSaveInfoPanel.getVideoSaveButton().addActionListener(al);
575 videoSaveInfoPanel.getVideoUseNiBrButton().addActionListener(al);
577 al = new InputCommentPanelButtonListener();
578 savePanel.getShowSavingCommentFolderDialogButton().addActionListener(al);
579 savePanel.getShowSavingCommentFileDialogButton().addActionListener(al);
581 al = new OutputVideoPanelButtonListener();
582 savePanel.getShowSavingConvertedVideoFolderDialogButton().addActionListener(al);
583 savePanel.getShowSavingConvertedVideoFileDialogButton().addActionListener(al);
586 private void setPopup() {
587 mainOptionField.addMouseListener(new PopupRightClick(
588 this.mainOptionField));
589 inputOptionField.addMouseListener(new PopupRightClick(
590 this.inputOptionField));
591 outputOptionField.addMouseListener(new PopupRightClick(
592 this.outputOptionField));
593 savePanel.getCommentNumField().addMouseListener(new PopupRightClick(
594 savePanel.getCommentNumField()));
596 savePanel.getCommentSavedFileField().addMouseListener(new PopupRightClick(
597 savePanel.getCommentSavedFileField()));
598 savePanel.getCommentSavedFolderField().addMouseListener(new PopupRightClick(
599 savePanel.getCommentSavedFolderField()));
601 savePanel.getConvertedVideoSavedFileField().addMouseListener(new PopupRightClick(
602 savePanel.getConvertedVideoSavedFileField()));
603 savePanel.getConvertedVideoSavedFolderField().addMouseListener(new PopupRightClick(
604 savePanel.getConvertedVideoSavedFolderField()));
606 videoSaveInfoPanel.getVideoSavedFileField().addMouseListener(new PopupRightClick(
607 videoSaveInfoPanel.getVideoSavedFileField()));
608 videoSaveInfoPanel.getVideoSavedFolderField().addMouseListener(new PopupRightClick(
609 videoSaveInfoPanel.getVideoSavedFolderField()));
610 videoSaveInfoPanel.getNibrFileField().addMouseListener(
611 new PopupRightClick(videoSaveInfoPanel.getNibrFileField()));
613 ffmpegPathField.addMouseListener(new PopupRightClick(
614 this.ffmpegPathField));
615 vhookPathField.addMouseListener(new PopupRightClick(this.vhookPathField));
616 videoIdField.addMouseListener(new PopupRightClick(
618 viewCommentField.addMouseListener(new PopupRightClick(
619 this.viewCommentField));
620 fontPathField.addMouseListener(new PopupRightClick(this.fontPathField));
621 mailAddressField.addMouseListener(new PopupRightClick(this.mailAddressField));
622 passwordField.addMouseListener(new PopupRightClick(this.passwordField));
623 wayBackField.addMouseListener(new PopupRightClick(this.wayBackField));
625 proxyTextField.addMouseListener(new PopupRightClick(this.proxyTextField));
626 proxyPortTextField.addMouseListener(new PopupRightClick(
627 this.proxyPortTextField));
629 fontIndexField.addMouseListener(new PopupRightClick(this.fontIndexField));
631 ngWordTextField.addMouseListener(new PopupRightClick(
632 this.ngWordTextField));
633 ngIdTextField.addMouseListener(new PopupRightClick(this.ngIdTextField));
636 private void setDropTarget() {
637 addTarget(videoSaveInfoPanel.getVideoSavedFileField(), false);
638 addTarget(videoSaveInfoPanel.getVideoSavedFolderField(), true);
639 addTarget(videoSaveInfoPanel.getNibrFileField(), false);
641 addTarget(savePanel.getCommentSavedFileField(), false);
642 addTarget(savePanel.getCommentSavedFolderField(), true);
644 addTarget(savePanel.getConvertedVideoSavedFileField(), false);
645 addTarget(savePanel.getConvertedVideoSavedFolderField(), true);
647 addTarget(ffmpegPathField, false);
648 addTarget(vhookPathField, false);
649 addTarget(fontPathField, false);
654 * テキストフィールドに対しドロップを行った場合にファイルもしくはディレクトリの文字列を設定できるようにする.
655 * @param c 設定対象のテキストフィールドオブジェクト.
656 * @param isDir ディレクトリを設定する場合はtrue, ファイルの場合はfalse.
657 * @return ドロップターゲット(用途無し).
659 private DropTarget addTarget(JTextField c, boolean isDir) {
660 return new DropTarget(c, DnDConstants.ACTION_COPY, new FileDropTarget(
663 private File CurrentDir = new File(".");
664 private JPanel PathSettingPanel = new JPanel();
665 private JLabel FFmpegPathLabel = new JLabel();
666 private GridBagLayout gridBagLayout7 = new GridBagLayout();
667 private JTextField ffmpegPathField = new JTextField();
668 private JButton SettingFFmpegPathButton = new JButton();
669 private JLabel VhookPathLabel = new JLabel();
670 private JTextField vhookPathField = new JTextField();
671 private JButton SettingVhookPathButton = new JButton();
672 private JPanel VhookSettingPanel = new JPanel();
673 private GridBagLayout gridBagLayout8 = new GridBagLayout();
674 private JPanel FFmpegSettingPanel = new JPanel();
675 private GridBagLayout gblFFmpegSettingPanel = new GridBagLayout();
676 private JLabel FontPathLabel = new JLabel();
677 private JTextField fontPathField = new JTextField();
678 private JButton SettingFontPathButton = new JButton();
679 private JCheckBox showConvVideoCheckBox = new JCheckBox();
681 private void showSaveDialog(String title, JTextField field, boolean isSave,
683 JFileChooser chooser = new JFileChooser(CurrentDir);
684 chooser.setDialogTitle(title);
687 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
690 code = chooser.showSaveDialog(this);
692 code = chooser.showOpenDialog(this);
694 if (code == JFileChooser.APPROVE_OPTION) {
696 CurrentDir = chooser.getSelectedFile();
697 field.setText(CurrentDir.getAbsolutePath());
699 File selected = chooser.getSelectedFile();
700 CurrentDir = chooser.getCurrentDirectory();
701 field.setText(selected.getAbsolutePath());
706 private SProperties getSetting() {
707 SProperties setting = new SProperties(
709 getInputVideoSetting(),
710 getInputCommentSetting(),
711 getTcommentSetting(),
712 getOutputVideoSetting(),
714 getConvertSetting());
720 * @param setting 反映する設定.
722 private void setSetting(SProperties setting) {
724 final BasicSetting basic = setting.getBasicSetting();
725 tempDir = basic.getTempDir();
726 mailAddressField.setText(basic.getUser().getMail());
727 passwordField.setText(basic.getUser().getPassword());
729 useProxyCheckBox.setSelected(basic.isProxyUse());
730 proxyTextField.setText(basic.getProxyHost());
731 int proxy_port = basic.getProxyPort();
732 if (proxy_port >= 0 && proxy_port <= 65535) {
733 proxyPortTextField.setText(Integer.toString(proxy_port));
735 proxyPortTextField.setText("");
739 final InputVideoSetting inVideo = setting.getInputVideoSetting();
740 JRadioButton activeButton;
741 switch (inVideo.getProcessKind()) {
743 activeButton = videoSaveInfoPanel.getVideoNoSaveButton();
746 activeButton = videoSaveInfoPanel.getVideoUseNiBrButton();
750 activeButton = videoSaveInfoPanel.getVideoSaveButton();
753 activeButton.doClick();
755 videoSaveInfoPanel.getVideoSavedFileField().setText(inVideo.getFile().getPath());
756 videoSaveInfoPanel.getVideoSavedFolderField().setText(inVideo.getFolder().getPath());
757 videoSaveInfoPanel.getDelVideoCheckBox().setSelected(inVideo.isDeleteAfterConvert());
758 final boolean videoFixName = inVideo.isAutoNaming();
759 videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
760 videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
761 videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath());
764 final InputCommentSetting inputComment = setting.getInputCommentSetting();
765 savePanel.getSavingCommentCheckBox().setSelected(inputComment.getProcessKind());
766 savePanel.getCommentSavedFileField().setText(inputComment.getFile().getPath());
767 savePanel.getDelCommentCheckBox().setSelected(inputComment.isDeleteAfterConvert());
768 savePanel.getCommentSavedFolderField().setText(inputComment.getFolder().getPath());
769 savePanel.getCommentNumField().setText(Integer.toString(inputComment.getNumOfComment()));
770 savePanel.getFixCommentNumCheckBox().setSelected(inputComment.isSelfAdjustNumOfComment());
771 boolean commentFixName = inputComment.isAutoNaming();
772 savePanel.getCommentSaveFileRadioButton().setSelected(!commentFixName);
773 savePanel.getCommentSaveFolderRadioButton().setSelected(commentFixName);
776 InputTcommentSetting tcom = setting.getInputTcommentSetting();
777 savePanel.setTcommentDownload(tcom.getProcessKind());
778 savePanel.setTcommentDelete(tcom.isDeleteAfterConvert());
779 savePanel.setTcommentAutoFileName(tcom.isAutoNaming());
780 savePanel.setTcommentDirectoryName(tcom.getFolder().getPath());
781 savePanel.setTcommentFileName(tcom.getFile().getPath());
784 final OutputVideoSetting outputVideo = setting.getOutputVideoSetting();
785 savePanel.getSavingConvertedVideoCheckBox().setSelected(outputVideo.getProcessKind());
786 savePanel.getAddCommentCheckBox().setSelected(outputVideo.isAddComment());
787 savePanel.getAddTcommentCheckBox().setSelected(outputVideo.isAddTcomment());
788 savePanel.getConvertedVideoSavedFileField().setText(outputVideo.getFile().getPath());
789 savePanel.getConvertedVideoSavedFolderField().setText(outputVideo.getFolder().getPath());
790 savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(outputVideo.isCutIdName());
791 boolean convFixName = outputVideo.isAutoNaming();
792 savePanel.getConvSaveFileRadioButton().setSelected(!convFixName);
793 savePanel.getConvSaveFolderRadioButton().setSelected(convFixName);
796 final MovieSetting movie = setting.getMovieSetting();
797 ffmpegPathField.setText(movie.getFfmpeg().toString());
798 vhookPathField.setText(movie.getVhook().toString());
799 extOptionField.setText(movie.getFfmpegOption().getExtOption());
800 mainOptionField.setText(movie.getFfmpegOption().getMainOption());
801 inputOptionField.setText(movie.getFfmpegOption().getInOption());
802 outputOptionField.setText(movie.getFfmpegOption().getOutOption());
803 avfilterOptionField.setText(movie.getFfmpegOption().getAvfilterOption());
804 resizeCheckBox.setSelected(movie.getFfmpegOption().isResize());
805 resizeWidthField.setText(Integer.toString(movie.getFfmpegOption().getResizeWidth()));
806 resizeHeigitField.setText(Integer.toString(movie.getFfmpegOption().getResizeHeight()));
807 adjustRatioCheckBox.setSelected(movie.getFfmpegOption().isAdjustRatio());
808 FFmpegOptionModel.reload(movie.getOptionFile());
811 final ConvertSetting conv = setting.getConvertSetting();
812 disableVhookCheckBox.setSelected(conv.isVhookDisabled());
813 viewCommentField.setText(Integer.toString(conv.getMaxNumOfComment()));
814 fontPathField.setText(conv.getFont().toString());
815 fontIndexField.setText(Integer.toString(conv.getFontIndex()));
816 shadowComboBox.setSelectedIndex(conv.getShadowIndex());
817 showConvVideoCheckBox.setSelected(conv.isShowConverting());
818 fixFontSizeCheckBox.setSelected(conv.isSelfAdjustFontSize());
819 opaqueCommentCheckBox.setSelected(conv.isCommentOpaque());
820 ngWordTextField.setText(conv.getNgSetting().getWord());
821 ngIdTextField.setText(conv.getNgSetting().getId());
825 * [ファイル|終了] アクションが実行されました。
830 void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
832 SProperties setting = getSetting();
833 SProperties.saveSetting(setting);
834 } catch (Throwable t) {
835 Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "設定保存に失敗", t);
841 * [ヘルプ|バージョン情報] アクションが実行されました。
846 void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
847 MainFrame_AboutBox dlg = new MainFrame_AboutBox(this);
849 dlg.setLocationRelativeTo(this);
850 dlg.setVisible(true);
854 private Converter Converter = null;
856 private final JLabel extOptionLabel = new JLabel();
857 private final JTextField extOptionField = new JTextField();
858 private JLabel mainOptionLabel = new JLabel();
859 private JTextField mainOptionField = new JTextField();
860 private JLabel inputOptionLabel = new JLabel();
861 private JTextField inputOptionField = new JTextField();
862 private JLabel outputOptionLabel = new JLabel();
863 private JTextField outputOptionField = new JTextField();
864 private final JLabel avfilterOptionLabel = new JLabel();
865 private final JTextField avfilterOptionField = new JTextField();
866 private final JCheckBox resizeCheckBox = new JCheckBox("次のサイズに収まるよう縮小(-s)");
867 private final JLabel resizeWidthLabel = new JLabel("横");
868 private final JTextField resizeWidthField = new NumberFormattedTextField();
869 private final JLabel resizeHeightLabel = new JLabel("縦");
870 private final JTextField resizeHeigitField = new NumberFormattedTextField();
871 private final JCheckBox adjustRatioCheckBox = new JCheckBox("アスペクト比を維持");
873 private JLabel FontIndexLabel = new JLabel();
874 private JTextField fontIndexField = new JTextField();
875 private JPanel BasicInfoTabPanel = new JPanel();
876 private GridBagLayout gridBagLayout12 = new GridBagLayout();
877 private JPanel ConvertingSettingPanel = null;
878 private JPanel NGWordSettingPanel = null;
879 private JLabel NGWordLabel = null;
880 private JTextField ngWordTextField = null;
881 private JLabel NGIDLabel = null;
882 private JTextField ngIdTextField = null;
884 private JPanel ProxyInfoPanel = null;
885 private JCheckBox useProxyCheckBox = null;
886 private JLabel proxyLabel = null;
887 private JTextField proxyTextField = null;
888 private JLabel proxyPortLabel = null;
889 private JTextField proxyPortTextField = null;
891 private JCheckBox fixFontSizeCheckBox = null;
892 private JCheckBox opaqueCommentCheckBox = null;
893 private final SavePanel savePanel = new SavePanel();
894 private final VideoSaveInfoPanel videoSaveInfoPanel;
895 private JComboBox FFmpegOptionComboBox = null;
896 private JButton FFmpegOptionReloadButton = null;
897 private JPanel FFmpegOptionComboBoxPanel = null;
899 public void DoButton_actionPerformed(ActionEvent e) {
900 if (Converter == null || Converter.isConverted()) {
903 } catch (Exception ex) {
904 String text = ex.getMessage();
905 if (StringUtils.isEmpty(text)) {
906 text = "予期しないエラーのため中断しました。";
908 ex.printStackTrace();
909 statusBar.setText(text);
911 } else { /* 開始しているので、ストップする。 */
912 final ConvertStopFlag flag = Converter.getStopFlag();
913 if (!flag.needStop()) { /* まだストップしていない。 */
919 private void executeConvert() throws IOException {
922 // NicoBrowserファイルを利用する場合は、ファイル名からビデオIDを特定.
923 if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
925 String fileName = videoSaveInfoPanel.getNibrFileField().getText();
926 NicoDBFinder finder = NicoDBFinder.getInstance();
927 NicoContent info = finder.findNicoContent(fileName);
929 url = info.getNicoId();
933 } catch (Exception ex) {
934 JOptionPane.showMessageDialog(this, ex.getMessage(), "エラー", JOptionPane.ERROR_MESSAGE);
938 url = videoIdField.getText();
941 TextProgressListener sl = new TextProgressListener() {
943 public void setText(final String text) {
944 SwingUtilities.invokeLater(new Runnable() {
947 statusBar.setText(text);
953 ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
955 public void changeState(final State s) {
956 SwingUtilities.invokeLater(new Runnable() {
961 doButton.setText(DoButtonWaitString);
964 doButton.setText(DoButtonDefString);
971 Converter = new Converter(url, wayBackField.getText(), getSetting().toProfile(), sl,
972 new ConvertStopFlag(scl));
973 doButton.setText(DoButtonStopString);
974 FutureTask<Boolean> task = new FutureTask<Boolean>(Converter);
975 new Thread(task).start();
980 public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
981 showSaveDialog("FFmpegへのパス", ffmpegPathField, false, false);
984 public void SettingVhookPathButton_actionPerformed(ActionEvent e) {
985 showSaveDialog("拡張vhookライブラリへのパス", vhookPathField, false, false);
988 public void SettingFontPathButton_actionPerformed(ActionEvent e) {
989 showSaveDialog("フォントへのパス", fontPathField, false, false);
992 public void this_windowClosing(WindowEvent e) {
993 this.jMenuFileExit_actionPerformed(null);
997 * This method initializes ConvertingSettingPanel
999 * @return javax.swing.JPanel
1001 private JPanel getConvertingSettingPanel() {
1002 if (ConvertingSettingPanel == null) {
1003 GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
1004 gridBagConstraints11.weighty = 1.0;
1005 gridBagConstraints11.weightx = 1.0;
1006 gridBagConstraints11.insets = new Insets(0, 5, 0, 5);
1007 gridBagConstraints11.gridy = 1;
1008 gridBagConstraints11.gridx = 0;
1009 gridBagConstraints11.anchor = GridBagConstraints.NORTH;
1010 gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
1011 GridBagConstraints gridBagConstraints = new GridBagConstraints(0,
1012 2, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
1013 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
1014 gridBagConstraints.gridx = 0;
1015 gridBagConstraints.anchor = GridBagConstraints.CENTER;
1016 gridBagConstraints.weighty = 0.0;
1017 gridBagConstraints.gridy = 0;
1018 ConvertingSettingPanel = new JPanel();
1019 ConvertingSettingPanel.setLayout(new GridBagLayout());
1020 ConvertingSettingPanel.add(getNGWordSettingPanel(),
1021 gridBagConstraints11);
1022 ConvertingSettingPanel.add(VhookSettingPanel, gridBagConstraints);
1024 return ConvertingSettingPanel;
1028 * This method initializes NGWordSettingPanel
1030 * @return javax.swing.JPanel
1032 private JPanel getNGWordSettingPanel() {
1033 if (NGWordSettingPanel == null) {
1034 GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
1035 gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
1036 gridBagConstraints5.gridy = 1;
1037 gridBagConstraints5.weightx = 1.0;
1038 gridBagConstraints5.insets = new Insets(0, 5, 5, 5);
1039 gridBagConstraints5.gridx = 1;
1040 GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
1041 gridBagConstraints4.gridx = 0;
1042 gridBagConstraints4.anchor = GridBagConstraints.WEST;
1043 gridBagConstraints4.insets = new Insets(0, 5, 5, 0);
1044 gridBagConstraints4.gridy = 1;
1045 NGIDLabel = new JLabel();
1046 NGIDLabel.setText("NG ID");
1047 GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
1048 gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
1049 gridBagConstraints3.gridy = 0;
1050 gridBagConstraints3.weightx = 1.0;
1051 gridBagConstraints3.insets = new Insets(0, 5, 5, 5);
1052 gridBagConstraints3.gridx = 1;
1053 GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
1054 gridBagConstraints2.gridx = 0;
1055 gridBagConstraints2.insets = new Insets(0, 5, 5, 0);
1056 gridBagConstraints2.gridy = 0;
1057 NGWordLabel = new JLabel();
1058 NGWordLabel.setText("NGワード");
1059 NGWordSettingPanel = new JPanel();
1060 NGWordSettingPanel.setLayout(new GridBagLayout());
1061 NGWordSettingPanel.setBorder(BorderFactory.createTitledBorder(null,
1062 "NGワード・ID設定(半角スペース区切りで複数入力)"));
1063 NGWordSettingPanel.add(NGWordLabel, gridBagConstraints2);
1064 NGWordSettingPanel.add(getNGWordTextField(), gridBagConstraints3);
1065 NGWordSettingPanel.add(NGIDLabel, gridBagConstraints4);
1066 NGWordSettingPanel.add(getNGIDTextField(), gridBagConstraints5);
1068 return NGWordSettingPanel;
1072 * This method initializes NGWordTextField
1074 * @return javax.swing.JTextField
1076 private JTextField getNGWordTextField() {
1077 if (ngWordTextField == null) {
1078 ngWordTextField = new JTextField();
1079 ngWordTextField.setName("ngWordTextField");
1081 return ngWordTextField;
1085 * This method initializes NGIDTextField
1087 * @return javax.swing.JTextField
1089 private JTextField getNGIDTextField() {
1090 if (ngIdTextField == null) {
1091 ngIdTextField = new JTextField();
1092 ngIdTextField.setName("ngIdTextField");
1094 return ngIdTextField;
1098 * This method initializes ProxyInfoPanel
1100 * @return javax.swing.JPanel
1102 private JPanel getProxyInfoPanel() {
1103 if (ProxyInfoPanel == null) {
1104 GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
1105 gridBagConstraints13.gridx = 0;
1106 gridBagConstraints13.gridwidth = 2;
1107 gridBagConstraints13.weightx = 1.0;
1108 gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL;
1109 gridBagConstraints13.insets = new Insets(0, 5, 0, 5);
1110 gridBagConstraints13.gridy = 0;
1111 GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
1112 gridBagConstraints12.fill = GridBagConstraints.HORIZONTAL;
1113 gridBagConstraints12.gridy = 2;
1114 gridBagConstraints12.weightx = 1.0;
1115 gridBagConstraints12.insets = new Insets(5, 0, 5, 5);
1116 gridBagConstraints12.gridx = 1;
1117 GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
1118 gridBagConstraints10.gridx = 0;
1119 gridBagConstraints10.insets = new Insets(5, 5, 5, 5);
1120 gridBagConstraints10.gridy = 2;
1121 proxyPortLabel = new JLabel();
1122 proxyPortLabel.setText("ポート番号");
1123 GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
1124 gridBagConstraints9.fill = GridBagConstraints.BOTH;
1125 gridBagConstraints9.gridy = 1;
1126 gridBagConstraints9.weightx = 1.0;
1127 gridBagConstraints9.insets = new Insets(0, 0, 0, 5);
1128 gridBagConstraints9.gridx = 1;
1129 GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
1130 gridBagConstraints8.gridx = 0;
1131 gridBagConstraints8.insets = new Insets(0, 5, 0, 5);
1132 gridBagConstraints8.fill = GridBagConstraints.NONE;
1133 gridBagConstraints8.anchor = GridBagConstraints.EAST;
1134 gridBagConstraints8.gridy = 1;
1135 proxyLabel = new JLabel();
1136 proxyLabel.setText("プロキシ");
1137 ProxyInfoPanel = new JPanel();
1138 ProxyInfoPanel.setLayout(new GridBagLayout());
1139 ProxyInfoPanel.setBorder(BorderFactory.createTitledBorder(null,
1141 ProxyInfoPanel.add(proxyLabel, gridBagConstraints8);
1142 ProxyInfoPanel.add(getProxyTextField(), gridBagConstraints9);
1143 ProxyInfoPanel.add(proxyPortLabel, gridBagConstraints10);
1144 ProxyInfoPanel.add(getProxyPortTextField(), gridBagConstraints12);
1145 ProxyInfoPanel.add(getUseProxyCheckBox(), gridBagConstraints13);
1147 return ProxyInfoPanel;
1151 * This method initializes ProxyTextField
1153 * @return javax.swing.JTextField
1155 private JTextField getProxyTextField() {
1156 if (proxyTextField == null) {
1157 proxyTextField = new JTextField();
1158 proxyTextField.setName("proxyTextField");
1160 return proxyTextField;
1164 * This method initializes ProxyPortTextField
1166 * @return javax.swing.JTextField
1168 private JTextField getProxyPortTextField() {
1169 if (proxyPortTextField == null) {
1170 proxyPortTextField = new JTextField();
1171 proxyPortTextField.setName("proxyPortTextField");
1173 return proxyPortTextField;
1177 * This method initializes UseProxyCheckBox
1179 * @return javax.swing.JCheckBox
1181 private JCheckBox getUseProxyCheckBox() {
1182 if (useProxyCheckBox == null) {
1183 useProxyCheckBox = new JCheckBox();
1184 useProxyCheckBox.setText("プロキシを使う");
1185 useProxyCheckBox.setName("useProxyCheckBox");
1187 return useProxyCheckBox;
1191 * This method initializes FixFontSizeCheckBox
1193 * @return javax.swing.JCheckBox
1195 private JCheckBox getFixFontSizeCheckBox() {
1196 if (fixFontSizeCheckBox == null) {
1197 fixFontSizeCheckBox = new JCheckBox();
1198 fixFontSizeCheckBox.setText("フォントサイズを画面にあわせて自動調整する");
1199 fixFontSizeCheckBox.setName("fixFontSizeCheckBox");
1201 return fixFontSizeCheckBox;
1205 * This method initializes OpaqueCommentCheckBox
1207 * @return javax.swing.JCheckBox
1209 private JCheckBox getOpaqueCommentCheckBox() {
1210 if (opaqueCommentCheckBox == null) {
1211 opaqueCommentCheckBox = new JCheckBox();
1212 opaqueCommentCheckBox.setText("全てのコメントを不透明にする");
1213 opaqueCommentCheckBox.setName("opaqueCommentCheckBox");
1215 return opaqueCommentCheckBox;
1218 * This method initializes FFmpegOptionComboBox
1220 * @return javax.swing.JComboBox
1222 private final OptionComboBoxModel FFmpegOptionModel = new OptionComboBoxModel();
1223 private JCheckBox disableVhookCheckBox = null;
1224 private JTextField viewCommentField = null;
1225 private JLabel ViewCommentLabel = null;
1226 private JLabel ShadowKindLabel = null;
1227 private JComboBox shadowComboBox = null;
1229 private JComboBox getFFmpegOptionComboBox() {
1230 if (FFmpegOptionComboBox == null) {
1231 FFmpegOptionComboBox = new JComboBox(FFmpegOptionModel);
1232 FFmpegOptionComboBox.addActionListener(new java.awt.event.ActionListener() {
1234 public void actionPerformed(java.awt.event.ActionEvent e) {
1235 if (FFmpegOptionModel.isFile()) {// ファイル
1236 setFFMpegOptionEnabled(false);
1238 setFFMpegOptionEnabled(true);
1239 setFFMpegOptionCheckbox();
1243 private void setFFMpegOptionEnabled(boolean enable) {
1244 extOptionField.setEnabled(enable);
1245 mainOptionField.setEnabled(enable);
1246 inputOptionField.setEnabled(enable);
1247 outputOptionField.setEnabled(enable);
1248 avfilterOptionField.setEnabled(enable);
1249 resizeCheckBox.setEnabled(enable);
1250 resizeWidthField.setEnabled(enable);
1251 resizeHeigitField.setEditable(enable);
1252 adjustRatioCheckBox.setEnabled(enable);
1256 return FFmpegOptionComboBox;
1260 * This method initializes FFmpegOptionReloadButton
1262 * @return javax.swing.JButton
1264 private JButton getFFmpegOptionReloadButton() {
1265 if (FFmpegOptionReloadButton == null) {
1266 FFmpegOptionReloadButton = new JButton();
1267 FFmpegOptionReloadButton.setText("更新");
1268 FFmpegOptionReloadButton.addActionListener(new java.awt.event.ActionListener() {
1270 public void actionPerformed(java.awt.event.ActionEvent e) {
1271 FFmpegOptionModel.reload();
1275 return FFmpegOptionReloadButton;
1279 * This method initializes FFmpegOptionComboBoxPanel
1281 * @return javax.swing.JPanel
1283 private JPanel getFFmpegOptionComboBoxPanel() {
1284 if (FFmpegOptionComboBoxPanel == null) {
1285 GridBagConstraints gridBagConstraints47 = new GridBagConstraints();
1286 gridBagConstraints47.fill = GridBagConstraints.BOTH;
1287 gridBagConstraints47.gridx = -1;
1288 gridBagConstraints47.gridy = -1;
1289 gridBagConstraints47.insets = new Insets(0, 0, 5, 5);
1290 GridBagConstraints gridBagConstraints46 = new GridBagConstraints();
1291 gridBagConstraints46.fill = GridBagConstraints.HORIZONTAL;
1292 gridBagConstraints46.gridwidth = 3;
1293 gridBagConstraints46.gridx = -1;
1294 gridBagConstraints46.gridy = -1;
1295 gridBagConstraints46.weightx = 1.0;
1296 gridBagConstraints46.insets = new Insets(0, 5, 5, 5);
1297 FFmpegOptionComboBoxPanel = new JPanel();
1298 FFmpegOptionComboBoxPanel.setLayout(new GridBagLayout());
1299 FFmpegOptionComboBoxPanel.add(getFFmpegOptionComboBox(),
1300 gridBagConstraints46);
1301 FFmpegOptionComboBoxPanel.add(getFFmpegOptionReloadButton(),
1302 gridBagConstraints47);
1304 return FFmpegOptionComboBoxPanel;
1308 * This method initializes NotUseVhookCheckBox
1310 * @return javax.swing.JCheckBox
1312 private JCheckBox getNotUseVhookCheckBox() {
1313 if (disableVhookCheckBox == null) {
1314 disableVhookCheckBox = new JCheckBox();
1315 disableVhookCheckBox.setText("拡張vhookライブラリを無効にする(デバッグ用)");
1316 disableVhookCheckBox.setName("disableVhookCheckBox");
1318 return disableVhookCheckBox;
1322 * This method initializes ViewCommentField
1324 * @return javax.swing.JTextField
1326 private JTextField getViewCommentField() {
1327 if (viewCommentField == null) {
1328 viewCommentField = new JTextField();
1329 viewCommentField.setName("viewCommentField");
1331 return viewCommentField;
1335 * This method initializes ShadowComboBox
1337 * @return javax.swing.JComboBox
1339 private JComboBox getShadowComboBox() {
1340 if (shadowComboBox == null) {
1341 shadowComboBox = new JComboBox(SProperties.ShadowKindArray);
1342 shadowComboBox.setName("shadowComboBox");
1344 return shadowComboBox;
1347 private BasicSetting getBasicSetting() {
1348 String mail = mailAddressField.getText();
1349 String pass = String.valueOf(passwordField.getPassword());
1350 boolean proxyUse = useProxyCheckBox.isSelected();
1351 String proxyHost = proxyTextField.getText();
1354 proxyPort = Integer.parseInt(proxyPortTextField.getText());
1355 } catch (NumberFormatException e) {
1358 // TODO 作業用ディレクトリの設定GUI無し
1359 return new BasicSetting(tempDir, mail, pass, proxyUse, proxyHost, proxyPort);
1362 private InputVideoSetting getInputVideoSetting() {
1364 if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) {
1365 kind = VideoSaveKind.NO_SAVE;
1366 } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) {
1367 kind = VideoSaveKind.NICOBROWSER;
1369 kind = VideoSaveKind.SAVE;
1371 boolean autoNaming = videoSaveInfoPanel.getSaveFolderRadioButton().isSelected();
1372 String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
1373 String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
1374 boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
1375 String nibrFile = videoSaveInfoPanel.getNibrFileField().getText();
1377 return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
1380 private InputCommentSetting getInputCommentSetting() {
1381 boolean download = savePanel.getSavingCommentCheckBox().isSelected();
1382 String file = savePanel.getCommentSavedFileField().getText();
1385 back_comment = Integer.parseInt(savePanel.getCommentNumField().getText());
1386 } catch (NumberFormatException ex) {
1389 boolean delete = savePanel.getDelCommentCheckBox().isSelected();
1390 boolean autoNaming = savePanel.getCommentSaveFolderRadioButton().isSelected();
1391 String folder = savePanel.getCommentSavedFolderField().getText();
1392 boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
1394 return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
1395 back_comment, reduceCommentCheckBox.isSelected());
1399 * 画面入力値から投稿者コメント設定を作成する.
1400 * @return 作成した投稿者コメント設定.
1402 private InputTcommentSetting getTcommentSetting() {
1403 boolean down = savePanel.isTcommentDownload();
1404 boolean del = savePanel.isTcommentDelete();
1405 boolean naming = savePanel.isTcommentAutoFileName();
1406 String dir = savePanel.getTcommentDirectoryName();
1407 String f = savePanel.getTcommentFileName();
1408 return new InputTcommentSetting(down, naming, dir, f, del);
1411 private OutputVideoSetting getOutputVideoSetting() {
1412 boolean process = savePanel.getSavingConvertedVideoCheckBox().isSelected();
1413 boolean addComment = savePanel.getAddCommentCheckBox().isSelected();
1414 boolean addTcomment = savePanel.getAddTcommentCheckBox().isSelected();
1415 String file = savePanel.getConvertedVideoSavedFileField().getText();
1416 boolean cutId = savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected();
1417 boolean autoNaming = savePanel.getConvSaveFolderRadioButton().isSelected();
1418 String folder = savePanel.getConvertedVideoSavedFolderField().getText();
1420 return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment,
1424 private MovieSetting getMovieSetting() {
1425 String ffmpeg = ffmpegPathField.getText();
1426 String vhook = vhookPathField.getText();
1427 String ext = extOptionField.getText();
1428 String main = mainOptionField.getText();
1429 String in = inputOptionField.getText();
1430 String out = outputOptionField.getText();
1431 String avfilter = avfilterOptionField.getText();
1432 boolean resize = resizeCheckBox.isSelected();
1433 String width = resizeWidthField.getText();
1434 String height = resizeHeigitField.getText();
1435 boolean adjust = adjustRatioCheckBox.isSelected();
1436 File optionFile = FFmpegOptionModel.getSelectedFile();
1438 FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust);
1439 return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
1442 private ConvertSetting getConvertSetting() {
1443 boolean vhookDisabled = disableVhookCheckBox.isSelected();
1444 int maxComment = 30;
1446 maxComment = Integer.parseInt(viewCommentField.getText());
1447 } catch (NumberFormatException ex) {
1449 File font = new File(fontPathField.getText());
1450 int fontIndex = Integer.parseInt(fontIndexField.getText());
1451 int shadowIndex = shadowComboBox.getSelectedIndex();
1452 boolean showConv = showConvVideoCheckBox.isSelected();
1453 boolean adjustFont = fixFontSizeCheckBox.isSelected();
1454 boolean commentOpaque = opaqueCommentCheckBox.isSelected();
1455 NgSetting ngSetting = new NgSetting(ngWordTextField.getText(), ngIdTextField.getText());
1457 return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
1458 commentOpaque, ngSetting);
1461 private class InputVideoPanelButtonListener implements ActionListener {
1463 public void actionPerformed(ActionEvent e) {
1464 final Object source = e.getSource();
1465 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1471 if (source == panel.getShowSavingVideoFolderDialogButton()) {
1472 title = "動画の保存先(フォルダ)";
1473 field = panel.getVideoSavedFolderField();
1476 } else if (source == panel.getShowSavingVideoFileDialogButton()) {
1477 title = "動画の保存先(ファイル)";
1478 field = panel.getVideoSavedFileField();
1481 } else if (source == panel.getNibrFileChooserButton()) {
1482 title = "NicoBrowserファイル選択";
1483 field = panel.getNibrFileField();
1489 showSaveDialog(title, field, isSave, isDir);
1493 private class InputCommentPanelButtonListener implements ActionListener {
1495 public void actionPerformed(ActionEvent e) {
1496 final Object source = e.getSource();
1501 if (source == savePanel.getShowSavingCommentFolderDialogButton()) {
1502 title = "コメントの保存先(フォルダ)";
1503 field = savePanel.getCommentSavedFolderField();
1506 } else if (source == savePanel.getShowSavingCommentFileDialogButton()) {
1507 title = "コメントの保存先(ファイル)";
1508 field = savePanel.getCommentSavedFileField();
1514 showSaveDialog(title, field, isSave, isDir);
1518 private class OutputVideoPanelButtonListener implements ActionListener {
1520 public void actionPerformed(ActionEvent e) {
1521 final Object source = e.getSource();
1526 if (source == savePanel.getShowSavingConvertedVideoFolderDialogButton()) {
1527 title = "コメント付き動画の保存先(フォルダ)";
1528 field = savePanel.getConvertedVideoSavedFolderField();
1531 } else if (source == savePanel.getShowSavingConvertedVideoFileDialogButton()) {
1532 title = "コメント付き動画の保存先(ファイル)";
1533 field = savePanel.getConvertedVideoSavedFileField();
1539 showSaveDialog(title, field, isSave, isDir);
1543 private class VideoUseRadioButtonListener implements ActionListener {
1545 public void actionPerformed(ActionEvent e) {
1546 Object source = e.getSource();
1547 if (source == videoSaveInfoPanel.getVideoUseNiBrButton()) {
1554 private void maskBase() {
1558 private void maskExt() {
1562 private void mask(boolean b) {
1563 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1564 videoIdField.setEditable(b);
1565 panel.getDelVideoCheckBox().setEnabled(b);
1567 panel.getSaveFolderRadioButton().setEnabled(b);
1568 panel.getVideoSavedFolderField().setEnabled(b);
1569 panel.getShowSavingVideoFolderDialogButton().setEnabled(b);
1571 panel.getSaveFileRadioButton().setEnabled(b);
1572 panel.getVideoSavedFileField().setEnabled(b);
1573 panel.getShowSavingVideoFileDialogButton().setEnabled(b);
1575 panel.getNibrFileField().setEnabled(!b);
1576 panel.getNibrFileChooserButton().setEnabled(!b);
1581 class MainFrame_this_windowAdapter extends WindowAdapter {
1583 private MainFrame adaptee;
1585 MainFrame_this_windowAdapter(MainFrame adaptee) {
1586 this.adaptee = adaptee;
1590 public void windowClosing(WindowEvent e) {
1591 adaptee.this_windowClosing(e);
1595 class MainFrame_SettingFontPathButton_actionAdapter implements ActionListener {
1597 private MainFrame adaptee;
1599 MainFrame_SettingFontPathButton_actionAdapter(MainFrame adaptee) {
1600 this.adaptee = adaptee;
1603 public void actionPerformed(ActionEvent e) {
1604 adaptee.SettingFontPathButton_actionPerformed(e);
1608 class MainFrame_SettingVhookPathButton_actionAdapter implements ActionListener {
1610 private MainFrame adaptee;
1612 MainFrame_SettingVhookPathButton_actionAdapter(MainFrame adaptee) {
1613 this.adaptee = adaptee;
1616 public void actionPerformed(ActionEvent e) {
1617 adaptee.SettingVhookPathButton_actionPerformed(e);
1621 class MainFrame_SettingFFmpegPathButton_actionAdapter implements ActionListener {
1623 private MainFrame adaptee;
1625 MainFrame_SettingFFmpegPathButton_actionAdapter(MainFrame adaptee) {
1626 this.adaptee = adaptee;
1629 public void actionPerformed(ActionEvent e) {
1630 adaptee.SettingFFmpegPathButton_actionPerformed(e);
1634 class MainFrame_DoButton_actionAdapter implements ActionListener {
1636 private MainFrame adaptee;
1638 MainFrame_DoButton_actionAdapter(MainFrame adaptee) {
1639 this.adaptee = adaptee;
1642 public void actionPerformed(ActionEvent e) {
1643 adaptee.DoButton_actionPerformed(e);
1647 class MainFrame_jMenuFileExit_ActionAdapter implements ActionListener {
1651 MainFrame_jMenuFileExit_ActionAdapter(MainFrame adaptee) {
1652 this.adaptee = adaptee;
1655 public void actionPerformed(ActionEvent actionEvent) {
1656 adaptee.jMenuFileExit_actionPerformed(actionEvent);
1660 class MainFrame_jMenuHelpAbout_ActionAdapter implements ActionListener {
1664 MainFrame_jMenuHelpAbout_ActionAdapter(MainFrame adaptee) {
1665 this.adaptee = adaptee;
1668 public void actionPerformed(ActionEvent actionEvent) {
1669 adaptee.jMenuHelpAbout_actionPerformed(actionEvent);