private Insets getCalculatedInsets( PanePainter pane, int index, boolean selected, Direction direction) { Rectangle b = pane.getBoundsAt(index); final int sizer = b.height + b.width; Icon icon = pane.getIconAt(index); pane.setIconAt(index, new SizeIcon(sizer, sizer)); if (selected) pane.setSelectedIndex(index); Rectangle bounds = pane.getBoundsAt(index); pane.setIconAt(index, icon); pane.setSelectedIndex(DEFAULT_SELECTED_INDEX); int height = bounds.height - sizer - getHeightCompensate(direction); int width = bounds.width - sizer - getWidthCompensate(direction); int top = height / 2; int left = width / 2 + width % 2; int bottom = height / 2 + height % 2; int right = width / 2; return new Insets(top, left, bottom, right); }