How to use icon changer extension - JorgeBranquinho/outline GitHub Wiki
To use the icon changer extension, it is necessary to implement the interface named "OutlineIcon". The class implementing such interface will be composed by at least 2 methods: getType,setIcon.
The method getType will return the type of object (e.g. Class, Method, Field) that is going to change. The method setIcon, is where the user can choose which image to set the icons to. It's also in this method that the user can choose to apply some kind of requirements so only the objects that fit such requirements may have their icons changed.
Before implementing the interface, one must first setup the extension point.
As we can see in the image above, this extension point has 3 attributes that must be filled before proceding.
- The first, imgpath, is the path where all the images to be used are located.
- The second attribute, is simply the class that is going to implement the interface.
- The third and final attribute, the name of the one using the extension, purely for flare, and also to help identifying the user.
The method getType is supposed to return one of the 3 possible choices in the "OutlineType" Enum Class, available to use. By doing this there is no need to cast the object because, we will already know what type it is going to be (e.g. Class, Method, Field).
WARNINIG: This Method cannot return null!
The method setIcon receives an "OutlineLookup" object as its argument. This is the interface implemented by the following classes: OutlineClass, OutlineMethod, OutlineField. As such, the user can use the "OutlineLookup" object to set one or more requirements before applying the icon change (see appendix below), or the user may simply choose to change the icon (see example below). To do this, the user must simply return the name of the new image. This is shown in the example below.
WARNINIG: This Method cannot return null!
public class Test implements OutlineIcon{
@Override
public OutlineType getType() {
return OutlineType.METHOD;
}
@Override
public boolean setIcon(OutlineLookup o) {
if(o.isPublic()){
return "new_public_m.gif";
}
return "";
}
}
Following the example above, we can see that using the getType method, our user defined that only "OutlineLookup" objects of type "Method" will have their icon changed. In the setIcon method, we can see that in this particular case, only methods that are public are going to have their icon changed.
Before the public method's icon was changed:
After the change:
That's all you really need to know in order to use this extension point!
For more detailed requirements such as, image size, see the aditional documentation on the extension point.
Thank you!
OutlineLookup interface
Returns the name of the Outline Object currently being used.
- getName();
Returns the parent Class of the Outline Object currently being used.
- getParent();
The next methods help check properties of the Outline Objects being used. They either return true if the Object holds such property, or false in case it doesn't have it.
-
isStatic();
-
isFinal();
-
isInterface();
-
isAbstract();
-
isEnum();
-
isInner();
-
isAnon();
-
isConstant();
-
isConstructor();
-
isSynchronized();
-
isPckgprivate();
-
isPrivate();
-
isProtected();
-
isPublic();