GogAxisColorMap

## GogAxisColorMap GogAxisColorMap — map values to colors. |

## Synopsis

                        GogAxisColorMap;
    GogAxisColorMap *   gog_axis_color_map_edit             (GogAxisColorMap *map,
                                                             GOCmdContext *cc);
    void                (*GogAxisColorMapHandler)           (GogAxisColorMap const *map,
                                                             gpointer user_data);
    gboolean            gog_axis_color_map_delete           (GogAxisColorMap *map);
    GogAxisColorMap *   gog_axis_color_map_dup              (GogAxisColorMap const *map);
    void                gog_axis_color_map_foreach          (GogAxisColorMapHandler handler,
                                                             gpointer user_data);
    GogAxisColorMap *   gog_axis_color_map_from_colors      (char const *name,
                                                             unsigned  nb,
                                                             GOColor const *colors,
                                                             GoResourceType type);
    GOColor             gog_axis_color_map_get_color        (GogAxisColorMap const *map,
                                                             double x);
    GogAxisColorMap const * gog_axis_color_map_get_from_id  (char const *id);
    unsigned            gog_axis_color_map_get_max          (GogAxisColorMap const *map);
    char const *        gog_axis_color_map_get_id           (GogAxisColorMap const *map);
    char const *        gog_axis_color_map_get_name         (GogAxisColorMap const *map);
    GoResourceType      gog_axis_color_map_get_resource_type
                                                            (GogAxisColorMap const *map);
    GdkPixbuf *         gog_axis_color_map_get_snapshot     (GogAxisColorMap const *map,
                                                             gboolean discrete,
                                                             gboolean horizontal,
                                                             unsigned  width,
                                                             unsigned  height);
    void                gog_axis_color_map_to_cairo         (GogAxisColorMap const *map,
                                                             cairo_t *cr,
                                                             unsigned  discrete,
                                                             gboolean horizontal,
                                                             double width,
                                                             double height);

## Object Hierarchy

      GObject
       +----GogAxisColorMap

## Implemented Interfaces

GogAxisColorMap implements GOPersist.

## Properties

      "resource-type"            GoResourceType        : Read / Write / Construct Only

## Description

Used to map color and pseudo-3d axes values to the actual color. The first color maps 0 and the last a positive integer returned by `gog_axis_color_map_get_max()`. For color axes, these integer values must themselves be mapped to the minimum and maximum of the axis (unless the axis is inverted). For pseudo-3d axes, successive colors are obtained for integer values, cycling to the first color when the colors number is not large enough.

## Details

### GogAxisColorMap

    typedef struct _GogAxisColorMap GogAxisColorMap;

### gog_axis_color_map_edit ()

    GogAxisColorMap *   gog_axis_color_map_edit             (GogAxisColorMap *map,
                                                             GOCmdContext *cc);

Opens a dialog to edit the color map. If `map` is `NULL`, creates a new one unless the user cancels the edition.

`map` : | a GogAxisColorMap or `NULL`
`cc` : | a GOCmdContext or `NULL`
Returns : | the edited color map. [transfer none]

### GogAxisColorMapHandler ()

    void                (*GogAxisColorMapHandler)           (GogAxisColorMap const *map,
                                                             gpointer user_data);

Type of the callback to pass to `gog_axis_color_map_foreach()` to iterate through color maps.

`map` : | a GogAxisColorMap
`user_data` : | user data

### gog_axis_color_map_delete ()

    gboolean            gog_axis_color_map_delete           (GogAxisColorMap *map);

Destroys the color map and remove it from the user directory and from the database.

`map` : | a GogAxisColorMap
Returns : | `TRUE` on success.

### gog_axis_color_map_dup ()

    GogAxisColorMap *   gog_axis_color_map_dup              (GogAxisColorMap const *map);

Duplicates the color map.

`map` : | a GogAxisColorMap
Returns : | the new color map. [transfer full]

### gog_axis_color_map_foreach ()

    void                gog_axis_color_map_foreach          (GogAxisColorMapHandler handler,
                                                             gpointer user_data);

Executes `handler` to each color map installed on the system or loaded from a document.

`handler` : | a GogAxisColorMapHandler. [scope call]
`user_data` : | data to pass to `handler`

### gog_axis_color_map_from_colors ()

    GogAxisColorMap *   gog_axis_color_map_from_colors      (char const *name,
                                                             unsigned  nb,
                                                             GOColor const *colors,
                                                             GoResourceType type);

Creates a color map using `colors`.

`name` : | color map name
`nb` : | colors number
`colors` : | the colors
`type` : | the resource type
Returns : | the newly created color map. [transfer full]

### gog_axis_color_map_get_color ()

    GOColor             gog_axis_color_map_get_color        (GogAxisColorMap const *map,
                                                             double x);

Maps `x` to a color.

`map` : | a GogAxisMap
`x` : | the value to map
Returns : | the found color.

### gog_axis_color_map_get_from_id ()

    GogAxisColorMap const * gog_axis_color_map_get_from_id  (char const *id);

Retrieves the color map whose identifier is `id`.

`id` : | the color map identifier to search for
Returns : | the found color map. [transfer none]

### gog_axis_color_map_get_max ()

    unsigned            gog_axis_color_map_get_max          (GogAxisColorMap const *map);

Retrieves the value corresponding to the last color in the map. The first always corresponds to 0.

`map` : | a GogAxisMap
Returns : | the maximum value.

### gog_axis_color_map_get_id ()

    char const *        gog_axis_color_map_get_id           (GogAxisColorMap const *map);

Retrieves the color map name.

`map` : | a GogAxisMap
Returns : | the map name. [transfer none]

### gog_axis_color_map_get_name ()

    char const *        gog_axis_color_map_get_name         (GogAxisColorMap const *map);

Retrieves the color map localized name.

`map` : | a GogAxisMap
Returns : | the map name. [transfer none]

### gog_axis_color_map_get_resource_type ()

    GoResourceType      gog_axis_color_map_get_resource_type
                                                            (GogAxisColorMap const *map);

Retrieves the resource type for `map`.

`map` : | a GogAxisMap
Returns : | the resource type.

### gog_axis_color_map_get_snapshot ()

    GdkPixbuf *         gog_axis_color_map_get_snapshot     (GogAxisColorMap const *map,
                                                             gboolean discrete,
                                                             gboolean horizontal,
                                                             unsigned  width,
                                                             unsigned  height);

Builds a snapshot of the color map.

`map` : | a GogAxisMap
`discrete` : | whether to use constant colors between each stop or a gradient.
`horizontal` : | whether to get an horizontal or a vertical snapshot.
`width` : | the pixbuf width.
`height` : | the pixbuf height.
Returns : | the new GdkPixbuf. [transfer full]

### gog_axis_color_map_to_cairo ()

    void                gog_axis_color_map_to_cairo         (GogAxisColorMap const *map,
                                                             cairo_t *cr,
                                                             unsigned  discrete,
                                                             gboolean horizontal,
                                                             double width,
                                                             double height);

When `discrete` is larger than 1, it will be interpreted as the number of major ticks used. The number of colors will then be `discrete` − 1. Draws a snapshot of the color map inside the rectangle.

`map` : | a GogAxisMap
`cr` : | a cairo context.
`discrete` : | whether to use constant colors between each stop or a gradient.
`horizontal` : | whether to get an horizontal or a vertical snapshot.
`width` : | the rectangle width.
`height` : | the rectangle height.

## Property Details

### The `"resource-type"` property

      "resource-type"            GoResourceType        : Read / Write / Construct Only

The resource type for the color map.

Default value: GO_RESOURCE_INVALID