public void rotate(int deg) { log.debug("rotate({}) with _rotateText {}, _text {}, _icon {}", deg, _rotateText, _text, _icon); _degrees = deg; if (_rotateText || deg == 0) { if (deg == 0) { // restore unrotated whatever _rotateText = false; if (_text) { log.debug(" super.setText(\"{}\");", _unRotatedText); super.setText(_unRotatedText); if (_popupUtil != null) { setOpaque(_popupUtil.hasBackground()); _popupUtil.setBorder(true); } if (_icon) { String url = _namedIcon.getURL(); _namedIcon = new NamedIcon(url, url); } else { _namedIcon = null; } super.setIcon(_namedIcon); } else { _namedIcon.rotate(deg, this); super.setIcon(_namedIcon); } } else { if (_text & _icon) { // update text over icon _namedIcon = makeTextOverlaidIcon(_unRotatedText, _namedIcon); } else if (_text) { // update text only icon image _namedIcon = makeTextIcon(_unRotatedText); } _namedIcon.rotate(deg, this); super.setIcon(_namedIcon); setOpaque(false); // rotations cannot be opaque } } else { if (deg != 0) { // first time text or icon is rotated from horizontal if (_text && _icon) { // text overlays icon e.g. LocoIcon _namedIcon = makeTextOverlaidIcon(_unRotatedText, _namedIcon); super.setText(null); _rotateText = true; setOpaque(false); } else if (_text) { _namedIcon = makeTextIcon(_unRotatedText); super.setText(null); _rotateText = true; setOpaque(false); } if (_popupUtil != null) { _popupUtil.setBorder(false); } _namedIcon.rotate(deg, this); super.setIcon(_namedIcon); } else if (_namedIcon != null) { _namedIcon.rotate(deg, this); super.setIcon(_namedIcon); } } updateSize(); }