org.kde.koala
Class KPalette

java.lang.Object
  extended by org.kde.koala.KPalette
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KPalette
extends java.lang.Object
implements org.kde.qt.QtSupport

Class for handling Palettes. This class makes it easy to handle palettes. A palette is a set of colors. This class can read and write palettes from and to a file. This class uses the "GIMP" palette file format. This class is totally unrelated to QPalette.

Author:
Waldo Bastian (bastian@kde.org)

Field Summary
static int Ask
           
static int No
           
static int Yes
          Used to specify whether a palette may be edited.
 
Constructor Summary
  KPalette()
           
protected KPalette(java.lang.Class dummy)
           
  KPalette(KPalette arg1)
          KPalette copy constructor.
  KPalette(java.lang.String name)
          KPalette constructor.
 
Method Summary
 int addColor(org.kde.qt.QColor newColor)
           
 int addColor(org.kde.qt.QColor newColor, java.lang.String newColorName)
          Add a color.
 int changeColor(int index, org.kde.qt.QColor newColor)
           
 int changeColor(int index, org.kde.qt.QColor newColor, java.lang.String newColorName)
          Change a color.
 int changeColor(org.kde.qt.QColor oldColor, org.kde.qt.QColor newColor)
           
 int changeColor(org.kde.qt.QColor oldColor, org.kde.qt.QColor newColor, java.lang.String newColorName)
          Change a color.
 org.kde.qt.QColor color(int index)
          Find color by index.
 java.lang.String colorName(int index)
          Find color name by index.
 java.lang.String colorName(org.kde.qt.QColor color)
          Find color name by color.
 java.lang.String description()
          Get the description of the palette.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
 int editable()
          Returns whether the palette may be edited.
protected  void finalize()
          Deletes the wrapped C++ instance
 int findColor(org.kde.qt.QColor color)
          Find index by color.
static java.util.ArrayList getPaletteList()
          Query which KDE palettes are installed.
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 java.lang.String name()
          Get the name of the palette.
 int nrColors()
          Return the number of colors in the palette.
 boolean save()
          Save the palette
 void setDescription(java.lang.String desc)
          Set the description of the palette.
 void setEditable(int editable)
          Change whether the palette may be edited.
 void setName(java.lang.String name)
          Set the name of the palette.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Yes

public static final int Yes
Used to specify whether a palette may be edited.

See Also:
editable(), setEditable(int), Constant Field Values

No

public static final int No
See Also:
Constant Field Values

Ask

public static final int Ask
See Also:
Constant Field Values
Constructor Detail

KPalette

protected KPalette(java.lang.Class dummy)

KPalette

public KPalette(java.lang.String name)
KPalette constructor. Creates a KPalette from a file the filename is derived from the name.

Parameters:
name - The name of palette as returned by getPaletteList()

KPalette

public KPalette()

KPalette

public KPalette(KPalette arg1)
KPalette copy constructor.

Method Detail

save

public boolean save()
Save the palette

Returns:
'true' if successful

description

public java.lang.String description()
Get the description of the palette.

Returns:
the description of the palette.

setDescription

public void setDescription(java.lang.String desc)
Set the description of the palette.

Parameters:
desc - the new description

name

public java.lang.String name()
Get the name of the palette.

Returns:
the name of the palette

setName

public void setName(java.lang.String name)
Set the name of the palette.

Parameters:
name - the name of the palette

editable

public int editable()
Returns whether the palette may be edited.

Returns:
the state of the palette

setEditable

public void setEditable(int editable)
Change whether the palette may be edited.

Parameters:
editable - the state of the palette

nrColors

public int nrColors()
Return the number of colors in the palette.

Returns:
the number of colors

color

public org.kde.qt.QColor color(int index)
Find color by index.

Parameters:
index - the index of the desired color
Returns:
The index -th color of the palette, null if not found.

findColor

public int findColor(org.kde.qt.QColor color)
Find index by color.

Parameters:
color - the color to find
Returns:
The index of the color in the palette or -1 if the color is not found.

colorName

public java.lang.String colorName(int index)
Find color name by index.

Parameters:
index - the index of the color
Returns:
The name of the index -th color. Note that not all palettes have named the colors. Null is returned if the color does not exist or has no name.

colorName

public java.lang.String colorName(org.kde.qt.QColor color)
Find color name by color.

Returns:
The name of color according to this palette. Note that not all palettes have named the colors. Note also that each palette can give the same color a different name.

addColor

public int addColor(org.kde.qt.QColor newColor,
                    java.lang.String newColorName)
Add a color.

Parameters:
newColor - The color to add.
newColorName - The name of the color, null to remove the name.
Returns:
The index of the added color.

addColor

public int addColor(org.kde.qt.QColor newColor)

changeColor

public int changeColor(int index,
                       org.kde.qt.QColor newColor,
                       java.lang.String newColorName)
Change a color.

Parameters:
index - Index of the color to change
newColor - The new color.
newColorName - The new color name, null to remove the name.
Returns:
The index of the new color or -1 if the color couldn't be changed.

changeColor

public int changeColor(int index,
                       org.kde.qt.QColor newColor)

changeColor

public int changeColor(org.kde.qt.QColor oldColor,
                       org.kde.qt.QColor newColor,
                       java.lang.String newColorName)
Change a color.

Parameters:
oldColor - The original color
newColor - The new color.
newColorName - The new color name, null to remove the name.
Returns:
The index of the new color or -1 if the color couldn't be changed.

changeColor

public int changeColor(org.kde.qt.QColor oldColor,
                       org.kde.qt.QColor newColor)

getPaletteList

public static java.util.ArrayList getPaletteList()
Query which KDE palettes are installed.

Returns:
A list with a palette names.

finalize

protected void finalize()
                 throws java.lang.InternalError
Deletes the wrapped C++ instance

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.InternalError

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()


isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?