コード例 #1
0
ファイル: NavigatedViewManager.java プロジェクト: ethanrd/IDV
  /**
   * Creates the Viewpoint Toolbar in the specified orientation.
   *
   * @param orientation orientation of the toolbar (JToolBar.VERTICAL or JToolBar.HORIZONTAL)
   * @return the toolbar component
   */
  public Component doMakeViewPointToolBar(int orientation) {
    JToolBar toolbar = getViewpointControl().getToolBar(getToolbarsFloatable());

    toolbar.setOrientation(orientation);

    return GuiUtils.top(toolbar);
  }
コード例 #2
0
    /**
     * Utility method to add components to dialog list
     *
     * @param comps list to add to
     * @param name name
     * @param cbx enable checkbox
     * @param comp the component
     */
    private void addEditComponents(
        List comps, String name, final JCheckBox cbx, final JComponent comp) {
      cbx.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              GuiUtils.enableTree(comp, cbx.isSelected());
            }
          });

      GuiUtils.enableTree(comp, cbx.isSelected());
      comps.add(GuiUtils.top(GuiUtils.inset(cbx, 5)));
      comps.add(GuiUtils.top(GuiUtils.inset(GuiUtils.rLabel(name), new Insets(8, 0, 0, 0))));
      JComponent right = GuiUtils.inset(comp, new Insets(3, 5, 0, 0));
      //            comps.add(GuiUtils.leftCenter(GuiUtils.top(GuiUtils.inset(cbx,
      //                    new Insets(2, 0, 0, 0))), GuiUtils.topLeft(right)));
      comps.add(GuiUtils.topLeft(right));
    }
コード例 #3
0
  /**
   * Returns the data-specific widget for controlling the data-specific aspects of the display.
   *
   * @return The data-specific control-component.
   * @throws RemoteException _more_
   * @throws VisADException _more_
   */
  Component getSpecificWidget() throws VisADException, RemoteException {

    stationMenue = new JComboBox(stationIds);

    // TODO: Check this
    if ((selectedStationIndex >= 0) && (selectedStationIndex < stationIds.length)) {
      stationMenue.setSelectedIndex(selectedStationIndex);
      setStation(selectedStationIndex);
    } else {
      setStation(0);
    }
    stationMenue.setToolTipText("Soundings");

    stationMenue.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            try {
              //                    System.err.println("station menu changed");
              //                    setStation(stationMenue.getSelectedIndex());
              updateHeaderLabel();
            } catch (Exception ex) {
              logException(ex);
            }
          }
        });

    stationMenue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (ignoreStationMenuEvent) {
              return;
            }
            Misc.run(
                new Runnable() {
                  public void run() {
                    try {
                      setStation(stationMenue.getSelectedIndex());
                      Misc.runInABit(
                          250,
                          new Runnable() {
                            public void run() {
                              stationMenue.requestFocus();
                            }
                          });
                      updateHeaderLabel();
                    } catch (Exception ex) {
                      logException(ex);
                    }
                  }
                });
          }
        });

    return GuiUtils.top(GuiUtils.inset(GuiUtils.label("Soundings: ", stationMenue), 8));
  }
コード例 #4
0
 /**
  * Create the editor with the given collection of xml resources
  *
  * @param idv The IDV
  */
 public ParamDefaultsEditor(IntegratedDataViewer idv) {
   super(idv);
   this.resources = getResourceManager().getXmlResources(IdvResourceManager.RSC_PARAMDEFAULTS);
   init(resources);
   if (resources.size() == 0) {
     contents = GuiUtils.top(new JLabel("No resources defined"));
   } else {
     // Initialize the user's writable document (if not created yet)
     resources.getWritableDocument("<" + TAG_PARAMS + "/>");
     init();
   }
 }
コード例 #5
0
ファイル: PointDataSource.java プロジェクト: nbearson/IDV
    /**
     * Make the gui for the data subset panel
     *
     * @return gui for data subset panel
     */
    protected JComponent doMakeContents() {
      GuiUtils.tmpInsets = GuiUtils.INSETS_5;
      String prop = (String) pointDataSource.getProperty(PROP_STATIONMODELNAME);
      if (dataSelection != null) {
        prop = (String) dataSelection.getProperty(PROP_STATIONMODELNAME);
      }
      if (prop != null) {
        pmc.setPlotModelByName((String) prop);
      }

      return GuiUtils.top(GuiUtils.hflow(Misc.newList(new JLabel("Layout Model: "), pmc), 5, 5));
    }
コード例 #6
0
  /**
   * Called by doMakeWindow in DisplayControlImpl, which then calls its doMakeMainButtonPanel(),
   * which makes more buttons.
   *
   * @return container of contents
   */
  public Container doMakeContents() {
    try {
      JTabbedPane tab = new MyTabbedPane();
      tab.add("Settings", GuiUtils.inset(GuiUtils.top(doMakeWidgetComponent()), 5));

      // MH: just add a dummy component to this tab for now..
      //            don't init histogram until the tab is clicked.
      tab.add("Histogram", new JLabel("Histogram not yet initialized"));

      return tab;
    } catch (Exception exc) {
      logException("doMakeContents", exc);
    }
    return null;
  }
