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 javax.swing.BorderFactory;
22 import javax.swing.ButtonGroup;
23 import javax.swing.GroupLayout;
24 import javax.swing.JButton;
25 import javax.swing.JCheckBox;
26 import javax.swing.JComboBox;
27 import javax.swing.JFileChooser;
28 import javax.swing.JFrame;
29 import javax.swing.JLabel;
30 import javax.swing.JMenu;
31 import javax.swing.JMenuBar;
32 import javax.swing.JMenuItem;
33 import javax.swing.JOptionPane;
34 import javax.swing.JPanel;
35 import javax.swing.JPasswordField;
36 import javax.swing.JRadioButton;
37 import javax.swing.JTabbedPane;
38 import javax.swing.JTextField;
39 import javax.swing.LayoutStyle.ComponentPlacement;
40 import javax.swing.SwingUtilities;
41 import javax.swing.border.BevelBorder;
42 import nicobrowser.entity.NicoContent;
43 import org.apache.commons.lang.StringUtils;
44 import saccubus.ConvertStopFlag.State;
45 import saccubus.converter.profile.FfmpegOption;
46 import saccubus.converter.profile.NgSetting;
47 import saccubus.net.TextProgressListener;
48 import saccubus.properties.BasicSetting;
49 import saccubus.properties.ConvertSetting;
50 import saccubus.properties.InputCommentSetting;
51 import saccubus.properties.InputVideoSetting;
52 import saccubus.properties.SProperties;
53 import saccubus.properties.InputTcommentSetting;
54 import saccubus.properties.MovieSetting;
55 import saccubus.properties.OutputVideoSetting;
56 import saccubus.util.FileDropTarget;
57 import saccubus.util.PopupRightClick;
58 import yukihane.nicovideo.NicoDBFinder;
66 * 説明: ニコニコ動画の動画をコメントつきで保存
70 * 著作権: Copyright (c) 2007 PSI
80 public class MainFrame extends JFrame {
82 private static final long serialVersionUID = 2564486741331062989L;
83 public static final String PRODUCT_NAME = "いんきゅばす";
84 public static final String VERSION = "1.5.0";
85 public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
87 // TODO GUIが無いためフィールドに保持.
90 BorderLayout borderLayout1 = new BorderLayout();
91 JMenuBar jMenuBar1 = new JMenuBar();
92 JMenu jMenuFile = new JMenu();
93 JMenuItem jMenuFileExit = new JMenuItem();
94 JMenu jMenuHelp = new JMenu();
95 JMenuItem jMenuHelpAbout = new JMenuItem();
96 JLabel statusBar = new JLabel();
97 JTabbedPane mainTabbedPane = new JTabbedPane();
98 JPanel SavingInfoTabPanel = new JPanel();
99 JPanel FFMpegTabPanel = new JPanel();
100 JPanel VideoInfoPanel = new JPanel();
101 JTextField VideoID_TextField = new JTextField();
102 JButton DoButton = new JButton();
103 public static final String DoButtonDefString = "変換";
104 public static final String DoButtonStopString = "停止";
105 public static final String DoButtonWaitString = "待機";
106 JPanel UserInfoPanel = new JPanel();
107 GridBagLayout gridBagLayout3 = new GridBagLayout();
109 JLabel mailAddressLabel = new JLabel();
110 JTextField mailAddressField = new JTextField();
111 JLabel passwordLabel = new JLabel();
112 JPasswordField passwordField = new JPasswordField();
113 GridBagLayout gridBagLayout4 = new GridBagLayout();
114 GridBagLayout gridBagLayout6 = new GridBagLayout();
115 ButtonGroup CommentSaveButtonGroup = new ButtonGroup();
116 ButtonGroup ConvSaveButtonGroup = new ButtonGroup();
118 private class FfmpegOptionCheckBoxListener implements ActionListener{
121 public void actionPerformed(ActionEvent e) {
122 setFFMpegOptionCheckbox();
125 private final FfmpegOptionCheckBoxListener ffmpegOptionCheckBoxListener = new FfmpegOptionCheckBoxListener();
127 private void setFFMpegOptionCheckbox() {
128 boolean resizable = (resizeCheckBox.isEnabled() && resizeCheckBox.isSelected());
129 resizeWidthField.setEnabled(resizable);
130 resizeHeigitField.setEnabled(resizable);
131 adjustRatioCheckBox.setEnabled(resizable);
133 boolean adjustable = (adjustRatioCheckBox.isEnabled() && adjustRatioCheckBox.isSelected());
134 paddingCheckBox.setEnabled(adjustable);
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 .addGroup(layout.createParallelGroup()
453 .addComponent(extOptionField)
454 .addComponent(mainOptionField)
455 .addComponent(inputOptionField)
456 .addComponent(outputOptionField)))
457 .addGroup(layout.createParallelGroup()
458 .addGroup(layout.createSequentialGroup()
459 .addComponent(resizeCheckBox)
460 .addPreferredGap(ComponentPlacement.UNRELATED)
461 .addComponent(resizeWidthLabel)
462 .addPreferredGap(ComponentPlacement.RELATED)
463 .addComponent(resizeWidthField)
464 .addPreferredGap(ComponentPlacement.UNRELATED)
465 .addComponent(resizeHeightLabel)
466 .addPreferredGap(ComponentPlacement.RELATED)
467 .addComponent(resizeHeigitField)))
468 .addGroup(layout.createSequentialGroup()
470 .addComponent(adjustRatioCheckBox))
471 .addGroup(layout.createSequentialGroup()
473 .addComponent(paddingCheckBox))
476 layout.setVerticalGroup(layout.createSequentialGroup()
477 .addComponent(getFFmpegOptionComboBoxPanel())
478 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
479 .addComponent(extOptionLabel)
480 .addComponent(extOptionField))
481 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
482 .addComponent(mainOptionLabel)
483 .addComponent(mainOptionField))
484 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
485 .addComponent(inputOptionLabel)
486 .addComponent(inputOptionField))
487 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
488 .addComponent(outputOptionLabel)
489 .addComponent(outputOptionField))
490 .addGroup(layout.createSequentialGroup()
491 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
492 .addComponent(resizeCheckBox)
493 .addComponent(resizeWidthLabel)
494 .addComponent(resizeWidthField)
495 .addComponent(resizeHeightLabel)
496 .addComponent(resizeHeigitField))
497 .addComponent(adjustRatioCheckBox)
498 .addComponent(paddingCheckBox)));
500 resizeCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
501 adjustRatioCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
502 paddingCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
503 setFFMpegOptionCheckbox();
506 VideoInfoPanel.add(DoButton, gridBagConstraints71);
507 VideoInfoPanel.add(OpPanel, new GridBagConstraints(0, 0, 1, 1, 1.0,
508 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
509 new Insets(0, 0, 0, 0), 0, 0));
510 OpPanel.add(VideoID_Label, gridBagConstraints67);
511 OpPanel.add(VideoID_TextField, gridBagConstraints68);
512 OpPanel.add(WayBackLabel, gridBagConstraints69);
513 OpPanel.add(WayBackField, gridBagConstraints70);
515 mainTabbedPane.add(BasicInfoTabPanel, "基本設定");
516 mainTabbedPane.add(SavingInfoTabPanel, "保存設定");
517 mainTabbedPane.add(FFMpegTabPanel, "動画設定");
518 mainTabbedPane.addTab("変換設定", null, getConvertingSettingPanel(), null);
519 SavingInfoTabPanel.add(savePanel);
520 BasicInfoTabPanel.add(UserInfoPanel, gridBagConstraints7);
521 BasicInfoTabPanel.add(getProxyInfoPanel(), gridBagConstraints6);
522 VhookSettingPanel.add(FontPathLabel, gridBagConstraints59);
523 VhookSettingPanel.add(showConvVideoCheckBox, gridBagConstraints63);
524 VhookSettingPanel.add(fontPathField, gridBagConstraints60);
525 VhookSettingPanel.add(fontIndexField, gridBagConstraints62);
526 VhookSettingPanel.add(FontIndexLabel, gridBagConstraints61);
527 VhookSettingPanel.add(SettingFontPathButton, gridBagConstraints64);
528 VhookSettingPanel.add(getFixFontSizeCheckBox(), gridBagConstraints14);
529 VhookSettingPanel.add(getOpaqueCommentCheckBox(), gridBagConstraints33);
530 VhookSettingPanel.add(getNotUseVhookCheckBox(), gridBagConstraints58);
531 VhookSettingPanel.add(getViewCommentField(), gridBagConstraints65);
532 VhookSettingPanel.add(ViewCommentLabel, gridBagConstraints66);
533 VhookSettingPanel.add(ShadowKindLabel, gridBagConstraints72);
534 VhookSettingPanel.add(getShadowComboBox(), gridBagConstraints73);
536 FFMpegTabPanel.add(PathSettingPanel, new GridBagConstraints(0, 0, 1, 1,
537 1.0, 0.0, GridBagConstraints.NORTHEAST,
538 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
539 FFMpegTabPanel.add(FFmpegSettingPanel, gridBagConstraints1);
543 * 保存設定パネル内のボタンにアクションリスナを割り当てる.
545 private void setListenerToSavePanelButton() {
547 al = new InputVideoPanelButtonListener();
548 videoSaveInfoPanel.getShowSavingVideoFolderDialogButton().addActionListener(al);
549 videoSaveInfoPanel.getShowSavingVideoFileDialogButton().addActionListener(al);
550 videoSaveInfoPanel.getNibrFileChooserButton().addActionListener(al);
552 al = new VideoUseRadioButtonListener();
553 videoSaveInfoPanel.getVideoNoSaveButton().addActionListener(al);
554 videoSaveInfoPanel.getVideoSaveButton().addActionListener(al);
555 videoSaveInfoPanel.getVideoUseNiBrButton().addActionListener(al);
557 al = new InputCommentPanelButtonListener();
558 savePanel.getShowSavingCommentFolderDialogButton().addActionListener(al);
559 savePanel.getShowSavingCommentFileDialogButton().addActionListener(al);
561 al = new OutputVideoPanelButtonListener();
562 savePanel.getShowSavingConvertedVideoFolderDialogButton().addActionListener(al);
563 savePanel.getShowSavingConvertedVideoFileDialogButton().addActionListener(al);
566 private void setPopup() {
567 mainOptionField.addMouseListener(new PopupRightClick(
568 this.mainOptionField));
569 inputOptionField.addMouseListener(new PopupRightClick(
570 this.inputOptionField));
571 outputOptionField.addMouseListener(new PopupRightClick(
572 this.outputOptionField));
573 savePanel.getCommentNumField().addMouseListener(new PopupRightClick(
574 savePanel.getCommentNumField()));
576 savePanel.getCommentSavedFileField().addMouseListener(new PopupRightClick(
577 savePanel.getCommentSavedFileField()));
578 savePanel.getCommentSavedFolderField().addMouseListener(new PopupRightClick(
579 savePanel.getCommentSavedFolderField()));
581 savePanel.getConvertedVideoSavedFileField().addMouseListener(new PopupRightClick(
582 savePanel.getConvertedVideoSavedFileField()));
583 savePanel.getConvertedVideoSavedFolderField().addMouseListener(new PopupRightClick(
584 savePanel.getConvertedVideoSavedFolderField()));
586 videoSaveInfoPanel.getVideoSavedFileField().addMouseListener(new PopupRightClick(
587 videoSaveInfoPanel.getVideoSavedFileField()));
588 videoSaveInfoPanel.getVideoSavedFolderField().addMouseListener(new PopupRightClick(
589 videoSaveInfoPanel.getVideoSavedFolderField()));
590 videoSaveInfoPanel.getNibrFileField().addMouseListener(
591 new PopupRightClick(videoSaveInfoPanel.getNibrFileField()));
593 ffmpegPathField.addMouseListener(new PopupRightClick(
594 this.ffmpegPathField));
595 vhookPathField.addMouseListener(new PopupRightClick(this.vhookPathField));
596 VideoID_TextField.addMouseListener(new PopupRightClick(
597 this.VideoID_TextField));
598 viewCommentField.addMouseListener(new PopupRightClick(
599 this.viewCommentField));
600 fontPathField.addMouseListener(new PopupRightClick(this.fontPathField));
601 mailAddressField.addMouseListener(new PopupRightClick(this.mailAddressField));
602 passwordField.addMouseListener(new PopupRightClick(this.passwordField));
603 WayBackField.addMouseListener(new PopupRightClick(this.WayBackField));
605 proxyTextField.addMouseListener(new PopupRightClick(this.proxyTextField));
606 proxyPortTextField.addMouseListener(new PopupRightClick(
607 this.proxyPortTextField));
609 fontIndexField.addMouseListener(new PopupRightClick(this.fontIndexField));
611 ngWordTextField.addMouseListener(new PopupRightClick(
612 this.ngWordTextField));
613 ngIdTextField.addMouseListener(new PopupRightClick(this.ngIdTextField));
616 private void setDropTarget() {
617 addTarget(videoSaveInfoPanel.getVideoSavedFileField(), false);
618 addTarget(videoSaveInfoPanel.getVideoSavedFolderField(), true);
619 addTarget(videoSaveInfoPanel.getNibrFileField(), false);
621 addTarget(savePanel.getCommentSavedFileField(), false);
622 addTarget(savePanel.getCommentSavedFolderField(), true);
624 addTarget(savePanel.getConvertedVideoSavedFileField(), false);
625 addTarget(savePanel.getConvertedVideoSavedFolderField(), true);
627 addTarget(ffmpegPathField, false);
628 addTarget(vhookPathField, false);
629 addTarget(fontPathField, false);
634 * テキストフィールドに対しドロップを行った場合にファイルもしくはディレクトリの文字列を設定できるようにする.
635 * @param c 設定対象のテキストフィールドオブジェクト.
636 * @param isDir ディレクトリを設定する場合はtrue, ファイルの場合はfalse.
637 * @return ドロップターゲット(用途無し).
639 private DropTarget addTarget(JTextField c, boolean isDir) {
640 return new DropTarget(c, DnDConstants.ACTION_COPY, new FileDropTarget(
643 private File CurrentDir = new File(".");
644 private JPanel PathSettingPanel = new JPanel();
645 private JLabel FFmpegPathLabel = new JLabel();
646 private GridBagLayout gridBagLayout7 = new GridBagLayout();
647 private JTextField ffmpegPathField = new JTextField();
648 private JButton SettingFFmpegPathButton = new JButton();
649 private JLabel VhookPathLabel = new JLabel();
650 private JTextField vhookPathField = new JTextField();
651 private JButton SettingVhookPathButton = new JButton();
652 private JPanel VhookSettingPanel = new JPanel();
653 private GridBagLayout gridBagLayout8 = new GridBagLayout();
654 private JPanel FFmpegSettingPanel = new JPanel();
655 private GridBagLayout gblFFmpegSettingPanel = new GridBagLayout();
656 private JLabel FontPathLabel = new JLabel();
657 private JTextField fontPathField = new JTextField();
658 private JButton SettingFontPathButton = new JButton();
659 private JCheckBox showConvVideoCheckBox = new JCheckBox();
661 private void showSaveDialog(String title, JTextField field, boolean isSave,
663 JFileChooser chooser = new JFileChooser(CurrentDir);
664 chooser.setDialogTitle(title);
667 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
670 code = chooser.showSaveDialog(this);
672 code = chooser.showOpenDialog(this);
674 if (code == JFileChooser.APPROVE_OPTION) {
676 CurrentDir = chooser.getSelectedFile();
677 field.setText(CurrentDir.getAbsolutePath());
679 File selected = chooser.getSelectedFile();
680 CurrentDir = chooser.getCurrentDirectory();
681 field.setText(selected.getAbsolutePath());
686 private SProperties getSetting() {
687 SProperties setting = new SProperties(
689 getInputVideoSetting(),
690 getInputCommentSetting(),
691 getTcommentSetting(),
692 getOutputVideoSetting(),
694 getConvertSetting());
700 * @param setting 反映する設定.
702 private void setSetting(SProperties setting) {
704 final BasicSetting basic = setting.getBasicSetting();
705 tempDir = basic.getTempDir();
706 mailAddressField.setText(basic.getUser().getMail());
707 passwordField.setText(basic.getUser().getPassword());
709 useProxyCheckBox.setSelected(basic.isProxyUse());
710 proxyTextField.setText(basic.getProxyHost());
711 int proxy_port = basic.getProxyPort();
712 if (proxy_port >= 0 && proxy_port <= 65535) {
713 proxyPortTextField.setText(Integer.toString(proxy_port));
715 proxyPortTextField.setText("");
719 final InputVideoSetting inVideo = setting.getInputVideoSetting();
720 JRadioButton activeButton;
721 switch (inVideo.getProcessKind()) {
723 activeButton = videoSaveInfoPanel.getVideoNoSaveButton();
726 activeButton = videoSaveInfoPanel.getVideoUseNiBrButton();
730 activeButton = videoSaveInfoPanel.getVideoSaveButton();
733 activeButton.doClick();
735 videoSaveInfoPanel.getVideoSavedFileField().setText(inVideo.getFile().getPath());
736 videoSaveInfoPanel.getVideoSavedFolderField().setText(inVideo.getFolder().getPath());
737 videoSaveInfoPanel.getDelVideoCheckBox().setSelected(inVideo.isDeleteAfterConvert());
738 final boolean videoFixName = inVideo.isAutoNaming();
739 videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
740 videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
741 videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath());
744 final InputCommentSetting inputComment = setting.getInputCommentSetting();
745 savePanel.getSavingCommentCheckBox().setSelected(inputComment.getProcessKind());
746 savePanel.getCommentSavedFileField().setText(inputComment.getFile().getPath());
747 savePanel.getDelCommentCheckBox().setSelected(inputComment.isDeleteAfterConvert());
748 savePanel.getCommentSavedFolderField().setText(inputComment.getFolder().getPath());
749 savePanel.getCommentNumField().setText(Integer.toString(inputComment.getNumOfComment()));
750 savePanel.getFixCommentNumCheckBox().setSelected(inputComment.isSelfAdjustNumOfComment());
751 boolean commentFixName = inputComment.isAutoNaming();
752 savePanel.getCommentSaveFileRadioButton().setSelected(!commentFixName);
753 savePanel.getCommentSaveFolderRadioButton().setSelected(commentFixName);
756 InputTcommentSetting tcom = setting.getInputTcommentSetting();
757 savePanel.setTcommentDownload(tcom.getProcessKind());
758 savePanel.setTcommentDelete(tcom.isDeleteAfterConvert());
759 savePanel.setTcommentAutoFileName(tcom.isAutoNaming());
760 savePanel.setTcommentDirectoryName(tcom.getFolder().getPath());
761 savePanel.setTcommentFileName(tcom.getFile().getPath());
764 final OutputVideoSetting outputVideo = setting.getOutputVideoSetting();
765 savePanel.getSavingConvertedVideoCheckBox().setSelected(outputVideo.getProcessKind());
766 savePanel.getAddCommentCheckBox().setSelected(outputVideo.isAddComment());
767 savePanel.getAddTcommentCheckBox().setSelected(outputVideo.isAddTcomment());
768 savePanel.getConvertedVideoSavedFileField().setText(outputVideo.getFile().getPath());
769 savePanel.getConvertedVideoSavedFolderField().setText(outputVideo.getFolder().getPath());
770 savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(outputVideo.isCutIdName());
771 boolean convFixName = outputVideo.isAutoNaming();
772 savePanel.getConvSaveFileRadioButton().setSelected(!convFixName);
773 savePanel.getConvSaveFolderRadioButton().setSelected(convFixName);
776 final MovieSetting movie = setting.getMovieSetting();
777 ffmpegPathField.setText(movie.getFfmpeg().toString());
778 vhookPathField.setText(movie.getVhook().toString());
779 extOptionField.setText(movie.getFfmpegOption().getExtOption());
780 mainOptionField.setText(movie.getFfmpegOption().getMainOption());
781 inputOptionField.setText(movie.getFfmpegOption().getInOption());
782 outputOptionField.setText(movie.getFfmpegOption().getOutOption());
783 avfilterOptionField.setText(movie.getFfmpegOption().getAvfilterOption());
784 resizeCheckBox.setSelected(movie.getFfmpegOption().isResize());
785 resizeWidthField.setText(Integer.toString(movie.getFfmpegOption().getResizeWidth()));
786 resizeHeigitField.setText(Integer.toString(movie.getFfmpegOption().getResizeHeight()));
787 adjustRatioCheckBox.setSelected(movie.getFfmpegOption().isAdjustRatio());
788 paddingCheckBox.setSelected(movie.getFfmpegOption().isPadding());
789 FFmpegOptionModel.reload(movie.getOptionFile());
792 final ConvertSetting conv = setting.getConvertSetting();
793 disableVhookCheckBox.setSelected(conv.isVhookDisabled());
794 viewCommentField.setText(Integer.toString(conv.getMaxNumOfComment()));
795 fontPathField.setText(conv.getFont().toString());
796 fontIndexField.setText(Integer.toString(conv.getFontIndex()));
797 shadowComboBox.setSelectedIndex(conv.getShadowIndex());
798 showConvVideoCheckBox.setSelected(conv.isShowConverting());
799 fixFontSizeCheckBox.setSelected(conv.isSelfAdjustFontSize());
800 opaqueCommentCheckBox.setSelected(conv.isCommentOpaque());
801 ngWordTextField.setText(conv.getNgSetting().getWord());
802 ngIdTextField.setText(conv.getNgSetting().getId());
806 * [ファイル|終了] アクションが実行されました。
811 void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
812 SProperties setting = getSetting();
813 SProperties.saveSetting(setting);
818 * [ヘルプ|バージョン情報] アクションが実行されました。
823 void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
824 MainFrame_AboutBox dlg = new MainFrame_AboutBox(this);
826 dlg.setLocationRelativeTo(this);
827 dlg.setVisible(true);
831 private Converter Converter = null;
833 private final JLabel extOptionLabel = new JLabel();
834 private final JTextField extOptionField = new JTextField();
835 private JLabel mainOptionLabel = new JLabel();
836 private JTextField mainOptionField = new JTextField();
837 private JLabel inputOptionLabel = new JLabel();
838 private JTextField inputOptionField = new JTextField();
839 private JLabel outputOptionLabel = new JLabel();
840 private JTextField outputOptionField = new JTextField();
841 private final JLabel avfilterOptionLabel = new JLabel();
842 private final JTextField avfilterOptionField = new JTextField();
843 private final JCheckBox resizeCheckBox = new JCheckBox("次のサイズに収まるようリサイズ");
844 private final JLabel resizeWidthLabel = new JLabel("横");
845 private final JTextField resizeWidthField = new JTextField();
846 private final JLabel resizeHeightLabel = new JLabel("縦");
847 private final JTextField resizeHeigitField = new JTextField();
848 private final JCheckBox adjustRatioCheckBox = new JCheckBox("アスペクト比を維持");
849 private final JCheckBox paddingCheckBox = new JCheckBox("黒幕を付与");
851 private JLabel FontIndexLabel = new JLabel();
852 private JTextField fontIndexField = new JTextField();
853 private JLabel VideoID_Label = new JLabel();
854 private JLabel WayBackLabel = new JLabel();
855 private JTextField WayBackField = new JTextField();
856 private GridBagLayout gridBagLayout1 = new GridBagLayout();
857 private JPanel OpPanel = new JPanel();
858 private JPanel BasicInfoTabPanel = new JPanel();
859 private GridBagLayout gridBagLayout12 = new GridBagLayout();
860 private JPanel ConvertingSettingPanel = null;
861 private JPanel NGWordSettingPanel = null;
862 private JLabel NGWordLavel = null;
863 private JTextField ngWordTextField = null;
864 private JLabel NGIDLabel = null;
865 private JTextField ngIdTextField = null;
867 private JPanel ProxyInfoPanel = null;
868 private JCheckBox useProxyCheckBox = null;
869 private JLabel proxyLabel = null;
870 private JTextField proxyTextField = null;
871 private JLabel proxyPortLabel = null;
872 private JTextField proxyPortTextField = null;
874 private JCheckBox fixFontSizeCheckBox = null;
875 private JCheckBox opaqueCommentCheckBox = null;
876 private final SavePanel savePanel = new SavePanel();
877 private final VideoSaveInfoPanel videoSaveInfoPanel;
878 private JComboBox FFmpegOptionComboBox = null;
879 private JButton FFmpegOptionReloadButton = null;
880 private JPanel FFmpegOptionComboBoxPanel = null;
882 public void DoButton_actionPerformed(ActionEvent e) {
883 if (Converter == null || Converter.isConverted()) {
886 } catch (Exception ex) {
887 String text = ex.getMessage();
888 if (StringUtils.isEmpty(text)) {
889 text = "予期しないエラーのため中断しました。";
891 ex.printStackTrace();
892 statusBar.setText(text);
894 } else { /* 開始しているので、ストップする。 */
895 final ConvertStopFlag flag = Converter.getStopFlag();
896 if (!flag.needStop()) { /* まだストップしていない。 */
902 private void executeConvert() throws IOException {
905 // NicoBrowserファイルを利用する場合は、ファイル名からビデオIDを特定.
906 if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
908 String fileName = videoSaveInfoPanel.getNibrFileField().getText();
909 NicoDBFinder finder = NicoDBFinder.getInstance();
910 NicoContent info = finder.findNicoContent(fileName);
912 url = info.getNicoId();
916 } catch (Exception ex) {
917 JOptionPane.showMessageDialog(this, ex.getMessage(), "エラー", JOptionPane.ERROR_MESSAGE);
921 url = VideoID_TextField.getText();
924 TextProgressListener sl = new TextProgressListener() {
926 public void setText(final String text) {
927 SwingUtilities.invokeLater(new Runnable() {
930 statusBar.setText(text);
936 ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
938 public void changeState(final State s) {
939 SwingUtilities.invokeLater(new Runnable() {
944 DoButton.setText(DoButtonWaitString);
947 DoButton.setText(DoButtonDefString);
954 Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
955 new ConvertStopFlag(scl));
956 DoButton.setText(DoButtonStopString);
957 new Thread(Converter).start();
962 public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
963 showSaveDialog("FFmpegへのパス", ffmpegPathField, false, false);
966 public void SettingVhookPathButton_actionPerformed(ActionEvent e) {
967 showSaveDialog("拡張vhookライブラリへのパス", vhookPathField, false, false);
970 public void SettingFontPathButton_actionPerformed(ActionEvent e) {
971 showSaveDialog("フォントへのパス", fontPathField, false, false);
974 public void this_windowClosing(WindowEvent e) {
975 this.jMenuFileExit_actionPerformed(null);
979 * This method initializes ConvertingSettingPanel
981 * @return javax.swing.JPanel
983 private JPanel getConvertingSettingPanel() {
984 if (ConvertingSettingPanel == null) {
985 GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
986 gridBagConstraints11.weighty = 1.0;
987 gridBagConstraints11.weightx = 1.0;
988 gridBagConstraints11.insets = new Insets(0, 5, 0, 5);
989 gridBagConstraints11.gridy = 1;
990 gridBagConstraints11.gridx = 0;
991 gridBagConstraints11.anchor = GridBagConstraints.NORTH;
992 gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
993 GridBagConstraints gridBagConstraints = new GridBagConstraints(0,
994 2, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
995 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
996 gridBagConstraints.gridx = 0;
997 gridBagConstraints.anchor = GridBagConstraints.CENTER;
998 gridBagConstraints.weighty = 0.0;
999 gridBagConstraints.gridy = 0;
1000 ConvertingSettingPanel = new JPanel();
1001 ConvertingSettingPanel.setLayout(new GridBagLayout());
1002 ConvertingSettingPanel.add(getNGWordSettingPanel(),
1003 gridBagConstraints11);
1004 ConvertingSettingPanel.add(VhookSettingPanel, gridBagConstraints);
1006 return ConvertingSettingPanel;
1010 * This method initializes NGWordSettingPanel
1012 * @return javax.swing.JPanel
1014 private JPanel getNGWordSettingPanel() {
1015 if (NGWordSettingPanel == null) {
1016 GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
1017 gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
1018 gridBagConstraints5.gridy = 1;
1019 gridBagConstraints5.weightx = 1.0;
1020 gridBagConstraints5.insets = new Insets(0, 5, 5, 5);
1021 gridBagConstraints5.gridx = 1;
1022 GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
1023 gridBagConstraints4.gridx = 0;
1024 gridBagConstraints4.anchor = GridBagConstraints.WEST;
1025 gridBagConstraints4.insets = new Insets(0, 5, 5, 0);
1026 gridBagConstraints4.gridy = 1;
1027 NGIDLabel = new JLabel();
1028 NGIDLabel.setText("NG ID");
1029 GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
1030 gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
1031 gridBagConstraints3.gridy = 0;
1032 gridBagConstraints3.weightx = 1.0;
1033 gridBagConstraints3.insets = new Insets(0, 5, 5, 5);
1034 gridBagConstraints3.gridx = 1;
1035 GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
1036 gridBagConstraints2.gridx = 0;
1037 gridBagConstraints2.insets = new Insets(0, 5, 5, 0);
1038 gridBagConstraints2.gridy = 0;
1039 NGWordLavel = new JLabel();
1040 NGWordLavel.setText("NGワード");
1041 NGWordSettingPanel = new JPanel();
1042 NGWordSettingPanel.setLayout(new GridBagLayout());
1043 NGWordSettingPanel.setBorder(BorderFactory.createTitledBorder(null,
1045 NGWordSettingPanel.add(NGWordLavel, gridBagConstraints2);
1046 NGWordSettingPanel.add(getNGWordTextField(), gridBagConstraints3);
1047 NGWordSettingPanel.add(NGIDLabel, gridBagConstraints4);
1048 NGWordSettingPanel.add(getNGIDTextField(), gridBagConstraints5);
1050 return NGWordSettingPanel;
1054 * This method initializes NGWordTextField
1056 * @return javax.swing.JTextField
1058 private JTextField getNGWordTextField() {
1059 if (ngWordTextField == null) {
1060 ngWordTextField = new JTextField();
1061 ngWordTextField.setName("ngWordTextField");
1063 return ngWordTextField;
1067 * This method initializes NGIDTextField
1069 * @return javax.swing.JTextField
1071 private JTextField getNGIDTextField() {
1072 if (ngIdTextField == null) {
1073 ngIdTextField = new JTextField();
1074 ngIdTextField.setName("ngIdTextField");
1076 return ngIdTextField;
1080 * This method initializes ProxyInfoPanel
1082 * @return javax.swing.JPanel
1084 private JPanel getProxyInfoPanel() {
1085 if (ProxyInfoPanel == null) {
1086 GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
1087 gridBagConstraints13.gridx = 0;
1088 gridBagConstraints13.gridwidth = 2;
1089 gridBagConstraints13.weightx = 1.0;
1090 gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL;
1091 gridBagConstraints13.insets = new Insets(0, 5, 0, 5);
1092 gridBagConstraints13.gridy = 0;
1093 GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
1094 gridBagConstraints12.fill = GridBagConstraints.HORIZONTAL;
1095 gridBagConstraints12.gridy = 2;
1096 gridBagConstraints12.weightx = 1.0;
1097 gridBagConstraints12.insets = new Insets(5, 0, 5, 5);
1098 gridBagConstraints12.gridx = 1;
1099 GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
1100 gridBagConstraints10.gridx = 0;
1101 gridBagConstraints10.insets = new Insets(5, 5, 5, 5);
1102 gridBagConstraints10.gridy = 2;
1103 proxyPortLabel = new JLabel();
1104 proxyPortLabel.setText("ポート番号");
1105 GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
1106 gridBagConstraints9.fill = GridBagConstraints.BOTH;
1107 gridBagConstraints9.gridy = 1;
1108 gridBagConstraints9.weightx = 1.0;
1109 gridBagConstraints9.insets = new Insets(0, 0, 0, 5);
1110 gridBagConstraints9.gridx = 1;
1111 GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
1112 gridBagConstraints8.gridx = 0;
1113 gridBagConstraints8.insets = new Insets(0, 5, 0, 5);
1114 gridBagConstraints8.fill = GridBagConstraints.NONE;
1115 gridBagConstraints8.anchor = GridBagConstraints.EAST;
1116 gridBagConstraints8.gridy = 1;
1117 proxyLabel = new JLabel();
1118 proxyLabel.setText("プロキシ");
1119 ProxyInfoPanel = new JPanel();
1120 ProxyInfoPanel.setLayout(new GridBagLayout());
1121 ProxyInfoPanel.setBorder(BorderFactory.createTitledBorder(null,
1123 ProxyInfoPanel.add(proxyLabel, gridBagConstraints8);
1124 ProxyInfoPanel.add(getProxyTextField(), gridBagConstraints9);
1125 ProxyInfoPanel.add(proxyPortLabel, gridBagConstraints10);
1126 ProxyInfoPanel.add(getProxyPortTextField(), gridBagConstraints12);
1127 ProxyInfoPanel.add(getUseProxyCheckBox(), gridBagConstraints13);
1129 return ProxyInfoPanel;
1133 * This method initializes ProxyTextField
1135 * @return javax.swing.JTextField
1137 private JTextField getProxyTextField() {
1138 if (proxyTextField == null) {
1139 proxyTextField = new JTextField();
1140 proxyTextField.setName("proxyTextField");
1142 return proxyTextField;
1146 * This method initializes ProxyPortTextField
1148 * @return javax.swing.JTextField
1150 private JTextField getProxyPortTextField() {
1151 if (proxyPortTextField == null) {
1152 proxyPortTextField = new JTextField();
1153 proxyPortTextField.setName("proxyPortTextField");
1155 return proxyPortTextField;
1159 * This method initializes UseProxyCheckBox
1161 * @return javax.swing.JCheckBox
1163 private JCheckBox getUseProxyCheckBox() {
1164 if (useProxyCheckBox == null) {
1165 useProxyCheckBox = new JCheckBox();
1166 useProxyCheckBox.setText("プロキシを使う");
1167 useProxyCheckBox.setName("useProxyCheckBox");
1169 return useProxyCheckBox;
1173 * This method initializes FixFontSizeCheckBox
1175 * @return javax.swing.JCheckBox
1177 private JCheckBox getFixFontSizeCheckBox() {
1178 if (fixFontSizeCheckBox == null) {
1179 fixFontSizeCheckBox = new JCheckBox();
1180 fixFontSizeCheckBox.setText("フォントサイズを画面にあわせて自動調整する");
1181 fixFontSizeCheckBox.setName("fixFontSizeCheckBox");
1183 return fixFontSizeCheckBox;
1187 * This method initializes OpaqueCommentCheckBox
1189 * @return javax.swing.JCheckBox
1191 private JCheckBox getOpaqueCommentCheckBox() {
1192 if (opaqueCommentCheckBox == null) {
1193 opaqueCommentCheckBox = new JCheckBox();
1194 opaqueCommentCheckBox.setText("全てのコメントを不透明にする");
1195 opaqueCommentCheckBox.setName("opaqueCommentCheckBox");
1197 return opaqueCommentCheckBox;
1200 * This method initializes FFmpegOptionComboBox
1202 * @return javax.swing.JComboBox
1204 private final OptionComboBoxModel FFmpegOptionModel = new OptionComboBoxModel();
1205 private JCheckBox disableVhookCheckBox = null;
1206 private JTextField viewCommentField = null;
1207 private JLabel ViewCommentLabel = null;
1208 private JLabel ShadowKindLabel = null;
1209 private JComboBox shadowComboBox = null;
1211 private JComboBox getFFmpegOptionComboBox() {
1212 if (FFmpegOptionComboBox == null) {
1213 FFmpegOptionComboBox = new JComboBox(FFmpegOptionModel);
1214 FFmpegOptionComboBox.addActionListener(new java.awt.event.ActionListener() {
1216 public void actionPerformed(java.awt.event.ActionEvent e) {
1217 if (FFmpegOptionModel.isFile()) {// ファイル
1218 setFFMpegOptionEnabled(false);
1220 setFFMpegOptionEnabled(true);
1221 setFFMpegOptionCheckbox();
1225 private void setFFMpegOptionEnabled(boolean enable) {
1226 extOptionField.setEnabled(enable);
1227 mainOptionField.setEnabled(enable);
1228 inputOptionField.setEnabled(enable);
1229 outputOptionField.setEnabled(enable);
1230 avfilterOptionField.setEnabled(enable);
1231 resizeCheckBox.setEnabled(enable);
1232 resizeWidthField.setEnabled(enable);
1233 resizeHeigitField.setEditable(enable);
1234 adjustRatioCheckBox.setEnabled(enable);
1235 paddingCheckBox.setEnabled(enable);
1239 return FFmpegOptionComboBox;
1243 * This method initializes FFmpegOptionReloadButton
1245 * @return javax.swing.JButton
1247 private JButton getFFmpegOptionReloadButton() {
1248 if (FFmpegOptionReloadButton == null) {
1249 FFmpegOptionReloadButton = new JButton();
1250 FFmpegOptionReloadButton.setText("更新");
1251 FFmpegOptionReloadButton.addActionListener(new java.awt.event.ActionListener() {
1253 public void actionPerformed(java.awt.event.ActionEvent e) {
1254 FFmpegOptionModel.reload();
1258 return FFmpegOptionReloadButton;
1262 * This method initializes FFmpegOptionComboBoxPanel
1264 * @return javax.swing.JPanel
1266 private JPanel getFFmpegOptionComboBoxPanel() {
1267 if (FFmpegOptionComboBoxPanel == null) {
1268 GridBagConstraints gridBagConstraints47 = new GridBagConstraints();
1269 gridBagConstraints47.fill = GridBagConstraints.BOTH;
1270 gridBagConstraints47.gridx = -1;
1271 gridBagConstraints47.gridy = -1;
1272 gridBagConstraints47.insets = new Insets(0, 0, 5, 5);
1273 GridBagConstraints gridBagConstraints46 = new GridBagConstraints();
1274 gridBagConstraints46.fill = GridBagConstraints.HORIZONTAL;
1275 gridBagConstraints46.gridwidth = 3;
1276 gridBagConstraints46.gridx = -1;
1277 gridBagConstraints46.gridy = -1;
1278 gridBagConstraints46.weightx = 1.0;
1279 gridBagConstraints46.insets = new Insets(0, 5, 5, 5);
1280 FFmpegOptionComboBoxPanel = new JPanel();
1281 FFmpegOptionComboBoxPanel.setLayout(new GridBagLayout());
1282 FFmpegOptionComboBoxPanel.add(getFFmpegOptionComboBox(),
1283 gridBagConstraints46);
1284 FFmpegOptionComboBoxPanel.add(getFFmpegOptionReloadButton(),
1285 gridBagConstraints47);
1287 return FFmpegOptionComboBoxPanel;
1291 * This method initializes NotUseVhookCheckBox
1293 * @return javax.swing.JCheckBox
1295 private JCheckBox getNotUseVhookCheckBox() {
1296 if (disableVhookCheckBox == null) {
1297 disableVhookCheckBox = new JCheckBox();
1298 disableVhookCheckBox.setText("拡張vhookライブラリを無効にする(デバッグ用)");
1299 disableVhookCheckBox.setName("disableVhookCheckBox");
1301 return disableVhookCheckBox;
1305 * This method initializes ViewCommentField
1307 * @return javax.swing.JTextField
1309 private JTextField getViewCommentField() {
1310 if (viewCommentField == null) {
1311 viewCommentField = new JTextField();
1312 viewCommentField.setName("viewCommentField");
1314 return viewCommentField;
1318 * This method initializes ShadowComboBox
1320 * @return javax.swing.JComboBox
1322 private JComboBox getShadowComboBox() {
1323 if (shadowComboBox == null) {
1324 shadowComboBox = new JComboBox(SProperties.ShadowKindArray);
1325 shadowComboBox.setName("shadowComboBox");
1327 return shadowComboBox;
1330 private BasicSetting getBasicSetting() {
1331 String mail = mailAddressField.getText();
1332 String pass = String.valueOf(passwordField.getPassword());
1333 boolean proxyUse = useProxyCheckBox.isSelected();
1334 String proxyHost = proxyTextField.getText();
1337 proxyPort = Integer.parseInt(proxyPortTextField.getText());
1338 } catch (NumberFormatException e) {
1341 // TODO 作業用ディレクトリの設定GUI無し
1342 return new BasicSetting(tempDir, mail, pass, proxyUse, proxyHost, proxyPort);
1345 private InputVideoSetting getInputVideoSetting() {
1347 if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) {
1348 kind = VideoSaveKind.NO_SAVE;
1349 } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) {
1350 kind = VideoSaveKind.NICOBROWSER;
1352 kind = VideoSaveKind.SAVE;
1354 boolean autoNaming = videoSaveInfoPanel.getSaveFolderRadioButton().isSelected();
1355 String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
1356 String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
1357 boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
1358 String nibrFile = videoSaveInfoPanel.getNibrFileField().getText();
1360 return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
1363 private InputCommentSetting getInputCommentSetting() {
1364 boolean download = savePanel.getSavingCommentCheckBox().isSelected();
1365 String file = savePanel.getCommentSavedFileField().getText();
1368 back_comment = Integer.parseInt(savePanel.getCommentNumField().getText());
1369 } catch (NumberFormatException ex) {
1372 boolean delete = savePanel.getDelCommentCheckBox().isSelected();
1373 boolean autoNaming = savePanel.getCommentSaveFolderRadioButton().isSelected();
1374 String folder = savePanel.getCommentSavedFolderField().getText();
1375 boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
1377 return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
1382 * 画面入力値から投稿者コメント設定を作成する.
1383 * @return 作成した投稿者コメント設定.
1385 private InputTcommentSetting getTcommentSetting() {
1386 boolean down = savePanel.isTcommentDownload();
1387 boolean del = savePanel.isTcommentDelete();
1388 boolean naming = savePanel.isTcommentAutoFileName();
1389 String dir = savePanel.getTcommentDirectoryName();
1390 String f = savePanel.getTcommentFileName();
1391 return new InputTcommentSetting(down, naming, dir, f, del);
1394 private OutputVideoSetting getOutputVideoSetting() {
1395 boolean process = savePanel.getSavingConvertedVideoCheckBox().isSelected();
1396 boolean addComment = savePanel.getAddCommentCheckBox().isSelected();
1397 boolean addTcomment = savePanel.getAddTcommentCheckBox().isSelected();
1398 String file = savePanel.getConvertedVideoSavedFileField().getText();
1399 boolean cutId = savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected();
1400 boolean autoNaming = savePanel.getConvSaveFolderRadioButton().isSelected();
1401 String folder = savePanel.getConvertedVideoSavedFolderField().getText();
1403 return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment,
1407 private MovieSetting getMovieSetting() {
1408 String ffmpeg = ffmpegPathField.getText();
1409 String vhook = vhookPathField.getText();
1410 String ext = extOptionField.getText();
1411 String main = mainOptionField.getText();
1412 String in = inputOptionField.getText();
1413 String out = outputOptionField.getText();
1414 String avfilter = avfilterOptionField.getText();
1415 boolean resize = resizeCheckBox.isSelected();
1416 String width = resizeWidthField.getText();
1417 String height = resizeHeigitField.getText();
1418 boolean adjust = adjustRatioCheckBox.isSelected();
1419 boolean pad = paddingCheckBox.isSelected();
1420 File optionFile = FFmpegOptionModel.getSelectedFile();
1422 FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust, pad);
1423 return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
1426 private ConvertSetting getConvertSetting() {
1427 boolean vhookDisabled = disableVhookCheckBox.isSelected();
1428 int maxComment = 30;
1430 maxComment = Integer.parseInt(viewCommentField.getText());
1431 } catch (NumberFormatException ex) {
1433 File font = new File(fontPathField.getText());
1434 int fontIndex = Integer.parseInt(fontIndexField.getText());
1435 int shadowIndex = shadowComboBox.getSelectedIndex();
1436 boolean showConv = showConvVideoCheckBox.isSelected();
1437 boolean adjustFont = fixFontSizeCheckBox.isSelected();
1438 boolean commentOpaque = opaqueCommentCheckBox.isSelected();
1439 NgSetting ngSetting = new NgSetting(ngWordTextField.getText(), ngIdTextField.getText());
1441 return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
1442 commentOpaque, ngSetting);
1445 private class InputVideoPanelButtonListener implements ActionListener {
1447 public void actionPerformed(ActionEvent e) {
1448 final Object source = e.getSource();
1449 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1455 if (source == panel.getShowSavingVideoFolderDialogButton()) {
1456 title = "動画の保存先(フォルダ)";
1457 field = panel.getVideoSavedFolderField();
1460 } else if (source == panel.getShowSavingVideoFileDialogButton()) {
1461 title = "動画の保存先(ファイル)";
1462 field = panel.getVideoSavedFileField();
1465 } else if (source == panel.getNibrFileChooserButton()) {
1466 title = "NicoBrowserファイル選択";
1467 field = panel.getNibrFileField();
1473 showSaveDialog(title, field, isSave, isDir);
1477 private class InputCommentPanelButtonListener implements ActionListener {
1479 public void actionPerformed(ActionEvent e) {
1480 final Object source = e.getSource();
1485 if (source == savePanel.getShowSavingCommentFolderDialogButton()) {
1486 title = "コメントの保存先(フォルダ)";
1487 field = savePanel.getCommentSavedFolderField();
1490 } else if (source == savePanel.getShowSavingCommentFileDialogButton()) {
1491 title = "コメントの保存先(ファイル)";
1492 field = savePanel.getCommentSavedFileField();
1498 showSaveDialog(title, field, isSave, isDir);
1502 private class OutputVideoPanelButtonListener implements ActionListener {
1504 public void actionPerformed(ActionEvent e) {
1505 final Object source = e.getSource();
1510 if (source == savePanel.getShowSavingConvertedVideoFolderDialogButton()) {
1511 title = "コメント付き動画の保存先(フォルダ)";
1512 field = savePanel.getConvertedVideoSavedFolderField();
1515 } else if (source == savePanel.getShowSavingConvertedVideoFileDialogButton()) {
1516 title = "コメント付き動画の保存先(ファイル)";
1517 field = savePanel.getConvertedVideoSavedFileField();
1523 showSaveDialog(title, field, isSave, isDir);
1527 private class VideoUseRadioButtonListener implements ActionListener {
1529 public void actionPerformed(ActionEvent e) {
1530 Object source = e.getSource();
1531 if (source == videoSaveInfoPanel.getVideoUseNiBrButton()) {
1538 private void maskBase() {
1542 private void maskExt() {
1546 private void mask(boolean b) {
1547 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1548 VideoID_TextField.setEditable(b);
1549 panel.getDelVideoCheckBox().setEnabled(b);
1551 panel.getSaveFolderRadioButton().setEnabled(b);
1552 panel.getVideoSavedFolderField().setEnabled(b);
1553 panel.getShowSavingVideoFolderDialogButton().setEnabled(b);
1555 panel.getSaveFileRadioButton().setEnabled(b);
1556 panel.getVideoSavedFileField().setEnabled(b);
1557 panel.getShowSavingVideoFileDialogButton().setEnabled(b);
1559 panel.getNibrFileField().setEnabled(!b);
1560 panel.getNibrFileChooserButton().setEnabled(!b);
1565 class MainFrame_this_windowAdapter extends WindowAdapter {
1567 private MainFrame adaptee;
1569 MainFrame_this_windowAdapter(MainFrame adaptee) {
1570 this.adaptee = adaptee;
1574 public void windowClosing(WindowEvent e) {
1575 adaptee.this_windowClosing(e);
1579 class MainFrame_SettingFontPathButton_actionAdapter implements ActionListener {
1581 private MainFrame adaptee;
1583 MainFrame_SettingFontPathButton_actionAdapter(MainFrame adaptee) {
1584 this.adaptee = adaptee;
1587 public void actionPerformed(ActionEvent e) {
1588 adaptee.SettingFontPathButton_actionPerformed(e);
1592 class MainFrame_SettingVhookPathButton_actionAdapter implements ActionListener {
1594 private MainFrame adaptee;
1596 MainFrame_SettingVhookPathButton_actionAdapter(MainFrame adaptee) {
1597 this.adaptee = adaptee;
1600 public void actionPerformed(ActionEvent e) {
1601 adaptee.SettingVhookPathButton_actionPerformed(e);
1605 class MainFrame_SettingFFmpegPathButton_actionAdapter implements ActionListener {
1607 private MainFrame adaptee;
1609 MainFrame_SettingFFmpegPathButton_actionAdapter(MainFrame adaptee) {
1610 this.adaptee = adaptee;
1613 public void actionPerformed(ActionEvent e) {
1614 adaptee.SettingFFmpegPathButton_actionPerformed(e);
1618 class MainFrame_DoButton_actionAdapter implements ActionListener {
1620 private MainFrame adaptee;
1622 MainFrame_DoButton_actionAdapter(MainFrame adaptee) {
1623 this.adaptee = adaptee;
1626 public void actionPerformed(ActionEvent e) {
1627 adaptee.DoButton_actionPerformed(e);
1631 class MainFrame_jMenuFileExit_ActionAdapter implements ActionListener {
1635 MainFrame_jMenuFileExit_ActionAdapter(MainFrame adaptee) {
1636 this.adaptee = adaptee;
1639 public void actionPerformed(ActionEvent actionEvent) {
1640 adaptee.jMenuFileExit_actionPerformed(actionEvent);
1644 class MainFrame_jMenuHelpAbout_ActionAdapter implements ActionListener {
1648 MainFrame_jMenuHelpAbout_ActionAdapter(MainFrame adaptee) {
1649 this.adaptee = adaptee;
1652 public void actionPerformed(ActionEvent actionEvent) {
1653 adaptee.jMenuHelpAbout_actionPerformed(actionEvent);