static SmushingRulesToApply getRulesToApply ( Integer oldLayout , Integer fullLayout ) { List < SmushingRule > horizontalSmushingRules = new ArrayList < SmushingRule > ( ) ; List < SmushingRule > verticalSmushingRules = new ArrayList < SmushingRule > ( ) ; SmushingRule . Layout horizontalLayout = null ; SmushingRule . Layout verticalLayout = null ; int layout = fullLayout != null ? fullLayout : oldLayout ; for ( Integer codeValue : SmushingRule . getAvailableCodeValues ( ) ) { if ( layout >= codeValue ) { layout = layout - codeValue ; SmushingRule rule = SmushingRule . getByCodeValue ( codeValue ) ; if ( rule . getType ( ) == SmushingRule . Type . HORIZONTAL ) { horizontalLayout = rule . getLayout ( ) ; horizontalSmushingRules . add ( rule ) ; } else if ( rule . getType ( ) == SmushingRule . Type . VERTICAL ) { verticalLayout = rule . getLayout ( ) ; verticalSmushingRules . add ( rule ) ; } } } if ( horizontalLayout == null ) { if ( oldLayout == 0 ) { horizontalLayout = SmushingRule . Layout . FITTING ; horizontalSmushingRules . add ( SmushingRule . HORIZONTAL_FITTING ) ; } else if ( oldLayout == - 1 ) { horizontalLayout = SmushingRule . Layout . FULL_WIDTH ; } } else if ( horizontalLayout == SmushingRule . Layout . CONTROLLED_SMUSHING ) { horizontalSmushingRules . remove ( SmushingRule . HORIZONTAL_SMUSHING ) ; } if ( verticalLayout == null ) { verticalLayout = SmushingRule . Layout . FULL_WIDTH ; } else if ( verticalLayout == SmushingRule . Layout . CONTROLLED_SMUSHING ) { verticalSmushingRules . remove ( SmushingRule . VERTICAL_SMUSHING ) ; } return new SmushingRulesToApply ( horizontalLayout , verticalLayout , horizontalSmushingRules , verticalSmushingRules ) ; }
Return definition of smushing logic to be applied .