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; /** *
Title:
*Description: define two icon in this class, one is up-arrow icon, * th other is down-arrow icon.
*Copyright: Copyright (c) 2009
*Company: VCI
* @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); } } }