Exemplo n.º 1
0
  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);
    }
  }
Exemplo n.º 2
0
  /**
   * Initialize the contents
   *
   * @param showDialog true to show the dialog
   */
  private void doMakeContents(boolean showDialog) {
    placementBox = new JComboBox(positions);
    colorSwatch =
        new ColorSwatchComponent(
            displayControl.getIdv().getStore(), myInfo.getLabelColor(), "Color Scale Label Color");
    final JComponent colorComp = colorSwatch.getSetPanel();
    visibilityCbx = new JCheckBox("", myInfo.getIsVisible());
    unitCbx = new JCheckBox("Show Unit", myInfo.isUnitVisible());
    alphaCbx = new JCheckBox("", myInfo.getUseAlpha());
    fontSelector = new FontSelector(FontSelector.COMBOBOX_UI, false, false);
    fontSelector.setFont(myInfo.getLabelFont());

    labelVisibilityCbx = new JCheckBox("Visible", myInfo.getLabelVisible());
    labelVisibilityCbx.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean showLabel = ((JCheckBox) e.getSource()).isSelected();
            GuiUtils.enableTree(fontSelector.getComponent(), showLabel);
            GuiUtils.enableTree(colorComp, showLabel);
          }
        });
    GuiUtils.tmpInsets = new Insets(4, 4, 4, 4);
    contents =
        GuiUtils.doLayout(
            new Component[] {
              GuiUtils.rLabel("Visible: "),
              visibilityCbx,
              // GuiUtils.leftRight(visibilityCbx, GuiUtils.flow( new Component[] {GuiUtils.rLabel("
              //  Show Transparency: "), alphaCbx})),
              GuiUtils.rLabel("Position: "),
              GuiUtils.leftRight(placementBox, GuiUtils.filler()),
              GuiUtils.rLabel("Labels: "),
              GuiUtils.leftRight(labelVisibilityCbx, GuiUtils.filler()),
              GuiUtils.filler(),
              GuiUtils.leftRight(unitCbx, GuiUtils.filler()),
              GuiUtils.filler(),
              GuiUtils.leftRight(GuiUtils.rLabel("Font: "), fontSelector.getComponent()),
              GuiUtils.filler(),
              GuiUtils.leftRight(
                  GuiUtils.rLabel("Color: "), GuiUtils.leftRight(colorComp, GuiUtils.filler())),
            },
            2,
            GuiUtils.WT_NY,
            GuiUtils.WT_N);
    contents = GuiUtils.leftRight(contents, GuiUtils.filler());
    if (showDialog) {
      JPanel buttons;
      if (displayControl != null) {
        buttons = GuiUtils.makeApplyOkCancelButtons(this);
      } else {
        buttons = GuiUtils.makeOkCancelButtons(this);
      }
      dialog.getContentPane().add(GuiUtils.centerBottom(contents, buttons));
      GuiUtils.packInCenter(dialog);
    }
  }
Exemplo n.º 3
0
 /**
  * Add the Grid Fields component to the properties tab
  *
  * @param tabbedPane properties tab
  */
 public void addPropertiesTabs(JTabbedPane tabbedPane) {
   super.addPropertiesTabs(tabbedPane);
   List comps = new ArrayList();
   gridProperties = new GridParameters(this);
   makeGridFieldsCbx = new JCheckBox("Make Grid Fields", makeGridFields);
   comps.add(GuiUtils.filler());
   comps.add(GuiUtils.left(makeGridFieldsCbx));
   comps.addAll(gridProperties.comps);
   GuiUtils.tmpInsets = GuiUtils.INSETS_5;
   tabbedPane.addTab(
       "Objective Analysis",
       GuiUtils.topLeft(GuiUtils.doLayout(comps, 2, GuiUtils.WT_NN, GuiUtils.WT_N)));
 }
