コード例 #1
0
ファイル: LightInfo.java プロジェクト: RickKohrs/IDV
  public void getPropertyComponents(List comps, final ObjectListener listener) {
    visibleCbx = new JCheckBox(getName(), visible);
    float[] rgb = color.get().getRGBComponents(null);
    slider = new JSlider(0, 100, (int) (rgb[0] * 100));

    float[] xyz = new float[3];
    direction.get(xyz);
    directionXFld = makeField("" + xyz[0], listener, "X Direction");
    directionYFld = makeField("" + xyz[1], listener, "Y Direction");
    directionZFld = makeField("" + xyz[2], listener, "Z Direction");

    double[] pxyz = new double[3];
    location.get(pxyz);
    locationXFld = makeField("" + pxyz[0], listener, "");
    locationYFld = makeField("" + pxyz[1], listener, "");
    locationZFld = makeField("" + pxyz[2], listener, "");

    List fldComps =
        Misc.newList(GuiUtils.rLabel("Direction:"), directionXFld, directionYFld, directionZFld);
    //
    // fldComps.addAll(Misc.newList(GuiUtils.rLabel("Location:"),locationXFld,locationYFld,locationZFld));

    comps.add(visibleCbx);
    GuiUtils.tmpInsets = new Insets(0, 2, 0, 0);
    comps.add(
        GuiUtils.vbox(
            slider, GuiUtils.left(GuiUtils.doLayout(fldComps, 4, GuiUtils.WT_N, GuiUtils.WT_N))));

    if (listener != null) {
      visibleCbx.addActionListener(listener);
      slider.addChangeListener(listener);
    }
  }
コード例 #2
0
ファイル: LoadBundleDialog.java プロジェクト: Unidata/IDV
  /**
   * Create me
   *
   * @param persistenceManager A reference to the persistence manager in case we need it
   * @param label The label to use in the dialog title
   */
  public LoadBundleDialog(IdvPersistenceManager persistenceManager, String label) {
    dialogTitle = label;
    label = null;
    this.persistenceManager = persistenceManager;
    msgLabel1 = new JLabel(" ");
    msgLabel1.setMinimumSize(new Dimension(250, 20));
    msgLabel1.setPreferredSize(new Dimension(250, 20));
    msgLabel2 = new JLabel(" ");
    msgLabel2.setMinimumSize(new Dimension(250, 20));
    msgLabel2.setPreferredSize(new Dimension(250, 20));

    progressBar = new RovingProgress();
    progressBar.start();
    progressBar.setBorder(BorderFactory.createLineBorder(Color.gray));
    JLabel waitLbl = new JLabel(IdvWindow.getWaitIcon());

    ActionListener buttonListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            removeItems = true;
            // removeItems = ae.getActionCommand().equals(CMD_CANCELANDREMOVE);
            okToRun = false;
            setMessage("Cancelling load. Please wait...");
            Misc.runInABit(
                2000,
                new Runnable() {
                  public void run() {
                    dispose();
                  }
                });
          }
        };
    // String[] cmds = { CMD_CANCELANDREMOVE, GuiUtils.CMD_CANCEL };
    String[] cmds = {GuiUtils.CMD_CANCEL};
    //            String[] tts = { "Press to cancel and remove any loaded items",
    //                             "Press to cancel" };
    String[] tts = {"Press to cancel and remove loaded items"};
    JPanel buttonPanel = GuiUtils.makeButtons(buttonListener, cmds, cmds, tts, null);

    GuiUtils.tmpInsets = GuiUtils.INSETS_2;
    JComponent labelComp =
        GuiUtils.doLayout(
            new Component[] {
              new JLabel("Status:"),
              msgLabel1,
              waitLbl,
              GuiUtils.filler(),
              msgLabel2,
              GuiUtils.filler()
            },
            3,
            GuiUtils.WT_NYN,
            GuiUtils.WT_N);

    contents = GuiUtils.inset(labelComp, 5);
    if (label != null) {
      contents = GuiUtils.topCenter(GuiUtils.cLabel("Loading: " + label), contents);
    }
    //            contents = GuiUtils.vbox(contents,
    //                                     GuiUtils.inset(progressBar, 5),
    //                                     buttonPanel);
    contents = GuiUtils.vbox(contents, buttonPanel);
  }
