Пример #1
0
 private JCheckBoxMenuItem addFilterMenuItem(
     String command, boolean defaultlistener, ParticlePicker picker) {
   JCheckBoxMenuItem mi = new JCheckBoxMenuItem(command);
   mifilters.add(mi);
   mi.setSelected(picker.isFilterAdded(command));
   if (defaultlistener) mi.addActionListener(this);
   filtersmn.add(mi);
   // mi.setEnabled(picker.getMode() != Mode.ReadOnly);
   return mi;
 }
Пример #2
0
  private void initMenuBar(ParticlePicker picker) {
    filemn = new JMenu(bundle.getString("file"));
    helpmn = new JMenu(bundle.getString("help"));
    savemi = new JMenuItem("Save", XmippResource.getIcon("save.gif"));
    savemi.setMnemonic('S');
    savemi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    savemi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            getParticlePicker().saveData();
            showMessage("Data saved successfully");
            setChanged(false);
          }
        });
    filemn.add(savemi);
    importmi = new JMenuItem("Import coordinates...", XmippResource.getIcon("import_wiz.gif"));
    filemn.add(importmi);
    if (picker.getMode() != Mode.Manual) importmi.setEnabled(false);

    importmi.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (importpjd == null)
              importpjd = new ImportParticlesJDialog(ParticlePickerJFrame.this);
            importpjd.showDialog();
          }
        });

    exitmi = new JMenuItem("Exit");
    exitmi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            close();
          }
        });

    ijmi = new JMenuItem("ImageJ", XmippResource.getIcon("ij.gif"));
    ijmi.setEnabled(picker.getMode() != Mode.ReadOnly);
    ijmi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            XmippUtil.showImageJ(Tool.PICKER);
          }
        });

    hcontentsmi = new JMenuItem("Online help", XmippResource.getIcon("online_help.gif"));
    hcontentsmi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              openHelpURl();

            } catch (Exception ex) {
              showException(ex);
            }
          }
        });
    helpmn.add(hcontentsmi);

    keyassistmi = new JMenuItem("Tips...", XmippResource.getIcon("bulb.png"));
    keyassistmi.addActionListener(
        new ActionListener() {

          private QuickHelpJDialog keyassistdlg;

          @Override
          public void actionPerformed(ActionEvent e) {
            if (keyassistdlg == null)
              keyassistdlg =
                  new QuickHelpJDialog(ParticlePickerJFrame.this, false, "Tips", getKeyAssist());
            keyassistdlg.setVisible(true);
          }
        });
    helpmn.add(keyassistmi);

    pmi = new JMenuItem("Particles", XmippResource.getIcon("table_view.gif"));
    pmi.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            loadParticles(false);
          }
        });

    mifilters = new ArrayList<JCheckBoxMenuItem>();
    filtersmn = new JMenu(bundle.getString("filters"));
    filtersmn.addMenuListener(
        new MenuListener() {

          @Override
          public void menuCanceled(MenuEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void menuDeselected(MenuEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void menuSelected(MenuEvent arg0) {
            boolean added;
            for (JCheckBoxMenuItem mi : mifilters) {
              added = getParticlePicker().isFilterAdded(mi.getText());
              mi.setSelected(added);
            }
          }
        });

    addFilterMenuItem(XmippImageJ.gaussianBlurFilter, true, picker);
    addFilterMenuItem(ParticlePicker.xmippsmoothfilter, true, picker);
    addFilterMenuItem(XmippImageJ.bandPassFilter, true, picker);
    addFilterMenuItem(XmippImageJ.enhanceContrastFilter, true, picker);
    addFilterMenuItem(XmippImageJ.brightnessContrastFilter, true, picker);

    //		JCheckBoxMenuItem admi = addFilterMenuItem(XmippImageJ.anisotropicDiffFilter, false,
    // picker);
    //		admi.addActionListener(new ActionListener()
    //		{
    //
    //			@Override
    //			public void actionPerformed(ActionEvent e)
    //			{
    //				activefilter = "8-bit";
    //				IJ.run(activefilter);
    //				activefilter = ((JCheckBoxMenuItem) e.getSource()).getText();
    //				IJ.run(activefilter);
    //			}
    //		});
    addFilterMenuItem(XmippImageJ.invertLUTFilter, true, picker);
    addFilterMenuItem(XmippImageJ.substractBackgroundFilter, true, picker);
    addFilterAppliedListener();
  }
Пример #3
0
  public ParticlePickerJFrame(ParticlePicker picker) {
    try {
      File file = new File(Filename.getXmippPath("resources"));
      URL[] urls = new URL[] {file.toURI().toURL()};
      ClassLoader loader = new URLClassLoader(urls);
      bundle = ResourceBundle.getBundle("Bundle", Locale.getDefault(), loader);
      XmippApplication.addInstance(false);
      setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
      addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent winEvt) {

              if (getParticlePicker().isChanged()) {
                XmippQuestionDialog qd =
                    new XmippQuestionDialog(
                        ParticlePickerJFrame.this, "Save changes before closing?");
                boolean save = qd.showDialog();
                if (save) getParticlePicker().saveData();
                else if (qd.isCanceled()) return;
              }
              close();
            }
          });

      initMenuBar(picker);

      resetbt =
          XmippWindowUtil.getTextButton(
              bundle.getString("resetmic"),
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                  String resetmsg = getResetMsg();
                  XmippQuestionDialog qd =
                      new XmippQuestionDialog(ParticlePickerJFrame.this, resetmsg, false);
                  if (qd.showDialog()) resetMicrograph();
                }
              });

      savebt =
          XmippWindowUtil.getTextIconButton(
              bundle.getString("save"),
              "save.gif",
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                  getParticlePicker().saveData();
                  setChanged(false);
                }
              });

      saveandexitbt =
          XmippWindowUtil.getTextButton(
              bundle.getString("saveandexit"),
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {

                  if (getParticlePicker().getMode() != Mode.ReadOnly)
                    getParticlePicker().saveData();
                  if (getParticlePicker().isScipionSave()) {
                    int count = getParticlePicker().getParticlesCount();
                    if (count == 0) {
                      XmippDialog.showInfo(
                          ParticlePickerJFrame.this, XmippMessage.getEmptyFieldMsg("coordinates"));
                      return;
                    }
                    HashMap<String, String> msgfields = new HashMap<String, String>();
                    boolean createprot = getParticlePicker().getPort() == null;
                    if (createprot) msgfields.put("Run name:", "ProtUserCoordinates");

                    String msg =
                        String.format(
                            "<html>Are you sure you want to register a new set of Coordinates with <font color=red>%s</font> %s?",
                            count, (count != 1) ? "elements" : "element");
                    InputFieldsMessageDialog dlg =
                        new InputFieldsMessageDialog(ParticlePickerJFrame.this, "Question", msg);

                    if (dlg.action == InputFieldsMessageDialog.OK_OPTION)
                      executeScipionSaveAndExit();

                  } else close();
                }
              });
      closebt =
          XmippWindowUtil.getTextIconButton(
              "Close",
              "fa-times.png",
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                  close();
                }
              });
      if (picker.isScipionSave()) {
        saveandexitbt.setText("Coordinates");
        Image img =
            Toolkit.getDefaultToolkit()
                .getImage(
                    Filename.getXmippPath("resources" + File.separator + "fa-plus-circle.png"));
        saveandexitbt.setIcon(new ImageIcon(img));
        saveandexitbt.setToolTipText("Create Coordinates");
        Color color = XmippWindowUtil.firebrick;
        saveandexitbt.setBackground(color);
        saveandexitbt.setForeground(Color.WHITE);
      }
      micrographstb = new JTable();
      micrographstb
          .getSelectionModel()
          .addListSelectionListener(new MicrographsSelectionListener());
      micrographstb.addMouseListener(
          new MouseListener() {

            @Override
            public void mouseReleased(MouseEvent arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public void mousePressed(MouseEvent arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public void mouseExited(MouseEvent arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public void mouseEntered(MouseEvent arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public void mouseClicked(MouseEvent arg0) {
              if (micrographstb.getSelectedRow() == -1) return;
              loadMicrograph();
            }
          });
    } catch (Exception ex) {
      Logger.getLogger(ParticlePickerJFrame.class.getName()).log(Level.SEVERE, null, ex);
      throw new IllegalArgumentException(ex);
    }
  }