2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / gnu / gcj / xlib / Colormap.java
blob538782e7e76cc99a1744a49adeb901276b3f0dc5
1 /* Copyright (C) 2000 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
9 package gnu.gcj.xlib;
11 import gnu.gcj.RawData;
13 /**
14 * An X11 color map resource.
16 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
18 public final class Colormap extends XID
20 Screen screen;
22 public static final byte FLAG_SHARED = 1;
23 public static final byte FLAG_NOT_SHARED = 2;
25 public Colormap(Screen screen, int xid)
27 super(screen.getDisplay(), xid);
28 this.screen = screen;
31 /**
32 * Allocate color pixel.
34 * @param color The color to be allocated. If allocation is
35 * successful, this object will be modified to reflect the actual
36 * color that was allocated.
38 * @return the pixel value of the allocated color.
40 public native long allocateColorPixel(XColor color);
42 /**
43 * Allocate a color consisting of the given RGB-triplet.
45 * @return a color object describing the allocated color.
47 public XColor allocateColor(int r, int g, int b)
49 XColor color = new XColor(r, g, b);
50 allocateColorPixel(color);
52 return color;
55 /**
56 * Get an array of all colors that currently resides in shared (read
57 * only) color-cells in this color map.
59 public native XColor[] getSharedColors();
62 /**
63 * Get all colors currently residing in this color map. Colors that
64 * are shared (read only) are marked as such by the color flags.
65 * The indexes of the returned array will correspond to the
66 * colorcells of the color map. Given a color <code>XColor
67 * color</code> from a given color-cell, the expression
68 * <code>color.getFlags() == Colormap.FLAG_SHARED</code> will check
69 * whether the color-cell is shared.
71 public native XColor[] getXColors();
73 /**
74 * Convenience method used by native code to create fully
75 * initialized arrays of XColor objects.
77 private XColor[] newXColorArray(int n)
79 XColor[] array = new XColor[n];
80 for (int i=0; i<n; i++)
81 array[i] = new XColor();
82 return array;