Developer Documentation
PATH  Mac OS X Documentation > Application Kit Reference: Java

Table of Contents

NSColor


Inherits from:
NSObject
Package:
com.apple.yellow.application

Class at a Glance


An NSColor object represents a color, which is defined in a color space, each point of which has a set of components (such as red, green, and blue) that uniquely define a color.

Principal Attributes


Creation



Various colorWith... and colorUsing... methods.
Preset colors: blackColor, blueColor, etc.

Commonly Used Methods



colorUsingColorSpaceName Creates an NSColor in the specified color space.
set Sets the drawing color.


Class Description


An NSColor object represents color and sometimes opacity (alpha). By sending a set message to an NSColor instance, you set the color for the current drawing context. This causes subsequently drawn graphics to have the color represented by the NSColor instance.


Color Spaces


A color is defined in some particular color space. A color space consists of a set of dimensions-such as red, green, and blue in the case of RGB space. Each point in the space represents a unique color, and the point's location along each dimension is called a component. An individual color is usually specified by the numeric values of its components, which range from 0.0 to 1.0. For instance, a pure red is specified in RGB space by the component values 1.0, 0.0, and 0.0.

Some color spaces include an alpha component, which defines the color's opacity. An alpha value of 1.0 means completely opaque, and 0.0 means completely transparent. The alpha component is ignored when the color is used on a device that doesn't support alpha, such as a printer.

There are three kinds of color spaces in the Application Kit:

NSColors provided by the Application Kit use eight different color spaces, referred to by these global String variables:


Global Variable Color Space Description
NSGraphics.DeviceCMYKColorSpace Cyan, magenta, yellow, black, and alpha components
NSGraphics.DeviceWhiteColorSpace White and alpha components
NSGraphics.DeviceRGBColorSpace Red, green, blue, and alpha componentsHue, saturation, brightness, and alpha components
NSGraphics.CalibratedWhiteColorSpace White and alpha components
NSGraphics.CalibratedRGBColorSpace Red, green, blue, and alpha componentsHue, saturation, brightness, and alpha components
NSGraphics.NamedColorSpace Catalog name and color name components

Color spaces whose names start with "Device" are device-dependent; those whose names start with "Calibrated" are device-independent.


Color Components