Exemplo n.º 4
0
  /**
   * This method checks if the current server is valid. If it is valid then it checks if there is
   * authentication required
   *
   * @return true if the server exists and can be accessed
   */
  protected boolean canAccessServer() {
    // Try reading the public.serv file to see if we need a username/proj
    JTextField projFld = null;
    JTextField userFld = null;
    JComponent contents = null;
    JLabel label = null;
    boolean firstTime = true;
    while (true) {
      int status = checkIfServerIsOk();
      if (status == STATUS_OK) {
        break;
      }
      if (status == STATUS_ERROR) {
        setState(STATE_UNCONNECTED);
        return false;
      }
      if (projFld == null) {
        projFld = new JTextField("", 10);
        userFld = new JTextField("", 10);
        GuiUtils.tmpInsets = GuiUtils.INSETS_5;
        contents =
            GuiUtils.doLayout(
                new Component[] {
                  GuiUtils.rLabel("User ID:"), userFld, GuiUtils.rLabel("Project #:"), projFld,
                },
                2,
                GuiUtils.WT_N,
                GuiUtils.WT_N);
        label = new JLabel(" ");
        contents = GuiUtils.topCenter(label, contents);
        contents = GuiUtils.inset(contents, 5);
      }
      String lbl =
          (firstTime
              ? "The server: " + getServer() + " requires a user ID & project number for access"
              : "Authentication for server: " + getServer() + " failed. Please try again");
      label.setText(lbl);

      if (!GuiUtils.showOkCancelDialog(null, "ADDE Project/User name", contents, null)) {
        setState(STATE_UNCONNECTED);
        return false;
      }
      firstTime = false;
      String userName = userFld.getText().trim();
      String project = projFld.getText().trim();
      if ((userName.length() > 0) && (project.length() > 0)) {
        passwords.put(getServer(), new String[] {userName, project});
      }
    }
    return true;
  }
Exemplo n.º 5
0
 /**
  * Add to the given comps list all the status line and server components.
  *
  * @param comps List of comps to add to
  * @param extra The components after the server box if non-null.
  */
 protected void addTopComponents(List comps, Component extra) {
   if (extra == null) {
     extra = GuiUtils.filler();
   }
   comps.add(GuiUtils.rLabel(LABEL_SERVER));
   GuiUtils.tmpInsets = GRID_INSETS;
   JPanel right =
       GuiUtils.doLayout(
           new Component[] {serverSelector, extra, getConnectButton()},
           3,
           GuiUtils.WT_YN,
           GuiUtils.WT_N);
   comps.add(GuiUtils.left(right));
 }
Exemplo n.º 6
0
    /**
     * Set the fields from the ProjectionClass
     *
     * @param projClass projection class to use
     */
    private void setFieldsWithClassParams(ProjectionClass projClass) {

      // set the projection in the JComboBox
      String want = projClass.toString();
      for (int i = 0; i < projClassCB.getItemCount(); i++) {
        ProjectionClass pc = (ProjectionClass) projClassCB.getItemAt(i);
        if (pc.toString().equals(want)) {
          projClassCB.setSelectedItem((Object) pc);
          break;
        }
      }

      // set the parameter fields
      paramPanel.removeAll();
      paramPanel.setVisible(0 < projClass.paramList.size());

      List widgets = new ArrayList();
      for (int i = 0; i < projClass.paramList.size(); i++) {
        ProjectionParam pp = (ProjectionParam) projClass.paramList.get(i);
        // construct the label
        String name = pp.name;
        String text = "";
        // Create a decent looking label
        for (int cIdx = 0; cIdx < name.length(); cIdx++) {
          char c = name.charAt(cIdx);
          if (cIdx == 0) {
            c = Character.toUpperCase(c);
          } else {
            if (Character.isUpperCase(c)) {
              text += " ";
              c = Character.toLowerCase(c);
            }
          }
          text += c;
        }
        widgets.add(GuiUtils.rLabel(text + ": "));
        // text input field
        JTextField tf = new JTextField();
        pp.setTextField(tf);
        tf.setColumns(12);
        widgets.add(tf);
      }
      GuiUtils.tmpInsets = new Insets(4, 4, 4, 4);
      JPanel widgetPanel = GuiUtils.doLayout(widgets, 2, GuiUtils.WT_N, GuiUtils.WT_N);

      paramPanel.add("North", widgetPanel);
      paramPanel.add("Center", GuiUtils.filler());
    }
