Пример #1
0
  /**
   * add to properties
   *
   * @param comps comps
   */
  public void getPropertiesComponents(List comps) {
    super.getPropertiesComponents(comps);
    binWidthField = new TimeLengthField("Bin Width", true);
    binRoundToField = new TimeLengthField("Bin Round To", true);
    binWidthField.setTime(binWidth);
    binRoundToField.setTime(binRoundTo);
    List roundToItems =
        Misc.toList(
            new Object[] {
              new TwoFacedObject("Change", new Double(0)),
              new TwoFacedObject("On the hour", new Double(60)),
              new TwoFacedObject("5 after", new Double(5)),
              new TwoFacedObject("10 after", new Double(10)),
              new TwoFacedObject("15 after", new Double(15)),
              new TwoFacedObject("20 after", new Double(20)),
              new TwoFacedObject("30 after", new Double(30)),
              new TwoFacedObject("45 after", new Double(45)),
              new TwoFacedObject("10 to", new Double(50)),
              new TwoFacedObject("5 to", new Double(55))
            });

    roundToCbx =
        GuiUtils.makeComboBox(
            roundToItems, roundToItems.get(0), false, this, "setRoundToFromComboBox");

    List widthItems =
        Misc.toList(
            new Object[] {
              new TwoFacedObject("Change", new Double(0)),
              new TwoFacedObject("5 minutes", new Double(5)),
              new TwoFacedObject("10 minutes", new Double(10)),
              new TwoFacedObject("15 minutes", new Double(15)),
              new TwoFacedObject("20 minutes", new Double(20)),
              new TwoFacedObject("30 minutes", new Double(30)),
              new TwoFacedObject("45 minutes", new Double(45)),
              new TwoFacedObject("1 hour", new Double(60)),
              new TwoFacedObject("6 hours", new Double(60 * 6)),
              new TwoFacedObject("12 hours", new Double(60 * 12)),
              new TwoFacedObject("1 day", new Double(60 * 24))
            });

    widthCbx =
        GuiUtils.makeComboBox(widthItems, widthItems.get(0), false, this, "setWidthFromComboBox");

    comps.add(GuiUtils.filler());
    comps.add(getPropertiesHeader("Time Binning"));

    comps.add(GuiUtils.rLabel("Bin Size:"));
    comps.add(GuiUtils.left(GuiUtils.hbox(binWidthField.getContents(), widthCbx, 5)));
    comps.add(GuiUtils.rLabel("Round To:"));
    comps.add(GuiUtils.left(GuiUtils.hbox(binRoundToField.getContents(), roundToCbx, 5)));
  }
Пример #2
0
  /**
   * Add components to properties dialog
   *
   * @param comps List of components
   * @param tabIdx Which tab in properties dialog
   */
  protected void getPropertiesComponents(List comps, int tabIdx) {
    super.getPropertiesComponents(comps, tabIdx);
    if (tabIdx != 0) {
      return;
    }
    comps.add(GuiUtils.rLabel("Histogram: "));

    comps.add(
        GuiUtils.left(
            GuiUtils.hbox(
                Misc.newList(new JLabel("Number of Bins: "), binFld = new JTextField("" + bins, 6)),
                4)));
    //                                             new JLabel("      Stacked: "),
    // stackedCbx = new JCheckBox("",stacked)),4)));
  }
Пример #3
0
  /**
   * Create the 'Connect' button.
   *
   * @return The connect button.
   */
  protected JComponent getConnectButton() {
    JButton connectBtn = new JButton("Connect");
    connectBtn.setActionCommand(CMD_CONNECT);
    connectBtn.addActionListener(this);
    JComponent buttonComp = connectBtn;
    registerStatusComp("connect", buttonComp);
    if (canDoCancel()) {
      cancelButton = GuiUtils.getImageButton("/auxdata/ui/icons/Exit16.gif", getClass());
      cancelButton.setEnabled(false);
      cancelButton.setActionCommand(GuiUtils.CMD_CANCEL);
      cancelButton.addActionListener(this);
      buttonComp = GuiUtils.hbox(buttonComp, cancelButton);
    }

    return buttonComp;
    //        return connectBtn;
  }
