Statistics
| Revision:

root / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / listview / RampPainter.java @ 12623

History | View | Annotate | Download (1.75 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.beans.listview;
20

    
21
import java.awt.Color;
22
import java.awt.GradientPaint;
23
import java.awt.Graphics2D;
24
import java.awt.Rectangle;
25
import java.awt.Shape;
26

    
27
import org.gvsig.gui.beans.listview.IIconPaint;
28
/**
29
 *
30
 * @version 29/06/2007
31
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
32
 */
33
public class RampPainter implements IIconPaint {
34

    
35
        public RampPainter() {
36
        }
37

    
38
        public void paint(Graphics2D g, boolean isSelected) {
39
                Shape clip = g.getClip();
40
                Rectangle area = clip.getBounds();
41

    
42
                int x1 = area.x;
43
                int x2 = area.x + area.width - 1;
44

    
45
                Color color1 = Color.green;
46
                Color color2 = Color.red;
47
                g.setPaint(new GradientPaint(area.x, 0, color1, area.x + area.width, 0, color2, false));
48
                g.fillRect(area.x, area.y, area.width, area.height);
49

    
50
                if (isSelected)
51
                        g.setColor(Color.black);
52
                else
53
                        g.setColor(new Color(96, 96, 96));
54
                g.drawRect(x1, area.y, x2 - x1, area.height - 1);
55
        }
56
}