public void createMeasureDimensionValueCombinationCrosstab ( final Map < ValueCombination < Number > , Number > valueCombinations , final Crosstab < Number > valueCombinationCrosstab ) { if ( CrosstabReducerHelper . findDimension ( valueCombinationCrosstab , BooleanAnalyzer . DIMENSION_MEASURE ) ) { final SortedSet < Entry < ValueCombination < Number > , Number > > entries = new TreeSet <> ( frequentValueCombinationComparator ) ; entries . addAll ( valueCombinations . entrySet ( ) ) ; final CrosstabNavigator < Number > nav = new CrosstabNavigator <> ( valueCombinationCrosstab ) ; final CrosstabDimension measureDimension = valueCombinationCrosstab . getDimension ( BooleanAnalyzer . DIMENSION_MEASURE ) ; final CrosstabDimension columnDimension = valueCombinationCrosstab . getDimension ( BooleanAnalyzer . DIMENSION_COLUMN ) ; final List < String > columnDimCategories = columnDimension . getCategories ( ) ; int row = 0 ; for ( final Entry < ValueCombination < Number > , Number > entry : entries ) { // create the category final String measureName ; if ( row == 0 ) { measureName = BooleanAnalyzer . MEASURE_MOST_FREQUENT ; } else if ( row == entries . size ( ) - 1 ) { measureName = BooleanAnalyzer . MEASURE_LEAST_FREQUENT ; } else { measureName = BooleanAnalyzer . DIMENSION_COMBINATION_PREFIX + row ; } measureDimension . addCategory ( measureName ) ; // extract data final Number [ ] values = new Number [ columnDimCategories . size ( ) ] ; final ValueCombination < Number > key = entry . getKey ( ) ; for ( int i = 0 ; i < key . getValueCount ( ) ; i ++ ) { values [ i ] = key . getValueAt ( i ) ; } values [ columnDimCategories . size ( ) - 1 ] = entry . getValue ( ) ; // put data into crosstab for ( int i = 0 ; i < columnDimCategories . size ( ) ; i ++ ) { nav . where ( columnDimension , columnDimCategories . get ( i ) ) ; nav . where ( measureDimension , measureName ) ; nav . put ( values [ i ] ) ; } row ++ ; } } }
Creates the measure dimension based on the sorted value combinations