Пример #4
0
  /**
   * Create and return the Gui contents.
   *
   * @return The gui contents.
   */
  protected JComponent doMakeContents() {
    //        dataSelector = new DataSelector(getIdv(), new Dimension(400, 200),
    //                                        true);

    // Get the list of catalogs but remove the old catalog.xml entry
    urlListHandler = getPreferenceList(PREF_CATALOGLIST);
    final XmlChooser xmlChooser = this;
    ActionListener catListListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            if (!okToDoUrlListEvents) {
              return;
            }
            xmlChooser.actionPerformed(ae);
          }
        };
    urlBox = urlListHandler.createComboBox(GuiUtils.CMD_UPDATE, catListListener, true);

    GuiUtils.setPreferredWidth(urlBox, 200);

    // top panel
    JButton browseButton = new JButton("Select File...");
    browseButton.setToolTipText("Choose a catalog from disk");
    browseButton.setActionCommand(CMD_BROWSE);
    browseButton.addActionListener(this);

    GuiUtils.setHFill();
    JPanel catListPanel =
        GuiUtils.doLayout(new Component[] {urlBox}, 1, GuiUtils.WT_Y, GuiUtils.WT_N);

    backBtn =
        GuiUtils.getImageButton(GuiUtils.getImageIcon("/auxdata/ui/icons/Left16.gif", getClass()));
    backBtn.setToolTipText("View previous selection");
    GuiUtils.makeMouseOverBorder(backBtn);
    backBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            goBack();
          }
        });

    fwdBtn =
        GuiUtils.getImageButton(GuiUtils.getImageIcon("/auxdata/ui/icons/Right16.gif", getClass()));
    GuiUtils.makeMouseOverBorder(fwdBtn);
    fwdBtn.setToolTipText("View next selection");
    fwdBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            goForward();
          }
        });

    checkButtons();
    JComponent bottomButtons = getDefaultButtons();
    handlerHolder = new JPanel();
    handlerHolder.setLayout(new BorderLayout());
    //        JPanel tmp = new JPanel();
    //        tmp.setPreferredSize(new Dimension(200,500));
    //        handlerHolder.add(tmp, BorderLayout.CENTER);

    if (getIdv().getArgsManager().getInitCatalogs().size() > 0) {
      initialUrlPath = (String) getIdv().getArgsManager().getInitCatalogs().get(0);
      urlBox.setSelectedItem(initialUrlPath);
    } else {
      if ((initialUrlPath != null) && (initialUrlPath.length() > 0)) {
        makeUiFromPath(initialUrlPath);
      } else {
        makeBlankTree();
      }
    }
    JPanel navButtons = GuiUtils.hbox(backBtn, fwdBtn);

    GuiUtils.tmpInsets = GRID_INSETS;
    JPanel catPanel =
        GuiUtils.doLayout(
            new Component[] {new JLabel("Catalogs:"), catListPanel, browseButton},
            3,
            GuiUtils.WT_NYN,
            GuiUtils.WT_N);
    JPanel topPanel = GuiUtils.leftCenter(navButtons, catPanel);
    myContents = GuiUtils.topCenterBottom(topPanel, handlerHolder, bottomButtons);
    //        myContents = GuiUtils.topCenter(getStatusComponent(), myContents);
    return myContents;
  }
