void (List<TabInfo> list, TablePassInfo data, int toFitLength) { if (list.isEmpty()) return; int spentLength = 0; int lengthEstimation = 0; for (TabInfo tabInfo : list) { lengthEstimation += Math.max(getMinTabWidth(), myTabs.getInfoToLabel().get(tabInfo).getPreferredSize().width); } final int extraWidth = toFitLength - lengthEstimation; for (Iterator<TabInfo> iterator = list.iterator(); iterator.hasNext(); ) { TabInfo tabInfo = iterator.next(); final TabLabel label = myTabs.getInfoToLabel().get(tabInfo); int length; int lengthIncrement = label.getPreferredSize().width; if (!iterator.hasNext()) { length = Math.min(toFitLength - spentLength, lengthIncrement); } else if (extraWidth <= 0) {//need compress length = (int)(lengthIncrement * (float)toFitLength / lengthEstimation); } else { length = lengthIncrement; } if (tabInfo.isPinned()) { length = Math.min(getMaxPinnedTabWidth(), length); } length = Math.max(getMinTabWidth(), length); data.lengths.put(tabInfo, length); spentLength += length + myTabs.getTabHGap(); } }