OmegaT の背景に画像を表示します。
設定ファイルで Effect Type を省略時は、既定値 Basic として解釈する
| @@ -171,7 +171,7 @@ | ||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | ConfigObject effect = new ConfigObject(); |
| 174 | - effect.put("type", Effect.Type.BasicEffect); | |
| 174 | + effect.put("type", Effect.Type.Basic); | |
| 175 | 175 | Map image = new LinkedHashMap<String, Object>(); |
| 176 | 176 | image.put("path", imagePath); |
| 177 | 177 | effect.put("image", image); |
| @@ -57,9 +57,9 @@ | ||
| 57 | 57 | |
| 58 | 58 | // apply effects |
| 59 | 59 | for (Map conf: effects) { |
| 60 | - | |
| 61 | 60 | try { |
| 62 | - Effect.Type type = (Effect.Type) conf.get("type"); | |
| 61 | + Effect.Type type = conf.containsKey("type") ? | |
| 62 | + (Effect.Type) conf.get("type") : Effect.Type.Basic; | |
| 63 | 63 | Effect effect = Effect.create(type, conf); |
| 64 | 64 | effect.invoke(model); |
| 65 | 65 | } catch (Exception ex) { |
| @@ -27,11 +27,11 @@ | ||
| 27 | 27 | public abstract class Effect { |
| 28 | 28 | |
| 29 | 29 | public enum Type { |
| 30 | - BasicEffect | |
| 30 | + Basic | |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public static Effect create(Type type, Map conf) throws Exception { |
| 34 | - final String CLASS_NAME = Effect.class.getPackage().getName() + "." + type.name(); | |
| 34 | + final String CLASS_NAME = Effect.class.getPackage().getName() + "." + type.name() + "Effect"; | |
| 35 | 35 | Class<? extends Effect> clazz = (Class<? extends Effect>) Class.forName(CLASS_NAME); |
| 36 | 36 | Class<?>[] types = {Map.class}; |
| 37 | 37 | Constructor<? extends Effect> constructor = clazz.getConstructor(types); |