Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / legend / edition / gui / PreviewIcon.java @ 29598

History | View | Annotate | Download (1.56 KB)

1
package org.gvsig.app.project.documents.view.legend.edition.gui;
2
import java.awt.Color;
3
import java.awt.Graphics;
4
import java.awt.Graphics2D;
5
import java.awt.event.MouseListener;
6

    
7
import javax.swing.ImageIcon;
8
import javax.swing.JPanel;
9

    
10

    
11
public class PreviewIcon extends JPanel {
12
        private ImageIcon icon;
13
        private boolean isSelected;
14

    
15
        /**
16
         *
17
         */
18
        public PreviewIcon() {
19
                super();
20
                        initialize();
21
        }
22

    
23

    
24
        /**
25
         * This method initializes this
26
         *
27
         * @return void
28
         */
29
        private void initialize() {
30
        this.setSize(70, 52);
31

    
32
        }
33
        protected void paintComponent(Graphics g) {
34
                super.paintComponent(g);
35
                if (icon == null)
36
                        return;
37

    
38
                Graphics2D g2 = (Graphics2D) g;
39
                //g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
40
                //g.setClip(0,0,getWidth(), getHeight());
41
                //Rectangle r = g.getClipBounds(); //getClipRect();
42
                if (isSelected)
43
                        g2.setColor(Color.blue);
44
                else
45
                        g2.setColor(Color.white);
46

    
47
                //g2.setColor(color);
48
                g2.fillRect(0,0,getWidth(),getHeight());
49
                g2.drawImage(icon.getImage(),0,0,this);
50

    
51
        }
52
        public void setSelected(boolean b) {
53
                isSelected=b;
54
        }
55
        public void setIcon(ImageIcon icon) {
56
                this.icon=icon;
57
                repaint();
58
        }
59
        public ImageIcon getIcon() {
60
                return icon;
61
        }
62

    
63
        /* (non-Javadoc)
64
         * @see java.awt.Component#isShowing()
65
         */
66
        public boolean isShowing() {
67
                return true; // super.isShowing();
68
        }
69

    
70

    
71
        public boolean isSelected() {
72
                return isSelected;
73
        }
74

    
75

    
76
        public synchronized void addMouseListener(MouseListener arg0) {
77
                super.addMouseListener(arg0);
78

    
79
        }
80
}  //  @jve:visual-info  decl-index=0 visual-constraint="10,10"