Dimension (Function<? super Component, ? extends Dimension> size) { Dimension titleSize = myTitleComponent == null ? new Dimension() : size.apply(myTitleComponent); Dimension centeredSize = myCenteredComponent == null ? new Dimension() : size.apply(myCenteredComponent); Dimension actionSize = myActionPanel == null ? new Dimension() : size.apply(myActionPanel); Dimension expandSize = myExpandAction == null || myLayoutData.showMinSize ? new Dimension() : size.apply(myExpandAction); int height = myLayoutData.configuration.topSpaceHeight + titleSize.height + centeredSize.height + Math.max(actionSize.height, expandSize.height) + myLayoutData.configuration.bottomSpaceHeight; if (titleSize.height > 0 && centeredSize.height > 0) { height += myLayoutData.configuration.titleContentSpaceHeight; } if (centeredSize.height > 0 && actionSize.height > 0) { height += myLayoutData.configuration.contentActionsSpaceHeight; } if (titleSize.height > 0 && actionSize.height > 0) { height += myLayoutData.configuration.titleActionsSpaceHeight; } int titleWidth = titleSize.width + myLayoutData.configuration.closeOffset; int centerWidth = centeredSize.width + myLayoutData.configuration.closeOffset; int actionWidth = actionSize.width + expandSize.width; int width = Math.max(centerWidth, Math.max(titleWidth, actionWidth)); if (!myLayoutData.showFullContent) { width = Math.min(width, BalloonLayoutConfiguration.MaxWidth()); } width = Math.max(width, BalloonLayoutConfiguration.MinWidth()); return new Dimension(width, height); }