1 26 27 package org.objectweb.util.browser.plugin.java.reflect; 28 29 import java.lang.reflect.Modifier ; 30 31 import javax.swing.Icon ; 32 import javax.swing.ImageIcon ; 33 34 import org.objectweb.util.browser.api.IconProvider; 35 import org.objectweb.util.browser.core.common.ClassResolver; 36 37 45 public class ClassIconProvider 46 implements IconProvider { 47 48 54 55 protected static Icon interface_; 56 57 58 protected static Icon publicClass_, publicAbstractClass_, publicStaticClass_, publicFinalClass_, publicStaticFinalClass_; 59 60 61 protected static Icon protectedClass_, protectedAbstractClass_, protectedStaticClass_, protectedFinalClass_, protectedStaticFinalClass_; 62 63 64 protected static Icon packageClass_, packageAbstractClass_, packageStaticClass_, packageFinalClass_, packageStaticFinalClass_; 65 66 67 protected static Icon privateClass_, privateFinalClass_; 68 69 70 76 79 public ClassIconProvider(){ 80 interface_ = new ImageIcon (ClassResolver.getResource("interface.png")); 81 publicClass_ = new ImageIcon (ClassResolver.getResource("publicClass.png")); 82 publicAbstractClass_ = new ImageIcon (ClassResolver.getResource("publicAbstractClass.png")); 83 publicStaticClass_ = new ImageIcon (ClassResolver.getResource("publicStaticClass.png")); 84 publicFinalClass_ = new ImageIcon (ClassResolver.getResource("publicFinalClass.png")); 85 publicStaticFinalClass_ = new ImageIcon (ClassResolver.getResource("publicStaticFinalClass.png")); 86 protectedClass_ = new ImageIcon (ClassResolver.getResource("protectedClass.png")); 87 protectedAbstractClass_ = new ImageIcon (ClassResolver.getResource("protectedAbstractClass.png")); 88 protectedStaticClass_ = new ImageIcon (ClassResolver.getResource("protectedStaticClass.png")); 89 protectedFinalClass_ = new ImageIcon (ClassResolver.getResource("protectedFinalClass.png")); 90 protectedStaticFinalClass_ = new ImageIcon (ClassResolver.getResource("protectedStaticFinalClass.png")); 91 privateClass_ = new ImageIcon (ClassResolver.getResource("privateClass.png")); 92 privateFinalClass_ = new ImageIcon (ClassResolver.getResource("privateFinalClass.png")); 93 packageClass_ = new ImageIcon (ClassResolver.getResource("packageClass.png")); 94 packageAbstractClass_ = new ImageIcon (ClassResolver.getResource("packageAbstractClass.png")); 95 packageStaticClass_ = new ImageIcon (ClassResolver.getResource("packageStaticClass.png")); 96 packageFinalClass_ = new ImageIcon (ClassResolver.getResource("packageFinalClass.png")); 97 packageStaticFinalClass_ = new ImageIcon (ClassResolver.getResource("packageStaticFinalClass.png")); 98 } 99 100 106 112 119 public Icon 120 newIcon(Object object){ 121 Class theClass = (Class )object; 122 int modifier = theClass.getModifiers(); 123 if (Modifier.isInterface(modifier)) { 124 return interface_; 125 } else if (Modifier.isPrivate(modifier)){ 126 if (Modifier.isFinal(modifier)) 127 return privateFinalClass_; 128 else 129 return privateClass_; 130 } else if (Modifier.isProtected(modifier)){ 131 if (Modifier.isAbstract(modifier)) 132 return protectedAbstractClass_; 133 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 134 return protectedStaticFinalClass_; 135 else if (Modifier.isStatic(modifier)) 136 return protectedStaticClass_; 137 else if (Modifier.isFinal(modifier)) 138 return protectedFinalClass_; 139 else 140 return protectedClass_; 141 } else if (Modifier.isPublic(modifier)){ 142 if (Modifier.isAbstract(modifier)) 143 return publicAbstractClass_; 144 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 145 return publicStaticFinalClass_; 146 else if (Modifier.isStatic(modifier)) 147 return publicStaticClass_; 148 else if (Modifier.isFinal(modifier)) 149 return publicFinalClass_; 150 else 151 return publicClass_; 152 } else if (!Modifier.isPrivate(modifier) && !Modifier.isProtected(modifier) && !Modifier.isPublic(modifier)){ 153 if (Modifier.isAbstract(modifier)) 154 return packageAbstractClass_; 155 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 156 return packageStaticFinalClass_; 157 else if (Modifier.isStatic(modifier)) 158 return packageStaticClass_; 159 else if (Modifier.isFinal(modifier)) 160 return packageFinalClass_; 161 else 162 return packageClass_; 163 } else 164 return null; 165 166 } 167 168 } | Popular Tags |