gnu.x11
Class Colormap

java.lang.Object
  extended by gnu.x11.Resource
      extended by gnu.x11.Colormap

public class Colormap
extends Resource

X colormap.


Nested Class Summary
static class Colormap.ColorCellsReply
          Reply of alloc_color_cells(boolean, int, int).
static class Colormap.ColorItem
          Used in Colormap#store_colors().
 class Colormap.ColorPlaneReply
          Reply for alloc_planes(boolean, int, int, int, int).
 
Field Summary
static int ALL
           
static Colormap COPY_FROM_PARENT
          Predefined colormap.
static int NONE
           
 
Fields inherited from class gnu.x11.Resource
display, id
 
Constructor Summary
Colormap(Display display)
          Create.
Colormap(Display display, int id)
          Intern.
Colormap(int id)
          Predefined.
Colormap(Window window, int visual_id, int alloc)
          Creates a colormap of the specified visual type for the screen on which the window resides.
 
Method Summary
 Colormap.ColorCellsReply alloc_color_cells(boolean contiguous, int color_count, int plane_count)
           
 Color alloc_color(int red, int green, int blue)
          Allocates a read-only colormap entry corresponding to the closest RGB values provided by the hardware.
 Color alloc_color(RGB rgb)
           
 Color alloc_color8(int red8, int green8, int blue8)
           
 Color alloc_named_color(java.lang.String name)
          Looks up the named color with respect to the screen associated with the colormap.
 Colormap.ColorPlaneReply alloc_planes(boolean contiguous, int color_count, int red_count, int green_count, int blue_count)
           
 Color alloc_random_color(java.util.Random random)
           
 Color alloc_random_rainbow_color(java.util.Random random)
           
 RGB[] colors(int[] pixels)
          Returns the hardware specific color values stored in this colormap for the specified pixels.
 Colormap copy_and_free(int new_id)
           
 void free_colors(int[] pixels, int plane_mask)
           
 void free()
           
 void install()
           
static java.lang.Object intern(Display display, int id)
           
 Color lookup_color(java.lang.String name)
          Looks up the name of a color with respect to the screen associated with this colormap, and returns both the exact color values and the closest values provided by the hardware with respect to the visual type of this colormap.
 void store_colors(Colormap.ColorItem[] items)
           
 void store_named_color(int pixel, java.lang.String name, boolean do_reds, boolean do_greens, boolean do_blues)
           
 void uninstall()
           
 
Methods inherited from class gnu.x11.Resource
id, unintern
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPY_FROM_PARENT

public static final Colormap COPY_FROM_PARENT
Predefined colormap.

See Also:
Window.NONE

NONE

public static final int NONE
See Also:
Constant Field Values

ALL

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

Colormap

public Colormap(int id)
Predefined.


Colormap

public Colormap(Display display)
Create.


Colormap

public Colormap(Display display,
                int id)
Intern.


Colormap

public Colormap(Window window,
                int visual_id,
                int alloc)
Creates a colormap of the specified visual type for the screen on which the window resides. The visual type must be supported by the screen (or a Match error results). The initial values of the colormap entries are undefined for classes GrayScale, PseudoColor and DirectColor. For StaticGray, StaticColor and TrueColor alloc must be specified as NONE (or a Match error results). For the other classes, if alloc is NONE the colormap initially has no allocated entries, and clients can allocate entries. If alloc is ALL, then the entire colormap is allocated writable. The initial values of all allocated entries are undefined. For GrayScale and PseudoColor, the effect is as if an AllocColorCells request returned all pixel values from zero to N − 1, where N is the colormap-entries value in the specified visual. For DirectColor, the effect is as if an AllocColorPlanes request returned a pixel value of zero and red-mask, green-mask, and blue-mask values containing the same bits as the corresponding masks in the specified visual. However, in all cases, none of these entries can be freed with FreeColors.

Parameters:
window - the window for which the colormap is allocated
visual - the visual type
alloc - one of NONE, ALL, see above for explanation
See Also:
XCreateColormap
Method Detail

free

public void free()
See Also:
XFreeColormap

copy_and_free

public Colormap copy_and_free(int new_id)

install

public void install()
See Also:
XInstallColormap

uninstall

public void uninstall()
See Also:
XUninstallColormap

intern

public static java.lang.Object intern(Display display,
                                      int id)

alloc_color

public Color alloc_color(int red,
                         int green,
                         int blue)
Allocates a read-only colormap entry corresponding to the closest RGB values provided by the hardware. It also returns the pixel and RGB values actually used. Multiple clients requesting the same effective RGB values can be assigned the same read-only entry, allowing entries to be shared. The return value carries the pixel value as Color.pixel and the RGB value as Color.exact.

Parameters:
red - the red component
green - the green component
blue - the blue component
Returns:
the closest pixel and RGB value of the requested entry
See Also:
XAllocColor

alloc_named_color

public Color alloc_named_color(java.lang.String name)
Looks up the named color with respect to the screen associated with the colormap. Then it does an AllocColor on the colormap. The name should use ISO Latin-1 encoding, and uppercase and lowercase do not matter. The exact RGB values specify the true values for the color, and the visual values specify the values actually used in the colormap.

Parameters:
name - the name of the color
Returns:
the allocated color
See Also:
XAllocNamedColor

alloc_color_cells

public Colormap.ColorCellsReply alloc_color_cells(boolean contiguous,
                                                  int color_count,
                                                  int plane_count)
See Also:
XAllocColorCells

alloc_planes

public Colormap.ColorPlaneReply alloc_planes(boolean contiguous,
                                             int color_count,
                                             int red_count,
                                             int green_count,
                                             int blue_count)
See Also:
XAllocColorPlanes

free_colors

public void free_colors(int[] pixels,
                        int plane_mask)
See Also:
XFreeColors

store_colors

public void store_colors(Colormap.ColorItem[] items)
See Also:
XStoreColors

store_named_color

public void store_named_color(int pixel,
                              java.lang.String name,
                              boolean do_reds,
                              boolean do_greens,
                              boolean do_blues)
See Also:
XStoreNamedColor

colors

public RGB[] colors(int[] pixels)
Returns the hardware specific color values stored in this colormap for the specified pixels. The values returned for an unallocated entry are undefined.

Parameters:
pixels - the pixels for which to return the color values
Returns:
the hardware specific color values of this colormap
See Also:
XQueryColors

lookup_color

public Color lookup_color(java.lang.String name)
Looks up the name of a color with respect to the screen associated with this colormap, and returns both the exact color values and the closest values provided by the hardware with respect to the visual type of this colormap. The name should use the ISO Latin-1 encoding, and uppercase and lowercase do not matter.

Parameters:
name - the color name to lookup
Returns:
the color
See Also:
XLookupColor

alloc_color

public Color alloc_color(RGB rgb)
See Also:
alloc_color(int, int, int)

alloc_color8

public Color alloc_color8(int red8,
                          int green8,
                          int blue8)
See Also:
alloc_color(RGB)

alloc_random_color

public Color alloc_random_color(java.util.Random random)
See Also:
alloc_color(int, int, int)

alloc_random_rainbow_color

public Color alloc_random_rainbow_color(java.util.Random random)
See Also:
alloc_color(int, int, int)