Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / listview / RampPainter.java @ 40561

History | View | Annotate | Download (1.8 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.gui.beans.listview;
25

    
26
import java.awt.Color;
27
import java.awt.GradientPaint;
28
import java.awt.Graphics2D;
29
import java.awt.Rectangle;
30
import java.awt.Shape;
31
/**
32
 *
33
 * @version 29/06/2007
34
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
35
 */
36
public class RampPainter implements IIconPaint {
37

    
38
        public RampPainter() {
39
        }
40

    
41
        public void paint(Graphics2D g, boolean isSelected) {
42
                Shape clip = g.getClip();
43
                Rectangle area = clip.getBounds();
44

    
45
                int x1 = area.x;
46
                int x2 = area.x + area.width - 1;
47

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

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