1 19 package org.netbeans.modules.web.jsf.navigation.vwmodel; 20 21 import org.netbeans.modules.web.jsf.navigation.vwmodel.Page; 22 import java.awt.Image ; 23 import com.sun.rave.designtime.DesignBean; 24 import java.awt.Graphics ; 25 import java.awt.Transparency ; 26 import java.awt.image.BufferedImage ; 27 import java.awt.image.ColorModel ; 28 import org.openide.util.Utilities; 29 30 34 public class NavigableComponent { 35 37 private Image bufferedIcon = null; 38 39 NavigableComponent(DesignBean bean, String action, Page on, String name, Image icon) { 40 this.bean = bean; 41 this.setAction(action); 42 this.on = on; 43 this.setName(name); 44 this.setIcon(icon); 45 } 46 private DesignBean bean; 48 private Page on; 49 private String name; 50 private String action; 51 private Image icon; 52 boolean error; boolean dynamic; 55 60 protected int lx; 62 protected int ly; 63 protected int lw; 64 protected int lh; 65 protected int lby; 67 public String toString() { 68 return "PageBean[" + getName() + "," + getOn() + "," + bean + "," + getIcon() + "," + 69 lx + ", " + ly + "," + lw + "," + lh + ", " + lby + 70 "]"; 71 } 72 73 public String getName() { 74 return this.name; 75 } 76 77 public DesignBean getBean() { 78 return this.bean; 79 } 80 81 public void setName(String name) { 82 this.name = name; 83 } 84 85 public String getAction() { 86 return this.action; 87 } 88 89 public void setAction(String action) { 90 this.action = action; 91 } 92 93 public Image getBufferedIcon(){ 94 if (bufferedIcon == null){ 95 bufferedIcon = toBufferedImage(getIcon()); 96 } 98 return bufferedIcon; 99 } 100 101 104 private Image toBufferedImage(Image img) { 105 new javax.swing.ImageIcon (img); 107 BufferedImage rep = createBufferedImage(img.getWidth(null), img.getHeight(null)); 108 Graphics g = rep.createGraphics(); 109 g.drawImage(img, 0, 0, null); 110 g.dispose(); 111 img.flush(); 112 return rep; 113 } 114 115 116 private BufferedImage createBufferedImage(int width, int height) { 117 if (Utilities.getOperatingSystem() == Utilities.OS_MAC) { 118 return new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB_PRE); 119 } 120 ColorModel model = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(). 121 getDefaultScreenDevice().getDefaultConfiguration().getColorModel(Transparency.TRANSLUCENT); 122 BufferedImage buffImage = new BufferedImage (model, 123 model.createCompatibleWritableRaster(width, height), model.isAlphaPremultiplied(), null); 124 return buffImage; 125 } 126 127 protected Page getOn() { 128 return on; 129 } 130 131 protected Image getIcon() { 132 return icon; 133 } 134 135 protected void setIcon(Image icon) { 136 this.icon = icon; 137 } 138 } | Popular Tags |