There's usually no need to retrieve the individual components of a color, but when needed, you can (using such methods as redComponent). However, it's illegal to ask an NSColor for components that aren't defined for its color space. You can identify the color space by sending a colorSpaceName message to the NSColor object. If you need to ask an NSColor for components that aren't in its color space (for instance, when you've gotten the color from the color panel), first convert the color to the appropriate color space using the colorUsingColorSpaceName method. If the color is already in the specified color space, you get the same color back; otherwise you get a conversion that's usually lossy or that's correct only for the current device. You get back null if the specified conversion can't be done.


Creating Subclasses


Subclasses of NSColor need to implement the colorSpaceName and set methods, as well as the methods that return the components for that color space. Some other methods-such as colorWithAlphaComponent and colorUsingColorSpaceNameAndDevice-may also be implemented if they make sense for the color space.


System Colors


NSColor has a number of methods which return "system" colors; colors that are controlled by user preferences. These colors-including controlColor, textColor, and selectedTextColor-should be used by developers who want to create custom controls or subclass existing controls while honoring the user's color preferences. System colors are implemented as named colors in a special color list named "System." To extract the components of a system color, you must use NSColor's colorUsingColorSpaceName method to convert the color to a color space known to respond to the component accessor methods you need.

A SystemColorsDidChangeNotification is sent when the system colors have been changed (such as through a system control panel interface). If you have any non-system colors that depend on the system colors, you can change them when you receive this notification.




Method Types


Constructors
NSColor
Creating an NSColor object from Component Values
colorWithCalibratedHSB
colorWithCalibratedRGB
colorWithCalibratedWhite
colorWithCatalogName
colorWithDeviceCMYK
colorWithDeviceHSB
colorWithDeviceRGB
colorWithDeviceWhite
Creating an NSColor With Preset Components
blackColor
blueColor
brownColor
clearColor
cyanColor
darkGrayColor
grayColor
greenColor
lightGrayColor
magentaColor
orangeColor
purpleColor
redColor
whiteColor
yellowColor
Creating a system color-an NSColor whose value is specified by user preferences
controlBackgroundColor
controlColor
controlHighlightColor
controlLightHighlightColor
controlShadowColor
controlDarkShadowColor
controlTextColor
disabledControlTextColor
gridColor
highlightColor
knobColor
scrollBarColor
selectedControlColor
selectedControlTextColor
selectedMenuItemColor
selectedMenuItemTextColor
selectedTextBackgroundColor
selectedTextColor
selectedKnobColor
shadowColor
textBackgroundColor
textColor
windowFrameColor
windowFrameTextColor
Ignoring Alpha Components
ignoresAlpha
setIgnoresAlpha
Copying and Pasting
colorFromPasteboard
writeToPasteboard
Retrieving Individual Components
alphaComponent
blackComponent
blueComponent
brightnessComponent
catalogNameComponent
colorNameComponent
cyanComponent
greenComponent
hueComponent
localizedCatalogNameComponent
localizedColorNameComponent
magentaComponent
redComponent
saturationComponent
whiteComponent
yellowComponent
Converting to Another Color Space
colorSpaceName
colorUsingColorSpaceName
colorUsingColorSpaceNameAndDevice
Changing the Color
blendedColorWithFractionOfColor
colorWithAlphaComponent
highlightWithLevel
shadowWithLevel
Drawing
drawSwatchInRect
set


Constructors



NSColor

public NSColor()

Description forthcoming.


Static Methods



blackColor

public static NSColor blackColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose grayscale value is 0.0 and whose alpha value is 1.0.

See Also: blackComponent



blueColor

public static NSColor blueColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 0.0, 0.0, 1.0 and whose alpha value is 1.0.

See Also: blueComponent



brownColor

public static NSColor brownColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 0.6, 0.4, 0.2 and whose alpha value is 1.0.

clearColor

public static NSColor clearColor()

Returns an NSColor in NSGraphics.CalibratedWhiteColorSpace whose grayscale and alpha values are both 0.0.

colorFromPasteboard

public static NSColor colorFromPasteboard(NSPasteboard pasteBoard)

Returns the NSColor currently on the pasteboard, or null if the pasteboard doesn't contain color data. The returned color's alpha component is set to 1.0 if ignoresAlpha returns true.

See Also: writeToPasteboard



colorWithCalibratedHSB

public static NSColor colorWithCalibratedHSB( float hue, float saturation, float brightness, float alpha)

Creates and returns an NSColor whose color space is NSGraphics.CalibratedRGBColorSpace, whose opacity value is alpha, and whose components in HSB space would be hue, saturation, and brightness. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.)

See Also: colorWithCalibratedRGB, colorWithDeviceHSB, getHue:saturation:brightness:alpha:



colorWithCalibratedRGB

public static NSColor colorWithCalibratedRGB( float red, float green, float blue, float alpha)

Creates and returns an NSColor whose color space is NSGraphics.CalibratedRGBColorSpace, whose opacity value is alpha, and whose RGB components are red, green, and blue. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.)

See Also: colorWithCalibratedHSB, colorWithDeviceRGB, getRed:green:blue:alpha:



colorWithCalibratedWhite

public static NSColor colorWithCalibratedWhite( float white, float alpha)

Creates and returns an NSColor whose color space is NSGraphics.CalibratedWhiteColorSpace, whose opacity value is alpha, and whose grayscale value is white. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.)

See Also: colorWithDeviceWhite, getWhite:alpha:



colorWithCatalogName

public static NSColor colorWithCatalogName( String listName, String colorName)

Creates and returns an NSColor whose color space is NSGraphics.NamedColorSpace, by finding the color named colorName in the catalog named listName, which may be a standard catalog.

See Also: catalogNameComponent, colorNameComponent, localizedCatalogNameComponent



colorWithDeviceCMYK

public static NSColor colorWithDeviceCMYK( float cyan, float magenta, float yellow, float black, float alpha)

Creates and returns an NSColor whose color space is NSGraphics.DeviceCMYKColorSpace, whose opacity value is alpha, and whose CMYK components are cyan, magenta, yellow, and black. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.) In PostScript, this colorspace corresponds directly to the device-dependent operator setcmykcolor.

See Also: getCyan:magenta:yellow:black:alpha:



colorWithDeviceHSB

public static NSColor colorWithDeviceHSB( float hue, float saturation, float brightness, float alpha)

Creates and returns an NSColor whose color space is NSGraphics.DeviceRGBColorSpace, whose opacity value is alpha, and whose components in HSB space would be hue, saturation, and brightness. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.) In PostScript, this colorspace corresponds directly to the device-dependent operator setrgbcolor.

