2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: Utility.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.2 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 21:00:04 $ |
2 |
26 Feb 07 |
jari |
* $Author: caliente $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.util.swing; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.GradientPaint; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
17 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
18 |
|
2 |
26 Feb 07 |
jari |
19 |
public class Utility { |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
public Utility() { |
2 |
26 Feb 07 |
jari |
22 |
} |
2 |
26 Feb 07 |
jari |
23 |
|
2 |
26 Feb 07 |
jari |
24 |
static public void drawRainbow(Graphics2D g2, int x, int y, int Width, int Height, int Mode) { |
2 |
26 Feb 07 |
jari |
25 |
Vector Colors=new Vector(); |
2 |
26 Feb 07 |
jari |
26 |
GradientPaint gp; |
2 |
26 Feb 07 |
jari |
27 |
switch (Mode) { |
2 |
26 Feb 07 |
jari |
28 |
case 1: Colors.add(new Color(255,000,000)); |
2 |
26 Feb 07 |
jari |
29 |
Colors.add(new Color(255,255,000)); |
2 |
26 Feb 07 |
jari |
30 |
Colors.add(new Color(000,255,000)); |
2 |
26 Feb 07 |
jari |
31 |
Colors.add(new Color(000,255,255)); |
2 |
26 Feb 07 |
jari |
32 |
Colors.add(new Color(000,000,255)); |
2 |
26 Feb 07 |
jari |
33 |
Colors.add(new Color(255,000,255)); |
2 |
26 Feb 07 |
jari |
34 |
break; |
2 |
26 Feb 07 |
jari |
35 |
case 2: Colors.add(new Color(255,000,000)); |
2 |
26 Feb 07 |
jari |
36 |
Colors.add(new Color(255,255,000)); |
2 |
26 Feb 07 |
jari |
37 |
Colors.add(new Color(000,000,128)); |
2 |
26 Feb 07 |
jari |
38 |
break; |
2 |
26 Feb 07 |
jari |
39 |
case 3: Colors.add(new Color(255,000,255)); |
2 |
26 Feb 07 |
jari |
40 |
Colors.add(new Color(000,000,255)); |
2 |
26 Feb 07 |
jari |
41 |
Colors.add(new Color(000,255,255)); |
2 |
26 Feb 07 |
jari |
42 |
Colors.add(new Color(000,255,000)); |
2 |
26 Feb 07 |
jari |
43 |
Colors.add(new Color(255,255,000)); |
2 |
26 Feb 07 |
jari |
44 |
Colors.add(new Color(255,000,000)); |
2 |
26 Feb 07 |
jari |
45 |
break; |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
} |
2 |
26 Feb 07 |
jari |
48 |
double Step=Width/(double)(Colors.size()-1); |
2 |
26 Feb 07 |
jari |
49 |
for (int i=0; i<(Colors.size()-1); i++) { |
2 |
26 Feb 07 |
jari |
50 |
gp=new GradientPaint(x+(int)Math.round(i*Step),0,(Color)Colors.get(i),x+(int)Math.round((i+1)*Step),0,(Color)Colors.get(i+1)); |
2 |
26 Feb 07 |
jari |
51 |
g2.setPaint(gp); |
2 |
26 Feb 07 |
jari |
52 |
g2.drawRect(x+(int)Math.round(i*Step),y,(int)Step,Height); |
2 |
26 Feb 07 |
jari |
53 |
g2.fillRect(x+(int)Math.round(i*Step),y,(int)Step,Height); |
2 |
26 Feb 07 |
jari |
54 |
} |
2 |
26 Feb 07 |
jari |
55 |
} |
2 |
26 Feb 07 |
jari |
56 |
} |