1 42 43 package org.jfree.experimental.chart.renderer; 44 45 import java.awt.Color ; 46 import java.awt.Paint ; 47 import java.io.Serializable ; 48 49 import org.jfree.util.PublicCloneable; 50 51 58 public class GrayPaintScale 59 implements PaintScale, PublicCloneable, Serializable { 60 61 62 private double min; 63 64 65 private double max; 66 67 70 public GrayPaintScale() { 71 this(0.0, 1.0); 72 } 73 74 80 public GrayPaintScale(double min, double max) { 81 this.min = min; 82 this.max = max; 83 } 84 85 92 public Paint getPaint(double value) { 93 double v = Math.max(value, this.min); 94 v = Math.min(v, this.max); 95 int g = (int) ((value - this.min) / (this.max - this.min) * 255.0); 96 return new Color (g, g, g); 97 } 98 99 112 public boolean equals(Object obj) { 113 if (obj == this) { 114 return true; 115 } 116 if (!(obj instanceof GrayPaintScale)) { 117 return false; 118 } 119 GrayPaintScale that = (GrayPaintScale) obj; 120 if (this.min != that.min) { 121 return false; 122 } 123 if (this.max != that.max) { 124 return false; 125 } 126 return true; 127 } 128 129 137 public Object clone() throws CloneNotSupportedException { 138 return super.clone(); 139 } 140 141 } 142 | Popular Tags |