ludc
2024-09-14 36c2449aec5b51e5ed4e5c6841154b746060e09a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.vci.client.ui.image;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Polygon;
 
import javax.swing.Icon;
 
/**
 * <p>Title: </p>
 * <p>Description: define two icon in this class, one is up-arrow icon,
 * th other is down-arrow icon.</p>
 * <p>Copyright: Copyright (c) 2009</p>
 * <p>Company: VCI</p>
 * @author eddie
 * @time 2009-5-6
 * @version 1.0
 */
public class ArrowIcon implements Icon{
 
    public static final int UP = 0;
 
    public static final int DOWN = 1;
 
    private int direction;
 
    private int[] arrowX = { 2, 10, 6 };
 
    private Polygon arrowUpPolygon = new Polygon(arrowX,
        new int[] { 10, 10, 2 }, 3);
 
    private Polygon arrowDownPolygon = new Polygon(arrowX,
        new int[] { 2, 2, 10 }, 3);
 
    public ArrowIcon(int which) {
      direction = which;
    }
 
    public int getIconWidth() {
      return 14;
    }
 
    public int getIconHeight() {
      return 14;
    }
 
    public void paintIcon(Component c, Graphics g, int x, int y) {
      g.setColor(Color.BLACK);
//      pagePolygon.translate(x, y);
//      g.drawPolygon(pagePolygon);
//      pagePolygon.translate(-x, -y);
      if (direction == UP) {
        arrowUpPolygon.translate(x, y);
        g.fillPolygon(arrowUpPolygon);
        arrowUpPolygon.translate(-x, -y);
      } else {
        arrowDownPolygon.translate(x, y);
        g.fillPolygon(arrowDownPolygon);
        arrowDownPolygon.translate(-x, -y);
      }
    }
 
}