jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java
author sherman
Tue, 30 Aug 2011 11:53:11 -0700
changeset 10419 12c063b39232
parent 5506 202f599c92aa
child 13604 31089af1a447
permissions -rw-r--r--
7084245: Update usages of InternalError to use exception chaining Summary: to use new InternalError constructor with cause chainning Reviewed-by: alanb, ksrini, xuelei, neugens Contributed-by: sebastian.sickelmann@gmx.de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
     2
 * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.reflect.Field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
public class XMenuItemPeer implements MenuItemPeer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
     * Data members
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * Primary members
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * Window that this item belongs to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private XBaseMenuWindow container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * Target MenuItem. Note that 'target' member
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * in XWindow is required for dispatching events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * This member is only used for accessing its fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * and firing ActionEvent & ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private MenuItem target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Mapping to window
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * Rectange occupied by menu item in container's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * coordinates. Filled by map(...) function from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * XBaseMenuWindow.map()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private Rectangle bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Point in container's coordinate system used as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * origin by drawText.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private Point textOrigin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * Size constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private final static int SEPARATOR_WIDTH = 20;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private final static int SEPARATOR_HEIGHT = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * MenuItem's fields & methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private final static Field f_enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private final static Field f_label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private final static Field f_shortcut;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private final static Method m_getFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private final static Method m_isItemEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    private final static Method m_getActionCommand;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        f_enabled = SunToolkit.getField(MenuItem.class, "enabled");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        f_label = SunToolkit.getField(MenuItem.class, "label");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        f_shortcut = SunToolkit.getField(MenuItem.class, "shortcut");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        m_getFont = SunToolkit.getMethod(MenuComponent.class, "getFont_NoClientCode", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        m_getActionCommand = SunToolkit.getMethod(MenuItem.class, "getActionCommandImpl", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        m_isItemEnabled = SunToolkit.getMethod(MenuItem.class, "isItemEnabled", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Text Metrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Text metrics are filled in calcTextMetrics function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * and reset in resetTextMetrics function. Text metrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * contain calculated dimensions of various components of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    private TextMetrics textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    static class TextMetrics implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
         * Calculated text size members
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        private Dimension textDimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        private int shortcutWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        private int textBaseline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        TextMetrics(Dimension textDimension, int shortcutWidth, int textBaseline) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            this.textDimension = textDimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            this.shortcutWidth = shortcutWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            this.textBaseline = textBaseline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                return super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            } catch (CloneNotSupportedException ex) {
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 5506
diff changeset
   134
                throw new InternalError(ex);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        Dimension getTextDimension() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            return this.textDimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        int getShortcutWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            return this.shortcutWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        int getTextBaseline() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            return this.textBaseline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * Construction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    XMenuItemPeer(MenuItem target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        this.target = target;
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
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Implementaion of interface methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * From MenuComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        //Empty function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public void setFont(Font font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        resetTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        repaintIfShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * From MenuItemPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public void setLabel(String label) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        resetTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        repaintIfShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public void setEnabled(boolean enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        repaintIfShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * DEPRECATED:  Replaced by setEnabled(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @see java.awt.peer.MenuItemPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public void enable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        setEnabled( true );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * DEPRECATED:  Replaced by setEnabled(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @see java.awt.peer.MenuItemPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public void disable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        setEnabled( false );
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
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Access to target's fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    MenuItem getTarget() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        return this.target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    Font getTargetFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if (target == null) {
116
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   217
            return XWindow.getDefaultFont();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            return (Font)m_getFont.invoke(target, new Object[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } catch (InvocationTargetException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
116
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   226
        return XWindow.getDefaultFont();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    String getTargetLabel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            String label = (String)f_label.get(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            return (label == null) ? "" : label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    boolean isTargetEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            return f_enabled.getBoolean(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * Returns true if item and all its parents are enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * This function is used to fix
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    boolean isTargetItemEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            return ((Boolean)m_isItemEnabled.invoke(target, new Object[0])).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        } catch (InvocationTargetException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    String getTargetActionCommand() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            return (String) m_getActionCommand.invoke(target,(Object[]) null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        } catch (InvocationTargetException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    MenuShortcut getTargetShortcut() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            return (MenuShortcut)f_shortcut.get(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    String getShortcutText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        //Fix for 6180413: shortcuts should not be displayed for any of the menuitems in a popup menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        if (container == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        if (container.getRootMenuWindow() instanceof XPopupMenuPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        MenuShortcut sc = getTargetShortcut();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        //TODO:This can potentially call user code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        return (sc == null) ? null : sc.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * Basic manipulations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * This function is called when filling item vectors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * in XMenuWindow & XMenuBar. We need it because peers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * are created earlier than windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @param container the window that this item belongs to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    void setContainer(XBaseMenuWindow container) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        synchronized(XBaseMenuWindow.getMenuTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            this.container = container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * returns the window that this item belongs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    XBaseMenuWindow getContainer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        return this.container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * Overridable behaviour
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * This function should be overriden simply to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * return false in inherited classes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    boolean isSeparator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        boolean r = (getTargetLabel().equals("-"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * Utility functions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * Returns true if container exists and is showing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    boolean isContainerShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        if (container == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        return container.isShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * Repaints item if it is showing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    void repaintIfShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        if (isContainerShowing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            container.postPaintEvent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * This function is invoked when the user clicks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * on menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @param when the timestamp of action event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    void action(long when) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        if (!isSeparator() && isTargetItemEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            XWindow.postEventStatic(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                                                    getTargetActionCommand(), when,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                                                    0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * Text metrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Returns text metrics of menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * This function does not use any locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * and is guaranteed to return some value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * (possibly actual, possibly expired)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    TextMetrics getTextMetrics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        TextMetrics textMetrics = this.textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        if (textMetrics == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            textMetrics = calcTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            this.textMetrics = textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        return textMetrics;
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
     * Returns dimensions of item's label.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * This function does not use any locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * Returns actual or expired  value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * or null if error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    /*Dimension getTextDimension() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        TextMetrics textMetrics = this.textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        if (textMetrics == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            textMetrics = calcTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            this.textMetrics = textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        return (textMetrics != null) ? textMetrics.textDimension : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        }*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * Returns width of item's shortcut label,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * 0 if item has no shortcut.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * The height of shortcut can be deternimed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * from text dimensions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * This function does not use any locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * and is guaranteed to return some value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * (possibly actual, possibly expired)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    /*int getShortcutWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        TextMetrics textMetrics = this.textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        if (textMetrics == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            textMetrics = calcTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            this.textMetrics = textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        return (textMetrics != null) ? textMetrics.shortcutWidth : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    int getTextBaseline() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        TextMetrics textMetrics = this.textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        if (textMetrics == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            textMetrics = calcTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            this.textMetrics = textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        return (textMetrics != null) ? textMetrics.textBaseline : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        }*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    TextMetrics calcTextMetrics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        if (container == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        if (isSeparator()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            return new TextMetrics(new Dimension(SEPARATOR_WIDTH, SEPARATOR_HEIGHT), 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        Graphics g = container.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        if (g == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            g.setFont(getTargetFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            FontMetrics fm = g.getFontMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            String str = getTargetLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            int width = fm.stringWidth(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            int height = fm.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            Dimension textDimension = new Dimension(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            int textBaseline = fm.getHeight() - fm.getAscent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            String sc = getShortcutText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            int shortcutWidth = (sc == null) ? 0 : fm.stringWidth(sc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            return new TextMetrics(textDimension, shortcutWidth, textBaseline);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            g.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    void resetTextMetrics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        textMetrics = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        if (container != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            container.updateSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * Mapping utility functions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * Sets mapping of item to window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @param bounds bounds of item in container's coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @param textOrigin point for drawString in container's coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * @see XBaseMenuWindow.map()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    void map(Rectangle bounds, Point textOrigin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        this.bounds = bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        this.textOrigin = textOrigin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * returns bounds of item that were previously set by map() function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * returns origin of item's text that was previously set by map() function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    Point getTextOrigin() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        return textOrigin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
}