Class RangeColorMap
java.lang.Object
microsim.gui.colormap.FixedColorMap
microsim.gui.colormap.RangeColorMap
- All Implemented Interfaces:
ColorMap
It builds automatically a color map using a variable range.
There are three types of range:
There are three types of range:
- From black color to a given color, based on a linear range.
- From given color to a given color, based on a linear range.
- From given color to a given color, based on dual range, with a middle color.
Title: JAS
Description: Java Agent-based Simulation library
Copyright (C) 2002 Michele Sonnessa
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.- Author:
- Michele Sonnessa, Matteo Morini
-
Field Summary
FieldsFields inherited from class FixedColorMap
colorComponents, colorList, colors, mapper -
Constructor Summary
ConstructorsConstructorDescriptionRangeColorMap(int gradients, double minValue, double midValue, double maxValue, Color bottomColor, Color middleColor, Color topColor) Create a color range map from lower given color to middle given color and from middle to the highest given one.RangeColorMap(int gradients, double minValue, double maxValue, Color color) Create a color range map from black to given color.RangeColorMap(int gradients, double minValue, double maxValue, Color bottomColor, Color topColor) Create a color range map from given color to given color. -
Method Summary
Modifier and TypeMethodDescriptionintgetColorIndex(double value) Return the color index.intgetColorIndex(int value) Return the color index.Methods inherited from class FixedColorMap
addColor, addColor, getColor, getColorComponents, getMappedColor, toArray
-
Field Details
-
rangeSize
protected double rangeSize -
minValue
protected double minValue
-
-
Constructor Details
-
RangeColorMap
Create a color range map from black to given color.- Parameters:
gradients- The number of color gradients that are added to the map.minValue- The lower bound of the range.maxValue- The upper bound of the range.color- The highest color. It will correspond to maxValue.- Throws:
ArrayIndexOutOfBoundsException- ifmaxValue <= minValue.
-
RangeColorMap
public RangeColorMap(int gradients, double minValue, double maxValue, Color bottomColor, Color topColor) Create a color range map from given color to given color.- Parameters:
gradients- The number of color gradients that are added to the map.minValue- The lower bound of the range.maxValue- The upper bound of the range.bottomColor- The lowest color. It will correspond to minValue.topColor- The highest color. It will correspond to maxValue.- Throws:
ArrayIndexOutOfBoundsException- ifmaxValue <= minValue.
-
RangeColorMap
public RangeColorMap(int gradients, double minValue, double midValue, double maxValue, Color bottomColor, Color middleColor, Color topColor) Create a color range map from lower given color to middle given color and from middle to the highest given one.- Parameters:
gradients- The number of color gradients that are added to the map.minValue- The lower bound of the range.midValue- The value at which color changes the range.maxValue- The upper bound of the range.bottomColor- The lowest color. It will correspond to minValue.middleColor- The middle color. It will correspond to midValue.topColor- The highest color. It will correspond to maxValue.- Throws:
ArrayIndexOutOfBoundsException- ifmaxValue <= midValue || midValue <= minValue.
-
-
Method Details
-
getColorIndex
public int getColorIndex(int value) Return the color index.- Specified by:
getColorIndexin interfaceColorMap- Overrides:
getColorIndexin classFixedColorMap- Parameters:
value- The value to be mapped. If it is outside the range bounds, the method returns its nearest bound.- Returns:
- The index of the color list mapping the value.
-
getColorIndex
public int getColorIndex(double value) Return the color index.- Specified by:
getColorIndexin interfaceColorMap- Overrides:
getColorIndexin classFixedColorMap- Parameters:
value- The value to be mapped. If it is outside the range bounds, the method returns its nearest bound.- Returns:
- The index of the color list mapping the value.
-