home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / awt / MultipleGradientPaint.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  3.0 KB  |  118 lines

  1. package java.awt;
  2.  
  3. import java.awt.geom.AffineTransform;
  4. import java.awt.image.ColorModel;
  5. import java.lang.ref.SoftReference;
  6. import java.util.Arrays;
  7.  
  8. public abstract class MultipleGradientPaint implements Paint {
  9.    final int transparency;
  10.    final float[] fractions;
  11.    final Color[] colors;
  12.    final AffineTransform gradientTransform;
  13.    final CycleMethod cycleMethod;
  14.    final ColorSpaceType colorSpace;
  15.    ColorModel model;
  16.    float[] normalizedIntervals;
  17.    boolean isSimpleLookup;
  18.    SoftReference<int[][]> gradients;
  19.    SoftReference<int[]> gradient;
  20.    int fastGradientArraySize;
  21.  
  22.    MultipleGradientPaint(float[] var1, Color[] var2, CycleMethod var3, ColorSpaceType var4, AffineTransform var5) {
  23.       if (var1 == null) {
  24.          throw new NullPointerException("Fractions array cannot be null");
  25.       } else if (var2 == null) {
  26.          throw new NullPointerException("Colors array cannot be null");
  27.       } else if (var3 == null) {
  28.          throw new NullPointerException("Cycle method cannot be null");
  29.       } else if (var4 == null) {
  30.          throw new NullPointerException("Color space cannot be null");
  31.       } else if (var5 == null) {
  32.          throw new NullPointerException("Gradient transform cannot be null");
  33.       } else if (var1.length != var2.length) {
  34.          throw new IllegalArgumentException("Colors and fractions must have equal size");
  35.       } else if (var2.length < 2) {
  36.          throw new IllegalArgumentException("User must specify at least 2 colors");
  37.       } else {
  38.          float var6 = -1.0F;
  39.  
  40.          for(float var10 : var1) {
  41.             if (var10 < 0.0F || var10 > 1.0F) {
  42.                throw new IllegalArgumentException("Fraction values must be in the range 0 to 1: " + var10);
  43.             }
  44.  
  45.             if (var10 <= var6) {
  46.                throw new IllegalArgumentException("Keyframe fractions must be increasing: " + var10);
  47.             }
  48.  
  49.             var6 = var10;
  50.          }
  51.  
  52.          boolean var13 = false;
  53.          boolean var14 = false;
  54.          int var15 = var1.length;
  55.          int var16 = 0;
  56.          if (var1[0] != 0.0F) {
  57.             var13 = true;
  58.             ++var15;
  59.             ++var16;
  60.          }
  61.  
  62.          if (var1[var1.length - 1] != 1.0F) {
  63.             var14 = true;
  64.             ++var15;
  65.          }
  66.  
  67.          this.fractions = new float[var15];
  68.          System.arraycopy(var1, 0, this.fractions, var16, var1.length);
  69.          this.colors = new Color[var15];
  70.          System.arraycopy(var2, 0, this.colors, var16, var2.length);
  71.          if (var13) {
  72.             this.fractions[0] = 0.0F;
  73.             this.colors[0] = var2[0];
  74.          }
  75.  
  76.          if (var14) {
  77.             this.fractions[var15 - 1] = 1.0F;
  78.             this.colors[var15 - 1] = var2[var2.length - 1];
  79.          }
  80.  
  81.          this.colorSpace = var4;
  82.          this.cycleMethod = var3;
  83.          this.gradientTransform = new AffineTransform(var5);
  84.          boolean var11 = true;
  85.  
  86.          for(int var12 = 0; var12 < var2.length; ++var12) {
  87.             var11 = var11 && var2[var12].getAlpha() == 255;
  88.          }
  89.  
  90.          this.transparency = var11 ? 1 : 3;
  91.       }
  92.    }
  93.  
  94.    public final float[] getFractions() {
  95.       return Arrays.copyOf(this.fractions, this.fractions.length);
  96.    }
  97.  
  98.    public final Color[] getColors() {
  99.       return (Color[])Arrays.copyOf(this.colors, this.colors.length);
  100.    }
  101.  
  102.    public final CycleMethod getCycleMethod() {
  103.       return this.cycleMethod;
  104.    }
  105.  
  106.    public final ColorSpaceType getColorSpace() {
  107.       return this.colorSpace;
  108.    }
  109.  
  110.    public final AffineTransform getTransform() {
  111.       return new AffineTransform(this.gradientTransform);
  112.    }
  113.  
  114.    public final int getTransparency() {
  115.       return this.transparency;
  116.    }
  117. }
  118.