public int calcReqWidthByStateAndInfos ( List < Glyph > stateORinfoList ) { int wholeSize = 0 ; int count = 0 ; for ( Glyph tmpGlyph : stateORinfoList ) { String text ; if ( tmpGlyph . getState ( ) != null ) { text = tmpGlyph . getState ( ) . getValue ( ) ; if ( tmpGlyph . getState ( ) . getVariable ( ) != null && tmpGlyph . getState ( ) . getVariable ( ) . length ( ) > 0 ) { if ( tmpGlyph . getState ( ) . getVariable ( ) != null ) text += "@" + tmpGlyph . getState ( ) . getVariable ( ) ; } } else if ( tmpGlyph . getLabel ( ) != null ) { text = tmpGlyph . getLabel ( ) . getText ( ) ; } else { throw new RuntimeException ( "Encountered an information glyph with no state " + "variable (as modification boxes should have) and no label (as molecule type " + "boxed should have). glyph = " + tmpGlyph ) ; } int numOfUpper = 0 ; int numOfLower = 0 ; for ( int i = 0 ; i < text . length ( ) ; i ++ ) { if ( Character . isLowerCase ( text . charAt ( i ) ) ) { numOfLower ++ ; } else numOfUpper ++ ; } Bbox b = new Bbox ( ) ; tmpGlyph . setBbox ( b ) ; //Set width float requiredSize = numOfLower * LOWERCASE_LETTER_PIXEL_WIDTH + numOfUpper * UPPERCASE_LETTER_PIXEL_WIDTH ; if ( requiredSize < MAX_STATE_AND_INFO_WIDTH ) tmpGlyph . getBbox ( ) . setW ( requiredSize ) ; else tmpGlyph . getBbox ( ) . setW ( STATE_BOUND . width ) ; //Set height tmpGlyph . getBbox ( ) . setH ( MAX_STATE_AND_INFO_HEIGHT ) ; if ( count < MAX_INFO_BOX_NUMBER / 2 ) wholeSize += tmpGlyph . getBbox ( ) . getW ( ) ; count ++ ; } return wholeSize ; }
Calculates required width according to the given list state and info glyphs of this VNode . This method also previously computes the width and height of state and info glyphs according to their label .