Exemplo n.º 1
0
 /** Return all the pictures with a given resolution on width. @ param List<Picture> */
 public List<Picture> getAll(int wResolution) {
   List result = new ArrayList();
   for (Picture p : pictures) {
     if (p.getWResolution() == wResolution) {
       result.add(p);
     }
   }
   return result;
 }
 public static void main(String[] args) {
   Picture p = new Picture(FileChooser.getMediaPath("horse.jpg"));
   Graphics g = p.getGraphics();
   Point ul = new Point(68, 24);
   Point te = new Point(182, 123);
   String message = "This is a test." + "  Of a message with more than one line in it.";
   SpeechBalloon balloon = new SpeechBalloon(ul, 200, te, message);
   balloon.draw(g);
   p.show();
 }
  public static void showGallery(Long id, String name) {
    notFoundIfNull(id);
    Gallery gallery = Gallery.findById(id);
    notFoundIfNull(gallery);

    List<Picture> pictures = gallery.getPictures();
    List<ImageView> images = new ArrayList<ImageView>();
    for (Picture picture : pictures) images.add(picture.toImageView());

    render("Application/gallery.html", images, gallery);
  }
Exemplo n.º 4
0
  /* Main method for testing - each class in Java can have a main
   * method
   */
  public static void main(String[] args) {
    Picture beach = new Picture("beach.jpg");
    beach.explore();
    beach.mirrorVerticalBottomToTop();
    // beach.mirrorVerticalRightToLeft();
    // beach.Grayscale();
    // beach.maxBlue();
    // beach.createCollage();
    // beach.rightRed();
    beach.explore();
    // beach.write("5FilterBeach.jpeg");

  }
Exemplo n.º 5
0
 /** Method to create a collage of several pictures */
 public void createCollage() {
   Picture flower1 = new Picture("flower1.jpg");
   Picture flower2 = new Picture("flower2.jpg");
   this.copy(flower1, 0, 0);
   this.copy(flower2, 100, 0);
   this.copy(flower1, 200, 0);
   Picture flowerNoBlue = new Picture(flower2);
   flowerNoBlue.zeroBlue();
   this.copy(flowerNoBlue, 300, 0);
   this.copy(flower1, 400, 0);
   this.copy(flower2, 500, 0);
   this.mirrorVertical();
   this.write("collage.jpg");
 }
Exemplo n.º 6
0
  /* Main method for testing - each class in Java can have a main
   * method
   */
  public static void main(String[] args) {
    Picture desert = new Picture("Desert.jpg");
    Picture koala = new Picture("Koala.jpg");
    //    beach.explore();
    //    beach.zeroBlue();
    //    desert.chromakey(koala);
    //    desert.sepia(25, 3);
    koala.sepia();
    //    desert.encode("ABCDEFGHIJKLMNOPasdfgwe6");
    //    System.out.println(desert.decode());

    //    desert.explore();
    koala.explore();
  }
Exemplo n.º 7
0
 public void cropAndCopy(
     Picture sourcePicture,
     int startSourceRow,
     int endSourceRow,
     int startSourceCol,
     int endSourceCol,
     int startDestRow,
     int startDestCol) {
   Pixel leftPixel = null;
   Pixel rightPixel = null;
   Pixel[][] pixels = this.getPixels2D();
   Color rightColor = null;
   Pixel[][] fromPixels = sourcePicture.getPixels2D();
   Pixel[][] toPixels = this.getPixels2D();
   Pixel fromPixel = null;
   Pixel toPixel = null;
   for (int fromRow = startSourceRow, toRow = endSourceRow;
       fromRow < fromPixels.length && toRow < toPixels.length;
       fromRow++, toRow++) {
     for (int fromCol = startSourceCol, toCol = endSourceCol;
         fromCol < fromPixels[0].length && toCol < toPixels[0].length;
         fromCol++, toCol++) {
       fromPixel = fromPixels[fromRow][fromCol];
       toPixel = toPixels[toRow][toCol];
       toPixel.setColor(fromPixel.getColor());
     }
   }
 }
Exemplo n.º 8
0
 /**
  * Method to replace blue pixels with pixels from the second picture.
  *
  * @param second picture to replace blue pixels with
  */
 public void chromakey(Picture second) {
   Pixel[][] pixels = this.getPixels2D();
   Pixel[][] pixels2 = second.getPixels2D();
   for (int row = 0; row < pixels.length; row++)
     for (int col = 0; col < pixels[0].length; col++)
       if (pixels[row][col].getColor().getBlue() >= 200)
         pixels[row][col].setColor(pixels2[row][col].getColor());
 }
