/***********************************************************************************/
/**										  **/
/**		Neonsign Applet							  **/
/**				file name : Neonsign_16.java			  **/
/**				window size : WIDTH x HEIGHT			  **/
/**				working: ﾈｵﾝｻｲﾝ表示ｱﾌﾟﾚｯﾄ			  **/
/**				param : "string"    (表示ﾃｷｽﾄ)			  **/
/**				param : "sleeptime" (ｽﾘｰﾌﾟ時間)			  **/
/**				param : "fontname"  (ﾌｫﾝﾄ名)			  **/
/**				param : "fontstyle" (ﾌｫﾝﾄｽﾀｲﾙ)			  **/
/**				param : "fontsize"  (ﾌｫﾝﾄｻｲｽﾞ)			  **/
/**				param : "backimg"   (背景画像名)		  **/
/**				param : "bgcolor"   (背景色 [RGB16進])		  **/
/**				param : "offcolor"  (文字消灯色 [RGB16進])	  **/
/**				param : "shadow"    (影の位置と色 [x,y,RGB16進])  **/
/**				param : "pattern"   (点灯ﾊﾟﾀｰﾝ指定 ["a〜o"任意])  **/
/**				param : "jumpto"    (ｸﾘｯｸ時ｼﾞｬﾝﾌﾟ先 [URLｱﾄﾞﾚｽ])	  **/
/**				param : "direction" (表示方向["H"=横/"V"=縦])	  **/
/**				file : 背景画像 (paramの"backimg"指定による画像)  **/
/**										  **/
/**				1996/04/29 ver1.0 created by H.Machida		  **/
/**				1996/05/04 ver1.1 updated by H.Machida		  **/
/**				1996/12/21 ver1.2 updated by H.Machida		  **/
/**					 (各種ﾊﾟﾗﾒｰﾀ対応、点灯ﾊﾞﾘｴｰｼｮﾝ追加等)	  **/
/**				1996/12/25 ver1.3 updated by H.Machida		  **/
/**					 (MSIE3.0での流れ点灯時表示かすれ対策)	  **/
/**				1997/01/03 ver1.4 updated by H.Machida		  **/
/**					 (初期表示の改良及び全体構成の見直し)	  **/
/**				1997/08/07 ver1.5 updated by H.Machida		  **/
/**					 (背景画像・消灯色・影・ﾊﾟﾀｰﾝ指定追加)	  **/
/**					 (点灯ﾊﾞﾘｴｰｼｮﾝ追加、URLｼﾞｬﾝﾌﾟ指定追加)	  **/
/**				1997/08/13 ver1.6 updated by H.Machida		  **/
/**					 (表示方向 横/縦 指定追加)		  **/
/**										  **/
/***********************************************************************************/

//----------- 点灯ﾊﾟﾀｰﾝ指定一覧 -----------------------------------------------------
//	"a":右へ1文字ずつ点灯
//	"b":左へ1文字ずつ点灯
//	"c":右へ1文字ずつ消灯
//	"d":左へ1文字ずつ消灯
//	"e":全文字を点灯
//	"f":全文字を消灯
//	"g":右へ流れる様に文字を点灯
//	"h":左へ流れる様に文字を点灯
//	"i":右へ流れる様に文字を消灯
//	"j":左へ流れる様に文字を消灯
//	"k":全文字をだんだんに点灯
//	"l":全文字をだんだんに消灯(消灯色は黒色となるので注意)
//	"m":右へ1文字ずつﾗﾝﾀﾞﾑ色で点灯
//	"n":左へ1文字ずつﾗﾝﾀﾞﾑ色で点灯
//	"o":一定時間(x5ｽﾘｰﾌﾟ時間)そのまま待機
//------------------------------------------------------------------------------------
//	ﾊﾟﾀｰﾝ指定例 : pattern = "kooo fo eoo fo eoo do gh gh eooo looo";
//	("a〜o"以外の指定は無視されるが、x1ｽﾘｰﾌﾟ時間だけ待機となる)
//------------------------------------------------------------------------------------

import java.awt.*;
import java.util.*;
import java.net.*;


public class Neonsign_16 extends java.applet.Applet implements Runnable {


/********** instance **********/

