jdk/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 453 145f4ac00bfd
child 1299 027d966d5658
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 453
diff changeset
     2
 * Copyright 1998-2008 Sun Microsystems, Inc.  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
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.metal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.plaf.UIResource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.swing.CachedPainter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Factory object that vends <code>Icon</code>s for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * the Java<sup><font size="-2">TM</font></sup> look and feel (Metal).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * These icons are used extensively in Metal via the defaults mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * While other look and feels often use GIFs for icons, creating icons
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * in code facilitates switching to other themes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Each method in this class returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * either an <code>Icon</code> or <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * where <code>null</code> implies that there is no default icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @author Michael C. Albers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
public class MetalIconFactory implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    // List of code-drawn Icons
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static Icon fileChooserDetailViewIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private static Icon fileChooserHomeFolderIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private static Icon fileChooserListViewIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static Icon fileChooserNewFolderIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private static Icon fileChooserUpFolderIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private static Icon internalFrameAltMaximizeIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private static Icon internalFrameCloseIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private static Icon internalFrameDefaultMenuIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private static Icon internalFrameMaximizeIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private static Icon internalFrameMinimizeIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static Icon radioButtonIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private static Icon treeComputerIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private static Icon treeFloppyDriveIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static Icon treeHardDriveIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static Icon menuArrowIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private static Icon menuItemArrowIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private static Icon checkBoxMenuItemIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private static Icon radioButtonMenuItemIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private static Icon checkBoxIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    // Ocean icons
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private static Icon oceanHorizontalSliderThumb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private static Icon oceanVerticalSliderThumb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    // Constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public static final boolean DARK = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public static final boolean LIGHT = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    // Accessor functions for Icons. Does the caching work.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public static Icon getFileChooserDetailViewIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        if (fileChooserDetailViewIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        return fileChooserDetailViewIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    public static Icon getFileChooserHomeFolderIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        if (fileChooserHomeFolderIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return fileChooserHomeFolderIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public static Icon getFileChooserListViewIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if (fileChooserListViewIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            fileChooserListViewIcon = new FileChooserListViewIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        return fileChooserListViewIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public static Icon getFileChooserNewFolderIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (fileChooserNewFolderIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        return fileChooserNewFolderIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public static Icon getFileChooserUpFolderIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        if (fileChooserUpFolderIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        return fileChooserUpFolderIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public static Icon getInternalFrameAltMaximizeIcon(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        return new InternalFrameAltMaximizeIcon(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public static Icon getInternalFrameCloseIcon(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        return new InternalFrameCloseIcon(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public static Icon getInternalFrameDefaultMenuIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        if (internalFrameDefaultMenuIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        return internalFrameDefaultMenuIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public static Icon getInternalFrameMaximizeIcon(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        return new InternalFrameMaximizeIcon(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public static Icon getInternalFrameMinimizeIcon(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return new InternalFrameMinimizeIcon(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public static Icon getRadioButtonIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        if (radioButtonIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            radioButtonIcon = new RadioButtonIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        return radioButtonIcon;
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
     * Returns a checkbox icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public static Icon getCheckBoxIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        if (checkBoxIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            checkBoxIcon = new CheckBoxIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        return checkBoxIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public static Icon getTreeComputerIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if ( treeComputerIcon == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            treeComputerIcon = new TreeComputerIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return treeComputerIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public static Icon getTreeFloppyDriveIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if ( treeFloppyDriveIcon == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            treeFloppyDriveIcon = new TreeFloppyDriveIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return treeFloppyDriveIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    public static Icon getTreeFolderIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return new TreeFolderIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public static Icon getTreeHardDriveIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if ( treeHardDriveIcon == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            treeHardDriveIcon = new TreeHardDriveIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return treeHardDriveIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public static Icon getTreeLeafIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return new TreeLeafIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public static Icon getTreeControlIcon( boolean isCollapsed ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            return new TreeControlIcon( isCollapsed );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public static Icon getMenuArrowIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        if (menuArrowIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            menuArrowIcon = new MenuArrowIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        return menuArrowIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Returns an icon to be used by <code>JCheckBoxMenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @return the default icon for check box menu items,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *         or <code>null</code> if no default exists
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    public static Icon getMenuItemCheckIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public static Icon getMenuItemArrowIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (menuItemArrowIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            menuItemArrowIcon = new MenuItemArrowIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        return menuItemArrowIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public static Icon getCheckBoxMenuItemIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if (checkBoxMenuItemIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return checkBoxMenuItemIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public static Icon getRadioButtonMenuItemIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        if (radioButtonMenuItemIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return radioButtonMenuItemIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public static Icon getHorizontalSliderThumbIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            if (oceanHorizontalSliderThumb == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                oceanHorizontalSliderThumb =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                               new OceanHorizontalSliderThumbIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            return oceanHorizontalSliderThumb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
      // don't cache these, bumps don't get updated otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        return new HorizontalSliderThumbIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public static Icon getVerticalSliderThumbIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            if (oceanVerticalSliderThumb == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                oceanVerticalSliderThumb = new OceanVerticalSliderThumbIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            return oceanVerticalSliderThumb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        // don't cache these, bumps don't get updated otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        return new VerticalSliderThumbIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    // File Chooser Detail View code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    private static class FileChooserDetailViewIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            // Draw outside edge of each of the documents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            //     top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            g.drawLine(2,2, 5,2); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            g.drawLine(2,3, 2,7); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            g.drawLine(3,7, 6,7); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            g.drawLine(6,6, 6,3); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            //     bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            g.drawLine(2,10, 5,10); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            g.drawLine(2,11, 2,15); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            g.drawLine(3,15, 6,15); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            g.drawLine(6,14, 6,11); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            // Draw little dots next to documents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            //     Same color as outside edge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            g.drawLine(8,5, 15,5);     // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            g.drawLine(8,13, 15,13);   // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            // Draw inner highlight on documents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            g.drawRect(3,3, 2,3);   // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            g.drawRect(3,11, 2,3);  // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            // Draw inner inner highlight on documents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            g.drawLine(4,4, 4,5);     // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            g.drawLine(4,12, 4,13);   // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }  // End class FileChooserDetailViewIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    // File Chooser Home Folder code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    private static class FileChooserHomeFolderIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            // Draw outside edge of house
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            g.drawLine(8,1, 1,8);  // left edge of roof
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            g.drawLine(8,1, 15,8); // right edge of roof
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            g.drawLine(11,2, 11,3); // left edge of chimney
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            g.drawLine(12,2, 12,4); // right edge of chimney
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            g.drawLine(3,7, 3,15); // left edge of house
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            g.drawLine(13,7, 13,15); // right edge of house
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            g.drawLine(4,15, 12,15); // bottom edge of house
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            // Draw door frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            //     same color as edge of house
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            g.drawLine( 6,9,  6,14); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            g.drawLine(10,9, 10,14); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            g.drawLine( 7,9,  9, 9); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            // Draw roof body
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            g.fillRect(8,2, 1,1); //top toward bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            g.fillRect(7,3, 3,1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            g.fillRect(6,4, 5,1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            g.fillRect(5,5, 7,1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            g.fillRect(4,6, 9,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            // Draw doornob
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            //     same color as roof body
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            g.drawLine(9,12, 9,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            // Paint the house
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            g.drawLine(4,8, 12,8); // above door
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            g.fillRect(4,9, 2,6); // left of door
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            g.fillRect(11,9, 2,6); // right of door
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }  // End class FileChooserHomeFolderIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    // File Chooser List View code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    private static class FileChooserListViewIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            // Draw outside edge of each of the documents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            //     top left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            g.drawLine(2,2, 5,2); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            g.drawLine(2,3, 2,7); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            g.drawLine(3,7, 6,7); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            g.drawLine(6,6, 6,3); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            //     top right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            g.drawLine(10,2, 13,2); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            g.drawLine(10,3, 10,7); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            g.drawLine(11,7, 14,7); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            g.drawLine(14,6, 14,3); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            //     bottom left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            g.drawLine(2,10, 5,10); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            g.drawLine(2,11, 2,15); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            g.drawLine(3,15, 6,15); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            g.drawLine(6,14, 6,11); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            //     bottom right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            g.drawLine(10,10, 13,10); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            g.drawLine(10,11, 10,15); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            g.drawLine(11,15, 14,15); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            g.drawLine(14,14, 14,11); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            // Draw little dots next to documents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            //     Same color as outside edge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            g.drawLine(8,5, 8,5);     // top left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            g.drawLine(16,5, 16,5);   // top right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            g.drawLine(8,13, 8,13);   // bottom left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            g.drawLine(16,13, 16,13); // bottom right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            // Draw inner highlight on documents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            g.drawRect(3,3, 2,3);   // top left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            g.drawRect(11,3, 2,3);  // top right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            g.drawRect(3,11, 2,3);  // bottom left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            g.drawRect(11,11, 2,3); // bottom right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            // Draw inner inner highlight on documents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            g.drawLine(4,4, 4,5);     // top left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            g.drawLine(12,4, 12,5);   // top right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            g.drawLine(4,12, 4,13);   // bottom left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            g.drawLine(12,12, 12,13); // bottom right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    }  // End class FileChooserListViewIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    // File Chooser New Folder code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    private static class FileChooserNewFolderIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            // Fill background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            g.fillRect(3,5, 12,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            // Draw outside edge of folder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            g.drawLine(1,6,    1,14); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            g.drawLine(2,14,  15,14); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            g.drawLine(15,13, 15,5);  // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            g.drawLine(2,5,    9,5);  // top left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            g.drawLine(10,6,  14,6);  // top right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            // Draw inner folder highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            g.drawLine( 2,6,  2,13); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            g.drawLine( 3,6,  9,6);  // top left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            g.drawLine(10,7, 14,7);  // top right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            // Draw tab on folder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            g.drawLine(11,3, 15,3); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            g.drawLine(10,4, 15,4); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            g.translate(-x, -y);
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 int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            return 18;
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 getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }  // End class FileChooserNewFolderIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    // File Chooser Up Folder code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    private static class FileChooserUpFolderIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            // Fill background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            g.fillRect(3,5, 12,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            // Draw outside edge of folder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            g.drawLine(1,6,    1,14); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            g.drawLine(2,14,  15,14); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            g.drawLine(15,13, 15,5);  // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            g.drawLine(2,5,    9,5);  // top left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            g.drawLine(10,6,  14,6);  // top right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            // Draw the UP arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            //     same color as edge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            g.drawLine(8,13,  8,16); // arrow shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            g.drawLine(8, 9,  8, 9); // arrowhead top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            g.drawLine(7,10,  9,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            g.drawLine(6,11, 10,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            g.drawLine(5,12, 11,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            // Draw inner folder highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            g.drawLine( 2,6,  2,13); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            g.drawLine( 3,6,  9,6);  // top left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            g.drawLine(10,7, 14,7);  // top right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            // Draw tab on folder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            g.drawLine(11,3, 15,3); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            g.drawLine(10,4, 15,4); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            return 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    }  // End class FileChooserUpFolderIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * Defines an icon for Palette close
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    public static class PaletteCloseIcon implements Icon, UIResource, Serializable{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        int iconSize = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            JButton parentButton = (JButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            ButtonModel buttonModel = parentButton.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            Color back;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            Color highlight = MetalLookAndFeel.getPrimaryControlHighlight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            Color shadow = MetalLookAndFeel.getPrimaryControlInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                back = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                back = MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            g.setColor(back);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            g.drawLine( 0, 1, 5, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            g.drawLine( 1, 0, 6, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            g.drawLine( 1, 1, 6, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            g.drawLine( 6, 1, 1, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            g.drawLine( 5,0, 0,5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            g.drawLine(5,1, 1,5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            g.drawLine(6,2, 5,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            g.drawLine(2,6, 3, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            g.drawLine(6,6,6,6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    // Internal Frame Close code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    private static class InternalFrameCloseIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        int iconSize = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        public InternalFrameCloseIcon(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            iconSize = size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            JButton parentButton = (JButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            ButtonModel buttonModel = parentButton.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            Color internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            Color mainItemColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            Color darkHighlightColor = MetalLookAndFeel.getBlack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            Color xLightHighlightColor = MetalLookAndFeel.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            Color boxLightHighlightColor = MetalLookAndFeel.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            // if the inactive window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                backgroundColor = MetalLookAndFeel.getControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                internalBackgroundColor = backgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                mainItemColor = MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                // if inactive and pressed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                    internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                        MetalLookAndFeel.getControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                    xLightHighlightColor = internalBackgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                    mainItemColor = darkHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            // if pressed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            else if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                    MetalLookAndFeel.getPrimaryControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                xLightHighlightColor = internalBackgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                mainItemColor = darkHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                // darkHighlightColor is still "getBlack()"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            // Some calculations that are needed more than once later on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            int oneHalf = (int)(iconSize / 2); // 16 -> 8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            // fill background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            g.setColor(backgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            g.fillRect(0,0, iconSize,iconSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            // fill inside of box area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            g.setColor(internalBackgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            g.fillRect(3,3, iconSize-6,iconSize-6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            // THE BOX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            // the top/left dark higlight - some of this will get overwritten
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            g.drawRect(1,1, iconSize-3,iconSize-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            // draw the inside bottom/right highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            g.drawRect(2,2, iconSize-5,iconSize-5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            // draw the light/outside, bottom/right highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            g.setColor(boxLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            g.drawRect(2,2, iconSize-3,iconSize-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            // draw the "normal" box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            g.drawRect(2,2, iconSize-4,iconSize-4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            g.drawLine(3,iconSize-3, 3,iconSize-3); // lower left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            g.drawLine(iconSize-3,3, iconSize-3,3); // up right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            // THE "X"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            // Dark highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            g.drawLine(4,5, 5,4); // far up left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            g.drawLine(4,iconSize-6, iconSize-6,4); // against body of "X"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            // Light highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            g.setColor(xLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            g.drawLine(6,iconSize-5, iconSize-5,6); // against body of "X"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
              // one pixel over from the body
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            g.drawLine(oneHalf,oneHalf+2, oneHalf+2,oneHalf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
              // bottom right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            g.drawLine(iconSize-5,iconSize-5, iconSize-4,iconSize-5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            g.drawLine(iconSize-5,iconSize-4, iconSize-5,iconSize-4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            // Main color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
              // Upper left to lower right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            g.drawLine(5,5, iconSize-6,iconSize-6); // g.drawLine(5,5, 10,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            g.drawLine(6,5, iconSize-5,iconSize-6); // g.drawLine(6,5, 11,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            g.drawLine(5,6, iconSize-6,iconSize-5); // g.drawLine(5,6, 10,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
              // Lower left to upper right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            g.drawLine(5,iconSize-5, iconSize-5,5); // g.drawLine(5,11, 11,5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            g.drawLine(5,iconSize-6, iconSize-6,5); // g.drawLine(5,10, 10,5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    }  // End class InternalFrameCloseIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    // Internal Frame Alternate Maximize code (actually, the un-maximize icon)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    private static class InternalFrameAltMaximizeIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        int iconSize = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        public InternalFrameAltMaximizeIcon(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            iconSize = size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            JButton parentButton = (JButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            ButtonModel buttonModel = parentButton.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            Color internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            Color mainItemColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            Color darkHighlightColor = MetalLookAndFeel.getBlack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            // ul = Upper Left and lr = Lower Right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            // if the internal frame is inactive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                backgroundColor = MetalLookAndFeel.getControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                internalBackgroundColor = backgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                mainItemColor = MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                // if inactive and pressed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                    internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                        MetalLookAndFeel.getControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                    ulLightHighlightColor = internalBackgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                    mainItemColor = darkHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            // if the button is pressed and the mouse is over it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            else if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                    MetalLookAndFeel.getPrimaryControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                ulLightHighlightColor = internalBackgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                mainItemColor = darkHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                // darkHighlightColor is still "getBlack()"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            // fill background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            g.setColor(backgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            g.fillRect(0,0, iconSize,iconSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            // BOX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            // fill inside the box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            g.setColor(internalBackgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            g.fillRect(3,6, iconSize-9,iconSize-9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
            // draw dark highlight color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            g.drawRect(1,5, iconSize-8,iconSize-8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
            g.drawLine(1,iconSize-2, 1,iconSize-2); // extra pixel on bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
            // draw lower right light highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            g.setColor(lrLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            g.drawRect(2,6, iconSize-7,iconSize-7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            // draw upper left light highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            g.setColor(ulLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            g.drawRect(3,7, iconSize-9,iconSize-9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            // draw the main box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            g.drawRect(2,6, iconSize-8,iconSize-8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
            // Six extraneous pixels to deal with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            g.setColor(ulLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            g.drawLine(iconSize-6,8,iconSize-6,8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            g.drawLine(iconSize-9,6, iconSize-7,8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
            g.drawLine(3,iconSize-3,3,iconSize-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            g.drawLine(iconSize-6,9,iconSize-6,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
            g.setColor(backgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            g.drawLine(iconSize-9,5,iconSize-9,5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
            // ARROW
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
            // do the shaft first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            g.fillRect(iconSize-7,3, 3,5); // do a big block
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            // draw the dark highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
            g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
            g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            // draw the light highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            g.setColor(lrLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            g.drawLine(iconSize-6,3, iconSize-6,3); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            g.drawLine(iconSize-4,8, iconSize-3,8); // under arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    }  // End class InternalFrameAltMaximizeIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    // Code for the default icons that goes in the upper left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    private static class InternalFrameDefaultMenuIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            Color windowBodyColor = MetalLookAndFeel.getWindowBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            Color titleColor = MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            Color edgeColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            // draw background color for title area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            // catch four corners and title area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            g.setColor(titleColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
            g.fillRect(0,0, 16,16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            // fill body of window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            g.setColor(windowBodyColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            g.fillRect(2,6, 13,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            // draw light parts of two "bumps"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            g.drawLine(2,2, 2,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            g.drawLine(5,2, 5,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            g.drawLine(8,2, 8,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            g.drawLine(11,2, 11,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            // draw line around edge of title and icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            g.setColor(edgeColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
            g.drawRect(1,1, 13,13); // entire inner edge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            g.drawLine(1,0, 14,0); // top outter edge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            g.drawLine(15,1, 15,14); // right outter edge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            g.drawLine(1,15, 14,15); // bottom outter edge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            g.drawLine(0,1, 0,14); // left outter edge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            g.drawLine(2,5, 13,5); // bottom of title bar area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            // draw dark part of four "bumps" (same color)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            g.drawLine(3,3, 3,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            g.drawLine(6,3, 6,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            g.drawLine(9,3, 9,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            g.drawLine(12,3, 12,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    }  // End class InternalFrameDefaultMenuIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    // Internal Frame Maximize code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    private static class InternalFrameMaximizeIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        protected int iconSize = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        public InternalFrameMaximizeIcon(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            iconSize = size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            JButton parentButton = (JButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            ButtonModel buttonModel = parentButton.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
            Color internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
            Color mainItemColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            Color darkHighlightColor = MetalLookAndFeel.getBlack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            // ul = Upper Left and lr = Lower Right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            // if the internal frame is inactive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                backgroundColor = MetalLookAndFeel.getControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                internalBackgroundColor = backgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                mainItemColor = MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                // if inactive and pressed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                    internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                        MetalLookAndFeel.getControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                    ulLightHighlightColor = internalBackgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    mainItemColor = darkHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
            // if the button is pressed and the mouse is over it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
            else if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                    MetalLookAndFeel.getPrimaryControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                ulLightHighlightColor = internalBackgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                mainItemColor = darkHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                // darkHighlightColor is still "getBlack()"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
            // fill background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            g.setColor(backgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            g.fillRect(0,0, iconSize,iconSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
            // BOX drawing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            // fill inside the box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            g.setColor(internalBackgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            g.fillRect(3,7, iconSize-10,iconSize-10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            // light highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            g.setColor(ulLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            g.drawRect(3,7, iconSize-10,iconSize-10); // up,left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            g.setColor(lrLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            g.drawRect(2,6, iconSize-7,iconSize-7); // low,right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            // dark highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
            g.drawRect(1,5, iconSize-7,iconSize-7); // outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            g.drawRect(2,6, iconSize-9,iconSize-9); // inner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            // main box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            g.drawRect(2,6, iconSize-8,iconSize-8); // g.drawRect(2,6, 8,8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            // ARROW drawing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            // dark highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
              // down,left to up,right - inside box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            g.drawLine(3,iconSize-5, iconSize-9,7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
              // down,left to up,right - outside box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            g.drawLine(iconSize-6,4, iconSize-5,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
              // outside edge of arrow head
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            g.drawLine(iconSize-7,1, iconSize-7,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
              // outside edge of arrow head
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            g.drawLine(iconSize-6,1, iconSize-2,1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            // light highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            g.setColor(ulLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
              // down,left to up,right - inside box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
            g.drawLine(5,iconSize-4, iconSize-8,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            g.setColor(lrLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            g.drawLine(iconSize-6,3, iconSize-4,5); // outside box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            g.drawLine(iconSize-4,5, iconSize-4,6); // one down from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            g.drawLine(iconSize-2,7, iconSize-1,7); // outside edge arrow head
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            g.drawLine(iconSize-1,2, iconSize-1,6); // outside edge arrow head
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            // main part of arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            g.drawLine(3,iconSize-4, iconSize-3,2); // top edge of staff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            g.drawLine(3,iconSize-3, iconSize-2,2); // bottom edge of staff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
            g.drawLine(4,iconSize-3, 5,iconSize-3); // highlights inside of box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            g.drawLine(iconSize-7,8, iconSize-7,9); // highlights inside of box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            g.drawLine(iconSize-6,2, iconSize-4,2); // top of arrow head
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            g.drawRect(iconSize-3,3, 1,3); // right of arrow head
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    }  // End class InternalFrameMaximizeIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    // Internal Frame Minimize code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    private static class InternalFrameMinimizeIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        int iconSize = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        public InternalFrameMinimizeIcon(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
            iconSize = size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            JButton parentButton = (JButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            ButtonModel buttonModel = parentButton.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
            Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
            Color internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                MetalLookAndFeel.getPrimaryControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            Color mainItemColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            Color darkHighlightColor = MetalLookAndFeel.getBlack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            // ul = Upper Left and lr = Lower Right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
            Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            // if the internal frame is inactive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                backgroundColor = MetalLookAndFeel.getControl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                internalBackgroundColor = backgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                mainItemColor = MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                // if inactive and pressed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                    internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                        MetalLookAndFeel.getControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                    ulLightHighlightColor = internalBackgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                    mainItemColor = darkHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
            // if the button is pressed and the mouse is over it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
            else if (buttonModel.isPressed() && buttonModel.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                internalBackgroundColor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                    MetalLookAndFeel.getPrimaryControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                ulLightHighlightColor = internalBackgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                mainItemColor = darkHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                // darkHighlightColor is still "getBlack()"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
            // fill background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
            g.setColor(backgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
            g.fillRect(0,0, iconSize,iconSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
            // BOX drawing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
            // fill inside the box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
            g.setColor(internalBackgroundColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
            g.fillRect(4,11, iconSize-13,iconSize-13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
            // light highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
            g.setColor(lrLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
            g.drawRect(2,10, iconSize-10,iconSize-11); // low,right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
            g.setColor(ulLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
            g.drawRect(3,10, iconSize-12,iconSize-12); // up,left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
            // dark highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
            g.drawRect(1,8, iconSize-10,iconSize-10); // outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
            g.drawRect(2,9, iconSize-12,iconSize-12); // inner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            // main box
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
            g.drawRect(2,9, iconSize-11,iconSize-11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
            g.drawLine(iconSize-10,10, iconSize-10,10); // up right highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
            g.drawLine(3,iconSize-3, 3,iconSize-3); // low left highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            // ARROW
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            // do the shaft first
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            g.setColor(mainItemColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            g.fillRect(iconSize-7,3, 3,5); // do a big block
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
            g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
            g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            // draw the dark highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            g.setColor(darkHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
            g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
            // draw the light highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            g.setColor(lrLightHighlightColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
            g.drawLine(iconSize-6,3, iconSize-6,3); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
            g.drawLine(iconSize-7,8, iconSize-3,8); // under arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
            return iconSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    }  // End class InternalFrameMinimizeIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    private static class CheckBoxIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        protected int getControlSize() { return 13; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        private void paintOceanIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
            ButtonModel model = ((JCheckBox)c).getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            int w = getIconWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
            int h = getIconHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            if ( model.isEnabled() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                if (model.isPressed() && model.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                    g.setColor(MetalLookAndFeel.getControlShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                    g.fillRect(0, 0, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                    g.fillRect(0, 0, w, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                    g.fillRect(0, 2, 2, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                    g.fillRect(w - 1, 1, 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                    g.fillRect(1, h - 1, w - 2, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                } else if (model.isRollover()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                    MetalUtils.drawGradient(c, g, "CheckBox.gradient", 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                                            w, h, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                    g.drawRect(0, 0, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                    g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                    g.drawRect(1, 1, w - 3, h - 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                    g.drawRect(2, 2, w - 5, h - 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                    MetalUtils.drawGradient(c, g, "CheckBox.gradient", 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                                            w, h, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                    g.drawRect(0, 0, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                g.setColor( MetalLookAndFeel.getControlInfo() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                g.drawRect(0, 0, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
            if (model.isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
                drawCheck(c,g,x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                paintOceanIcon(c, g, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
            ButtonModel model = ((JCheckBox)c).getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            int controlSize = getControlSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
            if ( model.isEnabled() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                if (model.isPressed() && model.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                    g.setColor( MetalLookAndFeel.getControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
                    g.fillRect( x, y, controlSize-1, controlSize-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                    MetalUtils.drawPressed3DBorder(g, x, y, controlSize, controlSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                    MetalUtils.drawFlush3DBorder(g, x, y, controlSize, controlSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                g.setColor(c.getForeground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                g.setColor( MetalLookAndFeel.getControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
                g.drawRect( x, y, controlSize-2, controlSize-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
            if (model.isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
                drawCheck(c,g,x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        protected void drawCheck(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
            int controlSize = getControlSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
            g.fillRect( x+3, y+5, 2, controlSize-8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
            g.drawLine( x+(controlSize-4), y+3, x+5, y+(controlSize-6) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
            g.drawLine( x+(controlSize-4), y+4, x+5, y+(controlSize-5) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
            return getControlSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
            return getControlSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    } // End class CheckBoxIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    // Radio button code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
    private static class RadioButtonIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        public void paintOceanIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
            ButtonModel model = ((JRadioButton)c).getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
            boolean enabled = model.isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
            boolean pressed = (enabled && model.isPressed() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                               model.isArmed());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
            boolean rollover = (enabled && model.isRollover());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
            if (enabled && !pressed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                // PENDING: this isn't quite right, when we're sure it won't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                // change it needs to be cleaned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
                MetalUtils.drawGradient(c, g, "RadioButton.gradient",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                                        1, 1, 10, 10, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
                g.setColor(c.getBackground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                g.fillRect(1, 1, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
                g.fillRect(10, 1, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                g.fillRect(1, 10, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
                g.fillRect(10, 10, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
            else if (pressed || !enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                if (pressed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                    g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
                    g.setColor(MetalLookAndFeel.getControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
                g.fillRect(2, 2, 8, 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                g.fillRect(4, 1, 4, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
                g.fillRect(4, 10, 4, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                g.fillRect(1, 4, 1, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
                g.fillRect(10, 4, 1, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
            // draw Dark Circle (start at top, go clockwise)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
            if (!enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
                g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
                g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
            g.drawLine( 4, 0,  7, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
            g.drawLine( 8, 1,  9, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
            g.drawLine(10, 2, 10, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
            g.drawLine(11, 4, 11, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
            g.drawLine(10, 8, 10, 9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
            g.drawLine( 9,10,  8,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
            g.drawLine( 7,11,  4,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
            g.drawLine( 3,10,  2,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
            g.drawLine( 1, 9,  1, 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
            g.drawLine( 0, 7,  0, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
            g.drawLine( 1, 3,  1, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
            g.drawLine( 2, 1,  3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
            if (pressed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
                g.fillRect(1, 4, 1, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                g.fillRect(2, 2, 1, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
                g.fillRect(3, 2, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
                g.fillRect(4, 1, 4, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
            else if (rollover) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                g.fillRect(4, 1, 4, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
                g.fillRect(8, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
                g.fillRect(9, 4, 2, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
                g.fillRect(8, 8, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
                g.fillRect(4, 9, 4, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
                g.fillRect(2, 8, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
                g.fillRect(1, 4, 2, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                g.fillRect(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
            // selected dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
            if (model.isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
                if (enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
                    g.setColor(MetalLookAndFeel.getControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
                g.fillRect( 4, 4,  4, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                g.drawLine( 4, 3,  7, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                g.drawLine( 8, 4,  8, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                g.drawLine( 7, 8,  4, 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                g.drawLine( 3, 7,  3, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                paintOceanIcon(c, g, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
            JRadioButton rb = (JRadioButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
            ButtonModel model = rb.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
            boolean drawDot = model.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
            Color background = c.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
            Color dotColor = c.getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            Color shadow = MetalLookAndFeel.getControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
            Color darkCircle = MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            Color whiteInnerLeftArc = MetalLookAndFeel.getControlHighlight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
            Color whiteOuterRightArc = MetalLookAndFeel.getControlHighlight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
            Color interiorColor = background;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
            // Set up colors per RadioButtonModel condition
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
            if ( !model.isEnabled() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
                whiteInnerLeftArc = whiteOuterRightArc = background;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
                darkCircle = dotColor = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
            else if (model.isPressed() && model.isArmed() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
                whiteInnerLeftArc = interiorColor = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
            // fill interior
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            g.setColor(interiorColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
            g.fillRect(2,2, 9,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
            // draw Dark Circle (start at top, go clockwise)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
            g.setColor(darkCircle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
            g.drawLine( 4, 0,  7, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
            g.drawLine( 8, 1,  9, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
            g.drawLine(10, 2, 10, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
            g.drawLine(11, 4, 11, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
            g.drawLine(10, 8, 10, 9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
            g.drawLine( 9,10,  8,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
            g.drawLine( 7,11,  4,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
            g.drawLine( 3,10,  2,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
            g.drawLine( 1, 9,  1, 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
            g.drawLine( 0, 7,  0, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
            g.drawLine( 1, 3,  1, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
            g.drawLine( 2, 1,  3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
            // draw Inner Left (usually) White Arc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
            //  start at lower left corner, go clockwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
            g.setColor(whiteInnerLeftArc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
            g.drawLine( 2, 9,  2, 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
            g.drawLine( 1, 7,  1, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
            g.drawLine( 2, 2,  2, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
            g.drawLine( 2, 2,  3, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
            g.drawLine( 4, 1,  7, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
            g.drawLine( 8, 2,  9, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
            // draw Outer Right White Arc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
            //  start at upper right corner, go clockwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
            g.setColor(whiteOuterRightArc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
            g.drawLine(10, 1, 10, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
            g.drawLine(11, 2, 11, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
            g.drawLine(12, 4, 12, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
            g.drawLine(11, 8, 11, 9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
            g.drawLine(10,10, 10,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
            g.drawLine( 9,11,  8,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
            g.drawLine( 7,12,  4,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
            g.drawLine( 3,11,  2,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
            // selected dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
            if ( drawDot ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                g.setColor(dotColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
                g.fillRect( 4, 4,  4, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
                g.drawLine( 4, 3,  7, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
                g.drawLine( 8, 4,  8, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
                g.drawLine( 7, 8,  4, 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
                g.drawLine( 3, 7,  3, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
            return 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
            return 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    }  // End class RadioButtonIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
    // Tree Computer Icon code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
    private static class TreeComputerIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
            // Fill glass portion of monitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
            g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
            g.fillRect(5,4, 6,4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
            // Draw outside edge of monitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
            g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
            g.drawLine( 2,2,  2,8); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
            g.drawLine(13,2, 13,8); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
            g.drawLine( 3,1, 12,1); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
            g.drawLine(12,9, 12,9); // bottom right base
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
            g.drawLine( 3,9,  3,9); // bottom left base
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
            // Draw the edge of the glass
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
            g.drawLine( 4,4,  4,7); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
            g.drawLine( 5,3, 10,3); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
            g.drawLine(11,4, 11,7); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
            g.drawLine( 5,8, 10,8); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
            // Draw the edge of the CPU
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
            g.drawLine( 1,10, 14,10); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
            g.drawLine(14,10, 14,14); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
            g.drawLine( 1,14, 14,14); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
            g.drawLine( 1,10,  1,14); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
            // Draw the disk drives
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
            g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
            g.drawLine( 6,12,  8,12); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
            g.drawLine(10,12, 12,12); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
    }  // End class TreeComputerIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
    // Tree HardDrive Icon code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
    private static class TreeHardDriveIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
            // Draw edges of the disks
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
            g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
            //     top disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
            g.drawLine(1,4, 1,5); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
            g.drawLine(2,3, 3,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
            g.drawLine(4,2, 11,2); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
            g.drawLine(12,3, 13,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
            g.drawLine(14,4, 14,5); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
            g.drawLine(12,6, 13,6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
            g.drawLine(4,7, 11,7); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
            g.drawLine(2,6, 3,6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
            //     middle disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
            g.drawLine(1,7, 1,8); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
            g.drawLine(2,9, 3,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
            g.drawLine(4,10, 11,10); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
            g.drawLine(12,9, 13,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
            g.drawLine(14,7, 14, 8); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
            //     bottom disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
            g.drawLine(1,10, 1,11); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
            g.drawLine(2,12, 3,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
            g.drawLine(4,13, 11,13); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
            g.drawLine(12,12, 13,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
            g.drawLine(14,10, 14,11); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
            // Draw the down right shadows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
            g.setColor(MetalLookAndFeel.getControlShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
            //     top disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
            g.drawLine(7,6, 7,6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
            g.drawLine(9,6, 9,6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
            g.drawLine(10,5, 10,5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
            g.drawLine(11,6, 11,6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
            g.drawLine(12,5, 13,5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
            g.drawLine(13,4, 13,4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
            //     middle disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
            g.drawLine(7,9, 7,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
            g.drawLine(9,9, 9,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
            g.drawLine(10,8, 10,8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
            g.drawLine(11,9, 11,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
            g.drawLine(12,8, 13,8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
            g.drawLine(13,7, 13,7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
            //     bottom disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
            g.drawLine(7,12, 7,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
            g.drawLine(9,12, 9,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
            g.drawLine(10,11, 10,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
            g.drawLine(11,12, 11,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
            g.drawLine(12,11, 13,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
            g.drawLine(13,10, 13,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            // Draw the up left highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
            g.setColor(MetalLookAndFeel.getControlHighlight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
            //     top disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
            g.drawLine(4,3, 5,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
            g.drawLine(7,3, 9,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
            g.drawLine(11,3, 11,3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
            g.drawLine(2,4, 6,4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
            g.drawLine(8,4, 8,4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
            g.drawLine(2,5, 3,5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
            g.drawLine(4,6, 4,6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
            //     middle disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
            g.drawLine(2,7, 3,7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
            g.drawLine(2,8, 3,8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
            g.drawLine(4,9, 4,9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
            //     bottom disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
            g.drawLine(2,10, 3,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
            g.drawLine(2,11, 3,11);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
            g.drawLine(4,12, 4,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
    }  // End class TreeHardDriveIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
    // Tree FloppyDrive Icon code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
    private static class TreeFloppyDriveIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
            // Fill body of floppy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
            g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
            g.fillRect(2,2, 12,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
            // Draw outside edge of floppy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
            g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
            g.drawLine( 1, 1, 13, 1); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
            g.drawLine(14, 2, 14,14); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
            g.drawLine( 1,14, 14,14); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
            g.drawLine( 1, 1,  1,14); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
            // Draw grey-ish highlights
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
            g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
            g.fillRect(5,2, 6,5); // metal disk protector part
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
            g.drawLine(4,8, 11,8); // top of label
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
            g.drawLine(3,9, 3,13); // left of label
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
            g.drawLine(12,9, 12,13); // right of label
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
            // Draw label and exposed disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
            g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
            g.fillRect(8,3, 2,3); // exposed disk
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
            g.fillRect(4,9, 8,5); // label
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
            // Draw text on label
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
            g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
            g.drawLine(5,10, 9,10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
            g.drawLine(5,12, 8,12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
            g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
    }  // End class TreeFloppyDriveIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
    static private final Dimension folderIcon16Size = new Dimension( 16, 16 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
     * Utility class for caching icon images.  This is necessary because
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
     * we need a new image whenever we are rendering into a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
     * GraphicsConfiguration, but we do not want to keep recreating icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
     * images for GC's that we have already seen (for example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
     * dragging a window back and forth between monitors on a multimon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
     * system, or drawing an icon to different Components that have different
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
     * GC's).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
     * So now whenever we create a new icon image for a given GC, we
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
     * cache that image with the GC for later retrieval.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
    static class ImageCacher {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
        // PENDING: Replace this class with CachedPainter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
        Vector images = new Vector(1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
        ImageGcPair currentImageGcPair;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
        class ImageGcPair {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
            Image image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
            GraphicsConfiguration gc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
            ImageGcPair(Image image, GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
                this.image = image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
                this.gc = gc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
            boolean hasSameConfiguration(GraphicsConfiguration newGC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
                if (((newGC != null) && (newGC.equals(gc))) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
                    ((newGC == null) && (gc == null)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
        Image getImage(GraphicsConfiguration newGC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
            if ((currentImageGcPair == null) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
                !(currentImageGcPair.hasSameConfiguration(newGC)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
                Enumeration elements = images.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
                while (elements.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
                    ImageGcPair imgGcPair = (ImageGcPair)elements.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
                    if (imgGcPair.hasSameConfiguration(newGC)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
                        currentImageGcPair = imgGcPair;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
                        return imgGcPair.image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
            return currentImageGcPair.image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
        void cacheImage(Image image, GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
            ImageGcPair imgGcPair = new ImageGcPair(image, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
            images.addElement(imgGcPair);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
            currentImageGcPair = imgGcPair;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
    public static class FolderIcon16 implements Icon, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
        ImageCacher imageCacher;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
            GraphicsConfiguration gc = c.getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
            if (imageCacher == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
                imageCacher = new ImageCacher();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
            Image image = imageCacher.getImage(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
            if (image == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
                if (gc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
                    image = gc.createCompatibleImage(getIconWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
                                                     getIconHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
                                                     Transparency.BITMASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
                    image = new BufferedImage(getIconWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
                                              getIconHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
                                              BufferedImage.TYPE_INT_ARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
                Graphics imageG = image.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
                paintMe(c,imageG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
                imageG.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
                imageCacher.cacheImage(image, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
            g.drawImage(image, x, y+getShift(), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
        private void paintMe(Component c, Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
            int right = folderIcon16Size.width - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
            int bottom = folderIcon16Size.height - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
            // Draw tab top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
            g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
            g.drawLine( right - 5, 3, right, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
            g.drawLine( right - 6, 4, right, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
            // Draw folder front
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
            g.setColor( MetalLookAndFeel.getPrimaryControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
            g.fillRect( 2, 7, 13, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
            // Draw tab bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
            g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
            g.drawLine( right - 6, 5, right - 1, 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
            // Draw outline
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
            g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
            g.drawLine( 0, 6, 0, bottom );            // left side
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
            g.drawLine( 1, 5, right - 7, 5 );         // first part of top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
            g.drawLine( right - 6, 6, right - 1, 6 ); // second part of top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
            g.drawLine( right, 5, right, bottom );    // right side
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
            g.drawLine( 0, bottom, right, bottom );   // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
            // Draw highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
            g.drawLine( 1, 6, 1, bottom - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
            g.drawLine( 1, 6, right - 7, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
            g.drawLine( right - 6, 7, right - 1, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
        public int getShift() { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
        public int getAdditionalHeight() { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
        public int getIconWidth() { return folderIcon16Size.width; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
        public int getIconHeight() { return folderIcon16Size.height + getAdditionalHeight(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
    public static class TreeFolderIcon extends FolderIcon16 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
        public int getShift() { return -1; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
        public int getAdditionalHeight() { return 2; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
    static private final Dimension fileIcon16Size = new Dimension( 16, 16 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
    public static class FileIcon16 implements Icon, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
        ImageCacher imageCacher;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
            GraphicsConfiguration gc = c.getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
            if (imageCacher == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
                imageCacher = new ImageCacher();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
            Image image = imageCacher.getImage(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
            if (image == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
                if (gc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
                    image = gc.createCompatibleImage(getIconWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
                                                     getIconHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
                                                     Transparency.BITMASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
                    image = new BufferedImage(getIconWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
                                              getIconHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
                                              BufferedImage.TYPE_INT_ARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
                Graphics imageG = image.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
                paintMe(c,imageG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
                imageG.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
                imageCacher.cacheImage(image, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
            g.drawImage(image, x, y+getShift(), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
        private void paintMe(Component c, Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
                int right = fileIcon16Size.width - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
                int bottom = fileIcon16Size.height - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
                // Draw fill
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
                g.setColor( MetalLookAndFeel.getWindowBackground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
                g.fillRect( 4, 2, 9, 12 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
                // Draw frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
                g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
                g.drawLine( 2, 0, 2, bottom );                 // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
                g.drawLine( 2, 0, right - 4, 0 );              // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
                g.drawLine( 2, bottom, right - 1, bottom );    // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
                g.drawLine( right - 1, 6, right - 1, bottom ); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
                g.drawLine( right - 6, 2, right - 2, 6 );      // slant 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
                g.drawLine( right - 5, 1, right - 4, 1 );      // part of slant 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
                g.drawLine( right - 3, 2, right - 3, 3 );      // part of slant 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
                g.drawLine( right - 2, 4, right - 2, 5 );      // part of slant 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
                // Draw highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
                g.setColor( MetalLookAndFeel.getPrimaryControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
                g.drawLine( 3, 1, 3, bottom - 1 );                  // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
                g.drawLine( 3, 1, right - 6, 1 );                   // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
                g.drawLine( right - 2, 7, right - 2, bottom - 1 );  // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
                g.drawLine( right - 5, 2, right - 3, 4 );           // slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
                g.drawLine( 3, bottom - 1, right - 2, bottom - 1 ); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
        public int getShift() { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
        public int getAdditionalHeight() { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
        public int getIconWidth() { return fileIcon16Size.width; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
        public int getIconHeight() { return fileIcon16Size.height + getAdditionalHeight(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
    public static class TreeLeafIcon extends FileIcon16 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
        public int getShift() { return 2; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
        public int getAdditionalHeight() { return 4; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
    static private final Dimension treeControlSize = new Dimension( 18, 18 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
    public static class TreeControlIcon implements Icon, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
        // This data member should not have been exposed.  It's called
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
        // isLight, but now it really means isCollapsed.  Since we can't change
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
        // any APIs... that's life.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
        protected boolean isLight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
        public TreeControlIcon( boolean isCollapsed ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
            isLight = isCollapsed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
        ImageCacher imageCacher;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
        transient boolean cachedOrientation = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
            GraphicsConfiguration gc = c.getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
            if (imageCacher == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
                imageCacher = new ImageCacher();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
            Image image = imageCacher.getImage(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
            if (image == null || cachedOrientation != MetalUtils.isLeftToRight(c)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
                cachedOrientation = MetalUtils.isLeftToRight(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
                if (gc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
                    image = gc.createCompatibleImage(getIconWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
                                                     getIconHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
                                                     Transparency.BITMASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
                    image = new BufferedImage(getIconWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
                                              getIconHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
                                              BufferedImage.TYPE_INT_ARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
                Graphics imageG = image.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
                paintMe(c,imageG,x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
                imageG.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
                imageCacher.cacheImage(image, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
            if (MetalUtils.isLeftToRight(c)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
                if (isLight) {    // isCollapsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
                    g.drawImage(image, x+5, y+3, x+18, y+13,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
                                       4,3, 17, 13, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
                    g.drawImage(image, x+5, y+3, x+18, y+17,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
                                       4,3, 17, 17, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
                if (isLight) {    // isCollapsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
                    g.drawImage(image, x+3, y+3, x+16, y+13,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
                                       4, 3, 17, 13, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
                    g.drawImage(image, x+3, y+3, x+16, y+17,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
                                       4, 3, 17, 17, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
        public void paintMe(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
            g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
            int xoff = (MetalUtils.isLeftToRight(c)) ? 0 : 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
            // Draw circle
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
            g.drawLine( xoff + 4, 6, xoff + 4, 9 );     // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
            g.drawLine( xoff + 5, 5, xoff + 5, 5 );     // top left dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
            g.drawLine( xoff + 6, 4, xoff + 9, 4 );     // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
            g.drawLine( xoff + 10, 5, xoff + 10, 5 );   // top right dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
            g.drawLine( xoff + 11, 6, xoff + 11, 9 );   // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
            g.drawLine( xoff + 10, 10, xoff + 10, 10 ); // botom right dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
            g.drawLine( xoff + 6, 11, xoff + 9, 11 );   // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
            g.drawLine( xoff + 5, 10, xoff + 5, 10 );   // bottom left dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
            // Draw Center Dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
            g.drawLine( xoff + 7, 7, xoff + 8, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
            g.drawLine( xoff + 7, 8, xoff + 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
            // Draw Handle
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
            if ( isLight ) {    // isCollapsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
                if( MetalUtils.isLeftToRight(c) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
                    g.drawLine( 12, 7, 15, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
                    g.drawLine( 12, 8, 15, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
                    //  g.setColor( c.getBackground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
                    //  g.drawLine( 16, 7, 16, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
                    g.drawLine(4, 7, 7, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
                    g.drawLine(4, 8, 7, 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
                g.drawLine( xoff + 7, 12, xoff + 7, 15 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
                g.drawLine( xoff + 8, 12, xoff + 8, 15 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
                //      g.setColor( c.getBackground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
                //      g.drawLine( xoff + 7, 16, xoff + 8, 16 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
            // Draw Fill
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
            g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
            g.drawLine( xoff + 5, 6, xoff + 5, 9 );      // left shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
            g.drawLine( xoff + 6, 5, xoff + 9, 5 );      // top shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
            g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
            g.drawLine( xoff + 6, 6, xoff + 6, 6 );      // top left fill
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
            g.drawLine( xoff + 9, 6, xoff + 9, 6 );      // top right fill
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
            g.drawLine( xoff + 6, 9, xoff + 6, 9 );      // bottom left fill
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
            g.drawLine( xoff + 10, 6, xoff + 10, 9 );    // right fill
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
            g.drawLine( xoff + 6, 10, xoff + 9, 10 );    // bottom fill
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
            g.setColor( MetalLookAndFeel.getPrimaryControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
            g.drawLine( xoff + 6, 7, xoff + 6, 8 );      // left highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
            g.drawLine( xoff + 7, 6, xoff + 8, 6 );      // top highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
            g.drawLine( xoff + 9, 7, xoff + 9, 7 );      // right highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
            g.drawLine( xoff + 7, 9, xoff + 7, 9 );      // bottom highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
            g.drawLine( xoff + 8, 9, xoff + 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
            g.drawLine( xoff + 9, 8, xoff + 9, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
        public int getIconWidth() { return treeControlSize.width; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
        public int getIconHeight() { return treeControlSize.height; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
  //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
  // Menu Icons
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
  //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
    static private final Dimension menuArrowIconSize = new Dimension( 4, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
    static private final Dimension menuCheckIconSize = new Dimension( 10, 10 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
    static private final int xOff = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
    private static class MenuArrowIcon implements Icon, UIResource, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
        public void paintIcon( Component c, Graphics g, int x, int y )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
            JMenuItem b = (JMenuItem) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
            ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
            if ( !model.isEnabled() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
                g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
                if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
                    g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
                    g.setColor( b.getForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
            if( MetalUtils.isLeftToRight(b) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
                g.drawLine( 0, 0, 0, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
                g.drawLine( 1, 1, 1, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
                g.drawLine( 2, 2, 2, 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
                g.drawLine( 3, 3, 3, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
                g.drawLine( 4, 0, 4, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
                g.drawLine( 3, 1, 3, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
                g.drawLine( 2, 2, 2, 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
                g.drawLine( 1, 3, 1, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
        public int getIconWidth() { return menuArrowIconSize.width; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
        public int getIconHeight() { return menuArrowIconSize.height; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
    } // End class MenuArrowIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
    private static class MenuItemArrowIcon implements Icon, UIResource, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
        public void paintIcon( Component c, Graphics g, int x, int y )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
        public int getIconWidth() { return menuArrowIconSize.width; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
        public int getIconHeight() { return menuArrowIconSize.height; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
    } // End class MenuItemArrowIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
    private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
        public void paintOceanIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
            ButtonModel model = ((JMenuItem)c).getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
            boolean isSelected = model.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
            boolean isEnabled = model.isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
            boolean isPressed = model.isPressed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
            boolean isArmed = model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
            if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
                MetalUtils.drawGradient(c, g, "CheckBoxMenuItem.gradient",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
                                        1, 1, 7, 7, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
                if (isPressed || isArmed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
                    g.setColor(MetalLookAndFeel.getControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
                    g.drawLine( 0, 0, 8, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
                    g.drawLine( 0, 0, 0, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
                    g.drawLine( 8, 2, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
                    g.drawLine( 2, 8, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
                    g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
                    g.drawLine( 9, 1, 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
                    g.drawLine( 1, 9, 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
                    g.drawLine( 0, 0, 8, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
                    g.drawLine( 0, 0, 0, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
                    g.drawLine( 8, 2, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
                    g.drawLine( 2, 8, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
                    g.setColor(MetalLookAndFeel.getControlHighlight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
                    g.drawLine( 9, 1, 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
                    g.drawLine( 1, 9, 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
                g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
                g.drawRect( 0, 0, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
            if (isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
                if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
                    if (isArmed || ( c instanceof JMenu && isSelected)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
                        g.setColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
                            MetalLookAndFeel.getMenuSelectedForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
                         g.setColor(MetalLookAndFeel.getControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
                    g.setColor( MetalLookAndFeel.getMenuDisabledForeground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
                g.drawLine( 2, 2, 2, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
                g.drawLine( 3, 2, 3, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
                g.drawLine( 4, 4, 8, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
                g.drawLine( 4, 5, 9, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
        public void paintIcon( Component c, Graphics g, int x, int y )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
                paintOceanIcon(c, g, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
            JMenuItem b = (JMenuItem) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
            ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
            boolean isSelected = model.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
            boolean isEnabled = model.isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
            boolean isPressed = model.isPressed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
            boolean isArmed = model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
            if ( isEnabled )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
                if ( isPressed || isArmed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
                    g.setColor( MetalLookAndFeel.getControlInfo()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
                    g.drawLine( 0, 0, 8, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
                    g.drawLine( 0, 0, 0, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
                    g.drawLine( 8, 2, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
                    g.drawLine( 2, 8, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
                    g.setColor( MetalLookAndFeel.getPrimaryControl()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
                    g.drawLine( 1, 1, 7, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
                    g.drawLine( 1, 1, 1, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
                    g.drawLine( 9, 1, 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
                    g.drawLine( 1, 9, 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
                    g.setColor( MetalLookAndFeel.getControlDarkShadow()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
                    g.drawLine( 0, 0, 8, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
                    g.drawLine( 0, 0, 0, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
                    g.drawLine( 8, 2, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
                    g.drawLine( 2, 8, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
                    g.setColor( MetalLookAndFeel.getControlHighlight()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
                    g.drawLine( 1, 1, 7, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
                    g.drawLine( 1, 1, 1, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
                    g.drawLine( 9, 1, 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
                    g.drawLine( 1, 9, 9, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
                g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
                g.drawRect( 0, 0, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
            if ( isSelected )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
                if ( isEnabled )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
                    if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
                        g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
                        g.setColor( b.getForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
                    g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
                g.drawLine( 2, 2, 2, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
                g.drawLine( 3, 2, 3, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
                g.drawLine( 4, 4, 8, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
                g.drawLine( 4, 5, 9, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
        public int getIconWidth() { return menuCheckIconSize.width; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
        public int getIconHeight() { return menuCheckIconSize.height; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
    }  // End class CheckBoxMenuItemIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
    private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
        public void paintOceanIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
            ButtonModel model = ((JMenuItem)c).getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
            boolean isSelected = model.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
            boolean isEnabled = model.isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
            boolean isPressed = model.isPressed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
            boolean isArmed = model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
            if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
                MetalUtils.drawGradient(c, g, "RadioButtonMenuItem.gradient",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
                                        1, 1, 7, 7, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
                if (isPressed || isArmed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
                    g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
                    g.setColor(MetalLookAndFeel.getControlHighlight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
                g.drawLine( 2, 9, 7, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
                g.drawLine( 9, 2, 9, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
                g.drawLine( 8, 8, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
                if (isPressed || isArmed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
                    g.setColor(MetalLookAndFeel.getControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
                g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
            g.drawLine( 2, 0, 6, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
            g.drawLine( 2, 8, 6, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
            g.drawLine( 0, 2, 0, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
            g.drawLine( 8, 2, 8, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
            g.drawLine( 1, 1, 1, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
            g.drawLine( 7, 1, 7, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
            g.drawLine( 1, 7, 1, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
            g.drawLine( 7, 7, 7, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
            if (isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
                if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
                    if (isArmed || (c instanceof JMenu && model.isSelected())){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
                        g.setColor(MetalLookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
                                   getMenuSelectedForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
                        g.setColor(MetalLookAndFeel.getControlInfo());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
                    g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
                g.drawLine( 3, 2, 5, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
                g.drawLine( 2, 3, 6, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
                g.drawLine( 2, 4, 6, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
                g.drawLine( 2, 5, 6, 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
                g.drawLine( 3, 6, 5, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
        public void paintIcon( Component c, Graphics g, int x, int y )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
                paintOceanIcon(c, g, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
            JMenuItem b = (JMenuItem) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
            ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
            boolean isSelected = model.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
            boolean isEnabled = model.isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
            boolean isPressed = model.isPressed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
            boolean isArmed = model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
            if ( isEnabled )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
                if ( isPressed || isArmed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
                    g.setColor( MetalLookAndFeel.getPrimaryControl()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
                    g.drawLine( 3, 1, 8, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
                    g.drawLine( 2, 9, 7, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
                    g.drawLine( 1, 3, 1, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
                    g.drawLine( 9, 2, 9, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
                    g.drawLine( 2, 2, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
                    g.drawLine( 8, 8, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
                    g.setColor( MetalLookAndFeel.getControlInfo()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
                    g.drawLine( 2, 0, 6, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
                    g.drawLine( 2, 8, 6, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
                    g.drawLine( 0, 2, 0, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
                    g.drawLine( 8, 2, 8, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
                    g.drawLine( 1, 1, 1, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
                    g.drawLine( 7, 1, 7, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
                    g.drawLine( 1, 7, 1, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
                    g.drawLine( 7, 7, 7, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
                    g.setColor( MetalLookAndFeel.getControlHighlight()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
                    g.drawLine( 3, 1, 8, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
                    g.drawLine( 2, 9, 7, 9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
                    g.drawLine( 1, 3, 1, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
                    g.drawLine( 9, 2, 9, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
                    g.drawLine( 2, 2, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
                    g.drawLine( 8, 8, 8, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
                    g.setColor( MetalLookAndFeel.getControlDarkShadow()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
                    g.drawLine( 2, 0, 6, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
                    g.drawLine( 2, 8, 6, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
                    g.drawLine( 0, 2, 0, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
                    g.drawLine( 8, 2, 8, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
                    g.drawLine( 1, 1, 1, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
                    g.drawLine( 7, 1, 7, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
                    g.drawLine( 1, 7, 1, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
                    g.drawLine( 7, 7, 7, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
                g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
                g.drawLine( 2, 0, 6, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
                g.drawLine( 2, 8, 6, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
                g.drawLine( 0, 2, 0, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
                g.drawLine( 8, 2, 8, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
                g.drawLine( 1, 1, 1, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
                g.drawLine( 7, 1, 7, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
                g.drawLine( 1, 7, 1, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
                g.drawLine( 7, 7, 7, 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
            if ( isSelected )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
                if ( isEnabled )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
                    if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
                        g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
                        g.setColor( b.getForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
                    g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2249
                g.drawLine( 3, 2, 5, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2250
                g.drawLine( 2, 3, 6, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2251
                g.drawLine( 2, 4, 6, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2252
                g.drawLine( 2, 5, 6, 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2253
                g.drawLine( 3, 6, 5, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2254
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2255
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2259
        public int getIconWidth() { return menuCheckIconSize.width; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2260
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2261
        public int getIconHeight() { return menuCheckIconSize.height; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2262
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2263
    }  // End class RadioButtonMenuItemIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2265
private static class VerticalSliderThumbIcon implements Icon, Serializable, UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2266
    protected static MetalBumps controlBumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2267
    protected static MetalBumps primaryBumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2268
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2269
    public VerticalSliderThumbIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2270
        controlBumps = new MetalBumps( 6, 10,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
                                MetalLookAndFeel.getControlHighlight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2272
                                MetalLookAndFeel.getControlInfo(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
                                MetalLookAndFeel.getControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
        primaryBumps = new MetalBumps( 6, 10,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2275
                                MetalLookAndFeel.getPrimaryControl(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2276
                                MetalLookAndFeel.getPrimaryControlDarkShadow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2277
                                MetalLookAndFeel.getPrimaryControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2279
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2280
    public void paintIcon( Component c, Graphics g, int x, int y ) {
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2281
        boolean leftToRight = MetalUtils.isLeftToRight(c);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2283
        g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2284
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2285
        // Draw the frame
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2286
        if ( c.hasFocus() ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2287
            g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2289
        else {
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2290
            g.setColor( c.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2291
                                             MetalLookAndFeel.getControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2292
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2293
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2294
        if (leftToRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2295
            g.drawLine(  1,0  ,  8,0  ); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2296
            g.drawLine(  0,1  ,  0,13 ); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2297
            g.drawLine(  1,14 ,  8,14 ); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2298
            g.drawLine(  9,1  , 15,7  ); // top slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2299
            g.drawLine(  9,13 , 15,7  ); // bottom slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2301
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2302
            g.drawLine(  7,0  , 14,0  ); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2303
            g.drawLine( 15,1  , 15,13 ); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2304
            g.drawLine(  7,14 , 14,14 ); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2305
            g.drawLine(  0,7  ,  6,1  ); // top slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2306
            g.drawLine(  0,7  ,  6,13 ); // bottom slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2308
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2309
        // Fill in the background
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2310
        if ( c.hasFocus() ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2311
            g.setColor( c.getForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2312
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2313
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2314
            g.setColor( MetalLookAndFeel.getControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2315
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2316
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2317
        if (leftToRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2318
            g.fillRect(  1,1 ,  8,13 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2319
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2320
            g.drawLine(  9,2 ,  9,12 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2321
            g.drawLine( 10,3 , 10,11 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2322
            g.drawLine( 11,4 , 11,10 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2323
            g.drawLine( 12,5 , 12,9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2324
            g.drawLine( 13,6 , 13,8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2325
            g.drawLine( 14,7 , 14,7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2327
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2328
            g.fillRect(  7,1,   8,13 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2329
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2330
            g.drawLine(  6,3 ,  6,12 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2331
            g.drawLine(  5,4 ,  5,11 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2332
            g.drawLine(  4,5 ,  4,10 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2333
            g.drawLine(  3,6 ,  3,9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2334
            g.drawLine(  2,7 ,  2,8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2335
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2336
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2337
        // Draw the bumps
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2338
        int offset = (leftToRight) ? 2 : 8;
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2339
        if ( c.isEnabled() ) {
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2340
            if ( c.hasFocus() ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2341
                primaryBumps.paintIcon( c, g, offset, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2342
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2343
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2344
                controlBumps.paintIcon( c, g, offset, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2345
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2347
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2348
        // Draw the highlight
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2349
        if ( c.isEnabled() ) {
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2350
            g.setColor( c.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2351
                        : MetalLookAndFeel.getControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2352
            if (leftToRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2353
                g.drawLine( 1, 1, 8, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2354
                g.drawLine( 1, 1, 1, 13 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2355
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2356
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2357
                g.drawLine(  8,1  , 14,1  ); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2358
                g.drawLine(  1,7  ,  7,1  ); // top slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2359
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2360
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2361
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2362
        g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2365
    public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2366
        return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2368
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2369
    public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2370
        return 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2372
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2373
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2374
private static class HorizontalSliderThumbIcon implements Icon, Serializable, UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2375
    protected static MetalBumps controlBumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2376
    protected static MetalBumps primaryBumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2377
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2378
    public HorizontalSliderThumbIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2379
        controlBumps = new MetalBumps( 10, 6,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2380
                                MetalLookAndFeel.getControlHighlight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2381
                                MetalLookAndFeel.getControlInfo(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2382
                                MetalLookAndFeel.getControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2383
        primaryBumps = new MetalBumps( 10, 6,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2384
                                MetalLookAndFeel.getPrimaryControl(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2385
                                MetalLookAndFeel.getPrimaryControlDarkShadow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2386
                                MetalLookAndFeel.getPrimaryControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2388
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2389
    public void paintIcon( Component c, Graphics g, int x, int y ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2390
        g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2391
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2392
        // Draw the frame
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2393
        if ( c.hasFocus() ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2394
            g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2395
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2396
        else {
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2397
            g.setColor( c.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2398
                                             MetalLookAndFeel.getControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2399
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2400
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2401
        g.drawLine(  1,0  , 13,0 );  // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2402
        g.drawLine(  0,1  ,  0,8 );  // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2403
        g.drawLine( 14,1  , 14,8 );  // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2404
        g.drawLine(  1,9  ,  7,15 ); // left slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2405
        g.drawLine(  7,15 , 14,8 );  // right slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2406
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2407
        // Fill in the background
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2408
        if ( c.hasFocus() ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2409
            g.setColor( c.getForeground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2410
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2411
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2412
            g.setColor( MetalLookAndFeel.getControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2413
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2414
        g.fillRect( 1,1, 13, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2415
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2416
        g.drawLine( 2,9  , 12,9 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2417
        g.drawLine( 3,10 , 11,10 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2418
        g.drawLine( 4,11 , 10,11 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2419
        g.drawLine( 5,12 ,  9,12 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2420
        g.drawLine( 6,13 ,  8,13 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2421
        g.drawLine( 7,14 ,  7,14 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2422
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2423
        // Draw the bumps
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2424
        if ( c.isEnabled() ) {
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2425
            if ( c.hasFocus() ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2426
                primaryBumps.paintIcon( c, g, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2427
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2428
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2429
                controlBumps.paintIcon( c, g, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2430
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2431
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2432
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2433
        // Draw the highlight
453
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2434
        if ( c.isEnabled() ) {
145f4ac00bfd 4252173: Inability to reuse the HorizontalSliderThumbIcon
rupashka
parents: 2
diff changeset
  2435
            g.setColor( c.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2436
                        : MetalLookAndFeel.getControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2437
            g.drawLine( 1, 1, 13, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2438
            g.drawLine( 1, 1, 1, 8 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2440
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2441
        g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2443
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2444
    public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2445
        return 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2446
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2447
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2448
    public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2449
        return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2450
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2451
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2452
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2453
    private static class OceanVerticalSliderThumbIcon extends CachedPainter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2454
                              implements Icon, Serializable, UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2455
        // Used for clipping when the orientation is left to right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2456
        private static Polygon LTR_THUMB_SHAPE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2457
        // Used for clipping when the orientation is right to left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2458
        private static Polygon RTL_THUMB_SHAPE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2459
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2460
        static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2461
            LTR_THUMB_SHAPE = new Polygon(new int[] { 0,  8, 15,  8,  0},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2462
                                          new int[] { 0,  0,  7, 14, 14 }, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2463
            RTL_THUMB_SHAPE = new Polygon(new int[] { 15, 15,  7,  0,  7},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2464
                                          new int[] {  0, 14, 14,  7,  0}, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2465
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2466
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2467
        OceanVerticalSliderThumbIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2468
            super(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2469
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2470
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2471
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2472
            if (!(g instanceof Graphics2D)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2473
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2474
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2475
            paint(c, g, x, y, getIconWidth(), getIconHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2476
                  MetalUtils.isLeftToRight(c), c.hasFocus(), c.isEnabled(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2477
                  MetalLookAndFeel.getCurrentTheme());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2478
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2479
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2480
        protected void paintToImage(Component c, Image image, Graphics g2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2481
                                    int w, int h, Object[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2482
            Graphics2D g = (Graphics2D)g2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2483
            boolean leftToRight = ((Boolean)args[0]).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2484
            boolean hasFocus = ((Boolean)args[1]).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2485
            boolean enabled = ((Boolean)args[2]).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2487
            Rectangle clip = g.getClipBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2488
            if (leftToRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2489
                g.clip(LTR_THUMB_SHAPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2490
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2491
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2492
                g.clip(RTL_THUMB_SHAPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2493
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2494
            if (!enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2495
                g.setColor(MetalLookAndFeel.getControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2496
                g.fillRect(1, 1, 14, 14);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2497
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2498
            else if (hasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2499
                MetalUtils.drawGradient(c, g, "Slider.focusGradient",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2500
                                        1, 1, 14, 14, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2501
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2502
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2503
                MetalUtils.drawGradient(c, g, "Slider.gradient",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2504
                                        1, 1, 14, 14, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2505
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2506
            g.setClip(clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2507
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2508
            // Draw the frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2509
            if (hasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2510
                g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2511
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2512
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2513
                g.setColor(enabled ? MetalLookAndFeel.getPrimaryControlInfo() :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2514
                           MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2515
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2516
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2517
            if (leftToRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2518
                g.drawLine(  1,0  ,  8,0  ); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2519
                g.drawLine(  0,1  ,  0,13 ); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2520
                g.drawLine(  1,14 ,  8,14 ); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2521
                g.drawLine(  9,1  , 15,7  ); // top slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2522
                g.drawLine(  9,13 , 15,7  ); // bottom slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2523
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2524
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2525
                g.drawLine(  7,0  , 14,0  ); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2526
                g.drawLine( 15,1  , 15,13 ); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2527
                g.drawLine(  7,14 , 14,14 ); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2528
                g.drawLine(  0,7  ,  6,1  ); // top slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2529
                g.drawLine(  0,7  ,  6,13 ); // bottom slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2530
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2531
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2532
            if (hasFocus && enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2533
                // Inner line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2534
                g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2535
                if (leftToRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2536
                    g.drawLine(  1,1  ,  8,1  ); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2537
                    g.drawLine(  1,1  ,  1,13 ); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2538
                    g.drawLine(  1,13 ,  8,13 ); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2539
                    g.drawLine(  9,2  , 14,7  ); // top slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2540
                    g.drawLine(  9,12 , 14,7  ); // bottom slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2541
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2542
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2543
                    g.drawLine(  7,1  , 14,1  ); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2544
                    g.drawLine( 14,1  , 14,13 ); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2545
                    g.drawLine(  7,13 , 14,13 ); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2546
                    g.drawLine(  1,7  ,  7,1  ); // top slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2547
                    g.drawLine(  1,7  ,  7,13 ); // bottom slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2548
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2549
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2550
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2551
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2552
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2553
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2554
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2555
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2556
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2557
            return 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2558
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2559
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2560
        protected Image createImage(Component c, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2561
                                    GraphicsConfiguration config,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2562
                                    Object[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2563
            if (config == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2564
                return new BufferedImage(w, h,BufferedImage.TYPE_INT_ARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2565
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2566
            return config.createCompatibleImage(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2567
                                w, h, Transparency.BITMASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2568
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2569
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2570
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2571
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2572
    private static class OceanHorizontalSliderThumbIcon extends CachedPainter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2573
                              implements Icon, Serializable, UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2574
        // Used for clipping
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2575
        private static Polygon THUMB_SHAPE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2576
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2577
        static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2578
            THUMB_SHAPE = new Polygon(new int[] { 0, 14, 14,  7,  0 },
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2579
                                      new int[] { 0,  0,  8, 15,  8 }, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2580
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2581
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2582
        OceanHorizontalSliderThumbIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2583
            super(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2584
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2585
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2586
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2587
            if (!(g instanceof Graphics2D)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2588
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2589
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2590
            paint(c, g, x, y, getIconWidth(), getIconHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2591
                  c.hasFocus(), c.isEnabled(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2592
                  MetalLookAndFeel.getCurrentTheme());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2593
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2594
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2595
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2596
        protected Image createImage(Component c, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2597
                                    GraphicsConfiguration config,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2598
                                    Object[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2599
            if (config == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2600
                return new BufferedImage(w, h,BufferedImage.TYPE_INT_ARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2601
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2602
            return config.createCompatibleImage(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2603
                                w, h, Transparency.BITMASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2604
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2605
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2606
        protected void paintToImage(Component c, Image image, Graphics g2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2607
                                    int w, int h, Object[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2608
            Graphics2D g = (Graphics2D)g2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2609
            boolean hasFocus = ((Boolean)args[0]).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2610
            boolean enabled = ((Boolean)args[1]).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2611
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2612
            // Fill in the background
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2613
            Rectangle clip = g.getClipBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2614
            g.clip(THUMB_SHAPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2615
            if (!enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2616
                g.setColor(MetalLookAndFeel.getControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2617
                g.fillRect(1, 1, 13, 14);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2618
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2619
            else if (hasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2620
                MetalUtils.drawGradient(c, g, "Slider.focusGradient",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2621
                                        1, 1, 13, 14, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2622
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2623
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2624
                MetalUtils.drawGradient(c, g, "Slider.gradient",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2625
                                        1, 1, 13, 14, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2626
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2627
            g.setClip(clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2628
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2629
            // Draw the frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2630
            if (hasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2631
                g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2632
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2633
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2634
                g.setColor(enabled ? MetalLookAndFeel.getPrimaryControlInfo() :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2635
                           MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2636
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2637
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2638
            g.drawLine(  1,0  , 13,0 );  // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2639
            g.drawLine(  0,1  ,  0,8 );  // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2640
            g.drawLine( 14,1  , 14,8 );  // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2641
            g.drawLine(  1,9  ,  7,15 ); // left slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2642
            g.drawLine(  7,15 , 14,8 );  // right slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2643
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2644
            if (hasFocus && enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2645
                // Inner line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2646
                g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2647
                g.fillRect(1, 1, 13, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2648
                g.fillRect(1, 2, 1, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2649
                g.fillRect(13, 2, 1, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2650
                g.drawLine(2, 9, 7, 14);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2651
                g.drawLine(8, 13, 12, 9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2652
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2653
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2654
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2655
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2656
            return 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2658
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2659
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2660
            return 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2661
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2662
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2663
}