• 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

Revision62 (tree)
Time2014-05-26 18:58:52
Authoryu-tang

Log Message

背景色の設定機能を実装

Change Summary

Incremental Difference

--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeUIDelegator.java (revision 61)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeUIDelegator.java (revision 62)
@@ -58,6 +58,9 @@
5858
5959 public void setBackgroundColor(Color color) {
6060 this.bgColor = color;
61+ if (component != null) {
62+ component.setBackground(color);
63+ }
6164 }
6265
6366 public BufferedImage getBackgroundImage() {
@@ -73,6 +76,9 @@
7376 if (!c.isOpaque()) {
7477 c.setOpaque(true);
7578 }
79+ if (bgColor != null) {
80+ c.setBackground(bgColor);
81+ }
7682 this.component = c;
7783 }
7884
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/BasicEffect.java (revision 61)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/BasicEffect.java (revision 62)
@@ -16,6 +16,7 @@
1616
1717 package jp.sourceforge.users.yutang.omegat.plugin.moenizer.effect;
1818
19+import java.awt.Color;
1920 import java.io.File;
2021 import java.io.IOException;
2122 import java.net.MalformedURLException;
@@ -39,11 +40,13 @@
3940 private final String KEY_OPACITY = "opacity";
4041 private final String KEY_IMAGE = "image";
4142 private final String KEY_PATH = "path";
43+ private final String KEY_BGCOLOR = "bgColor";
4244 private final String KEY_EXCLUDE = "exclude";
4345
4446 private Parts target = Parts.MainWindow;
4547 private float opacity = 0.5f;
4648 private String image = "";
49+ private Color bgColor = null;
4750 private List<Parts> exclude = new ArrayList<Parts>();
4851
4952 public BasicEffect(Map<String, Object> config) {
@@ -53,15 +56,15 @@
5356 image = get(KEY_PATH, conf, image);
5457 opacity = get(KEY_OPACITY, conf, opacity);
5558 }
59+ Integer rgb = get(KEY_BGCOLOR, config, null);
60+ if (rgb != null) {
61+ bgColor = new Color(rgb);
62+ }
5663 exclude = get(KEY_EXCLUDE, config, exclude);
5764 }
5865
5966 @Override
6067 public void invoke(MoeUI ui) {
61- if (image.isEmpty()) {
62- return;
63- }
64-
6568 EnumSet<Parts> excludeParts = EnumSet.noneOf(Parts.class);
6669 for (Parts part: EnumSet.allOf(Parts.class)) {
6770 if (exclude.contains(part)) {
@@ -69,21 +72,25 @@
6972 }
7073 }
7174
72- try {
73- String lcased = image.toLowerCase();
74- if (lcased.startsWith("http://") || lcased.startsWith("https://")) {
75- ui.setBackground(target, ImageIO.read(new URL(image)));
76- } else {
77- ui.setBackground(target, ImageIO.read(new File(image)));
75+ if (!image.isEmpty()) {
76+ try {
77+ String lcased = image.toLowerCase();
78+ if (lcased.startsWith("http://") || lcased.startsWith("https://")) {
79+ ui.setBackground(target, ImageIO.read(new URL(image)));
80+ } else {
81+ ui.setBackground(target, ImageIO.read(new File(image)));
82+ }
83+ } catch (MalformedURLException ex) {
84+ Log.log(ex.getMessage());
85+ } catch (IOException ex) {
86+ Log.log(ex.getMessage());
7887 }
79- } catch (MalformedURLException ex) {
80- Log.log(ex.getMessage());
81- } catch (IOException ex) {
82- Log.log(ex.getMessage());
8388 }
8489
8590 ui.setOpacity(target, opacity);
8691
92+ ui.setBackground(target, bgColor);
93+
8794 ui.transparent(target, excludeParts);
8895 }
8996