/** * Given a photoList, builds for each picture a label to display in the main view * * @author Anas Alaoui M'Darhri * @param pl a existing PhotoList */ public static void buildLabels(PhotoList pl) { ArrayList<JLabel> ret = new ArrayList<>(); for (final ImgModel im : pl.getPhotolist()) { JLabel labPic = new JLabel(); labPic.setIcon( new ImageIcon( new ImageIcon(im.getFile().toString()) .getImage() .getScaledInstance(90, 90, Image.SCALE_SMOOTH))); labPic.setText("Toto " + im.getPath()); labPic.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); labPic.setBorder(BorderFactory.createRaisedBevelBorder()); labPic.setVisible(true); labPic.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent me) { if (im.equals(UICtrlV2.getSelected())) { UICtrlV2.setSelected(null); UICtrlV2.refreshImgDP(); } else { UICtrlV2.setSelected(im.getId()); UICtrlV2.refreshImgDP(); } } }); ret.add(labPic); } labels.put(pl.getId(), ret); }
/** * @author Anas ALaoui M'Darhri * @param selected id of the newly selected photo */ public static void setSelected(UUID selected) { if (selected == null) UICtrlV2.selected = null; else for (ImgModel im : ProcessingCtrl.loadedPhotoLists .get(ProcessingCtrl.getPlidFromImgid(selected)) .getPhotolist()) if (im.getId().equals(selected)) UICtrlV2.selected = im; }