OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [gcj/] [xlib/] [Colormap.java] - Blame information for rev 756

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 756 jeremybenn
/* Copyright (C) 2000  Free Software Foundation
2
 
3
   This file is part of libgcj.
4
 
5
This software is copyrighted work licensed under the terms of the
6
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7
details.  */
8
 
9
package gnu.gcj.xlib;
10
 
11
import gnu.gcj.RawData;
12
 
13
/**
14
 * An X11 color map resource.
15
 *
16
 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
17
 */
18
public final class Colormap extends XID
19
{
20
  Screen screen;
21
 
22
  public static final byte FLAG_SHARED = 1;
23
  public static final byte FLAG_NOT_SHARED = 2;
24
 
25
  public Colormap(Screen screen, int xid)
26
  {
27
    super(screen.getDisplay(), xid);
28
    this.screen = screen;
29
  }
30
 
31
  /**
32
   * Allocate color pixel.
33
   *
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.
37
   *
38
   * @return the pixel value of the allocated color.
39
   */
40
  public native long allocateColorPixel(XColor color);
41
 
42
  /**
43
   * Allocate a color consisting of the given RGB-triplet.
44
   *
45
   * @return a color object describing the allocated color.
46
   */
47
  public XColor allocateColor(int r, int g, int b)
48
  {
49
    XColor color = new XColor(r, g, b);
50
    allocateColorPixel(color);
51
 
52
    return color;
53
  }
54
 
55
  /**
56
   * Get an array of all colors that currently resides in shared (read
57
   * only) color-cells in this color map.
58
   */
59
  public native XColor[] getSharedColors();
60
 
61
 
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.
70
   */
71
  public native XColor[] getXColors();
72
 
73
  /**
74
   * Convenience method used by native code to create fully
75
   * initialized arrays of XColor objects.
76
   */
77
  private XColor[] newXColorArray(int n)
78
  {
79
    XColor[] array = new XColor[n];
80
    for (int i=0; i<n; i++)
81
      array[i] = new XColor();
82
    return array;
83
  }
84
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.