/** * Makes a thumbnail from the existing picture and sets it to the thumbnail slot. * The size of the created thumbnail is 100 x 100px and the aspect ratio is * preserved. */ public void makeThumbnail() // ------------- // ------------- { // --------- if (picture.val() != null) try { thumbnail.set(Picture.fromBufferedImage(Thumbnails.of(picture.val().toBufferedImage()).size(150, 150).outputFormat("jpg").asBufferedImage())); } catch (IOException e) { e.printStackTrace(); } // --------- } public void removeFromGallery(IAssociationEndInstance gallery) // ------------- // ------------- { // --------- gallery.remove(this); if (this.house.read().isEmpty()) this.destroy(); // --------- } public void addToGallery(IAssociationEndInstance gallery) // ------------- // ------------- { // --------- this.makeThumbnail(); this.submitted.set(Boolean.TRUE); gallery.addLast(this); // --------- } public void moveWithinGallery(IAssociationEndInstance gallery, Integer pos) // ------------- // ------------- { // --------- int i = gallery.read().indexOf(this); int position = pos.toInt() - 1; if (position != -1) { if (position >= gallery.size()) position = (int) (gallery.size() - 1); else if (position < 0) position = 0; gallery.reorder(i, position); } // --------- }