double theta = getTextRotation();
size.setSize(rotateWidth(size, theta), rotateHeight(size,
theta));
} else {
// #swingx-780 preferred size is not set properly when parent container doesn't enforce the width
View view = getWrappingView();
if (view == null) {
if (isLineWrap() && !MultiLineSupport.isHTML(getText())) {
// view might get lost on LAF change ...
putClientProperty(BasicHTML.propertyKey,
getMultiLineSupport().createView(this));
view = (View) getClientProperty(BasicHTML.propertyKey);
} else {
return size;
}
}
Insets insets = getInsets();
int dx = insets.left + insets.right;
int dy = insets.top + insets.bottom;
//log.fine("INSETS:" + insets);
//log.fine("BORDER:" + this.getBorder());
Rectangle textR = new Rectangle();
Rectangle viewR = new Rectangle();
textR.x = textR.y = textR.width = textR.height = 0;
viewR.x = dx;
viewR.y = dy;
viewR.width = viewR.height = Short.MAX_VALUE;
// layout label
// 1) icon
Rectangle iconR = calculateIconRect();
// 2) init textR
boolean textIsEmpty = (getText() == null) || (getText().length() < 1);
int lsb = 0;
/* Unless both text and icon are non-null, we effectively ignore
* the value of textIconGap.
*/
int gap;
if (textIsEmpty) {
textR.width = textR.height = 0;
gap = 0;
}
else {
int availTextWidth;
gap = (iconR.width == 0) ? 0 : getIconTextGap();
occupiedWidth = dx + iconR.width + gap;
Object parent = getParent();
if (parent != null && (parent instanceof JPanel)) {
JPanel panel = ((JPanel) parent);
Border b = panel.getBorder();
if (b != null) {
Insets in = b.getBorderInsets(panel);
occupiedWidth += in.left + in.right;
}
}
if (getHorizontalTextPosition() == CENTER) {
availTextWidth = viewR.width;
}
else {
availTextWidth = viewR.width - (iconR.width + gap);
}
float xPrefSpan = view.getPreferredSpan(View.X_AXIS);
//log.fine("atw:" + availTextWidth + ", vps:" + xPrefSpan);
textR.width = Math.min(availTextWidth, (int) xPrefSpan);
if (maxLineSpan > 0) {
textR.width = Math.min(textR.width, maxLineSpan);
if (xPrefSpan > maxLineSpan) {
view.setSize(maxLineSpan, textR.height);
}
}
textR.height = (int) view.getPreferredSpan(View.Y_AXIS);
if (textR.height == 0) {
textR.height = getFont().getSize();
}
//log.fine("atw:" + availTextWidth + ", vps:" + xPrefSpan + ", h:" + textR.height);