home *** CD-ROM | disk | FTP | other *** search
- package hhapplet;
-
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Rectangle;
- import java.awt.image.ImageObserver;
- import java.util.Vector;
-
- public class BsscImageLabel extends Canvas implements Runnable {
- private Image m_bgImage;
- private int m_nbgWidth;
- private int m_nbgHeight;
- private Image m_cachebgImage;
- private int m_nOldWidth;
- private int m_nOldHeight;
- private boolean m_bBgUpdated;
- private Image m_imgbackground;
- private Vector m_vToDo;
- private BsscFont m_bFont;
- private String m_strValue;
- private static int m_nHeading = 4;
- private static int m_nEnding = 4;
-
- private Image getBackgroundImage() {
- if (this.m_nbgWidth > 0 && this.m_nbgHeight > 0 && this.m_bgImage != null) {
- Rectangle var1 = ((Component)this).getBounds();
- if (var1.height == this.m_nOldHeight && var1.width == this.m_nOldWidth && !this.m_bBgUpdated) {
- return this.m_cachebgImage;
- } else {
- this.m_nOldWidth = var1.width;
- this.m_nOldHeight = var1.height;
- this.m_cachebgImage = ((Component)this).createImage(var1.width, var1.height);
- Graphics var2 = this.m_cachebgImage.getGraphics();
- this.drawBackGround(var2);
- return this.m_cachebgImage;
- }
- } else {
- return null;
- }
- }
-
- public BsscImageLabel(String var1) {
- this.m_strValue = var1;
- if (ViewSkin.m_PaneColorBg != null) {
- ((Component)this).setBackground(ViewSkin.m_PaneColorBg);
- }
-
- if (ViewSkin.m_PaneImageBg != null) {
- this.setBgImage(ViewSkin.m_PaneImageBg);
- }
-
- if (ViewSkin.m_PaneFont != null) {
- this.m_bFont = ViewSkin.m_PaneFont;
- }
-
- this.m_vToDo = new Vector();
- }
-
- public void paint(Graphics var1) {
- try {
- Rectangle var2 = ((Component)this).getBounds();
- Image var3 = ((Component)this).createImage(var2.width, var2.height);
- Graphics var4 = var3.getGraphics();
- this.m_imgbackground = this.getBackgroundImage();
- if (this.m_imgbackground != null) {
- var4.drawImage(this.m_imgbackground, 0, 0, this);
- }
-
- Object var5 = null;
- Object var6 = null;
- Font var12;
- Color var13;
- if (this.m_bFont != null) {
- var12 = this.m_bFont.getFont();
- var13 = this.m_bFont.getColor();
- } else {
- var12 = new Font(BsscFontFixPatch.GetFontName(), 0, BsscFontFixPatch.GetFontSize());
- var13 = Color.black;
- }
-
- FontMetrics var7 = var1.getFontMetrics(var12);
- int var8 = var7.getAscent();
- int var9 = var7.getLeading();
- var4.getFont();
- Color var10 = var4.getColor();
- var4.setColor(var13);
- var4.setFont(var12);
- var4.drawString(this.m_strValue, 0, var8 + var9 + m_nHeading);
- var4.setFont(var12);
- var4.setColor(var10);
- var1.drawImage(var3, 0, 0, this);
- } catch (Exception var11) {
- ((Throwable)var11).printStackTrace();
- }
- }
-
- public void setBgImage(Image var1) {
- this.m_bgImage = var1;
- this.m_nbgHeight = this.m_bgImage.getHeight(this);
- this.m_nbgWidth = this.m_bgImage.getWidth(this);
- }
-
- public void dispatchToDo(String var1) {
- if (var1 == "repaint") {
- ((Component)this).repaint();
- }
-
- }
-
- public boolean imageUpdate(Image var1, int var2, int var3, int var4, int var5, int var6) {
- if (var1 == this.m_bgImage) {
- this.m_nbgWidth = var5;
- this.m_nbgHeight = var6;
- this.m_bBgUpdated = true;
- ((Component)this).repaint();
- return false;
- } else {
- return true;
- }
- }
-
- public void drawBackGround(Graphics var1) {
- if (this.m_nbgWidth > 0 && this.m_nbgHeight > 0 && this.m_bgImage != null) {
- Rectangle var5 = ((Component)this).getBounds();
-
- for(int var6 = 0; var6 <= (var5.width - 1) / this.m_nbgWidth; ++var6) {
- for(int var7 = 0; var7 <= (var5.height - 1) / this.m_nbgHeight; ++var7) {
- if (!var1.drawImage(this.m_bgImage, var6 * this.m_nbgWidth, var7 * this.m_nbgHeight, this.m_nbgWidth, this.m_nbgHeight, (ImageObserver)null)) {
- this.setTimeout("repaint", 100);
- return;
- }
- }
- }
-
- if (this.m_bBgUpdated) {
- this.m_bBgUpdated = false;
- return;
- }
- } else {
- Color var2 = var1.getColor();
- Color var3 = ((Component)this).getBackground();
- var1.setColor(var3);
- Rectangle var4 = ((Component)this).getBounds();
- var1.fillRect(0, 0, var4.width, var4.height);
- var1.setColor(var2);
- }
-
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public Dimension getPreferredSize() {
- new Dimension();
- Object var1 = null;
- Font var6;
- if (this.m_bFont != null) {
- var6 = this.m_bFont.getFont();
- } else {
- var6 = new Font(BsscFontFixPatch.GetFontName(), 0, BsscFontFixPatch.GetFontSize());
- }
-
- FontMetrics var2 = ((Component)this).getGraphics().getFontMetrics(var6);
- char[] var3 = new char[this.m_strValue.length()];
- this.m_strValue.getChars(0, this.m_strValue.length(), var3, 0);
- int var4 = var2.charsWidth(var3, 0, this.m_strValue.length());
- int var5 = var2.getHeight() + m_nHeading + m_nEnding;
- return new Dimension(var4, var5);
- }
-
- public void run() {
- synchronized(this.m_vToDo){}
-
- ToDo var1;
- try {
- var1 = (ToDo)this.m_vToDo.elementAt(0);
- this.m_vToDo.removeElementAt(0);
- } catch (Throwable var8) {
- throw var8;
- }
-
- try {
- Thread.sleep((long)var1.m_nMSec);
- this.dispatchToDo(var1.m_sToDo);
- } catch (InterruptedException var7) {
- ((Throwable)var7).printStackTrace();
- }
- }
-
- public final void setTimeout(String var1, int var2) {
- ToDo var3 = new ToDo(this, var1, var2);
- synchronized(this.m_vToDo){}
-
- try {
- this.m_vToDo.addElement(var3);
- } catch (Throwable var8) {
- throw var8;
- }
-
- Thread var4 = new Thread(this);
- var4.start();
- }
-
- public void setText(String var1) {
- this.m_strValue = var1;
- }
- }
-