See Also: colorWithCalibratedHSB, colorWithDeviceRGB, getHue:saturation:brightness:alpha:



colorWithDeviceRGB

public static NSColor colorWithDeviceRGB( float red, float green, float blue, float alpha)

Creates and returns an NSColor whose color space is NSGraphics.DeviceRGBColorSpace, whose opacity value is alpha, and whose RGB components are red, green, and blue. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.) In PostScript, this colorspace corresponds directly to the device-dependent operator setrgbcolor.

See Also: colorWithCalibratedRGB, colorWithDeviceHSB, getRed:green:blue:alpha:



colorWithDeviceWhite

public static NSColor colorWithDeviceWhite( float white, float alpha)

Creates and returns an NSColor whose color space is NSGraphics.DeviceWhiteColorSpace, whose opacity value is alpha, and whose grayscale value is white. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.) In PostScript, this colorspace corresponds directly to the device-dependent operator setgray.

See Also: colorWithCalibratedWhite, getWhite:alpha:



controlBackgroundColor

public static NSColor controlBackgroundColor()

Returns the system color used for the background of large controls such as browsers, table views and clip views. By default, this color is light gray. For general information on system colors, see "System Colors" .

controlColor

public static NSColor controlColor()

Returns the system color used for the flat surfaces of a control. By default, the control color is light gray. A control's beveled edges, which set it in relief, are drawn in the colors returned by controlShadowColor, controlDarkShadowColor, controlHighlightColor and controlLightHighlightColor. When a control is selected-that is, clicked or dragged-it changes to the color returned by selectedControlColor.

The return value of controlColor is also the system color used for window backgrounds. For general information about system colors, see "System Colors" .



controlDarkShadowColor

public static NSColor controlDarkShadowColor()

Returns the system color used for the dark edge of the shadow dropped from controls. Controls are displayed as though they were lit from the upper left. Two dark borders, representing shadows, run along the bottom and right. controlDarkShadowColor returns the color of the outer, darker border. By default, this color is black. For general information about system colors, see "System Colors" .

See Also: controlShadowColor



controlHighlightColor

public static NSColor controlHighlightColor()

Returns the system color used for the highlighted bezels of controls. Controls are displayed as though they were lit from the upper left. Two light borders, representing reflections from the light source, run along the top and left. controlHighlightColor returns the color of the inner, duller border. By default, this color is light gray. For general information about system colors, see "System Colors" .

See Also: controlLightHighlightColor



controlLightHighlightColor

public static NSColor controlLightHighlightColor()

Returns the system color used for light highlights in controls. Controls are displayed as though they were lit from the upper left. Two light borders, representing reflections from the light source, run along the top and left. controlLightHighlightColor returns the color of the outer, brighter border. By default, this color is white. For general information about system colors, see "System Colors" .

See Also: controlHighlightColor



controlShadowColor

public static NSColor controlShadowColor()

Returns the system color used for the shadows dropped from controls. Controls are displayed as though they were lit from the upper left. Two dark borders, representing shadows, run along the bottom and right. controlShadowColor returns the color of the inner, lighter border. By default, this color is dark gray. For general information about system colors, see "System Colors" .

See Also: controlDarkShadowColor



controlTextColor

public static NSColor controlTextColor()

Returns the system color used for text on controls that aren't disabled. By default, the text color is black. For general information about system colors, see "System Colors" .

See Also: disabledControlTextColor



cyanColor

public static NSColor cyanColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 0.0, 1.0, 1.0 and whose alpha value is 1.0.

See Also: cyanComponent



darkGrayColor

public static NSColor darkGrayColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose grayscale value is 1/3 and whose alpha value is 1.0.

See Also: lightGrayColor, grayColor



disabledControlTextColor

public static NSColor disabledControlTextColor()

Returns the system color used for text on disabled controls. By default, the text color is dark gray. For general information about system colors, see "System Colors" .

See Also: controlTextColor



grayColor

public static NSColor grayColor()

Returns an NSColor in NSGraphics.CalibratedWhiteColorSpace whose grayscale value is 0.5 and whose alpha value is 1.0.

See Also: lightGrayColor, darkGrayColor



greenColor

public static NSColor greenColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 0.0, 1.0, 0.0 and whose alpha value is 1.0.

See Also: greenComponent



gridColor

public static NSColor gridColor()

