OSDN Git Service

置換文字設定を削除
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / gui / FfmpegParamPanel.java
1 package yukihane.inqubus.gui;
2
3 import java.awt.event.ActionEvent;
4 import java.awt.event.ActionListener;
5 import java.io.File;
6 import javax.swing.BorderFactory;
7 import javax.swing.GroupLayout;
8 import javax.swing.GroupLayout.Alignment;
9 import javax.swing.JButton;
10 import javax.swing.JCheckBox;
11 import javax.swing.JComboBox;
12 import javax.swing.JLabel;
13 import javax.swing.JPanel;
14 import javax.swing.JTextField;
15 import javax.swing.LayoutStyle.ComponentPlacement;
16 import org.apache.commons.lang.StringUtils;
17 import saccubus.FFmpegSelectedItem;
18 import saccubus.OptionComboBoxModel;
19 import yukihane.inqubus.config.Config;
20
21 /**
22  *
23  * @author yuki
24  */
25 class FfmpegParamPanel extends JPanel {
26
27     private static final long serialVersionUID = 1L;
28     // ffmpeg - ffmpegパラメータ
29     final OptionComboBoxModel mdlFfmpegOption = new OptionComboBoxModel();
30     final JComboBox<FFmpegSelectedItem> cmbFfmpegOptionFile = new JComboBox<>(mdlFfmpegOption);
31     final JTextField fldFfmpegOptionExtension = new JTextField();
32     final JTextField fldFfmpegOptionMain = new JTextField();
33     final JTextField fldFfmpegOptionIn = new JTextField();
34     final JTextField fldFfmpegOptionOut = new JTextField();
35     final JTextField fldFfmpegOptionAv = new JTextField();
36     final JCheckBox cbFfmpegOptionResize = new JCheckBox("次のサイズに収まるよう縮小(-s)");
37     final NumberFormattedTextField fldFfmpegOptionResizeWidth = new NumberFormattedTextField();
38     final NumberFormattedTextField fldFfmpegOptionResizeHeight = new NumberFormattedTextField();
39     final JCheckBox cbFfmpegOptionKeepAspect = new JCheckBox("アスペクト比を維持");
40
41     void init(Config p) {
42         final String fof = p.getFfmpegOptionFile();
43         mdlFfmpegOption.reload(StringUtils.isNotEmpty(fof) ? new File(fof) : null);
44         fldFfmpegOptionExtension.setText(p.getFfmpegExtension());
45         fldFfmpegOptionMain.setText(p.getFfmpegMainOption());
46         fldFfmpegOptionIn.setText(p.getFfmpegInOption());
47         fldFfmpegOptionOut.setText(p.getFfmpegOutOption());
48         fldFfmpegOptionAv.setText(p.getFfmpegAvOption());
49         cbFfmpegOptionResize.setSelected(p.getFfmpegResizeEnable());
50         fldFfmpegOptionResizeWidth.setText(p.getFfmpegResizeWidth());
51         fldFfmpegOptionResizeHeight.setText(p.getFfmpegResizeHeight());
52         cbFfmpegOptionKeepAspect.setSelected(p.getFfmpegKeepAspect());
53     }
54
55     FfmpegParamPanel() {
56         final JLabel lblFfmpegOptionExtension = new JLabel("出力動画の拡張子");
57         final JLabel lblFfmpegOptionMain = new JLabel("メインオプション");
58         final JLabel lblFfmpegOptionIn = new JLabel("入力オプション");
59         final JLabel lblFfmpegOptionOut = new JLabel("出力オプション");
60         final JLabel lblFfmpegOptionAvfilter = new JLabel("avfilterオプション");
61         final JLabel lblFfmpegOptionResizeWidth = new JLabel("横");
62         final JLabel lblFfmpegOptionResizeHeight = new JLabel("縦");
63
64
65
66         final JPanel pnlFfmpegParamOption = new JPanel();
67         pnlFfmpegParamOption.setBorder(BorderFactory.createEtchedBorder());
68
69         final GroupLayout glFfmpegParamOption = new GroupLayout(pnlFfmpegParamOption);
70         glFfmpegParamOption.setAutoCreateContainerGaps(true);
71         pnlFfmpegParamOption.setLayout(glFfmpegParamOption);
72         glFfmpegParamOption.setHorizontalGroup(glFfmpegParamOption.createParallelGroup(Alignment.LEADING)
73             .addGroup(glFfmpegParamOption.createSequentialGroup()
74                 .addGroup(glFfmpegParamOption.createParallelGroup(Alignment.LEADING)
75                     .addComponent(lblFfmpegOptionAvfilter)
76                     .addComponent(lblFfmpegOptionExtension)
77                     .addComponent(lblFfmpegOptionMain)
78                     .addComponent(lblFfmpegOptionIn)
79                     .addComponent(lblFfmpegOptionOut)
80                 )
81                 .addPreferredGap(ComponentPlacement.RELATED)
82                 .addGroup(glFfmpegParamOption.createParallelGroup(Alignment.LEADING)
83                     .addComponent(fldFfmpegOptionExtension, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
84                     .addComponent(fldFfmpegOptionMain, GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
85                     .addComponent(fldFfmpegOptionIn, GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
86                     .addComponent(fldFfmpegOptionOut, GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
87                     .addComponent(fldFfmpegOptionAv, GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
88                 )
89             )
90             .addGroup(glFfmpegParamOption.createSequentialGroup()
91                 .addComponent(cbFfmpegOptionResize)
92                 .addPreferredGap(ComponentPlacement.UNRELATED)
93                 .addComponent(lblFfmpegOptionResizeWidth)
94                 .addPreferredGap(ComponentPlacement.RELATED)
95                 .addComponent(fldFfmpegOptionResizeWidth, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
96                 .addPreferredGap(ComponentPlacement.UNRELATED)
97                 .addComponent(lblFfmpegOptionResizeHeight)
98                 .addPreferredGap(ComponentPlacement.RELATED)
99                 .addComponent(fldFfmpegOptionResizeHeight, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))
100             .addGroup(glFfmpegParamOption.createSequentialGroup()
101                 .addGap(15)
102                 .addComponent(cbFfmpegOptionKeepAspect)
103             )
104         );
105
106         glFfmpegParamOption.setVerticalGroup(glFfmpegParamOption.createSequentialGroup()
107             .addGroup(glFfmpegParamOption.createParallelGroup(Alignment.BASELINE)
108                 .addComponent(lblFfmpegOptionExtension)
109                 .addComponent(fldFfmpegOptionExtension, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
110             .addGroup(glFfmpegParamOption.createParallelGroup(Alignment.BASELINE)
111                 .addComponent(lblFfmpegOptionMain)
112                 .addComponent(fldFfmpegOptionMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
113             .addGroup(glFfmpegParamOption.createParallelGroup(Alignment.BASELINE)
114                 .addComponent(lblFfmpegOptionIn)
115                 .addComponent(fldFfmpegOptionIn, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
116             .addGroup(glFfmpegParamOption.createParallelGroup(Alignment.BASELINE)
117                 .addComponent(lblFfmpegOptionOut)
118                 .addComponent(fldFfmpegOptionOut, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
119             .addGroup(glFfmpegParamOption.createParallelGroup(Alignment.BASELINE)
120                 .addComponent(lblFfmpegOptionAvfilter)
121                 .addComponent(fldFfmpegOptionAv, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
122             .addGroup(glFfmpegParamOption.createParallelGroup(Alignment.BASELINE)
123                 .addComponent(cbFfmpegOptionResize)
124                 .addComponent(lblFfmpegOptionResizeWidth)
125                 .addComponent(fldFfmpegOptionResizeWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
126                 .addComponent(lblFfmpegOptionResizeHeight)
127                 .addComponent(fldFfmpegOptionResizeHeight, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
128             .addComponent(cbFfmpegOptionKeepAspect)
129         );
130
131         final JButton btnReload = new JButton("更新");
132         btnReload.addActionListener(new ActionListener() {
133
134             @Override
135             public void actionPerformed(ActionEvent e) {
136                 mdlFfmpegOption.reload();
137             }
138         });
139
140
141         final GroupLayout glFfmpegParam = new GroupLayout(this);
142         setLayout(glFfmpegParam);
143         glFfmpegParam.setHorizontalGroup(
144             glFfmpegParam.createParallelGroup(Alignment.LEADING)
145             .addGroup(glFfmpegParam.createSequentialGroup()
146                 .addContainerGap()
147                 .addGroup(glFfmpegParam.createParallelGroup(Alignment.LEADING)
148                     .addGroup(glFfmpegParam.createSequentialGroup()
149                         .addComponent(cmbFfmpegOptionFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
150                         .addPreferredGap(ComponentPlacement.UNRELATED)
151                         .addComponent(btnReload)
152                     )
153                     .addComponent(pnlFfmpegParamOption, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
154                 )
155                 .addContainerGap())
156         );
157         glFfmpegParam.setVerticalGroup(
158             glFfmpegParam.createParallelGroup(Alignment.LEADING)
159             .addGroup(glFfmpegParam.createSequentialGroup()
160                 .addContainerGap()
161                 .addGroup(glFfmpegParam.createParallelGroup(Alignment.BASELINE)
162                     .addComponent(cmbFfmpegOptionFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
163                     .addComponent(btnReload)
164                 )
165                 .addPreferredGap(ComponentPlacement.RELATED)
166                 .addComponent(pnlFfmpegParamOption)
167                 .addContainerGap())
168         );
169     }
170 }