OSDN Git Service

設定のsave, load処理
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / config / ConfigConvertProfile.java
1 package yukihane.inqubus.config;
2
3 import java.io.File;
4 import java.io.IOException;
5 import org.apache.commons.lang.StringUtils;
6 import org.apache.commons.lang.builder.ToStringBuilder;
7 import saccubus.worker.profile.ConvertProfile;
8 import saccubus.worker.profile.FfmpegProfile;
9 import saccubus.worker.profile.GeneralProfile;
10
11 /**
12  * コンフィグに設定された値を基にしたConvertProfile実装.
13  * @author yuki
14  */
15 public abstract class ConfigConvertProfile implements ConvertProfile {
16
17     private final GeneralProfile generalProfile;
18     private final FfmpegProfile ffmpegProfile;
19     private final boolean convert;
20     private final File ffmpeg;
21     private final boolean vhookDisabled;
22     private final boolean commentOverlay;
23     private final File vhook;
24     private final File mediaInfo;
25     private final File tempDir;
26     private final File font;
27     private final int fontIndex;
28     private final boolean commentOpaque;
29     private final boolean disableFontSizeArrange;
30     private final int shadowIndex;
31     private final boolean showConverting;
32     private final int maxNumOfComment;
33     private final HideCondition ngSetting;
34
35     public ConfigConvertProfile() throws IOException {
36         final Config p = Config.INSTANCE;
37         this.generalProfile = new ConfigGeneralProfile();
38         this.ffmpegProfile = new ConfigFfmpegProfile();
39         this.convert = p.getOutputEnable();
40         this.ffmpeg = new File(p.getFfmpegPath());
41         this.vhookDisabled = p.getFfmpegDllDisabled();
42         this.commentOverlay = p.getOutputCommentOverlay();
43         this.vhook = new File(p.getFfmpegDllPath());
44         this.mediaInfo = new File(p.getMediaInfoPath());
45         this.tempDir = new File(p.getSystemTempDir());
46         this.font = new File(p.getFontPath());
47         this.fontIndex = Integer.parseInt(p.getFontIndex());
48         this.commentOpaque = p.getCommentOpaque();
49         this.disableFontSizeArrange = p.getFontSizeArrangeDisable();
50         this.shadowIndex = p.getFontShadow();
51         this.showConverting = p.getFfmpegDisplayConverting();
52         this.maxNumOfComment = (p.getCommentDisplaySizeDefault()) ? -1 : Integer.parseInt(p.getCommentDisplaySizeManual());
53         this.ngSetting = new ConfigHideCondition();
54
55     }
56
57     @Override
58     public GeneralProfile getGeneralProfile() {
59         return generalProfile;
60     }
61
62     @Override
63     public FfmpegProfile getFfmpegOption() {
64         return ffmpegProfile;
65     }
66
67     @Override
68     public boolean isConvert() {
69         return convert;
70     }
71
72     @Override
73     public File getFfmpeg() {
74         return ffmpeg;
75     }
76
77     @Override
78     public boolean isVhookDisabled() {
79         return vhookDisabled;
80     }
81
82     @Override
83     public boolean isCommentOverlay() {
84         return commentOverlay;
85     }
86
87     @Override
88     public File getVhook() {
89         return vhook;
90     }
91
92     @Override
93     public File getMediaInfo() {
94         return mediaInfo;
95     }
96
97     @Override
98     public File getTempDir() {
99         return tempDir;
100     }
101
102     @Override
103     public File getFont() {
104         return font;
105     }
106
107     @Override
108     public int getFontIndex() {
109         return fontIndex;
110     }
111
112     @Override
113     public boolean isCommentOpaque() {
114         return commentOpaque;
115     }
116
117     @Override
118     public boolean isDisableFontSizeArrange() {
119         return disableFontSizeArrange;
120     }
121
122     @Override
123     public int getShadowIndex() {
124         return shadowIndex;
125     }
126
127     @Override
128     public boolean isShowConverting() {
129         return showConverting;
130     }
131
132     @Override
133     public int getMaxNumOfComment() {
134         return maxNumOfComment;
135     }
136
137     @Override
138     public HideCondition getNgSetting() {
139         return ngSetting;
140     }
141
142     @Override
143     public String toString() {
144         return ToStringBuilder.reflectionToString(this);
145     }
146 }
147
148 class ConfigHideCondition implements ConvertProfile.HideCondition {
149
150     private final String word;
151     private final String id;
152
153     ConfigHideCondition() {
154         final Config p = Config.INSTANCE;
155         this.word = StringUtils.join(p.getNgWords(), ' ');
156         this.id = StringUtils.join(p.getNgIds(), ' ');
157     }
158
159     @Override
160     public String getWord() {
161         return word;
162     }
163
164     @Override
165     public String getId() {
166         return id;
167     }
168
169     @Override
170     public String toString() {
171         return ToStringBuilder.reflectionToString(this);
172     }
173 }