Пример #1
0
 /**
  * Apply properties
  *
  * @return Was successful
  */
 protected boolean applyProperties() {
   if (!super.applyProperties()) {
     return false;
   }
   try {
     bins = new Integer(binFld.getText().trim()).intValue();
   } catch (NumberFormatException nfe) {
     LogUtil.userErrorMessage("Bad value for bins: " + binFld.getText());
     return false;
   }
   //        stacked = stackedCbx.isSelected();
   return true;
 }
Пример #2
0
 /**
  * Apply properties
  *
  * @return Was successful
  */
 protected boolean applyProperties() {
   if (!super.applyProperties()) {
     return false;
   }
   setLabelShown(labelShownCbx.isSelected());
   setName(propertiesNameFld.getText().trim());
   return true;
 }
Пример #3
0
 /**
  * Pattern widget
  *
  * @return Pattern widget
  */
 public JTextField getPatternWidget() {
   if (patternFld == null) {
     patternFld = new JTextField(pattern, 20);
     patternFld.setToolTipText(
         "<html>A string pattern to match or a comma separated numeric range:<br><i>e.g., -5.0,0</i></html>");
   }
   return patternFld;
 }
Пример #4
0
  /**
   * Apply the properties
   *
   * @param compMap Optional map that holds components
   * @return Success
   * @throws RemoteException On badness
   * @throws VisADException On badness
   */
  protected boolean applyProperties(Hashtable compMap) throws VisADException, RemoteException {
    if (!super.applyProperties(compMap)) {
      return false;
    }
    setStartText(startTextFld.getText().trim());
    setEndText(endTextFld.getText().trim());
    try {
      if (maxDistanceFld != null) {
        Real oldMaxDataDistance = maxDataDistance;
        maxDataDistance = ucar.visad.Util.toReal(maxDistanceFld.getText().trim());
        tvm.setMaxDataDistance(maxDataDistance);
        updateLocation();
      }
    } catch (Exception exc) {
      LogUtil.userErrorMessage("Bad value:" + maxDistanceFld.getText().trim());
      return false;
    }

    return true;
  }
Пример #5
0
 /**
  * Add to the properties list
  *
  * @param comps List of label/widgets
  * @param compMap Optional mapping to hold components for later access
  */
 protected void getPropertiesComponents(List comps, Hashtable compMap) {
   super.getPropertiesComponents(comps, compMap);
   startTextFld = new JTextField(startText, 5);
   endTextFld = new JTextField(endText, 5);
   comps.add(GuiUtils.rLabel("Start Label:"));
   comps.add(GuiUtils.left(startTextFld));
   comps.add(GuiUtils.rLabel("End Label:"));
   comps.add(GuiUtils.left(endTextFld));
   maxDistanceFld = null;
   tvm = null;
   if (viewDescriptor != null) {
     VMManager vmManager = control.getControlContext().getIdv().getVMManager();
     List vms = vmManager.getViewManagers(TransectViewManager.class);
     tvm = (TransectViewManager) VMManager.findViewManagerInList(viewDescriptor, vms);
     if ((tvm != null) && (maxDataDistance != null)) {
       maxDistanceFld =
           new JTextField(maxDataDistance.getValue() + " [" + maxDataDistance.getUnit() + "]", 15);
       maxDistanceFld.setToolTipText("Maximum distance shown. e.g.: value[unit]");
       comps.add(GuiUtils.rLabel("Max distance:"));
       comps.add(GuiUtils.left(maxDistanceFld));
     }
   }
 }
