3 import java.io.IOException;
4 import saccubus.converter.Converter;
5 import java.awt.BorderLayout;
6 import java.awt.Dimension;
7 import java.awt.GridBagConstraints;
8 import java.awt.GridBagLayout;
9 import java.awt.GridLayout;
10 import java.awt.Image;
11 import java.awt.Insets;
12 import java.awt.Toolkit;
13 import java.awt.dnd.DnDConstants;
14 import java.awt.dnd.DropTarget;
15 import java.awt.event.ActionEvent;
16 import java.awt.event.ActionListener;
17 import java.awt.event.KeyEvent;
18 import java.awt.event.WindowAdapter;
19 import java.awt.event.WindowEvent;
21 import java.util.logging.Level;
22 import java.util.logging.Logger;
23 import javax.swing.BorderFactory;
24 import javax.swing.ButtonGroup;
25 import javax.swing.GroupLayout;
26 import javax.swing.JButton;
27 import javax.swing.JCheckBox;
28 import javax.swing.JComboBox;
29 import javax.swing.JFileChooser;
30 import javax.swing.JFrame;
31 import javax.swing.JLabel;
32 import javax.swing.JMenu;
33 import javax.swing.JMenuBar;
34 import javax.swing.JMenuItem;
35 import javax.swing.JOptionPane;
36 import javax.swing.JPanel;
37 import javax.swing.JPasswordField;
38 import javax.swing.JRadioButton;
39 import javax.swing.JTabbedPane;
40 import javax.swing.JTextField;
41 import javax.swing.LayoutStyle.ComponentPlacement;
42 import javax.swing.SwingUtilities;
43 import nicobrowser.entity.NicoContent;
44 import nicobrowser.main.Main;
45 import org.apache.commons.lang.StringUtils;
46 import saccubus.ConvertStopFlag.State;
47 import saccubus.converter.profile.FfmpegOption;
48 import saccubus.converter.profile.NgSetting;
49 import saccubus.net.TextProgressListener;
50 import saccubus.properties.BasicSetting;
51 import saccubus.properties.ConvertSetting;
52 import saccubus.properties.InputCommentSetting;
53 import saccubus.properties.InputVideoSetting;
54 import saccubus.properties.SProperties;
55 import saccubus.properties.InputTcommentSetting;
56 import saccubus.properties.MovieSetting;
57 import saccubus.properties.OutputVideoSetting;
58 import saccubus.util.FileDropTarget;
59 import saccubus.util.PopupRightClick;
60 import yukihane.nicovideo.NicoDBFinder;
68 * 説明: ニコニコ動画の動画をコメントつきで保存
72 * 著作権: Copyright (c) 2007 PSI
82 public class MainFrame extends JFrame {
84 private static final long serialVersionUID = 2564486741331062989L;
85 public static final String PRODUCT_NAME = "いんきゅばす";
86 public static final String VERSION = "1.7.1 (NicoBrowser" + Main.VERSION + ")";
87 public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
89 // TODO GUIが無いためフィールドに保持.
92 BorderLayout borderLayout1 = new BorderLayout();
93 JMenuBar jMenuBar1 = new JMenuBar();
94 JMenu jMenuFile = new JMenu();
95 JMenuItem jMenuFileExit = new JMenuItem();
96 JMenu jMenuHelp = new JMenu();
97 JMenuItem jMenuHelpAbout = new JMenuItem();
98 JLabel statusBar = new JLabel();
99 JTabbedPane mainTabbedPane = new JTabbedPane();
100 JPanel SavingInfoTabPanel = new JPanel();
101 JPanel FFMpegTabPanel = new JPanel();
103 private JPanel videoInfoPanel = new JPanel();
104 private JPanel opPanel = new JPanel();
105 private JLabel videoIdLabel = new JLabel();
106 private JTextField videoIdField = new JTextField();
107 private JLabel wayBackLabel = new JLabel();
108 private JTextField wayBackField = new JTextField();
109 JButton DoButton = new JButton();
110 public static final String DoButtonDefString = "変換";
111 public static final String DoButtonStopString = "停止";
112 public static final String DoButtonWaitString = "待機";
113 JPanel UserInfoPanel = new JPanel();
114 GridBagLayout gridBagLayout3 = new GridBagLayout();
116 JLabel mailAddressLabel = new JLabel();
117 JTextField mailAddressField = new JTextField();
118 JLabel passwordLabel = new JLabel();
119 JPasswordField passwordField = new JPasswordField();
120 GridBagLayout gridBagLayout4 = new GridBagLayout();
121 GridBagLayout gridBagLayout6 = new GridBagLayout();
122 ButtonGroup CommentSaveButtonGroup = new ButtonGroup();
123 ButtonGroup ConvSaveButtonGroup = new ButtonGroup();
125 private class FfmpegOptionCheckBoxListener implements ActionListener{
128 public void actionPerformed(ActionEvent e) {
129 setFFMpegOptionCheckbox();
132 private final FfmpegOptionCheckBoxListener ffmpegOptionCheckBoxListener = new FfmpegOptionCheckBoxListener();
134 private void setFFMpegOptionCheckbox() {
135 boolean resizable = (resizeCheckBox.isEnabled() && resizeCheckBox.isSelected());
136 resizeWidthField.setEnabled(resizable);
137 resizeHeigitField.setEnabled(resizable);
138 adjustRatioCheckBox.setEnabled(resizable);
142 private void setNames() {
143 mainTabbedPane.setName("mainTabbedPane");
145 mailAddressField.setName("mailAddressField");
146 passwordField.setName("passwordField");
148 ffmpegPathField.setName("ffmpegPathField");
149 vhookPathField.setName("vhookPathField");
151 mainOptionField.setName("mainOptionField");
152 inputOptionField.setName("inputOptionField");
153 outputOptionField.setName("outputOptionField");
155 fontPathField.setName("fontPathField");
156 fontIndexField.setName("fontIndexField");
157 showConvVideoCheckBox.setName("showConvVideoCheckBox");
163 videoSaveInfoPanel = savePanel.getVideoSaveInfoPanel();
166 setDefaultCloseOperation(EXIT_ON_CLOSE);
170 SProperties setting = SProperties.loadSetting(null,
172 this.setSetting(setting);
173 } catch (Exception exception) {
174 exception.printStackTrace();
181 * @throws java.lang.Exception
183 private void jbInit() throws Exception {
184 GridBagConstraints gridBagConstraints74 = new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
185 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
186 gridBagConstraints74.gridwidth = 2;
187 GridBagConstraints gridBagConstraints73 = new GridBagConstraints();
188 gridBagConstraints73.fill = GridBagConstraints.HORIZONTAL;
189 gridBagConstraints73.gridy = 6;
190 gridBagConstraints73.weightx = 1.0;
191 gridBagConstraints73.gridwidth = 4;
192 gridBagConstraints73.insets = new Insets(0, 0, 0, 5);
193 gridBagConstraints73.gridx = 1;
194 GridBagConstraints gridBagConstraints72 = new GridBagConstraints();
195 gridBagConstraints72.gridx = 0;
196 gridBagConstraints72.anchor = GridBagConstraints.WEST;
197 gridBagConstraints72.insets = new Insets(0, 5, 0, 5);
198 gridBagConstraints72.fill = GridBagConstraints.NONE;
199 gridBagConstraints72.gridwidth = 1;
200 gridBagConstraints72.gridy = 6;
201 ShadowKindLabel = new JLabel();
202 ShadowKindLabel.setText("影の種類");
203 ShadowKindLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
204 GridBagConstraints gridBagConstraints71 = new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
205 GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 6);
206 gridBagConstraints71.fill = GridBagConstraints.BOTH;
207 gridBagConstraints71.ipady = 0;
208 GridBagConstraints gridBagConstraints70 = new GridBagConstraints();
209 gridBagConstraints70.fill = GridBagConstraints.HORIZONTAL;
210 gridBagConstraints70.gridy = 1;
211 gridBagConstraints70.ipadx = 0;
212 gridBagConstraints70.ipady = 0;
213 gridBagConstraints70.weightx = 1.0;
214 gridBagConstraints70.insets = new Insets(0, 0, 0, 0);
215 gridBagConstraints70.gridx = 1;
216 GridBagConstraints gridBagConstraints69 = new GridBagConstraints();
217 gridBagConstraints69.gridx = 0;
218 gridBagConstraints69.ipadx = 0;
219 gridBagConstraints69.ipady = 0;
220 gridBagConstraints69.insets = new Insets(0, 5, 0, 5);
221 gridBagConstraints69.anchor = GridBagConstraints.WEST;
222 gridBagConstraints69.gridy = 1;
223 GridBagConstraints gridBagConstraints68 = new GridBagConstraints();
224 gridBagConstraints68.fill = GridBagConstraints.BOTH;
225 gridBagConstraints68.gridy = 0;
226 gridBagConstraints68.ipady = 0;
227 gridBagConstraints68.weightx = 1.0;
228 gridBagConstraints68.insets = new Insets(0, 0, 0, 0);
229 gridBagConstraints68.gridx = 1;
230 GridBagConstraints gridBagConstraints67 = new GridBagConstraints();
231 gridBagConstraints67.gridx = 0;
232 gridBagConstraints67.ipadx = 0;
233 gridBagConstraints67.ipady = 0;
234 gridBagConstraints67.insets = new Insets(0, 5, 0, 5);
235 gridBagConstraints67.anchor = GridBagConstraints.WEST;
236 gridBagConstraints67.gridy = 0;
237 GridBagConstraints gridBagConstraints66 = new GridBagConstraints();
238 gridBagConstraints66.gridx = 0;
239 gridBagConstraints66.insets = new Insets(0, 5, 5, 5);
240 gridBagConstraints66.anchor = GridBagConstraints.WEST;
241 gridBagConstraints66.gridwidth = 2;
242 gridBagConstraints66.gridy = 1;
243 ViewCommentLabel = new JLabel();
244 ViewCommentLabel.setText("表示コメント数");
245 GridBagConstraints gridBagConstraints65 = new GridBagConstraints();
246 gridBagConstraints65.fill = GridBagConstraints.HORIZONTAL;
247 gridBagConstraints65.gridy = 1;
248 gridBagConstraints65.weightx = 1.0;
249 gridBagConstraints65.gridwidth = 6;
250 gridBagConstraints65.insets = new Insets(0, 5, 5, 5);
251 gridBagConstraints65.gridx = 3;
252 GridBagConstraints gridBagConstraints64 = new GridBagConstraints(1, 1,
253 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
254 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
255 gridBagConstraints64.gridy = 3;
256 gridBagConstraints64.fill = GridBagConstraints.HORIZONTAL;
257 gridBagConstraints64.gridx = 4;
258 GridBagConstraints gridBagConstraints63 = new GridBagConstraints(0, 4,
259 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
260 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
261 gridBagConstraints63.gridy = 7;
262 gridBagConstraints63.gridx = 0;
263 gridBagConstraints63.gridwidth = 5;
264 GridBagConstraints gridBagConstraints62 = new GridBagConstraints(0, 3,
265 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
266 GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0);
267 gridBagConstraints62.gridy = 5;
268 gridBagConstraints62.gridx = 1;
269 gridBagConstraints62.fill = GridBagConstraints.HORIZONTAL;
270 gridBagConstraints62.insets = new Insets(0, 0, 5, 5);
271 gridBagConstraints62.gridwidth = 4;
272 GridBagConstraints gridBagConstraints61 = new GridBagConstraints(0, 2,
273 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
274 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
275 gridBagConstraints61.gridy = 5;
276 gridBagConstraints61.gridx = 0;
277 gridBagConstraints61.fill = GridBagConstraints.VERTICAL;
278 gridBagConstraints61.anchor = GridBagConstraints.WEST;
279 gridBagConstraints61.gridwidth = 1;
280 GridBagConstraints gridBagConstraints60 = new GridBagConstraints(0, 1,
281 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
282 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0);
283 gridBagConstraints60.gridy = 3;
284 gridBagConstraints60.gridx = 1;
285 gridBagConstraints60.fill = GridBagConstraints.HORIZONTAL;
286 gridBagConstraints60.insets = new Insets(0, 0, 0, 5);
287 gridBagConstraints60.gridwidth = 3;
288 GridBagConstraints gridBagConstraints59 = new GridBagConstraints(0, 0,
289 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
290 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0);
291 gridBagConstraints59.gridy = 3;
292 gridBagConstraints59.insets = new Insets(5, 5, 5, 5);
293 gridBagConstraints59.gridx = 0;
294 gridBagConstraints59.fill = GridBagConstraints.NONE;
295 gridBagConstraints59.anchor = GridBagConstraints.WEST;
296 gridBagConstraints59.weightx = 0.0;
297 gridBagConstraints59.gridwidth = 1;
298 GridBagConstraints gridBagConstraints58 = new GridBagConstraints();
299 gridBagConstraints58.gridx = 0;
300 gridBagConstraints58.anchor = GridBagConstraints.WEST;
301 gridBagConstraints58.insets = new Insets(0, 5, 5, 5);
302 gridBagConstraints58.gridwidth = 5;
303 gridBagConstraints58.weightx = 1.0;
304 gridBagConstraints58.fill = GridBagConstraints.HORIZONTAL;
305 gridBagConstraints58.gridy = 0;
307 GridBagConstraints gridBagConstraints54 = new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
308 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
309 gridBagConstraints54.gridwidth = 3;
311 GridBagConstraints gridBagConstraints33 = new GridBagConstraints();
312 gridBagConstraints33.gridx = 0;
313 gridBagConstraints33.fill = GridBagConstraints.HORIZONTAL;
314 gridBagConstraints33.weightx = 1.0;
315 gridBagConstraints33.insets = new Insets(0, 5, 5, 5);
316 gridBagConstraints33.gridwidth = 5;
317 gridBagConstraints33.gridy = 9;
319 GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
320 gridBagConstraints14.gridx = 0;
321 gridBagConstraints14.anchor = GridBagConstraints.WEST;
322 gridBagConstraints14.fill = GridBagConstraints.HORIZONTAL;
323 gridBagConstraints14.weightx = 1.0;
324 gridBagConstraints14.gridwidth = 5;
325 gridBagConstraints14.insets = new Insets(0, 5, 0, 5);
326 gridBagConstraints14.gridy = 8;
327 GridBagConstraints gridBagConstraints7 = new GridBagConstraints(0, 0,
328 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
329 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
330 gridBagConstraints7.weighty = 0.0;
331 GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
332 gridBagConstraints6.gridx = 0;
333 gridBagConstraints6.weighty = 1.0;
334 gridBagConstraints6.weightx = 1.0;
335 gridBagConstraints6.insets = new Insets(0, 5, 0, 5);
336 gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL;
337 gridBagConstraints6.anchor = GridBagConstraints.NORTH;
338 gridBagConstraints6.gridy = 1;
339 GridBagConstraints gridBagConstraints1 = new GridBagConstraints(0, 1,
340 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
341 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
342 gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
343 gridBagConstraints1.anchor = GridBagConstraints.NORTH;
344 gridBagConstraints1.weighty = 1.0;
346 this.setIconImage(WinIcon);
347 contentPane = (JPanel) this.getContentPane();
348 contentPane.setLayout(borderLayout1);
349 setSize(new Dimension(400, 450));
350 setTitle(PRODUCT_NAME + " " + VERSION);
351 this.addWindowListener(new MainFrame_this_windowAdapter(this));
352 statusBar.setText(" ");
353 jMenuFile.setText("ファイル");
354 jMenuFileExit.setText("終了");
355 jMenuFileExit.addActionListener(new MainFrame_jMenuFileExit_ActionAdapter(
357 jMenuHelp.setText("ヘルプ");
358 jMenuHelpAbout.setText("バージョン情報");
359 jMenuHelpAbout.addActionListener(new MainFrame_jMenuHelpAbout_ActionAdapter(
361 videoInfoPanel.setLayout(gridBagLayout1);
362 DoButton.setText(DoButtonDefString);
363 DoButton.addActionListener(new MainFrame_DoButton_actionAdapter(this));
364 SavingInfoTabPanel.setLayout(new GridLayout());
365 UserInfoPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "ユーザ設定"));
366 UserInfoPanel.setLayout(gridBagLayout3);
367 mailAddressLabel.setText("メールアドレス");
368 passwordLabel.setText("パスワード");
370 setListenerToSavePanelButton();
372 FFMpegTabPanel.setLayout(gridBagLayout6);
373 PathSettingPanel.setBorder(BorderFactory.createTitledBorder(
374 BorderFactory.createEtchedBorder(), "プログラムの位置の設定"));
375 PathSettingPanel.setLayout(gridBagLayout7);
376 FFmpegPathLabel.setText("FFmpeg");
377 SettingFFmpegPathButton.setText("参照");
378 SettingFFmpegPathButton.addActionListener(new MainFrame_SettingFFmpegPathButton_actionAdapter(
380 VhookPathLabel.setText("拡張vhookライブラリ");
381 SettingVhookPathButton.setText("参照");
382 SettingVhookPathButton.addActionListener(new MainFrame_SettingVhookPathButton_actionAdapter(
384 VhookSettingPanel.setLayout(gridBagLayout8);
385 VhookSettingPanel.setBorder(BorderFactory.createTitledBorder(
386 BorderFactory.createEtchedBorder(), "拡張vhookライブラリの設定"));
387 FFmpegSettingPanel.setBorder(BorderFactory.createTitledBorder(
388 BorderFactory.createEtchedBorder(), "FFmpegの設定"));
389 FFmpegSettingPanel.setLayout(gblFFmpegSettingPanel);
390 FontPathLabel.setText("フォントパス");
391 SettingFontPathButton.setText("参照");
392 SettingFontPathButton.addActionListener(new MainFrame_SettingFontPathButton_actionAdapter(
394 showConvVideoCheckBox.setText("変換中の画像を表示する");
396 extOptionLabel.setText("出力動画の拡張子");
397 inputOptionLabel.setText("入力オプション");
398 outputOptionLabel.setText("出力オプション");
399 mainOptionLabel.setText("メインオプション");
400 avfilterOptionLabel.setText("avfilterオプション");
402 FontIndexLabel.setText("フォント番号");
404 BasicInfoTabPanel.setLayout(gridBagLayout12);
405 jMenuBar1.add(jMenuFile);
406 jMenuFile.add(jMenuFileExit);
407 jMenuBar1.add(jMenuHelp);
408 jMenuHelp.add(jMenuHelpAbout);
409 setJMenuBar(jMenuBar1);
411 contentPane.add(statusBar, BorderLayout.SOUTH);
412 contentPane.add(mainTabbedPane, java.awt.BorderLayout.CENTER);
413 contentPane.add(videoInfoPanel, java.awt.BorderLayout.NORTH);
414 UserInfoPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1,
415 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
416 new Insets(0, 5, 5, 5), 0, 0));
417 UserInfoPanel.add(mailAddressField, new GridBagConstraints(1, 0, 1, 1,
418 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
419 new Insets(0, 5, 5, 5), 0, 0));
420 UserInfoPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1,
421 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
422 new Insets(0, 5, 5, 0), 0, 0));
423 UserInfoPanel.add(mailAddressLabel, new GridBagConstraints(0, 0, 1, 1,
424 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
425 new Insets(0, 5, 5, 0), 0, 0));
426 PathSettingPanel.add(ffmpegPathField, new GridBagConstraints(0, 1, 1,
427 1, 1.0, 0.0, GridBagConstraints.CENTER,
428 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));
429 PathSettingPanel.add(SettingFFmpegPathButton, gridBagConstraints74);
430 PathSettingPanel.add(FFmpegPathLabel, new GridBagConstraints(0, 0, 2,
431 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
432 new Insets(0, 5, 5, 5), 0, 0));
433 PathSettingPanel.add(vhookPathField, new GridBagConstraints(0, 3, 1, 1,
434 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
435 new Insets(0, 5, 5, 5), 0, 0));
436 PathSettingPanel.add(SettingVhookPathButton, new GridBagConstraints(1,
437 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
438 GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
439 PathSettingPanel.add(VhookPathLabel, gridBagConstraints54);
442 final GroupLayout layout = new GroupLayout(FFmpegSettingPanel);
443 FFmpegSettingPanel.setLayout(layout);
445 layout.setHorizontalGroup(layout.createParallelGroup()
446 .addComponent(getFFmpegOptionComboBoxPanel())
447 .addGroup(layout.createSequentialGroup()
448 .addGroup(layout.createParallelGroup()
449 .addComponent(extOptionLabel)
450 .addComponent(mainOptionLabel)
451 .addComponent(inputOptionLabel)
452 .addComponent(outputOptionLabel)
453 .addComponent(avfilterOptionLabel)
455 .addPreferredGap(ComponentPlacement.RELATED)
456 .addGroup(layout.createParallelGroup()
457 .addComponent(extOptionField)
458 .addComponent(mainOptionField)
459 .addComponent(inputOptionField)
460 .addComponent(outputOptionField)
461 .addComponent(avfilterOptionField)
464 .addGroup(layout.createParallelGroup()
465 .addGroup(layout.createSequentialGroup()
466 .addComponent(resizeCheckBox)
467 .addPreferredGap(ComponentPlacement.UNRELATED)
468 .addComponent(resizeWidthLabel)
469 .addPreferredGap(ComponentPlacement.RELATED)
470 .addComponent(resizeWidthField)
471 .addPreferredGap(ComponentPlacement.UNRELATED)
472 .addComponent(resizeHeightLabel)
473 .addPreferredGap(ComponentPlacement.RELATED)
474 .addComponent(resizeHeigitField)
477 .addGroup(layout.createSequentialGroup()
479 .addComponent(adjustRatioCheckBox))
480 .addGroup(layout.createSequentialGroup()
485 layout.setVerticalGroup(layout.createSequentialGroup()
486 .addComponent(getFFmpegOptionComboBoxPanel())
487 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
488 .addComponent(extOptionLabel)
489 .addComponent(extOptionField))
490 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
491 .addComponent(mainOptionLabel)
492 .addComponent(mainOptionField))
493 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
494 .addComponent(inputOptionLabel)
495 .addComponent(inputOptionField))
496 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
497 .addComponent(outputOptionLabel)
498 .addComponent(outputOptionField))
499 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
500 .addComponent(avfilterOptionLabel)
501 .addComponent(avfilterOptionField))
502 .addGroup(layout.createSequentialGroup()
503 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
504 .addComponent(resizeCheckBox)
505 .addComponent(resizeWidthLabel)
506 .addComponent(resizeWidthField)
507 .addComponent(resizeHeightLabel)
508 .addComponent(resizeHeigitField))
509 .addComponent(adjustRatioCheckBox)
513 resizeCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
514 adjustRatioCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
515 setFFMpegOptionCheckbox();
518 videoInfoPanel.add(DoButton, gridBagConstraints71);
520 videoIdLabel.setText("URL/ID");
521 wayBackLabel.setText("過去ログ");
522 videoIdField.setText("http://www.nicovideo.jp/watch/");
524 opPanel.setLayout(new GridBagLayout());
526 videoInfoPanel.add(opPanel, new GridBagConstraints(0, 0, 1, 1, 1.0,
527 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
528 new Insets(0, 0, 0, 0), 0, 0));
529 opPanel.add(videoIdLabel, gridBagConstraints67);
530 opPanel.add(videoIdField, gridBagConstraints68);
531 opPanel.add(wayBackLabel, gridBagConstraints69);
532 opPanel.add(wayBackField, gridBagConstraints70);
534 mainTabbedPane.add(BasicInfoTabPanel, "基本設定");
535 mainTabbedPane.add(SavingInfoTabPanel, "保存設定");
536 mainTabbedPane.add(FFMpegTabPanel, "動画設定");
537 mainTabbedPane.addTab("変換設定", null, getConvertingSettingPanel(), null);
538 SavingInfoTabPanel.add(savePanel);
539 BasicInfoTabPanel.add(UserInfoPanel, gridBagConstraints7);
540 BasicInfoTabPanel.add(getProxyInfoPanel(), gridBagConstraints6);
541 VhookSettingPanel.add(FontPathLabel, gridBagConstraints59);
542 VhookSettingPanel.add(showConvVideoCheckBox, gridBagConstraints63);
543 VhookSettingPanel.add(fontPathField, gridBagConstraints60);
544 VhookSettingPanel.add(fontIndexField, gridBagConstraints62);
545 VhookSettingPanel.add(FontIndexLabel, gridBagConstraints61);
546 VhookSettingPanel.add(SettingFontPathButton, gridBagConstraints64);
547 VhookSettingPanel.add(getFixFontSizeCheckBox(), gridBagConstraints14);
548 VhookSettingPanel.add(getOpaqueCommentCheckBox(), gridBagConstraints33);
549 VhookSettingPanel.add(getNotUseVhookCheckBox(), gridBagConstraints58);
550 VhookSettingPanel.add(getViewCommentField(), gridBagConstraints65);
551 VhookSettingPanel.add(ViewCommentLabel, gridBagConstraints66);
552 VhookSettingPanel.add(ShadowKindLabel, gridBagConstraints72);
553 VhookSettingPanel.add(getShadowComboBox(), gridBagConstraints73);
555 FFMpegTabPanel.add(PathSettingPanel, new GridBagConstraints(0, 0, 1, 1,
556 1.0, 0.0, GridBagConstraints.NORTHEAST,
557 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
558 FFMpegTabPanel.add(FFmpegSettingPanel, gridBagConstraints1);
562 * 保存設定パネル内のボタンにアクションリスナを割り当てる.
564 private void setListenerToSavePanelButton() {
566 al = new InputVideoPanelButtonListener();
567 videoSaveInfoPanel.getShowSavingVideoFolderDialogButton().addActionListener(al);
568 videoSaveInfoPanel.getShowSavingVideoFileDialogButton().addActionListener(al);
569 videoSaveInfoPanel.getNibrFileChooserButton().addActionListener(al);
571 al = new VideoUseRadioButtonListener();
572 videoSaveInfoPanel.getVideoNoSaveButton().addActionListener(al);
573 videoSaveInfoPanel.getVideoSaveButton().addActionListener(al);
574 videoSaveInfoPanel.getVideoUseNiBrButton().addActionListener(al);
576 al = new InputCommentPanelButtonListener();
577 savePanel.getShowSavingCommentFolderDialogButton().addActionListener(al);
578 savePanel.getShowSavingCommentFileDialogButton().addActionListener(al);
580 al = new OutputVideoPanelButtonListener();
581 savePanel.getShowSavingConvertedVideoFolderDialogButton().addActionListener(al);
582 savePanel.getShowSavingConvertedVideoFileDialogButton().addActionListener(al);
585 private void setPopup() {
586 mainOptionField.addMouseListener(new PopupRightClick(
587 this.mainOptionField));
588 inputOptionField.addMouseListener(new PopupRightClick(
589 this.inputOptionField));
590 outputOptionField.addMouseListener(new PopupRightClick(
591 this.outputOptionField));
592 savePanel.getCommentNumField().addMouseListener(new PopupRightClick(
593 savePanel.getCommentNumField()));
595 savePanel.getCommentSavedFileField().addMouseListener(new PopupRightClick(
596 savePanel.getCommentSavedFileField()));
597 savePanel.getCommentSavedFolderField().addMouseListener(new PopupRightClick(
598 savePanel.getCommentSavedFolderField()));
600 savePanel.getConvertedVideoSavedFileField().addMouseListener(new PopupRightClick(
601 savePanel.getConvertedVideoSavedFileField()));
602 savePanel.getConvertedVideoSavedFolderField().addMouseListener(new PopupRightClick(
603 savePanel.getConvertedVideoSavedFolderField()));
605 videoSaveInfoPanel.getVideoSavedFileField().addMouseListener(new PopupRightClick(
606 videoSaveInfoPanel.getVideoSavedFileField()));
607 videoSaveInfoPanel.getVideoSavedFolderField().addMouseListener(new PopupRightClick(
608 videoSaveInfoPanel.getVideoSavedFolderField()));
609 videoSaveInfoPanel.getNibrFileField().addMouseListener(
610 new PopupRightClick(videoSaveInfoPanel.getNibrFileField()));
612 ffmpegPathField.addMouseListener(new PopupRightClick(
613 this.ffmpegPathField));
614 vhookPathField.addMouseListener(new PopupRightClick(this.vhookPathField));
615 videoIdField.addMouseListener(new PopupRightClick(
617 viewCommentField.addMouseListener(new PopupRightClick(
618 this.viewCommentField));
619 fontPathField.addMouseListener(new PopupRightClick(this.fontPathField));
620 mailAddressField.addMouseListener(new PopupRightClick(this.mailAddressField));
621 passwordField.addMouseListener(new PopupRightClick(this.passwordField));
622 wayBackField.addMouseListener(new PopupRightClick(this.wayBackField));
624 proxyTextField.addMouseListener(new PopupRightClick(this.proxyTextField));
625 proxyPortTextField.addMouseListener(new PopupRightClick(
626 this.proxyPortTextField));
628 fontIndexField.addMouseListener(new PopupRightClick(this.fontIndexField));
630 ngWordTextField.addMouseListener(new PopupRightClick(
631 this.ngWordTextField));
632 ngIdTextField.addMouseListener(new PopupRightClick(this.ngIdTextField));
635 private void setDropTarget() {
636 addTarget(videoSaveInfoPanel.getVideoSavedFileField(), false);
637 addTarget(videoSaveInfoPanel.getVideoSavedFolderField(), true);
638 addTarget(videoSaveInfoPanel.getNibrFileField(), false);
640 addTarget(savePanel.getCommentSavedFileField(), false);
641 addTarget(savePanel.getCommentSavedFolderField(), true);
643 addTarget(savePanel.getConvertedVideoSavedFileField(), false);
644 addTarget(savePanel.getConvertedVideoSavedFolderField(), true);
646 addTarget(ffmpegPathField, false);
647 addTarget(vhookPathField, false);
648 addTarget(fontPathField, false);
653 * テキストフィールドに対しドロップを行った場合にファイルもしくはディレクトリの文字列を設定できるようにする.
654 * @param c 設定対象のテキストフィールドオブジェクト.
655 * @param isDir ディレクトリを設定する場合はtrue, ファイルの場合はfalse.
656 * @return ドロップターゲット(用途無し).
658 private DropTarget addTarget(JTextField c, boolean isDir) {
659 return new DropTarget(c, DnDConstants.ACTION_COPY, new FileDropTarget(
662 private File CurrentDir = new File(".");
663 private JPanel PathSettingPanel = new JPanel();
664 private JLabel FFmpegPathLabel = new JLabel();
665 private GridBagLayout gridBagLayout7 = new GridBagLayout();
666 private JTextField ffmpegPathField = new JTextField();
667 private JButton SettingFFmpegPathButton = new JButton();
668 private JLabel VhookPathLabel = new JLabel();
669 private JTextField vhookPathField = new JTextField();
670 private JButton SettingVhookPathButton = new JButton();
671 private JPanel VhookSettingPanel = new JPanel();
672 private GridBagLayout gridBagLayout8 = new GridBagLayout();
673 private JPanel FFmpegSettingPanel = new JPanel();
674 private GridBagLayout gblFFmpegSettingPanel = new GridBagLayout();
675 private JLabel FontPathLabel = new JLabel();
676 private JTextField fontPathField = new JTextField();
677 private JButton SettingFontPathButton = new JButton();
678 private JCheckBox showConvVideoCheckBox = new JCheckBox();
680 private void showSaveDialog(String title, JTextField field, boolean isSave,
682 JFileChooser chooser = new JFileChooser(CurrentDir);
683 chooser.setDialogTitle(title);
686 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
689 code = chooser.showSaveDialog(this);
691 code = chooser.showOpenDialog(this);
693 if (code == JFileChooser.APPROVE_OPTION) {
695 CurrentDir = chooser.getSelectedFile();
696 field.setText(CurrentDir.getAbsolutePath());
698 File selected = chooser.getSelectedFile();
699 CurrentDir = chooser.getCurrentDirectory();
700 field.setText(selected.getAbsolutePath());
705 private SProperties getSetting() {
706 SProperties setting = new SProperties(
708 getInputVideoSetting(),
709 getInputCommentSetting(),
710 getTcommentSetting(),
711 getOutputVideoSetting(),
713 getConvertSetting());
719 * @param setting 反映する設定.
721 private void setSetting(SProperties setting) {
723 final BasicSetting basic = setting.getBasicSetting();
724 tempDir = basic.getTempDir();
725 mailAddressField.setText(basic.getUser().getMail());
726 passwordField.setText(basic.getUser().getPassword());
728 useProxyCheckBox.setSelected(basic.isProxyUse());
729 proxyTextField.setText(basic.getProxyHost());
730 int proxy_port = basic.getProxyPort();
731 if (proxy_port >= 0 && proxy_port <= 65535) {
732 proxyPortTextField.setText(Integer.toString(proxy_port));
734 proxyPortTextField.setText("");
738 final InputVideoSetting inVideo = setting.getInputVideoSetting();
739 JRadioButton activeButton;
740 switch (inVideo.getProcessKind()) {
742 activeButton = videoSaveInfoPanel.getVideoNoSaveButton();
745 activeButton = videoSaveInfoPanel.getVideoUseNiBrButton();
749 activeButton = videoSaveInfoPanel.getVideoSaveButton();
752 activeButton.doClick();
754 videoSaveInfoPanel.getVideoSavedFileField().setText(inVideo.getFile().getPath());
755 videoSaveInfoPanel.getVideoSavedFolderField().setText(inVideo.getFolder().getPath());
756 videoSaveInfoPanel.getDelVideoCheckBox().setSelected(inVideo.isDeleteAfterConvert());
757 final boolean videoFixName = inVideo.isAutoNaming();
758 videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
759 videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
760 videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath());
763 final InputCommentSetting inputComment = setting.getInputCommentSetting();
764 savePanel.getSavingCommentCheckBox().setSelected(inputComment.getProcessKind());
765 savePanel.getCommentSavedFileField().setText(inputComment.getFile().getPath());
766 savePanel.getDelCommentCheckBox().setSelected(inputComment.isDeleteAfterConvert());
767 savePanel.getCommentSavedFolderField().setText(inputComment.getFolder().getPath());
768 savePanel.getCommentNumField().setText(Integer.toString(inputComment.getNumOfComment()));
769 savePanel.getFixCommentNumCheckBox().setSelected(inputComment.isSelfAdjustNumOfComment());
770 boolean commentFixName = inputComment.isAutoNaming();
771 savePanel.getCommentSaveFileRadioButton().setSelected(!commentFixName);
772 savePanel.getCommentSaveFolderRadioButton().setSelected(commentFixName);
775 InputTcommentSetting tcom = setting.getInputTcommentSetting();
776 savePanel.setTcommentDownload(tcom.getProcessKind());
777 savePanel.setTcommentDelete(tcom.isDeleteAfterConvert());
778 savePanel.setTcommentAutoFileName(tcom.isAutoNaming());
779 savePanel.setTcommentDirectoryName(tcom.getFolder().getPath());
780 savePanel.setTcommentFileName(tcom.getFile().getPath());
783 final OutputVideoSetting outputVideo = setting.getOutputVideoSetting();
784 savePanel.getSavingConvertedVideoCheckBox().setSelected(outputVideo.getProcessKind());
785 savePanel.getAddCommentCheckBox().setSelected(outputVideo.isAddComment());
786 savePanel.getAddTcommentCheckBox().setSelected(outputVideo.isAddTcomment());
787 savePanel.getConvertedVideoSavedFileField().setText(outputVideo.getFile().getPath());
788 savePanel.getConvertedVideoSavedFolderField().setText(outputVideo.getFolder().getPath());
789 savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(outputVideo.isCutIdName());
790 boolean convFixName = outputVideo.isAutoNaming();
791 savePanel.getConvSaveFileRadioButton().setSelected(!convFixName);
792 savePanel.getConvSaveFolderRadioButton().setSelected(convFixName);
795 final MovieSetting movie = setting.getMovieSetting();
796 ffmpegPathField.setText(movie.getFfmpeg().toString());
797 vhookPathField.setText(movie.getVhook().toString());
798 extOptionField.setText(movie.getFfmpegOption().getExtOption());
799 mainOptionField.setText(movie.getFfmpegOption().getMainOption());
800 inputOptionField.setText(movie.getFfmpegOption().getInOption());
801 outputOptionField.setText(movie.getFfmpegOption().getOutOption());
802 avfilterOptionField.setText(movie.getFfmpegOption().getAvfilterOption());
803 resizeCheckBox.setSelected(movie.getFfmpegOption().isResize());
804 resizeWidthField.setText(Integer.toString(movie.getFfmpegOption().getResizeWidth()));
805 resizeHeigitField.setText(Integer.toString(movie.getFfmpegOption().getResizeHeight()));
806 adjustRatioCheckBox.setSelected(movie.getFfmpegOption().isAdjustRatio());
807 FFmpegOptionModel.reload(movie.getOptionFile());
810 final ConvertSetting conv = setting.getConvertSetting();
811 disableVhookCheckBox.setSelected(conv.isVhookDisabled());
812 viewCommentField.setText(Integer.toString(conv.getMaxNumOfComment()));
813 fontPathField.setText(conv.getFont().toString());
814 fontIndexField.setText(Integer.toString(conv.getFontIndex()));
815 shadowComboBox.setSelectedIndex(conv.getShadowIndex());
816 showConvVideoCheckBox.setSelected(conv.isShowConverting());
817 fixFontSizeCheckBox.setSelected(conv.isSelfAdjustFontSize());
818 opaqueCommentCheckBox.setSelected(conv.isCommentOpaque());
819 ngWordTextField.setText(conv.getNgSetting().getWord());
820 ngIdTextField.setText(conv.getNgSetting().getId());
824 * [ファイル|終了] アクションが実行されました。
829 void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
831 SProperties setting = getSetting();
832 SProperties.saveSetting(setting);
833 } catch (Throwable t) {
834 Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "設定保存に失敗", t);
840 * [ヘルプ|バージョン情報] アクションが実行されました。
845 void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
846 MainFrame_AboutBox dlg = new MainFrame_AboutBox(this);
848 dlg.setLocationRelativeTo(this);
849 dlg.setVisible(true);
853 private Converter Converter = null;
855 private final JLabel extOptionLabel = new JLabel();
856 private final JTextField extOptionField = new JTextField();
857 private JLabel mainOptionLabel = new JLabel();
858 private JTextField mainOptionField = new JTextField();
859 private JLabel inputOptionLabel = new JLabel();
860 private JTextField inputOptionField = new JTextField();
861 private JLabel outputOptionLabel = new JLabel();
862 private JTextField outputOptionField = new JTextField();
863 private final JLabel avfilterOptionLabel = new JLabel();
864 private final JTextField avfilterOptionField = new JTextField();
865 private final JCheckBox resizeCheckBox = new JCheckBox("次のサイズに収まるよう縮小(-s)");
866 private final JLabel resizeWidthLabel = new JLabel("横");
867 private final JTextField resizeWidthField = new NumberFormattedTextField();
868 private final JLabel resizeHeightLabel = new JLabel("縦");
869 private final JTextField resizeHeigitField = new NumberFormattedTextField();
870 private final JCheckBox adjustRatioCheckBox = new JCheckBox("アスペクト比を維持");
872 private JLabel FontIndexLabel = new JLabel();
873 private JTextField fontIndexField = new JTextField();
874 private GridBagLayout gridBagLayout1 = new GridBagLayout();
875 private JPanel BasicInfoTabPanel = new JPanel();
876 private GridBagLayout gridBagLayout12 = new GridBagLayout();
877 private JPanel ConvertingSettingPanel = null;
878 private JPanel NGWordSettingPanel = null;
879 private JLabel NGWordLabel = null;
880 private JTextField ngWordTextField = null;
881 private JLabel NGIDLabel = null;
882 private JTextField ngIdTextField = null;
884 private JPanel ProxyInfoPanel = null;
885 private JCheckBox useProxyCheckBox = null;
886 private JLabel proxyLabel = null;
887 private JTextField proxyTextField = null;
888 private JLabel proxyPortLabel = null;
889 private JTextField proxyPortTextField = null;
891 private JCheckBox fixFontSizeCheckBox = null;
892 private JCheckBox opaqueCommentCheckBox = null;
893 private final SavePanel savePanel = new SavePanel();
894 private final VideoSaveInfoPanel videoSaveInfoPanel;
895 private JComboBox FFmpegOptionComboBox = null;
896 private JButton FFmpegOptionReloadButton = null;
897 private JPanel FFmpegOptionComboBoxPanel = null;
899 public void DoButton_actionPerformed(ActionEvent e) {
900 if (Converter == null || Converter.isConverted()) {
903 } catch (Exception ex) {
904 String text = ex.getMessage();
905 if (StringUtils.isEmpty(text)) {
906 text = "予期しないエラーのため中断しました。";
908 ex.printStackTrace();
909 statusBar.setText(text);
911 } else { /* 開始しているので、ストップする。 */
912 final ConvertStopFlag flag = Converter.getStopFlag();
913 if (!flag.needStop()) { /* まだストップしていない。 */
919 private void executeConvert() throws IOException {
922 // NicoBrowserファイルを利用する場合は、ファイル名からビデオIDを特定.
923 if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
925 String fileName = videoSaveInfoPanel.getNibrFileField().getText();
926 NicoDBFinder finder = NicoDBFinder.getInstance();
927 NicoContent info = finder.findNicoContent(fileName);
929 url = info.getNicoId();
933 } catch (Exception ex) {
934 JOptionPane.showMessageDialog(this, ex.getMessage(), "エラー", JOptionPane.ERROR_MESSAGE);
938 url = videoIdField.getText();
941 TextProgressListener sl = new TextProgressListener() {
943 public void setText(final String text) {
944 SwingUtilities.invokeLater(new Runnable() {
947 statusBar.setText(text);
953 ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
955 public void changeState(final State s) {
956 SwingUtilities.invokeLater(new Runnable() {
961 DoButton.setText(DoButtonWaitString);
964 DoButton.setText(DoButtonDefString);
971 Converter = new Converter(url, wayBackField.getText(), getSetting().toProfile(), sl,
972 new ConvertStopFlag(scl));
973 DoButton.setText(DoButtonStopString);
974 new Thread(Converter).start();
979 public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
980 showSaveDialog("FFmpegへのパス", ffmpegPathField, false, false);
983 public void SettingVhookPathButton_actionPerformed(ActionEvent e) {
984 showSaveDialog("拡張vhookライブラリへのパス", vhookPathField, false, false);
987 public void SettingFontPathButton_actionPerformed(ActionEvent e) {
988 showSaveDialog("フォントへのパス", fontPathField, false, false);
991 public void this_windowClosing(WindowEvent e) {
992 this.jMenuFileExit_actionPerformed(null);
996 * This method initializes ConvertingSettingPanel
998 * @return javax.swing.JPanel
1000 private JPanel getConvertingSettingPanel() {
1001 if (ConvertingSettingPanel == null) {
1002 GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
1003 gridBagConstraints11.weighty = 1.0;
1004 gridBagConstraints11.weightx = 1.0;
1005 gridBagConstraints11.insets = new Insets(0, 5, 0, 5);
1006 gridBagConstraints11.gridy = 1;
1007 gridBagConstraints11.gridx = 0;
1008 gridBagConstraints11.anchor = GridBagConstraints.NORTH;
1009 gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
1010 GridBagConstraints gridBagConstraints = new GridBagConstraints(0,
1011 2, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
1012 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
1013 gridBagConstraints.gridx = 0;
1014 gridBagConstraints.anchor = GridBagConstraints.CENTER;
1015 gridBagConstraints.weighty = 0.0;
1016 gridBagConstraints.gridy = 0;
1017 ConvertingSettingPanel = new JPanel();
1018 ConvertingSettingPanel.setLayout(new GridBagLayout());
1019 ConvertingSettingPanel.add(getNGWordSettingPanel(),
1020 gridBagConstraints11);
1021 ConvertingSettingPanel.add(VhookSettingPanel, gridBagConstraints);
1023 return ConvertingSettingPanel;
1027 * This method initializes NGWordSettingPanel
1029 * @return javax.swing.JPanel
1031 private JPanel getNGWordSettingPanel() {
1032 if (NGWordSettingPanel == null) {
1033 GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
1034 gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
1035 gridBagConstraints5.gridy = 1;
1036 gridBagConstraints5.weightx = 1.0;
1037 gridBagConstraints5.insets = new Insets(0, 5, 5, 5);
1038 gridBagConstraints5.gridx = 1;
1039 GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
1040 gridBagConstraints4.gridx = 0;
1041 gridBagConstraints4.anchor = GridBagConstraints.WEST;
1042 gridBagConstraints4.insets = new Insets(0, 5, 5, 0);
1043 gridBagConstraints4.gridy = 1;
1044 NGIDLabel = new JLabel();
1045 NGIDLabel.setText("NG ID");
1046 GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
1047 gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
1048 gridBagConstraints3.gridy = 0;
1049 gridBagConstraints3.weightx = 1.0;
1050 gridBagConstraints3.insets = new Insets(0, 5, 5, 5);
1051 gridBagConstraints3.gridx = 1;
1052 GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
1053 gridBagConstraints2.gridx = 0;
1054 gridBagConstraints2.insets = new Insets(0, 5, 5, 0);
1055 gridBagConstraints2.gridy = 0;
1056 NGWordLabel = new JLabel();
1057 NGWordLabel.setText("NGワード");
1058 NGWordSettingPanel = new JPanel();
1059 NGWordSettingPanel.setLayout(new GridBagLayout());
1060 NGWordSettingPanel.setBorder(BorderFactory.createTitledBorder(null,
1061 "NGワード・ID設定(半角スペース区切りで複数入力)"));
1062 NGWordSettingPanel.add(NGWordLabel, gridBagConstraints2);
1063 NGWordSettingPanel.add(getNGWordTextField(), gridBagConstraints3);
1064 NGWordSettingPanel.add(NGIDLabel, gridBagConstraints4);
1065 NGWordSettingPanel.add(getNGIDTextField(), gridBagConstraints5);
1067 return NGWordSettingPanel;
1071 * This method initializes NGWordTextField
1073 * @return javax.swing.JTextField
1075 private JTextField getNGWordTextField() {
1076 if (ngWordTextField == null) {
1077 ngWordTextField = new JTextField();
1078 ngWordTextField.setName("ngWordTextField");
1080 return ngWordTextField;
1084 * This method initializes NGIDTextField
1086 * @return javax.swing.JTextField
1088 private JTextField getNGIDTextField() {
1089 if (ngIdTextField == null) {
1090 ngIdTextField = new JTextField();
1091 ngIdTextField.setName("ngIdTextField");
1093 return ngIdTextField;
1097 * This method initializes ProxyInfoPanel
1099 * @return javax.swing.JPanel
1101 private JPanel getProxyInfoPanel() {
1102 if (ProxyInfoPanel == null) {
1103 GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
1104 gridBagConstraints13.gridx = 0;
1105 gridBagConstraints13.gridwidth = 2;
1106 gridBagConstraints13.weightx = 1.0;
1107 gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL;
1108 gridBagConstraints13.insets = new Insets(0, 5, 0, 5);
1109 gridBagConstraints13.gridy = 0;
1110 GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
1111 gridBagConstraints12.fill = GridBagConstraints.HORIZONTAL;
1112 gridBagConstraints12.gridy = 2;
1113 gridBagConstraints12.weightx = 1.0;
1114 gridBagConstraints12.insets = new Insets(5, 0, 5, 5);
1115 gridBagConstraints12.gridx = 1;
1116 GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
1117 gridBagConstraints10.gridx = 0;
1118 gridBagConstraints10.insets = new Insets(5, 5, 5, 5);
1119 gridBagConstraints10.gridy = 2;
1120 proxyPortLabel = new JLabel();
1121 proxyPortLabel.setText("ポート番号");
1122 GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
1123 gridBagConstraints9.fill = GridBagConstraints.BOTH;
1124 gridBagConstraints9.gridy = 1;
1125 gridBagConstraints9.weightx = 1.0;
1126 gridBagConstraints9.insets = new Insets(0, 0, 0, 5);
1127 gridBagConstraints9.gridx = 1;
1128 GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
1129 gridBagConstraints8.gridx = 0;
1130 gridBagConstraints8.insets = new Insets(0, 5, 0, 5);
1131 gridBagConstraints8.fill = GridBagConstraints.NONE;
1132 gridBagConstraints8.anchor = GridBagConstraints.EAST;
1133 gridBagConstraints8.gridy = 1;
1134 proxyLabel = new JLabel();
1135 proxyLabel.setText("プロキシ");
1136 ProxyInfoPanel = new JPanel();
1137 ProxyInfoPanel.setLayout(new GridBagLayout());
1138 ProxyInfoPanel.setBorder(BorderFactory.createTitledBorder(null,
1140 ProxyInfoPanel.add(proxyLabel, gridBagConstraints8);
1141 ProxyInfoPanel.add(getProxyTextField(), gridBagConstraints9);
1142 ProxyInfoPanel.add(proxyPortLabel, gridBagConstraints10);
1143 ProxyInfoPanel.add(getProxyPortTextField(), gridBagConstraints12);
1144 ProxyInfoPanel.add(getUseProxyCheckBox(), gridBagConstraints13);
1146 return ProxyInfoPanel;
1150 * This method initializes ProxyTextField
1152 * @return javax.swing.JTextField
1154 private JTextField getProxyTextField() {
1155 if (proxyTextField == null) {
1156 proxyTextField = new JTextField();
1157 proxyTextField.setName("proxyTextField");
1159 return proxyTextField;
1163 * This method initializes ProxyPortTextField
1165 * @return javax.swing.JTextField
1167 private JTextField getProxyPortTextField() {
1168 if (proxyPortTextField == null) {
1169 proxyPortTextField = new JTextField();
1170 proxyPortTextField.setName("proxyPortTextField");
1172 return proxyPortTextField;
1176 * This method initializes UseProxyCheckBox
1178 * @return javax.swing.JCheckBox
1180 private JCheckBox getUseProxyCheckBox() {
1181 if (useProxyCheckBox == null) {
1182 useProxyCheckBox = new JCheckBox();
1183 useProxyCheckBox.setText("プロキシを使う");
1184 useProxyCheckBox.setName("useProxyCheckBox");
1186 return useProxyCheckBox;
1190 * This method initializes FixFontSizeCheckBox
1192 * @return javax.swing.JCheckBox
1194 private JCheckBox getFixFontSizeCheckBox() {
1195 if (fixFontSizeCheckBox == null) {
1196 fixFontSizeCheckBox = new JCheckBox();
1197 fixFontSizeCheckBox.setText("フォントサイズを画面にあわせて自動調整する");
1198 fixFontSizeCheckBox.setName("fixFontSizeCheckBox");
1200 return fixFontSizeCheckBox;
1204 * This method initializes OpaqueCommentCheckBox
1206 * @return javax.swing.JCheckBox
1208 private JCheckBox getOpaqueCommentCheckBox() {
1209 if (opaqueCommentCheckBox == null) {
1210 opaqueCommentCheckBox = new JCheckBox();
1211 opaqueCommentCheckBox.setText("全てのコメントを不透明にする");
1212 opaqueCommentCheckBox.setName("opaqueCommentCheckBox");
1214 return opaqueCommentCheckBox;
1217 * This method initializes FFmpegOptionComboBox
1219 * @return javax.swing.JComboBox
1221 private final OptionComboBoxModel FFmpegOptionModel = new OptionComboBoxModel();
1222 private JCheckBox disableVhookCheckBox = null;
1223 private JTextField viewCommentField = null;
1224 private JLabel ViewCommentLabel = null;
1225 private JLabel ShadowKindLabel = null;
1226 private JComboBox shadowComboBox = null;
1228 private JComboBox getFFmpegOptionComboBox() {
1229 if (FFmpegOptionComboBox == null) {
1230 FFmpegOptionComboBox = new JComboBox(FFmpegOptionModel);
1231 FFmpegOptionComboBox.addActionListener(new java.awt.event.ActionListener() {
1233 public void actionPerformed(java.awt.event.ActionEvent e) {
1234 if (FFmpegOptionModel.isFile()) {// ファイル
1235 setFFMpegOptionEnabled(false);
1237 setFFMpegOptionEnabled(true);
1238 setFFMpegOptionCheckbox();
1242 private void setFFMpegOptionEnabled(boolean enable) {
1243 extOptionField.setEnabled(enable);
1244 mainOptionField.setEnabled(enable);
1245 inputOptionField.setEnabled(enable);
1246 outputOptionField.setEnabled(enable);
1247 avfilterOptionField.setEnabled(enable);
1248 resizeCheckBox.setEnabled(enable);
1249 resizeWidthField.setEnabled(enable);
1250 resizeHeigitField.setEditable(enable);
1251 adjustRatioCheckBox.setEnabled(enable);
1255 return FFmpegOptionComboBox;
1259 * This method initializes FFmpegOptionReloadButton
1261 * @return javax.swing.JButton
1263 private JButton getFFmpegOptionReloadButton() {
1264 if (FFmpegOptionReloadButton == null) {
1265 FFmpegOptionReloadButton = new JButton();
1266 FFmpegOptionReloadButton.setText("更新");
1267 FFmpegOptionReloadButton.addActionListener(new java.awt.event.ActionListener() {
1269 public void actionPerformed(java.awt.event.ActionEvent e) {
1270 FFmpegOptionModel.reload();
1274 return FFmpegOptionReloadButton;
1278 * This method initializes FFmpegOptionComboBoxPanel
1280 * @return javax.swing.JPanel
1282 private JPanel getFFmpegOptionComboBoxPanel() {
1283 if (FFmpegOptionComboBoxPanel == null) {
1284 GridBagConstraints gridBagConstraints47 = new GridBagConstraints();
1285 gridBagConstraints47.fill = GridBagConstraints.BOTH;
1286 gridBagConstraints47.gridx = -1;
1287 gridBagConstraints47.gridy = -1;
1288 gridBagConstraints47.insets = new Insets(0, 0, 5, 5);
1289 GridBagConstraints gridBagConstraints46 = new GridBagConstraints();
1290 gridBagConstraints46.fill = GridBagConstraints.HORIZONTAL;
1291 gridBagConstraints46.gridwidth = 3;
1292 gridBagConstraints46.gridx = -1;
1293 gridBagConstraints46.gridy = -1;
1294 gridBagConstraints46.weightx = 1.0;
1295 gridBagConstraints46.insets = new Insets(0, 5, 5, 5);
1296 FFmpegOptionComboBoxPanel = new JPanel();
1297 FFmpegOptionComboBoxPanel.setLayout(new GridBagLayout());
1298 FFmpegOptionComboBoxPanel.add(getFFmpegOptionComboBox(),
1299 gridBagConstraints46);
1300 FFmpegOptionComboBoxPanel.add(getFFmpegOptionReloadButton(),
1301 gridBagConstraints47);
1303 return FFmpegOptionComboBoxPanel;
1307 * This method initializes NotUseVhookCheckBox
1309 * @return javax.swing.JCheckBox
1311 private JCheckBox getNotUseVhookCheckBox() {
1312 if (disableVhookCheckBox == null) {
1313 disableVhookCheckBox = new JCheckBox();
1314 disableVhookCheckBox.setText("拡張vhookライブラリを無効にする(デバッグ用)");
1315 disableVhookCheckBox.setName("disableVhookCheckBox");
1317 return disableVhookCheckBox;
1321 * This method initializes ViewCommentField
1323 * @return javax.swing.JTextField
1325 private JTextField getViewCommentField() {
1326 if (viewCommentField == null) {
1327 viewCommentField = new JTextField();
1328 viewCommentField.setName("viewCommentField");
1330 return viewCommentField;
1334 * This method initializes ShadowComboBox
1336 * @return javax.swing.JComboBox
1338 private JComboBox getShadowComboBox() {
1339 if (shadowComboBox == null) {
1340 shadowComboBox = new JComboBox(SProperties.ShadowKindArray);
1341 shadowComboBox.setName("shadowComboBox");
1343 return shadowComboBox;
1346 private BasicSetting getBasicSetting() {
1347 String mail = mailAddressField.getText();
1348 String pass = String.valueOf(passwordField.getPassword());
1349 boolean proxyUse = useProxyCheckBox.isSelected();
1350 String proxyHost = proxyTextField.getText();
1353 proxyPort = Integer.parseInt(proxyPortTextField.getText());
1354 } catch (NumberFormatException e) {
1357 // TODO 作業用ディレクトリの設定GUI無し
1358 return new BasicSetting(tempDir, mail, pass, proxyUse, proxyHost, proxyPort);
1361 private InputVideoSetting getInputVideoSetting() {
1363 if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) {
1364 kind = VideoSaveKind.NO_SAVE;
1365 } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) {
1366 kind = VideoSaveKind.NICOBROWSER;
1368 kind = VideoSaveKind.SAVE;
1370 boolean autoNaming = videoSaveInfoPanel.getSaveFolderRadioButton().isSelected();
1371 String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
1372 String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
1373 boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
1374 String nibrFile = videoSaveInfoPanel.getNibrFileField().getText();
1376 return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
1379 private InputCommentSetting getInputCommentSetting() {
1380 boolean download = savePanel.getSavingCommentCheckBox().isSelected();
1381 String file = savePanel.getCommentSavedFileField().getText();
1384 back_comment = Integer.parseInt(savePanel.getCommentNumField().getText());
1385 } catch (NumberFormatException ex) {
1388 boolean delete = savePanel.getDelCommentCheckBox().isSelected();
1389 boolean autoNaming = savePanel.getCommentSaveFolderRadioButton().isSelected();
1390 String folder = savePanel.getCommentSavedFolderField().getText();
1391 boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
1393 return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
1398 * 画面入力値から投稿者コメント設定を作成する.
1399 * @return 作成した投稿者コメント設定.
1401 private InputTcommentSetting getTcommentSetting() {
1402 boolean down = savePanel.isTcommentDownload();
1403 boolean del = savePanel.isTcommentDelete();
1404 boolean naming = savePanel.isTcommentAutoFileName();
1405 String dir = savePanel.getTcommentDirectoryName();
1406 String f = savePanel.getTcommentFileName();
1407 return new InputTcommentSetting(down, naming, dir, f, del);
1410 private OutputVideoSetting getOutputVideoSetting() {
1411 boolean process = savePanel.getSavingConvertedVideoCheckBox().isSelected();
1412 boolean addComment = savePanel.getAddCommentCheckBox().isSelected();
1413 boolean addTcomment = savePanel.getAddTcommentCheckBox().isSelected();
1414 String file = savePanel.getConvertedVideoSavedFileField().getText();
1415 boolean cutId = savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected();
1416 boolean autoNaming = savePanel.getConvSaveFolderRadioButton().isSelected();
1417 String folder = savePanel.getConvertedVideoSavedFolderField().getText();
1419 return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment,
1423 private MovieSetting getMovieSetting() {
1424 String ffmpeg = ffmpegPathField.getText();
1425 String vhook = vhookPathField.getText();
1426 String ext = extOptionField.getText();
1427 String main = mainOptionField.getText();
1428 String in = inputOptionField.getText();
1429 String out = outputOptionField.getText();
1430 String avfilter = avfilterOptionField.getText();
1431 boolean resize = resizeCheckBox.isSelected();
1432 String width = resizeWidthField.getText();
1433 String height = resizeHeigitField.getText();
1434 boolean adjust = adjustRatioCheckBox.isSelected();
1435 File optionFile = FFmpegOptionModel.getSelectedFile();
1437 FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust);
1438 return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
1441 private ConvertSetting getConvertSetting() {
1442 boolean vhookDisabled = disableVhookCheckBox.isSelected();
1443 int maxComment = 30;
1445 maxComment = Integer.parseInt(viewCommentField.getText());
1446 } catch (NumberFormatException ex) {
1448 File font = new File(fontPathField.getText());
1449 int fontIndex = Integer.parseInt(fontIndexField.getText());
1450 int shadowIndex = shadowComboBox.getSelectedIndex();
1451 boolean showConv = showConvVideoCheckBox.isSelected();
1452 boolean adjustFont = fixFontSizeCheckBox.isSelected();
1453 boolean commentOpaque = opaqueCommentCheckBox.isSelected();
1454 NgSetting ngSetting = new NgSetting(ngWordTextField.getText(), ngIdTextField.getText());
1456 return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
1457 commentOpaque, ngSetting);
1460 private class InputVideoPanelButtonListener implements ActionListener {
1462 public void actionPerformed(ActionEvent e) {
1463 final Object source = e.getSource();
1464 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1470 if (source == panel.getShowSavingVideoFolderDialogButton()) {
1471 title = "動画の保存先(フォルダ)";
1472 field = panel.getVideoSavedFolderField();
1475 } else if (source == panel.getShowSavingVideoFileDialogButton()) {
1476 title = "動画の保存先(ファイル)";
1477 field = panel.getVideoSavedFileField();
1480 } else if (source == panel.getNibrFileChooserButton()) {
1481 title = "NicoBrowserファイル選択";
1482 field = panel.getNibrFileField();
1488 showSaveDialog(title, field, isSave, isDir);
1492 private class InputCommentPanelButtonListener implements ActionListener {
1494 public void actionPerformed(ActionEvent e) {
1495 final Object source = e.getSource();
1500 if (source == savePanel.getShowSavingCommentFolderDialogButton()) {
1501 title = "コメントの保存先(フォルダ)";
1502 field = savePanel.getCommentSavedFolderField();
1505 } else if (source == savePanel.getShowSavingCommentFileDialogButton()) {
1506 title = "コメントの保存先(ファイル)";
1507 field = savePanel.getCommentSavedFileField();
1513 showSaveDialog(title, field, isSave, isDir);
1517 private class OutputVideoPanelButtonListener implements ActionListener {
1519 public void actionPerformed(ActionEvent e) {
1520 final Object source = e.getSource();
1525 if (source == savePanel.getShowSavingConvertedVideoFolderDialogButton()) {
1526 title = "コメント付き動画の保存先(フォルダ)";
1527 field = savePanel.getConvertedVideoSavedFolderField();
1530 } else if (source == savePanel.getShowSavingConvertedVideoFileDialogButton()) {
1531 title = "コメント付き動画の保存先(ファイル)";
1532 field = savePanel.getConvertedVideoSavedFileField();
1538 showSaveDialog(title, field, isSave, isDir);
1542 private class VideoUseRadioButtonListener implements ActionListener {
1544 public void actionPerformed(ActionEvent e) {
1545 Object source = e.getSource();
1546 if (source == videoSaveInfoPanel.getVideoUseNiBrButton()) {
1553 private void maskBase() {
1557 private void maskExt() {
1561 private void mask(boolean b) {
1562 final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1563 videoIdField.setEditable(b);
1564 panel.getDelVideoCheckBox().setEnabled(b);
1566 panel.getSaveFolderRadioButton().setEnabled(b);
1567 panel.getVideoSavedFolderField().setEnabled(b);
1568 panel.getShowSavingVideoFolderDialogButton().setEnabled(b);
1570 panel.getSaveFileRadioButton().setEnabled(b);
1571 panel.getVideoSavedFileField().setEnabled(b);
1572 panel.getShowSavingVideoFileDialogButton().setEnabled(b);
1574 panel.getNibrFileField().setEnabled(!b);
1575 panel.getNibrFileChooserButton().setEnabled(!b);
1580 class MainFrame_this_windowAdapter extends WindowAdapter {
1582 private MainFrame adaptee;
1584 MainFrame_this_windowAdapter(MainFrame adaptee) {
1585 this.adaptee = adaptee;
1589 public void windowClosing(WindowEvent e) {
1590 adaptee.this_windowClosing(e);
1594 class MainFrame_SettingFontPathButton_actionAdapter implements ActionListener {
1596 private MainFrame adaptee;
1598 MainFrame_SettingFontPathButton_actionAdapter(MainFrame adaptee) {
1599 this.adaptee = adaptee;
1602 public void actionPerformed(ActionEvent e) {
1603 adaptee.SettingFontPathButton_actionPerformed(e);
1607 class MainFrame_SettingVhookPathButton_actionAdapter implements ActionListener {
1609 private MainFrame adaptee;
1611 MainFrame_SettingVhookPathButton_actionAdapter(MainFrame adaptee) {
1612 this.adaptee = adaptee;
1615 public void actionPerformed(ActionEvent e) {
1616 adaptee.SettingVhookPathButton_actionPerformed(e);
1620 class MainFrame_SettingFFmpegPathButton_actionAdapter implements ActionListener {
1622 private MainFrame adaptee;
1624 MainFrame_SettingFFmpegPathButton_actionAdapter(MainFrame adaptee) {
1625 this.adaptee = adaptee;
1628 public void actionPerformed(ActionEvent e) {
1629 adaptee.SettingFFmpegPathButton_actionPerformed(e);
1633 class MainFrame_DoButton_actionAdapter implements ActionListener {
1635 private MainFrame adaptee;
1637 MainFrame_DoButton_actionAdapter(MainFrame adaptee) {
1638 this.adaptee = adaptee;
1641 public void actionPerformed(ActionEvent e) {
1642 adaptee.DoButton_actionPerformed(e);
1646 class MainFrame_jMenuFileExit_ActionAdapter implements ActionListener {
1650 MainFrame_jMenuFileExit_ActionAdapter(MainFrame adaptee) {
1651 this.adaptee = adaptee;
1654 public void actionPerformed(ActionEvent actionEvent) {
1655 adaptee.jMenuFileExit_actionPerformed(actionEvent);
1659 class MainFrame_jMenuHelpAbout_ActionAdapter implements ActionListener {
1663 MainFrame_jMenuHelpAbout_ActionAdapter(MainFrame adaptee) {
1664 this.adaptee = adaptee;
1667 public void actionPerformed(ActionEvent actionEvent) {
1668 adaptee.jMenuHelpAbout_actionPerformed(actionEvent);