コード例 #1
0
ファイル: ColorScale.java プロジェクト: giserh/mrgeo
 /**
  * Method is responsible for generating a color scale from hard coded values. It should be called
  * when there is no input default color scale.
  */
 public void setDefaultGrayScaleValues() {
   clear();
   setScaling(ColorScale.Scaling.MinMax);
   put(0.0, new Color(0, 0, 0));
   put(0.1, new Color(26, 26, 26));
   put(0.2, new Color(52, 52, 52));
   put(0.3, new Color(77, 77, 77));
   put(0.4, new Color(102, 102, 102));
   put(0.5, new Color(128, 128, 128));
   put(0.6, new Color(154, 154, 154));
   put(0.7, new Color(179, 179, 179));
   put(0.8, new Color(205, 205, 205));
   put(0.9, new Color(230, 230, 230));
   put(1.0, new Color(255, 255, 255));
   setInterpolate(true);
   setForceValuesIntoRange(false);
 }
コード例 #2
0
ファイル: ColorScale.java プロジェクト: giserh/mrgeo
 /**
  * Method is responsible for generating a color scale from hard coded values. It should be called
  * when there is no input default color scale.
  */
 public void setDefaultValues() {
   clear();
   setScaling(ColorScale.Scaling.MinMax);
   put(0.0, new Color(0, 0, 0, 0));
   put(1e-12, new Color(255, 255, 255, 128));
   put(0.1, new Color(247, 252, 253));
   put(0.2, new Color(229, 245, 249));
   put(0.3, new Color(204, 236, 230));
   put(0.4, new Color(153, 216, 201));
   put(0.5, new Color(102, 194, 164));
   put(0.6, new Color(65, 174, 118));
   put(0.7, new Color(35, 139, 69));
   put(0.8, new Color(0, 109, 44));
   put(0.9, new Color(0, 68, 27));
   put(1.0, new Color(0, 0, 0));
   setInterpolate(true);
   setForceValuesIntoRange(false);
 }
コード例 #3
0
ファイル: ColorScale.java プロジェクト: giserh/mrgeo
 private ColorScale() {
   clear();
 }
コード例 #4
0
ファイル: ColorScale.java プロジェクト: giserh/mrgeo
  public void fromXML(final Document doc) throws ColorScaleException {
    try {
      clear();

      final XPath xpath = XmlUtils.createXPath();

      name = xpath.evaluate("/ColorMap/@name", doc);

      final Node nodeTitle = (Node) xpath.evaluate("/ColorMap/Title", doc, XPathConstants.NODE);
      if (nodeTitle != null) {
        title = xpath.evaluate("text()", nodeTitle);
      }

      final Node nodeDesc =
          (Node) xpath.evaluate("/ColorMap/Description", doc, XPathConstants.NODE);
      if (nodeDesc != null) {
        description = xpath.evaluate("text()", nodeDesc);
      }

      scaling = Scaling.valueOf(xpath.evaluate("/ColorMap/Scaling/text()", doc));
      final String reliefShadingStr =
          xpath.evaluate("/ColorMap/ReliefShading/text()", doc).toLowerCase();
      reliefShading = reliefShadingStr.equals("1") || reliefShadingStr.equals("true");

      final String interpolateStr =
          xpath.evaluate("/ColorMap/Interpolate/text()", doc).toLowerCase();
      interpolate =
          interpolateStr.isEmpty() || (interpolateStr.equals("1") || interpolateStr.equals("true"));

      final String forceStr =
          xpath.evaluate("/ColorMap/ForceValuesIntoRange/text()", doc).toLowerCase();
      forceValuesIntoRange = (forceStr.equals("1") || forceStr.equals("true"));

      final Node nullColorNode =
          (Node) xpath.evaluate("/ColorMap/NullColor", doc, XPathConstants.NODE);
      if (nullColorNode != null) {
        final String colorStr = xpath.evaluate("@color", nullColorNode);
        final String opacityStr = xpath.evaluate("@opacity", nullColorNode);
        parseColor(colorStr, opacityStr, nullColor);
      }

      final int[] color = new int[4];
      final XPathExpression expr = xpath.compile("/ColorMap/Color");
      final NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
      for (int i = 0; i < nodes.getLength(); i++) {
        final Node node = nodes.item(i);

        final String valueStr = xpath.evaluate("@value", node);
        final String colorStr = xpath.evaluate("@color", node);
        final String opacityStr = xpath.evaluate("@opacity", node);

        if (valueStr.isEmpty()) {
          throw new IOException(
              "Error parsing XML: A value must be specified for a color element.");
        }

        final double value = Double.valueOf(valueStr);
        parseColor(colorStr, opacityStr, color);
        put(value, color);
      }
      cache = null;
    } catch (final Exception e) {
      throw new BadXMLException(e);
    }
  }