| Method from org.jfree.chart.ui.ColorPalette Detail: |
public Object clone() throws CloneNotSupportedException {
ColorPalette clone = (ColorPalette) super.clone();
return clone;
}
Returns a clone of the palette. |
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ColorPalette)) {
return false;
}
ColorPalette colorPalette = (ColorPalette) o;
if (this.inverse != colorPalette.inverse) {
return false;
}
if (this.logscale != colorPalette.logscale) {
return false;
}
if (this.maxZ != colorPalette.maxZ) {
return false;
}
if (this.minZ != colorPalette.minZ) {
return false;
}
if (this.stepped != colorPalette.stepped) {
return false;
}
if (!Arrays.equals(this.b, colorPalette.b)) {
return false;
}
if (!Arrays.equals(this.g, colorPalette.g)) {
return false;
}
if (this.paletteName != null
? !this.paletteName.equals(colorPalette.paletteName)
: colorPalette.paletteName != null) {
return false;
}
if (!Arrays.equals(this.r, colorPalette.r)) {
return false;
}
if (!Arrays.equals(this.tickValues, colorPalette.tickValues)) {
return false;
}
return true;
}
Tests an object for equality with this instance. |
public Paint getColor(double value) {
int izV = (int) (253 * (value - this.minZ)
/ (this.maxZ - this.minZ)) + 2;
return new Color(this.r[izV], this.g[izV], this.b[izV]);
}
Returns the color associated with a value. |
public Color getColor(int izV) {
return new Color(this.r[izV], this.g[izV], this.b[izV]);
}
|
public Color getColorLinear(double value) {
int izV = 0;
if (this.stepped) {
int index = Arrays.binarySearch(this.tickValues, value);
if (index < 0) {
index = -1 * index - 2;
}
if (index < 0) { // For the case were the first tick is greater
// than minZ
value = this.minZ;
}
else {
value = this.tickValues[index];
}
}
izV = (int) (253 * (value - this.minZ) / (this.maxZ - this.minZ)) + 2;
izV = Math.min(izV, 255);
izV = Math.max(izV, 2);
return getColor(izV);
}
Returns Color by mapping a given value to a linear palette. |
public Color getColorLog(double value) {
int izV = 0;
double minZtmp = this.minZ;
double maxZtmp = this.maxZ;
if (this.minZ < = 0.0) {
// negatives = true;
this.maxZ = maxZtmp - minZtmp + 1;
this.minZ = 1;
value = value - minZtmp + 1;
}
double minZlog = Math.log(this.minZ) / log10;
double maxZlog = Math.log(this.maxZ) / log10;
value = Math.log(value) / log10;
// value = Math.pow(10,value);
if (this.stepped) {
int numSteps = this.tickValues.length;
int steps = 256 / (numSteps - 1);
izV = steps * (int) (numSteps * (value - minZlog)
/ (maxZlog - minZlog)) + 2;
// izV = steps*numSteps*(int)((value/minZ)/(maxZlog-minZlog)) + 2;
}
else {
izV = (int) (253 * (value - minZlog) / (maxZlog - minZlog)) + 2;
}
izV = Math.min(izV, 255);
izV = Math.max(izV, 2);
this.minZ = minZtmp;
this.maxZ = maxZtmp;
return getColor(izV);
}
Returns Color by mapping a given value to a common log palette. |
public double getMaxZ() {
return this.maxZ;
}
Returns the maximum Z value. |
public double getMinZ() {
return this.minZ;
}
Returns the minimum Z value. |
public Paint getPaint(double value) {
if (isLogscale()) {
return getColorLog(value);
}
else {
return getColorLinear(value);
}
}
Returns Paint by mapping a given value to a either a linear or common
log palette as controlled by the value logscale. |
public String getPaletteName() {
return this.paletteName;
}
Returns the palette name. |
public double[] getTickValues() {
return this.tickValues;
}
|
public int hashCode() {
int result;
long temp;
temp = Double.doubleToLongBits(this.minZ);
result = (int) (temp ^ (temp > > > 32));
temp = Double.doubleToLongBits(this.maxZ);
result = 29 * result + (int) (temp ^ (temp > > > 32));
result = 29 * result + (this.logscale ? 1 : 0);
result = 29 * result + (this.inverse ? 1 : 0);
result = 29 * result
+ (this.paletteName != null ? this.paletteName.hashCode() : 0);
result = 29 * result + (this.stepped ? 1 : 0);
return result;
}
|
abstract public void initialize()
Called to initialize the palette's color indexes |
public void invertPalette() {
int[] red = new int[256];
int[] green = new int[256];
int[] blue = new int[256];
for (int i = 0; i < 256; i++) {
red[i] = this.r[i];
green[i] = this.g[i];
blue[i] = this.b[i];
}
for (int i = 2; i < 256; i++) {
this.r[i] = red[257 - i];
this.g[i] = green[257 - i];
this.b[i] = blue[257 - i];
}
}
|
public boolean isInverse() {
return this.inverse;
}
Returns the inverse flag. |
public boolean isLogscale() {
return this.logscale;
}
Returns the log-scale flag. |
public boolean isStepped() {
return this.stepped;
}
Returns the 'is-stepped' flag. |
public void setInverse(boolean inverse) {
this.inverse = inverse;
initialize();
if (inverse) {
invertPalette();
}
return;
}
|
public void setLogscale(boolean logscale) {
this.logscale = logscale;
}
Sets the 'log-scale' flag. |
public void setMaxZ(double newMaxZ) {
this.maxZ = newMaxZ;
}
Sets the maximum Z value. |
public void setMinZ(double newMinZ) {
this.minZ = newMinZ;
}
Sets the minimum Z value. |
public void setPaletteName(String paletteName) {
//String oldValue = this.paletteName;
this.paletteName = paletteName;
return;
}
|
public void setStepped(boolean stepped) {
this.stepped = stepped;
return;
}
|
public void setTickValues(double[] newTickValues) {
this.tickValues = newTickValues;
}
|
public void setTickValues(List ticks) {
this.tickValues = new double[ticks.size()];
for (int i = 0; i < this.tickValues.length; i++) {
this.tickValues[i] = ((ValueTick) ticks.get(i)).getValue();
}
}
Store ticks. Required when doing stepped axis |