  Thread neon;					// ｽﾚｯﾄﾞ
  int appwidth;					// ｱﾌﾟﾚｯﾄ横幅
  int appheight;				// ｱﾌﾟﾚｯﾄ縦幅
  int stime;					// ｽﾘｰﾌﾟ時間
  int seqnum = 0;				// ｼｰｹﾝｽ番号
  int colornum = 0;				// ｶﾗｰ番号
  int chrnum = 0;				// 文字番号(ﾀｲﾐﾝｸﾞｶｳﾝﾀ兼用)
  char chr[];					// ﾃｷｽﾄの文字配列
  int chr_length;				// ﾃｷｽﾄの文字数
  int xp[];					// ﾃｷｽﾄの文字毎描画位置(x座標)
  int yp[];					// ﾃｷｽﾄの文字毎描画位置(y座標)
  Color texclr;					// ﾃｷｽﾄ点灯色
  Font font;					// ﾌｫﾝﾄ
  FontMetrics fm;				// ﾌｫﾝﾄ ﾒﾄﾘｯｸｽ
  Color bgclr;					// 背景色
  Color offclr;					// ﾃｷｽﾄ消灯色
  int shx;					// ﾃｷｽﾄ影位置(x相対座標)
  int shy;					// ﾃｷｽﾄ影位置(y相対座標)
  Color shclr;					// ﾃｷｽﾄ影色
  Image backimg;				// 背景画像
  String pattern;				// 点灯ﾊﾟﾀｰﾝ指定("abc..."のｱﾙﾌｧﾍﾞｯﾄ)
  String jumpto;				// ｸﾘｯｸ時ｼﾞｬﾝﾌﾟ先URLｱﾄﾞﾚｽ
  MediaTracker mt;				// ﾒﾃﾞｨｱﾄﾗｯｶｰ
  boolean imgflag;				// 背景画像描画完了ﾌﾗｸﾞ

  final String STATUSTEXT = "Neonsign ver1.6";	// ｽﾃｰﾀｽﾗｲﾝ表示ﾃｷｽﾄ


/********** init **********/

