Ejemplo n.º 1
0
  /**
   * Create the param infos from the given xml root
   *
   * @param root The xml root
   * @param overwriteOk Ok to overwrite an existing one
   */
  private void loadParamDefaults(Element root, boolean overwriteOk) {
    List listOfInfos = createParamInfoList(root);
    for (int i = 0; i < listOfInfos.size(); i++) {
      ParamInfo newParamInfo = (ParamInfo) listOfInfos.get(i);
      String paramName = newParamInfo.getName();
      if (!overwriteOk && (paramToInfo.get(paramName) != null)) {
        continue;
      }

      ParamInfo oldParamInfo = (ParamInfo) paramToInfo.get(paramName);
      if (oldParamInfo == null) {
        paramToInfo.put(paramName, newParamInfo);
        paramInfos.add(newParamInfo);
      } else {
        if (!oldParamInfo.hasColorTableName()) {
          oldParamInfo.setColorTableName(newParamInfo.getColorTableName());
        }
        if (!oldParamInfo.hasRange()) {
          oldParamInfo.setRange(newParamInfo.getRange());
        }
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * Create xml dom from the given list of {@link ucar.unidata.idv.ui.ParamInfo}-s
  *
  * @param doc The document to write to
  * @param paramInfos List of param infos
  * @return Root xml element
  */
 private Element createDom(Document doc, List paramInfos) {
   Element root = doc.createElement(TAG_PARAMS);
   for (int i = 0; i < paramInfos.size(); i++) {
     ParamInfo paramInfo = (ParamInfo) paramInfos.get(i);
     if (paramInfo.getName().trim().length() == 0) {
       continue;
     }
     Element node = doc.createElement(TAG_PARAM);
     node.setAttribute(ATTR_NAME, paramInfo.getName());
     if (paramInfo.hasColorTableName()) {
       node.setAttribute(ATTR_COLORTABLE, paramInfo.getColorTableName());
     }
     if (paramInfo.hasRange()) {
       node.setAttribute(ATTR_RANGE_MIN, "" + paramInfo.getRange().getMin());
       node.setAttribute(ATTR_RANGE_MAX, "" + paramInfo.getRange().getMax());
     }
     if (paramInfo.hasDisplayUnit()) {
       node.setAttribute(ATTR_UNIT, "" + paramInfo.getDisplayUnit());
     }
     if (paramInfo.hasContourInfo()) {
       ContourInfo ci = paramInfo.getContourInfo();
       node.setAttribute(ATTR_CI_INTERVAL, "" + ci.getIntervalString(true));
       node.setAttribute(ATTR_CI_BASE, "" + ci.getBase());
       node.setAttribute(ATTR_CI_MIN, "" + ci.getMin());
       node.setAttribute(ATTR_CI_MAX, "" + ci.getMax());
       if (ci.getDashOn() != DFLT_CI_DASH) {
         node.setAttribute(ATTR_CI_DASH, "" + ci.getDashOn());
       }
       if (ci.getIsLabeled() != DFLT_CI_LABEL) {
         node.setAttribute(ATTR_CI_LABEL, "" + ci.getIsLabeled());
       }
       node.setAttribute(ATTR_CI_WIDTH, "" + ci.getLineWidth());
     }
     root.appendChild(node);
   }
   return root;
 }
Ejemplo n.º 3
0
 /**
  * Returns a Range based on the parameter name (e.g., rh, t, etc.)
  *
  * @param paramName Name to look for
  * @return The {@link ucar.unidata.util.Range} found or null
  */
 public Range getParamRange(String paramName) {
   ParamInfo paramInfo = getParamInfo(paramName);
   return ((paramInfo != null) ? paramInfo.getRange() : null);
 }