Exemplo n.º 9
0
 private static void handlePost(Post post) {
   Main.post_post_hash.put(post, post);
   for (Picture picture : post.pictures) {
     Helper.downloadFileFromURLToFileInTemp(picture.thumb_url, picture.thumb_name);
     picture.md5_id = Helper.createMD5FromFileInTemp(picture.thumb_name);
     Helper.moveTempImageToStore(picture.thumb_name, new File(Main.blogdir, picture.md5_id));
     if (!Main.pic_pic_hash.containsKey(picture)) {
       Main.pic_pic_hash.put(picture, picture);
       Main.pic_post_hash.put(picture, post);
       Helper.downloadFileFromURLToFileInTemp(picture.media_url, picture.media_name);
       Helper.moveTempImageToStore(picture.media_name, new File(Main.blogdir, picture.md5_id));
     } else {
       if (!post.equals(Main.pic_post_hash.get(picture))) {
         dup_post_list.put(post, Main.pic_post_hash.get(picture));
       }
     }
   }
 }
Exemplo n.º 10
0
  public String toString() {
    StringBuilder output = new StringBuilder();
    // String NEW_LINE = System.getProperty("line.separator");

    output.append("Common Name: " + myCommonName + "\n");
    output.append(myGenericInfo.toString());
    output.append(myPicture.toString());
    output.append(mySound.toString());

    return output.toString();
  }
Exemplo n.º 11
0
 private static void tryResUrls(Picture picture) {
   String hi_res = "";
   String url = picture.media_url.toString();
   for (String ending : Main.endings) {
     try {
       hi_res = url.replace(url.substring(url.lastIndexOf("_"), url.lastIndexOf(".")), ending);
       URL hi_url = new URL(hi_res);
       File hi_name = Helper.extractMediaFileNameFromURL(hi_url);
       if (hi_name.equals(picture.media_name)) {
         picture.hi_url = hi_url;
         picture.hi_name = hi_name;
         picture.downloaded_hi = true;
         break;
       } else {
         boolean success = Helper.downloadFileFromURLToFileInTemp(hi_url, hi_name);
         if (success) {
           picture.hi_url = hi_url;
           picture.hi_name = hi_name;
           picture.downloaded_hi = true;
           Helper.moveTempImageToStore(hi_name, new File(Main.blogdir, picture.md5_id));
           break;
         }
       }
     } catch (MalformedURLException ex) {
       Main.error(String.format("Attempted hi res url %s is a malformed URL.", hi_res));
     }
   }
 }
Exemplo n.º 12
0
  /**
   * Тестирование на HashMap
   *
   * @throws Exception
   */
  @Test
  public void testOnHashMap() throws Exception {
    Map<UserHashcode, Picture> users = new HashMap<>();
    users.put(user1, user1.getPicture());
    assertTrue(users.containsKey(user1));

    // user3 копия user1 но не содержится в ключах Map. Поиск идет по equals, а он не переопределен
    assertFalse(users.containsKey(user3));

    // В Map есть только user1, но присутствует value для user3,
    // т.к. у класса Picture переопределены оба метода, хотя объекты pic1 и pic3 разные по ссылкам
    assertTrue(users.containsValue(pic3));
    // Объекты разные, а хэш-коды - одинаковые
    assertFalse(pic1 == pic3);
    assertEquals(pic1.hashCode(), pic3.hashCode());

    users.put(user2, user2.getPicture());
    users.put(user3, user3.getPicture());

    // user3 не перезатирает user1, т.к. ключи не равны по equals, а только по hashCode
    assertEquals(3, users.size());
  }
Exemplo n.º 13
0
 protected void importPicture(List<Picture> poiPictures, Sheet poiSheet, SSheet sheet) {
   for (Picture poiPicture : poiPictures) {
     PictureData poiPicData = poiPicture.getPictureData();
     Integer picDataIx = importedPictureData.get(poiPicData); // ZSS-735
     if (picDataIx != null) {
       sheet.addPicture(
           picDataIx.intValue(), toViewAnchor(poiSheet, poiPicture.getClientAnchor()));
     } else {
       Format format = Format.valueOfFileExtension(poiPicData.suggestFileExtension());
       if (format != null) {
         SPicture pic =
             sheet.addPicture(
                 format,
                 poiPicData.getData(),
                 toViewAnchor(poiSheet, poiPicture.getClientAnchor()));
         importedPictureData.put(poiPicData, pic.getPictureData().getIndex());
       } else {
         // TODO log we ignore a picture with unsupported format
       }
     }
   }
 }
Exemplo n.º 14
0
  public int buildBird(String[] birdData, int location) throws FileNotFoundException {
    myCommonName = birdData[location++];

    myGenericInfo = new GenericInfo();
    location = myGenericInfo.buildGenericInfo(birdData, location);
    myPicture = new Picture();
    location = myPicture.buildPicture(birdData, location);
    mySound = new Sound();
    location = mySound.buildSound(birdData, location);
    // System.out.println(mySound.toString());

    // System.out.println(location);
    return location;
  }