Пример #5
0
  /**
   * Create a new ProjectionManager.
   *
   * @param parent JFrame (application) or JApplet (applet)
   * @param projections list of initial projections
   * @param makeDialog true to make this a dialog
   * @param helpId help id if dialog
   * @param maps List of MapData
   */
  public ProjectionManager(
      RootPaneContainer parent, List projections, boolean makeDialog, String helpId, List maps) {

    this.helpId = helpId;
    this.maps = maps;
    this.parent = parent;

    // manage NewProjectionListeners
    lm =
        new ListenerManager(
            "java.beans.PropertyChangeListener",
            "java.beans.PropertyChangeEvent",
            "propertyChange");

    // here's where the map will be drawn: but cant be changed/edited
    npViewControl = new NPController();
    if (maps == null) {
      maps = getDefaultMaps(); // we use the system default
    }
    for (int mapIdx = 0; mapIdx < maps.size(); mapIdx++) {
      MapData mapData = (MapData) maps.get(mapIdx);
      if (mapData.getVisible()) {
        npViewControl.addMap(mapData.getSource(), mapData.getColor());
      }
    }
    mapViewPanel = npViewControl.getNavigatedPanel();
    mapViewPanel.setPreferredSize(new Dimension(250, 250));
    mapViewPanel.setToolTipText("Shows the default zoom of the current projection");
    mapViewPanel.setChangeable(false);

    if ((projections == null) || (projections.size() == 0)) {
      projections = makeDefaultProjections();
    }

    // the actual list is a JTable subclass
    projTable = new JTableProjection(this, projections);

    JComponent listContents = new JScrollPane(projTable);

    JComponent buttons =
        GuiUtils.hbox(
            GuiUtils.makeButton("Edit", this, "doEdit"),
            GuiUtils.makeButton("New", this, "doNew"),
            GuiUtils.makeButton("Export", this, "doExport"),
            GuiUtils.makeButton("Delete", this, "doDelete"));

    mapLabel = new JLabel(" ");
    JComponent leftPanel = GuiUtils.inset(GuiUtils.topCenter(mapLabel, mapViewPanel), 5);

    JComponent rightPanel = GuiUtils.topCenter(buttons, listContents);
    rightPanel = GuiUtils.inset(rightPanel, 5);
    contents = GuiUtils.inset(GuiUtils.hbox(leftPanel, rightPanel), 5);

    // default current and working projection
    if (null != (current = projTable.getSelected())) {
      setWorkingProjection(current);
      projTable.setCurrentProjection(current);
      mapLabel.setText(current.getName());
    }

    /* listen for new working Projections from projTable */
    projTable.addNewProjectionListener(
        new NewProjectionListener() {
          public void actionPerformed(NewProjectionEvent e) {
            if (e.getProjection() != null) {
              setWorkingProjection(e.getProjection());
            }
          }
        });

    eventsOK = true;

    // put it together in the viewDialog
    if (makeDialog) {
      Container buttPanel = GuiUtils.makeApplyOkHelpCancelButtons(this);
      contents = GuiUtils.centerBottom(contents, buttPanel);
      viewDialog =
          GuiUtils.createDialog(GuiUtils.getApplicationTitle() + "Projection Manager", false);
      viewDialog.getContentPane().add(contents);
      viewDialog.pack();
      ucar.unidata.util.Msg.translateTree(viewDialog);
      viewDialog.setLocation(100, 100);
    }
  }
Пример #6
0
 /**
  * Add to the given comps list all the status line and server components.
  *
  * @param comps List of comps to add to
  * @param label The label to add after the server selector
  * @param extra The component to add after the label (usually a combobox)
  */
 protected void addTopComponents(List comps, String label, JComponent extra) {
   addTopComponents(comps, GuiUtils.hbox(padLabel(label), extra, GRID_SPACING));
 }
Пример #7
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;
    }
Пример #8
0
  private void showSaveDialog() {
    if (saveWindow == null) {
      saveWindow = GuiUtils.createFrame("Save Image Parameter Set");
    }
    if (statusComp == null) {
      statusLabel = new JLabel();
      statusComp = GuiUtils.inset(statusLabel, 2);
      statusComp.setBackground(new Color(255, 255, 204));
      statusLabel.setOpaque(true);
      statusLabel.setBackground(new Color(255, 255, 204));
    }
    JPanel statusPanel =
        GuiUtils.inset(
            GuiUtils.top(
                GuiUtils.vbox(
                    new JLabel(" "),
                    GuiUtils.hbox(GuiUtils.rLabel("Status: "), statusComp),
                    new JLabel(" "))),
            6);
    JPanel sPanel = GuiUtils.topCenter(statusPanel, GuiUtils.filler());

    List newComps = new ArrayList();
    final JTextField newName = new JTextField(20);
    newName.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            setStatus("Click New Folder or New ParameterSet button");
            newCompName = newName.getText().trim();
          }
        });
    newComps.add(newName);
    newComps.add(GuiUtils.filler());
    newFolderBtn = new JButton("New Folder");
    newFolderBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            newFolder = newName.getText().trim();
            if (newFolder.length() == 0) {
              newComponentError("folder");
              return;
            }
            Element exists = XmlUtil.findElement(imageDefaultsRoot, "folder", ATTR_NAME, newFolder);
            if (!(exists == null)) {
              if (!GuiUtils.askYesNo(
                  "Verify Replace Folder",
                  "Do you want to replace the folder "
                      + "\""
                      + newFolder
                      + "\"?"
                      + "\nNOTE: All parameter sets it contains will be deleted.")) return;
              imageDefaultsRoot.removeChild(exists);
            }
            newName.setText("");
            Node newEle = makeNewFolder();
            makeXmlTree();
            xmlTree.selectElement((Element) newEle);
            lastCat = newEle;
            lastClicked = null;
            newSetBtn.setEnabled(true);
            setStatus("Please enter a name for the new parameter set");
          }
        });
    newComps.add(newFolderBtn);
    newComps.add(GuiUtils.filler());
    newName.setEnabled(true);
    newFolderBtn.setEnabled(true);
    newSetBtn = new JButton("New Parameter Set");
    newSetBtn.setActionCommand(CMD_NEWPARASET);
    newSetBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            newCompName = newName.getText().trim();
            if (newCompName.length() == 0) {
              newComponentError("parameter set");
              return;
            }
            newName.setText("");
            Element newEle = saveParameterSet();
            if (newEle == null) return;
            xmlTree.selectElement(newEle);
            lastClicked = newEle;
          }
        });
    newComps.add(newSetBtn);
    newSetBtn.setEnabled(false);

    JPanel newPanel = GuiUtils.top(GuiUtils.left(GuiUtils.hbox(newComps)));
    JPanel topPanel = GuiUtils.topCenter(sPanel, newPanel);

    treePanel = new JPanel();
    treePanel.setLayout(new BorderLayout());
    makeXmlTree();
    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            String cmd = event.getActionCommand();
            if (cmd.equals(GuiUtils.CMD_CANCEL)) {
              if (lastClicked != null) {
                removeNode(lastClicked);
                lastClicked = null;
              }
              saveWindow.setVisible(false);
              saveWindow = null;
            } else {
              saveWindow.setVisible(false);
              saveWindow = null;
            }
          }
        };
    JPanel bottom = GuiUtils.inset(GuiUtils.makeApplyCancelButtons(listener), 5);
    contents = GuiUtils.topCenterBottom(topPanel, treePanel, bottom);

    saveWindow.getContentPane().add(contents);
    saveWindow.pack();
    saveWindow.setLocation(200, 200);

    saveWindow.setVisible(true);
    GuiUtils.toFront(saveWindow);
    setStatus("Please select a folder from tree, or create a new folder");
  }
