uic.model
Class IconFactory.SizeComperator
java.lang.Object
uic.model.IconFactory.SizeComperator
- All Implemented Interfaces:
- Comparator
- Enclosing class:
- IconFactory
- public static class IconFactory.SizeComperator
- extends Object
- implements Comparator
This comperator is usable to sort image sizes in an existing collection for best quality.
Most icon libraries have icons of different sizes and when a size requested does not
return a image we have to look further for almost matches.
For a list of sizes (as Number objects in a collection) this Comparator can be
used to return a sorted list where the best matching size comes first and the worst
matching comes last.
After sorting its a case of trying each item in the collection for a match.
Example usage:
List myList = new Vector();
myList.add(new Integer(22));
myList.add(new Integer(128));
myList.add(new Integer(48));
Collections.sort(myList, new SizeComperator(preferredSize));
Iterator iter = myList.iterator();
while(iter.hasNext()) {
Integer integer = (Integer) iter.next();
// search for icon in dir the represents 'integer' size.
}
IconFactory.SizeComperator
public IconFactory.SizeComperator(int preferredSize)
- Sole constructor.
- Parameters:
preferredSize
- the sizes that is wanted so the closest result will come first.
compare
public int compare(Object o1,
Object o2)
- Specified by:
compare
in interface Comparator
equals
public boolean equals(Object obj)
- Specified by:
equals
in interface Comparator
Copyright © 2002,2003 Thomas Zander Available under the Free Apache licence