0N/A/*
2362N/A * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.swing.plaf.metal;
0N/A
0N/Aimport javax.swing.*;
0N/Aimport javax.swing.plaf.UIResource;
0N/Aimport java.awt.*;
0N/Aimport java.awt.image.BufferedImage;
0N/Aimport java.io.Serializable;
0N/Aimport java.util.Enumeration;
0N/Aimport java.util.Vector;
0N/Aimport sun.swing.CachedPainter;
0N/A
0N/A/**
0N/A * Factory object that vends <code>Icon</code>s for
0N/A * the Java<sup><font size="-2">TM</font></sup> look and feel (Metal).
0N/A * These icons are used extensively in Metal via the defaults mechanism.
0N/A * While other look and feels often use GIFs for icons, creating icons
0N/A * in code facilitates switching to other themes.
0N/A *
0N/A * <p>
0N/A * Each method in this class returns
0N/A * either an <code>Icon</code> or <code>null</code>,
0N/A * where <code>null</code> implies that there is no default icon.
0N/A *
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A *
0N/A * @author Michael C. Albers
0N/A */
0N/Apublic class MetalIconFactory implements Serializable {
0N/A
0N/A // List of code-drawn Icons
0N/A private static Icon fileChooserDetailViewIcon;
0N/A private static Icon fileChooserHomeFolderIcon;
0N/A private static Icon fileChooserListViewIcon;
0N/A private static Icon fileChooserNewFolderIcon;
0N/A private static Icon fileChooserUpFolderIcon;
0N/A private static Icon internalFrameAltMaximizeIcon;
0N/A private static Icon internalFrameCloseIcon;
0N/A private static Icon internalFrameDefaultMenuIcon;
0N/A private static Icon internalFrameMaximizeIcon;
0N/A private static Icon internalFrameMinimizeIcon;
0N/A private static Icon radioButtonIcon;
0N/A private static Icon treeComputerIcon;
0N/A private static Icon treeFloppyDriveIcon;
0N/A private static Icon treeHardDriveIcon;
0N/A
0N/A
0N/A private static Icon menuArrowIcon;
0N/A private static Icon menuItemArrowIcon;
0N/A private static Icon checkBoxMenuItemIcon;
0N/A private static Icon radioButtonMenuItemIcon;
0N/A private static Icon checkBoxIcon;
0N/A
0N/A
0N/A // Ocean icons
0N/A private static Icon oceanHorizontalSliderThumb;
0N/A private static Icon oceanVerticalSliderThumb;
0N/A
0N/A // Constants
0N/A public static final boolean DARK = false;
0N/A public static final boolean LIGHT = true;
0N/A
0N/A // Accessor functions for Icons. Does the caching work.
0N/A public static Icon getFileChooserDetailViewIcon() {
0N/A if (fileChooserDetailViewIcon == null) {
0N/A fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
0N/A }
0N/A return fileChooserDetailViewIcon;
0N/A }
0N/A
0N/A public static Icon getFileChooserHomeFolderIcon() {
0N/A if (fileChooserHomeFolderIcon == null) {
0N/A fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
0N/A }
0N/A return fileChooserHomeFolderIcon;
0N/A }
0N/A
0N/A public static Icon getFileChooserListViewIcon() {
0N/A if (fileChooserListViewIcon == null) {
0N/A fileChooserListViewIcon = new FileChooserListViewIcon();
0N/A }
0N/A return fileChooserListViewIcon;
0N/A }
0N/A
0N/A public static Icon getFileChooserNewFolderIcon() {
0N/A if (fileChooserNewFolderIcon == null) {
0N/A fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
0N/A }
0N/A return fileChooserNewFolderIcon;
0N/A }
0N/A
0N/A public static Icon getFileChooserUpFolderIcon() {
0N/A if (fileChooserUpFolderIcon == null) {
0N/A fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
0N/A }
0N/A return fileChooserUpFolderIcon;
0N/A }
0N/A
0N/A public static Icon getInternalFrameAltMaximizeIcon(int size) {
0N/A return new InternalFrameAltMaximizeIcon(size);
0N/A }
0N/A
0N/A public static Icon getInternalFrameCloseIcon(int size) {
0N/A return new InternalFrameCloseIcon(size);
0N/A }
0N/A
0N/A public static Icon getInternalFrameDefaultMenuIcon() {
0N/A if (internalFrameDefaultMenuIcon == null) {
0N/A internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
0N/A }
0N/A return internalFrameDefaultMenuIcon;
0N/A }
0N/A
0N/A public static Icon getInternalFrameMaximizeIcon(int size) {
0N/A return new InternalFrameMaximizeIcon(size);
0N/A }
0N/A
0N/A public static Icon getInternalFrameMinimizeIcon(int size) {
0N/A return new InternalFrameMinimizeIcon(size);
0N/A }
0N/A
0N/A public static Icon getRadioButtonIcon() {
0N/A if (radioButtonIcon == null) {
0N/A radioButtonIcon = new RadioButtonIcon();
0N/A }
0N/A return radioButtonIcon;
0N/A }
0N/A
0N/A /**
0N/A * Returns a checkbox icon.
0N/A * @since 1.3
0N/A */
0N/A public static Icon getCheckBoxIcon() {
0N/A if (checkBoxIcon == null) {
0N/A checkBoxIcon = new CheckBoxIcon();
0N/A }
0N/A return checkBoxIcon;
0N/A }
0N/A
0N/A public static Icon getTreeComputerIcon() {
0N/A if ( treeComputerIcon == null ) {
0N/A treeComputerIcon = new TreeComputerIcon();
0N/A }
0N/A return treeComputerIcon;
0N/A }
0N/A
0N/A public static Icon getTreeFloppyDriveIcon() {
0N/A if ( treeFloppyDriveIcon == null ) {
0N/A treeFloppyDriveIcon = new TreeFloppyDriveIcon();
0N/A }
0N/A return treeFloppyDriveIcon;
0N/A }
0N/A
0N/A public static Icon getTreeFolderIcon() {
0N/A return new TreeFolderIcon();
0N/A }
0N/A
0N/A public static Icon getTreeHardDriveIcon() {
0N/A if ( treeHardDriveIcon == null ) {
0N/A treeHardDriveIcon = new TreeHardDriveIcon();
0N/A }
0N/A return treeHardDriveIcon;
0N/A }
0N/A
0N/A public static Icon getTreeLeafIcon() {
0N/A return new TreeLeafIcon();
0N/A }
0N/A
0N/A public static Icon getTreeControlIcon( boolean isCollapsed ) {
0N/A return new TreeControlIcon( isCollapsed );
0N/A }
0N/A
0N/A public static Icon getMenuArrowIcon() {
0N/A if (menuArrowIcon == null) {
0N/A menuArrowIcon = new MenuArrowIcon();
0N/A }
0N/A return menuArrowIcon;
0N/A }
0N/A
0N/A /**
0N/A * Returns an icon to be used by <code>JCheckBoxMenuItem</code>.
0N/A *
0N/A * @return the default icon for check box menu items,
0N/A * or <code>null</code> if no default exists
0N/A */
0N/A public static Icon getMenuItemCheckIcon() {
0N/A return null;
0N/A }
0N/A
0N/A public static Icon getMenuItemArrowIcon() {
0N/A if (menuItemArrowIcon == null) {
0N/A menuItemArrowIcon = new MenuItemArrowIcon();
0N/A }
0N/A return menuItemArrowIcon;
0N/A }
0N/A
0N/A public static Icon getCheckBoxMenuItemIcon() {
0N/A if (checkBoxMenuItemIcon == null) {
0N/A checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
0N/A }
0N/A return checkBoxMenuItemIcon;
0N/A }
0N/A
0N/A public static Icon getRadioButtonMenuItemIcon() {
0N/A if (radioButtonMenuItemIcon == null) {
0N/A radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
0N/A }
0N/A return radioButtonMenuItemIcon;
0N/A }
0N/A
0N/A public static Icon getHorizontalSliderThumbIcon() {
0N/A if (MetalLookAndFeel.usingOcean()) {
0N/A if (oceanHorizontalSliderThumb == null) {
0N/A oceanHorizontalSliderThumb =
0N/A new OceanHorizontalSliderThumbIcon();
0N/A }
0N/A return oceanHorizontalSliderThumb;
0N/A }
0N/A // don't cache these, bumps don't get updated otherwise
0N/A return new HorizontalSliderThumbIcon();
0N/A }
0N/A
0N/A public static Icon getVerticalSliderThumbIcon() {
0N/A if (MetalLookAndFeel.usingOcean()) {
0N/A if (oceanVerticalSliderThumb == null) {
0N/A oceanVerticalSliderThumb = new OceanVerticalSliderThumbIcon();
0N/A }
0N/A return oceanVerticalSliderThumb;
0N/A }
0N/A // don't cache these, bumps don't get updated otherwise
0N/A return new VerticalSliderThumbIcon();
0N/A }
0N/A
0N/A // File Chooser Detail View code
0N/A private static class FileChooserDetailViewIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A g.translate(x, y);
0N/A
0N/A // Draw outside edge of each of the documents
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
0N/A // top
0N/A g.drawLine(2,2, 5,2); // top
0N/A g.drawLine(2,3, 2,7); // left
0N/A g.drawLine(3,7, 6,7); // bottom
0N/A g.drawLine(6,6, 6,3); // right
0N/A // bottom
0N/A g.drawLine(2,10, 5,10); // top
0N/A g.drawLine(2,11, 2,15); // left
0N/A g.drawLine(3,15, 6,15); // bottom
0N/A g.drawLine(6,14, 6,11); // right
0N/A
0N/A // Draw little dots next to documents
0N/A // Same color as outside edge
0N/A g.drawLine(8,5, 15,5); // top
0N/A g.drawLine(8,13, 15,13); // bottom
0N/A
0N/A // Draw inner highlight on documents
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.drawRect(3,3, 2,3); // top
0N/A g.drawRect(3,11, 2,3); // bottom
0N/A
0N/A // Draw inner inner highlight on documents
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
0N/A g.drawLine(4,4, 4,5); // top
0N/A g.drawLine(4,12, 4,13); // bottom
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 18;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 18;
0N/A }
0N/A } // End class FileChooserDetailViewIcon
0N/A
0N/A // File Chooser Home Folder code
0N/A private static class FileChooserHomeFolderIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A g.translate(x, y);
0N/A
0N/A // Draw outside edge of house
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
0N/A g.drawLine(8,1, 1,8); // left edge of roof
0N/A g.drawLine(8,1, 15,8); // right edge of roof
0N/A g.drawLine(11,2, 11,3); // left edge of chimney
0N/A g.drawLine(12,2, 12,4); // right edge of chimney
0N/A g.drawLine(3,7, 3,15); // left edge of house
0N/A g.drawLine(13,7, 13,15); // right edge of house
0N/A g.drawLine(4,15, 12,15); // bottom edge of house
0N/A // Draw door frame
0N/A // same color as edge of house
0N/A g.drawLine( 6,9, 6,14); // left
0N/A g.drawLine(10,9, 10,14); // right
0N/A g.drawLine( 7,9, 9, 9); // top
0N/A
0N/A // Draw roof body
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A g.fillRect(8,2, 1,1); //top toward bottom
0N/A g.fillRect(7,3, 3,1);
0N/A g.fillRect(6,4, 5,1);
0N/A g.fillRect(5,5, 7,1);
0N/A g.fillRect(4,6, 9,2);
0N/A // Draw doornob
0N/A // same color as roof body
0N/A g.drawLine(9,12, 9,12);
0N/A
0N/A // Paint the house
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.drawLine(4,8, 12,8); // above door
0N/A g.fillRect(4,9, 2,6); // left of door
0N/A g.fillRect(11,9, 2,6); // right of door
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 18;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 18;
0N/A }
0N/A } // End class FileChooserHomeFolderIcon
0N/A
0N/A // File Chooser List View code
0N/A private static class FileChooserListViewIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A g.translate(x, y);
0N/A
0N/A // Draw outside edge of each of the documents
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
0N/A // top left
0N/A g.drawLine(2,2, 5,2); // top
0N/A g.drawLine(2,3, 2,7); // left
0N/A g.drawLine(3,7, 6,7); // bottom
0N/A g.drawLine(6,6, 6,3); // right
0N/A // top right
0N/A g.drawLine(10,2, 13,2); // top
0N/A g.drawLine(10,3, 10,7); // left
0N/A g.drawLine(11,7, 14,7); // bottom
0N/A g.drawLine(14,6, 14,3); // right
0N/A // bottom left
0N/A g.drawLine(2,10, 5,10); // top
0N/A g.drawLine(2,11, 2,15); // left
0N/A g.drawLine(3,15, 6,15); // bottom
0N/A g.drawLine(6,14, 6,11); // right
0N/A // bottom right
0N/A g.drawLine(10,10, 13,10); // top
0N/A g.drawLine(10,11, 10,15); // left
0N/A g.drawLine(11,15, 14,15); // bottom
0N/A g.drawLine(14,14, 14,11); // right
0N/A
0N/A // Draw little dots next to documents
0N/A // Same color as outside edge
0N/A g.drawLine(8,5, 8,5); // top left
0N/A g.drawLine(16,5, 16,5); // top right
0N/A g.drawLine(8,13, 8,13); // bottom left
0N/A g.drawLine(16,13, 16,13); // bottom right
0N/A
0N/A // Draw inner highlight on documents
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.drawRect(3,3, 2,3); // top left
0N/A g.drawRect(11,3, 2,3); // top right
0N/A g.drawRect(3,11, 2,3); // bottom left
0N/A g.drawRect(11,11, 2,3); // bottom right
0N/A
0N/A // Draw inner inner highlight on documents
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
0N/A g.drawLine(4,4, 4,5); // top left
0N/A g.drawLine(12,4, 12,5); // top right
0N/A g.drawLine(4,12, 4,13); // bottom left
0N/A g.drawLine(12,12, 12,13); // bottom right
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 18;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 18;
0N/A }
0N/A } // End class FileChooserListViewIcon
0N/A
0N/A // File Chooser New Folder code
0N/A private static class FileChooserNewFolderIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A g.translate(x, y);
0N/A
0N/A // Fill background
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.fillRect(3,5, 12,9);
0N/A
0N/A // Draw outside edge of folder
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
0N/A g.drawLine(1,6, 1,14); // left
0N/A g.drawLine(2,14, 15,14); // bottom
0N/A g.drawLine(15,13, 15,5); // right
0N/A g.drawLine(2,5, 9,5); // top left
0N/A g.drawLine(10,6, 14,6); // top right
0N/A
0N/A // Draw inner folder highlight
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
0N/A g.drawLine( 2,6, 2,13); // left
0N/A g.drawLine( 3,6, 9,6); // top left
0N/A g.drawLine(10,7, 14,7); // top right
0N/A
0N/A // Draw tab on folder
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
0N/A g.drawLine(11,3, 15,3); // top
0N/A g.drawLine(10,4, 15,4); // bottom
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 18;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 18;
0N/A }
0N/A } // End class FileChooserNewFolderIcon
0N/A
0N/A // File Chooser Up Folder code
0N/A private static class FileChooserUpFolderIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A g.translate(x, y);
0N/A
0N/A // Fill background
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.fillRect(3,5, 12,9);
0N/A
0N/A // Draw outside edge of folder
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
0N/A g.drawLine(1,6, 1,14); // left
0N/A g.drawLine(2,14, 15,14); // bottom
0N/A g.drawLine(15,13, 15,5); // right
0N/A g.drawLine(2,5, 9,5); // top left
0N/A g.drawLine(10,6, 14,6); // top right
0N/A // Draw the UP arrow
0N/A // same color as edge
0N/A g.drawLine(8,13, 8,16); // arrow shaft
0N/A g.drawLine(8, 9, 8, 9); // arrowhead top
0N/A g.drawLine(7,10, 9,10);
0N/A g.drawLine(6,11, 10,11);
0N/A g.drawLine(5,12, 11,12);
0N/A
0N/A // Draw inner folder highlight
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
0N/A g.drawLine( 2,6, 2,13); // left
0N/A g.drawLine( 3,6, 9,6); // top left
0N/A g.drawLine(10,7, 14,7); // top right
0N/A
0N/A // Draw tab on folder
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
0N/A g.drawLine(11,3, 15,3); // top
0N/A g.drawLine(10,4, 15,4); // bottom
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 18;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 18;
0N/A }
0N/A } // End class FileChooserUpFolderIcon
0N/A
0N/A
0N/A /**
0N/A * Defines an icon for Palette close
0N/A * @since 1.3
0N/A */
0N/A public static class PaletteCloseIcon implements Icon, UIResource, Serializable{
0N/A int iconSize = 7;
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A JButton parentButton = (JButton)c;
0N/A ButtonModel buttonModel = parentButton.getModel();
0N/A
0N/A Color back;
0N/A Color highlight = MetalLookAndFeel.getPrimaryControlHighlight();
0N/A Color shadow = MetalLookAndFeel.getPrimaryControlInfo();
0N/A if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A back = shadow;
0N/A } else {
0N/A back = MetalLookAndFeel.getPrimaryControlDarkShadow();
0N/A }
0N/A
0N/A g.translate(x, y);
0N/A g.setColor(back);
0N/A g.drawLine( 0, 1, 5, 6);
0N/A g.drawLine( 1, 0, 6, 5);
0N/A g.drawLine( 1, 1, 6, 6);
0N/A g.drawLine( 6, 1, 1, 6);
0N/A g.drawLine( 5,0, 0,5);
0N/A g.drawLine(5,1, 1,5);
0N/A
0N/A g.setColor(highlight);
0N/A g.drawLine(6,2, 5,3);
0N/A g.drawLine(2,6, 3, 5);
0N/A g.drawLine(6,6,6,6);
0N/A
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return iconSize;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return iconSize;
0N/A }
0N/A }
0N/A
0N/A // Internal Frame Close code
0N/A private static class InternalFrameCloseIcon implements Icon, UIResource, Serializable {
0N/A int iconSize = 16;
0N/A
0N/A public InternalFrameCloseIcon(int size) {
0N/A iconSize = size;
0N/A }
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A JButton parentButton = (JButton)c;
0N/A ButtonModel buttonModel = parentButton.getModel();
0N/A
0N/A Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
0N/A Color internalBackgroundColor =
0N/A MetalLookAndFeel.getPrimaryControl();
0N/A Color mainItemColor =
0N/A MetalLookAndFeel.getPrimaryControlDarkShadow();
0N/A Color darkHighlightColor = MetalLookAndFeel.getBlack();
0N/A Color xLightHighlightColor = MetalLookAndFeel.getWhite();
0N/A Color boxLightHighlightColor = MetalLookAndFeel.getWhite();
0N/A
0N/A // if the inactive window
0N/A if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
0N/A {
0N/A backgroundColor = MetalLookAndFeel.getControl();
0N/A internalBackgroundColor = backgroundColor;
0N/A mainItemColor = MetalLookAndFeel.getControlDarkShadow();
0N/A // if inactive and pressed
0N/A if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A internalBackgroundColor =
0N/A MetalLookAndFeel.getControlShadow();
0N/A xLightHighlightColor = internalBackgroundColor;
0N/A mainItemColor = darkHighlightColor;
0N/A }
0N/A }
0N/A // if pressed
0N/A else if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A internalBackgroundColor =
0N/A MetalLookAndFeel.getPrimaryControlShadow();
0N/A xLightHighlightColor = internalBackgroundColor;
0N/A mainItemColor = darkHighlightColor;
0N/A // darkHighlightColor is still "getBlack()"
0N/A }
0N/A
0N/A // Some calculations that are needed more than once later on.
614N/A int oneHalf = iconSize / 2; // 16 -> 8
0N/A
0N/A g.translate(x, y);
0N/A
0N/A // fill background
0N/A g.setColor(backgroundColor);
0N/A g.fillRect(0,0, iconSize,iconSize);
0N/A
0N/A // fill inside of box area
0N/A g.setColor(internalBackgroundColor);
0N/A g.fillRect(3,3, iconSize-6,iconSize-6);
0N/A
0N/A // THE BOX
0N/A // the top/left dark higlight - some of this will get overwritten
0N/A g.setColor(darkHighlightColor);
0N/A g.drawRect(1,1, iconSize-3,iconSize-3);
0N/A // draw the inside bottom/right highlight
0N/A g.drawRect(2,2, iconSize-5,iconSize-5);
0N/A // draw the light/outside, bottom/right highlight
0N/A g.setColor(boxLightHighlightColor);
0N/A g.drawRect(2,2, iconSize-3,iconSize-3);
0N/A // draw the "normal" box
0N/A g.setColor(mainItemColor);
0N/A g.drawRect(2,2, iconSize-4,iconSize-4);
0N/A g.drawLine(3,iconSize-3, 3,iconSize-3); // lower left
0N/A g.drawLine(iconSize-3,3, iconSize-3,3); // up right
0N/A
0N/A // THE "X"
0N/A // Dark highlight
0N/A g.setColor(darkHighlightColor);
0N/A g.drawLine(4,5, 5,4); // far up left
0N/A g.drawLine(4,iconSize-6, iconSize-6,4); // against body of "X"
0N/A // Light highlight
0N/A g.setColor(xLightHighlightColor);
0N/A g.drawLine(6,iconSize-5, iconSize-5,6); // against body of "X"
0N/A // one pixel over from the body
0N/A g.drawLine(oneHalf,oneHalf+2, oneHalf+2,oneHalf);
0N/A // bottom right
0N/A g.drawLine(iconSize-5,iconSize-5, iconSize-4,iconSize-5);
0N/A g.drawLine(iconSize-5,iconSize-4, iconSize-5,iconSize-4);
0N/A // Main color
0N/A g.setColor(mainItemColor);
0N/A // Upper left to lower right
0N/A g.drawLine(5,5, iconSize-6,iconSize-6); // g.drawLine(5,5, 10,10);
0N/A g.drawLine(6,5, iconSize-5,iconSize-6); // g.drawLine(6,5, 11,10);
0N/A g.drawLine(5,6, iconSize-6,iconSize-5); // g.drawLine(5,6, 10,11);
0N/A // Lower left to upper right
0N/A g.drawLine(5,iconSize-5, iconSize-5,5); // g.drawLine(5,11, 11,5);
0N/A g.drawLine(5,iconSize-6, iconSize-6,5); // g.drawLine(5,10, 10,5);
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return iconSize;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return iconSize;
0N/A }
0N/A } // End class InternalFrameCloseIcon
0N/A
0N/A // Internal Frame Alternate Maximize code (actually, the un-maximize icon)
0N/A private static class InternalFrameAltMaximizeIcon implements Icon, UIResource, Serializable {
0N/A int iconSize = 16;
0N/A
0N/A public InternalFrameAltMaximizeIcon(int size) {
0N/A iconSize = size;
0N/A }
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A JButton parentButton = (JButton)c;
0N/A ButtonModel buttonModel = parentButton.getModel();
0N/A
0N/A Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
0N/A Color internalBackgroundColor =
0N/A MetalLookAndFeel.getPrimaryControl();
0N/A Color mainItemColor =
0N/A MetalLookAndFeel.getPrimaryControlDarkShadow();
0N/A Color darkHighlightColor = MetalLookAndFeel.getBlack();
0N/A // ul = Upper Left and lr = Lower Right
0N/A Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
0N/A Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
0N/A
0N/A // if the internal frame is inactive
0N/A if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
0N/A {
0N/A backgroundColor = MetalLookAndFeel.getControl();
0N/A internalBackgroundColor = backgroundColor;
0N/A mainItemColor = MetalLookAndFeel.getControlDarkShadow();
0N/A // if inactive and pressed
0N/A if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A internalBackgroundColor =
0N/A MetalLookAndFeel.getControlShadow();
0N/A ulLightHighlightColor = internalBackgroundColor;
0N/A mainItemColor = darkHighlightColor;
0N/A }
0N/A }
0N/A // if the button is pressed and the mouse is over it
0N/A else if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A internalBackgroundColor =
0N/A MetalLookAndFeel.getPrimaryControlShadow();
0N/A ulLightHighlightColor = internalBackgroundColor;
0N/A mainItemColor = darkHighlightColor;
0N/A // darkHighlightColor is still "getBlack()"
0N/A }
0N/A
0N/A g.translate(x, y);
0N/A
0N/A // fill background
0N/A g.setColor(backgroundColor);
0N/A g.fillRect(0,0, iconSize,iconSize);
0N/A
0N/A // BOX
0N/A // fill inside the box
0N/A g.setColor(internalBackgroundColor);
0N/A g.fillRect(3,6, iconSize-9,iconSize-9);
0N/A
0N/A // draw dark highlight color
0N/A g.setColor(darkHighlightColor);
0N/A g.drawRect(1,5, iconSize-8,iconSize-8);
0N/A g.drawLine(1,iconSize-2, 1,iconSize-2); // extra pixel on bottom
0N/A
0N/A // draw lower right light highlight
0N/A g.setColor(lrLightHighlightColor);
0N/A g.drawRect(2,6, iconSize-7,iconSize-7);
0N/A // draw upper left light highlight
0N/A g.setColor(ulLightHighlightColor);
0N/A g.drawRect(3,7, iconSize-9,iconSize-9);
0N/A
0N/A // draw the main box
0N/A g.setColor(mainItemColor);
0N/A g.drawRect(2,6, iconSize-8,iconSize-8);
0N/A
0N/A // Six extraneous pixels to deal with
0N/A g.setColor(ulLightHighlightColor);
0N/A g.drawLine(iconSize-6,8,iconSize-6,8);
0N/A g.drawLine(iconSize-9,6, iconSize-7,8);
0N/A g.setColor(mainItemColor);
0N/A g.drawLine(3,iconSize-3,3,iconSize-3);
0N/A g.setColor(darkHighlightColor);
0N/A g.drawLine(iconSize-6,9,iconSize-6,9);
0N/A g.setColor(backgroundColor);
0N/A g.drawLine(iconSize-9,5,iconSize-9,5);
0N/A
0N/A // ARROW
0N/A // do the shaft first
0N/A g.setColor(mainItemColor);
0N/A g.fillRect(iconSize-7,3, 3,5); // do a big block
0N/A g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
0N/A g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
0N/A g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
0N/A
0N/A // draw the dark highlight
0N/A g.setColor(darkHighlightColor);
0N/A g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
0N/A g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
0N/A g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
0N/A g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
0N/A
0N/A // draw the light highlight
0N/A g.setColor(lrLightHighlightColor);
0N/A g.drawLine(iconSize-6,3, iconSize-6,3); // top
0N/A g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
0N/A g.drawLine(iconSize-4,8, iconSize-3,8); // under arrowhead
0N/A g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return iconSize;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return iconSize;
0N/A }
0N/A } // End class InternalFrameAltMaximizeIcon
0N/A
0N/A // Code for the default icons that goes in the upper left corner
0N/A private static class InternalFrameDefaultMenuIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A
0N/A Color windowBodyColor = MetalLookAndFeel.getWindowBackground();
0N/A Color titleColor = MetalLookAndFeel.getPrimaryControl();
0N/A Color edgeColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
0N/A
0N/A g.translate(x, y);
0N/A
0N/A // draw background color for title area
0N/A // catch four corners and title area
0N/A g.setColor(titleColor);
0N/A g.fillRect(0,0, 16,16);
0N/A
0N/A // fill body of window
0N/A g.setColor(windowBodyColor);
0N/A g.fillRect(2,6, 13,9);
0N/A // draw light parts of two "bumps"
0N/A g.drawLine(2,2, 2,2);
0N/A g.drawLine(5,2, 5,2);
0N/A g.drawLine(8,2, 8,2);
0N/A g.drawLine(11,2, 11,2);
0N/A
0N/A // draw line around edge of title and icon
0N/A g.setColor(edgeColor);
0N/A g.drawRect(1,1, 13,13); // entire inner edge
0N/A g.drawLine(1,0, 14,0); // top outter edge
0N/A g.drawLine(15,1, 15,14); // right outter edge
0N/A g.drawLine(1,15, 14,15); // bottom outter edge
0N/A g.drawLine(0,1, 0,14); // left outter edge
0N/A g.drawLine(2,5, 13,5); // bottom of title bar area
0N/A // draw dark part of four "bumps" (same color)
0N/A g.drawLine(3,3, 3,3);
0N/A g.drawLine(6,3, 6,3);
0N/A g.drawLine(9,3, 9,3);
0N/A g.drawLine(12,3, 12,3);
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 16;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 16;
0N/A }
0N/A } // End class InternalFrameDefaultMenuIcon
0N/A
0N/A // Internal Frame Maximize code
0N/A private static class InternalFrameMaximizeIcon implements Icon, UIResource, Serializable {
0N/A protected int iconSize = 16;
0N/A
0N/A public InternalFrameMaximizeIcon(int size) {
0N/A iconSize = size;
0N/A }
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A JButton parentButton = (JButton)c;
0N/A ButtonModel buttonModel = parentButton.getModel();
0N/A
0N/A Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
0N/A Color internalBackgroundColor =
0N/A MetalLookAndFeel.getPrimaryControl();
0N/A Color mainItemColor =
0N/A MetalLookAndFeel.getPrimaryControlDarkShadow();
0N/A Color darkHighlightColor = MetalLookAndFeel.getBlack();
0N/A // ul = Upper Left and lr = Lower Right
0N/A Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
0N/A Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
0N/A
0N/A // if the internal frame is inactive
0N/A if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
0N/A {
0N/A backgroundColor = MetalLookAndFeel.getControl();
0N/A internalBackgroundColor = backgroundColor;
0N/A mainItemColor = MetalLookAndFeel.getControlDarkShadow();
0N/A // if inactive and pressed
0N/A if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A internalBackgroundColor =
0N/A MetalLookAndFeel.getControlShadow();
0N/A ulLightHighlightColor = internalBackgroundColor;
0N/A mainItemColor = darkHighlightColor;
0N/A }
0N/A }
0N/A // if the button is pressed and the mouse is over it
0N/A else if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A internalBackgroundColor =
0N/A MetalLookAndFeel.getPrimaryControlShadow();
0N/A ulLightHighlightColor = internalBackgroundColor;
0N/A mainItemColor = darkHighlightColor;
0N/A // darkHighlightColor is still "getBlack()"
0N/A }
0N/A
0N/A g.translate(x, y);
0N/A
0N/A // fill background
0N/A g.setColor(backgroundColor);
0N/A g.fillRect(0,0, iconSize,iconSize);
0N/A
0N/A // BOX drawing
0N/A // fill inside the box
0N/A g.setColor(internalBackgroundColor);
0N/A g.fillRect(3,7, iconSize-10,iconSize-10);
0N/A
0N/A // light highlight
0N/A g.setColor(ulLightHighlightColor);
0N/A g.drawRect(3,7, iconSize-10,iconSize-10); // up,left
0N/A g.setColor(lrLightHighlightColor);
0N/A g.drawRect(2,6, iconSize-7,iconSize-7); // low,right
0N/A // dark highlight
0N/A g.setColor(darkHighlightColor);
0N/A g.drawRect(1,5, iconSize-7,iconSize-7); // outer
0N/A g.drawRect(2,6, iconSize-9,iconSize-9); // inner
0N/A // main box
0N/A g.setColor(mainItemColor);
0N/A g.drawRect(2,6, iconSize-8,iconSize-8); // g.drawRect(2,6, 8,8);
0N/A
0N/A // ARROW drawing
0N/A // dark highlight
0N/A g.setColor(darkHighlightColor);
0N/A // down,left to up,right - inside box
0N/A g.drawLine(3,iconSize-5, iconSize-9,7);
0N/A // down,left to up,right - outside box
0N/A g.drawLine(iconSize-6,4, iconSize-5,3);
0N/A // outside edge of arrow head
0N/A g.drawLine(iconSize-7,1, iconSize-7,2);
0N/A // outside edge of arrow head
0N/A g.drawLine(iconSize-6,1, iconSize-2,1);
0N/A // light highlight
0N/A g.setColor(ulLightHighlightColor);
0N/A // down,left to up,right - inside box
0N/A g.drawLine(5,iconSize-4, iconSize-8,9);
0N/A g.setColor(lrLightHighlightColor);
0N/A g.drawLine(iconSize-6,3, iconSize-4,5); // outside box
0N/A g.drawLine(iconSize-4,5, iconSize-4,6); // one down from this
0N/A g.drawLine(iconSize-2,7, iconSize-1,7); // outside edge arrow head
0N/A g.drawLine(iconSize-1,2, iconSize-1,6); // outside edge arrow head
0N/A // main part of arrow
0N/A g.setColor(mainItemColor);
0N/A g.drawLine(3,iconSize-4, iconSize-3,2); // top edge of staff
0N/A g.drawLine(3,iconSize-3, iconSize-2,2); // bottom edge of staff
0N/A g.drawLine(4,iconSize-3, 5,iconSize-3); // highlights inside of box
0N/A g.drawLine(iconSize-7,8, iconSize-7,9); // highlights inside of box
0N/A g.drawLine(iconSize-6,2, iconSize-4,2); // top of arrow head
0N/A g.drawRect(iconSize-3,3, 1,3); // right of arrow head
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return iconSize;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return iconSize;
0N/A }
0N/A } // End class InternalFrameMaximizeIcon
0N/A
0N/A // Internal Frame Minimize code
0N/A private static class InternalFrameMinimizeIcon implements Icon, UIResource, Serializable {
0N/A int iconSize = 16;
0N/A
0N/A public InternalFrameMinimizeIcon(int size) {
0N/A iconSize = size;
0N/A }
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A JButton parentButton = (JButton)c;
0N/A ButtonModel buttonModel = parentButton.getModel();
0N/A
0N/A
0N/A Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
0N/A Color internalBackgroundColor =
0N/A MetalLookAndFeel.getPrimaryControl();
0N/A Color mainItemColor =
0N/A MetalLookAndFeel.getPrimaryControlDarkShadow();
0N/A Color darkHighlightColor = MetalLookAndFeel.getBlack();
0N/A // ul = Upper Left and lr = Lower Right
0N/A Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
0N/A Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
0N/A
0N/A // if the internal frame is inactive
0N/A if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
0N/A {
0N/A backgroundColor = MetalLookAndFeel.getControl();
0N/A internalBackgroundColor = backgroundColor;
0N/A mainItemColor = MetalLookAndFeel.getControlDarkShadow();
0N/A // if inactive and pressed
0N/A if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A internalBackgroundColor =
0N/A MetalLookAndFeel.getControlShadow();
0N/A ulLightHighlightColor = internalBackgroundColor;
0N/A mainItemColor = darkHighlightColor;
0N/A }
0N/A }
0N/A // if the button is pressed and the mouse is over it
0N/A else if (buttonModel.isPressed() && buttonModel.isArmed()) {
0N/A internalBackgroundColor =
0N/A MetalLookAndFeel.getPrimaryControlShadow();
0N/A ulLightHighlightColor = internalBackgroundColor;
0N/A mainItemColor = darkHighlightColor;
0N/A // darkHighlightColor is still "getBlack()"
0N/A }
0N/A
0N/A g.translate(x, y);
0N/A
0N/A // fill background
0N/A g.setColor(backgroundColor);
0N/A g.fillRect(0,0, iconSize,iconSize);
0N/A
0N/A // BOX drawing
0N/A // fill inside the box
0N/A g.setColor(internalBackgroundColor);
0N/A g.fillRect(4,11, iconSize-13,iconSize-13);
0N/A // light highlight
0N/A g.setColor(lrLightHighlightColor);
0N/A g.drawRect(2,10, iconSize-10,iconSize-11); // low,right
0N/A g.setColor(ulLightHighlightColor);
0N/A g.drawRect(3,10, iconSize-12,iconSize-12); // up,left
0N/A // dark highlight
0N/A g.setColor(darkHighlightColor);
0N/A g.drawRect(1,8, iconSize-10,iconSize-10); // outer
0N/A g.drawRect(2,9, iconSize-12,iconSize-12); // inner
0N/A // main box
0N/A g.setColor(mainItemColor);
0N/A g.drawRect(2,9, iconSize-11,iconSize-11);
0N/A g.drawLine(iconSize-10,10, iconSize-10,10); // up right highlight
0N/A g.drawLine(3,iconSize-3, 3,iconSize-3); // low left highlight
0N/A
0N/A // ARROW
0N/A // do the shaft first
0N/A g.setColor(mainItemColor);
0N/A g.fillRect(iconSize-7,3, 3,5); // do a big block
0N/A g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
0N/A g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
0N/A g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
0N/A
0N/A // draw the dark highlight
0N/A g.setColor(darkHighlightColor);
0N/A g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
0N/A g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
0N/A g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
0N/A g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
0N/A
0N/A // draw the light highlight
0N/A g.setColor(lrLightHighlightColor);
0N/A g.drawLine(iconSize-6,3, iconSize-6,3); // top
0N/A g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
0N/A g.drawLine(iconSize-7,8, iconSize-3,8); // under arrowhead
0N/A g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return iconSize;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return iconSize;
0N/A }
0N/A } // End class InternalFrameMinimizeIcon
0N/A
0N/A private static class CheckBoxIcon implements Icon, UIResource, Serializable {
0N/A
0N/A protected int getControlSize() { return 13; }
0N/A
0N/A private void paintOceanIcon(Component c, Graphics g, int x, int y) {
0N/A ButtonModel model = ((JCheckBox)c).getModel();
0N/A
0N/A g.translate(x, y);
0N/A int w = getIconWidth();
0N/A int h = getIconHeight();
0N/A if ( model.isEnabled() ) {
0N/A if (model.isPressed() && model.isArmed()) {
0N/A g.setColor(MetalLookAndFeel.getControlShadow());
0N/A g.fillRect(0, 0, w, h);
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A g.fillRect(0, 0, w, 2);
0N/A g.fillRect(0, 2, 2, h - 2);
0N/A g.fillRect(w - 1, 1, 1, h - 1);
0N/A g.fillRect(1, h - 1, w - 2, 1);
0N/A } else if (model.isRollover()) {
0N/A MetalUtils.drawGradient(c, g, "CheckBox.gradient", 0, 0,
0N/A w, h, true);
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A g.drawRect(0, 0, w - 1, h - 1);
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.drawRect(1, 1, w - 3, h - 3);
0N/A g.drawRect(2, 2, w - 5, h - 5);
0N/A }
0N/A else {
0N/A MetalUtils.drawGradient(c, g, "CheckBox.gradient", 0, 0,
0N/A w, h, true);
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A g.drawRect(0, 0, w - 1, h - 1);
0N/A }
0N/A g.setColor( MetalLookAndFeel.getControlInfo() );
0N/A } else {
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A g.drawRect(0, 0, w - 1, h - 1);
0N/A }
0N/A g.translate(-x, -y);
0N/A if (model.isSelected()) {
0N/A drawCheck(c,g,x,y);
0N/A }
0N/A }
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A if (MetalLookAndFeel.usingOcean()) {
0N/A paintOceanIcon(c, g, x, y);
0N/A return;
0N/A }
0N/A ButtonModel model = ((JCheckBox)c).getModel();
0N/A int controlSize = getControlSize();
0N/A
0N/A if ( model.isEnabled() ) {
0N/A if (model.isPressed() && model.isArmed()) {
0N/A g.setColor( MetalLookAndFeel.getControlShadow() );
0N/A g.fillRect( x, y, controlSize-1, controlSize-1);
0N/A MetalUtils.drawPressed3DBorder(g, x, y, controlSize, controlSize);
0N/A } else {
0N/A MetalUtils.drawFlush3DBorder(g, x, y, controlSize, controlSize);
0N/A }
0N/A g.setColor(c.getForeground());
0N/A } else {
0N/A g.setColor( MetalLookAndFeel.getControlShadow() );
0N/A g.drawRect( x, y, controlSize-2, controlSize-2);
0N/A }
0N/A
0N/A if (model.isSelected()) {
0N/A drawCheck(c,g,x,y);
0N/A }
0N/A
0N/A }
0N/A
0N/A protected void drawCheck(Component c, Graphics g, int x, int y) {
0N/A int controlSize = getControlSize();
0N/A g.fillRect( x+3, y+5, 2, controlSize-8 );
0N/A g.drawLine( x+(controlSize-4), y+3, x+5, y+(controlSize-6) );
0N/A g.drawLine( x+(controlSize-4), y+4, x+5, y+(controlSize-5) );
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return getControlSize();
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return getControlSize();
0N/A }
0N/A } // End class CheckBoxIcon
0N/A
0N/A // Radio button code
0N/A private static class RadioButtonIcon implements Icon, UIResource, Serializable {
0N/A public void paintOceanIcon(Component c, Graphics g, int x, int y) {
0N/A ButtonModel model = ((JRadioButton)c).getModel();
0N/A boolean enabled = model.isEnabled();
0N/A boolean pressed = (enabled && model.isPressed() &&
0N/A model.isArmed());
0N/A boolean rollover = (enabled && model.isRollover());
0N/A
0N/A g.translate(x, y);
0N/A if (enabled && !pressed) {
0N/A // PENDING: this isn't quite right, when we're sure it won't
0N/A // change it needs to be cleaned.
0N/A MetalUtils.drawGradient(c, g, "RadioButton.gradient",
0N/A 1, 1, 10, 10, true);
0N/A g.setColor(c.getBackground());
0N/A g.fillRect(1, 1, 1, 1);
0N/A g.fillRect(10, 1, 1, 1);
0N/A g.fillRect(1, 10, 1, 1);
0N/A g.fillRect(10, 10, 1, 1);
0N/A }
0N/A else if (pressed || !enabled) {
0N/A if (pressed) {
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getControl());
0N/A }
0N/A g.fillRect(2, 2, 8, 8);
0N/A g.fillRect(4, 1, 4, 1);
0N/A g.fillRect(4, 10, 4, 1);
0N/A g.fillRect(1, 4, 1, 4);
0N/A g.fillRect(10, 4, 1, 4);
0N/A }
0N/A
0N/A // draw Dark Circle (start at top, go clockwise)
0N/A if (!enabled) {
0N/A g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A }
0N/A g.drawLine( 4, 0, 7, 0);
0N/A g.drawLine( 8, 1, 9, 1);
0N/A g.drawLine(10, 2, 10, 3);
0N/A g.drawLine(11, 4, 11, 7);
0N/A g.drawLine(10, 8, 10, 9);
0N/A g.drawLine( 9,10, 8,10);
0N/A g.drawLine( 7,11, 4,11);
0N/A g.drawLine( 3,10, 2,10);
0N/A g.drawLine( 1, 9, 1, 8);
0N/A g.drawLine( 0, 7, 0, 4);
0N/A g.drawLine( 1, 3, 1, 2);
0N/A g.drawLine( 2, 1, 3, 1);
0N/A
0N/A if (pressed) {
0N/A g.fillRect(1, 4, 1, 4);
0N/A g.fillRect(2, 2, 1, 2);
0N/A g.fillRect(3, 2, 1, 1);
0N/A g.fillRect(4, 1, 4, 1);
0N/A }
0N/A else if (rollover) {
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.fillRect(4, 1, 4, 2);
0N/A g.fillRect(8, 2, 2, 2);
0N/A g.fillRect(9, 4, 2, 4);
0N/A g.fillRect(8, 8, 2, 2);
0N/A g.fillRect(4, 9, 4, 2);
0N/A g.fillRect(2, 8, 2, 2);
0N/A g.fillRect(1, 4, 2, 4);
0N/A g.fillRect(2, 2, 2, 2);
0N/A }
0N/A
0N/A // selected dot
0N/A if (model.isSelected()) {
0N/A if (enabled) {
0N/A g.setColor(MetalLookAndFeel.getControlInfo());
0N/A } else {
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A }
0N/A g.fillRect( 4, 4, 4, 4);
0N/A g.drawLine( 4, 3, 7, 3);
0N/A g.drawLine( 8, 4, 8, 7);
0N/A g.drawLine( 7, 8, 4, 8);
0N/A g.drawLine( 3, 7, 3, 4);
0N/A }
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A if (MetalLookAndFeel.usingOcean()) {
0N/A paintOceanIcon(c, g, x, y);
0N/A return;
0N/A }
0N/A JRadioButton rb = (JRadioButton)c;
0N/A ButtonModel model = rb.getModel();
0N/A boolean drawDot = model.isSelected();
0N/A
0N/A Color background = c.getBackground();
0N/A Color dotColor = c.getForeground();
0N/A Color shadow = MetalLookAndFeel.getControlShadow();
0N/A Color darkCircle = MetalLookAndFeel.getControlDarkShadow();
0N/A Color whiteInnerLeftArc = MetalLookAndFeel.getControlHighlight();
0N/A Color whiteOuterRightArc = MetalLookAndFeel.getControlHighlight();
0N/A Color interiorColor = background;
0N/A
0N/A // Set up colors per RadioButtonModel condition
0N/A if ( !model.isEnabled() ) {
0N/A whiteInnerLeftArc = whiteOuterRightArc = background;
0N/A darkCircle = dotColor = shadow;
0N/A }
0N/A else if (model.isPressed() && model.isArmed() ) {
0N/A whiteInnerLeftArc = interiorColor = shadow;
0N/A }
0N/A
0N/A g.translate(x, y);
0N/A
0N/A // fill interior
0N/A g.setColor(interiorColor);
0N/A g.fillRect(2,2, 9,9);
0N/A
0N/A // draw Dark Circle (start at top, go clockwise)
0N/A g.setColor(darkCircle);
0N/A g.drawLine( 4, 0, 7, 0);
0N/A g.drawLine( 8, 1, 9, 1);
0N/A g.drawLine(10, 2, 10, 3);
0N/A g.drawLine(11, 4, 11, 7);
0N/A g.drawLine(10, 8, 10, 9);
0N/A g.drawLine( 9,10, 8,10);
0N/A g.drawLine( 7,11, 4,11);
0N/A g.drawLine( 3,10, 2,10);
0N/A g.drawLine( 1, 9, 1, 8);
0N/A g.drawLine( 0, 7, 0, 4);
0N/A g.drawLine( 1, 3, 1, 2);
0N/A g.drawLine( 2, 1, 3, 1);
0N/A
0N/A // draw Inner Left (usually) White Arc
0N/A // start at lower left corner, go clockwise
0N/A g.setColor(whiteInnerLeftArc);
0N/A g.drawLine( 2, 9, 2, 8);
0N/A g.drawLine( 1, 7, 1, 4);
0N/A g.drawLine( 2, 2, 2, 3);
0N/A g.drawLine( 2, 2, 3, 2);
0N/A g.drawLine( 4, 1, 7, 1);
0N/A g.drawLine( 8, 2, 9, 2);
0N/A // draw Outer Right White Arc
0N/A // start at upper right corner, go clockwise
0N/A g.setColor(whiteOuterRightArc);
0N/A g.drawLine(10, 1, 10, 1);
0N/A g.drawLine(11, 2, 11, 3);
0N/A g.drawLine(12, 4, 12, 7);
0N/A g.drawLine(11, 8, 11, 9);
0N/A g.drawLine(10,10, 10,10);
0N/A g.drawLine( 9,11, 8,11);
0N/A g.drawLine( 7,12, 4,12);
0N/A g.drawLine( 3,11, 2,11);
0N/A
0N/A // selected dot
0N/A if ( drawDot ) {
0N/A g.setColor(dotColor);
0N/A g.fillRect( 4, 4, 4, 4);
0N/A g.drawLine( 4, 3, 7, 3);
0N/A g.drawLine( 8, 4, 8, 7);
0N/A g.drawLine( 7, 8, 4, 8);
0N/A g.drawLine( 3, 7, 3, 4);
0N/A }
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 13;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 13;
0N/A }
0N/A } // End class RadioButtonIcon
0N/A
0N/A // Tree Computer Icon code
0N/A private static class TreeComputerIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A g.translate(x, y);
0N/A
0N/A // Fill glass portion of monitor
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.fillRect(5,4, 6,4);
0N/A
0N/A // Draw outside edge of monitor
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
0N/A g.drawLine( 2,2, 2,8); // left
0N/A g.drawLine(13,2, 13,8); // right
0N/A g.drawLine( 3,1, 12,1); // top
0N/A g.drawLine(12,9, 12,9); // bottom right base
0N/A g.drawLine( 3,9, 3,9); // bottom left base
0N/A // Draw the edge of the glass
0N/A g.drawLine( 4,4, 4,7); // left
0N/A g.drawLine( 5,3, 10,3); // top
0N/A g.drawLine(11,4, 11,7); // right
0N/A g.drawLine( 5,8, 10,8); // bottom
0N/A // Draw the edge of the CPU
0N/A g.drawLine( 1,10, 14,10); // top
0N/A g.drawLine(14,10, 14,14); // right
0N/A g.drawLine( 1,14, 14,14); // bottom
0N/A g.drawLine( 1,10, 1,14); // left
0N/A
0N/A // Draw the disk drives
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A g.drawLine( 6,12, 8,12); // left
0N/A g.drawLine(10,12, 12,12); // right
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 16;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 16;
0N/A }
0N/A } // End class TreeComputerIcon
0N/A
0N/A // Tree HardDrive Icon code
0N/A private static class TreeHardDriveIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A g.translate(x, y);
0N/A
0N/A // Draw edges of the disks
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
0N/A // top disk
0N/A g.drawLine(1,4, 1,5); // left
0N/A g.drawLine(2,3, 3,3);
0N/A g.drawLine(4,2, 11,2); // top
0N/A g.drawLine(12,3, 13,3);
0N/A g.drawLine(14,4, 14,5); // right
0N/A g.drawLine(12,6, 13,6);
0N/A g.drawLine(4,7, 11,7); // bottom
0N/A g.drawLine(2,6, 3,6);
0N/A // middle disk
0N/A g.drawLine(1,7, 1,8); // left
0N/A g.drawLine(2,9, 3,9);
0N/A g.drawLine(4,10, 11,10); // bottom
0N/A g.drawLine(12,9, 13,9);
0N/A g.drawLine(14,7, 14, 8); // right
0N/A // bottom disk
0N/A g.drawLine(1,10, 1,11); // left
0N/A g.drawLine(2,12, 3,12);
0N/A g.drawLine(4,13, 11,13); // bottom
0N/A g.drawLine(12,12, 13,12);
0N/A g.drawLine(14,10, 14,11); // right
0N/A
0N/A // Draw the down right shadows
0N/A g.setColor(MetalLookAndFeel.getControlShadow());
0N/A // top disk
0N/A g.drawLine(7,6, 7,6);
0N/A g.drawLine(9,6, 9,6);
0N/A g.drawLine(10,5, 10,5);
0N/A g.drawLine(11,6, 11,6);
0N/A g.drawLine(12,5, 13,5);
0N/A g.drawLine(13,4, 13,4);
0N/A // middle disk
0N/A g.drawLine(7,9, 7,9);
0N/A g.drawLine(9,9, 9,9);
0N/A g.drawLine(10,8, 10,8);
0N/A g.drawLine(11,9, 11,9);
0N/A g.drawLine(12,8, 13,8);
0N/A g.drawLine(13,7, 13,7);
0N/A // bottom disk
0N/A g.drawLine(7,12, 7,12);
0N/A g.drawLine(9,12, 9,12);
0N/A g.drawLine(10,11, 10,11);
0N/A g.drawLine(11,12, 11,12);
0N/A g.drawLine(12,11, 13,11);
0N/A g.drawLine(13,10, 13,10);
0N/A
0N/A // Draw the up left highlight
0N/A g.setColor(MetalLookAndFeel.getControlHighlight());
0N/A // top disk
0N/A g.drawLine(4,3, 5,3);
0N/A g.drawLine(7,3, 9,3);
0N/A g.drawLine(11,3, 11,3);
0N/A g.drawLine(2,4, 6,4);
0N/A g.drawLine(8,4, 8,4);
0N/A g.drawLine(2,5, 3,5);
0N/A g.drawLine(4,6, 4,6);
0N/A // middle disk
0N/A g.drawLine(2,7, 3,7);
0N/A g.drawLine(2,8, 3,8);
0N/A g.drawLine(4,9, 4,9);
0N/A // bottom disk
0N/A g.drawLine(2,10, 3,10);
0N/A g.drawLine(2,11, 3,11);
0N/A g.drawLine(4,12, 4,12);
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 16;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 16;
0N/A }
0N/A } // End class TreeHardDriveIcon
0N/A
0N/A // Tree FloppyDrive Icon code
0N/A private static class TreeFloppyDriveIcon implements Icon, UIResource, Serializable {
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A g.translate(x, y);
0N/A
0N/A // Fill body of floppy
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.fillRect(2,2, 12,12);
0N/A
0N/A // Draw outside edge of floppy
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
0N/A g.drawLine( 1, 1, 13, 1); // top
0N/A g.drawLine(14, 2, 14,14); // right
0N/A g.drawLine( 1,14, 14,14); // bottom
0N/A g.drawLine( 1, 1, 1,14); // left
0N/A
0N/A // Draw grey-ish highlights
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A g.fillRect(5,2, 6,5); // metal disk protector part
0N/A g.drawLine(4,8, 11,8); // top of label
0N/A g.drawLine(3,9, 3,13); // left of label
0N/A g.drawLine(12,9, 12,13); // right of label
0N/A
0N/A // Draw label and exposed disk
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
0N/A g.fillRect(8,3, 2,3); // exposed disk
0N/A g.fillRect(4,9, 8,5); // label
0N/A
0N/A // Draw text on label
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
0N/A g.drawLine(5,10, 9,10);
0N/A g.drawLine(5,12, 8,12);
0N/A
0N/A g.translate(-x, -y);
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 16;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 16;
0N/A }
0N/A } // End class TreeFloppyDriveIcon
0N/A
0N/A
0N/A static private final Dimension folderIcon16Size = new Dimension( 16, 16 );
0N/A
0N/A /**
0N/A * Utility class for caching icon images. This is necessary because
0N/A * we need a new image whenever we are rendering into a new
0N/A * GraphicsConfiguration, but we do not want to keep recreating icon
0N/A * images for GC's that we have already seen (for example,
0N/A * dragging a window back and forth between monitors on a multimon
0N/A * system, or drawing an icon to different Components that have different
0N/A * GC's).
0N/A * So now whenever we create a new icon image for a given GC, we
0N/A * cache that image with the GC for later retrieval.
0N/A */
0N/A static class ImageCacher {
0N/A
0N/A // PENDING: Replace this class with CachedPainter.
0N/A
614N/A Vector<ImageGcPair> images = new Vector<ImageGcPair>(1, 1);
0N/A ImageGcPair currentImageGcPair;
0N/A
0N/A class ImageGcPair {
0N/A Image image;
0N/A GraphicsConfiguration gc;
0N/A ImageGcPair(Image image, GraphicsConfiguration gc) {
0N/A this.image = image;
0N/A this.gc = gc;
0N/A }
0N/A
0N/A boolean hasSameConfiguration(GraphicsConfiguration newGC) {
614N/A return ((newGC != null) && (newGC.equals(gc))) ||
614N/A ((newGC == null) && (gc == null));
0N/A }
0N/A
0N/A }
0N/A
0N/A Image getImage(GraphicsConfiguration newGC) {
0N/A if ((currentImageGcPair == null) ||
0N/A !(currentImageGcPair.hasSameConfiguration(newGC)))
0N/A {
614N/A for (ImageGcPair imgGcPair : images) {
0N/A if (imgGcPair.hasSameConfiguration(newGC)) {
0N/A currentImageGcPair = imgGcPair;
0N/A return imgGcPair.image;
0N/A }
0N/A }
0N/A return null;
0N/A }
0N/A return currentImageGcPair.image;
0N/A }
0N/A
0N/A void cacheImage(Image image, GraphicsConfiguration gc) {
0N/A ImageGcPair imgGcPair = new ImageGcPair(image, gc);
0N/A images.addElement(imgGcPair);
0N/A currentImageGcPair = imgGcPair;
0N/A }
0N/A
0N/A }
0N/A
0N/A /**
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A */
0N/A public static class FolderIcon16 implements Icon, Serializable {
0N/A
0N/A ImageCacher imageCacher;
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A GraphicsConfiguration gc = c.getGraphicsConfiguration();
0N/A if (imageCacher == null) {
0N/A imageCacher = new ImageCacher();
0N/A }
0N/A Image image = imageCacher.getImage(gc);
0N/A if (image == null) {
0N/A if (gc != null) {
0N/A image = gc.createCompatibleImage(getIconWidth(),
0N/A getIconHeight(),
0N/A Transparency.BITMASK);
0N/A } else {
0N/A image = new BufferedImage(getIconWidth(),
0N/A getIconHeight(),
0N/A BufferedImage.TYPE_INT_ARGB);
0N/A }
0N/A Graphics imageG = image.getGraphics();
0N/A paintMe(c,imageG);
0N/A imageG.dispose();
0N/A imageCacher.cacheImage(image, gc);
0N/A }
0N/A g.drawImage(image, x, y+getShift(), null);
0N/A }
0N/A
0N/A
0N/A private void paintMe(Component c, Graphics g) {
0N/A
0N/A int right = folderIcon16Size.width - 1;
0N/A int bottom = folderIcon16Size.height - 1;
0N/A
0N/A // Draw tab top
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
0N/A g.drawLine( right - 5, 3, right, 3 );
0N/A g.drawLine( right - 6, 4, right, 4 );
0N/A
0N/A // Draw folder front
0N/A g.setColor( MetalLookAndFeel.getPrimaryControl() );
0N/A g.fillRect( 2, 7, 13, 8 );
0N/A
0N/A // Draw tab bottom
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
0N/A g.drawLine( right - 6, 5, right - 1, 5 );
0N/A
0N/A // Draw outline
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
0N/A g.drawLine( 0, 6, 0, bottom ); // left side
0N/A g.drawLine( 1, 5, right - 7, 5 ); // first part of top
0N/A g.drawLine( right - 6, 6, right - 1, 6 ); // second part of top
0N/A g.drawLine( right, 5, right, bottom ); // right side
0N/A g.drawLine( 0, bottom, right, bottom ); // bottom
0N/A
0N/A // Draw highlight
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
0N/A g.drawLine( 1, 6, 1, bottom - 1 );
0N/A g.drawLine( 1, 6, right - 7, 6 );
0N/A g.drawLine( right - 6, 7, right - 1, 7 );
0N/A
0N/A }
0N/A
0N/A public int getShift() { return 0; }
0N/A public int getAdditionalHeight() { return 0; }
0N/A
0N/A public int getIconWidth() { return folderIcon16Size.width; }
0N/A public int getIconHeight() { return folderIcon16Size.height + getAdditionalHeight(); }
0N/A }
0N/A
0N/A
0N/A /**
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A */
0N/A public static class TreeFolderIcon extends FolderIcon16 {
0N/A public int getShift() { return -1; }
0N/A public int getAdditionalHeight() { return 2; }
0N/A }
0N/A
0N/A
0N/A static private final Dimension fileIcon16Size = new Dimension( 16, 16 );
0N/A
0N/A /**
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A */
0N/A public static class FileIcon16 implements Icon, Serializable {
0N/A
0N/A ImageCacher imageCacher;
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A GraphicsConfiguration gc = c.getGraphicsConfiguration();
0N/A if (imageCacher == null) {
0N/A imageCacher = new ImageCacher();
0N/A }
0N/A Image image = imageCacher.getImage(gc);
0N/A if (image == null) {
0N/A if (gc != null) {
0N/A image = gc.createCompatibleImage(getIconWidth(),
0N/A getIconHeight(),
0N/A Transparency.BITMASK);
0N/A } else {
0N/A image = new BufferedImage(getIconWidth(),
0N/A getIconHeight(),
0N/A BufferedImage.TYPE_INT_ARGB);
0N/A }
0N/A Graphics imageG = image.getGraphics();
0N/A paintMe(c,imageG);
0N/A imageG.dispose();
0N/A imageCacher.cacheImage(image, gc);
0N/A }
0N/A g.drawImage(image, x, y+getShift(), null);
0N/A }
0N/A
0N/A private void paintMe(Component c, Graphics g) {
0N/A
0N/A int right = fileIcon16Size.width - 1;
0N/A int bottom = fileIcon16Size.height - 1;
0N/A
0N/A // Draw fill
0N/A g.setColor( MetalLookAndFeel.getWindowBackground() );
0N/A g.fillRect( 4, 2, 9, 12 );
0N/A
0N/A // Draw frame
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
0N/A g.drawLine( 2, 0, 2, bottom ); // left
0N/A g.drawLine( 2, 0, right - 4, 0 ); // top
0N/A g.drawLine( 2, bottom, right - 1, bottom ); // bottom
0N/A g.drawLine( right - 1, 6, right - 1, bottom ); // right
0N/A g.drawLine( right - 6, 2, right - 2, 6 ); // slant 1
0N/A g.drawLine( right - 5, 1, right - 4, 1 ); // part of slant 2
0N/A g.drawLine( right - 3, 2, right - 3, 3 ); // part of slant 2
0N/A g.drawLine( right - 2, 4, right - 2, 5 ); // part of slant 2
0N/A
0N/A // Draw highlight
0N/A g.setColor( MetalLookAndFeel.getPrimaryControl() );
0N/A g.drawLine( 3, 1, 3, bottom - 1 ); // left
0N/A g.drawLine( 3, 1, right - 6, 1 ); // top
0N/A g.drawLine( right - 2, 7, right - 2, bottom - 1 ); // right
0N/A g.drawLine( right - 5, 2, right - 3, 4 ); // slant
0N/A g.drawLine( 3, bottom - 1, right - 2, bottom - 1 ); // bottom
0N/A
0N/A }
0N/A
0N/A public int getShift() { return 0; }
0N/A public int getAdditionalHeight() { return 0; }
0N/A
0N/A public int getIconWidth() { return fileIcon16Size.width; }
0N/A public int getIconHeight() { return fileIcon16Size.height + getAdditionalHeight(); }
0N/A }
0N/A
0N/A
0N/A public static class TreeLeafIcon extends FileIcon16 {
0N/A public int getShift() { return 2; }
0N/A public int getAdditionalHeight() { return 4; }
0N/A }
0N/A
0N/A
0N/A static private final Dimension treeControlSize = new Dimension( 18, 18 );
0N/A
0N/A /**
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A */
0N/A public static class TreeControlIcon implements Icon, Serializable {
0N/A // This data member should not have been exposed. It's called
0N/A // isLight, but now it really means isCollapsed. Since we can't change
0N/A // any APIs... that's life.
0N/A protected boolean isLight;
0N/A
0N/A
0N/A public TreeControlIcon( boolean isCollapsed ) {
0N/A isLight = isCollapsed;
0N/A }
0N/A
0N/A ImageCacher imageCacher;
0N/A
0N/A transient boolean cachedOrientation = true;
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A
0N/A GraphicsConfiguration gc = c.getGraphicsConfiguration();
0N/A
0N/A if (imageCacher == null) {
0N/A imageCacher = new ImageCacher();
0N/A }
0N/A Image image = imageCacher.getImage(gc);
0N/A
0N/A if (image == null || cachedOrientation != MetalUtils.isLeftToRight(c)) {
0N/A cachedOrientation = MetalUtils.isLeftToRight(c);
0N/A if (gc != null) {
0N/A image = gc.createCompatibleImage(getIconWidth(),
0N/A getIconHeight(),
0N/A Transparency.BITMASK);
0N/A } else {
0N/A image = new BufferedImage(getIconWidth(),
0N/A getIconHeight(),
0N/A BufferedImage.TYPE_INT_ARGB);
0N/A }
0N/A Graphics imageG = image.getGraphics();
0N/A paintMe(c,imageG,x,y);
0N/A imageG.dispose();
0N/A imageCacher.cacheImage(image, gc);
0N/A
0N/A }
0N/A
0N/A if (MetalUtils.isLeftToRight(c)) {
0N/A if (isLight) { // isCollapsed
0N/A g.drawImage(image, x+5, y+3, x+18, y+13,
0N/A 4,3, 17, 13, null);
0N/A }
0N/A else {
0N/A g.drawImage(image, x+5, y+3, x+18, y+17,
0N/A 4,3, 17, 17, null);
0N/A }
0N/A }
0N/A else {
0N/A if (isLight) { // isCollapsed
0N/A g.drawImage(image, x+3, y+3, x+16, y+13,
0N/A 4, 3, 17, 13, null);
0N/A }
0N/A else {
0N/A g.drawImage(image, x+3, y+3, x+16, y+17,
0N/A 4, 3, 17, 17, null);
0N/A }
0N/A }
0N/A }
0N/A
0N/A public void paintMe(Component c, Graphics g, int x, int y) {
0N/A
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
0N/A
0N/A int xoff = (MetalUtils.isLeftToRight(c)) ? 0 : 4;
0N/A
0N/A // Draw circle
0N/A g.drawLine( xoff + 4, 6, xoff + 4, 9 ); // left
0N/A g.drawLine( xoff + 5, 5, xoff + 5, 5 ); // top left dot
0N/A g.drawLine( xoff + 6, 4, xoff + 9, 4 ); // top
0N/A g.drawLine( xoff + 10, 5, xoff + 10, 5 ); // top right dot
0N/A g.drawLine( xoff + 11, 6, xoff + 11, 9 ); // right
0N/A g.drawLine( xoff + 10, 10, xoff + 10, 10 ); // botom right dot
0N/A g.drawLine( xoff + 6, 11, xoff + 9, 11 ); // bottom
0N/A g.drawLine( xoff + 5, 10, xoff + 5, 10 ); // bottom left dot
0N/A
0N/A // Draw Center Dot
0N/A g.drawLine( xoff + 7, 7, xoff + 8, 7 );
0N/A g.drawLine( xoff + 7, 8, xoff + 8, 8 );
0N/A
0N/A // Draw Handle
0N/A if ( isLight ) { // isCollapsed
0N/A if( MetalUtils.isLeftToRight(c) ) {
0N/A g.drawLine( 12, 7, 15, 7 );
0N/A g.drawLine( 12, 8, 15, 8 );
0N/A // g.setColor( c.getBackground() );
0N/A // g.drawLine( 16, 7, 16, 8 );
0N/A }
0N/A else {
0N/A g.drawLine(4, 7, 7, 7);
0N/A g.drawLine(4, 8, 7, 8);
0N/A }
0N/A }
0N/A else {
0N/A g.drawLine( xoff + 7, 12, xoff + 7, 15 );
0N/A g.drawLine( xoff + 8, 12, xoff + 8, 15 );
0N/A // g.setColor( c.getBackground() );
0N/A // g.drawLine( xoff + 7, 16, xoff + 8, 16 );
0N/A }
0N/A
0N/A // Draw Fill
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
0N/A g.drawLine( xoff + 5, 6, xoff + 5, 9 ); // left shadow
0N/A g.drawLine( xoff + 6, 5, xoff + 9, 5 ); // top shadow
0N/A
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
0N/A g.drawLine( xoff + 6, 6, xoff + 6, 6 ); // top left fill
0N/A g.drawLine( xoff + 9, 6, xoff + 9, 6 ); // top right fill
0N/A g.drawLine( xoff + 6, 9, xoff + 6, 9 ); // bottom left fill
0N/A g.drawLine( xoff + 10, 6, xoff + 10, 9 ); // right fill
0N/A g.drawLine( xoff + 6, 10, xoff + 9, 10 ); // bottom fill
0N/A
0N/A g.setColor( MetalLookAndFeel.getPrimaryControl() );
0N/A g.drawLine( xoff + 6, 7, xoff + 6, 8 ); // left highlight
0N/A g.drawLine( xoff + 7, 6, xoff + 8, 6 ); // top highlight
0N/A g.drawLine( xoff + 9, 7, xoff + 9, 7 ); // right highlight
0N/A g.drawLine( xoff + 7, 9, xoff + 7, 9 ); // bottom highlight
0N/A
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
0N/A g.drawLine( xoff + 8, 9, xoff + 9, 9 );
0N/A g.drawLine( xoff + 9, 8, xoff + 9, 8 );
0N/A }
0N/A
0N/A public int getIconWidth() { return treeControlSize.width; }
0N/A public int getIconHeight() { return treeControlSize.height; }
0N/A }
0N/A
0N/A //
0N/A // Menu Icons
0N/A //
0N/A
0N/A static private final Dimension menuArrowIconSize = new Dimension( 4, 8 );
0N/A static private final Dimension menuCheckIconSize = new Dimension( 10, 10 );
0N/A static private final int xOff = 4;
0N/A
0N/A private static class MenuArrowIcon implements Icon, UIResource, Serializable
0N/A {
0N/A public void paintIcon( Component c, Graphics g, int x, int y )
0N/A {
0N/A JMenuItem b = (JMenuItem) c;
0N/A ButtonModel model = b.getModel();
0N/A
0N/A g.translate( x, y );
0N/A
0N/A if ( !model.isEnabled() )
0N/A {
0N/A g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
0N/A }
0N/A else
0N/A {
0N/A if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
0N/A {
0N/A g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
0N/A }
0N/A else
0N/A {
0N/A g.setColor( b.getForeground() );
0N/A }
0N/A }
0N/A if( MetalUtils.isLeftToRight(b) ) {
0N/A g.drawLine( 0, 0, 0, 7 );
0N/A g.drawLine( 1, 1, 1, 6 );
0N/A g.drawLine( 2, 2, 2, 5 );
0N/A g.drawLine( 3, 3, 3, 4 );
0N/A } else {
0N/A g.drawLine( 4, 0, 4, 7 );
0N/A g.drawLine( 3, 1, 3, 6 );
0N/A g.drawLine( 2, 2, 2, 5 );
0N/A g.drawLine( 1, 3, 1, 4 );
0N/A }
0N/A
0N/A g.translate( -x, -y );
0N/A }
0N/A
0N/A public int getIconWidth() { return menuArrowIconSize.width; }
0N/A
0N/A public int getIconHeight() { return menuArrowIconSize.height; }
0N/A
0N/A } // End class MenuArrowIcon
0N/A
0N/A private static class MenuItemArrowIcon implements Icon, UIResource, Serializable
0N/A {
0N/A public void paintIcon( Component c, Graphics g, int x, int y )
0N/A {
0N/A }
0N/A
0N/A public int getIconWidth() { return menuArrowIconSize.width; }
0N/A
0N/A public int getIconHeight() { return menuArrowIconSize.height; }
0N/A
0N/A } // End class MenuItemArrowIcon
0N/A
0N/A private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable
0N/A {
0N/A public void paintOceanIcon(Component c, Graphics g, int x, int y) {
0N/A ButtonModel model = ((JMenuItem)c).getModel();
0N/A boolean isSelected = model.isSelected();
0N/A boolean isEnabled = model.isEnabled();
0N/A boolean isPressed = model.isPressed();
0N/A boolean isArmed = model.isArmed();
0N/A
0N/A g.translate(x, y);
0N/A if (isEnabled) {
0N/A MetalUtils.drawGradient(c, g, "CheckBoxMenuItem.gradient",
0N/A 1, 1, 7, 7, true);
0N/A if (isPressed || isArmed) {
0N/A g.setColor(MetalLookAndFeel.getControlInfo());
0N/A g.drawLine( 0, 0, 8, 0 );
0N/A g.drawLine( 0, 0, 0, 8 );
0N/A g.drawLine( 8, 2, 8, 8 );
0N/A g.drawLine( 2, 8, 8, 8 );
0N/A
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.drawLine( 9, 1, 9, 9 );
0N/A g.drawLine( 1, 9, 9, 9 );
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A g.drawLine( 0, 0, 8, 0 );
0N/A g.drawLine( 0, 0, 0, 8 );
0N/A g.drawLine( 8, 2, 8, 8 );
0N/A g.drawLine( 2, 8, 8, 8 );
0N/A
0N/A g.setColor(MetalLookAndFeel.getControlHighlight());
0N/A g.drawLine( 9, 1, 9, 9 );
0N/A g.drawLine( 1, 9, 9, 9 );
0N/A }
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
0N/A g.drawRect( 0, 0, 8, 8 );
0N/A }
0N/A if (isSelected) {
0N/A if (isEnabled) {
0N/A if (isArmed || ( c instanceof JMenu && isSelected)) {
0N/A g.setColor(
0N/A MetalLookAndFeel.getMenuSelectedForeground() );
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getControlInfo());
0N/A }
0N/A }
0N/A else {
0N/A g.setColor( MetalLookAndFeel.getMenuDisabledForeground());
0N/A }
0N/A
0N/A g.drawLine( 2, 2, 2, 6 );
0N/A g.drawLine( 3, 2, 3, 6 );
0N/A g.drawLine( 4, 4, 8, 0 );
0N/A g.drawLine( 4, 5, 9, 0 );
0N/A }
0N/A g.translate( -x, -y );
0N/A }
0N/A
0N/A public void paintIcon( Component c, Graphics g, int x, int y )
0N/A {
0N/A if (MetalLookAndFeel.usingOcean()) {
0N/A paintOceanIcon(c, g, x, y);
0N/A return;
0N/A }
0N/A JMenuItem b = (JMenuItem) c;
0N/A ButtonModel model = b.getModel();
0N/A
0N/A boolean isSelected = model.isSelected();
0N/A boolean isEnabled = model.isEnabled();
0N/A boolean isPressed = model.isPressed();
0N/A boolean isArmed = model.isArmed();
0N/A
0N/A g.translate( x, y );
0N/A
0N/A if ( isEnabled )
0N/A {
0N/A if ( isPressed || isArmed )
0N/A {
0N/A g.setColor( MetalLookAndFeel.getControlInfo() );
0N/A g.drawLine( 0, 0, 8, 0 );
0N/A g.drawLine( 0, 0, 0, 8 );
0N/A g.drawLine( 8, 2, 8, 8 );
0N/A g.drawLine( 2, 8, 8, 8 );
0N/A
0N/A g.setColor( MetalLookAndFeel.getPrimaryControl() );
0N/A g.drawLine( 1, 1, 7, 1 );
0N/A g.drawLine( 1, 1, 1, 7 );
0N/A g.drawLine( 9, 1, 9, 9 );
0N/A g.drawLine( 1, 9, 9, 9 );
0N/A }
0N/A else
0N/A {
0N/A g.setColor( MetalLookAndFeel.getControlDarkShadow() );
0N/A g.drawLine( 0, 0, 8, 0 );
0N/A g.drawLine( 0, 0, 0, 8 );
0N/A g.drawLine( 8, 2, 8, 8 );
0N/A g.drawLine( 2, 8, 8, 8 );
0N/A
0N/A g.setColor( MetalLookAndFeel.getControlHighlight() );
0N/A g.drawLine( 1, 1, 7, 1 );
0N/A g.drawLine( 1, 1, 1, 7 );
0N/A g.drawLine( 9, 1, 9, 9 );
0N/A g.drawLine( 1, 9, 9, 9 );
0N/A }
0N/A }
0N/A else
0N/A {
0N/A g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
0N/A g.drawRect( 0, 0, 8, 8 );
0N/A }
0N/A
0N/A if ( isSelected )
0N/A {
0N/A if ( isEnabled )
0N/A {
0N/A if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
0N/A {
0N/A g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
0N/A }
0N/A else
0N/A {
0N/A g.setColor( b.getForeground() );
0N/A }
0N/A }
0N/A else
0N/A {
0N/A g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
0N/A }
0N/A
0N/A g.drawLine( 2, 2, 2, 6 );
0N/A g.drawLine( 3, 2, 3, 6 );
0N/A g.drawLine( 4, 4, 8, 0 );
0N/A g.drawLine( 4, 5, 9, 0 );
0N/A }
0N/A
0N/A g.translate( -x, -y );
0N/A }
0N/A
0N/A public int getIconWidth() { return menuCheckIconSize.width; }
0N/A
0N/A public int getIconHeight() { return menuCheckIconSize.height; }
0N/A
0N/A } // End class CheckBoxMenuItemIcon
0N/A
0N/A private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable
0N/A {
0N/A public void paintOceanIcon(Component c, Graphics g, int x, int y) {
0N/A ButtonModel model = ((JMenuItem)c).getModel();
0N/A boolean isSelected = model.isSelected();
0N/A boolean isEnabled = model.isEnabled();
0N/A boolean isPressed = model.isPressed();
0N/A boolean isArmed = model.isArmed();
0N/A
0N/A g.translate( x, y );
0N/A
0N/A if (isEnabled) {
0N/A MetalUtils.drawGradient(c, g, "RadioButtonMenuItem.gradient",
0N/A 1, 1, 7, 7, true);
0N/A if (isPressed || isArmed) {
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getControlHighlight());
0N/A }
0N/A g.drawLine( 2, 9, 7, 9 );
0N/A g.drawLine( 9, 2, 9, 7 );
0N/A g.drawLine( 8, 8, 8, 8 );
0N/A
0N/A if (isPressed || isArmed) {
0N/A g.setColor(MetalLookAndFeel.getControlInfo());
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getControlDarkShadow());
0N/A }
0N/A }
0N/A else {
0N/A g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
0N/A }
0N/A g.drawLine( 2, 0, 6, 0 );
0N/A g.drawLine( 2, 8, 6, 8 );
0N/A g.drawLine( 0, 2, 0, 6 );
0N/A g.drawLine( 8, 2, 8, 6 );
0N/A g.drawLine( 1, 1, 1, 1 );
0N/A g.drawLine( 7, 1, 7, 1 );
0N/A g.drawLine( 1, 7, 1, 7 );
0N/A g.drawLine( 7, 7, 7, 7 );
0N/A
0N/A if (isSelected) {
0N/A if (isEnabled) {
0N/A if (isArmed || (c instanceof JMenu && model.isSelected())){
0N/A g.setColor(MetalLookAndFeel.
0N/A getMenuSelectedForeground() );
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getControlInfo());
0N/A }
0N/A }
0N/A else {
0N/A g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
0N/A }
0N/A g.drawLine( 3, 2, 5, 2 );
0N/A g.drawLine( 2, 3, 6, 3 );
0N/A g.drawLine( 2, 4, 6, 4 );
0N/A g.drawLine( 2, 5, 6, 5 );
0N/A g.drawLine( 3, 6, 5, 6 );
0N/A }
0N/A
0N/A g.translate( -x, -y );
0N/A }
0N/A
0N/A public void paintIcon( Component c, Graphics g, int x, int y )
0N/A {
0N/A if (MetalLookAndFeel.usingOcean()) {
0N/A paintOceanIcon(c, g, x, y);
0N/A return;
0N/A }
0N/A JMenuItem b = (JMenuItem) c;
0N/A ButtonModel model = b.getModel();
0N/A
0N/A boolean isSelected = model.isSelected();
0N/A boolean isEnabled = model.isEnabled();
0N/A boolean isPressed = model.isPressed();
0N/A boolean isArmed = model.isArmed();
0N/A
0N/A g.translate( x, y );
0N/A
0N/A if ( isEnabled )
0N/A {
0N/A if ( isPressed || isArmed )
0N/A {
0N/A g.setColor( MetalLookAndFeel.getPrimaryControl() );
0N/A g.drawLine( 3, 1, 8, 1 );
0N/A g.drawLine( 2, 9, 7, 9 );
0N/A g.drawLine( 1, 3, 1, 8 );
0N/A g.drawLine( 9, 2, 9, 7 );
0N/A g.drawLine( 2, 2, 2, 2 );
0N/A g.drawLine( 8, 8, 8, 8 );
0N/A
0N/A g.setColor( MetalLookAndFeel.getControlInfo() );
0N/A g.drawLine( 2, 0, 6, 0 );
0N/A g.drawLine( 2, 8, 6, 8 );
0N/A g.drawLine( 0, 2, 0, 6 );
0N/A g.drawLine( 8, 2, 8, 6 );
0N/A g.drawLine( 1, 1, 1, 1 );
0N/A g.drawLine( 7, 1, 7, 1 );
0N/A g.drawLine( 1, 7, 1, 7 );
0N/A g.drawLine( 7, 7, 7, 7 );
0N/A }
0N/A else
0N/A {
0N/A g.setColor( MetalLookAndFeel.getControlHighlight() );
0N/A g.drawLine( 3, 1, 8, 1 );
0N/A g.drawLine( 2, 9, 7, 9 );
0N/A g.drawLine( 1, 3, 1, 8 );
0N/A g.drawLine( 9, 2, 9, 7 );
0N/A g.drawLine( 2, 2, 2, 2 );
0N/A g.drawLine( 8, 8, 8, 8 );
0N/A
0N/A g.setColor( MetalLookAndFeel.getControlDarkShadow() );
0N/A g.drawLine( 2, 0, 6, 0 );
0N/A g.drawLine( 2, 8, 6, 8 );
0N/A g.drawLine( 0, 2, 0, 6 );
0N/A g.drawLine( 8, 2, 8, 6 );
0N/A g.drawLine( 1, 1, 1, 1 );
0N/A g.drawLine( 7, 1, 7, 1 );
0N/A g.drawLine( 1, 7, 1, 7 );
0N/A g.drawLine( 7, 7, 7, 7 );
0N/A }
0N/A }
0N/A else
0N/A {
0N/A g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
0N/A g.drawLine( 2, 0, 6, 0 );
0N/A g.drawLine( 2, 8, 6, 8 );
0N/A g.drawLine( 0, 2, 0, 6 );
0N/A g.drawLine( 8, 2, 8, 6 );
0N/A g.drawLine( 1, 1, 1, 1 );
0N/A g.drawLine( 7, 1, 7, 1 );
0N/A g.drawLine( 1, 7, 1, 7 );
0N/A g.drawLine( 7, 7, 7, 7 );
0N/A }
0N/A
0N/A if ( isSelected )
0N/A {
0N/A if ( isEnabled )
0N/A {
0N/A if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
0N/A {
0N/A g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
0N/A }
0N/A else
0N/A {
0N/A g.setColor( b.getForeground() );
0N/A }
0N/A }
0N/A else
0N/A {
0N/A g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
0N/A }
0N/A
0N/A g.drawLine( 3, 2, 5, 2 );
0N/A g.drawLine( 2, 3, 6, 3 );
0N/A g.drawLine( 2, 4, 6, 4 );
0N/A g.drawLine( 2, 5, 6, 5 );
0N/A g.drawLine( 3, 6, 5, 6 );
0N/A }
0N/A
0N/A g.translate( -x, -y );
0N/A }
0N/A
0N/A public int getIconWidth() { return menuCheckIconSize.width; }
0N/A
0N/A public int getIconHeight() { return menuCheckIconSize.height; }
0N/A
0N/A } // End class RadioButtonMenuItemIcon
0N/A
0N/Aprivate static class VerticalSliderThumbIcon implements Icon, Serializable, UIResource {
0N/A protected static MetalBumps controlBumps;
0N/A protected static MetalBumps primaryBumps;
0N/A
0N/A public VerticalSliderThumbIcon() {
0N/A controlBumps = new MetalBumps( 6, 10,
0N/A MetalLookAndFeel.getControlHighlight(),
0N/A MetalLookAndFeel.getControlInfo(),
0N/A MetalLookAndFeel.getControl() );
0N/A primaryBumps = new MetalBumps( 6, 10,
0N/A MetalLookAndFeel.getPrimaryControl(),
0N/A MetalLookAndFeel.getPrimaryControlDarkShadow(),
0N/A MetalLookAndFeel.getPrimaryControlShadow() );
0N/A }
0N/A
0N/A public void paintIcon( Component c, Graphics g, int x, int y ) {
230N/A boolean leftToRight = MetalUtils.isLeftToRight(c);
0N/A
0N/A g.translate( x, y );
0N/A
0N/A // Draw the frame
230N/A if ( c.hasFocus() ) {
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
0N/A }
0N/A else {
230N/A g.setColor( c.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
0N/A MetalLookAndFeel.getControlDarkShadow() );
0N/A }
0N/A
0N/A if (leftToRight) {
0N/A g.drawLine( 1,0 , 8,0 ); // top
0N/A g.drawLine( 0,1 , 0,13 ); // left
0N/A g.drawLine( 1,14 , 8,14 ); // bottom
0N/A g.drawLine( 9,1 , 15,7 ); // top slant
0N/A g.drawLine( 9,13 , 15,7 ); // bottom slant
0N/A }
0N/A else {
0N/A g.drawLine( 7,0 , 14,0 ); // top
0N/A g.drawLine( 15,1 , 15,13 ); // right
0N/A g.drawLine( 7,14 , 14,14 ); // bottom
0N/A g.drawLine( 0,7 , 6,1 ); // top slant
0N/A g.drawLine( 0,7 , 6,13 ); // bottom slant
0N/A }
0N/A
0N/A // Fill in the background
230N/A if ( c.hasFocus() ) {
0N/A g.setColor( c.getForeground() );
0N/A }
0N/A else {
0N/A g.setColor( MetalLookAndFeel.getControl() );
0N/A }
0N/A
0N/A if (leftToRight) {
0N/A g.fillRect( 1,1 , 8,13 );
0N/A
0N/A g.drawLine( 9,2 , 9,12 );
0N/A g.drawLine( 10,3 , 10,11 );
0N/A g.drawLine( 11,4 , 11,10 );
0N/A g.drawLine( 12,5 , 12,9 );
0N/A g.drawLine( 13,6 , 13,8 );
0N/A g.drawLine( 14,7 , 14,7 );
0N/A }
0N/A else {
0N/A g.fillRect( 7,1, 8,13 );
0N/A
0N/A g.drawLine( 6,3 , 6,12 );
0N/A g.drawLine( 5,4 , 5,11 );
0N/A g.drawLine( 4,5 , 4,10 );
0N/A g.drawLine( 3,6 , 3,9 );
0N/A g.drawLine( 2,7 , 2,8 );
0N/A }
0N/A
0N/A // Draw the bumps
0N/A int offset = (leftToRight) ? 2 : 8;
230N/A if ( c.isEnabled() ) {
230N/A if ( c.hasFocus() ) {
0N/A primaryBumps.paintIcon( c, g, offset, 2 );
0N/A }
0N/A else {
0N/A controlBumps.paintIcon( c, g, offset, 2 );
0N/A }
0N/A }
0N/A
0N/A // Draw the highlight
230N/A if ( c.isEnabled() ) {
230N/A g.setColor( c.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
0N/A : MetalLookAndFeel.getControlHighlight() );
0N/A if (leftToRight) {
0N/A g.drawLine( 1, 1, 8, 1 );
0N/A g.drawLine( 1, 1, 1, 13 );
0N/A }
0N/A else {
0N/A g.drawLine( 8,1 , 14,1 ); // top
0N/A g.drawLine( 1,7 , 7,1 ); // top slant
0N/A }
0N/A }
0N/A
0N/A g.translate( -x, -y );
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 16;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 15;
0N/A }
0N/A}
0N/A
0N/Aprivate static class HorizontalSliderThumbIcon implements Icon, Serializable, UIResource {
0N/A protected static MetalBumps controlBumps;
0N/A protected static MetalBumps primaryBumps;
0N/A
0N/A public HorizontalSliderThumbIcon() {
0N/A controlBumps = new MetalBumps( 10, 6,
0N/A MetalLookAndFeel.getControlHighlight(),
0N/A MetalLookAndFeel.getControlInfo(),
0N/A MetalLookAndFeel.getControl() );
0N/A primaryBumps = new MetalBumps( 10, 6,
0N/A MetalLookAndFeel.getPrimaryControl(),
0N/A MetalLookAndFeel.getPrimaryControlDarkShadow(),
0N/A MetalLookAndFeel.getPrimaryControlShadow() );
0N/A }
0N/A
0N/A public void paintIcon( Component c, Graphics g, int x, int y ) {
0N/A g.translate( x, y );
0N/A
0N/A // Draw the frame
230N/A if ( c.hasFocus() ) {
0N/A g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
0N/A }
0N/A else {
230N/A g.setColor( c.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
0N/A MetalLookAndFeel.getControlDarkShadow() );
0N/A }
0N/A
0N/A g.drawLine( 1,0 , 13,0 ); // top
0N/A g.drawLine( 0,1 , 0,8 ); // left
0N/A g.drawLine( 14,1 , 14,8 ); // right
0N/A g.drawLine( 1,9 , 7,15 ); // left slant
0N/A g.drawLine( 7,15 , 14,8 ); // right slant
0N/A
0N/A // Fill in the background
230N/A if ( c.hasFocus() ) {
0N/A g.setColor( c.getForeground() );
0N/A }
0N/A else {
0N/A g.setColor( MetalLookAndFeel.getControl() );
0N/A }
0N/A g.fillRect( 1,1, 13, 8 );
0N/A
0N/A g.drawLine( 2,9 , 12,9 );
0N/A g.drawLine( 3,10 , 11,10 );
0N/A g.drawLine( 4,11 , 10,11 );
0N/A g.drawLine( 5,12 , 9,12 );
0N/A g.drawLine( 6,13 , 8,13 );
0N/A g.drawLine( 7,14 , 7,14 );
0N/A
0N/A // Draw the bumps
230N/A if ( c.isEnabled() ) {
230N/A if ( c.hasFocus() ) {
0N/A primaryBumps.paintIcon( c, g, 2, 2 );
0N/A }
0N/A else {
0N/A controlBumps.paintIcon( c, g, 2, 2 );
0N/A }
0N/A }
0N/A
0N/A // Draw the highlight
230N/A if ( c.isEnabled() ) {
230N/A g.setColor( c.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
0N/A : MetalLookAndFeel.getControlHighlight() );
0N/A g.drawLine( 1, 1, 13, 1 );
0N/A g.drawLine( 1, 1, 1, 8 );
0N/A }
0N/A
0N/A g.translate( -x, -y );
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 15;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 16;
0N/A }
0N/A}
0N/A
0N/A private static class OceanVerticalSliderThumbIcon extends CachedPainter
0N/A implements Icon, Serializable, UIResource {
0N/A // Used for clipping when the orientation is left to right
0N/A private static Polygon LTR_THUMB_SHAPE;
0N/A // Used for clipping when the orientation is right to left
0N/A private static Polygon RTL_THUMB_SHAPE;
0N/A
0N/A static {
0N/A LTR_THUMB_SHAPE = new Polygon(new int[] { 0, 8, 15, 8, 0},
0N/A new int[] { 0, 0, 7, 14, 14 }, 5);
0N/A RTL_THUMB_SHAPE = new Polygon(new int[] { 15, 15, 7, 0, 7},
0N/A new int[] { 0, 14, 14, 7, 0}, 5);
0N/A }
0N/A
0N/A OceanVerticalSliderThumbIcon() {
0N/A super(3);
0N/A }
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A if (!(g instanceof Graphics2D)) {
0N/A return;
0N/A }
0N/A paint(c, g, x, y, getIconWidth(), getIconHeight(),
0N/A MetalUtils.isLeftToRight(c), c.hasFocus(), c.isEnabled(),
0N/A MetalLookAndFeel.getCurrentTheme());
0N/A }
0N/A
0N/A protected void paintToImage(Component c, Image image, Graphics g2,
0N/A int w, int h, Object[] args) {
0N/A Graphics2D g = (Graphics2D)g2;
0N/A boolean leftToRight = ((Boolean)args[0]).booleanValue();
0N/A boolean hasFocus = ((Boolean)args[1]).booleanValue();
0N/A boolean enabled = ((Boolean)args[2]).booleanValue();
0N/A
0N/A Rectangle clip = g.getClipBounds();
0N/A if (leftToRight) {
0N/A g.clip(LTR_THUMB_SHAPE);
0N/A }
0N/A else {
0N/A g.clip(RTL_THUMB_SHAPE);
0N/A }
0N/A if (!enabled) {
0N/A g.setColor(MetalLookAndFeel.getControl());
0N/A g.fillRect(1, 1, 14, 14);
0N/A }
0N/A else if (hasFocus) {
0N/A MetalUtils.drawGradient(c, g, "Slider.focusGradient",
0N/A 1, 1, 14, 14, false);
0N/A }
0N/A else {
0N/A MetalUtils.drawGradient(c, g, "Slider.gradient",
0N/A 1, 1, 14, 14, false);
0N/A }
0N/A g.setClip(clip);
0N/A
0N/A // Draw the frame
0N/A if (hasFocus) {
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
0N/A }
0N/A else {
0N/A g.setColor(enabled ? MetalLookAndFeel.getPrimaryControlInfo() :
0N/A MetalLookAndFeel.getControlDarkShadow());
0N/A }
0N/A
0N/A if (leftToRight) {
0N/A g.drawLine( 1,0 , 8,0 ); // top
0N/A g.drawLine( 0,1 , 0,13 ); // left
0N/A g.drawLine( 1,14 , 8,14 ); // bottom
0N/A g.drawLine( 9,1 , 15,7 ); // top slant
0N/A g.drawLine( 9,13 , 15,7 ); // bottom slant
0N/A }
0N/A else {
0N/A g.drawLine( 7,0 , 14,0 ); // top
0N/A g.drawLine( 15,1 , 15,13 ); // right
0N/A g.drawLine( 7,14 , 14,14 ); // bottom
0N/A g.drawLine( 0,7 , 6,1 ); // top slant
0N/A g.drawLine( 0,7 , 6,13 ); // bottom slant
0N/A }
0N/A
0N/A if (hasFocus && enabled) {
0N/A // Inner line.
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A if (leftToRight) {
0N/A g.drawLine( 1,1 , 8,1 ); // top
0N/A g.drawLine( 1,1 , 1,13 ); // left
0N/A g.drawLine( 1,13 , 8,13 ); // bottom
0N/A g.drawLine( 9,2 , 14,7 ); // top slant
0N/A g.drawLine( 9,12 , 14,7 ); // bottom slant
0N/A }
0N/A else {
0N/A g.drawLine( 7,1 , 14,1 ); // top
0N/A g.drawLine( 14,1 , 14,13 ); // right
0N/A g.drawLine( 7,13 , 14,13 ); // bottom
0N/A g.drawLine( 1,7 , 7,1 ); // top slant
0N/A g.drawLine( 1,7 , 7,13 ); // bottom slant
0N/A }
0N/A }
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 16;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 15;
0N/A }
0N/A
0N/A protected Image createImage(Component c, int w, int h,
0N/A GraphicsConfiguration config,
0N/A Object[] args) {
0N/A if (config == null) {
0N/A return new BufferedImage(w, h,BufferedImage.TYPE_INT_ARGB);
0N/A }
0N/A return config.createCompatibleImage(
0N/A w, h, Transparency.BITMASK);
0N/A }
0N/A }
0N/A
0N/A
0N/A private static class OceanHorizontalSliderThumbIcon extends CachedPainter
0N/A implements Icon, Serializable, UIResource {
0N/A // Used for clipping
0N/A private static Polygon THUMB_SHAPE;
0N/A
0N/A static {
0N/A THUMB_SHAPE = new Polygon(new int[] { 0, 14, 14, 7, 0 },
0N/A new int[] { 0, 0, 8, 15, 8 }, 5);
0N/A }
0N/A
0N/A OceanHorizontalSliderThumbIcon() {
0N/A super(3);
0N/A }
0N/A
0N/A public void paintIcon(Component c, Graphics g, int x, int y) {
0N/A if (!(g instanceof Graphics2D)) {
0N/A return;
0N/A }
0N/A paint(c, g, x, y, getIconWidth(), getIconHeight(),
0N/A c.hasFocus(), c.isEnabled(),
0N/A MetalLookAndFeel.getCurrentTheme());
0N/A }
0N/A
0N/A
0N/A protected Image createImage(Component c, int w, int h,
0N/A GraphicsConfiguration config,
0N/A Object[] args) {
0N/A if (config == null) {
0N/A return new BufferedImage(w, h,BufferedImage.TYPE_INT_ARGB);
0N/A }
0N/A return config.createCompatibleImage(
0N/A w, h, Transparency.BITMASK);
0N/A }
0N/A
0N/A protected void paintToImage(Component c, Image image, Graphics g2,
0N/A int w, int h, Object[] args) {
0N/A Graphics2D g = (Graphics2D)g2;
0N/A boolean hasFocus = ((Boolean)args[0]).booleanValue();
0N/A boolean enabled = ((Boolean)args[1]).booleanValue();
0N/A
0N/A // Fill in the background
0N/A Rectangle clip = g.getClipBounds();
0N/A g.clip(THUMB_SHAPE);
0N/A if (!enabled) {
0N/A g.setColor(MetalLookAndFeel.getControl());
0N/A g.fillRect(1, 1, 13, 14);
0N/A }
0N/A else if (hasFocus) {
0N/A MetalUtils.drawGradient(c, g, "Slider.focusGradient",
0N/A 1, 1, 13, 14, true);
0N/A }
0N/A else {
0N/A MetalUtils.drawGradient(c, g, "Slider.gradient",
0N/A 1, 1, 13, 14, true);
0N/A }
0N/A g.setClip(clip);
0N/A
0N/A // Draw the frame
0N/A if (hasFocus) {
0N/A g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
0N/A }
0N/A else {
0N/A g.setColor(enabled ? MetalLookAndFeel.getPrimaryControlInfo() :
0N/A MetalLookAndFeel.getControlDarkShadow());
0N/A }
0N/A
0N/A g.drawLine( 1,0 , 13,0 ); // top
0N/A g.drawLine( 0,1 , 0,8 ); // left
0N/A g.drawLine( 14,1 , 14,8 ); // right
0N/A g.drawLine( 1,9 , 7,15 ); // left slant
0N/A g.drawLine( 7,15 , 14,8 ); // right slant
0N/A
0N/A if (hasFocus && enabled) {
0N/A // Inner line.
0N/A g.setColor(MetalLookAndFeel.getPrimaryControl());
0N/A g.fillRect(1, 1, 13, 1);
0N/A g.fillRect(1, 2, 1, 7);
0N/A g.fillRect(13, 2, 1, 7);
0N/A g.drawLine(2, 9, 7, 14);
0N/A g.drawLine(8, 13, 12, 9);
0N/A }
0N/A }
0N/A
0N/A public int getIconWidth() {
0N/A return 15;
0N/A }
0N/A
0N/A public int getIconHeight() {
0N/A return 16;
0N/A }
0N/A }
0N/A}