jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java
author rupashka
Fri, 25 Jul 2008 17:50:36 +0400
changeset 1290 da8902cd496c
parent 2 90ce3da70b43
child 1295 3cf2264a5743
permissions -rw-r--r--
6727661: Code improvement and warnings removing from the swing/plaf packages Summary: Removed unnecessary castings and other warnings Reviewed-by: alexp Contributed-by: Florian Brunner <fbrunnerlist@gmx.ch>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.plaf.synth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import sun.swing.SwingUtilities2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.plaf.basic.BasicHTML;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.swing.plaf.synth.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Wrapper for primitive graphics calls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @author Scott Violet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class SynthGraphicsUtils {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    // These are used in the text painting code to avoid allocating a bunch of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    // garbage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private Rectangle paintIconR = new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private Rectangle paintTextR = new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private Rectangle paintViewR = new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private Insets paintInsets = new Insets(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    // These Rectangles/Insets are used in the text size calculation to avoid a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    // a bunch of garbage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private Rectangle iconR = new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private Rectangle textR = new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private Rectangle viewR = new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private Insets viewSizingInsets = new Insets(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Creates a <code>SynthGraphicsUtils</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public SynthGraphicsUtils() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Draws a line between the two end points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param context Identifies hosting region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param paintKey Identifies the portion of the component being asked
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *                 to paint, may be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @param g Graphics object to paint to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param x1 x origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param y1 y origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param x2 x destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param y2 y destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public void drawLine(SynthContext context, Object paintKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                         Graphics g, int x1, int y1, int x2, int y2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        g.drawLine(x1, y1, x2, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * Draws a line between the two end points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * <p>This implementation supports only one line style key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * <code>"dashed"</code>. The <code>"dashed"</code> line style is applied
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * only to vertical and horizontal lines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <p>Specifying <code>null</code> or any key different from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * <code>"dashed"</code> will draw solid lines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param context identifies hosting region
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param paintKey identifies the portion of the component being asked
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *                 to paint, may be null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param g Graphics object to paint to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param x1 x origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param y1 y origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param x2 x destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param y2 y destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @param styleKey identifies the requested style of the line (e.g. "dashed")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public void drawLine(SynthContext context, Object paintKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                         Graphics g, int x1, int y1, int x2, int y2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                         Object styleKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if ("dashed".equals(styleKey)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            // draw vertical line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            if (x1 == x2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                y1 += (y1 % 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                for (int y = y1; y <= y2; y+=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                    g.drawLine(x1, y, x2, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            // draw horizontal line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            } else if (y1 == y2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                x1 += (x1 % 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                for (int x = x1; x <= x2; x+=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                    g.drawLine(x, y1, x, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            // oblique lines are not supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            drawLine(context, paintKey, g, x1, y1, x2, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Lays out text and an icon returning, by reference, the location to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * place the icon and text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param ss SynthContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param fm FontMetrics for the Font to use, this may be ignored
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param text Text to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @param icon Icon to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param hAlign horizontal alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param vAlign vertical alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param hTextPosition horizontal text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param vTextPosition vertical text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param viewR Rectangle to layout text and icon in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @param iconR Rectangle to place icon bounds in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @param textR Rectangle to place text in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @param iconTextGap gap between icon and text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public String layoutText(SynthContext ss, FontMetrics fm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                         String text, Icon icon, int hAlign,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                         int vAlign, int hTextPosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                         int vTextPosition, Rectangle viewR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                         Rectangle iconR, Rectangle textR, int iconTextGap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (icon instanceof SynthIcon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            SynthIconWrapper wrapper = SynthIconWrapper.get((SynthIcon)icon,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                                            ss);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            String formattedText = SwingUtilities.layoutCompoundLabel(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                      ss.getComponent(), fm, text, wrapper, vAlign, hAlign,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                      vTextPosition, hTextPosition, viewR, iconR, textR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                      iconTextGap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            SynthIconWrapper.release(wrapper);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            return formattedText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        return SwingUtilities.layoutCompoundLabel(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                      ss.getComponent(), fm, text, icon, vAlign, hAlign,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                      vTextPosition, hTextPosition, viewR, iconR, textR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                      iconTextGap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Returns the size of the passed in string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param ss SynthContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @param font Font to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param metrics FontMetrics, may be ignored
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param text Text to get size of.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public int computeStringWidth(SynthContext ss, Font font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                  FontMetrics metrics, String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        return SwingUtilities2.stringWidth(ss.getComponent(), metrics,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                                          text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Returns the minimum size needed to properly render an icon and text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @param ss SynthContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @param font Font to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @param text Text to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @param icon Icon to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @param hAlign horizontal alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @param vAlign vertical alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @param hTextPosition horizontal text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @param vTextPosition vertical text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @param iconTextGap gap between icon and text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param mnemonicIndex Index into text to render the mnemonic at, -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *        indicates no mnemonic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public Dimension getMinimumSize(SynthContext ss, Font font, String text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                      Icon icon, int hAlign, int vAlign, int hTextPosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                      int vTextPosition, int iconTextGap, int mnemonicIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        JComponent c = ss.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                          vAlign, hTextPosition, vTextPosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                          iconTextGap, mnemonicIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        View v = (View) c.getClientProperty(BasicHTML.propertyKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (v != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            size.width -= v.getPreferredSpan(View.X_AXIS) -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                          v.getMinimumSpan(View.X_AXIS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * Returns the maximum size needed to properly render an icon and text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @param ss SynthContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @param font Font to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @param text Text to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @param icon Icon to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @param hAlign horizontal alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @param vAlign vertical alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @param hTextPosition horizontal text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @param vTextPosition vertical text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @param iconTextGap gap between icon and text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @param mnemonicIndex Index into text to render the mnemonic at, -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *        indicates no mnemonic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public Dimension getMaximumSize(SynthContext ss, Font font, String text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                      Icon icon, int hAlign, int vAlign, int hTextPosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                      int vTextPosition, int iconTextGap, int mnemonicIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        JComponent c = ss.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                          vAlign, hTextPosition, vTextPosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                                          iconTextGap, mnemonicIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        View v = (View) c.getClientProperty(BasicHTML.propertyKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (v != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            size.width += v.getMaximumSpan(View.X_AXIS) -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                          v.getPreferredSpan(View.X_AXIS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Returns the maximum height of the the Font from the passed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * SynthContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @param context SynthContext used to determine font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @return maximum height of the characters for the font from the passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *         in context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    public int getMaximumCharHeight(SynthContext context) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        FontMetrics fm = context.getComponent().getFontMetrics(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            context.getStyle().getFont(context));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return (fm.getAscent() + fm.getDescent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Returns the preferred size needed to properly render an icon and text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @param ss SynthContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @param font Font to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @param text Text to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @param icon Icon to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @param hAlign horizontal alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @param vAlign vertical alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @param hTextPosition horizontal text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @param vTextPosition vertical text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @param iconTextGap gap between icon and text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @param mnemonicIndex Index into text to render the mnemonic at, -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *        indicates no mnemonic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public Dimension getPreferredSize(SynthContext ss, Font font, String text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                      Icon icon, int hAlign, int vAlign, int hTextPosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                      int vTextPosition, int iconTextGap, int mnemonicIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        JComponent c = ss.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        Insets insets = c.getInsets(viewSizingInsets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        int dx = insets.left + insets.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        int dy = insets.top + insets.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        if (icon == null && (text == null || font == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            return new Dimension(dx, dy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        else if ((text == null) || ((icon != null) && (font == null))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            return new Dimension(SynthIcon.getIconWidth(icon, ss) + dx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                                 SynthIcon.getIconHeight(icon, ss) + dy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            FontMetrics fm = c.getFontMetrics(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            iconR.x = iconR.y = iconR.width = iconR.height = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            textR.x = textR.y = textR.width = textR.height = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            viewR.x = dx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            viewR.y = dy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            viewR.width = viewR.height = Short.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            layoutText(ss, fm, text, icon, hAlign, vAlign,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                   hTextPosition, vTextPosition, viewR, iconR, textR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                   iconTextGap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            int x1 = Math.min(iconR.x, textR.x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            int x2 = Math.max(iconR.x + iconR.width, textR.x + textR.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            int y1 = Math.min(iconR.y, textR.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            int y2 = Math.max(iconR.y + iconR.height, textR.y + textR.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            Dimension rv = new Dimension(x2 - x1, y2 - y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            rv.width += dx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            rv.height += dy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            return rv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * Paints text at the specified location. This will not attempt to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * render the text as html nor will it offset by the insets of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @param ss SynthContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @param g Graphics used to render string in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @param text Text to render
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @param bounds Bounds of the text to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @param mnemonicIndex Index to draw string at.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public void paintText(SynthContext ss, Graphics g, String text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                          Rectangle bounds, int mnemonicIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        paintText(ss, g, text, bounds.x, bounds.y, mnemonicIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * Paints text at the specified location. This will not attempt to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * render the text as html nor will it offset by the insets of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @param ss SynthContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @param g Graphics used to render string in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @param text Text to render
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @param x X location to draw text at.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @param y Upper left corner to draw text at.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @param mnemonicIndex Index to draw string at.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    public void paintText(SynthContext ss, Graphics g, String text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                          int x, int y, int mnemonicIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        if (text != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            JComponent c = ss.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            FontMetrics fm = SwingUtilities2.getFontMetrics(c, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            y += fm.getAscent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            SwingUtilities2.drawStringUnderlineCharAt(c, g, text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                                                      mnemonicIndex, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * Paints an icon and text. This will render the text as html, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * necessary, and offset the location by the insets of the component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @param ss SynthContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * @param g Graphics to render string and icon into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @param text Text to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @param icon Icon to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @param hAlign horizontal alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @param vAlign vertical alignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @param hTextPosition horizontal text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * @param vTextPosition vertical text position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @param iconTextGap gap between icon and text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @param mnemonicIndex Index into text to render the mnemonic at, -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *        indicates no mnemonic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @param textOffset Amount to offset the text when painting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    public void paintText(SynthContext ss, Graphics g, String text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                      Icon icon, int hAlign, int vAlign, int hTextPosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                      int vTextPosition, int iconTextGap, int mnemonicIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                      int textOffset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        if ((icon == null) && (text == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        JComponent c = ss.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        FontMetrics fm = SwingUtilities2.getFontMetrics(c, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        Insets insets = SynthLookAndFeel.getPaintingInsets(ss, paintInsets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        paintViewR.x = insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        paintViewR.y = insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        paintViewR.width = c.getWidth() - (insets.left + insets.right);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        paintViewR.height = c.getHeight() - (insets.top + insets.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        String clippedText =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            layoutText(ss, fm, text, icon, hAlign, vAlign,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                   hTextPosition, vTextPosition, paintViewR, paintIconR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                   paintTextR, iconTextGap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        if (icon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            Color color = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            if (ss.getStyle().getBoolean(ss, "TableHeader.alignSorterArrow", false) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                "TableHeader.renderer".equals(c.getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                paintIconR.x = paintViewR.width - paintIconR.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                paintIconR.x += textOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            paintIconR.y += textOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            SynthIcon.paintIcon(icon, ss, g, paintIconR.x, paintIconR.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                                paintIconR.width, paintIconR.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            g.setColor(color);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        if (text != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            View v = (View) c.getClientProperty(BasicHTML.propertyKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            if (v != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                v.paint(g, paintTextR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                paintTextR.x += textOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                paintTextR.y += textOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                paintText(ss, g, clippedText, paintTextR, mnemonicIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * Wraps a SynthIcon around the Icon interface, forwarding calls to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * the SynthIcon with a given SynthContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    private static class SynthIconWrapper implements Icon {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   419
        private static final java.util.List<SynthIconWrapper> CACHE = new java.util.ArrayList<SynthIconWrapper>(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        private SynthIcon synthIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        private SynthContext context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        static SynthIconWrapper get(SynthIcon icon, SynthContext context) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            synchronized(CACHE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                int size = CACHE.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                if (size > 0) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   428
                    SynthIconWrapper wrapper = CACHE.remove(size - 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                    wrapper.reset(icon, context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                    return wrapper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            return new SynthIconWrapper(icon, context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        static void release(SynthIconWrapper wrapper) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            wrapper.reset(null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            synchronized(CACHE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                CACHE.add(wrapper);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        SynthIconWrapper(SynthIcon icon, SynthContext context) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            reset(icon, context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        void reset(SynthIcon icon, SynthContext context) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            synthIcon = icon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            this.context = context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            // This is a noop as this should only be for sizing calls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            return synthIcon.getIconWidth(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            return synthIcon.getIconHeight(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
}