Returns the system color used for the optional gridlines in, for example, a table view. By default, this color is gray. For general information about system colors, see "System Colors" .

highlightColor

public static NSColor highlightColor()

Returns the system color that represents the virtual light source on the screen. By default, this color is white. This method is invoked by the highlightWithLevel method. For general information about system colors, see "System Colors" .

See Also: highlightWithLevel



ignoresAlpha

public static boolean ignoresAlpha()

Returns true if the application doesn't support alpha. This value is consulted when an application imports alpha (through color dragging, for instance). The value determines whether the color panel has an opacity slider. This value is true by default, indicating that the opacity components of imported colors will be set to 1.0. If an application wants alpha, it can invoke the setIgnoresAlpha method with a parameter of false.

See Also: setIgnoresAlpha, alphaComponent



keyboardFocusIndicatorColor

public static NSColor keyboardFocusIndicatorColor()

Description forthcoming.

knobColor

public static NSColor knobColor()

Returns the system color used for the flat surface of a slider knob that hasn't been selected. By default, this color is light blue. The knob's beveled edges, which set it in relief, are drawn in highlighted and shadowed versions of the face color. When a knob is selected, its color changes to selectedKnobColor. For general information about system colors, see "System Colors" .

lightGrayColor

public static NSColor lightGrayColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose grayscale value is 2/3 and whose alpha value is 1.0.

See Also: grayColor, darkGrayColor



magentaColor

public static NSColor magentaColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 1.0, 0.0, 1.0 and whose alpha value is 1.0.

See Also: magentaComponent



orangeColor

public static NSColor orangeColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 1.0, 0.5, 0.0 and whose alpha value is 1.0.

purpleColor

public static NSColor purpleColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 0.5, 0.0, 0.5 and whose alpha value is 1.0.

redColor

public static NSColor redColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 1.0, 0.0, 0.0 and whose alpha value is 1.0.

See Also: redComponent



scrollBarColor

public static NSColor scrollBarColor()

Returns the system color used for scroll "bars"-that is, for the groove in which a scroller's knob moves. By default, this color is gray. For general information about system colors, see "System Colors" .

selectedControlColor

public static NSColor selectedControlColor()

Returns the system color used for the face of a selected control-a control being clicked or dragged. By default, this color is white. For general information about system colors, see "System Colors" .

See Also: selectedControlTextColor



selectedControlTextColor

public static NSColor selectedControlTextColor()

Returns the system color used for text in a selected control-a control being clicked or dragged. By default, this color is black. For general information about system colors, see "System Colors" .

See Also: selectedControlColor



selectedKnobColor

public static NSColor selectedKnobColor()

Returns the system color used for the slider knob when it is selected-that is, dragged. By default, this color is light blue. For general information about system colors, see "System Colors" .

See Also: knobColor



selectedMenuItemColor

public static NSColor selectedMenuItemColor()

Returns the system color used for the face of selected menu items. By default, this color is white. For general information about system colors, see "System Colors" .

See Also: selectedMenuItemTextColor



selectedMenuItemTextColor

public static NSColor selectedMenuItemTextColor()

Returns the system color used for the text in menu items. By default, this color is black. For general information about system colors, see "System Colors" .

See Also: selectedMenuItemColor



selectedTextBackgroundColor

public static NSColor selectedTextBackgroundColor()

Returns the system color used for the background of selected text. By default, this color is light gray. For general information about system colors, see "System Colors" .

See Also: selectedTextColor



selectedTextColor

public static NSColor selectedTextColor()

Returns the system color used for selected text. By default, this color is black. For general information about system colors, see "System Colors" .

See Also: selectedTextBackgroundColor



setIgnoresAlpha

public static void setIgnoresAlpha(boolean flag)

If flag is true, the application won't support alpha. In this case, no opacity slider is displayed in the color panel, and colors dragged in or pasted have their alpha values set to 1.0. By default, applications ignore alpha. Applications that need to import alpha can invoke this method with flag set to false and explicitly make colors opaque in cases where it matters to them.

See Also: ignoresAlpha, alphaComponent



shadowColor

public static NSColor shadowColor()

Returns the system color that represents the virtual shadows cast by raised objects on the screen. This method is invoked by shadowWithLevel. By default, the color it returns is black. For general information about system colors, see "System Colors" .

See Also: shadowWithLevel



textBackgroundColor

public static NSColor textBackgroundColor()

