Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Implements | |
Package | com.apple.cocoa.application |
Companion guide |
An NSColorList is an ordered list of NSColors, identified by keys. Instances of NSColorList, or more simply color lists, are used to manage named lists of NSColors. NSColorPanel’s list mode color picker uses instances of NSColorList to represent any lists of colors that come with the system, as well as any lists created by the user. An application can use NSColorList to manage document-specific color lists.
Creates an empty NSColorList.
public NSColorlist
()
Creates a color list, registering it under name if name isn’t in use already.
public NSColorList
(String name)
This constructor invokes the constructor with two arguments, using null
as the additional argument, indicating that the color list doesn’t need to be initialized from a file.
Creates an NSColorList, registering it under name if name isn’t in use already.
public NSColorList
(String name, String path)
path should be the full path to the file for the color list; name should be the name of the file for the color list (minus the “.clr
” extension). A null
path indicates the color list should be initialized with no colors.
Returns an array of all NSColorLists found in the standard color list directories, including color catalogs (lists of colors identified only by name).
public static NSArray availableColorLists
()
Color lists created at runtime aren’t included in this list unless they’re saved into one of the standard color list directories.
Searches the array that’s returned by availableColorLists
and returns the NSColorList named name, or null
if no such color list exists.
public static NSColorList colorListNamed
(String name)
name must not include the “.clr
” suffix.
Returns an array of String objects that contains all the keys by which the NSColors are stored in the receiver.
public NSArray allKeys
()
The length of this array equals the number of colors, and its contents are arranged according to the ordering specified when the colors were inserted.
Returns the NSColor associated with key, or null
if there is none.
public NSColor colorWithKey
(String key)
Inserts color at the specified location in the receiver (numbered starting with 0).
public void insertColorForKeyAtIndex
(NSColor color, String key, int location)
If the list already contains a color with the same key at a different location, it’s removed from the old location. This method posts ColorListDidChangeNotification
to the default notification center. It throws ColorListNotEditableException
if the color list isn’t editable.
Returns true
if the receiver can be modified.
public boolean isEditable
()
This result depends on the source of the list: If it came from a write-protected file, this method returns false
.
Returns the name of the receiver.
public String name
()
Removes the color associated with key from the receiver.
public void removeColorWithKey
(String key)
This method does nothing if the receiver doesn’t contain the key. This method posts ColorListDidChangeNotification
to the default notification center. It throws ColorListNotEditableException
if the receiver is not editable.
Removes the file from which the list was created, if the file is in a standard search path and owned by the user.
public void removeFile
()
The receiver is removed from the list of available color lists returned by availableColorLists
.
Associates the specified NSColor with key.
public void setColorForKey
(NSColor color, String key)
If the list already contains key, this method sets the corresponding color to color; otherwise, it inserts color at the end of the list by invoking insertColorForKeyAtIndex
.
If path is a directory, saves the receiver in a file named listname.clr
in that directory (where listname is the name with which the receiver was initialized).
public boolean writeToFile
(String path)
If path includes a filename, this method saves the file under that name. If path is null
, this method saves the file as listname.clr
in the user’s private colorlists directory. Returns true
upon success and false
if it fails to write the file.
Posted whenever a color list changes. The notification object is the NSColorList object that changed. This notification does not contain a userInfo dictionary.
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)