• 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

Revision49 (tree)
Time2014-05-23 01:11:13
Authoryu-tang

Log Message

effect/SimpleImage のクラス名が実情にそぐわなくなってきたので、effect/BasicEffect に変更

Change Summary

Incremental Difference

--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeConfig.java (revision 48)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeConfig.java (revision 49)
@@ -150,7 +150,7 @@
150150 }
151151
152152 ConfigObject effect = new ConfigObject();
153- effect.put("type", Effect.Type.SimpleImage.name());
153+ effect.put("type", Effect.Type.BasicEffect.name());
154154 effect.put("image", image);
155155
156156 List<ConfigObject> effects = new ArrayList<ConfigObject>(1);
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/SimpleImage.java (revision 48)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/SimpleImage.java (nonexistent)
@@ -1,105 +0,0 @@
1-/**************************************************************************
2- Moenizer - Allow to set background image for OmegaT.
3-
4- Copyright (C) 2014 Yu Tang
5- Home page: http://sourceforge.jp/users/yu-tang/
6- Support center: http://sourceforge.jp/users/yu-tang/pf/Moenizer/
7-
8- This file is part of plugin for OmegaT.
9- http://www.omegat.org/
10-
11- License: GNU GPL version 3 or (at your option) any later version.
12-
13- You should have received a copy of the GNU General Public License
14- along with this program. If not, see <http://www.gnu.org/licenses/>.
15- **************************************************************************/
16-
17-package jp.sourceforge.users.yutang.omegat.plugin.moenizer.effect;
18-
19-import java.io.File;
20-import java.io.IOException;
21-import java.net.MalformedURLException;
22-import java.net.URL;
23-import java.util.ArrayList;
24-import java.util.EnumSet;
25-import java.util.List;
26-import java.util.Map;
27-import javax.imageio.ImageIO;
28-import jp.sourceforge.users.yutang.omegat.plugin.moenizer.MoeUI;
29-import jp.sourceforge.users.yutang.omegat.plugin.moenizer.MoeUI.Parts;
30-import org.omegat.util.Log;
31-
32-/**
33- *
34- * @author Yu-Tang
35- */
36-public class SimpleImage implements IEffect {
37-
38- private final String KEY_TARGET = "target";
39- private final String KEY_OPACITY = "opacity";
40- private final String KEY_IMAGE = "image";
41- private final String KEY_EXCLUDE = "exclude";
42-
43- private Parts target = Parts.MainWindow;
44- private float opacity = 0.5f;
45- private String image = "";
46- private List<String> exclude = new ArrayList<String>();
47-
48- public SimpleImage(Map config) {
49- if (config.containsKey(KEY_TARGET)) {
50- //@@TODO 設定自体を Enum で受け取れるように
51- String targetName = (String) config.get(KEY_TARGET);
52- try {
53- target = Parts.valueOf(targetName);
54- } catch (IllegalArgumentException ex) {
55- Log.log("warning: target name '" + targetName + "' is not found in Parts enum.");
56- }
57- }
58-
59- if (config.containsKey(KEY_OPACITY)) {
60- opacity = (Float) config.get(KEY_OPACITY);
61- }
62-
63- if (config.containsKey(KEY_IMAGE)) {
64- image = (String) config.get(KEY_IMAGE);
65- }
66-
67- if (config.containsKey(KEY_EXCLUDE)) {
68- exclude = (List<String>) config.get(KEY_EXCLUDE);
69- }
70- }
71-
72- @Override
73- public void invoke(MoeUI ui) {
74- if (image.isEmpty()) {
75- return;
76- }
77-
78- EnumSet<Parts> excludeParts = EnumSet.noneOf(Parts.class);
79- for (Parts part: EnumSet.allOf(Parts.class)) {
80- if (exclude.contains(part.name())) {
81- excludeParts.add(part);
82- }
83- }
84-
85- try {
86- String lcased = image.toLowerCase();
87- if (lcased.startsWith("http://") || lcased.startsWith("https://")) {
88- ui.setBackground(target, ImageIO.read(new URL(image)));
89- } else {
90- ui.setBackground(target, ImageIO.read(new File(image)));
91- }
92- } catch (MalformedURLException ex) {
93- Log.log(ex.getMessage());
94- } catch (IOException ex) {
95- Log.log(ex.getMessage());
96- }
97-
98- ui.setOpacity(target, opacity);
99-
100- if (target == Parts.MainWindow) {
101- ui.transparent(excludeParts);
102- }
103- }
104-
105-}
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/Effect.java (revision 48)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/Effect.java (revision 49)
@@ -30,7 +30,7 @@
3030 }
3131
3232 public enum Type {
33- SimpleImage
33+ BasicEffect
3434 }
3535
3636 public static IEffect create(Type type, Map conf) throws Exception {
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/BasicEffect.java (nonexistent)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/BasicEffect.java (revision 49)
@@ -0,0 +1,105 @@
1+/**************************************************************************
2+ Moenizer - Allow to set background image for OmegaT.
3+
4+ Copyright (C) 2014 Yu Tang
5+ Home page: http://sourceforge.jp/users/yu-tang/
6+ Support center: http://sourceforge.jp/users/yu-tang/pf/Moenizer/
7+
8+ This file is part of plugin for OmegaT.
9+ http://www.omegat.org/
10+
11+ License: GNU GPL version 3 or (at your option) any later version.
12+
13+ You should have received a copy of the GNU General Public License
14+ along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ **************************************************************************/
16+
17+package jp.sourceforge.users.yutang.omegat.plugin.moenizer.effect;
18+
19+import java.io.File;
20+import java.io.IOException;
21+import java.net.MalformedURLException;
22+import java.net.URL;
23+import java.util.ArrayList;
24+import java.util.EnumSet;
25+import java.util.List;
26+import java.util.Map;
27+import javax.imageio.ImageIO;
28+import jp.sourceforge.users.yutang.omegat.plugin.moenizer.MoeUI;
29+import jp.sourceforge.users.yutang.omegat.plugin.moenizer.MoeUI.Parts;
30+import org.omegat.util.Log;
31+
32+/**
33+ *
34+ * @author Yu-Tang
35+ */
36+public class BasicEffect implements IEffect {
37+
38+ private final String KEY_TARGET = "target";
39+ private final String KEY_OPACITY = "opacity";
40+ private final String KEY_IMAGE = "image";
41+ private final String KEY_EXCLUDE = "exclude";
42+
43+ private Parts target = Parts.MainWindow;
44+ private float opacity = 0.5f;
45+ private String image = "";
46+ private List<String> exclude = new ArrayList<String>();
47+
48+ public BasicEffect(Map config) {
49+ if (config.containsKey(KEY_TARGET)) {
50+ //@@TODO 設定自体を Enum で受け取れるように
51+ String targetName = (String) config.get(KEY_TARGET);
52+ try {
53+ target = Parts.valueOf(targetName);
54+ } catch (IllegalArgumentException ex) {
55+ Log.log("warning: target name '" + targetName + "' is not found in Parts enum.");
56+ }
57+ }
58+
59+ if (config.containsKey(KEY_OPACITY)) {
60+ opacity = (Float) config.get(KEY_OPACITY);
61+ }
62+
63+ if (config.containsKey(KEY_IMAGE)) {
64+ image = (String) config.get(KEY_IMAGE);
65+ }
66+
67+ if (config.containsKey(KEY_EXCLUDE)) {
68+ exclude = (List<String>) config.get(KEY_EXCLUDE);
69+ }
70+ }
71+
72+ @Override
73+ public void invoke(MoeUI ui) {
74+ if (image.isEmpty()) {
75+ return;
76+ }
77+
78+ EnumSet<Parts> excludeParts = EnumSet.noneOf(Parts.class);
79+ for (Parts part: EnumSet.allOf(Parts.class)) {
80+ if (exclude.contains(part.name())) {
81+ excludeParts.add(part);
82+ }
83+ }
84+
85+ try {
86+ String lcased = image.toLowerCase();
87+ if (lcased.startsWith("http://") || lcased.startsWith("https://")) {
88+ ui.setBackground(target, ImageIO.read(new URL(image)));
89+ } else {
90+ ui.setBackground(target, ImageIO.read(new File(image)));
91+ }
92+ } catch (MalformedURLException ex) {
93+ Log.log(ex.getMessage());
94+ } catch (IOException ex) {
95+ Log.log(ex.getMessage());
96+ }
97+
98+ ui.setOpacity(target, opacity);
99+
100+ if (target == Parts.MainWindow) {
101+ ui.transparent(excludeParts);
102+ }
103+ }
104+
105+}