Returns the system color used for the text background. By default, this color is white. When text is selected, its background color changes to the return value of selectedTextBackgroundColor. For general information about system colors, see "System Colors" .

See Also: textColor



textColor

public static NSColor textColor()

Returns the system color used for text. By default, this color is black. When text is selected, its background color changes to the return value of selectedTextColor. For general information about system colors, see "System Colors" .

See Also: textBackgroundColor



whiteColor

public static NSColor whiteColor()

Returns an NSColor in NSGraphics.CalibratedWhiteColorSpace whose grayscale and alpha values are both 1.0.

See Also: whiteComponent



windowFrameColor

public static NSColor windowFrameColor()

Returns the system color used for window frames, except for their text. By default, this color is gray. For general information about system colors, see "System Colors" .

See Also: windowFrameTextColor



windowFrameTextColor

public static NSColor windowFrameTextColor()

Returns the system color used for the text in window frames. By default, this color is black. For general information about system colors, see "System Colors" .

See Also: windowFrameColor



yellowColor

public static NSColor yellowColor()

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose RGB value is 1.0, 1.0, 0.0 and whose alpha value is 1.0.

See Also: yellowComponent




Instance Methods



alphaComponent

public float alphaComponent()

Returns the receiver's alpha (opacity) component. Returns 1.0 (opaque) if the receiver has no alpha component.

See Also: getCyan:magenta:yellow:black:alpha:, getHue:saturation:brightness:alpha:, getRed:green:blue:alpha:, getWhite:alpha:



blackComponent

public float blackComponent()

Returns the receiver's black component. Throws an exception if the receiver isn't a CMYK color.

See Also: getCyan:magenta:yellow:black:alpha:



blendedColorWithFractionOfColor

public NSColor blendedColorWithFractionOfColor( float fraction, NSColor color)

Creates and returns an NSColor in NSGraphics.CalibratedRGBColorSpace whose component values are a weighted sum of the receiver's and color's. The method converts color and a copy of the receiver to RGB, and then sets each component of the returned color to fraction of color's value plus 1 - fraction of the receiver's. Returns null if the colors can't be converted to NSGraphics.CalibratedRGBColorSpace.

blueComponent

public float blueComponent()

Returns the receiver's blue component. Throws an exception if the receiver isn't an RGB color.

See Also: getRed:green:blue:alpha:



brightnessComponent

public float brightnessComponent()

Returns the brightness component of the HSB color equivalent to the receiver. Throws an exception if the receiver isn't an RGB color.

See Also: getHue:saturation:brightness:alpha:



catalogNameComponent

public String catalogNameComponent()

Returns the name of the catalog containing the receiver's name. Throws an exception if the receiver's color space isn't NSGraphics.NamedColorSpace.

See Also: colorWithCatalogName, colorNameComponent, localizedCatalogNameComponent



colorNameComponent

public String colorNameComponent()

Returns the receiver's name. Throws an exception if the receiver's color space isn't NSGraphics.NamedColorSpace.

See Also: colorWithCatalogName, catalogNameComponent, localizedCatalogNameComponent



colorSpaceName

public String colorSpaceName()

Returns the name of the receiver's color space. This method should be implemented in subclasses of NSColor.

See Also: colorUsingColorSpaceName, colorUsingColorSpaceNameAndDevice



colorUsingColorSpaceName

public NSColor colorUsingColorSpaceName(String colorSpace)

Creates and returns an NSColor whose color is the same as the receiver's, except that the new NSColor is in the color space named colorSpace. If colorSpace is null, the most appropriate color space is used.

Returns null if the specified conversion cannot be done.

See Also: colorSpaceName



colorUsingColorSpaceNameAndDevice

public NSColor colorUsingColorSpaceNameAndDevice( String colorSpace, NSDictionary deviceDescription)

Creates and returns an NSColor whose color is the same as the receiver's, except that the new NSColor is in the color space named colorSpace and is specific to the device described by deviceDescription. Device descriptions can be obtained from windows, screens, and printers with the deviceDescription method. If colorSpace is null, the most appropriate color space is used.

If deviceDescription is null, the current device (as obtained from the currently lockFocus'ed view's window or, if printing, the current printer) is used.

Returns null if the specified conversion cannot be done.

See Also: colorSpaceName, colorUsingColorSpaceName



colorWithAlphaComponent

public NSColor colorWithAlphaComponent(float alpha)

