Logo Search packages:      
Sourcecode: ygraph version File versions  Download package

void axis_draw_y_text ( Plot plot  ) 

Draw the y-axis labels.

Parameters:
plot The Plot on which the axis is to be displayed.

Definition at line 497 of file axis.c.

References axis_calc_tick_sep(), axis_get_text_height(), axis_get_text_width(), _Axis::font, _Axis::gc, _Plot::i_origin, _Plot::j_origin, _Axis::orientation, _Plot::pixmap, _Tick::str, _Axis::ticks, _Tick::val, _Plot::y_axis, and y_to_j().

Referenced by axis_draw().

{
  Axis* axis;
  GArray* ticks;
  Tick* tick;
  guint i;
  gint len;
  gint text_height;
  gint text_width;
  gint text_ip;
  gint text_jp;
  gint tick_ip;
  gint tick_jp;
  gchar* str;
  gint di;
  gint step;
  
  axis = plot->y_axis;
  ticks = axis->ticks;

  /*
   * Determine the number of pixels between two ticks (assuming uniform grid),
   * and the number of ticks that need to be skipped in order to display the
   * label text without overlap.
   */
  di = axis_calc_tick_sep(plot, axis, 0);
  step = 1;

  tick_ip = plot->i_origin - 1;

  for (i=0; i<ticks->len; i++)
    {
      tick = g_array_index(ticks, Tick*, i);
      str = tick->str;
      len = strlen(str);
      if (i < ticks->len)
        {

          /*
           * Center the text next to a tick mark and draw a long tick at points
           * for which there is a text label.
           */
           text_height = axis_get_text_height(axis->font, str,
                                              axis->orientation);
           text_width = axis_get_text_width(axis->font, str,
                                            axis->orientation);

           tick_jp = plot->j_origin + y_to_j(plot, tick->val);
           text_jp = tick_jp + 0.3*text_height;
           text_ip = tick_ip - LONG_TICK_LENGTH - text_width;

           g_assert(axis->gc != NULL);
           gdk_draw_text(plot->pixmap, axis->font, axis->gc, text_ip, text_jp,
                         str, len);
           gdk_draw_line(plot->pixmap, axis->gc, tick_ip-LONG_TICK_LENGTH,
                         tick_jp, tick_ip, tick_jp);
        }
    }

  /*
   * At points for which there is no text label, draw a short tick.
   * need to be fixed
   */
  for (i=1; i<ticks->len; i+=step)
    {
      tick = g_array_index(ticks, Tick*, i);
      tick_jp = plot->j_origin + y_to_j(plot, tick->val);
      g_assert(axis->gc != NULL);
      gdk_draw_line(plot->pixmap, axis->gc, tick_ip-SHORT_TICK_LENGTH, tick_jp,
                    tick_ip, tick_jp);
    }
}


Generated by  Doxygen 1.6.0   Back to index