OSDN Git Service

コメント修正
[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 tempDir;
25     private final File font;
26     private final int fontIndex;
27     private final boolean commentOpaque;
28     private final boolean disableFontSizeArrange;
29     private final int shadowIndex;
30     private final boolean showConverting;
31     private final int maxNumOfComment;
32     private final HideCondition ngSetting;
33
34     public ConfigConvertProfile() throws IOException {
35         final Config p = Config.INSTANCE;
36         this.generalProfile = new ConfigGeneralProfile();
37         this.ffmpegProfile = new ConfigFfmpegProfile();
38         this.convert = p.getOutputEnable();
39         this.ffmpeg = new File(p.getFfmpegPath());
40         this.vhookDisabled = p.getFfmpegDllDisabled();
41         this.commentOverlay = p.getOutputCommentOverlay();
42         this.vhook = new File(p.getFfmpegDllPath());
43         this.tempDir = new File(p.getSystemTempDir());
44         this.font = new File(p.getFontPath());
45         this.fontIndex = Integer.parseInt(p.getFontIndex());
46         this.commentOpaque = p.getCommentOpaque();
47         this.disableFontSizeArrange = p.getFontSizeArrangeDisable();
48         this.shadowIndex = p.getFontShadow();
49         this.showConverting = p.getFfmpegDisplayConverting();
50         this.maxNumOfComment = (p.getCommentDisplaySizeDefault()) ? -1 : Integer.parseInt(p.getCommentDisplaySizeManual());
51         this.ngSetting = new ConfigHideCondition();
52
53     }
54
55     @Override
56     public GeneralProfile getGeneralProfile() {
57         return generalProfile;
58     }
59
60     @Override
61     public FfmpegProfile getFfmpegOption() {
62         return ffmpegProfile;
63     }
64
65     @Override
66     public boolean isConvert() {
67         return convert;
68     }
69
70     @Override
71     public File getFfmpeg() {
72         return ffmpeg;
73     }
74
75     @Override
76     public boolean isVhookDisabled() {
77         return vhookDisabled;
78     }
79
80     @Override
81     public boolean isCommentOverlay() {
82         return commentOverlay;
83     }
84
85     @Override
86     public File getVhook() {
87         return vhook;
88     }
89
90     @Override
91     public File getTempDir() {
92         return tempDir;
93     }
94
95     @Override
96     public File getFont() {
97         return font;
98     }
99
100     @Override
101     public int getFontIndex() {
102         return fontIndex;
103     }
104
105     @Override
106     public boolean isCommentOpaque() {
107         return commentOpaque;
108     }
109
110     @Override
111     public boolean isDisableFontSizeArrange() {
112         return disableFontSizeArrange;
113     }
114
115     @Override
116     public int getShadowIndex() {
117         return shadowIndex;
118     }
119
120     @Override
121     public boolean isShowConverting() {
122         return showConverting;
123     }
124
125     @Override
126     public int getMaxNumOfComment() {
127         return maxNumOfComment;
128     }
129
130     @Override
131     public HideCondition getNgSetting() {
132         return ngSetting;
133     }
134
135     @Override
136     public String toString() {
137         return ToStringBuilder.reflectionToString(this);
138     }
139 }
140
141 class ConfigHideCondition implements ConvertProfile.HideCondition {
142
143     private final String word;
144     private final String id;
145
146     ConfigHideCondition() {
147         final Config p = Config.INSTANCE;
148         this.word = StringUtils.join(p.getNgWords(), ' ');
149         this.id = StringUtils.join(p.getNgIds(), ' ');
150     }
151
152     @Override
153     public String getWord() {
154         return word;
155     }
156
157     @Override
158     public String getId() {
159         return id;
160     }
161
162     @Override
163     public String toString() {
164         return ToStringBuilder.reflectionToString(this);
165     }
166 }