Package microsim.gui.colormap
Class RangeColorMap
- java.lang.Object
-
- microsim.gui.colormap.FixedColorMap
-
- microsim.gui.colormap.RangeColorMap
-
- All Implemented Interfaces:
ColorMap
public class RangeColorMap extends FixedColorMap
It builds automatically a color map using a variable 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
-
-
Constructor Summary
Constructors Constructor Description RangeColorMap(int gradients, double minValue, double midValue, double maxValue, java.awt.Color bottomColor, java.awt.Color middleColor, java.awt.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, java.awt.Color color)
Create a color range map from black to given color.RangeColorMap(int gradients, double minValue, double maxValue, java.awt.Color bottomColor, java.awt.Color topColor)
Create a color range map from given color to given color.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getColorIndex(double value)
Return the color index.int
getColorIndex(int value)
Return the color index.-
Methods inherited from class microsim.gui.colormap.FixedColorMap
addColor, addColor, getColor, getColorComponents, getMappedColor, toArray
-
-
-
-
Constructor Detail
-
RangeColorMap
public RangeColorMap(int gradients, double minValue, double maxValue, java.awt.Color color)
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.
-
RangeColorMap
public RangeColorMap(int gradients, double minValue, double maxValue, java.awt.Color bottomColor, java.awt.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.
-
RangeColorMap
public RangeColorMap(int gradients, double minValue, double midValue, double maxValue, java.awt.Color bottomColor, java.awt.Color middleColor, java.awt.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.
-
-
Method Detail
-
getColorIndex
public int getColorIndex(int value)
Return the color index.- Specified by:
getColorIndex
in interfaceColorMap
- Overrides:
getColorIndex
in 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:
getColorIndex
in interfaceColorMap
- Overrides:
getColorIndex
in 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.
-
-