home *** CD-ROM | disk | FTP | other *** search
/ Popular Software (Premium Edition) / mycd.iso / INTERNET / PFRONT98 / DATA.Z / fprotatx.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-09-26  |  1.7 KB  |  102 lines

  1. import java.awt.image.RGBImageFilter;
  2.  
  3. class fprotatx extends RGBImageFilter {
  4.    private int m_i;
  5.    private int m_n;
  6.    private int m_w;
  7.    private int m_h;
  8.    private int m_effect;
  9.    private int m_alpha;
  10.    private int m_rowsPerSlat;
  11.    private int m_colsPerSlat;
  12.    private int m_slatPosition;
  13.    private int m_xc;
  14.    private int m_yc;
  15.    private int m_xl;
  16.    private int m_xr;
  17.    private int m_yt;
  18.    private int m_yb;
  19.    private int m_maxDist;
  20.  
  21.    public int filterRGB(int x, int y, int rgb) {
  22.       int rgbVal = rgb & 16777215;
  23.       int alpha;
  24.       switch (this.m_effect) {
  25.          case 0:
  26.             alpha = -16777216;
  27.             break;
  28.          case 1:
  29.             if (y % this.m_rowsPerSlat < this.m_slatPosition) {
  30.                alpha = -16777216;
  31.             } else {
  32.                alpha = 0;
  33.             }
  34.             break;
  35.          case 2:
  36.             if (x % this.m_colsPerSlat < this.m_slatPosition) {
  37.                alpha = -16777216;
  38.             } else {
  39.                alpha = 0;
  40.             }
  41.             break;
  42.          case 3:
  43.             alpha = this.m_alpha << 24;
  44.             break;
  45.          case 4:
  46.             if (x > this.m_xl && x < this.m_xr && y > this.m_yt && y < this.m_yb) {
  47.                alpha = 0;
  48.             } else {
  49.                alpha = -16777216;
  50.             }
  51.             break;
  52.          case 5:
  53.             if (x >= this.m_xl && x <= this.m_xr && y >= this.m_yt && y <= this.m_yb) {
  54.                alpha = -16777216;
  55.             } else {
  56.                alpha = 0;
  57.             }
  58.             break;
  59.          default:
  60.             alpha = 0;
  61.       }
  62.  
  63.       return alpha | rgbVal;
  64.    }
  65.  
  66.    public fprotatx(int i, int n, int w, int h, int effect) {
  67.       super.canFilterIndexColorModel = false;
  68.       this.m_i = i;
  69.       this.m_n = n;
  70.       this.m_w = w;
  71.       this.m_h = h;
  72.       this.m_effect = effect;
  73.       this.m_xc = this.m_w / 2;
  74.       this.m_yc = this.m_h / 2;
  75.       if (this.m_effect == 1) {
  76.          this.m_rowsPerSlat = 16;
  77.          this.m_slatPosition = (this.m_i + 1) * this.m_rowsPerSlat / this.m_n;
  78.       }
  79.  
  80.       if (this.m_effect == 2) {
  81.          this.m_colsPerSlat = 16;
  82.          this.m_slatPosition = (this.m_i + 1) * this.m_colsPerSlat / this.m_n;
  83.       }
  84.  
  85.       this.m_alpha = (this.m_i + 1) * 255 / this.m_n;
  86.       if (this.m_effect == 4) {
  87.          this.m_xl = (this.m_i + 1) * this.m_xc / this.m_n;
  88.          this.m_yt = (this.m_i + 1) * this.m_yc / this.m_n;
  89.          this.m_xr = this.m_w - this.m_xl;
  90.          this.m_yb = this.m_h - this.m_yt;
  91.       }
  92.  
  93.       if (this.m_effect == 5) {
  94.          this.m_xl = (this.m_n - this.m_i - 1) * this.m_xc / this.m_n;
  95.          this.m_yt = (this.m_n - this.m_i - 1) * this.m_yc / this.m_n;
  96.          this.m_xr = this.m_w - this.m_xl;
  97.          this.m_yb = this.m_h - this.m_yt;
  98.       }
  99.  
  100.    }
  101. }
  102.