  public void init() {

    String str;
    String fname;
    int fstyle, fsize;
    String direction;

    appwidth = size().width;			// ｱﾌﾟﾚｯﾄ横幅を取得
    appheight = size().height;			// ｱﾌﾟﾚｯﾄ縦幅を取得

    String param = null;			// 各種ﾊﾟﾗﾒｰﾀの読み出し

    param = getParameter("string");		// "string"を読出してﾃｷｽﾄを設定
    if (param == null) {
      str = "Welcome to My Home Page !!";
    } else {
      str = param;
    }

    param = getParameter("sleeptime");		// "sleeptime"を読出してstimeを設定
    if (param == null) {
      stime = 50;
    } else {
      stime = Integer.valueOf(param).intValue();
    }

    param = getParameter("fontname");		// "fontname"を読出してﾌｫﾝﾄ名を設定
    if (param == null) {
      fname = "TimesRoman";
    } else {
      fname = param;
    }
    param = getParameter("fontstyle");		// "fontstyle"を読出してﾌｫﾝﾄｽﾀｲﾙを設定
    if (param == null) {
      fstyle = Font.BOLD;
    } else {
      if (param.equals("PLAIN")) {
        fstyle = Font.PLAIN;
      } else {
        if (param.equals("BOLD")) {
          fstyle = Font.BOLD;
        } else {
          if (param.equals("ITALIC")) {
            fstyle = Font.ITALIC;
          } else {
            fstyle = Font.BOLD + Font.ITALIC;
          }
        }
      }
    }
    param = getParameter("fontsize");		// "fontsize"を読出してﾌｫﾝﾄｻｲｽﾞを設定
    if (param == null) {
      fsize = 24;
    } else {
      fsize = Integer.valueOf(param).intValue();
    }

    bgclr = Color.darkGray;			// "bgcolor"を読出して背景色を設定
    param = getParameter("bgcolor");
    if (param != null) {
      bgclr = new Color(Integer.valueOf(param,16).intValue());
    }

    offclr = Color.black;			// "offcolor"を読出して文字消灯色を設定
    param = getParameter("offcolor");
    if (param != null) {
      offclr = new Color(Integer.valueOf(param,16).intValue());
    }

    shx = 0;					// "shadow"を読出して影位置・色を設定
    shy = 0;
    shclr = Color.gray;
    param = getParameter("shadow");
    if (param != null) {
      StringTokenizer st = new StringTokenizer(param, ",");
      if (st.hasMoreTokens()) {			// (影位置x座標)
        shx = Integer.valueOf(st.nextToken()).intValue();
      }
      if (st.hasMoreTokens()) {			// (影位置y座標)
        shy = Integer.valueOf(st.nextToken()).intValue();
      }
      if (st.hasMoreTokens()) {			// (影色)
        shclr = new Color(Integer.valueOf(st.nextToken(),16).intValue());
      }
    }

    param = getParameter("backimg");		// "backimg"を読出して背景画像を設定
    if (param == null) {
      backimg = null;
    } else {
      backimg = getImage(getDocumentBase(), param); // (背景画像をﾛｰﾃﾞｨﾝｸﾞ開始)
      mt = new MediaTracker(this);		// (ﾒﾃﾞｨｱﾄﾗｯｶｰを設定)
      mt.addImage(backimg ,0);
      imgflag = false;				// (imgflagを初期化)
    }

    param = getParameter("pattern");		// "pattern"を読出してpatternを設定
    if (param == null) {
      pattern = "aoo d boo c ghgh o eoo fo eoo fooo";
    } else {
      pattern = param;
    }

    param = getParameter("jumpto");		// "jumpto"を読出してjumptoを設定
    if (param == null) {
      jumpto = null;
    } else {
      jumpto = param;
    }

    param = getParameter("direction");		// "direction"を読出して表示方向を設定
    if (param == null) {
      direction = "H";
    } else {
      direction = param;
    }


    chr = str.toCharArray();			// chr[]を初期化(ﾃｷｽﾄを文字配列に変換)
    chr_length = str.length();			// chr_length(文字配列数)を設定

    font = new Font(fname, fstyle, fsize);	// ﾌｫﾝﾄを設定

    fm = getFontMetrics(font);			// 設定ﾌｫﾝﾄのﾌｫﾝﾄﾒﾄﾘｯｸを得る


    xp = new int[chr_length];			// xp[]を初期化
    yp = new int[chr_length];			// yp[]を初期化

    if (direction.equals("H") == true) {	// 表示方向 = 横 or 縦 ?

      int str_w = 0;				// (横表示におけるﾃｷｽﾄ横幅を得る)
      for (int i = 0 ; i < chr_length ; i++) {
        str_w += fm.charWidth(chr[i]);
      }

      xp[0] = (appwidth-str_w)/2;		// ﾃｷｽﾄがｾﾝﾀﾘﾝｸﾞするようにxp[]を設定
      for (int i = 1 ; i < chr_length ; i++) {
        xp[i] = xp[i-1] + fm.charWidth(chr[i-1]);
      }
						// (横表示におけるﾃｷｽﾄ縦幅を得る)
      int str_h = fm.getAscent()+fm.getDescent();

      for (int i = 0 ; i < chr_length ; i++) {	// ﾃｷｽﾄがｾﾝﾀﾘﾝｸﾞするようにyp[]を設定
        yp[i] = ((appheight-str_h)/2)+fm.getAscent();
      }

    } else {

      for (int i = 0 ; i < chr_length ; i++) {	// ﾃｷｽﾄがｾﾝﾀﾘﾝｸﾞするようにxp[]を設定
        xp[i] = (appwidth-fm.charWidth(chr[i]))/2;
      }

      int str_h = 0;				// (縦表示におけるﾃｷｽﾄ縦幅を得る)
      for (int i = 0 ; i < chr_length ; i++) {
        str_h += fm.getAscent()+fm.getDescent();
      }
						// ﾃｷｽﾄがｾﾝﾀﾘﾝｸﾞするようにyp[]を設定
      yp[0] = ((appheight-str_h)/2)+fm.getAscent();
      for (int i = 1 ; i < chr_length ; i++) {
        yp[i] = yp[i-1] + fm.getAscent()+fm.getDescent();
      }

    }

    setBackground(bgclr);			// ｱﾌﾟﾚｯﾄの背景色を設定

  }


/********** start **********/

