KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > base > AscendingIcon


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.core.gui.base;
17
18 import java.awt.Color JavaDoc;
19 import java.awt.Component JavaDoc;
20 import java.awt.Graphics JavaDoc;
21 import java.awt.Graphics2D JavaDoc;
22
23 import javax.swing.ImageIcon JavaDoc;
24
25 @SuppressWarnings JavaDoc( { "serial", "serial" })
26 public class AscendingIcon extends ImageIcon JavaDoc {
27
28     private Color JavaDoc color = new Color JavaDoc(100,100,100);
29
30     public AscendingIcon() {
31         super();
32     }
33
34     public AscendingIcon(Color JavaDoc color) {
35         super();
36         this.color = color;
37     }
38     
39     public void paintIcon(Component JavaDoc c, Graphics JavaDoc g, int x, int y) {
40         Graphics2D JavaDoc g2 = (Graphics2D JavaDoc) g;
41
42         int[] xp = new int[3];
43         int[] yp = new int[3];
44
45         xp[0] = x;
46         xp[1] = x + 9;
47         xp[2] = x + 4;
48
49         yp[0] = y;
50         yp[1] = y;
51         yp[2] = y + 5;
52
53         g2.setColor(color);
54         g2.fillPolygon(xp, yp, 3);
55     }
56
57     /**
58      * @see javax.swing.Icon#getIconHeight()
59      */

60     public int getIconHeight() {
61         return 6;
62     }
63
64     /**
65      * @see javax.swing.Icon#getIconWidth()
66      */

67     public int getIconWidth() {
68         return 10;
69     }
70
71 }
72
Popular Tags