Package geodress.model

Examples of geodress.model.PictureBox


   *             may cause an exception
   */
  @Test
  public void makeWritingTestDescription() throws Exception {
    /* use program */
    PictureBox testBox = new PictureBox(dir);
    testBox.catchAddresses(new GoogleMapsReader(), new EmptyProgress());
    testBox.writeAddresses(new ExifToolWriter(), InfoConstants.IMAGE_DESCRIPTION,
        new EmptyProgress());

    /* test beach.jpg */
    reader.setFile(testFileBeach);
    String testedAddress = reader.getData(InfoConstants.IMAGE_DESCRIPTION);
View Full Code Here


  @Test
  public void makeWritingTestComment() throws Exception {
    /* use program */
    ExifToolWriter writer = new ExifToolWriter();
    writer.setExifToolPath("exiftool");
    PictureBox testBox = new PictureBox(dir);
    testBox.catchAddresses(new GoogleMapsReader(), new EmptyProgress());
    testBox.writeAddresses(writer, InfoConstants.USER_COMMENT,
        new EmptyProgress());

    /* test beach.jpg */
    reader.setFile(testFileBeach);
    String testedAddress = reader.getData(InfoConstants.USER_COMMENT);
View Full Code Here

        System.out.println(InfoConstants.LICENSE);
        System.exit(0);
      }

      /* initialization */
      PictureBox pictureBox = null;

      /* get picture folder */
      File dir;
      if (line.hasOption("d")) {
        dir = new File(line.getOptionValue("d"));

        /* load picture folder */
        try {
          logger.log(Level.FINE, "directory: "
              + dir.getCanonicalPath());
          pictureBox = new PictureBox(dir);
        } catch (FileNotFoundException fnfe) {
          logger.log(Level.WARNING, fnfe.getMessage(), fnfe);
          System.out.println("The directory " + dir.getAbsolutePath()
              + " doesn't exist.");
          System.exit(0);
        } catch (IOException ioe) {
          logger.log(Level.WARNING,
              "error while loading files from directory", ioe);
        }

        /* print only pictures */
        if (!line.hasOption("a")) {
          System.out.println(pictureBox
              .getPicturesAsString(PictureBox.FORMAT_TXT));
        }

        /* catch address and print them */
        if (line.hasOption("a")) {
          try {
            if (line.hasOption("k")) {
              logger.log(Level.FINE,
                  "an individual Google Maps API key is used: "
                      + line.getOptionValue("k"));
              System.out
                  .println("An individual Google Maps API key is used: "
                      + line.getOptionValue("k") + ".");
              pictureBox.catchAddresses(new GoogleMapsReader(line
                  .getOptionValue("k")), new ProgressCli(
                  "Catch addresses from Google Maps"));
            } else {
              pictureBox
                  .catchAddresses(
                      new GoogleMapsReader(),
                      new ProgressCli(
                          "Catch addresses from Google Maps"));
            }

            /* print pictures */
            System.out.println(pictureBox
                .getPicturesAsString(PictureBox.FORMAT_TXT));

          } catch (UnknownHostException uhe) {
            logger.log(Level.WARNING, uhe.getMessage(), uhe);
            System.out
                .println("An error occured while connecting to Google Maps "
                    + "(maybe there is no Internet connection).");
          }

          /* write caught addresses to picture files */
          if (line.hasOption("w")) {
            logger.log(Level.FINE,
                "write caught addresses (field '"
                    + line.getOptionValue("w") + "')");

            ExifToolWriter writer = new ExifToolWriter();

            if (line.hasOption("b")) {
              writer.setBackupMode(false);
            }

            if (line.hasOption("p")) {
              System.out.println("Setting "
                  + line.getOptionValue("p")
                  + " as path to ExifTool...");
              try {
                writer
                    .setExifToolPath(line
                        .getOptionValue("p"));
              } catch (IOException ioe) {
                System.out
                    .println("An error occured while setting the ExifToolPath: "
                        + ioe.getMessage());
              }
            }

            /* find out field */
            int field = InfoConstants.IMAGE_DESCRIPTION;
            if (line.getOptionValue("w").contains(WRITE_TO_COMMENT)) {
              field = InfoConstants.USER_COMMENT;
            }

            /* write data */
            pictureBox.writeAddresses(writer, field,
                new ProgressCli(
                    "Writing addresses to picture files"));
          }
        }

        /* export to text file */
        if (line.hasOption("e")) {
          File exportFile = new File(line.getOptionValue("e"));

          logger.log(Level.FINE, "Picture data will be exported to "
              + exportFile.getName() + ".");
          System.out.println("Picture data will be exported to "
              + exportFile.getName() + ".");
          try {
            pictureBox.saveToFile(exportFile,
                PictureBox.FORMAT_TXT_OS);
          } catch (IOException ioe) {
            logger
                .log(
                    Level.WARNING,
View Full Code Here

    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int state = fc.showOpenDialog(this);
    if (state == JFileChooser.APPROVE_OPTION) {
      if (fc.getSelectedFile().isDirectory()) {
        try {
          createPictureList(new PictureBox(fc.getSelectedFile()));
          setTitle(windowTitle + " - "
              + fc.getSelectedFile().getAbsolutePath());
        } catch (FileNotFoundException fnfe) {
          logger.log(Level.WARNING, fnfe.getMessage(), fnfe);
          showError("The directory "
View Full Code Here

TOP

Related Classes of geodress.model.PictureBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.