Exemplo n.º 15
0
 public static void main(String[] args) {
   String fileName = FileChooser.pickAFile();
   Picture pictObj = new Picture(fileName);
   pictObj.changeWhole(.5);
   pictObj.changeWhole(.8);
   pictObj.scrible(200, 200, 50);
   pictObj.scrible(350, 320, 100);
   pictObj.ManipBoxUniformly(200, 200, 300, 300, .2);
   pictObj.ManipBoxUniformly(100, 100, 400, 300, .5);
   pictObj.ManipBoxPattern(100, 100, 300, 300, .3);
   pictObj.ManipBoxPattern(300, 300, 400, 400, .8);
   pictObj.explore();
 }
Exemplo n.º 16
0
 /**
  * copy from the passed fromPic to the specified startRow and startCol in the current picture
  *
  * @param fromPic the picture to copy from
  * @param startRow the start row to copy to
  * @param startCol the start col to copy to
  */
 public void copy(Picture fromPic, int startRow, int startCol) {
   Pixel fromPixel = null;
   Pixel toPixel = null;
   Pixel[][] toPixels = this.getPixels2D();
   Pixel[][] fromPixels = fromPic.getPixels2D();
   for (int fromRow = 0, toRow = startRow;
       fromRow < fromPixels.length && toRow < toPixels.length;
       fromRow++, toRow++) {
     for (int fromCol = 0, toCol = startCol;
         fromCol < fromPixels[0].length && toCol < toPixels[0].length;
         fromCol++, toCol++) {
       fromPixel = fromPixels[fromRow][fromCol];
       toPixel = toPixels[toRow][toCol];
       toPixel.setColor(fromPixel.getColor());
     }
   }
 }
  /**
   * Method to add a picture to the frame sequence
   *
   * @param picture the picture to add
   */
  public void addFrame(Picture picture) {

    // add this picture to the list
    pictureList.add(picture);

    // write out this frame
    picture.write(directory + baseName + numberFormat.format(frameNumber) + ".jpg");

    // if this sequence is being shown update the frame
    if (shown) {
      if (pictureFrame != null) pictureFrame.setPicture(picture);
      else pictureFrame = new PictureFrame(picture);
    }

    // increment the frame number
    frameNumber++;
  }
Exemplo n.º 18
0
 public void copy(
     Picture fromPic,
     int fromStartRow,
     int fromStartCol,
     int toStartRow,
     int toStartCol,
     int fromEndRow,
     int fromEndCol) {
   Pixel fromPixel = null;
   Pixel toPixel = null;
   Pixel[][] toPixels = this.getPixels2D();
   Pixel[][] fromPixels = fromPic.getPixels2D();
   for (int fromRow = fromStartRow, toRow = toStartRow;
       fromRow <= fromEndRow && toRow < toPixels.length;
       fromRow++, toRow++) {
     for (int fromCol = fromStartCol, toCol = toStartCol;
         fromCol <= fromEndCol && toCol < toPixels.length;
         fromCol++, toCol++) {
       fromPixel = fromPixels[fromRow][fromCol];
       toPixel = toPixels[toRow][toCol];
       toPixel.setColor(fromPixel.getColor());
     }
   }
 }
Exemplo n.º 19
0
  /** Method to create a collage of several pictures */
  public void createCollage() {
    Picture pic2 = new Picture("moon-surface.jpg");

    Picture picNoBlue = new Picture(pic2);
    picNoBlue.zeroBlue();

    Picture effect1 = new Picture(pic2);
    effect1.edgeDetection(10);

    Picture effect2 = new Picture(pic2);

    this.copy(effect1, 250, 600);
    this.copy(pic2, 0, 600);
    effect2.mirrorVertical();
    this.copy(effect2, 250, 0);

    this.copy(picNoBlue, 0, 0);

    this.write("collage.jpg");
  }
Exemplo n.º 20
0
 /* Main method for testing - each class in Java can have a main
  * method
  */
 public static void main(String[] args) {
   Picture beach = new Picture("beach.jpg");
   beach.explore();
   beach.zeroBlue();
   beach.explore();
 }
 public static void resized(Long galleryId, Long pictureId) {
   File picture = Picture.getFile(galleryId, pictureId, Application.RESIZED);
   if (!picture.exists()) notFound();
   renderBinary(picture);
 }
 public static void thumbnail(Long galleryId, Long pictureId) {
   File picture = Picture.getFile(galleryId, pictureId, Application.THUMBNAILS);
   if (!picture.exists()) notFound();
   renderBinary(picture);
 }
Exemplo n.º 23
0
 /* Main method for testing - each class in Java can have a main
  * method
  */
 public static void main(String[] args) {
   Picture beach = new Picture("pixLab/images/beach.jpg");
   beach.explore();
   beach.keepOnlyRed();
   beach.explore();
 }
Exemplo n.º 24
0
 public String getMyPicture() {
   return myPicture.getBirdPictureLocation();
 }