示例#1
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == invertImage) {

      image = invertImage(image);
      midwin.updateImage(image);
    }

    if (e.getSource() == zoomOut) midwin.zoomOut();
    if (e.getSource() == zoomIn) midwin.zoomIn();

    if (e.getSource() == toggleHighlights) batchState.toggleHighlights();

    if (e.getSource() == submit) {
      if (!batchState.hasCurrentBatch()) {
        displayError();
      } else {
        JTable table = batchState.getTable();
        Object[][] data = getTableData(table);
        model.Image image = batchState.getImage();
        String recordValues = transferData(data);
        SubmitBatch_Params params =
            new SubmitBatch_Params(batchState.getUser(), batchState.getImage(), recordValues);
        ClientCommunicator c = new ClientCommunicator();
        try {
          SubmitBatch_Result result = c.SubmitBatch(params);
          if (result.isSuccess()) {
            batchState.clearDrawingComponent();
            batchState.enableDownload();
            batchState.clearBottom();
          }
        } catch (ClientException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
      }
    }
  }
  @Test
  public void test() throws ClientException {
    DownloadBatch_Params params = new DownloadBatch_Params();
    DownloadBatch_Result result = new DownloadBatch_Result();

    System.out.println("here");

    params.setUsername("sheila");
    params.setPassword("parker");
    params.setProjectID(1);

    result = communicator.downloadImage(params);

    String expected =
        "1\n"
            + "1\n"
            + "http://localhost:38440/Records/images/1890_image0.png\n"
            + "199\n"
            + "60\n"
            + "8\n"
            + "4\n"
            + "1\n"
            + "0\n"
            + "Last Name\n"
            + "http://localhost:38440/Records/fieldhelp/last_name.html\n"
            + "60\n"
            + "300\n"
            + "http://localhost:38440/Records/knowndata/1890_last_names.txt\n"
            + "2\n"
            + "1\n"
            + "First Name\n"
            + "http://localhost:38440/Records/fieldhelp/first_name.html\n"
            + "360\n"
            + "280\n"
            + "http://localhost:38440/Records/knowndata/1890_first_names.txt\n"
            + "3\n"
            + "2\n"
            + "Gender\n"
            + "http://localhost:38440/Records/fieldhelp/gender.html\n"
            + "640\n"
            + "205\n"
            + "http://localhost:38440/Records/knowndata/genders.txt\n"
            + "4\n"
            + "3\n"
            + "Age\n"
            + "http://localhost:38440/Records/fieldhelp/age.html\n"
            + "845\n"
            + "120\n";
    assertEquals(expected, result.toString());
  }