private Collection<LicenseHistogramDataPoint> createLicenseHistogram(BaseCheckPoliciesResult result) {
        Collection<LicenseHistogramDataPoint> dataPoints = new ArrayList<LicenseHistogramDataPoint>();

        // create distribution histogram
        Map<String, Integer> licenseHistogram = new HashMap<String, Integer>();
        for (Map.Entry<String, Collection<ResourceInfo>> entry : result.getProjectNewResources().entrySet()) {
            for (ResourceInfo resource : entry.getValue()) {
                for (String license : resource.getLicenses()) {
                    licenseHistogram.put(license, MapUtils.getInteger(licenseHistogram, license, 0) + 1);
                }
            }
        }

        // sort by count descending
        List<Map.Entry<String, Integer>> licenses = new ArrayList<Map.Entry<String, Integer>>(licenseHistogram.entrySet());
        Collections.sort(licenses, new ValueComparator());

        // create data points
        if (!licenses.isEmpty()) {
            // first licenses
            for (Map.Entry<String, Integer> entry : licenses.subList(0, Math.min(LICENSE_LIMIT, licenses.size()))) {
                dataPoints.add(new LicenseHistogramDataPoint(entry.getKey(), entry.getValue()));
            }

            // aggregation of histogram tail
            int tailSize = licenses.size() - LICENSE_LIMIT;
            int tailSum = 0;
            if (tailSize > 0) {
                for (Map.Entry<String, Integer> entry : licenses.subList(LICENSE_LIMIT, licenses.size())) {
                    tailSum += entry.getValue();
                }
                dataPoints.add(new LicenseHistogramDataPoint(OTHER_LICENSE + " (" + tailSize + ")", tailSum));
            }

            // normalize bar height
            float factor = MAX_BAR_HEIGHT / (float) Math.max(tailSum, licenses.get(0).getValue());
            for (LicenseHistogramDataPoint dataPoint : dataPoints) {
                dataPoint.setHeight((int) (factor * dataPoint.getOccurrences()));
            }
        }

        return dataPoints;
    }
private Collection < LicenseHistogramDataPoint > createLicenseHistogram ( BaseCheckPoliciesResult result ) { Collection < LicenseHistogramDataPoint > dataPoints = new ArrayList < LicenseHistogramDataPoint > ( ) ; Map < String , Integer > licenseHistogram = new HashMap < String , Integer > ( ) ; for ( Map . Entry < String , Collection < ResourceInfo > > entry : result . getProjectNewResources ( ) . entrySet ( ) ) { for ( ResourceInfo resource : entry . getValue ( ) ) { for ( String license : resource . getLicenses ( ) ) { licenseHistogram . put ( license , MapUtils . getInteger ( licenseHistogram , license , 0 ) + 1 ) ; } } } List < Map . Entry < String , Integer > > licenses = new ArrayList < Map . Entry < String , Integer > > ( licenseHistogram . entrySet ( ) ) ; Collections . sort ( licenses , new ValueComparator ( ) ) ; if ( ! licenses . isEmpty ( ) ) { for ( Map . Entry < String , Integer > entry : licenses . subList ( 0 , Math . min ( LICENSE_LIMIT , licenses . size ( ) ) ) ) { dataPoints . add ( new LicenseHistogramDataPoint ( entry . getKey ( ) , entry . getValue ( ) ) ) ; } int tailSize = licenses . size ( ) - LICENSE_LIMIT ; int tailSum = 0 ; if ( tailSize > 0 ) { for ( Map . Entry < String , Integer > entry : licenses . subList ( LICENSE_LIMIT , licenses . size ( ) ) ) { tailSum += entry . getValue ( ) ; } dataPoints . add ( new LicenseHistogramDataPoint ( OTHER_LICENSE + " (" + tailSize + ")" , tailSum ) ) ; } float factor = MAX_BAR_HEIGHT / ( float ) Math . max ( tailSum , licenses . get ( 0 ) . getValue ( ) ) ; for ( LicenseHistogramDataPoint dataPoint : dataPoints ) { dataPoint . setHeight ( ( int ) ( factor * dataPoint . getOccurrences ( ) ) ) ; } } return dataPoints ; }
/* --- Private methods ---