1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.log4j.chainsaw;
19
20 import java.awt.*;
21
22 import javax.swing.*;
23
24
25 /***
26 * An Icon that is a Nice arrow to be used for displaying which
27 * Column is being used for sorting.
28 * @author Claude Duguay
29 */
30 public class SortArrowIcon implements Icon {
31 public static final int NONE = 0;
32 public static final int DECENDING = 1;
33 public static final int ASCENDING = 2;
34 protected int direction;
35 protected int width = 8;
36 protected int height = 8;
37
38 public SortArrowIcon(int direction) {
39 this.direction = direction;
40 }
41
42 public int getIconWidth() {
43 return width;
44 }
45
46 public int getIconHeight() {
47 return height;
48 }
49
50 public void paintIcon(Component c, Graphics g, int x, int y) {
51 Color bg = c.getBackground();
52 Color light = bg.brighter();
53 Color shade = bg.darker();
54
55 int w = width;
56 int h = height;
57 int m = w / 2;
58
59 if (direction == ASCENDING) {
60 g.setColor(shade);
61 g.drawLine(x, y, x + w, y);
62 g.drawLine(x, y, x + m, y + h);
63 g.setColor(light);
64 g.drawLine(x + w, y, x + m, y + h);
65 }
66
67 if (direction == DECENDING) {
68 g.setColor(shade);
69 g.drawLine(x + m, y, x, y + h);
70 g.setColor(light);
71 g.drawLine(x, y + h, x + w, y + h);
72 g.drawLine(x + m, y, x + w, y + h);
73 }
74 }
75 }