source: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/MiniaturePanel.java @ 6821

Last change on this file since 6821 was 6821, checked in by mlg, 14 years ago

Premier commit. Actuellement, l'application gère :
-Listing des catégories
-Affichage des miniatures
-Ajout de commentaires
-gestion d'un cache pour ne pas télécharger les images plusieurs fois
-gestion d'un zoom dans le navigateur d'images
-navigateur d'images complètement refait, je viens de tester sur un grand écran, à priori, c'est beaucoup mieux
-meilleure gestion des exceptions, avec affichage de messages d'erreurs
-ajout d'un "logger" qui enregistre toutes les exceptions dans un fichier de log
-possibilité de ne pas mettre le "http://" dans l'écran de connexion
-gestion de transformations d'images dans le navigateur d'images : "flip" horizontal et vertical, rotations
-menu dans le navigateur d'images, qui permet d'effectuer toutes les actions, avec en plus, la possibilité d'imprimer une image

en cours d'implémentation : gestion des préférences de l'utilisateur. Actuellement, le fichier xml permettant d'écrire les préférences est géré,
il reste à faire un écran de gestion des préférences, avec un maximum d'options, afin que l'appli soit configurable.

File size: 4.0 KB
Line 
1package fr.mael.jiwigo.ui.mainframe;
2
3import java.awt.Cursor;
4import java.awt.Dimension;
5import java.awt.Graphics;
6import java.awt.Graphics2D;
7import java.awt.RenderingHints;
8import java.awt.event.MouseEvent;
9import java.awt.event.MouseListener;
10
11import javax.swing.JLabel;
12
13import fr.mael.jiwigo.om.Image;
14import fr.mael.jiwigo.ui.ImagesManagement;
15import fr.mael.jiwigo.ui.browser.NavigateurFrame;
16
17/**
18   Copyright (c) 2010, Mael
19   All rights reserved.
20
21   Redistribution and use in source and binary forms, with or without
22   modification, are permitted provided that the following conditions are met:
23    * Redistributions of source code must retain the above copyright
24      notice, this list of conditions and the following disclaimer.
25    * Redistributions in binary form must reproduce the above copyright
26      notice, this list of conditions and the following disclaimer in the
27      documentation and/or other materials provided with the distribution.
28    * Neither the name of jiwigo nor the
29      names of its contributors may be used to endorse or promote products
30      derived from this software without specific prior written permission.
31
32   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35   DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY
36   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42   
43 * @author mael
44 * Panel contenant la miniature d'une image.
45 * C'est un panel "cliquable", qui permet d'afficher l'image à taille réelle
46 */
47public class MiniaturePanel extends JLabel implements MouseListener {
48    /**
49     * Logger
50     */
51    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
52            .getLog(MiniaturePanel.class);
53    /**
54     * l'image
55     */
56    private Image image;
57
58    /**
59     * Constructeur
60     * @param image l'image
61     * @param imagesPanel le panel
62     */
63    public MiniaturePanel(Image image) {
64        this.image = image;
65        this.addMouseListener(this);
66    }
67
68    protected void paintComponent(Graphics g) {
69        super.paintComponent(g);
70        Graphics2D g2 = (Graphics2D) g;
71        g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
72        double x = (getWidth() * ImagesManagement.getMiniatureBufferedImage(image).getWidth()) / 2;
73        double y = (getHeight() * ImagesManagement.getMiniatureBufferedImage(image).getHeight()) / 2;
74        g2.drawRenderedImage(ImagesManagement.getMiniatureBufferedImage(image), null);
75    }
76
77    /* (non-Javadoc)
78     * @see javax.swing.JComponent#getPreferredSize()
79     */
80    public Dimension getPreferredSize() {
81        int w = (int) (ImagesManagement.getMiniatureBufferedImage(image).getWidth());
82        int h = (int) (ImagesManagement.getMiniatureBufferedImage(image).getHeight());
83        return new Dimension(w, h);
84    }
85
86    @Override
87    public void mouseClicked(MouseEvent paramMouseEvent) {
88        // on affiche l'image en grand
89        ImagesManagement.setCurrentImage(image);
90        new NavigateurFrame(image);
91
92    }
93
94    @Override
95    public void mouseEntered(MouseEvent paramMouseEvent) {
96        //changement du curseur, pour signifier à l'utilisateur que l'image est cliquable
97        this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
98    }
99
100    @Override
101    public void mouseExited(MouseEvent paramMouseEvent) {
102    }
103
104    @Override
105    public void mousePressed(MouseEvent paramMouseEvent) {
106        // TODO Auto-generated method stub
107
108    }
109
110    @Override
111    public void mouseReleased(MouseEvent paramMouseEvent) {
112        // TODO Auto-generated method stub
113
114    }
115
116}
Note: See TracBrowser for help on using the repository browser.