Exemplo n.º 7
0
 private void doRename(Element node) {
   if (imageDefaults == null) {
     imageDefaults = getImageDefaults();
   }
   if (!node.hasAttribute(ATTR_NAME)) return;
   JLabel label = new JLabel("New name: ");
   JTextField nameFld = new JTextField("", 20);
   JComponent contents =
       GuiUtils.doLayout(
           new Component[] {
             GuiUtils.rLabel("New name: "), nameFld,
           },
           2,
           GuiUtils.WT_N,
           GuiUtils.WT_N);
   contents = GuiUtils.center(contents);
   contents = GuiUtils.inset(contents, 10);
   if (!GuiUtils.showOkCancelDialog(
       null, "Rename \"" + node.getAttribute("name") + "\"", contents, null)) return;
   String newName = nameFld.getText().trim();
   String tagName = node.getTagName();
   Element root = imageDefaultsRoot;
   if (tagName.equals("default")) {
     root = (Element) node.getParentNode();
   }
   Element exists = XmlUtil.findElement(root, tagName, ATTR_NAME, newName);
   if (!(exists == null)) {
     if (!GuiUtils.askYesNo(
         "Name Already Exists",
         "Do you want to replace " + node.getAttribute("name") + " with" + "\"" + newName + "\"?"))
       return;
   }
   node.removeAttribute(ATTR_NAME);
   node.setAttribute(ATTR_NAME, newName);
   makeXmlTree();
   try {
     imageDefaults.writeWritable();
   } catch (Exception e) {
     logger.error("write error!", e);
   }
   imageDefaults.setWritableDocument(imageDefaultsDocument, imageDefaultsRoot);
 }
Exemplo n.º 8
0
    /**
     * Make the gui for the field selector
     *
     * @return gui for field selector
     */
    protected JComponent doMakeContents() {
      GuiUtils.tmpInsets = GuiUtils.INSETS_5;
      comp = GuiUtils.doLayout(comps, 2, GuiUtils.WT_N, GuiUtils.WT_N);
      if (dataSelection != null) {
        Object prop;
        prop = dataSelection.getProperty(PROP_GRID_X);
        if (prop != null) {
          gridXFld.setText("" + prop);
          // If we have a data selection property then turn of cbx
          useDefaultCbx.setSelected(false);
        }
        prop = dataSelection.getProperty(PROP_GRID_Y);
        if (prop != null) {
          gridYFld.setText("" + prop);
        }

        prop = dataSelection.getProperty(PROP_GRID_UNIT);
        if (prop != null) {
          gridUnitCmbx.setSelectedItem(TwoFacedObject.findId(prop, tfos));
        }
        prop = dataSelection.getProperty(PROP_GRID_NUMPASSES);
        if (prop != null) {
          numGridPassesFld.setText("" + prop);
        }
        prop = dataSelection.getProperty(PROP_GRID_GAIN);
        if (prop != null) {
          gainComp.setValue(((Number) prop).floatValue());
        }
        prop = dataSelection.getProperty(PROP_GRID_SEARCH_RADIUS);
        if (prop != null) {
          searchComp.setValue(((Number) prop).floatValue());
        }
      }

      checkEnable();
      return GuiUtils.topCenter(GuiUtils.right(useDefaultCbx), GuiUtils.topLeft(comp));
    }
Exemplo n.º 9
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;
  }
