Changeset 929


Ignore:
Timestamp:
Dec 2, 2009, 9:02:12 AM (12 years ago)
Author:
Jari Häkkinen
Message:

Changed Colour to Color for consistency.

Location:
trunk
Files:
5 edited
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/lib/Color.cc

    r928 r929  
    2020*/
    2121
    22 #include "Colours.h"
     22#include "Colors.h"
    2323
    2424#include "Configuration.h"
     
    3030namespace svndigest {
    3131
    32   Colours* Colours::instance_=NULL;
     32  Colors* Colors::instance_=NULL;
    3333
    3434
    35   Colours::Colours(void)
    36     : colour_map_(13), next_colour_(colour_map_.begin())
     35  Colors::Colors(void)
     36    : color_map_(13), next_color_(color_map_.begin())
    3737
    3838  {
    39     colour_map_[ 0].label="green";
    40     colour_map_[ 0].r=  0; colour_map_[ 0].g=146; colour_map_[ 0].b= 72;
    41     colour_map_[ 1].label="blue";
    42     colour_map_[ 1].r= 27; colour_map_[ 1].g=117; colour_map_[ 1].b=186;
    43     colour_map_[ 2].label="red";
    44     colour_map_[ 2].r=189; colour_map_[ 2].g= 32; colour_map_[ 2].b= 46;
    45     colour_map_[ 3].label="grey";
    46     colour_map_[ 3].r=131; colour_map_[ 3].g=131; colour_map_[ 3].b=131;
    47     colour_map_[ 4].label="orange";
    48     colour_map_[ 4].r=245; colour_map_[ 4].g=145; colour_map_[ 4].b= 32;
    49     colour_map_[ 5].label="brown";
    50     colour_map_[ 5].r=117; colour_map_[ 5].g= 77; colour_map_[ 5].b= 41;
    51     colour_map_[ 6].label="cyan";
    52     colour_map_[ 6].r= 40; colour_map_[ 6].g=170; colour_map_[ 6].b=225;
    53     colour_map_[ 7].label="lime";
    54     colour_map_[ 7].r=213; colour_map_[ 7].g=221; colour_map_[ 7].b= 38;
    55     colour_map_[ 8].label="purple";
    56     colour_map_[ 8].r=143; colour_map_[ 8].g= 40; colour_map_[ 8].b=140;
    57     colour_map_[ 9].label="lgrey";
    58     colour_map_[ 9].r=220; colour_map_[ 9].g=220; colour_map_[ 9].b=220;
    59     colour_map_[10].label="lbrown";
    60     colour_map_[10].r=194; colour_map_[10].g=151; colour_map_[10].b=106;
    61     colour_map_[11].label="pink";
    62     colour_map_[11].r=230; colour_map_[11].g=125; colour_map_[11].b=230;
    63     colour_map_[12].label="black";
    64     colour_map_[12].r=  0; colour_map_[12].g=  0; colour_map_[12].b=  0;
     39    color_map_[ 0].label="green";
     40    color_map_[ 0].r=  0; color_map_[ 0].g=146; color_map_[ 0].b= 72;
     41    color_map_[ 1].label="blue";
     42    color_map_[ 1].r= 27; color_map_[ 1].g=117; color_map_[ 1].b=186;
     43    color_map_[ 2].label="red";
     44    color_map_[ 2].r=189; color_map_[ 2].g= 32; color_map_[ 2].b= 46;
     45    color_map_[ 3].label="grey";
     46    color_map_[ 3].r=131; color_map_[ 3].g=131; color_map_[ 3].b=131;
     47    color_map_[ 4].label="orange";
     48    color_map_[ 4].r=245; color_map_[ 4].g=145; color_map_[ 4].b= 32;
     49    color_map_[ 5].label="brown";
     50    color_map_[ 5].r=117; color_map_[ 5].g= 77; color_map_[ 5].b= 41;
     51    color_map_[ 6].label="cyan";
     52    color_map_[ 6].r= 40; color_map_[ 6].g=170; color_map_[ 6].b=225;
     53    color_map_[ 7].label="lime";
     54    color_map_[ 7].r=213; color_map_[ 7].g=221; color_map_[ 7].b= 38;
     55    color_map_[ 8].label="purple";
     56    color_map_[ 8].r=143; color_map_[ 8].g= 40; color_map_[ 8].b=140;
     57    color_map_[ 9].label="lgrey";
     58    color_map_[ 9].r=220; color_map_[ 9].g=220; color_map_[ 9].b=220;
     59    color_map_[10].label="lbrown";
     60    color_map_[10].r=194; color_map_[10].g=151; color_map_[10].b=106;
     61    color_map_[11].label="pink";
     62    color_map_[11].r=230; color_map_[11].g=125; color_map_[11].b=230;
     63    color_map_[12].label="black";
     64    color_map_[12].r=  0; color_map_[12].g=  0; color_map_[12].b=  0;
    6565
    6666    typedef std::map<std::string, std::string> ACmap;
    6767    const ACmap& authcols=Configuration::instance().author_colors();
    68     std::map<std::string,std::vector<colour>::iterator>::iterator j;
     68    std::map<std::string,std::vector<color>::iterator>::iterator j;
    6969    for (ACmap::const_iterator i=authcols.begin(); i!=authcols.end(); i++) {
    70       colour c;
     70      color c;
    7171      c.label=i->first;
    7272      c.r= 16*to_decimal(i->second[0]) + to_decimal(i->second[1]);
    7373      c.g= 16*to_decimal(i->second[2]) + to_decimal(i->second[3]);
    7474      c.b= 16*to_decimal(i->second[4]) + to_decimal(i->second[5]);
    75       next_colour_=colour_map_.insert(next_colour_,c);
    76       author_map_.insert(std::make_pair(c.label, next_colour_++));
     75      next_color_=color_map_.insert(next_color_,c);
     76      author_map_.insert(std::make_pair(c.label, next_color_++));
    7777    }
    7878  }
    7979
    8080
    81   void Colours::get_colour(const std::string& label, unsigned char& r,
     81  void Colors::get_color(const std::string& label, unsigned char& r,
    8282                           unsigned char& g, unsigned char& b)
    8383  {
    84     std::map<std::string,std::vector<colour>::iterator>::iterator i;
     84    std::map<std::string,std::vector<color>::iterator>::iterator i;
    8585    i = author_map_.lower_bound(label);
    8686    if (i==author_map_.end() || i->first != label) {
    87       // no colour defined for label, set colour for label
    88       i = author_map_.insert(i, std::make_pair(label, next_colour_++));
    89       if (next_colour_==colour_map_.end())
    90         // end of colour map reach, start over
    91         next_colour_=colour_map_.begin();
     87      // no color defined for label, set color for label
     88      i = author_map_.insert(i, std::make_pair(label, next_color_++));
     89      if (next_color_==color_map_.end())
     90        // end of color map reach, start over
     91        next_color_=color_map_.begin();
    9292    }
    9393    r = i->second->r;
     
    9797
    9898
    99   Colours& Colours::instance(void)
     99  Colors& Colors::instance(void)
    100100  {
    101101    if (!instance_)
    102       instance_ = new Colours;
     102      instance_ = new Colors;
    103103    return *instance_;
    104104  }
    105105
    106106
    107   int Colours::to_decimal(int hex)
     107  int Colors::to_decimal(int hex)
    108108  {
    109109    hex=toupper(hex);
  • trunk/lib/Colors.h

    r928 r929  
    1 #ifndef _theplu_svndigest_colours_
    2 #define _theplu_svndigest_colours_
     1#ifndef _theplu_svndigest_colors_
     2#define _theplu_svndigest_colors_
    33
    44// $Id$
     
    3131
    3232  /**
    33      The author-colour mapping is provided by the Colours class.
     33     The author-color mapping is provided by the Colors class.
    3434
    35      Colours use the singleton design pattern.
     35     Colors use the singleton design pattern.
    3636   */
    37   class Colours
     37  class Colors
    3838  {
    3939  public:
    4040
    4141    /**
    42        \brief Get RGB colour for \a label
     42       \brief Get RGB color for \a label
    4343
    44        If \a label has no assigned colour, the next unused colour is
     44       If \a label has no assigned color, the next unused color is
    4545       automatically assigned to \a label. The number of available
    46        unique colours is low, when all colours are used mapped with a
    47        \a label once, the colours are reused.
     46       unique colors is low, when all colors are used mapped with a
     47       \a label once, the colors are reused.
    4848
    49        \see To be written. If a specific colour is to be assigned for
     49       \see To be written. If a specific color is to be assigned for
    5050       a label, use function TBA.
    5151     */
    52     void get_colour(const std::string& label, unsigned char& r,
     52    void get_color(const std::string& label, unsigned char& r,
    5353                    unsigned char& g, unsigned char& b);
    5454
    5555    /**
    56        \brief Get an instance of Colour
     56       \brief Get an instance of Color
    5757     */
    58     static Colours& instance(void);
     58    static Colors& instance(void);
    5959
    6060  private:
    6161
    62     Colours(void);
     62    Colors(void);
    6363
    6464    // Copy constructor not implemented
    65     Colours(const Colours&);
     65    Colors(const Colors&);
    6666
    6767    // Convert char from hexadecimal to decimal, if char is out of
     
    7070
    7171    // Assignment not implemented because assignment is always self-assignment
    72     Colours& operator=(const Colours&);
     72    Colors& operator=(const Colors&);
    7373
    7474    // Destructor not implemented
    75     ~Colours(void);
     75    ~Colors(void);
    7676
    77     struct colour {
     77    struct color {
    7878      std::string label;
    7979      unsigned char r,g,b;
    8080    };
    8181
    82     std::map<std::string, std::vector<colour>::iterator> author_map_;
    83     std::vector<colour> colour_map_;
    84     static Colours* instance_;
    85     std::vector<colour>::iterator next_colour_;
     82    std::map<std::string, std::vector<color>::iterator> author_map_;
     83    std::vector<color> color_map_;
     84    static Colors* instance_;
     85    std::vector<color>::iterator next_color_;
    8686  };
    8787
  • trunk/lib/Graph.cc

    r918 r929  
    3939  {
    4040    legend_.reserve(20);
    41     // we use colour map 0 position 0 for background colour
     41    // we use color map 0 position 0 for background color
    4242    pls_.scolbga(255,255,255,0);
    4343    pls_.init();
     
    6262
    6363
    64   void Graph::current_colour(const legend_data& legend)
     64  void Graph::current_color(const legend_data& legend)
    6565  {
    66     // we use colour map 0 position 1 for current colour
     66    // we use color map 0 position 1 for current color
    6767#ifdef HAVE_PLPLOT
    6868    pls_.scol0a(1,legend.r,legend.g,legend.b,1.0);
     
    7171
    7272
    73   void Graph::current_colour(unsigned char r, unsigned char g, unsigned char b)
     73  void Graph::current_color(unsigned char r, unsigned char g, unsigned char b)
    7474  {
    75     // we use colour map 0 position 1 for current colour
     75    // we use color map 0 position 1 for current color
    7676#ifdef HAVE_PLPLOT
    7777    pls_.scol0a(1,r,g,b,1.0);
     
    143143         i!=legend_.end(); i++, ++row) {
    144144      PLFLT y=(0.95-0.04*row)*yrange_;
    145       current_colour(*i);
     145      current_color(*i);
    146146      pls_.col0(1);
    147147      pls_.join(x-line_length, y-dy, x, y-dy);
  • trunk/lib/Graph.h

    r916 r929  
    6262       \brief Set the pen colour to use in next drawing call
    6363    */
    64     void current_colour(unsigned char r, unsigned char g, unsigned char b);
     64    void current_color(unsigned char r, unsigned char g, unsigned char b);
    6565
    6666    static bool date_xticks(void);
     
    123123       \brief Set the pen colour to use in next drawing call
    124124    */
    125     void current_colour(const legend_data&);
     125    void current_color(const legend_data&);
    126126    void print_legend(void);
    127127    unsigned int tick_spacing(const double range) const;
  • trunk/lib/Makefile.am

    r916 r929  
    3333
    3434noinst_HEADERS = AddStats.h Alias.h BlameStats.h ClassicStats.h \
    35   Colours.h Commitment.h Configuration.h css.h \
     35  Colors.h Commitment.h Configuration.h css.h \
    3636  Date.h Directory.h File.h first_page.h Functor.h \
    3737  Graph.h \
     
    4343
    4444libsvndigest_a_SOURCES = AddStats.cc Alias.cc BlameStats.cc \
    45   ClassicStats.cc Colours.cc \
     45  ClassicStats.cc Colors.cc \
    4646  Commitment.cc Configuration.cc \
    4747  css.cc Date.cc Directory.cc File.cc first_page.cc\
  • trunk/lib/Stats.cc

    r916 r929  
    2424#include "Stats.h"
    2525
    26 #include "Colours.h"
     26#include "Colors.h"
    2727#include "Functor.h"
    2828#include "Graph.h"
     
    389389    for (vec_type::iterator i(author_cont.begin()); i!=end; ++i) {
    390390      unsigned char r, g, b;
    391       Colours::instance().get_colour(i->first,r,g,b);
    392       gp.current_colour(r,g,b);
     391      Colors::instance().get_color(i->first,r,g,b);
     392      gp.current_color(r,g,b);
    393393      gp.plot(i->second, i->first, get_back(*stat, i->first));
    394394    }
    395     gp.current_colour(255,0,0);
     395    gp.current_color(255,0,0);
    396396    gp.plot(total, "total", get_back(*stat, "all"));
    397397
     
    408408   
    409409    std::vector<unsigned int> x(get_vector(code_stats(), "all"));
    410     gp.current_colour(255,255,0);
     410    gp.current_color(255,255,0);
    411411    gp.plot(x, "code", x.back());
    412412
    413413    x = get_vector(comment_or_copy_stats(), "all");
    414     gp.current_colour(0,0,255);
     414    gp.current_color(0,0,255);
    415415    gp.plot(x, "comment", x.back());
    416416
    417417    x = get_vector(other_stats(), "all");
    418     gp.current_colour(0,255,0);
     418    gp.current_color(0,255,0);
    419419    gp.plot(x, "other", x.back());
    420420
    421     gp.current_colour(255,0,0);
     421    gp.current_color(255,0,0);
    422422    gp.plot(total, "total", total.back());
    423423  }
  • trunk/test/Makefile.am

    r919 r929  
    2222check_SCRIPTS = svn_update.sh
    2323
    24 check_PROGRAMS = cache_partial_test colour_test \
     24check_PROGRAMS = cache_partial_test color_test \
    2525  config_test copyright_test date_test \
    2626  parser_test stats_test trac_test utility_test
     
    5454
    5555cache_partial_test_SOURCES = cache_partial_test.cc
    56 colour_test_SOURCES = colour_test.cc
     56color_test_SOURCES = color_test.cc
    5757config_test_SOURCES = config_test.cc
    5858copyright_test_SOURCES = copyright_test.cc
  • trunk/test/color_test.cc

    r924 r929  
    2020*/
    2121
    22 #include "Colours.h"
     22#include "Colors.h"
    2323
    2424#include <iostream>
     
    3030  bool ok=true;
    3131
    32   // The loop adds new authors to the author colour map until all
    33   // colours are use. The colour map contains 12 colours and black
     32  // The loop adds new authors to the author color map until all
     33  // colors are use. The color map contains 12 colors and black
    3434  // (total 13). The loop is 14 iterations and therefore the first
    35   // colour is reused for the last author. This test checks that
    36   // colours are reused. If the colour map size changes, then the loop
     35  // color is reused for the last author. This test checks that
     36  // colors are reused. If the color map size changes, then the loop
    3737  // must be adjusted accordingly
    3838  unsigned char r_first, g_first, b_first;
     
    4141    std::stringstream ss;
    4242    ss << i;
    43     Colours::instance().get_colour(ss.str(), r, g, b);
    44     if (!i) r_first=r, g_first=g, b_first=b;  // remember first colour
     43    Colors::instance().get_color(ss.str(), r, g, b);
     44    if (!i) r_first=r, g_first=g, b_first=b;  // remember first color
    4545  }
    46   // Test first and last colour, expected to be the same.
     46  // Test first and last color, expected to be the same.
    4747  if (r!=r_first || g!=g_first || b!=b_first) {
    4848    ok=false;
Note: See TracChangeset for help on using the changeset viewer.