home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.image.RGBImageFilter;
-
- class fphoverx extends RGBImageFilter {
- private int m_w;
- private int m_h;
- private int m_xc;
- private int m_yc;
- private int m_dmax;
- private int m_r;
- private int m_g;
- private int m_b;
- private int m_effect;
- private int m_bevelSize;
-
- public fphoverx(int w, int h, Color color, int effect) {
- super.canFilterIndexColorModel = false;
- this.m_w = w;
- this.m_h = h;
- this.m_xc = w / 2;
- this.m_yc = h / 2;
- this.m_dmax = this.m_xc * this.m_xc + this.m_yc * this.m_yc;
- this.m_r = color.getRed();
- this.m_g = color.getGreen();
- this.m_b = color.getBlue();
- this.m_effect = effect;
- this.m_bevelSize = w < h ? w / 12 : h / 12;
- if (this.m_bevelSize < 2) {
- this.m_bevelSize = 2;
- }
-
- }
-
- public int filterRGB(int x, int y, int rgb) {
- int d = (x - this.m_xc) * (x - this.m_xc) + (y - this.m_yc) * (y - this.m_yc);
- int r = (rgb & 16711680) >> 16;
- int g = (rgb & '\uff00') >> 8;
- int b = rgb & 255;
- switch (this.m_effect) {
- case 0:
- r = this.m_r;
- g = this.m_g;
- b = this.m_b;
- break;
- case 1:
- r = r + this.m_r >> 1;
- g = g + this.m_g >> 1;
- b = b + this.m_b >> 1;
- break;
- case 2:
- r = this.m_r + (r - this.m_r) * d / this.m_dmax;
- g = this.m_g + (g - this.m_g) * d / this.m_dmax;
- b = this.m_b + (b - this.m_b) * d / this.m_dmax;
- break;
- case 3:
- r += (this.m_r - r) * d / this.m_dmax;
- g += (this.m_g - g) * d / this.m_dmax;
- b += (this.m_b - b) * d / this.m_dmax;
- break;
- case 4:
- r = r + 255 - (255 - r) * d / this.m_dmax >> 1;
- g = g + 255 - (255 - g) * d / this.m_dmax >> 1;
- b = b + 255 - (255 - b) * d / this.m_dmax >> 1;
- break;
- case 5:
- case 6:
- if (x < this.m_bevelSize || this.m_w - 1 - x < this.m_bevelSize || y < this.m_bevelSize || this.m_h - 1 - y < this.m_bevelSize) {
- Color color = new Color(r, g, b);
- boolean topLeft = false;
- if (x < this.m_bevelSize && x + y <= this.m_h) {
- topLeft = true;
- } else if (y < this.m_bevelSize && x + y <= this.m_w) {
- topLeft = true;
- }
-
- if ((!topLeft || this.m_effect != 5) && (topLeft || this.m_effect != 6)) {
- color = color.darker();
- } else {
- color = color.brighter();
- }
-
- r = color.getRed();
- g = color.getGreen();
- b = color.getBlue();
- }
- break;
- case 7:
- if (r == 0 && g == 0 && b == 0) {
- r = this.m_r;
- g = this.m_g;
- b = this.m_b;
- }
- }
-
- return rgb & -16777216 | r << 16 | g << 8 | b;
- }
- }
-