Exemplo n.º 10
0
  /**
   * Make the UI for this widget.
   *
   * @param floatToolBar true if the toolbar should be floatable
   * @return UI as a Component
   */
  private JComponent doMakeContents(boolean floatToolBar) {

    String imgp = "/auxdata/ui/icons/";
    KeyListener listener =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if ((e.getSource() instanceof JComboBox)) {
              return;
            }
            int code = e.getKeyCode();
            char c = e.getKeyChar();
            if ((code == KeyEvent.VK_RIGHT) || (code == KeyEvent.VK_KP_RIGHT)) {
              if (e.isShiftDown()) {
                gotoIndex(anime.getNumSteps() - 1);
              } else {
                actionPerformed(CMD_FORWARD);
              }
            } else if ((code == KeyEvent.VK_LEFT) || (code == KeyEvent.VK_KP_LEFT)) {
              if (e.isShiftDown()) {
                gotoIndex(0);
              } else {
                actionPerformed(CMD_BACKWARD);
              }
            } else if (code == KeyEvent.VK_ENTER) {
              actionPerformed(CMD_STARTSTOP);
            } else if ((code == KeyEvent.VK_P) && e.isControlDown()) {
              actionPerformed(CMD_PROPS);
            } else if (Character.isDigit(c)) {
              int step = new Integer("" + c).intValue() - 1;
              if (step < 0) {
                step = 0;
              }
              if (step >= anime.getNumSteps()) {
                step = anime.getNumSteps() - 1;
              }
              gotoIndex(step);
            }
          }
        };

    List buttonList = new ArrayList();
    buttonList.add(timesCbx);
    // Update the list of times
    setTimesInTimesBox();

    Dimension preferredSize = timesCbx.getPreferredSize();
    if (preferredSize != null) {
      int height = preferredSize.height;
      if (height < 50) {
        JComponent filler = GuiUtils.filler(3, height);
        buttonList.add(filler);
      }
    }

    String[][] buttonInfo = {
      {"Go to first frame", CMD_BEGINNING, getIcon("Rewind")},
      {"One frame back", CMD_BACKWARD, getIcon("StepBack")},
      {"Run/Stop", CMD_STARTSTOP, getIcon("Play")},
      {"One frame forward", CMD_FORWARD, getIcon("StepForward")},
      {"Go to last frame", CMD_END, getIcon("FastForward")},
      {"Properties", CMD_PROPS, getIcon("Information")}
    };

    for (int i = 0; i < buttonInfo.length; i++) {
      JButton btn = GuiUtils.getScaledImageButton(buttonInfo[i][2], getClass(), 2, 2);
      btn.setToolTipText(buttonInfo[i][0]);
      btn.setActionCommand(buttonInfo[i][1]);
      btn.addActionListener(this);
      btn.addKeyListener(listener);
      //            JComponent wrapper = GuiUtils.center(btn);
      //            wrapper.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
      btn.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
      buttonList.add(btn);
      //            buttonList.add(wrapper);
      if (i == 2) {
        startStopBtn = btn;
      }
    }

    JComponent contents = GuiUtils.hflow(buttonList, 1, 0);
    if (boxPanel == null) {
      boxPanel = new AnimationBoxPanel(this);
      if (timesArray != null) {
        updateBoxPanel(timesArray);
      }
    }
    boxPanel.addKeyListener(listener);
    if (!getBoxPanelVisible()) {
      boxPanel.setVisible(false);
    }
    contents =
        GuiUtils.doLayout(new Component[] {boxPanel, contents}, 1, GuiUtils.WT_Y, GuiUtils.WT_N);
    //      GuiUtils.addKeyListenerRecurse(listener,contents);
    if (floatToolBar) {
      JToolBar toolbar = new JToolBar(JToolBar.HORIZONTAL);
      toolbar.setFloatable(true);
      contents = GuiUtils.left(contents);
      toolbar.add(contents);
      contents = toolbar;
    }

    updateRunButton();
    madeContents = true;
    return contents;
  }
