• 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

Revision33 (tree)
Time2014-05-18 01:05:55
Authoryu-tang

Log Message

背景タイリング画像を保持する処理を追加

Change Summary

Incremental Difference

--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeLayeredPane.java (revision 32)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeLayeredPane.java (revision 33)
@@ -19,8 +19,6 @@
1919 import java.awt.AlphaComposite;
2020 import java.awt.Graphics;
2121 import java.awt.Graphics2D;
22-import java.awt.Rectangle;
23-import java.awt.TexturePaint;
2422 import java.awt.image.BufferedImage;
2523 import java.awt.image.WritableRaster;
2624 import javax.swing.JLayeredPane;
@@ -44,7 +42,7 @@
4442 public class MoeLayeredPane extends JLayeredPane {
4543
4644 private BufferedImage image = null;
47- private TexturePaint paint = null;
45+ private BufferedImage tiledImage = null;
4846 private float alpha = 0.5f; //@@TODO replace literal to constant
4947 private int paintMarginTop = 0;
5048
@@ -67,15 +65,21 @@
6765 Graphics2D g2 = (Graphics2D) g.create();
6866 g2.setComposite(makeComposite(alpha));
6967
70- if (getWidth() > image.getWidth() || getHeight() > image.getHeight()) {
71- //g2.setPaint(paint);
72- //g2.fillRect(0, 0, getWidth(), getHeight());
73- //g2.fillRect(0, paintMarginTop, getWidth(), getHeight());
74- BufferedImage tiledImage = createTiledImage(image, getWidth(), getHeight());
75- g2.drawImage(tiledImage, 0, paintMarginTop, this);
76- } else {
77- g2.drawImage(image, 0, paintMarginTop, this);
68+ // 当初 TexturePaint を用意して、
69+ // g2.setPaint(paint);
70+ // g2.fillRect(0, 0, getWidth(), getHeight());
71+ // などとしていたが、メニューバーなどが不透過に設定された場合に
72+ // 背景の描画開始位置を下げる必要があり、テクスチャによるタイリング
73+ // では対応できなかった(描画開始位置を下げてもテクスチャの位置が
74+ // 変わらないので、テクスチャの途中から描画が始まる感じ)。
75+ // そこで、自前でタイリング画像を作って保持し、その一枚絵を貼る路線
76+ // に変更する。
77+ int width = getWidth();
78+ int height = getHeight();
79+ if (width > image.getWidth() || height > image.getHeight()) {
80+ this.tiledImage = createTiledImage(image, width, height);
7881 }
82+ g2.drawImage(tiledImage, 0, paintMarginTop, this);
7983
8084 g2.dispose();
8185 }
@@ -89,12 +93,11 @@
8993
9094 private void setPicture(BufferedImage image) {
9195 this.image = image;
92-
96+
9397 if (image == null) {
94- this.paint = null;
98+ this.tiledImage = null;
9599 } else {
96- Rectangle rect = new Rectangle(image.getWidth(), image.getHeight());
97- this.paint = new TexturePaint(image, rect);
100+ this.tiledImage = createTiledImage(image, getWidth(), getHeight());
98101 }
99102 }
100103