/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
protected static final RecyclableSingleton<AquaButtonUI> buttonUI = new RecyclableSingletonFromDefaultConstructor<AquaButtonUI>(AquaButtonUI.class);
}
// Has the shared instance defaults been initialized?
private boolean defaults_initialized = false;
// load shared instance defaults
if (!defaults_initialized) {
defaults_initialized = true;
}
boolean hasBorder = false;
if (borderProp != null) {
}
if (!hasBorder) setThemeBorder(b);
if (segmentProp != null) {
if (!(border instanceof AquaBorder)) return;
b.setBorder(AquaButtonExtendedTypes.getBorderForPosition(b, b.getClientProperty(BUTTON_TYPE), segmentProp));
}
}
// this space intentionally left blank
// (subclasses need to do work here)
}
// Set the correct border
if (!(genericUI instanceof AquaButtonUI)) return;
if (!ui.isBorderFromProperty(b) && (border == null || border instanceof UIResource || border instanceof AquaButtonBorder)) {
// See BasicGraphicsUtils.getPreferredButtonSize - it returns null for preferred size,
// causing it to use the subcomponent's size, which doesn't allow space for Aqua pushbuttons
boolean iconFont = true;
if (isOnToolbar(b)) {
if (b instanceof JToggleButton) {
} else {
}
// radar 3308129 && (b.getText() == null || b.getText().equals("")))
// we used to only do this for buttons that had images and no text
// now we do it for all buttons that have any images - they cannot
// be a default button.
} else {
iconFont = false;
}
}
}
}
}
return false;
}
// A state that affects border has changed. Make sure we have the right one
// See if the button has overridden the automatic button type
if (!(ui instanceof AquaButtonUI)) return;
}
}
}
}
return false;
}
boolean iconFont = true;
}
}
return true;
}
// put the listener in the button's client properties so that
// we can get at it later
b.putClientProperty(this, listener);
}
}
}
// Uninstall PLAF
//BasicHTML.updateRenderer(c, "");
}
}
b.putClientProperty(this, null);
}
}
defaults_initialized = false;
}
// Create Listeners
return new AquaButtonListener(b);
}
// Paint Methods
final AbstractButton b = (AbstractButton)c;
// we are overdrawing here with translucent colors so we get
// a darkening effect. How can we avoid it. Try clear rect?
if (b.isOpaque()) {
g.setColor(c.getBackground());
}
if (((AbstractButton)c).isBorderPainted()) {
if (border instanceof AquaButtonBorder) {
// only do this if borders are on!
// this also takes care of focus painting.
}
} else {
if (b.isOpaque()) {
else g.setColor(c.getBackground());
}
}
// needs focus to be painted
// for now we don't know exactly what to do...we'll see!
if (b.isFocusPainted() && b.hasFocus()) {
// paint UI specific focus
}
}
// performs icon and text rect calculations
// Paint the Icon
}
}
if (v != null) {
} else {
}
}
}
protected String layoutAndGetText(final Graphics g, final AbstractButton b, final AquaButtonBorder aquaBorder, final Insets i, Rectangle viewRect, Rectangle iconRect, Rectangle textRect) {
// re-initialize the view rect to the selected insets
// reset the text and icon rects
// setup the font
// layout the text and icon
final String text = SwingUtilities.layoutCompoundLabel(b, fm, originalText, b.getIcon(), b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, originalText == null ? 0 : b.getIconTextGap());
// if the text didn't fit - check if the aqua border has alternate Insets that are more adhering
if (alternateContentInsets != null) {
// recursively call and don't pass AquaBorder
}
// there is no Aqua border, go with what we've got
return text;
}
if (model.isSelected()) {
tmpIcon = b.getDisabledSelectedIcon();
} else {
tmpIcon = b.getDisabledIcon();
}
tmpIcon = b.getPressedIcon();
}
}
if (model.isSelected()) {
tmpIcon = b.getRolloverSelectedIcon();
} else {
tmpIcon = b.getRolloverIcon();
}
} else if (model.isSelected()) {
tmpIcon = b.getSelectedIcon();
}
return;
}
}
}
}
/**
* As of Java 2 platform v 1.4 this method should not be used or overriden.
* Use the paintText method which takes the AbstractButton argument.
*/
protected void paintText(final Graphics g, final JComponent c, final Rectangle localTextRect, final String text) {
final AbstractButton b = (AbstractButton)c;
final int mnemonicIndex = AquaMnemonicHandler.isMnemonicHidden() ? -1 : b.getDisplayedMnemonicIndex();
/* Draw the Text */
/*** paint the text normally */
g.setColor(b.getForeground());
} else {
/*** paint the text disabled ***/
}
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemonicIndex, localTextRect.x, localTextRect.y + fm.getAscent());
}
protected void paintText(final Graphics g, final AbstractButton b, final Rectangle localTextRect, final String text) {
}
paint(g, b);
}
// Layout Methods
final Dimension d = getPreferredSize(c);
if (v != null) {
}
return d;
}
final AbstractButton b = (AbstractButton)c;
// fix for Radar #3134273
if (border instanceof AquaButtonBorder) {
}
return d;
}
final Dimension d = getPreferredSize(c);
if (v != null) {
}
return d;
}
final static RecyclableSingleton<AquaHierarchyButtonListener> fHierListener = new RecyclableSingletonFromDefaultConstructor<AquaHierarchyButtonListener>(AquaHierarchyButtonListener.class);
return fHierListener.get();
}
// We need to know when ordinary JButtons are put on JToolbars, but not JComboBoxButtons
// JToggleButtons always have the same border
return (b instanceof JButton || b instanceof JToggleButton && !(b instanceof AquaComboBoxButton) && !(b instanceof JCheckBox) && !(b instanceof JRadioButton));
}
if (shouldInstallHierListener(b)) {
// super put the listener in the button's client properties
}
}
if (shouldInstallHierListener(b)) {
}
}
// Everytime a hierarchy is change we need to check if the button if moved on or from
// a toolbar. If that is the case, we need to re-set the border of the button.
if (!(o instanceof AbstractButton)) return;
final AbstractButton b = (AbstractButton)o;
if (!(ui instanceof AquaButtonUI)) return;
}
}
protected final AbstractButton b;
super(b);
this.b = b;
}
}
// 10-06-03 VL: [Radar 3187049]
// If focusLost arrives while the button has been left-clicked this would disarm the button,
// causing actionPerformed not to fire on mouse release!
//b.getModel().setArmed(false);
}
super.propertyChange(e);
// Repaint the button, since its border needs to handle the new state.
b.repaint();
return;
}
setThemeBorder(b);
return;
}
// Forced border types
final Border border = AquaButtonExtendedTypes.getBorderForPosition(b, value, b.getClientProperty(SEGMENTED_BUTTON_POSITION));
}
return;
}
if (!(border instanceof AquaBorder)) return;
b.setBorder(AquaButtonExtendedTypes.getBorderForPosition(b, b.getClientProperty(BUTTON_TYPE), e.getNewValue()));
}
if (!(border instanceof AquaBorder)) return;
}
}
}
}
}
protected void updateDefaultButton() {
if (!(b instanceof JButton)) return;
if (!((JButton)b).isDefaultButton()) return;
if (!(ui instanceof AquaRootPaneUI)) return;
}
}
}