  public void start() {
    neon = new Thread(this);
    neon.start();
  }


/********** stop **********/

  public void stop() {
    neon.stop();
    neon = null;
  }


/********** run **********/

  public void run() {

    if (backimg != null) {			// 背景画像有りの場合は、
      try { mt.waitForID(0); }			// 　　　ﾒﾃﾞｨｱﾄﾗｯｶｰ完了まで待機する
      catch (InterruptedException e) {};
    }

    while( true ) {
      try { Thread.currentThread().sleep(stime);}
      catch (InterruptedException e) {};
      repaint();
    }
  }


/********** paint **********/

  public void paint(Graphics scr) {

    if (backimg != null) {			// 背景画像=有ならば背景画像を描画
      scr.drawImage(backimg, 0,0, appwidth,appheight, this);
      if (mt.checkID(0) == true) imgflag = true;
    } else {					// 背景画像=無ならば背景色で全ｸﾘｱ
      scr.clearRect(0, 0, appwidth, appheight);
    }

    scr.setColor(shclr);			// 文字影を描画
    scr.setFont(font);
    for (int i = 0 ; i < chr_length ; i++) {
      scr.drawChars(chr, i,1, xp[i]+shx, yp[i]+shy);
    }

    scr.setColor(offclr);			// 全文字を消灯色で描画
    scr.setFont(font);
    for (int i = 0 ; i < chr_length ; i++) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }

  }


/********** update **********/

  public void update(Graphics scr) {

    if (backimg != null && imgflag == false) {	// 背景画像が未描画ならば、
      paint(scr);				// 　　　　　　　paint()を呼んで終了
      return;
    }

    texclr = textcolor(colornum);		// 点灯文字色を作成

    switch (pattern.charAt(seqnum)) {		// ﾊﾟﾀｰﾝﾃﾞｰﾀにより点灯ﾊﾟﾀｰﾝを決定する
      case 'a':
        stepon_r(scr);				// (右へ1文字ずつ点灯)
        break;
      case 'b':
        stepon_l(scr);				// (左へ1文字ずつ点灯)
        break;
      case 'c':
        stepoff_r(scr);				// (右へ1文字ずつ消灯)
        break;
      case 'd':
        stepoff_l(scr);				// (左へ1文字ずつ消灯)
        break;
      case 'e':
        allon(scr);				// (全文字を点灯)
        break;
      case 'f':
        alloff(scr);				// (全文字を消灯)
        break;
      case 'g':
        flow_r(scr, offclr, texclr);		// (右へ流れる様に文字を点灯)
        break;
      case 'h':
        flow_l(scr, offclr, texclr);		// (左へ流れる様に文字を点灯)
        break;
      case 'i':
        flow_r(scr, texclr, offclr);		// (右へ流れる様に文字を消灯)
        break;
      case 'j':
        flow_l(scr, texclr, offclr);		// (左へ流れる様に文字を消灯)
        break;
      case 'k':
        gradon(scr);				// (全文字をだんだんに点灯)
        break;
      case 'l':
        gradoff(scr);				// (全文字をだんだんに消灯)
        break;
      case 'm':
        rndc_r(scr);				// (右へ1文字ずつﾗﾝﾀﾞﾑ色で点灯)
        break;
      case 'n':
        rndc_l(scr);				// (左へ1文字ずつﾗﾝﾀﾞﾑ色で点灯)
        break;
      case 'o':
        waitwait();				// (一定時間そのまま待機)
        break;
      default:
        seqnum++;
    }

    if (seqnum >= pattern.length()) {		// ﾊﾟﾀｰﾝ表示が全て終了したか ?
      colornum++;				// (表示色を更新して、最初に戻る)
      if (colornum >= 7) colornum = 0;
      seqnum = 0;
    }

  }


