1 14 package org.compiere.apps.wf; 15 16 import java.awt.*; 17 import javax.swing.*; 18 19 import org.compiere.util.*; 20 import org.compiere.model.*; 21 22 23 29 public class WFIcon implements Icon 30 { 31 35 public WFIcon (int type) 36 { 37 if (type > 0 && type < MTreeNode.IMAGES.length) 38 m_type = type; 39 } 41 45 public WFIcon (String action) 46 { 47 if (action != null) 48 m_type = MTreeNode.getImageIndex(action); 49 } 51 52 private static int WIDTH = 30; 53 private static int HEIGHT = 30; 54 55 56 private int m_type = 0; 57 private boolean m_selected = false; 58 59 63 public void setSelected (boolean selected) 64 { 65 m_selected = selected; 66 } 68 72 public boolean isSelected() 73 { 74 return m_selected; 75 } 77 87 public void paintIcon (Component c, Graphics g, int x, int y) 88 { 89 Graphics2D g2D = (Graphics2D)g; 90 91 if (m_selected) 93 g2D.setColor(c.getBackground().darker()); 94 else 95 g2D.setColor(c.getBackground().brighter()); 96 g2D.setColor (Color.white); 97 g2D.draw3DRect (x+1, y+1, WIDTH-2, HEIGHT-2, !m_selected); 98 99 Icon icon = MTreeNode.getIcon(m_type); 100 if (icon != null) 101 { 102 int xI = x + ((WIDTH - icon.getIconWidth()) / 2); 103 int yI = y + ((HEIGHT - icon.getIconHeight()) / 2); 104 icon.paintIcon(c, g, xI, yI); 105 } 106 else { 108 int size = 10; 109 int xI = x + ((WIDTH - size) / 2); 110 int yI = y + ((HEIGHT - size) / 2); 111 g2D.setColor(Color.magenta); 112 g2D.fillOval(xI, yI, size, size); 113 } 114 } 116 120 public int getIconWidth() 121 { 122 return WIDTH; 123 } 125 129 public int getIconHeight() 130 { 131 return HEIGHT; 132 } 134 } | Popular Tags |