Пример #9
0
 /**
  * ctor
  *
  * @param pointDataSource the associated data source
  */
 public GridParameters(PointDataSource pointDataSource) {
   super("Grid Parameters");
   this.pointDataSource = pointDataSource;
   gridXFld = new JTextField("" + pointDataSource.gridX, 4);
   gridXFld.setToolTipText("X spacing in spacing units");
   gridYFld = new JTextField("" + pointDataSource.gridY, 4);
   gridYFld.setToolTipText("Y spacing in spacing units");
   gridUnitCmbx = new JComboBox();
   gridUnitCmbx.setToolTipText("Set grid spacing option");
   tfos = TwoFacedObject.createList(SPACING_IDS, SPACING_NAMES);
   GuiUtils.setListData(gridUnitCmbx, tfos);
   gridUnitCmbx.setSelectedItem(TwoFacedObject.findId(pointDataSource.gridUnit, tfos));
   gridUnitCmbx.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
           TwoFacedObject tfo = (TwoFacedObject) ((JComboBox) ae.getSource()).getSelectedItem();
           if (tfo != null) {
             useCompute = tfo.getId().equals(SPACING_IDS[0]);
             enableAutoComps(!useCompute);
           }
         }
       });
   gainComp =
       new ValueSliderComponent(
           pointDataSource,
           0,
           1,
           "gridGain",
           "Gain",
           10,
           false,
           "Factor by which scaleLength is reduced for the second pass");
   searchComp =
       new ValueSliderComponent(
           pointDataSource,
           0,
           20,
           "gridSearchRadius",
           "Search Radius",
           1,
           false,
           "Search radius in grid units for weighting");
   numGridPassesFld = new JTextField("" + pointDataSource.numGridPasses, 4);
   numGridPassesFld.setToolTipText("Set the number of passes for the Barnes analysis");
   comps.add(GuiUtils.rLabel("Spacing:"));
   comps.add(GuiUtils.left(gridUnitCmbx));
   comps.add(GuiUtils.rLabel("Grid Size:"));
   sizeComp =
       GuiUtils.left(GuiUtils.hbox(new JLabel("X: "), gridXFld, new JLabel("  Y: "), gridYFld));
   comps.add(sizeComp);
   comps.add(GuiUtils.rLabel("Passes:"));
   comps.add(GuiUtils.left(numGridPassesFld));
   comps.add(GuiUtils.rLabel("Search Radius:"));
   comps.add(GuiUtils.left(searchComp.getContents(false)));
   comps.add(GuiUtils.rLabel("Gain:"));
   comps.add(GuiUtils.left(gainComp.getContents(false)));
   enableAutoComps(!useCompute);
   useDefaultCbx.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
           checkEnable();
         }
       });
 }
Пример #10
0
 /**
  * Make the color widget
  *
  * @return color widget
  */
 public JComponent getColorWidget() {
   getSwatchComps();
   return GuiUtils.hbox(swatchComps[0], swatchComps[2]);
 }