/********** mouseEnter **********/

  public boolean mouseEnter(Event e, int x, int y) {

    if (jumpto == null) {			// ｽﾃｰﾀｽﾗｲﾝにﾒｯｾｰｼﾞを表示する
      showStatus(STATUSTEXT);
    } else {
      showStatus(STATUSTEXT + " [Jump to " + jumpto + "]");
    }

    return true;

  }


/********** mouseUp **********/

  public boolean mouseUp(Event e, int x, int y) {

    if (jumpto == null) return false;		// ｼﾞｬﾝﾌﾟ先指定がなければ終了

    URL url;					// URLを作成
    try {
      url = new URL(getDocumentBase(), jumpto);
    }
    catch (MalformedURLException murle) {
      url = null;
    }

    if (url != null) {				// ｽﾃｰﾀｽﾗｲﾝにﾒｯｾｰｼﾞを表示してｼﾞｬﾝﾌﾟ!!
      showStatus(STATUSTEXT + " [OK! Jump to " + jumpto + "]");
      getAppletContext().showDocument(url);
    }

    return true;

  }


/********** mouseExit **********/

  public boolean mouseExit(Event e, int x, int y) {

    showStatus("");				// ｽﾃｰﾀｽﾗｲﾝのﾒｯｾｰｼﾞを消去する

    return true;

  }


