Ejemplo n.º 1
0
  public static void main(String[] args) throws Exception {

    // get credentials from stdin
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in, Constants.ENCODING));
    String server = readLine(in, "Server", "localhost");
    String portValue = readLine(in, "Port", "1099");
    String user = readLine(in, "Username", "root");
    String pass = readLine(in, "Password", "ome");
    String pidValue = readLine(in, "Pixels ID", "1");
    int port = Integer.parseInt(portValue);
    int pid = Integer.parseInt(pidValue);
    System.out.println();

    // connect to OMERO server
    System.out.println("Initializing OMERO reader");
    OmeroReader omero = new OmeroReader();
    String id =
        "omero:\n"
            + "server="
            + server
            + "\n"
            + "port="
            + port
            + "\n"
            + "user="******"\n"
            + "pass="******"\n"
            + "pid="
            + pid;
    omero.setId(id);

    // print some metadata as a simple test
    int sizeX = omero.getSizeX();
    int sizeY = omero.getSizeY();
    System.out.println("Image dimensions are " + sizeX + " x " + sizeY);

    omero.close();
  }
Ejemplo n.º 2
0
  /** A simple command line tool for downloading images from OMERO. */
  public static void main(String[] args) throws Exception {
    // parse OMERO credentials
    BufferedReader con = new BufferedReader(new InputStreamReader(System.in, Constants.ENCODING));

    System.out.print("Server? ");
    final String server = con.readLine();

    System.out.printf("Port [%d]? ", DEFAULT_PORT);
    final String portString = con.readLine();
    final int port = portString.equals("") ? DEFAULT_PORT : Integer.parseInt(portString);

    System.out.print("Username? ");
    final String user = con.readLine();

    System.out.print("Password? ");
    final String pass = new String(con.readLine());

    System.out.print("Group? ");
    final String group = con.readLine();

    System.out.print("Image ID? ");
    final int imageId = Integer.parseInt(con.readLine());
    System.out.print("\n\n");

    // construct the OMERO reader
    final OmeroReader omeroReader = new OmeroReader();
    omeroReader.setUsername(user);
    omeroReader.setPassword(pass);
    omeroReader.setServer(server);
    omeroReader.setPort(port);
    omeroReader.setGroupName(group);
    final String id = "omero:iid=" + imageId;
    try {
      omeroReader.setId(id);
    } catch (Exception e) {
      omeroReader.close();
      throw e;
    }
    omeroReader.close();
  }