1 14 package org.compiere.images; 15 16 import java.awt.*; 17 import java.awt.image.*; 18 import javax.swing.*; 19 import javax.swing.plaf.*; 20 import java.net.*; 21 import org.compiere.util.*; 22 import org.compiere.plaf.*; 23 24 30 public class ImageFactory 31 { 32 37 public static ImageIcon getImageIcon (String name) 38 { 39 URL url = org.compiere.Compiere.class.getResource("images/" + name); 40 if (url == null) 41 { 42 Log.error("ImageFactory.getImageIcon - not found: " + name); 43 return null; 44 } 45 return new ImageIcon(url); 46 } 48 49 private static Icon s_HomeIcon = null; 50 51 55 public static Icon getHomeIcon() 56 { 57 if (s_HomeIcon == null) 58 s_HomeIcon = new HomeIcon(); 59 return s_HomeIcon; 60 } 62 65 private static class HomeIcon implements Icon, UIResource 66 { 67 public void paintIcon(Component c, Graphics g, int x, int y) 68 { 69 g.translate(x, y); 70 g.setColor(CompiereLookAndFeel.getControlInfo()); g.drawLine(8,1, 1,8); g.drawLine(8,1, 15,8); g.drawLine(11,2, 11,3); g.drawLine(12,2, 12,4); g.drawLine(3,7, 3,15); g.drawLine(13,7, 13,15); g.drawLine(4,15, 12,15); g.drawLine( 6,9, 6,14); g.drawLine(10,9, 10,14); g.drawLine( 7,9, 9, 9); g.setColor(CompiereLookAndFeel.getControlDarkShadow()); g.fillRect(8,2, 1,1); g.fillRect(7,3, 3,1); 88 g.fillRect(6,4, 5,1); 89 g.fillRect(5,5, 7,1); 90 g.fillRect(4,6, 9,2); 91 g.drawLine(9,12, 9,12); 94 g.setColor(CompiereLookAndFeel.getPrimaryControl()); g.drawLine(4,8, 12,8); g.fillRect(4,9, 2,6); g.fillRect(11,9, 2,6); g.translate(-x, -y); 100 } 101 public int getIconWidth() 102 { 103 return 18; 104 } 105 public int getIconHeight() 106 { 107 return 18; 108 } 109 } 111 112 private static Icon s_FolderIcon = null; 113 114 private static final Dimension s_icon16Size = new Dimension(16, 16); 115 116 120 public static Icon getFolderIcon() 121 { 122 if (s_FolderIcon == null) 123 s_FolderIcon = new FolderIcon(); 124 return s_FolderIcon; 125 } 127 130 private static class FolderIcon extends FolderIcon16 131 { 132 public int getShift() 133 { 134 return -1; 135 } 136 public int getAdditionalHeight() 137 { 138 return 2; 139 } 140 } 142 145 public static class FolderIcon16 implements Icon 146 { 147 transient Image image; 148 149 public void paintIcon (Component c, Graphics g, int x, int y) 150 { 151 if (image == null) 152 { 153 image = new BufferedImage(getIconWidth(), getIconHeight(), 154 BufferedImage.TYPE_INT_ARGB); 155 Graphics imageG = image.getGraphics(); 156 paintMe (c,imageG); 157 imageG.dispose(); 158 } 159 g.drawImage(image, x, y+getShift(), null); 160 } 161 private void paintMe(Component c, Graphics g) 162 { 163 int right = s_icon16Size.width - 1; 164 int bottom = s_icon16Size.height - 1; 165 g.setColor(CompiereLookAndFeel.getPrimaryControlDarkShadow()); g.drawLine(right - 5, 3, right, 3); 168 g.drawLine(right - 6, 4, right, 4); 169 g.setColor(CompiereLookAndFeel.getPrimaryControl()); g.fillRect(2, 7, 13, 8); 172 g.setColor(CompiereLookAndFeel.getPrimaryControlShadow()); g.drawLine(right - 6, 5, right - 1, 5); 175 g.setColor(CompiereLookAndFeel.getPrimaryControlInfo()); g.drawLine(0, 6, 0, bottom); g.drawLine(1, 5, right - 7, 5); g.drawLine(right - 6, 6, right - 1, 6); g.drawLine(right, 5, right, bottom); g.drawLine(0, bottom, right, bottom); g.setColor(CompiereLookAndFeel.getPrimaryControlHighlight()); g.drawLine(1, 6, 1, bottom - 1); 185 g.drawLine(1, 6, right - 7, 6); 186 g.drawLine(right - 6, 7, right - 1, 7); 187 } 188 public int getShift() 189 { 190 return 0; 191 } 192 public int getAdditionalHeight() 193 { 194 return 0; 195 } 196 public int getIconWidth() 197 { 198 return s_icon16Size.width; 199 } 200 public int getIconHeight() 201 { 202 return s_icon16Size.height + getAdditionalHeight(); 203 } 204 } 206 } | Popular Tags |