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();
102 JPanel VideoInfoPanel = new JPanel();
103 JTextField VideoID_TextField = new JTextField();
104 JButton DoButton = new JButton();
105 public static final String DoButtonDefString = "変換";
106 public static final String DoButtonStopString = "停止";
107 public static final String DoButtonWaitString = "待機";
108 JPanel UserInfoPanel = new JPanel();
109 GridBagLayout gridBagLayout3 = new GridBagLayout();
111 JLabel mailAddressLabel = new JLabel();
112 JTextField mailAddressField = new JTextField();
113 JLabel passwordLabel = new JLabel();
114 JPasswordField passwordField = new JPasswordField();
115 GridBagLayout gridBagLayout4 = new GridBagLayout();
116 GridBagLayout gridBagLayout6 = new GridBagLayout();
117 ButtonGroup CommentSaveButtonGroup = new ButtonGroup();
118 ButtonGroup ConvSaveButtonGroup = new ButtonGroup();
120 private class FfmpegOptionCheckBoxListener implements ActionListener{
123 public void actionPerformed(ActionEvent e) {
124 setFFMpegOptionCheckbox();
127 private final FfmpegOptionCheckBoxListener ffmpegOptionCheckBoxListener = new FfmpegOptionCheckBoxListener();
129 private void setFFMpegOptionCheckbox() {
130 boolean resizable = (resizeCheckBox.isEnabled() && resizeCheckBox.isSelected());
131 resizeWidthField.setEnabled(resizable);
132 resizeHeigitField.setEnabled(resizable);
133 adjustRatioCheckBox.setEnabled(resizable);
137 private void setNames() {
138 mainTabbedPane.setName("mainTabbedPane");
140 mailAddressField.setName("mailAddressField");
141 passwordField.setName("passwordField");
143 ffmpegPathField.setName("ffmpegPathField");
144 vhookPathField.setName("vhookPathField");
146 mainOptionField.setName("mainOptionField");
147 inputOptionField.setName("inputOptionField");
148 outputOptionField.setName("outputOptionField");
150 fontPathField.setName("fontPathField");
151 fontIndexField.setName("fontIndexField");
152 showConvVideoCheckBox.setName("showConvVideoCheckBox");
158 videoSaveInfoPanel = savePanel.getVideoSaveInfoPanel();
161 setDefaultCloseOperation(EXIT_ON_CLOSE);
165 SProperties setting = SProperties.loadSetting(null,
167 this.setSetting(setting);
168 } catch (Exception exception) {
169 exception.printStackTrace();
176 * @throws java.lang.Exception
178 private void jbInit() throws Exception {
179 GridBagConstraints gridBagConstraints74 = new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
180 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
181 gridBagConstraints74.gridwidth = 2;
182 GridBagConstraints gridBagConstraints73 = new GridBagConstraints();
183 gridBagConstraints73.fill = GridBagConstraints.HORIZONTAL;
184 gridBagConstraints73.gridy = 6;
185 gridBagConstraints73.weightx = 1.0;
186 gridBagConstraints73.gridwidth = 4;
187 gridBagConstraints73.insets = new Insets(0, 0, 0, 5);
188 gridBagConstraints73.gridx = 1;
189 GridBagConstraints gridBagConstraints72 = new GridBagConstraints();
190 gridBagConstraints72.gridx = 0;
191 gridBagConstraints72.anchor = GridBagConstraints.WEST;
192 gridBagConstraints72.insets = new Insets(0, 5, 0, 5);
193 gridBagConstraints72.fill = GridBagConstraints.NONE;
194 gridBagConstraints72.gridwidth = 1;
195 gridBagConstraints72.gridy = 6;
196 ShadowKindLabel = new JLabel();
197 ShadowKindLabel.setText("影の種類");
198 ShadowKindLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
199 GridBagConstraints gridBagConstraints71 = new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
200 GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 6);
201 gridBagConstraints71.fill = GridBagConstraints.BOTH;
202 gridBagConstraints71.ipady = 0;
203 GridBagConstraints gridBagConstraints70 = new GridBagConstraints();
204 gridBagConstraints70.fill = GridBagConstraints.HORIZONTAL;
205 gridBagConstraints70.gridy = 1;
206 gridBagConstraints70.ipadx = 0;
207 gridBagConstraints70.ipady = 0;
208 gridBagConstraints70.weightx = 1.0;
209 gridBagConstraints70.insets = new Insets(0, 0, 0, 0);
210 gridBagConstraints70.gridx = 1;
211 GridBagConstraints gridBagConstraints69 = new GridBagConstraints();
212 gridBagConstraints69.gridx = 0;
213 gridBagConstraints69.ipadx = 0;
214 gridBagConstraints69.ipady = 0;
215 gridBagConstraints69.insets = new Insets(0, 5, 0, 5);
216 gridBagConstraints69.anchor = GridBagConstraints.WEST;
217 gridBagConstraints69.gridy = 1;
218 GridBagConstraints gridBagConstraints68 = new GridBagConstraints();
219 gridBagConstraints68.fill = GridBagConstraints.BOTH;
220 gridBagConstraints68.gridy = 0;
221 gridBagConstraints68.ipady = 0;
222 gridBagConstraints68.weightx = 1.0;
223 gridBagConstraints68.insets = new Insets(0, 0, 0, 0);
224 gridBagConstraints68.gridx = 1;
225 GridBagConstraints gridBagConstraints67 = new GridBagConstraints();
226 gridBagConstraints67.gridx = 0;
227 gridBagConstraints67.ipadx = 0;
228 gridBagConstraints67.ipady = 0;
229 gridBagConstraints67.insets = new Insets(0, 5, 0, 5);
230 gridBagConstraints67.anchor = GridBagConstraints.WEST;
231 gridBagConstraints67.gridy = 0;
232 GridBagConstraints gridBagConstraints66 = new GridBagConstraints();
233 gridBagConstraints66.gridx = 0;
234 gridBagConstraints66.insets = new Insets(0, 5, 5, 5);
235 gridBagConstraints66.anchor = GridBagConstraints.WEST;
236 gridBagConstraints66.gridwidth = 2;
237 gridBagConstraints66.gridy = 1;
238 ViewCommentLabel = new JLabel();
239 ViewCommentLabel.setText("表示コメント数");
240 GridBagConstraints gridBagConstraints65 = new GridBagConstraints();
241 gridBagConstraints65.fill = GridBagConstraints.HORIZONTAL;
242 gridBagConstraints65.gridy = 1;
243 gridBagConstraints65.weightx = 1.0;
244 gridBagConstraints65.gridwidth = 6;
245 gridBagConstraints65.insets = new Insets(0, 5, 5, 5);
246 gridBagConstraints65.gridx = 3;
247 GridBagConstraints gridBagConstraints64 = new GridBagConstraints(1, 1,
248 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
249 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
250 gridBagConstraints64.gridy = 3;
251 gridBagConstraints64.fill = GridBagConstraints.HORIZONTAL;
252 gridBagConstraints64.gridx = 4;
253 GridBagConstraints gridBagConstraints63 = new GridBagConstraints(0, 4,
254 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
255 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
256 gridBagConstraints63.gridy = 7;
257 gridBagConstraints63.gridx = 0;
258 gridBagConstraints63.gridwidth = 5;
259 GridBagConstraints gridBagConstraints62 = new GridBagConstraints(0, 3,
260 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
261 GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0);
262 gridBagConstraints62.gridy = 5;
263 gridBagConstraints62.gridx = 1;
264 gridBagConstraints62.fill = GridBagConstraints.HORIZONTAL;
265 gridBagConstraints62.insets = new Insets(0, 0, 5, 5);
266 gridBagConstraints62.gridwidth = 4;
267 GridBagConstraints gridBagConstraints61 = new GridBagConstraints(0, 2,
268 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
269 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
270 gridBagConstraints61.gridy = 5;
271 gridBagConstraints61.gridx = 0;
272 gridBagConstraints61.fill = GridBagConstraints.VERTICAL;
273 gridBagConstraints61.anchor = GridBagConstraints.WEST;
274 gridBagConstraints61.gridwidth = 1;
275 GridBagConstraints gridBagConstraints60 = new GridBagConstraints(0, 1,
276 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
277 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0);
278 gridBagConstraints60.gridy = 3;
279 gridBagConstraints60.gridx = 1;
280 gridBagConstraints60.fill = GridBagConstraints.HORIZONTAL;
281 gridBagConstraints60.insets = new Insets(0, 0, 0, 5);
282 gridBagConstraints60.gridwidth = 3;
283 GridBagConstraints gridBagConstraints59 = new GridBagConstraints(0, 0,
284 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
285 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0);
286 gridBagConstraints59.gridy = 3;
287 gridBagConstraints59.insets = new Insets(5, 5, 5, 5);
288 gridBagConstraints59.gridx = 0;
289 gridBagConstraints59.fill = GridBagConstraints.NONE;
290 gridBagConstraints59.anchor = GridBagConstraints.WEST;
291 gridBagConstraints59.weightx = 0.0;
292 gridBagConstraints59.gridwidth = 1;
293 GridBagConstraints gridBagConstraints58 = new GridBagConstraints();
294 gridBagConstraints58.gridx = 0;
295 gridBagConstraints58.anchor = GridBagConstraints.WEST;
296 gridBagConstraints58.insets = new Insets(0, 5, 5, 5);
297 gridBagConstraints58.gridwidth = 5;
298 gridBagConstraints58.weightx = 1.0;
299 gridBagConstraints58.fill = GridBagConstraints.HORIZONTAL;
300 gridBagConstraints58.gridy = 0;
302 GridBagConstraints gridBagConstraints54 = new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
303 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
304 gridBagConstraints54.gridwidth = 3;
306 GridBagConstraints gridBagConstraints33 = new GridBagConstraints();
307 gridBagConstraints33.gridx = 0;
308 gridBagConstraints33.fill = GridBagConstraints.HORIZONTAL;
309 gridBagConstraints33.weightx = 1.0;
310 gridBagConstraints33.insets = new Insets(0, 5, 5, 5);
311 gridBagConstraints33.gridwidth = 5;
312 gridBagConstraints33.gridy = 9;
314 GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
315 gridBagConstraints14.gridx = 0;
316 gridBagConstraints14.anchor = GridBagConstraints.WEST;
317 gridBagConstraints14.fill = GridBagConstraints.HORIZONTAL;
318 gridBagConstraints14.weightx = 1.0;
319 gridBagConstraints14.gridwidth = 5;
320 gridBagConstraints14.insets = new Insets(0, 5, 0, 5);
321 gridBagConstraints14.gridy = 8;
322 GridBagConstraints gridBagConstraints7 = new GridBagConstraints(0, 0,
323 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
324 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
325 gridBagConstraints7.weighty = 0.0;
326 GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
327 gridBagConstraints6.gridx = 0;
328 gridBagConstraints6.weighty = 1.0;
329 gridBagConstraints6.weightx = 1.0;
330 gridBagConstraints6.insets = new Insets(0, 5, 0, 5);
331 gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL;
332 gridBagConstraints6.anchor = GridBagConstraints.NORTH;
333 gridBagConstraints6.gridy = 1;
334 GridBagConstraints gridBagConstraints1 = new GridBagConstraints(0, 1,
335 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
336 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
337 gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
338 gridBagConstraints1.anchor = GridBagConstraints.NORTH;
339 gridBagConstraints1.weighty = 1.0;
341 this.setIconImage(WinIcon);
342 contentPane = (JPanel) this.getContentPane();
343 contentPane.setLayout(borderLayout1);
344 setSize(new Dimension(400, 450));
345 setTitle(PRODUCT_NAME + " " + VERSION);
346 this.addWindowListener(new MainFrame_this_windowAdapter(this));
347 statusBar.setText(" ");
348 jMenuFile.setText("ファイル");
349 jMenuFileExit.setText("終了");
350 jMenuFileExit.addActionListener(new MainFrame_jMenuFileExit_ActionAdapter(
352 jMenuHelp.setText("ヘルプ");
353 jMenuHelpAbout.setText("バージョン情報");
354 jMenuHelpAbout.addActionListener(new MainFrame_jMenuHelpAbout_ActionAdapter(
356 VideoInfoPanel.setLayout(gridBagLayout1);
357 VideoID_TextField.setText("http://www.nicovideo.jp/watch/");
358 DoButton.setText(DoButtonDefString);
359 DoButton.addActionListener(new MainFrame_DoButton_actionAdapter(this));
360 SavingInfoTabPanel.setLayout(new GridLayout());
361 UserInfoPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "ユーザ設定"));
362 UserInfoPanel.setLayout(gridBagLayout3);
363 mailAddressLabel.setText("メールアドレス");
364 passwordLabel.setText("パスワード");
366 setListenerToSavePanelButton();
368 FFMpegTabPanel.setLayout(gridBagLayout6);
369 PathSettingPanel.setBorder(BorderFactory.createTitledBorder(
370 BorderFactory.createEtchedBorder(), "プログラムの位置の設定"));
371 PathSettingPanel.setLayout(gridBagLayout7);
372 FFmpegPathLabel.setText("FFmpeg");
373 SettingFFmpegPathButton.setText("参照");
374 SettingFFmpegPathButton.addActionListener(new MainFrame_SettingFFmpegPathButton_actionAdapter(
376 VhookPathLabel.setText("拡張vhookライブラリ");
377 SettingVhookPathButton.setText("参照");
378 SettingVhookPathButton.addActionListener(new MainFrame_SettingVhookPathButton_actionAdapter(
380 VhookSettingPanel.setLayout(gridBagLayout8);
381 VhookSettingPanel.setBorder(BorderFactory.createTitledBorder(
382 BorderFactory.createEtchedBorder(), "拡張vhookライブラリの設定"));
383 FFmpegSettingPanel.setBorder(BorderFactory.createTitledBorder(
384 BorderFactory.createEtchedBorder(), "FFmpegの設定"));
385 FFmpegSettingPanel.setLayout(gblFFmpegSettingPanel);
386 FontPathLabel.setText("フォントパス");
387 SettingFontPathButton.setText("参照");
388 SettingFontPathButton.addActionListener(new MainFrame_SettingFontPathButton_actionAdapter(
390 showConvVideoCheckBox.setText("変換中の画像を表示する");
392 extOptionLabel.setText("出力動画の拡張子");
393 inputOptionLabel.setText("入力オプション");
394 outputOptionLabel.setText("出力オプション");
395 mainOptionLabel.setText("メインオプション");
396 avfilterOptionLabel.setText("avfilterオプション");
398 FontIndexLabel.setText("フォント番号");
399 VideoID_Label.setText("URL/ID");
400 WayBackLabel.setText("過去ログ");
401 OpPanel.setLayout(new GridBagLayout());
403 BasicInfoTabPanel.setLayout(gridBagLayout12);
404 jMenuBar1.add(jMenuFile);
405 jMenuFile.add(jMenuFileExit);
406 jMenuBar1.add(jMenuHelp);
407 jMenuHelp.add(jMenuHelpAbout);
408 setJMenuBar(jMenuBar1);
410 contentPane.add(statusBar, BorderLayout.SOUTH);
411 contentPane.add(mainTabbedPane, java.awt.BorderLayout.CENTER);
412 contentPane.add(VideoInfoPanel, java.awt.BorderLayout.NORTH);
413 UserInfoPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1,
414 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
415 new Insets(0, 5, 5, 5), 0, 0));
416 UserInfoPanel.add(mailAddressField, new GridBagConstraints(1, 0, 1, 1,
417 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
418 new Insets(0, 5, 5, 5), 0, 0));
419 UserInfoPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1,
420 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
421 new Insets(0, 5, 5, 0), 0, 0));
422 UserInfoPanel.add(mailAddressLabel, new GridBagConstraints(0, 0, 1, 1,
423 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
424 new Insets(0, 5, 5, 0), 0, 0));
425 PathSettingPanel.add(ffmpegPathField, new GridBagConstraints(0, 1, 1,
426 1, 1.0, 0.0, GridBagConstraints.CENTER,
427 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));
428 PathSettingPanel.add(SettingFFmpegPathButton, gridBagConstraints74);
429 PathSettingPanel.add(FFmpegPathLabel, new GridBagConstraints(0, 0, 2,
430 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
431 new Insets(0, 5, 5, 5), 0, 0));
432 PathSettingPanel.add(vhookPathField, new GridBagConstraints(0, 3, 1, 1,
433 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
434 new Insets(0, 5, 5, 5), 0, 0));
435 PathSettingPanel.add(SettingVhookPathButton, new GridBagConstraints(1,
436 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
437 GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
438 PathSettingPanel.add(VhookPathLabel, gridBagConstraints54);
441 final GroupLayout layout = new GroupLayout(FFmpegSettingPanel);
442 FFmpegSettingPanel.setLayout(layout);
444 layout.setHorizontalGroup(layout.createParallelGroup()
445 .addComponent(getFFmpegOptionComboBoxPanel())
446 .addGroup(layout.createSequentialGroup()
447 .addGroup(layout.createParallelGroup()
448 .addComponent(extOptionLabel)
449 .addComponent(mainOptionLabel)
450 .addComponent(inputOptionLabel)
451 .addComponent(outputOptionLabel)
452 .addComponent(avfilterOptionLabel)
454 .addPreferredGap(ComponentPlacement.RELATED)
455 .addGroup(layout.createParallelGroup()
456 .addComponent(extOptionField)
457 .addComponent(mainOptionField)
458 .addComponent(inputOptionField)
459 .addComponent(outputOptionField)
460 .addComponent(avfilterOptionField)
463 .addGroup(layout.createParallelGroup()
464 .addGroup(layout.createSequentialGroup()
465 .addComponent(resizeCheckBox)
466 .addPreferredGap(ComponentPlacement.UNRELATED)
467 .addComponent(resizeWidthLabel)
468 .addPreferredGap(ComponentPlacement.RELATED)
469 .addComponent(resizeWidthField)
470 .addPreferredGap(ComponentPlacement.UNRELATED)
471 .addComponent(resizeHeightLabel)
472 .addPreferredGap(ComponentPlacement.RELATED)
473 .addComponent(resizeHeigitField)
476 .addGroup(layout.createSequentialGroup()
478 .addComponent(adjustRatioCheckBox))
479 .addGroup(layout.createSequentialGroup()
484 layout.setVerticalGroup(layout.createSequentialGroup()
485 .addComponent(getFFmpegOptionComboBoxPanel())
486 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
487 .addComponent(extOptionLabel)
488 .addComponent(extOptionField))
489 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
490 .addComponent(mainOptionLabel)
491 .addComponent(mainOptionField))
492 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
493 .addComponent(inputOptionLabel)
494 .addComponent(inputOptionField))
495 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
496 .addComponent(outputOptionLabel)
497 .addComponent(outputOptionField))
498 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
499 .addComponent(avfilterOptionLabel)
500 .addComponent(avfilterOptionField))
501 .addGroup(layout.createSequentialGroup()
502 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
503 .addComponent(resizeCheckBox)
504 .addComponent(resizeWidthLabel)
505 .addComponent(resizeWidthField)
506 .addComponent(resizeHeightLabel)
507 .addComponent(resizeHeigitField))
508 .addComponent(adjustRatioCheckBox)
512 resizeCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
513 adjustRatioCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
514 setFFMpegOptionCheckbox();
517 VideoInfoPanel.add(DoButton, gridBagConstraints71);
518 VideoInfoPanel.add(OpPanel, new GridBagConstraints(0, 0, 1, 1, 1.0,
519 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
520 new Insets(0, 0, 0, 0), 0, 0));
521 OpPanel.add(VideoID_Label, gridBagConstraints67);
522 OpPanel.add(VideoID_TextField, gridBagConstraints68);
523 OpPanel.add(WayBackLabel, gridBagConstraints69);
524 OpPanel.add(WayBackField, gridBagConstraints70);
526 mainTabbedPane.add(BasicInfoTabPanel, "基本設定");
527 mainTabbedPane.add(SavingInfoTabPanel, "保存設定");
528 mainTabbedPane.add(FFMpegTabPanel, "動画設定");
529 mainTabbedPane.addTab("変換設定", null, getConvertingSettingPanel(), null);
530 SavingInfoTabPanel.add(savePanel);
531 BasicInfoTabPanel.add(UserInfoPanel, gridBagConstraints7);
532 BasicInfoTabPanel.add(getProxyInfoPanel(), gridBagConstraints6);
533 VhookSettingPanel.add(FontPathLabel, gridBagConstraints59);
534 VhookSettingPanel.add(showConvVideoCheckBox, gridBagConstraints63);
535 VhookSettingPanel.add(fontPathField, gridBagConstraints60);
536 VhookSettingPanel.add(fontIndexField, gridBagConstraints62);
537 VhookSettingPanel.add(FontIndexLabel, gridBagConstraints61);
538 VhookSettingPanel.add(SettingFontPathButton, gridBagConstraints64);
539 VhookSettingPanel.add(getFixFontSizeCheckBox(), gridBagConstraints14);
540 VhookSettingPanel.add(getOpaqueCommentCheckBox(), gridBagConstraints33);
541 VhookSettingPanel.add(getNotUseVhookCheckBox(), gridBagConstraints58);
542 VhookSettingPanel.add(getViewCommentField(), gridBagConstraints65);
543 VhookSettingPanel.add(ViewCommentLabel, gridBagConstraints66);
544 VhookSettingPanel.add(ShadowKindLabel, gridBagConstraints72);
545 VhookSettingPanel.add(getShadowComboBox(), gridBagConstraints73);
547 FFMpegTabPanel.add(PathSettingPanel, new GridBagConstraints(0, 0, 1, 1,
548 1.0, 0.0, GridBagConstraints.NORTHEAST,
549 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
550 FFMpegTabPanel.add(FFmpegSettingPanel, gridBagConstraints1);
554 * 保存設定パネル内のボタンにアクションリスナを割り当てる.
556 private void setListenerToSavePanelButton() {
558 al = new InputVideoPanelButtonListener();
559 videoSaveInfoPanel.getShowSavingVideoFolderDialogButton().addActionListener(al);
560 videoSaveInfoPanel.getShowSavingVideoFileDialogButton().addActionListener(al);
561 videoSaveInfoPanel.getNibrFileChooserButton().addActionListener(al);
563 al = new VideoUseRadioButtonListener();
564 videoSaveInfoPanel.getVideoNoSaveButton().addActionListener(al);
565 videoSaveInfoPanel.getVideoSaveButton().addActionListener(al);
566 videoSaveInfoPanel.getVideoUseNiBrButton().addActionListener(al);
568 al = new InputCommentPanelButtonListener();
569 savePanel.getShowSavingCommentFolderDialogButton().addActionListener(al);
570 savePanel.getShowSavingCommentFileDialogButton().addActionListener(al);
572 al = new OutputVideoPanelButtonListener();
573 savePanel.getShowSavingConvertedVideoFolderDialogButton().addActionListener(al);
574 savePanel.getShowSavingConvertedVideoFileDialogButton().addActionListener(al);
577 private void setPopup() {
578 mainOptionField.addMouseListener(new PopupRightClick(
579 this.mainOptionField));
580 inputOptionField.addMouseListener(new PopupRightClick(
581 this.inputOptionField));
582 outputOptionField.addMouseListener(new PopupRightClick(
583 this.outputOptionField));
584 savePanel.getCommentNumField().addMouseListener(new PopupRightClick(
585 savePanel.getCommentNumField()));
587 savePanel.getCommentSavedFileField().addMouseListener(new PopupRightClick(
588 savePanel.getCommentSavedFileField()));
589 savePanel.getCommentSavedFolderField().addMouseListener(new PopupRightClick(
590 savePanel.getCommentSavedFolderField()));
592 savePanel.getConvertedVideoSavedFileField().addMouseListener(new PopupRightClick(
593 savePanel.getConvertedVideoSavedFileField()));
594 savePanel.getConvertedVideoSavedFolderField().addMouseListener(new PopupRightClick(
595 savePanel.getConvertedVideoSavedFolderField()));
597 videoSaveInfoPanel.getVideoSavedFileField().addMouseListener(new PopupRightClick(
598 videoSaveInfoPanel.getVideoSavedFileField()));
599 videoSaveInfoPanel.getVideoSavedFolderField().addMouseListener(new PopupRightClick(
600 videoSaveInfoPanel.getVideoSavedFolderField()));
601 videoSaveInfoPanel.getNibrFileField().addMouseListener(
602 new PopupRightClick(videoSaveInfoPanel.getNibrFileField()));
604 ffmpegPathField.addMouseListener(new PopupRightClick(
605 this.ffmpegPathField));
606 vhookPathField.addMouseListener(new PopupRightClick(this.vhookPathField));
607 VideoID_TextField.addMouseListener(new PopupRightClick(
608 this.VideoID_TextField));
609 viewCommentField.addMouseListener(new PopupRightClick(
610 this.viewCommentField));
611 fontPathField.addMouseListener(new PopupRightClick(this.fontPathField));
612 mailAddressField.addMouseListener(new PopupRightClick(this.mailAddressField));
613 passwordField.addMouseListener(new PopupRightClick(this.passwordField));
614 WayBackField.addMouseListener(new PopupRightClick(this.WayBackField));
616 proxyTextField.addMouseListener(new PopupRightClick(this.proxyTextField));
617 proxyPortTextField.addMouseListener(new PopupRightClick(
618 this.proxyPortTextField));
620 fontIndexField.addMouseListener(new PopupRightClick(this.fontIndexField));
622 ngWordTextField.addMouseListener(new PopupRightClick(
623 this.ngWordTextField));
624 ngIdTextField.addMouseListener(new PopupRightClick(this.ngIdTextField));
627 private void setDropTarget() {
628 addTarget(videoSaveInfoPanel.getVideoSavedFileField(), false);
629 addTarget(videoSaveInfoPanel.getVideoSavedFolderField(), true);
630 addTarget(videoSaveInfoPanel.getNibrFileField(), false);
632 addTarget(savePanel.getCommentSavedFileField(), false);
633 addTarget(savePanel.getCommentSavedFolderField(), true);
635 addTarget(savePanel.getConvertedVideoSavedFileField(), false);
636 addTarget(savePanel.getConvertedVideoSavedFolderField(), true);
638 addTarget(ffmpegPathField, false);
639 addTarget(vhookPathField, false);
640 addTarget(fontPathField, false);
645 * テキストフィールドに対しドロップを行った場合にファイルもしくはディレクトリの文字列を設定できるようにする.
646 * @param c 設定対象のテキストフィールドオブジェクト.
647 * @param isDir ディレクトリを設定する場合はtrue, ファイルの場合はfalse.
648 * @return ドロップターゲット(用途無し).
650 private DropTarget addTarget(JTextField c, boolean isDir) {
651 return new DropTarget(c, DnDConstants.ACTION_COPY, new FileDropTarget(
654 private File CurrentDir = new File(".");
655 private JPanel PathSettingPanel = new JPanel();
656 private JLabel FFmpegPathLabel = new JLabel();
657 private GridBagLayout gridBagLayout7 = new GridBagLayout();
658 private JTextField ffmpegPathField = new JTextField();
659 private JButton SettingFFmpegPathButton = new JButton();
660 private JLabel VhookPathLabel = new JLabel();
661 private JTextField vhookPathField = new JTextField();
662 private JButton SettingVhookPathButton = new JButton();
663 private JPanel VhookSettingPanel = new JPanel();
664 private GridBagLayout gridBagLayout8 = new GridBagLayout();
665 private JPanel FFmpegSettingPanel = new JPanel();
666 private GridBagLayout gblFFmpegSettingPanel = new GridBagLayout();
667 private JLabel FontPathLabel = new JLabel();
668 private JTextField fontPathField = new JTextField();
669 private JButton SettingFontPathButton = new JButton();
670 private JCheckBox showConvVideoCheckBox = new JCheckBox();
672 private void showSaveDialog(String title, JTextField field, boolean isSave,
674 JFileChooser chooser = new JFileChooser(CurrentDir);
675 chooser.setDialogTitle(title);
678 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
681 code = chooser.showSaveDialog(this);
683 code = chooser.showOpenDialog(this);
685 if (code == JFileChooser.APPROVE_OPTION) {
687 CurrentDir = chooser.getSelectedFile();
688 field.setText(CurrentDir.getAbsolutePath());
690 File selected = chooser.getSelectedFile();
691 CurrentDir = chooser.getCurrentDirectory();
692 field.setText(selected.getAbsolutePath());
697 private SProperties getSetting() {
698 SProperties setting = new SProperties(
700 getInputVideoSetting(),
701 getInputCommentSetting(),
702 getTcommentSetting(),
703 getOutputVideoSetting(),
705 getConvertSetting());
711 * @param setting 反映する設定.
713 private void setSetting(SProperties setting) {
715 final BasicSetting basic = setting.getBasicSetting();
716 tempDir = basic.getTempDir();
717 mailAddressField.setText(basic.getUser().getMail());
718 passwordField.setText(basic.getUser().getPassword());
720 useProxyCheckBox.setSelected(basic.isProxyUse());
721 proxyTextField.setText(basic.getProxyHost());
722 int proxy_port = basic.getProxyPort();
723 if (proxy_port >= 0 && proxy_port <= 65535) {
724 proxyPortTextField.setText(Integer.toString(proxy_port));
726 proxyPortTextField.setText("");
730 final InputVideoSetting inVideo = setting.getInputVideoSetting();
731 JRadioButton activeButton;
732 switch (inVideo.getProcessKind()) {
734 activeButton = videoSaveInfoPanel.getVideoNoSaveButton();
737 activeButton = videoSaveInfoPanel.getVideoUseNiBrButton();
741 activeButton = videoSaveInfoPanel.getVideoSaveButton();
744 activeButton.doClick();
746 videoSaveInfoPanel.getVideoSavedFileField().setText(inVideo.getFile().getPath());
747 videoSaveInfoPanel.getVideoSavedFolderField().setText(inVideo.getFolder().getPath());
748 videoSaveInfoPanel.getDelVideoCheckBox().setSelected(inVideo.isDeleteAfterConvert());
749 final boolean videoFixName = inVideo.isAutoNaming();
750 videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
751 videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
752 videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath());
755 final InputCommentSetting inputComment = setting.getInputCommentSetting();
756 savePanel.getSavingCommentCheckBox().setSelected(inputComment.getProcessKind());
757 savePanel.getCommentSavedFileField().setText(inputComment.getFile().getPath());
758 savePanel.getDelCommentCheckBox().setSelected(inputComment.isDeleteAfterConvert());
759 savePanel.getCommentSavedFolderField().setText(inputComment.getFolder().getPath());
760 savePanel.getCommentNumField().setText(Integer.toString(inputComment.getNumOfComment()));
761 savePanel.getFixCommentNumCheckBox().setSelected(inputComment.isSelfAdjustNumOfComment());
762 boolean commentFixName = inputComment.isAutoNaming();
763 savePanel.getCommentSaveFileRadioButton().setSelected(!commentFixName);
764 savePanel.getCommentSaveFolderRadioButton().setSelected(commentFixName);
767 InputTcommentSetting tcom = setting.getInputTcommentSetting();
768 savePanel.setTcommentDownload(tcom.getProcessKind());
769 savePanel.setTcommentDelete(tcom.isDeleteAfterConvert());
770 savePanel.setTcommentAutoFileName(tcom.isAutoNaming());
771 savePanel.setTcommentDirectoryName(tcom.getFolder().getPath());
772 savePanel.setTcommentFileName(tcom.getFile().getPath());
775 final OutputVideoSetting outputVideo = setting.getOutputVideoSetting();
776 savePanel.getSavingConvertedVideoCheckBox().setSelected(outputVideo.getProcessKind());
777 savePanel.getAddCommentCheckBox().setSelected(outputVideo.isAddComment());
778 savePanel.getAddTcommentCheckBox().setSelected(outputVideo.isAddTcomment());
779 savePanel.getConvertedVideoSavedFileField().setText(outputVideo.getFile().getPath());
780 savePanel.getConvertedVideoSavedFolderField().setText(outputVideo.getFolder().getPath());
781 savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(outputVideo.isCutIdName());
782 boolean convFixName = outputVideo.isAutoNaming();
783 savePanel.getConvSaveFileRadioButton().setSelected(!convFixName);
784 savePanel.getConvSaveFolderRadioButton().setSelected(convFixName);
787 final MovieSetting movie = setting.getMovieSetting();
788 ffmpegPathField.setText(movie.getFfmpeg().toString());
789 vhookPathField.setText(movie.getVhook().toString());
790 extOptionField.setText(movie.getFfmpegOption().getExtOption());
791 mainOptionField.setText(movie.getFfmpegOption().getMainOption());
792 inputOptionField.setText(movie.getFfmpegOption().getInOption());
793 outputOptionField.setText(movie.getFfmpegOption().getOutOption());
794 avfilterOptionField.setText(movie.getFfmpegOption().getAvfilterOption());
795 resizeCheckBox.setSelected(movie.getFfmpegOption().isResize());
796 resizeWidthField.setText(Integer.toString(movie.getFfmpegOption().getResizeWidth()));
797 resizeHeigitField.setText(Integer.toString(movie.getFfmpegOption().getResizeHeight()));
798 adjustRatioCheckBox.setSelected(movie.getFfmpegOption().isAdjustRatio());
799 FFmpegOptionModel.reload(movie.getOptionFile());
802 final ConvertSetting conv = setting.getConvertSetting();
803 disableVhookCheckBox.setSelected(conv.isVhookDisabled());
804 viewCommentField.setText(Integer.toString(conv.getMaxNumOfComment()));
805 fontPathField.setText(conv.getFont().toString());
806 fontIndexField.setText(Integer.toString(conv.getFontIndex()));
807 shadowComboBox.setSelectedIndex(conv.getShadowIndex());
808 showConvVideoCheckBox.setSelected(conv.isShowConverting());
809 fixFontSizeCheckBox.setSelected(conv.isSelfAdjustFontSize());
810 opaqueCommentCheckBox.setSelected(conv.isCommentOpaque());
811 ngWordTextField.setText(conv.getNgSetting().getWord());
812 ngIdTextField.setText(conv.getNgSetting().getId());
816 * [ファイル|終了] アクションが実行されました。
821 void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
823 SProperties setting = getSetting();
824 SProperties.saveSetting(setting);
825 } catch (Throwable t) {
826 Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "設定保存に失敗", t);
832 * [ヘルプ|バージョン情報] アクションが実行されました。
837 void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
838 MainFrame_AboutBox dlg = new MainFrame_AboutBox(this);
840 dlg.setLocationRelativeTo(this);
841 dlg.setVisible(true);
845 private Converter Converter = null;
847 private final JLabel extOptionLabel = new JLabel();
848 private final JTextField extOptionField = new JTextField();
849 private JLabel mainOptionLabel = new JLabel();
850 private JTextField mainOptionField = new JTextField();
851 private JLabel inputOptionLabel = new JLabel();
852 private JTextField inputOptionField = new JTextField();
853 private JLabel outputOptionLabel = new JLabel();
854 private JTextField outputOptionField = new JTextField();
855 private final JLabel avfilterOptionLabel = new JLabel();
856 private final JTextField avfilterOptionField = new JTextField();
857 private final JCheckBox resizeCheckBox = new JCheckBox("次のサイズに収まるよう縮小(-s)");
858 private final JLabel resizeWidthLabel = new JLabel("横");
859 private final JTextField resizeWidthField = new NumberFormattedTextField();
860 private final JLabel resizeHeightLabel = new JLabel("縦");
861 private final JTextField resizeHeigitField = new NumberFormattedTextField();
862 private final JCheckBox adjustRatioCheckBox = new JCheckBox("アスペクト比を維持");
864 private JLabel FontIndexLabel = new JLabel();
865 private JTextField fontIndexField = new JTextField();
866 private JLabel VideoID_Label = new JLabel();
867 private JLabel WayBackLabel = new JLabel();
868 private JTextField WayBackField = new JTextField();
869 private GridBagLayout gridBagLayout1 = new GridBagLayout();
870 private JPanel OpPanel = new JPanel();
871 private JPanel BasicInfoTabPanel = new JPanel();
872 private GridBagLayout gridBagLayout12 = new GridBagLayout();
873 private JPanel ConvertingSettingPanel = null;
874 private JPanel NGWordSettingPanel = null;
875 private JLabel NGWordLabel = null;
876 private JTextField ngWordTextField = null;
877 private JLabel NGIDLabel = null;
878 private JTextField ngIdTextField = null;
880 private JPanel ProxyInfoPanel = null;
881 private JCheckBox useProxyCheckBox = null;
882 private JLabel proxyLabel = null;
883 private JTextField proxyTextField = null;
884 private JLabel proxyPortLabel = null;
885 private JTextField proxyPortTextField = null;
887 private JCheckBox fixFontSizeCheckBox = null;
888 private JCheckBox opaqueCommentCheckBox = null;
889 private final SavePanel savePanel = new SavePanel();
890 private final VideoSaveInfoPanel videoSaveInfoPanel;
891 private JComboBox FFmpegOptionComboBox = null;
892 private JButton FFmpegOptionReloadButton = null;
893 private JPanel FFmpegOptionComboBoxPanel = null;
895 public void DoButton_actionPerformed(ActionEvent e) {
896 if (Converter == null || Converter.isConverted()) {
899 } catch (Exception ex) {
900 String text = ex.getMessage();
901 if (StringUtils.isEmpty(text)) {
902 text = "予期しないエラーのため中断しました。";
904 ex.printStackTrace();
905 statusBar.setText(text);
907 } else { /* 開始しているので、ストップする。 */
908 final ConvertStopFlag flag = Converter.getStopFlag();
909 if (!flag.needStop()) { /* まだストップしていない。 */
915 private void executeConvert() throws IOException {
918 // NicoBrowserファイルを利用する場合は、ファイル名からビデオIDを特定.
919 if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
921 String fileName = videoSaveInfoPanel.getNibrFileField().getText();
922 NicoDBFinder finder = NicoDBFinder.getInstance();
923 NicoContent info = finder.findNicoContent(fileName);
925 url = info.getNicoId();
929 } catch (Exception ex) {
930 JOptionPane.showMessageDialog(this, ex.getMessage(), "エラー", JOptionPane.ERROR_MESSAGE);
934 url = VideoID_TextField.getText();
937 TextProgressListener sl = new TextProgressListener() {
939 public void setText(final String text) {
940 SwingUtilities.invokeLater(new Runnable() {
943 statusBar.setText(text);
949 ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
951 public void changeState(final State s) {
952 SwingUtilities.invokeLater(new Runnable() {
957 DoButton.setText(DoButtonWaitString);
960 DoButton.setText(DoButtonDefString);
967 Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
968 new ConvertStopFlag(scl));
969 DoButton.setText(DoButtonStopString);
970 new Thread(Converter).start();
975 public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
976 showSaveDialog("FFmpegへのパス", ffmpegPathField, false, false);
979 public void SettingVhookPathButton_actionPerformed(ActionEvent e) {
980 showSaveDialog("拡張vhookライブラリへのパス", vhookPathField, false, false);
983 public void SettingFontPathButton_actionPerformed(ActionEvent e) {
984 showSaveDialog("フォントへのパス", fontPathField, false, false);
987 public void this_windowClosing(WindowEvent e) {
988 this.jMenuFileExit_actionPerformed(null);
992 * This method initializes ConvertingSettingPanel
994 * @return javax.swing.JPanel
996 private JPanel getConvertingSettingPanel() {
997 if (ConvertingSettingPanel == null) {
998 GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
999 gridBagConstraints11.weighty = 1.0;
1000 gridBagConstraints11.weightx = 1.0;
1001 gridBagConstraints11.insets = new Insets(0, 5, 0, 5);
1002 gridBagConstraints11.gridy = 1;
1003 gridBagConstraints11.gridx = 0;
1004 gridBagConstraints11.anchor = GridBagConstraints.NORTH;
1005 gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
1006 GridBagConstraints gridBagConstraints = new GridBagConstraints(0,
1007 2, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
1008 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
1009 gridBagConstraints.gridx = 0;
1010 gridBagConstraints.anchor = GridBagConstraints.CENTER;
1011 gridBagConstraints.weighty = 0.0;
1012 gridBagConstraints.gridy = 0;
1013 ConvertingSettingPanel = new JPanel();
1014 ConvertingSettingPanel.setLayout(new GridBagLayout());
1015 ConvertingSettingPanel.add(getNGWordSettingPanel(),
1016 gridBagConstraints11);
1017 ConvertingSettingPanel.add(VhookSettingPanel, gridBagConstraints);
1019 return ConvertingSettingPanel;
1023 * This method initializes NGWordSettingPanel
1025 * @return javax.swing.JPanel
1027 private JPanel getNGWordSettingPanel() {
1028 if (NGWordSettingPanel == null) {
1029 GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
1030 gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
1031 gridBagConstraints5.gridy = 1;
1032 gridBagConstraints5.weightx = 1.0;
1033 gridBagConstraints5.insets = new Insets(0, 5, 5, 5);
1034 gridBagConstraints5.gridx = 1;
1035 GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
1036 gridBagConstraints4.gridx = 0;
1037 gridBagConstraints4.anchor = GridBagConstraints.WEST;
1038 gridBagConstraints4.insets = new Insets(0, 5, 5, 0);
1039 gridBagConstraints4.gridy = 1;
1040 NGIDLabel = new JLabel();
1041 NGIDLabel.setText("NG ID");
1042 GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
1043 gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
1044 gridBagConstraints3.gridy = 0;
1045 gridBagConstraints3.weightx = 1.0;
1046 gridBagConstraints3.insets = new Insets(0, 5, 5, 5);
1047 gridBagConstraints3.gridx = 1;
1048 GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
1049 gridBagConstraints2.gridx = 0;
1050 gridBagConstraints2.insets = new Insets(0, 5, 5, 0);
1051 gridBagConstraints2.gridy = 0;
1052 NGWordLabel = new JLabel();
1053 NGWordLabel.setText("NGワード");
1054 NGWordSettingPanel = new JPanel();
1055 NGWordSettingPanel.setLayout(new GridBagLayout());
1056 NGWordSettingPanel.setBorder(BorderFactory.createTitledBorder(null,
1057 "NGワード・ID設定(半角スペース区切りで複数入力)"));
1058 NGWordSettingPanel.add(NGWordLabel, gridBagConstraints2);
1059 NGWordSettingPanel.add(getNGWordTextField(), gridBagConstraints3);
1060 NGWordSettingPanel.add(NGIDLabel, gridBagConstraints4);
1061 NGWordSettingPanel.add(getNGIDTextField(), gridBagConstraints5);
1063 return NGWordSettingPanel;
1067 * This method initializes NGWordTextField
1069 * @return javax.swing.JTextField
1071 private JTextField getNGWordTextField() {
1072 if (ngWordTextField == null) {
1073 ngWordTextField = new JTextField();
1074 ngWordTextField.setName("ngWordTextField");
1076 return ngWordTextField;
1080 * This method initializes NGIDTextField
1082 * @return javax.swing.JTextField
1084 private JTextField getNGIDTextField() {
1085 if (ngIdTextField == null) {
1086 ngIdTextField = new JTextField();
1087 ngIdTextField.setName("ngIdTextField");
1089 return ngIdTextField;
1093 * This method initializes ProxyInfoPanel
1095 * @return javax.swing.JPanel
1097 private JPanel getProxyInfoPanel() {
1098 if (ProxyInfoPanel == null) {
1099 GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
1100 gridBagConstraints13.gridx = 0;
1101 gridBagConstraints13.gridwidth = 2;
1102 gridBagConstraints13.weightx = 1.0;
1103 gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL;
1104 gridBagConstraints13.insets = new Insets(0, 5, 0, 5);
1105 gridBagConstraints13.gridy = 0;
1106 GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
1107 gridBagConstraints12.fill = GridBagConstraints.HORIZONTAL;
1108 gridBagConstraints12.gridy = 2;
1109 gridBagConstraints12.weightx = 1.0;
1110 gridBagConstraints12.insets = new Insets(5, 0, 5, 5);
1111 gridBagConstraints12.gridx = 1;
1112 GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
1113 gridBagConstraints10.gridx = 0;
1114 gridBagConstraints10.insets = new Insets(5, 5, 5, 5);
1115 gridBagConstraints10.gridy = 2;
1116 proxyPortLabel = new JLabel();
1117 proxyPortLabel.setText("ポート番号");
1118 GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
1119 gridBagConstraints9.fill = GridBagConstraints.BOTH;
1120 gridBagConstraints9.gridy = 1;
1121 gridBagConstraints9.weightx = 1.0;
1122 gridBagConstraints9.insets = new Insets(0, 0, 0, 5);
1123 gridBagConstraints9.gridx = 1;
1124 GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
1125 gridBagConstraints8.gridx = 0;
1126 gridBagConstraints8.insets = new Insets(0, 5, 0, 5);
1127 gridBagConstraints8.fill = GridBagConstraints.NONE;
1128 gridBagConstraints8.anchor = GridBagConstraints.EAST;
1129 gridBagConstraints8.gridy = 1;
1130 proxyLabel = new JLabel();
1131 proxyLabel.setText("プロキシ");
1132 ProxyInfoPanel = new JPanel();
1133 ProxyInfoPanel.setLayout(new GridBagLayout());
1134 ProxyInfoPanel.setBorder(BorderFactory.createTitledBorder(null,
1136 ProxyInfoPanel.add(proxyLabel, gridBagConstraints8);
1137 ProxyInfoPanel.add(getProxyTextField(), gridBagConstraints9);
1138 ProxyInfoPanel.add(proxyPortLabel, gridBagConstraints10);
1139 ProxyInfoPanel.add(getProxyPortTextField(), gridBagConstraints12);
1140 ProxyInfoPanel.add(getUseProxyCheckBox(), gridBagConstraints13);
1142 return ProxyInfoPanel;
1146 * This method initializes ProxyTextField
1148 * @return javax.swing.JTextField
1150 private JTextField getProxyTextField() {
1151 if (proxyTextField == null) {
1152 proxyTextField = new JTextField();
1153 proxyTextField.setName("proxyTextField");
1155 return proxyTextField;
1159 * This method initializes ProxyPortTextField
1161 * @return javax.swing.JTextField
1163 private JTextField getProxyPortTextField() {
1164 if (proxyPortTextField == null) {
1165 proxyPortTextField = new JTextField();
1166 proxyPortTextField.setName("proxyPortTextField");
1168 return proxyPortTextField;
1172 * This method initializes UseProxyCheckBox
1174 * @return javax.swing.JCheckBox
1176 private JCheckBox getUseProxyCheckBox() {
1177 if (useProxyCheckBox == null) {
1178 useProxyCheckBox = new JCheckBox();
1179 useProxyCheckBox.setText("プロキシを使う");
1180 useProxyCheckBox.setName("useProxyCheckBox");
1182 return useProxyCheckBox;
1186 * This method initializes FixFontSizeCheckBox
1188 * @return javax.swing.JCheckBox
1190 private JCheckBox getFixFontSizeCheckBox() {
1191 if (fixFontSizeCheckBox == null) {
1192 fixFontSizeCheckBox = new JCheckBox();
1193 fixFontSizeCheckBox.setText("フォントサイズを画面にあわせて自動調整する");
1194 fixFontSizeCheckBox.setName("fixFontSizeCheckBox");
1196 return fixFontSizeCheckBox;
1200 * This method initializes OpaqueCommentCheckBox
1202 * @return javax.swing.JCheckBox
1204 private JCheckBox getOpaqueCommentCheckBox() {
1205 if (opaqueCommentCheckBox == null) {
1206 opaqueCommentCheckBox = new JCheckBox();
1207 opaqueCommentCheckBox.setText("全てのコメントを不透明にする");
1208 opaqueCommentCheckBox.setName("opaqueCommentCheckBox");
1210 return opaqueCommentCheckBox;
1213 * This method initializes FFmpegOptionComboBox
1215 * @return javax.swing.JComboBox
1217 private final OptionComboBoxModel FFmpegOptionModel = new OptionComboBoxModel();
1218 private JCheckBox disableVhookCheckBox = null;
1219 private JTextField viewCommentField = null;
1220 private JLabel ViewCommentLabel = null;
1221 private JLabel ShadowKindLabel = null;
1222 private JComboBox shadowComboBox = null;
1224 private JComboBox getFFmpegOptionComboBox() {
1225 if (FFmpegOptionComboBox == null) {
1226 FFmpegOptionComboBox = new JComboBox(FFmpegOptionModel);
1227 FFmpegOptionComboBox.addActionListener(new java.awt.event.ActionListener() {
1229 public void actionPerformed(java.awt.event.ActionEvent e) {
1230 if (FFmpegOptionModel.isFile()) {// ファイル
1231 setFFMpegOptionEnabled(false);
1233 setFFMpegOptionEnabled(true);
1234 setFFMpegOptionCheckbox();
1238 private void setFFMpegOptionEnabled(boolean enable) {
1239 extOptionField.setEnabled(enable);
1240 mainOptionField.setEnabled(enable);
1241 inputOptionField.setEnabled(enable);
1242 outputOptionField.setEnabled(enable);
1243 avfilterOptionField.setEnabled(enable);
1244 resizeCheckBox.setEnabled(enable);
1245 resizeWidthField.setEnabled(enable);
1246 resizeHeigitField.setEditable(enable);
1247 adjustRatioCheckBox.setEnabled(enable);
1251 return FFmpegOptionComboBox;
1255 * This method initializes FFmpegOptionReloadButton
1257 * @return javax.swing.JButton
1259 private JButton getFFmpegOptionReloadButton() {
1260 if (FFmpegOptionReloadButton == null) {
1261 FFmpegOptionReloadButton = new JButton();
1262 FFmpegOptionReloadButton.setText("更新");
1263 FFmpegOptionReloadButton.addActionListener(new java.awt.event.ActionListener() {
1265 public void actionPerformed(java.awt.event.ActionEvent e) {
1266 FFmpegOptionModel.reload();
1270 return FFmpegOptionReloadButton;
1274 * This method initializes FFmpegOptionComboBoxPanel
1276 * @return javax.swing.JPanel
1278 private JPanel getFFmpegOptionComboBoxPanel() {
1279 if (FFmpegOptionComboBoxPanel == null) {
1280 GridBagConstraints gridBagConstraints47 = new GridBagConstraints();
1281 gridBagConstraints47.fill = GridBagConstraints.BOTH;
1282 gridBagConstraints47.gridx = -1;
1283 gridBagConstraints47.gridy = -1;
1284 gridBagConstraints47.insets = new Insets(0, 0, 5, 5);
1285 GridBagConstraints gridBagConstraints46 = new GridBagConstraints();
1286 gridBagConstraints46.fill = GridBagConstraints.HORIZONTAL;
1287 gridBagConstraints46.gridwidth = 3;
1288 gridBagConstraints46.gridx = -1;
1289 gridBagConstraints46.gridy = -1;
1290 gridBagConstraints46.weightx = 1.0;
1291 gridBagConstraints46.insets = new Insets(0, 5, 5, 5);
1292 FFmpegOptionComboBoxPanel = new JPanel();
1293 FFmpegOptionComboBoxPanel.setLayout(new GridBagLayout());
1294 FFmpegOptionComboBoxPanel.add(getFFmpegOptionComboBox(),
1295 gridBagConstraints46);
1296 FFmpegOptionComboBoxPanel.add(getFFmpegOptionReloadButton(),
1297 gridBagConstraints47);
1299 return FFmpegOptionComboBoxPanel;
1303 * This method initializes NotUseVhookCheckBox
1305 * @return javax.swing.JCheckBox
1307 private JCheckBox getNotUseVhookCheckBox() {
1308 if (disableVhookCheckBox == null) {
1309 disableVhookCheckBox = new JCheckBox();
1310 disableVhookCheckBox.setText("拡張vhookライブラリを無効にする(デバッグ用)");
1311 disableVhookCheckBox.setName("disableVhookCheckBox");
1313 return disableVhookCheckBox;
1317 * This method initializes ViewCommentField
1319 * @return javax.swing.JTextField
1321 private JTextField getViewCommentField() {
1322 if (viewCommentField == null) {
1323 viewCommentField = new JTextField();
1324 viewCommentField.setName("viewCommentField");
1326 return viewCommentField;
1330 * This method initializes ShadowComboBox
1332 * @return javax.swing.JComboBox
1334 private JComboBox getShadowComboBox() {
1335 if (shadowComboBox == null) {
1336 shadowComboBox = new JComboBox(SProperties.ShadowKindArray);
1337 shadowComboBox.setName("shadowComboBox");
1339 return shadowComboBox;
1342 private BasicSetting getBasicSetting() {
1343 String mail = mailAddressField.getText();
1344 String pass = String.valueOf(passwordField.getPassword());
1345 boolean proxyUse = useProxyCheckBox.isSelected();
1346 String proxyHost = proxyTextField.getText();
1349 proxyPort = Integer.parseInt(proxyPortTextField.getText());
1350 } catch (NumberFormatException e) {
1353 // TODO 作業用ディレクトリの設定GUI無し
1354 return new BasicSetting(tempDir, mail, pass, proxyUse, proxyHost, proxyPort);
1357 private InputVideoSetting getInputVideoSetting() {
1359 if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) {
1360 kind = VideoSaveKind.NO_SAVE;
1361 } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) {
1362 kind = VideoSaveKind.NICOBROWSER;
1364 kind = VideoSaveKind.SAVE;
1366 boolean autoNaming = videoSaveInfoPanel.getSaveFolderRadioButton().isSelected();
1367 String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
1368 String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
1369 boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
1370 String nibrFile = videoSaveInfoPanel.getNibrFileField().getText();
1372 return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
1375 private InputCommentSetting getInputCommentSetting() {
1376 boolean download = savePanel.getSavingCommentCheckBox().isSelected();
1377 String file = savePanel.getCommentSavedFileField().getText();
1380 back_comment = Integer.parseInt(savePanel.getCommentNumField().getText());
1381 } catch (NumberFormatException ex) {
1384 boolean delete = savePanel.getDelCommentCheckBox().isSelected();
1385 boolean autoNaming = savePanel.getCommentSaveFolderRadioButton().isSelected();
1386 String folder = savePanel.getCommentSavedFolderField().getText();
1387 boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
1389 return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
1394 * 画面入力値から投稿者コメント設定を作成する.
1395 * @return 作成した投稿者コメント設定.
1397 private InputTcommentSetting getTcommentSetting() {
1398 boolean down = savePanel.isTcommentDownload();
1399 boolean del = savePanel.isTcommentDelete();
1400 boolean naming = savePanel.isTcommentAutoFileName();
1401 String dir = savePanel.getTcommentDirectoryName();
1402 String f = savePanel.getTcommentFileName();
1403 return new InputTcommentSetting(down, naming, dir, f, del);
1406 private OutputVideoSetting getOutputVideoSetting() {
1407 boolean process = savePanel.getSavingConvertedVideoCheckBox().isSelected();
1408 boolean addComment = savePanel.getAddCommentCheckBox().isSelected();
1409 boolean addTcomment = savePanel.getAddTcommentCheckBox().isSelected();
1410 String file = savePanel.getConvertedVideoSavedFileField().getText();
1411 boolean cutId = savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected();
1412 boolean autoNaming = savePanel.getConvSaveFolderRadioButton().isSelected();
1413 String folder = savePanel.getConvertedVideoSavedFolderField().getText();
1415 return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment,
1419 private MovieSetting getMovieSetting() {
1420 String ffmpeg = ffmpegPathField.getText();
1421 String vhook = vhookPathField.getText();
1422 String ext = extOptionField.getText();
1423 String main = mainOptionField.getText();
1424 String in = inputOptionField.getText();
1425 String out = outputOptionField.getText();
1426 String avfilter = avfilterOptionField.getText();
1427 boolean resize = resizeCheckBox.isSelected();
1428 String width = resizeWidthField.getText();
1429 String height = resizeHeigitField.getText();
1430 boolean adjust = adjustRatioCheckBox.isSelected();
1431 File optionFile = FFmpegOptionModel.getSelectedFile();
1433 FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust);
1434 return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
1437 private ConvertSetting getConvertSetting() {
1438 boolean vhookDisabled = disableVhookCheckBox.isSelected();
1439 int maxComment = 30;
1441 maxComment = Integer.parseInt(viewCommentField.getText());
1442 } catch (NumberFormatException ex) {
1444 File font = new File(fontPathField.getText());
1445 int fontIndex = Integer.parseInt(fontIndexField.getText());
1446 int shadowIndex = shadowComboBox.getSelectedIndex();
1447 boolean showConv = showConvVideoCheckBox.isSelected();
1448 boolean adjustFont = fixFontSizeCheckBox.isSelected();
1449 boolean commentOpaque = opaqueCommentCheckBox.isSelected();
1450 NgSetting ngSetting = new NgSetting(ngWordTextField.getText(), ngIdTextField.getText());
1452 return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
1453 commentOpaque, ngSetting);
1456 private class InputVideoPanelButtonListener implements ActionListener {
1458 public void actionPerformed(ActionEvent e) {
1459 final Object source = e.getSource();
1460 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1466 if (source == panel.getShowSavingVideoFolderDialogButton()) {
1467 title = "動画の保存先(フォルダ)";
1468 field = panel.getVideoSavedFolderField();
1471 } else if (source == panel.getShowSavingVideoFileDialogButton()) {
1472 title = "動画の保存先(ファイル)";
1473 field = panel.getVideoSavedFileField();
1476 } else if (source == panel.getNibrFileChooserButton()) {
1477 title = "NicoBrowserファイル選択";
1478 field = panel.getNibrFileField();
1484 showSaveDialog(title, field, isSave, isDir);
1488 private class InputCommentPanelButtonListener implements ActionListener {
1490 public void actionPerformed(ActionEvent e) {
1491 final Object source = e.getSource();
1496 if (source == savePanel.getShowSavingCommentFolderDialogButton()) {
1497 title = "コメントの保存先(フォルダ)";
1498 field = savePanel.getCommentSavedFolderField();
1501 } else if (source == savePanel.getShowSavingCommentFileDialogButton()) {
1502 title = "コメントの保存先(ファイル)";
1503 field = savePanel.getCommentSavedFileField();
1509 showSaveDialog(title, field, isSave, isDir);
1513 private class OutputVideoPanelButtonListener implements ActionListener {
1515 public void actionPerformed(ActionEvent e) {
1516 final Object source = e.getSource();
1521 if (source == savePanel.getShowSavingConvertedVideoFolderDialogButton()) {
1522 title = "コメント付き動画の保存先(フォルダ)";
1523 field = savePanel.getConvertedVideoSavedFolderField();
1526 } else if (source == savePanel.getShowSavingConvertedVideoFileDialogButton()) {
1527 title = "コメント付き動画の保存先(ファイル)";
1528 field = savePanel.getConvertedVideoSavedFileField();
1534 showSaveDialog(title, field, isSave, isDir);
1538 private class VideoUseRadioButtonListener implements ActionListener {
1540 public void actionPerformed(ActionEvent e) {
1541 Object source = e.getSource();
1542 if (source == videoSaveInfoPanel.getVideoUseNiBrButton()) {
1549 private void maskBase() {
1553 private void maskExt() {
1557 private void mask(boolean b) {
1558 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1559 VideoID_TextField.setEditable(b);
1560 panel.getDelVideoCheckBox().setEnabled(b);
1562 panel.getSaveFolderRadioButton().setEnabled(b);
1563 panel.getVideoSavedFolderField().setEnabled(b);
1564 panel.getShowSavingVideoFolderDialogButton().setEnabled(b);
1566 panel.getSaveFileRadioButton().setEnabled(b);
1567 panel.getVideoSavedFileField().setEnabled(b);
1568 panel.getShowSavingVideoFileDialogButton().setEnabled(b);
1570 panel.getNibrFileField().setEnabled(!b);
1571 panel.getNibrFileChooserButton().setEnabled(!b);
1576 class MainFrame_this_windowAdapter extends WindowAdapter {
1578 private MainFrame adaptee;
1580 MainFrame_this_windowAdapter(MainFrame adaptee) {
1581 this.adaptee = adaptee;
1585 public void windowClosing(WindowEvent e) {
1586 adaptee.this_windowClosing(e);
1590 class MainFrame_SettingFontPathButton_actionAdapter implements ActionListener {
1592 private MainFrame adaptee;
1594 MainFrame_SettingFontPathButton_actionAdapter(MainFrame adaptee) {
1595 this.adaptee = adaptee;
1598 public void actionPerformed(ActionEvent e) {
1599 adaptee.SettingFontPathButton_actionPerformed(e);
1603 class MainFrame_SettingVhookPathButton_actionAdapter implements ActionListener {
1605 private MainFrame adaptee;
1607 MainFrame_SettingVhookPathButton_actionAdapter(MainFrame adaptee) {
1608 this.adaptee = adaptee;
1611 public void actionPerformed(ActionEvent e) {
1612 adaptee.SettingVhookPathButton_actionPerformed(e);
1616 class MainFrame_SettingFFmpegPathButton_actionAdapter implements ActionListener {
1618 private MainFrame adaptee;
1620 MainFrame_SettingFFmpegPathButton_actionAdapter(MainFrame adaptee) {
1621 this.adaptee = adaptee;
1624 public void actionPerformed(ActionEvent e) {
1625 adaptee.SettingFFmpegPathButton_actionPerformed(e);
1629 class MainFrame_DoButton_actionAdapter implements ActionListener {
1631 private MainFrame adaptee;
1633 MainFrame_DoButton_actionAdapter(MainFrame adaptee) {
1634 this.adaptee = adaptee;
1637 public void actionPerformed(ActionEvent e) {
1638 adaptee.DoButton_actionPerformed(e);
1642 class MainFrame_jMenuFileExit_ActionAdapter implements ActionListener {
1646 MainFrame_jMenuFileExit_ActionAdapter(MainFrame adaptee) {
1647 this.adaptee = adaptee;
1650 public void actionPerformed(ActionEvent actionEvent) {
1651 adaptee.jMenuFileExit_actionPerformed(actionEvent);
1655 class MainFrame_jMenuHelpAbout_ActionAdapter implements ActionListener {
1659 MainFrame_jMenuHelpAbout_ActionAdapter(MainFrame adaptee) {
1660 this.adaptee = adaptee;
1663 public void actionPerformed(ActionEvent actionEvent) {
1664 adaptee.jMenuHelpAbout_actionPerformed(actionEvent);