コード例 #7
0
ファイル: NavigatedViewManager.java プロジェクト: ethanrd/IDV
  /** Initialize the toolbars for the GUI */
  protected void initToolBars() {
    addToolBar(doMakeZoomPanToolBar(JToolBar.VERTICAL), "zoompan", "Zoom/Pan toolbar");

    JComponent backButton = getCommandManager().getBackButton();
    JComponent forwardButton = getCommandManager().getForwardButton();

    backButton.setToolTipText(
        "<html>Undo the viewpoint/projection change<br>Shift-click to go 10 steps back</html>");
    forwardButton.setToolTipText(
        "<html>Redo the viewpoint/projection change<br>Shift-click to go 10 steps forward</html>");

    JToolBar undoToolbar = new JToolBar(JToolBar.VERTICAL);

    undoToolbar.setFloatable(getToolbarsFloatable());
    undoToolbar.add(backButton);
    undoToolbar.add(forwardButton);
    addToolBar(GuiUtils.top(undoToolbar), "undoredo", "Undo/Redo toolbar");

    // JPanel undoPanel = GuiUtils.inset(GuiUtils.vbox(backButton,
    // forwardButton), new Insets(10, 0, 0, 0));
    // addToolBar(undoPanel, "undoredo", "Undo/Redo toolbar");
  }
コード例 #8
0
ファイル: NavigatedViewManager.java プロジェクト: ethanrd/IDV
  /**
   * Creates the Zoom/Pan Toolbar in the specified orientation.
   *
   * @param orientation orientation of the toolbar (JToolBar.VERTICAL or JToolBar.HORIZONTAL)
   * @return the toolbar component
   */
  protected Component doMakeZoomPanToolBar(int orientation) {
    JToolBar toolbar =
        getNavigatedDisplay().getNavigationToolBar(orientation, getToolbarsFloatable());

    return GuiUtils.top(toolbar);
  }
コード例 #9
0
  public Element saveParameterSet() {
    if (imageDefaults == null) {
      imageDefaults = getImageDefaults();
    }
    if (newCompName.length() == 0) {
      newComponentError("parameter set");
      return null;
    }
    Element newChild = imageDefaultsDocument.createElement(TAG_DEFAULT);
    newChild.setAttribute(ATTR_NAME, newCompName);

    if (datachoice == null) {
      datachoice = getDataChoice();
    }
    dataSource = getDataSource();
    if (!(dataSource.getClass().isInstance(new AddeImageParameterDataSource()))) {
      return newChild;
    }
    AddeImageParameterDataSource testDataSource = (AddeImageParameterDataSource) dataSource;
    List imageList = testDataSource.getDescriptors(datachoice, this.dataSelection);
    int numImages = imageList.size();
    List dateTimes = new ArrayList();
    DateTime thisDT = null;
    if (!(imageList == null)) {
      AddeImageDescriptor aid = null;
      for (int imageNo = 0; imageNo < numImages; imageNo++) {
        aid = (AddeImageDescriptor) (imageList.get(imageNo));
        thisDT = aid.getImageTime();
        if (!(dateTimes.contains(thisDT))) {
          if (thisDT != null) {
            dateTimes.add(thisDT);
          }
        }
      }
      String dateS = "";
      String timeS = "";
      if (!(dateTimes.isEmpty())) {
        thisDT = (DateTime) dateTimes.get(0);
        dateS = thisDT.dateString();
        timeS = thisDT.timeString();
        if (dateTimes.size() > 1) {
          for (int img = 1; img < dateTimes.size(); img++) {
            thisDT = (DateTime) dateTimes.get(img);
            String str = ',' + thisDT.dateString();
            String newString = new String(dateS + str);
            dateS = newString;
            str = ',' + thisDT.timeString();
            newString = new String(timeS + str);
            timeS = newString;
          }
        }
      }
      if (aid != null) {
        String displayUrl = testDataSource.getDisplaySource();
        ImageParameters ip = new ImageParameters(displayUrl);
        List props = ip.getProperties();
        List vals = ip.getValues();
        String server = ip.getServer();
        newChild.setAttribute(ATTR_SERVER, server);
        int num = props.size();
        if (num > 0) {
          String attr = "";
          String val = "";
          for (int i = 0; i < num; i++) {
            attr = (String) (props.get(i));
            if (attr.equals(ATTR_POS)) {
              val = new Integer(numImages - 1).toString();
            } else if (attr.equals(ATTR_DAY)) {
              val = dateS;
            } else if (attr.equals(ATTR_TIME)) {
              val = timeS;
            } else {
              val = (String) (vals.get(i));
            }
            newChild.setAttribute(attr, val);
          }
        }
      }
    }
    Element parent = xmlTree.getSelectedElement();
    if (parent == null) {
      parent = (Element) lastCat;
    }
    if (parent != null) {
      Element exists = XmlUtil.findElement(parent, "default", ATTR_NAME, newCompName);
      if (!(exists == null)) {
        JLabel label = new JLabel("Replace \"" + newCompName + "\"?");
        JPanel contents = GuiUtils.top(GuiUtils.inset(label, newCompName.length() + 12));
        if (!GuiUtils.showOkCancelDialog(null, "Parameter Set Exists", contents, null)) {
          return newChild;
        }
        parent.removeChild(exists);
      }
      parent.appendChild(newChild);
      makeXmlTree();
    }
    try {
      imageDefaults.writeWritable();
    } catch (Exception e) {
      logger.error("write error!", e);
    }
    imageDefaults.setWritableDocument(imageDefaultsDocument, imageDefaultsRoot);
    return newChild;
  }
コード例 #10
0
 private void newComponentError(String comp) {
   JLabel label = new JLabel("Please enter " + comp + " name");
   JPanel contents = GuiUtils.top(GuiUtils.inset(label, 24));
   GuiUtils.showOkCancelDialog(null, "Make Component Error", contents, null);
 }
コード例 #11
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");
  }