Exemplo n.º 1
0
 public static ColorScale createDefaultGrayScale() {
   // Make sure the color scale has been initiated before returning
   if (_grayScale == null || _grayScale.isEmpty()) {
     _grayScale = new ColorScale();
     _grayScale.setDefaultGrayScaleValues();
   }
   return (ColorScale) _grayScale.clone();
 }
Exemplo n.º 2
0
  public boolean equals(final ColorScale cs) {
    if (min == null && cs.min != null || min != null && cs.min == null) {
      return false;
    }
    if ((min != null && cs.min != null) && Double.compare(min, cs.min) != 0) {
      return false;
    }
    if (max == null && cs.max != null || max != null && cs.max == null) {
      return false;
    }
    if ((max != null && cs.max != null) && Double.compare(max, cs.max) != 0) {
      return false;
    }
    if (!scaling.equals(cs.scaling)) {
      return false;
    }
    if (interpolate != cs.interpolate) {
      return false;
    }
    if (forceValuesIntoRange != cs.forceValuesIntoRange) {
      return false;
    }
    if (reliefShading != cs.reliefShading) {
      return false;
    }
    if (nullColor.length != cs.nullColor.length) {
      return false;
    }
    for (int i = 0; i < nullColor.length; i++) {
      if (nullColor[i] != cs.nullColor[i]) {
        return false;
      }
    }
    if (size() != cs.size()) {
      return false;
    }
    final Iterator<Double> iterator1 = cs.keySet().iterator();
    for (final Double d1 : this.keySet()) {
      final Double d2 = iterator1.next();
      if (d1.compareTo(d2) != 0) {
        return false;
      }

      final Color value1 = get(d1);
      final Color value2 = get(d2);
      if (!value1.equals(value2)) {
        return false;
      }
    }
    return true;
  }
Exemplo n.º 3
0
  /**
   * Method to set the default color scale. The source for the color scale can come from either an
   * xml file or from hard coded values in the absent of the file.
   *
   * @param colorScale The URI of the color xml file.
   */
  public static void setDefault(final ColorScale colorScale) {
    _colorScale = colorScale;

    if (_colorScale == null) {
      _colorScale = new ColorScale();
      _colorScale.setDefaultValues();
    }
  }
Exemplo n.º 4
0
  public static ColorScale loadFromXML(String filename) throws ColorScaleException {
    try {
      InputStream stream = null;
      try {
        stream = new FileInputStream(filename);
        ColorScale cs = new ColorScale();
        cs.fromXML(stream);

        return cs;
      } finally {
        if (stream != null) {
          IOUtils.closeQuietly(stream);
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
      throw new ColorScaleException(e);
    }
  }
Exemplo n.º 5
0
  public static ColorScale loadFromXML(InputStream stream) throws ColorScaleException {
    ColorScale cs = new ColorScale();
    cs.fromXML(stream);

    return cs;
  }
Exemplo n.º 6
0
  @Override
  public Object clone() {
    super.clone();

    final ColorScale result = new ColorScale();
    result.cache = null;
    result.interpolate = interpolate;
    result.min = min;
    result.max = max;
    result.nullColor = nullColor.clone();
    result.reliefShading = reliefShading;
    result.scaling = scaling;
    result.transparent = transparent;
    result.forceValuesIntoRange = forceValuesIntoRange;
    result.putAll(this);

    return result;
  }
Exemplo n.º 7
0
 public static ColorScale loadFromJSON(String json) throws ColorScaleException {
   ColorScale cs = new ColorScale();
   cs.fromJSON(json);
   return cs;
 }