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
  • Field Details

    • rangeSize

      protected double rangeSize
    • minValue

      protected double minValue
  • Constructor Details

    • RangeColorMap

      public RangeColorMap(int gradients, double minValue, double maxValue, 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.
      Throws:
      ArrayIndexOutOfBoundsException - if maxValue <= 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 - if maxValue <= 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 - if maxValue <= midValue || midValue <= minValue.
  • Method Details

    • getColorIndex

      public int getColorIndex(int value)
      Return the color index.
      Specified by:
      getColorIndex in interface ColorMap
      Overrides:
      getColorIndex in class FixedColorMap
      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 interface ColorMap
      Overrides:
      getColorIndex in class FixedColorMap
      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.