Esempio n. 1
0
  private void analyze() {
    if (WindowManager.getCurrentImage() != null) {
      RConnection c = RServe.getConnection();
      if (c != null) {
        /* Special method to reuse the GUI method! */
        IJTranserResultsTable.runParticleAnalysis(
            c,
            "run(\"Analyze Particles...\", \"size=0-Infinity circularity=0.00-1.00 show=Nothing display clear\")");

        try {
          c.eval("assign(paste0('Particles'," + count + ",sep=''),Particles)");
        } catch (RserveException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
  }
Esempio n. 2
0
  public void run() {

    IPreferenceStore store = Bio7Plugin.getDefault().getPreferenceStore();
    RConnection con = RServe.getConnection();
    // boolean rPipe = store.getBoolean("r_pipe");
    if (con == null) {

      String selectionConsole = ConsolePageParticipant.getInterpreterSelection();
      if (selectionConsole.equals("R")) {
        String selected = null;

        Shell s = new Shell();
        FileDialog fd = new FileDialog(s, SWT.SAVE);

        if (ApplicationWorkbenchWindowAdvisor.getOS().equals("Windows")) {
          prefs = Preferences.userNodeForPackage(this.getClass());
          String lastOutputDir = prefs.get("R_FILE_DIR", "");
          fd.setFilterPath(lastOutputDir);

          String[] filterExt = {"*.RData"};
          fd.setFilterExtensions(filterExt);
          fd.setOverwrite(true);
          selected = fd.open();
          prefs.put("R_FILE_DIR", fd.getFilterPath());
          if (selected != null) {
            selected = selected.replace("\\", "\\\\");
            // selected = selected.replace("ä", "ae");
            // selected = selected.replace("ü", "ue");
            // selected = selected.replace("ö", "oe");

            ConsolePageParticipant.pipeInputToConsole(
                "save.image(file =\"" + selected + "\", version = NULL, ascii = FALSE)",
                true,
                true);
            System.out.print(
                "save.image(file =\"" + selected + "\", version = NULL, ascii = FALSE)");
            System.out.println();
          }
        } else {
          prefs = Preferences.userNodeForPackage(this.getClass());
          String lastOutputDir = prefs.get("R_FILE_DIR", "");
          fd.setFilterPath(lastOutputDir);
          String[] filterExt = {"*.RData"};
          fd.setFilterExtensions(filterExt);
          fd.setOverwrite(true);
          selected = fd.open();
          prefs.put("R_FILE_DIR", fd.getFilterPath());

          if (selected != null) {
            ConsolePageParticipant.pipeInputToConsole(
                "save.image(file =\"" + selected + "\", version = NULL, ascii = FALSE)",
                true,
                true);
            System.out.print(
                "save.image(file =\"" + selected + "\", version = NULL, ascii = FALSE)");
            System.out.println();
          }
        }

        ConsolePageParticipant.pipeInputToConsole("load(file = \"" + selected + "\")", true, true);

      } else {
        Bio7Dialog.message(
            "Please start the \"Native R\" shell in the Bio7 console or the Rserve connection!");
      }

    } else {

      saveRWorkspace();
    }
  }