• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

OmegaT の背景に画像を表示します。


Commit MetaInfo

Revision66 (tree)
Time2014-05-28 23:07:57
Authoryu-tang

Log Message

画像収集用のメソッド getImagePaths() を MoeUtil#collectImagePaths() に移動

Change Summary

Incremental Difference

--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeConfig.java (revision 65)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeConfig.java (revision 66)
@@ -24,9 +24,7 @@
2424 import java.io.IOException;
2525 import java.io.Writer;
2626 import java.net.URISyntaxException;
27-import java.net.URL;
2827 import java.util.ArrayList;
29-import java.util.Collections;
3028 import java.util.Comparator;
3129 import java.util.HashMap;
3230 import java.util.LinkedHashMap;
@@ -191,7 +189,7 @@
191189
192190 private static String getFirstImagePath(File parentDir) {
193191 try {
194- List<String> imagePaths = getImagePaths(parentDir);
192+ List<String> imagePaths = MoeUtil.collectImagePaths(parentDir);
195193 if (!imagePaths.isEmpty()) {
196194 return imagePaths.get(0);
197195 }
@@ -200,27 +198,5 @@
200198 }
201199 return "";
202200 }
203-
204- private static List<String> getImagePaths(File parentDir) throws IOException {
205- ArrayList<String> array = new ArrayList<String>();
206- if (parentDir.isDirectory()) {
207- for (File f: parentDir.listFiles()) {
208- if (f.isFile()) {
209- if (MoeUtil.isImage(f)) {
210- array.add(f.getCanonicalPath());
211- }else if (MoeUtil.isURLShortcut(f)) {
212- URL url = MoeUtil.getURL(f);
213- array.add(url.toExternalForm());
214- }
215- }
216- }
217- }
218201
219- if (!array.isEmpty()) {
220- Collections.sort(array);
221- }
222-
223- return array;
224- }
225-
226202 }
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeUtil.java (revision 65)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeUtil.java (revision 66)
@@ -25,6 +25,9 @@
2525 import java.net.URISyntaxException;
2626 import java.net.URL;
2727 import java.security.CodeSource;
28+import java.util.ArrayList;
29+import java.util.Collections;
30+import java.util.List;
2831 import java.util.regex.Matcher;
2932 import java.util.regex.Pattern;
3033 import org.omegat.util.LFileCopy;
@@ -159,4 +162,40 @@
159162 return primaryMoeConfigFile;
160163 }
161164
165+ /**
166+ * 指定されたフォルダー配下の画像パスを収集する
167+ *
168+ * 収集対象は、画像ファイルおよびインターネット ショートカットです。
169+ * 画像ファイルは、そのフルパスを取得します。画像形式かどうかは、単純に
170+ * 拡張子によって判断されます。
171+ * インターネット ショートカットの場合は、参照先の URL 文字列を取得します。
172+ * HTTP および HTTPS プロトコルのみ有効です。このとき、URL が画像データ
173+ * を取得するかどうか検査しない点に留意してください。インターネット
174+ * ショートカットはすべて収集されます。
175+ *
176+ * @param parentDir 対象フォルダー
177+ * @return 画像パスのリスト
178+ * @throws IOException
179+ */
180+ public static List<String> collectImagePaths(File parentDir) throws IOException {
181+ ArrayList<String> array = new ArrayList<String>();
182+ if (parentDir.isDirectory()) {
183+ for (File f: parentDir.listFiles()) {
184+ if (f.isFile()) {
185+ if (MoeUtil.isImage(f)) {
186+ array.add(f.getCanonicalPath());
187+ }else if (MoeUtil.isURLShortcut(f)) {
188+ URL url = MoeUtil.getURL(f);
189+ array.add(url.toExternalForm());
190+ }
191+ }
192+ }
193+ }
194+
195+ if (!array.isEmpty()) {
196+ Collections.sort(array);
197+ }
198+
199+ return array;
200+ }
162201 }