Creates and returns an NSColor that has the same color space and component values as the receiver, except its alpha component is alpha. If the receiver's color space doesn't include an alpha component, the receiver is returned. A subclass with explicit opacity components should override this method to return a color with the specified alpha.

See Also: alphaComponent, blendedColorWithFractionOfColor



cyanComponent

public float cyanComponent()

Returns the receiver's cyan component. Throws an exception if the receiver isn't a CMYK color.

See Also: getCyan:magenta:yellow:black:alpha:



drawSwatchInRect

public void drawSwatchInRect(NSRect rect)

Draws the current color in the rectangle rect. Subclasses adorn the rectangle in some manner to indicate the type of color. This method is invoked by color wells, swatches, and other user-interface objects that need to display colors.

greenComponent

public float greenComponent()

Returns the receiver's green component. Throws an exception if the receiver isn't an RGB color.

See Also: getRed:green:blue:alpha:



highlightWithLevel

public NSColor highlightWithLevel(float highlightLevel)

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace that represents a blend between the receiver and the highlight color returned by highlightColor. The highlight color's contribution to the blend depends on highlightLevel, which should be a number between 0.0 and 1.0. (A highlightLevel below 0.0 is interpreted as 0.0 (the receiver); a highlightLevel above 1.0 is interpreted as 1.0 (highlightLevel).)

Returns null if the colors can't be converted to NSGraphics.CalibratedRGBColorSpace. Invoke this method when you want to brighten the receiving NSColor for use in highlights.

See Also: shadowWithLevel



hueComponent

public float hueComponent()

Returns the hue component of the HSB color equivalent to the receiver. Throws an exception if the receiver isn't an RGB color.

See Also: getHue:saturation:brightness:alpha:



localizedCatalogNameComponent

public String localizedCatalogNameComponent()

Like catalogNameComponent, but returns a localized string. This string may be displayed in user-interface items like color pickers.

See Also: colorWithCatalogName, colorNameComponent



localizedColorNameComponent

public String localizedColorNameComponent()

Like colorNameComponent, but returns a localized string. This string may be displayed in user-interface items like color pickers.

See Also: colorWithCatalogName, catalogNameComponent, colorNameComponent, localizedCatalogNameComponent



magentaComponent

public float magentaComponent()

Returns the receiver's magenta component. Throws an exception if the receiver isn't a CMYK color.

See Also: getCyan:magenta:yellow:black:alpha:



redComponent

public float redComponent()

Returns the receiver's red component. Throws an exception if the receiver isn't an RGB color.

See Also: getRed:green:blue:alpha:



saturationComponent

public float saturationComponent()

Returns the saturation component of the HSB color equivalent to the receiver. Throws an exception if the receiver isn't an RGB color.

See Also: getHue:saturation:brightness:alpha:



set

public void set()

Sets the color of subsequent drawing to the color that the receiver represents. If the application is drawing to the screen rather than printing, this method also sets the current drawing context's alpha value to the value returned by alphaComponent; if the color doesn't know about alpha, it's set to 1.0. This method should be implemented in subclasses.

shadowWithLevel

public NSColor shadowWithLevel(float shadowLevel)

Returns an NSColor in NSGraphics.CalibratedRGBColorSpace that represents a blend between the receiver and the shadow color returned by shadowColor. The shadow color's contribution to the blend depends on shadowLevel, which should be a number between 0.0 and 1.0. (A shadowLevel below 0.0 is interpreted as 0.0 (the receiver); a shadowLevel above 1.0 is interpreted as 1.0 (shadowLevel).)

Returns null if the colors can't be converted to NSGraphics.CalibratedRGBColorSpace. Invoke this method when you want to darken the receiving NSColor for use in shadows.

See Also: highlightWithLevel



whiteComponent

public float whiteComponent()

Returns the receiver's white component. Throws an exception if the receiver isn't a grayscale color.

See Also: getWhite:alpha:



writeToPasteboard

public void writeToPasteboard(NSPasteboard pasteBoard)

Writes the receiver's data to the pasteboard, unless the pasteboard doesn't support color data (in which case the method does nothing).

See Also: colorFromPasteboard



yellowComponent

public float yellowComponent()

Returns the receiver's yellow component. Throws an exception if the receiver isn't a CMYK color.

See Also: getCyan:magenta:yellow:black:alpha:




Notifications


SystemColorsDidChangeNotification

Sent when the system colors have been changed (such as through a system control panel interface).

This notification contains no notification object and no userInfo dictionary.



Table of Contents