コード例 #3
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");
  }
コード例 #4
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;
    }
コード例 #5
0
ファイル: StormTrackChart.java プロジェクト: ethanrd/IDV
  /** _more_ */
  protected void createChart() {

    if (madeChart) {
      return;
    }
    madeChart = true;
    final JCheckBox chartDiffCbx = new JCheckBox("Use Difference", chartDifference);
    chartDiffCbx.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            chartDifference = chartDiffCbx.isSelected();
            updateChart();
          }
        });

    chartTimeBox = new JList();
    chartTimeBox.setVisibleRowCount(3);
    chartTimeBox.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    chartTimeBox.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            if (ignoreChartTimeChanges) {
              return;
            }

            updateChart();
          }
        });

    List<StormParam> params = getStormTrackParams();

    Insets inset = new Insets(3, 7, 7, 0);
    List chartComps = new ArrayList();

    List<Way> ways = Misc.sort(stormDisplayState.getTrackCollection().getWayList());
    List wayComps = new ArrayList();
    for (Way way : ways) {
      final Way theWay = way;
      if (way.isObservation() && !chartWays.contains(way)) {
        chartWays.add(way);
      }
      final JCheckBox cbx = new JCheckBox(way.toString(), chartWays.contains(theWay));
      cbx.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              if (cbx.isSelected()) {
                addChartWay(theWay);
              } else {
                removeChartWay(theWay);
              }
            }
          });
      if (!way.isObservation()) {
        wayComps.add(cbx);
      } else {
        wayComps.add(0, cbx);
      }
    }

    chartComps.add(new JLabel(stormDisplayState.getStormTrackControl().getWaysName() + ":"));
    JComponent chartWayComp = GuiUtils.vbox(wayComps);
    if (wayComps.size() > 6) {
      chartWayComp = makeScroller(chartWayComp, 100, 150);
    }
    chartComps.add(GuiUtils.inset(chartWayComp, inset));
    chartComps.add(GuiUtils.lLabel((isHourly() ? "Forecast Hour:" : "Forecast Time:")));
    JScrollPane sp = new JScrollPane(chartTimeBox);
    chartComps.add(GuiUtils.inset(sp, inset));

    List paramComps = new ArrayList();
    for (StormParam param : params) {
      //   if (param.getIsChartParam() == false) {
      //       continue;
      //   }
      final StormParam theParam = param;
      boolean useChartParam = chartParams.contains(theParam);
      final JCheckBox cbx = new JCheckBox(param.toString(), useChartParam);
      cbx.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              if (cbx.isSelected()) {
                addChartParam(theParam);
              } else {
                removeChartParam(theParam);
              }
            }
          });
      paramComps.add(cbx);
    }
    chartComps.add(new JLabel("Parameters:"));
    JComponent paramComp = GuiUtils.vbox(paramComps);
    if (paramComps.size() > 6) {
      paramComp = makeScroller(paramComp, 100, 150);
    }
    chartComps.add(GuiUtils.inset(paramComp, inset));
    chartComps.add(chartDiffCbx);

    JButton removeBtn = GuiUtils.makeButton("Remove Chart", this, "removeChart");
    chartComps.add(GuiUtils.filler(5, 10));
    chartComps.add(removeBtn);

    //        JComponent top = GuiUtils.left(GuiUtils.hbox(
    //                                                     GuiUtils.label("Forecast Time: ",
    // chartTimeBox),
    //                                                     chartDiffCbx));
    //        top = GuiUtils.inset(top,5);
    //        chartTop.add(BorderLayout.NORTH, top);
    JComponent left = GuiUtils.doLayout(chartComps, 1, GuiUtils.WT_N, new double[] {0, 1, 0, 1, 0});
    chartLeft.add(BorderLayout.CENTER, GuiUtils.inset(left, 5));

    chartLeft.invalidate();
    chartLeft.validate();
    chartLeft.repaint();
  }