Exemplo n.º 11
0
    /** Create the UI for this editor */
    void makeUI() {

      JPanel mainPanel = new JPanel(new BorderLayout());
      mainPanel.setBorder(new LineBorder(Color.blue));
      getContentPane().add(mainPanel, BorderLayout.CENTER);

      // the map and associated toolbar
      npEditControl = new NPController();
      mapEditPanel = npEditControl.getNavigatedPanel(); // here's where the map will be drawn
      mapEditPanel.setPreferredSize(new Dimension(250, 250));
      mapEditPanel.setSelectRegionMode(true);
      JToolBar navToolbar = mapEditPanel.getNavToolBar();
      navToolbar.setFloatable(false);
      JToolBar moveToolbar = mapEditPanel.getMoveToolBar();
      moveToolbar.setFloatable(false);
      // toolbar.remove("setReference");

      JPanel toolbar = new JPanel();
      List localMaps = maps;
      if (localMaps == null) {
        localMaps = getDefaultMaps();
      }
      JMenu mapMenu = new JMenu("Maps");
      JMenuBar menuHolder = new JMenuBar();
      menuHolder.setBorder(null);
      menuHolder.add(mapMenu);
      toolbar.add(menuHolder);
      for (int mapIdx = 0; mapIdx < localMaps.size(); mapIdx++) {
        final MapData mapData = (MapData) localMaps.get(mapIdx);
        final JCheckBoxMenuItem cbx =
            new JCheckBoxMenuItem(mapData.getDescription(), mapData.getVisible());
        if (mapData.getVisible()) {
          toggleMap(mapData, true);
        }
        mapMenu.add(cbx);
        cbx.addItemListener(
            new ItemListener() {
              public void itemStateChanged(ItemEvent event) {
                toggleMap(mapData, cbx.isSelected());
              }
            });
      }
      GuiUtils.limitMenuSize(mapMenu, "Maps ", 20);

      toolbar.add(navToolbar);
      toolbar.add(moveToolbar);

      JPanel mapSide = new JPanel();
      mapSide.setLayout(new BorderLayout());
      TitledBorder mapBorder =
          new TitledBorder(
              standardBorder, "Edit Projection", TitledBorder.ABOVE_TOP, TitledBorder.CENTER);
      mapSide.setBorder(mapBorder);
      mapSide.add(toolbar, BorderLayout.NORTH);
      mapSide.add(mapEditPanel, BorderLayout.CENTER);
      mainPanel.add(mapSide, BorderLayout.WEST);

      // the projection parameters

      // the Projection name
      JLabel nameLabel = GuiUtils.rLabel("Name: ");
      nameTF = new JTextField(20);

      // the list of Projection classes is kept in a comboBox
      typeLabel = GuiUtils.rLabel("Type: ");
      projClassCB = new JComboBox();
      // standard list of projection classes
      List classNames = getDefaultProjections();
      for (int i = 0; i < classNames.size(); i++) {
        String className = (String) classNames.get(i);
        try {
          projClassCB.addItem(new ProjectionClass(className));
        } catch (ClassNotFoundException ee) {
          System.err.println("ProjectionManager failed on " + className + " " + ee);
        } catch (IntrospectionException ee) {
          System.err.println("ProjectionManager failed on " + className + " " + ee);
        }
      }
      GuiUtils.tmpInsets = new Insets(4, 4, 4, 4);
      JPanel topPanel =
          GuiUtils.doLayout(
              new Component[] {nameLabel, nameTF, typeLabel, projClassCB},
              2,
              GuiUtils.WT_N,
              GuiUtils.WT_N);

      // the Projection parameter area
      paramPanel = new JPanel();
      paramPanel.setLayout(new BorderLayout());
      paramPanel.setBorder(
          new TitledBorder(
              standardBorder,
              "Projection Parameters",
              TitledBorder.ABOVE_TOP,
              TitledBorder.CENTER));

      // the bottom button panel
      JPanel buttPanel = new JPanel();
      JButton acceptButton = new JButton("Save");
      JButton previewButton = new JButton("Preview");
      JButton cancelButton = new JButton("Cancel");
      buttPanel.add(acceptButton, null);
      buttPanel.add(previewButton, null);
      buttPanel.add(cancelButton, null);

      JPanel mainBox = GuiUtils.topCenterBottom(topPanel, paramPanel, buttPanel);
      mainPanel.add(mainBox, BorderLayout.CENTER);
      pack();

      // enable event listeners when we're done constructing the UI
      projClassCB.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              ProjectionClass selectClass = (ProjectionClass) projClassCB.getSelectedItem();
              setProjection(selectClass.makeDefaultProjection());
            }
          });

      acceptButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              accept();
            }
          });
      previewButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              ProjectionClass projClass = findProjectionClass(editProjection);
              if (null != projClass) {
                setProjFromDialog(projClass, editProjection);
                setProjection(editProjection);
              }
            }
          });
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              NewProjectionDialog.this.setVisible(false);
            }
          });
    }
Exemplo n.º 12
0
  /**
   * 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);
  }
Exemplo n.º 13
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;
    }
Exemplo n.º 14
0
  /** _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();
  }