/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Factory object that vends <code>Icon</code>s for
* the Java<sup><font size="-2">TM</font></sup> look and feel (Metal).
* These icons are used extensively in Metal via the defaults mechanism.
* While other look and feels often use GIFs for icons, creating icons
* in code facilitates switching to other themes.
*
* <p>
* Each method in this class returns
* either an <code>Icon</code> or <code>null</code>,
* where <code>null</code> implies that there is no default icon.
*
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Michael C. Albers
*/
// List of code-drawn Icons
// Ocean icons
// Constants
public static final boolean DARK = false;
public static final boolean LIGHT = true;
// Accessor functions for Icons. Does the caching work.
if (fileChooserDetailViewIcon == null) {
}
return fileChooserDetailViewIcon;
}
if (fileChooserHomeFolderIcon == null) {
}
return fileChooserHomeFolderIcon;
}
if (fileChooserListViewIcon == null) {
}
return fileChooserListViewIcon;
}
if (fileChooserNewFolderIcon == null) {
}
return fileChooserNewFolderIcon;
}
if (fileChooserUpFolderIcon == null) {
}
return fileChooserUpFolderIcon;
}
return new InternalFrameAltMaximizeIcon(size);
}
return new InternalFrameCloseIcon(size);
}
if (internalFrameDefaultMenuIcon == null) {
}
return internalFrameDefaultMenuIcon;
}
return new InternalFrameMaximizeIcon(size);
}
return new InternalFrameMinimizeIcon(size);
}
if (radioButtonIcon == null) {
radioButtonIcon = new RadioButtonIcon();
}
return radioButtonIcon;
}
/**
* Returns a checkbox icon.
* @since 1.3
*/
if (checkBoxIcon == null) {
checkBoxIcon = new CheckBoxIcon();
}
return checkBoxIcon;
}
if ( treeComputerIcon == null ) {
treeComputerIcon = new TreeComputerIcon();
}
return treeComputerIcon;
}
if ( treeFloppyDriveIcon == null ) {
treeFloppyDriveIcon = new TreeFloppyDriveIcon();
}
return treeFloppyDriveIcon;
}
return new TreeFolderIcon();
}
if ( treeHardDriveIcon == null ) {
treeHardDriveIcon = new TreeHardDriveIcon();
}
return treeHardDriveIcon;
}
return new TreeLeafIcon();
}
return new TreeControlIcon( isCollapsed );
}
if (menuArrowIcon == null) {
menuArrowIcon = new MenuArrowIcon();
}
return menuArrowIcon;
}
/**
* Returns an icon to be used by <code>JCheckBoxMenuItem</code>.
*
* @return the default icon for check box menu items,
* or <code>null</code> if no default exists
*/
return null;
}
if (menuItemArrowIcon == null) {
menuItemArrowIcon = new MenuItemArrowIcon();
}
return menuItemArrowIcon;
}
if (checkBoxMenuItemIcon == null) {
checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
}
return checkBoxMenuItemIcon;
}
if (radioButtonMenuItemIcon == null) {
}
return radioButtonMenuItemIcon;
}
if (MetalLookAndFeel.usingOcean()) {
if (oceanHorizontalSliderThumb == null) {
}
return oceanHorizontalSliderThumb;
}
// don't cache these, bumps don't get updated otherwise
return new HorizontalSliderThumbIcon();
}
if (MetalLookAndFeel.usingOcean()) {
if (oceanVerticalSliderThumb == null) {
}
return oceanVerticalSliderThumb;
}
// don't cache these, bumps don't get updated otherwise
return new VerticalSliderThumbIcon();
}
// File Chooser Detail View code
g.translate(x, y);
// Draw outside edge of each of the documents
// top
// bottom
// Draw little dots next to documents
// Same color as outside edge
// Draw inner highlight on documents
// Draw inner inner highlight on documents
g.translate(-x, -y);
}
public int getIconWidth() {
return 18;
}
public int getIconHeight() {
return 18;
}
} // End class FileChooserDetailViewIcon
// File Chooser Home Folder code
g.translate(x, y);
// Draw outside edge of house
// Draw door frame
// same color as edge of house
// Draw roof body
// Draw doornob
// same color as roof body
// Paint the house
g.translate(-x, -y);
}
public int getIconWidth() {
return 18;
}
public int getIconHeight() {
return 18;
}
} // End class FileChooserHomeFolderIcon
// File Chooser List View code
g.translate(x, y);
// Draw outside edge of each of the documents
// top left
// top right
// bottom left
// bottom right
// Draw little dots next to documents
// Same color as outside edge
// Draw inner highlight on documents
// Draw inner inner highlight on documents
g.translate(-x, -y);
}
public int getIconWidth() {
return 18;
}
public int getIconHeight() {
return 18;
}
} // End class FileChooserListViewIcon
// File Chooser New Folder code
g.translate(x, y);
// Fill background
// Draw outside edge of folder
// Draw inner folder highlight
// Draw tab on folder
g.translate(-x, -y);
}
public int getIconWidth() {
return 18;
}
public int getIconHeight() {
return 18;
}
} // End class FileChooserNewFolderIcon
// File Chooser Up Folder code
g.translate(x, y);
// Fill background
// Draw outside edge of folder
// Draw the UP arrow
// same color as edge
// Draw inner folder highlight
// Draw tab on folder
g.translate(-x, -y);
}
public int getIconWidth() {
return 18;
}
public int getIconHeight() {
return 18;
}
} // End class FileChooserUpFolderIcon
/**
* Defines an icon for Palette close
* @since 1.3
*/
} else {
}
g.translate(x, y);
g.translate(-x, -y);
}
public int getIconWidth() {
return iconSize;
}
public int getIconHeight() {
return iconSize;
}
}
// Internal Frame Close code
}
// if the inactive window
{
// if inactive and pressed
}
}
// if pressed
// darkHighlightColor is still "getBlack()"
}
// Some calculations that are needed more than once later on.
g.translate(x, y);
// fill background
// fill inside of box area
// THE BOX
// draw the "normal" box
// THE "X"
// Dark highlight
// Light highlight
// one pixel over from the body
// bottom right
// Main color
// Upper left to lower right
// Lower left to upper right
g.translate(-x, -y);
}
public int getIconWidth() {
return iconSize;
}
public int getIconHeight() {
return iconSize;
}
} // End class InternalFrameCloseIcon
// Internal Frame Alternate Maximize code (actually, the un-maximize icon)
}
// ul = Upper Left and lr = Lower Right
// if the internal frame is inactive
{
// if inactive and pressed
}
}
// if the button is pressed and the mouse is over it
// darkHighlightColor is still "getBlack()"
}
g.translate(x, y);
// fill background
// BOX
// fill inside the box
// draw dark highlight color
// draw lower right light highlight
// draw upper left light highlight
// draw the main box
// Six extraneous pixels to deal with
// ARROW
// do the shaft first
// draw the dark highlight
// draw the light highlight
g.translate(-x, -y);
}
public int getIconWidth() {
return iconSize;
}
public int getIconHeight() {
return iconSize;
}
} // End class InternalFrameAltMaximizeIcon
// Code for the default icons that goes in the upper left corner
g.translate(x, y);
// draw background color for title area
// catch four corners and title area
g.setColor(titleColor);
// fill body of window
// draw light parts of two "bumps"
// draw line around edge of title and icon
// draw dark part of four "bumps" (same color)
g.translate(-x, -y);
}
public int getIconWidth() {
return 16;
}
public int getIconHeight() {
return 16;
}
} // End class InternalFrameDefaultMenuIcon
// Internal Frame Maximize code
}
// ul = Upper Left and lr = Lower Right
// if the internal frame is inactive
{
// if inactive and pressed
}
}
// if the button is pressed and the mouse is over it
// darkHighlightColor is still "getBlack()"
}
g.translate(x, y);
// fill background
// BOX drawing
// fill inside the box
// light highlight
// dark highlight
// main box
// ARROW drawing
// dark highlight
// down,left to up,right - inside box
// down,left to up,right - outside box
// outside edge of arrow head
// outside edge of arrow head
// light highlight
// down,left to up,right - inside box
// main part of arrow
g.translate(-x, -y);
}
public int getIconWidth() {
return iconSize;
}
public int getIconHeight() {
return iconSize;
}
} // End class InternalFrameMaximizeIcon
// Internal Frame Minimize code
}
// ul = Upper Left and lr = Lower Right
// if the internal frame is inactive
{
// if inactive and pressed
}
}
// if the button is pressed and the mouse is over it
// darkHighlightColor is still "getBlack()"
}
g.translate(x, y);
// fill background
// BOX drawing
// fill inside the box
// light highlight
// dark highlight
// main box
// ARROW
// do the shaft first
// draw the dark highlight
// draw the light highlight
g.translate(-x, -y);
}
public int getIconWidth() {
return iconSize;
}
public int getIconHeight() {
return iconSize;
}
} // End class InternalFrameMinimizeIcon
g.translate(x, y);
int w = getIconWidth();
int h = getIconHeight();
} else if (model.isRollover()) {
w, h, true);
}
else {
w, h, true);
}
} else {
}
g.translate(-x, -y);
if (model.isSelected()) {
drawCheck(c,g,x,y);
}
}
if (MetalLookAndFeel.usingOcean()) {
paintOceanIcon(c, g, x, y);
return;
}
int controlSize = getControlSize();
} else {
}
g.setColor(c.getForeground());
} else {
}
if (model.isSelected()) {
drawCheck(c,g,x,y);
}
}
int controlSize = getControlSize();
}
public int getIconWidth() {
return getControlSize();
}
public int getIconHeight() {
return getControlSize();
}
} // End class CheckBoxIcon
// Radio button code
g.translate(x, y);
// PENDING: this isn't quite right, when we're sure it won't
// change it needs to be cleaned.
1, 1, 10, 10, true);
g.setColor(c.getBackground());
}
if (pressed) {
}
else {
}
}
// draw Dark Circle (start at top, go clockwise)
if (!enabled) {
}
else {
}
if (pressed) {
}
else if (rollover) {
}
// selected dot
if (model.isSelected()) {
if (enabled) {
} else {
}
}
g.translate(-x, -y);
}
if (MetalLookAndFeel.usingOcean()) {
paintOceanIcon(c, g, x, y);
return;
}
// Set up colors per RadioButtonModel condition
}
}
g.translate(x, y);
// fill interior
// draw Dark Circle (start at top, go clockwise)
g.setColor(darkCircle);
// draw Inner Left (usually) White Arc
// start at lower left corner, go clockwise
// draw Outer Right White Arc
// start at upper right corner, go clockwise
// selected dot
if ( drawDot ) {
}
g.translate(-x, -y);
}
public int getIconWidth() {
return 13;
}
public int getIconHeight() {
return 13;
}
} // End class RadioButtonIcon
// Tree Computer Icon code
g.translate(x, y);
// Fill glass portion of monitor
// Draw outside edge of monitor
// Draw the edge of the glass
// Draw the edge of the CPU
// Draw the disk drives
g.translate(-x, -y);
}
public int getIconWidth() {
return 16;
}
public int getIconHeight() {
return 16;
}
} // End class TreeComputerIcon
// Tree HardDrive Icon code
g.translate(x, y);
// Draw edges of the disks
// top disk
// middle disk
// bottom disk
// Draw the down right shadows
// top disk
// middle disk
// bottom disk
// Draw the up left highlight
// top disk
// middle disk
// bottom disk
g.translate(-x, -y);
}
public int getIconWidth() {
return 16;
}
public int getIconHeight() {
return 16;
}
} // End class TreeHardDriveIcon
// Tree FloppyDrive Icon code
g.translate(x, y);
// Fill body of floppy
// Draw outside edge of floppy
// Draw grey-ish highlights
// Draw label and exposed disk
// Draw text on label
g.translate(-x, -y);
}
public int getIconWidth() {
return 16;
}
public int getIconHeight() {
return 16;
}
} // End class TreeFloppyDriveIcon
/**
* Utility class for caching icon images. This is necessary because
* we need a new image whenever we are rendering into a new
* GraphicsConfiguration, but we do not want to keep recreating icon
* images for GC's that we have already seen (for example,
* dragging a window back and forth between monitors on a multimon
* system, or drawing an icon to different Components that have different
* GC's).
* So now whenever we create a new icon image for a given GC, we
* cache that image with the GC for later retrieval.
*/
static class ImageCacher {
// PENDING: Replace this class with CachedPainter.
class ImageGcPair {
}
}
}
if ((currentImageGcPair == null) ||
{
}
}
return null;
}
return currentImageGcPair.image;
}
}
}
/**
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*/
if (imageCacher == null) {
imageCacher = new ImageCacher();
}
} else {
}
}
}
// Draw tab top
// Draw folder front
// Draw tab bottom
// Draw outline
// Draw highlight
}
}
/**
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*/
}
/**
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*/
if (imageCacher == null) {
imageCacher = new ImageCacher();
}
} else {
}
}
}
// Draw fill
// Draw frame
// Draw highlight
}
}
}
/**
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*/
// This data member should not have been exposed. It's called
// isLight, but now it really means isCollapsed. Since we can't change
// any APIs... that's life.
protected boolean isLight;
}
transient boolean cachedOrientation = true;
if (imageCacher == null) {
imageCacher = new ImageCacher();
}
} else {
}
}
if (MetalUtils.isLeftToRight(c)) {
if (isLight) { // isCollapsed
}
else {
}
}
else {
if (isLight) { // isCollapsed
}
else {
}
}
}
// Draw circle
// Draw Center Dot
// Draw Handle
if ( isLight ) { // isCollapsed
if( MetalUtils.isLeftToRight(c) ) {
// g.setColor( c.getBackground() );
// g.drawLine( 16, 7, 16, 8 );
}
else {
}
}
else {
// g.setColor( c.getBackground() );
// g.drawLine( xoff + 7, 16, xoff + 8, 16 );
}
// Draw Fill
}
}
//
// Menu Icons
//
{
{
g.translate( x, y );
{
}
else
{
{
}
else
{
g.setColor( b.getForeground() );
}
}
if( MetalUtils.isLeftToRight(b) ) {
} else {
}
g.translate( -x, -y );
}
} // End class MenuArrowIcon
{
{
}
} // End class MenuItemArrowIcon
{
g.translate(x, y);
if (isEnabled) {
1, 1, 7, 7, true);
}
else {
}
}
else {
}
if (isSelected) {
if (isEnabled) {
g.setColor(
}
else {
}
}
else {
}
}
g.translate( -x, -y );
}
{
if (MetalLookAndFeel.usingOcean()) {
paintOceanIcon(c, g, x, y);
return;
}
g.translate( x, y );
if ( isEnabled )
{
{
}
else
{
}
}
else
{
}
if ( isSelected )
{
if ( isEnabled )
{
{
}
else
{
g.setColor( b.getForeground() );
}
}
else
{
}
}
g.translate( -x, -y );
}
} // End class CheckBoxMenuItemIcon
{
g.translate( x, y );
if (isEnabled) {
1, 1, 7, 7, true);
}
else {
}
}
else {
}
}
else {
}
if (isSelected) {
if (isEnabled) {
}
else {
}
}
else {
}
}
g.translate( -x, -y );
}
{
if (MetalLookAndFeel.usingOcean()) {
paintOceanIcon(c, g, x, y);
return;
}
g.translate( x, y );
if ( isEnabled )
{
{
}
else
{
}
}
else
{
}
if ( isSelected )
{
if ( isEnabled )
{
{
}
else
{
g.setColor( b.getForeground() );
}
}
else
{
}
}
g.translate( -x, -y );
}
} // End class RadioButtonMenuItemIcon
public VerticalSliderThumbIcon() {
}
g.translate( x, y );
// Draw the frame
if ( c.hasFocus() ) {
}
else {
}
if (leftToRight) {
}
else {
}
// Fill in the background
if ( c.hasFocus() ) {
g.setColor( c.getForeground() );
}
else {
}
if (leftToRight) {
}
else {
}
// Draw the bumps
if ( c.isEnabled() ) {
if ( c.hasFocus() ) {
}
else {
}
}
// Draw the highlight
if ( c.isEnabled() ) {
if (leftToRight) {
}
else {
}
}
g.translate( -x, -y );
}
public int getIconWidth() {
return 16;
}
public int getIconHeight() {
return 15;
}
}
public HorizontalSliderThumbIcon() {
}
g.translate( x, y );
// Draw the frame
if ( c.hasFocus() ) {
}
else {
}
// Fill in the background
if ( c.hasFocus() ) {
g.setColor( c.getForeground() );
}
else {
}
// Draw the bumps
if ( c.isEnabled() ) {
if ( c.hasFocus() ) {
}
else {
}
}
// Draw the highlight
if ( c.isEnabled() ) {
}
g.translate( -x, -y );
}
public int getIconWidth() {
return 15;
}
public int getIconHeight() {
return 16;
}
}
// Used for clipping when the orientation is left to right
// Used for clipping when the orientation is right to left
static {
new int[] { 0, 0, 7, 14, 14 }, 5);
new int[] { 0, 14, 14, 7, 0}, 5);
}
super(3);
}
if (!(g instanceof Graphics2D)) {
return;
}
}
if (leftToRight) {
g.clip(LTR_THUMB_SHAPE);
}
else {
g.clip(RTL_THUMB_SHAPE);
}
if (!enabled) {
}
else if (hasFocus) {
1, 1, 14, 14, false);
}
else {
1, 1, 14, 14, false);
}
// Draw the frame
if (hasFocus) {
}
else {
}
if (leftToRight) {
}
else {
}
// Inner line.
if (leftToRight) {
}
else {
}
}
}
public int getIconWidth() {
return 16;
}
public int getIconHeight() {
return 15;
}
}
return config.createCompatibleImage(
w, h, Transparency.BITMASK);
}
}
// Used for clipping
static {
new int[] { 0, 0, 8, 15, 8 }, 5);
}
super(3);
}
if (!(g instanceof Graphics2D)) {
return;
}
}
}
return config.createCompatibleImage(
w, h, Transparency.BITMASK);
}
// Fill in the background
g.clip(THUMB_SHAPE);
if (!enabled) {
}
else if (hasFocus) {
1, 1, 13, 14, true);
}
else {
1, 1, 13, 14, true);
}
// Draw the frame
if (hasFocus) {
}
else {
}
// Inner line.
}
}
public int getIconWidth() {
return 15;
}
public int getIconHeight() {
return 16;
}
}
}