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