Search in sources :

Example 1 with ColorFactory

use of com.gitblit.utils.ColorFactory in project gitblit by gitblit.

the class BlamePage method initializeColors.

private Map<?, String> initializeColors(BlameType blameType, List<AnnotatedLine> lines) {
    ColorFactory colorFactory = new ColorFactory();
    Map<?, String> colorMap;
    if (BlameType.AGE == blameType) {
        Set<Date> keys = new TreeSet<Date>(new Comparator<Date>() {

            @Override
            public int compare(Date o1, Date o2) {
                // younger code has a brighter, older code lightens to white
                return o1.compareTo(o2);
            }
        });
        for (AnnotatedLine line : lines) {
            keys.add(line.when);
        }
        // TODO consider making this a setting
        colorMap = colorFactory.getGraduatedColorMap(keys, Color.decode("#FFA63A"));
    } else {
        Set<String> keys = new HashSet<String>();
        for (AnnotatedLine line : lines) {
            if (blameType == BlameType.AUTHOR) {
                keys.add(line.author);
            } else {
                keys.add(line.commitId);
            }
        }
        colorMap = colorFactory.getRandomColorMap(keys);
    }
    return colorMap;
}
Also used : AnnotatedLine(com.gitblit.models.AnnotatedLine) TreeSet(java.util.TreeSet) ColorFactory(com.gitblit.utils.ColorFactory) Date(java.util.Date) HashSet(java.util.HashSet)

Aggregations

AnnotatedLine (com.gitblit.models.AnnotatedLine)1 ColorFactory (com.gitblit.utils.ColorFactory)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1