Пример #6
0
    /**
     * Edit row
     *
     * @param paramInfo param info
     * @param removeOnCancel Should remove param info if user presses cancel_
     * @return ok
     */
    public boolean editRow(ParamInfo paramInfo, boolean removeOnCancel) {

      List comps = new ArrayList();
      ParamField nameFld = new ParamField(null, true);
      nameFld.setText(paramInfo.getName());
      JPanel topPanel = GuiUtils.hbox(GuiUtils.lLabel("Parameter:  "), nameFld);
      topPanel = GuiUtils.inset(topPanel, 5);

      comps.add(GuiUtils.inset(new JLabel("Defined"), new Insets(5, 0, 0, 0)));
      comps.add(GuiUtils.filler());
      comps.add(GuiUtils.filler());

      final JLabel ctPreviewLbl = new JLabel("");
      final JLabel ctLbl = new JLabel("");
      if (paramInfo.hasColorTableName()) {
        ctLbl.setText(paramInfo.getColorTableName());
        ColorTable ct =
            getIdv().getColorTableManager().getColorTable(paramInfo.getColorTableName());
        if (ct != null) {
          ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct));
        } else {
          ctPreviewLbl.setIcon(null);
        }
      }
      String cbxLabel = "";
      final ArrayList menus = new ArrayList();
      getIdv()
          .getColorTableManager()
          .makeColorTableMenu(
              new ObjectListener(null) {
                public void actionPerformed(ActionEvent ae, Object data) {
                  ctLbl.setText(data.toString());
                  ColorTable ct = getIdv().getColorTableManager().getColorTable(ctLbl.getText());
                  if (ct != null) {
                    ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct));
                  } else {
                    ctPreviewLbl.setIcon(null);
                  }
                }
              },
              menus);

      JCheckBox ctUseCbx = new JCheckBox(cbxLabel, paramInfo.hasColorTableName());
      final JButton ctPopup = new JButton("Change");
      ctPopup.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              GuiUtils.showPopupMenu(menus, ctPopup);
            }
          });
      addEditComponents(
          comps,
          "Color Table:",
          ctUseCbx,
          GuiUtils.hbox(ctPopup, GuiUtils.vbox(ctLbl, ctPreviewLbl), 5));

      JCheckBox rangeUseCbx = new JCheckBox(cbxLabel, paramInfo.hasRange());
      JTextField minFld = new JTextField("" + paramInfo.getMin(), 4);
      JTextField maxFld = new JTextField("" + paramInfo.getMax(), 4);
      JPanel rangePanel = GuiUtils.hbox(minFld, maxFld, 5);
      addEditComponents(comps, "Range:", rangeUseCbx, rangePanel);

      JCheckBox unitUseCbx = new JCheckBox(cbxLabel, paramInfo.hasDisplayUnit());
      String unitLabel = "";
      Unit unit = null;
      if (paramInfo.hasDisplayUnit()) {
        unit = paramInfo.getDisplayUnit();
      }

      JComboBox unitFld = getIdv().getDisplayConventions().makeUnitBox(unit, null);
      //            JTextField unitFld = new JTextField(unitLabel, 15);
      addEditComponents(comps, "Unit:", unitUseCbx, unitFld);

      ContourInfo ci = paramInfo.getContourInfo();
      JCheckBox contourUseCbx = new JCheckBox(cbxLabel, ci != null);
      if (ci == null) {
        ci = new ContourInfo();
      }
      ContourInfoDialog contDialog =
          new ContourInfoDialog("Edit Contour Defaults", false, null, false);
      contDialog.setState(ci);
      addEditComponents(comps, "Contour:", contourUseCbx, contDialog.getContents());

      GuiUtils.tmpInsets = new Insets(5, 5, 5, 5);
      JComponent contents = GuiUtils.doLayout(comps, 3, GuiUtils.WT_NNY, GuiUtils.WT_N);

      contents = GuiUtils.topCenter(topPanel, contents);
      contents = GuiUtils.inset(contents, 5);
      while (true) {
        if (!GuiUtils.showOkCancelDialog(null, "Parameter Defaults", contents, null)) {
          if (removeOnCancel) {
            myParamInfos.remove(paramInfo);
            tableChanged();
          }
          return false;
        }
        String what = "";
        try {
          if (contourUseCbx.isSelected()) {
            what = "setting contour defaults";
            contDialog.doApply();
            ci.set(contDialog.getInfo());
            paramInfo.setContourInfo(ci);
          } else {
            paramInfo.clearContourInfo();
          }
          if (unitUseCbx.isSelected()) {
            what = "setting display unit";
            Object selected = unitFld.getSelectedItem();
            String unitName = TwoFacedObject.getIdString(selected);
            if ((unitName == null) || unitName.trim().equals("")) {
              paramInfo.setDisplayUnit(null);
            } else {
              paramInfo.setDisplayUnit(ucar.visad.Util.parseUnit(unitName));
            }
          } else {
            paramInfo.setDisplayUnit(null);
          }

          if (ctUseCbx.isSelected()) {
            paramInfo.setColorTableName(ctLbl.getText());
          } else {
            paramInfo.clearColorTableName();
          }

          if (rangeUseCbx.isSelected()) {
            what = "setting range";
            paramInfo.setRange(
                new Range(Misc.parseNumber(minFld.getText()), Misc.parseNumber(maxFld.getText())));
          } else {
            paramInfo.clearRange();
          }

          paramInfo.setName(nameFld.getText().trim());
          break;
        } catch (Exception exc) {
          errorMsg("An error occurred " + what + "\n " + exc.getMessage());
          //              exc.printStackTrace();
        }
      }
      repaint();
      saveData();
      return true;
    }
Пример #7
0
 /** Apply the properties */
 public void applyProperties() {
   range = null;
   pattern = patternFld.getText().trim();
   GuiUtils.ColorSwatch colorSwatch = (GuiUtils.ColorSwatch) getSwatchComps()[0];
   color = colorSwatch.getSwatchColor();
 }