/********** light pattern methods **********/

  void stepon_r(Graphics scr) {			// 右へ1文字ずつ点灯

    scr.setColor(texclr);
    scr.setFont(font);
    for (int i = 0 ; i <= chrnum ; i++) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum++;
    if (chrnum >= chr_length) {
      chrnum = 0;
      seqnum++;
    }

  }


  void stepon_l(Graphics scr) {			// 左へ1文字ずつ点灯

    int pt = (chr_length - 1) - chrnum;		// (点灯文字位置)

    scr.setColor(texclr);
    scr.setFont(font);
    for (int i = chr_length - 1 ; i >= pt ; i--) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum++;
    if (chrnum >= chr_length) {
      chrnum = 0;
      seqnum++;
    }

  }


  void stepoff_r(Graphics scr) {		// 右へ1文字ずつ消灯

    scr.setColor(offclr);
    scr.setFont(font);
    for (int i = 0 ; i <= chrnum ; i++) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum++;
    if (chrnum >= chr_length) {
      chrnum = 0;
      seqnum++;
    }

  }


  void stepoff_l(Graphics scr) {		// 左へ1文字ずつ消灯

    int pt = (chr_length - 1) - chrnum;		// (点灯文字位置)

    scr.setColor(offclr);
    scr.setFont(font);
    for (int i = chr_length - 1 ; i >= pt ; i--) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum++;
    if (chrnum >= chr_length) {
      chrnum = 0;
      seqnum++;
    }

  }


  void allon(Graphics scr) {			// 全文字を点灯

    scr.setColor(texclr);
    scr.setFont(font);
    for (int i = 0 ; i < chr_length ; i++) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum = 0;
    seqnum++;

  }


  void alloff(Graphics scr) {			// 全文字を消灯

    scr.setColor(offclr);
    scr.setFont(font);
    for (int i = 0 ; i < chr_length ; i++) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum = 0;
    seqnum++;

  }

						// 右へ流れる様に文字を点灯or消灯
  void flow_r(Graphics scr, Color c1, Color c2) {

    scr.setFont(font);
    scr.setColor(c1);				// (前文字までを点灯or消灯)
    for (int i = 0 ; i <= chrnum ; i++) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }

    scr.setColor(c2);				// (該当文字から3文字分を点灯or消灯)
    if (chrnum < chr_length) {
      scr.drawChars(chr, chrnum+0,1, xp[chrnum+0], yp[chrnum+0]);
      if (chrnum+1 < chr_length) {
        scr.drawChars(chr, chrnum+1,1, xp[chrnum+1], yp[chrnum+1]);
        if (chrnum+2 < chr_length) {
          scr.drawChars(chr, chrnum+2,1, xp[chrnum+2], yp[chrnum+2]);
        }
      }
      chrnum++;
      if (chrnum >= chr_length) {
        scr.setColor(c1);			// (全文字を点灯or消灯)
        for (int i = 0 ; i < chr_length ; i++) {
          scr.drawChars(chr, i,1, xp[i], yp[i]);
        }
        chrnum = 0;
        seqnum++;
      }
    }

  }

						// 左へ流れる様に文字を点灯or消灯
  void flow_l(Graphics scr, Color c1, Color c2) {

    int pt = (chr_length - 1) - chrnum;		// (該当文字位置)

    scr.setFont(font);
    scr.setColor(c1);				// (前文字までを点灯or消灯)
    for (int i = chr_length - 1 ; i >= pt ; i--) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }

    scr.setColor(c2);				// (該当文字から3文字分を点灯or消灯)
    if (chrnum < chr_length) {
      scr.drawChars(chr, pt-0,1, xp[pt-0], yp[pt-0]);
      if (chrnum+1 < chr_length) {
        scr.drawChars(chr, pt-1,1, xp[pt-1], yp[pt-1]);
        if (chrnum+2 < chr_length) {
          scr.drawChars(chr, pt-2,1, xp[pt-2], yp[pt-2]);
        }
      }
      chrnum++;
      if (chrnum >= chr_length) {
        scr.setColor(c1);			// (全文字を点灯or消灯)
        for (int i = 0 ; i < chr_length ; i++) {
          scr.drawChars(chr, i,1, xp[i], yp[i]);
        }
        chrnum = 0;
        seqnum++;
      }
    }

  }


  void gradon(Graphics scr) {			// 全文字をだんだんに点灯

    scr.setColor(gradcolor((float)chrnum / 20)); // (点灯色の明度を調整)
    scr.setFont(font);
    for (int i = 0 ; i < chr_length ; i++) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum++;
    if (chrnum >= 20) {
      chrnum = 0;
      seqnum++;
    }

  }


  void gradoff(Graphics scr) {			// 全文字をだんだんに消灯

    scr.setColor(gradcolor((float)(20-chrnum) / 20)); // (点灯色の明度を調整)
    scr.setFont(font);
    for (int i = 0 ; i < chr_length ; i++) {
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum++;
    if (chrnum >= 20) {
      chrnum = 0;
      seqnum++;
    }

  }


  void rndc_r(Graphics scr) {			// 右へ1文字ずつﾗﾝﾀﾞﾑな色で点灯

    scr.setFont(font);
    for (int i = 0 ; i <= chrnum ; i++) {
      scr.setColor(textcolor((int)(Math.random()*8)));
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum++;
    if (chrnum >= chr_length) {
      chrnum = 0;
      seqnum++;
    }

  }


  void rndc_l(Graphics scr) {			// 左へ1文字ずつﾗﾝﾀﾞﾑな色で点灯

    int pt = (chr_length - 1) - chrnum;		// (点灯文字位置)

    scr.setFont(font);
    for (int i = chr_length - 1 ; i >= pt ; i--) {
      scr.setColor(textcolor((int)(Math.random()*8)));
      scr.drawChars(chr, i,1, xp[i], yp[i]);
    }
    chrnum++;
    if (chrnum >= chr_length) {
      chrnum = 0;
      seqnum++;
    }

  }


  void waitwait() {				// 一定時間そのまま待機(stime*5)

    chrnum++;
    if (chrnum >= 5) {
      chrnum = 0;
      seqnum++;
    }

  }


/********** methods **********/

  Color textcolor(int number) {			// 文字点灯色を作成

    Color clr = Color.red;

    switch (number) {				// numberにより色を決定する
      case 0:
        clr = Color.red;
        break;
      case 1:
        clr = Color.yellow;
        break;
      case 2:
        clr = Color.green;
        break;
      case 3:
        clr = Color.cyan;
        break;
      case 4:
        clr = Color.blue;
        break;
      case 5:
        clr = Color.magenta;
        break;
      case 6:
        clr = Color.white;
        break;
    }

    return clr;

  }


  Color gradcolor(float val) {			// 明度のグラデーション色を作成

    Color clr;

    float hsb[];
    hsb = new float[3];
    hsb = Color.RGBtoHSB(texclr.getRed(), texclr.getGreen(), texclr.getBlue(), null);
    clr = new Color(Color.HSBtoRGB(hsb[0],hsb[1],hsb[2]*val));

    return clr;

  }


}
