コード例 #1
0
ファイル: large_package.c プロジェクト: krattai/monoflow
static void
largepackage_update_data(LargePackage *pkg)
{
  Element *elem = &pkg->element;
  DiaObject *obj = &elem->object;

  pkg->stereotype = remove_stereotype_from_string(pkg->stereotype);
  if (!pkg->st_stereotype) {
    pkg->st_stereotype = string_to_stereotype(pkg->stereotype);
  }
  
  pkg->topheight = LARGEPACKAGE_FONTHEIGHT + 0.1*2;

  pkg->topwidth = 2.0;
  if (pkg->name != NULL)
    pkg->topwidth = MAX(pkg->topwidth,
                        dia_font_string_width(pkg->name, pkg->font,
                                          LARGEPACKAGE_FONTHEIGHT)+2*0.1);
  if (pkg->st_stereotype != NULL && pkg->st_stereotype[0] != '\0') {
    pkg->topwidth = MAX(pkg->topwidth,
                        dia_font_string_width(pkg->st_stereotype, pkg->font,
                                              LARGEPACKAGE_FONTHEIGHT)+2*0.1);
    pkg->topheight += LARGEPACKAGE_FONTHEIGHT;
  }

  if (elem->width < (pkg->topwidth + 0.2))
    elem->width = pkg->topwidth + 0.2;
  if (elem->height < 1.0)
    elem->height = 1.0;
  
  /* Update connections: */
  element_update_connections_rectangle(elem, pkg->connections);

  element_update_boundingbox(elem);
  /* fix boundingbox for top rectangle: */
  obj->bounding_box.top -= pkg->topheight;

  obj->position = elem->corner;

  element_update_handles(elem);
}
コード例 #2
0
ファイル: dependency.c プロジェクト: krattai/monoflow
static void
dependency_update_data(Dependency *dep)
{
  OrthConn *orth = &dep->orth;
  DiaObject *obj = &orth->object;
  PolyBBExtras *extra = &orth->extra_spacing;
  int num_segm, i;
  Point *points;
  Rectangle rect;
  
  orthconn_update_data(orth);

  dep->stereotype = remove_stereotype_from_string(dep->stereotype);
  if (!dep->st_stereotype) {
    dep->st_stereotype =  string_to_stereotype(dep->stereotype);
  }

  dep->text_width = 0.0;
  if (dep->name)
    dep->text_width = dia_font_string_width(dep->name, dep_font,
					DEPENDENCY_FONTHEIGHT);
  if (dep->stereotype)
    dep->text_width = MAX(dep->text_width,
			  dia_font_string_width(dep->stereotype, dep_font,
					    DEPENDENCY_FONTHEIGHT));
  
  extra->start_trans = 
    extra->start_long = 
    extra->middle_trans = DEPENDENCY_WIDTH/2.0;
  
  extra->end_trans = 
    extra->end_long = (dep->draw_arrow?
                       (DEPENDENCY_WIDTH + DEPENDENCY_ARROWLEN)/2.0:
                       DEPENDENCY_WIDTH/2.0);

  orthconn_update_boundingbox(orth);
  
  /* Calc text pos: */
  num_segm = dep->orth.numpoints - 1;
  points = dep->orth.points;
  i = num_segm / 2;
  
  if ((num_segm % 2) == 0) { /* If no middle segment, use horizontal */
    if (dep->orth.orientation[i]==VERTICAL)
      i--;
  }

  switch (dep->orth.orientation[i]) {
  case HORIZONTAL:
    dep->text_align = ALIGN_CENTER;
    dep->text_pos.x = 0.5*(points[i].x+points[i+1].x);
    dep->text_pos.y = points[i].y;
    if (dep->name)
      dep->text_pos.y -= dia_font_descent(dep->name,
					  dep_font,
					  DEPENDENCY_FONTHEIGHT);
    break;
  case VERTICAL:
    dep->text_align = ALIGN_LEFT;
    dep->text_pos.x = points[i].x + 0.1;
    dep->text_pos.y =
      0.5*(points[i].y+points[i+1].y);
    if (dep->name)
      dep->text_pos.y -= dia_font_descent(dep->name,
					  dep_font,
					  DEPENDENCY_FONTHEIGHT);
    break;
  }

  /* Add the text recangle to the bounding box: */
  rect.left = dep->text_pos.x;
  if (dep->text_align == ALIGN_CENTER)
    rect.left -= dep->text_width/2.0;
  rect.right = rect.left + dep->text_width;
  rect.top = dep->text_pos.y;
  if (dep->name)
    rect.top -= dia_font_ascent(dep->name,
				dep_font,
				DEPENDENCY_FONTHEIGHT);
  rect.bottom = rect.top + 2*DEPENDENCY_FONTHEIGHT;

  rectangle_union(&obj->bounding_box, &rect);
}
コード例 #3
0
ファイル: realizes.c プロジェクト: krattai/monoflow
static void
realizes_update_data(Realizes *realize)
{
  OrthConn *orth = &realize->orth;
  DiaObject *obj = &orth->object;
  int num_segm, i;
  Point *points;
  Rectangle rect;
  PolyBBExtras *extra;

  orthconn_update_data(orth);
  
  realize->text_width = 0.0;

  realize->stereotype = remove_stereotype_from_string(realize->stereotype);
  if (!realize->st_stereotype) {
    realize->st_stereotype =  string_to_stereotype(realize->stereotype);
  }

  if (realize->name)
    realize->text_width = dia_font_string_width(realize->name, realize_font,
					    REALIZES_FONTHEIGHT);
  if (realize->stereotype)
    realize->text_width = MAX(realize->text_width,
			      dia_font_string_width(realize->stereotype,
						realize_font,
						REALIZES_FONTHEIGHT));

  extra = &orth->extra_spacing;
  
  extra->start_trans = REALIZES_WIDTH/2.0 + REALIZES_TRIANGLESIZE;
  extra->start_long = 
    extra->middle_trans = 
    extra->end_trans = 
    extra->end_long = REALIZES_WIDTH/2.0;

  orthconn_update_boundingbox(orth);
  
  /* Calc text pos: */
  num_segm = realize->orth.numpoints - 1;
  points = realize->orth.points;
  i = num_segm / 2;
  
  if ((num_segm % 2) == 0) { /* If no middle segment, use horizontal */
    if (realize->orth.orientation[i]==VERTICAL)
      i--;
  }

  switch (realize->orth.orientation[i]) {
  case HORIZONTAL:
    realize->text_align = ALIGN_CENTER;
    realize->text_pos.x = 0.5*(points[i].x+points[i+1].x);
    realize->text_pos.y = points[i].y;
    if (realize->name)
      realize->text_pos.y -=
        dia_font_descent(realize->name,realize_font, REALIZES_FONTHEIGHT);
    break;
  case VERTICAL:
    realize->text_align = ALIGN_LEFT;
    realize->text_pos.x = points[i].x + 0.1;
    realize->text_pos.y = 0.5*(points[i].y+points[i+1].y);
    if (realize->name)
      realize->text_pos.y -=
        dia_font_descent(realize->name, realize_font, REALIZES_FONTHEIGHT);
    break;
  }

  /* Add the text recangle to the bounding box: */
  rect.left = realize->text_pos.x;
  if (realize->text_align == ALIGN_CENTER)
    rect.left -= realize->text_width/2.0;
  rect.right = rect.left + realize->text_width;
  rect.top = realize->text_pos.y;
  if (realize->name)
    rect.top -= dia_font_ascent(realize->name,realize_font, REALIZES_FONTHEIGHT);
  rect.bottom = rect.top + 2*REALIZES_FONTHEIGHT;

  rectangle_union(&obj->bounding_box, &rect);
}
コード例 #4
0
ファイル: object.c プロジェクト: brunetton/dia
static void
objet_update_data(Objet *ob)
{
  Element *elem = &ob->element;
  DiaObject *obj = &elem->object;
  DiaFont *font;
  Point p1, p2;
  real h, w = 0;
  
  text_calc_boundingbox(ob->text, NULL);
  ob->stereotype = remove_stereotype_from_string(ob->stereotype);
  if (!ob->st_stereotype) {
    ob->st_stereotype =  string_to_stereotype(ob->stereotype);
  }

  font = ob->text->font;
  h = elem->corner.y + OBJET_MARGIN_Y(ob);

  if (ob->is_multiple) {
    h += OBJET_MARGIN_M(ob);
  }
    
  if ((ob->stereotype != NULL) && (ob->stereotype[0] != '\0')) {
      w = dia_font_string_width(ob->st_stereotype, font, OBJET_FONTHEIGHT(ob));
      h += OBJET_FONTHEIGHT(ob);
      ob->st_pos.y = h;
      h += OBJET_MARGIN_Y(ob)/2.0;
  }

  w = MAX(w, ob->text->max_width);
  p1.y = h + ob->text->ascent;  /* position of text */

  h += ob->text->height*ob->text->numlines;

  if ((ob->exstate != NULL) && (ob->exstate[0] != '\0')) {
      w = MAX(w, dia_font_string_width(ob->exstate, font, OBJET_FONTHEIGHT(ob)));
      h += OBJET_FONTHEIGHT(ob);
      ob->ex_pos.y = h;
  }
  
  h += OBJET_MARGIN_Y(ob);

  if (ob->show_attributes) {
      h += OBJET_MARGIN_Y(ob) + ob->attributes->ascent;
      p2.x = elem->corner.x + OBJET_MARGIN_X(ob);
      p2.y = h;      
      text_set_position(ob->attributes, &p2);

      h += ob->attributes->height*ob->attributes->numlines; 

      text_calc_boundingbox(ob->attributes, NULL);
      w = MAX(w, ob->attributes->max_width);
  }

  w += 2*OBJET_MARGIN_X(ob); 

  p1.x = elem->corner.x + w/2.0;
  text_set_position(ob->text, &p1);
  
  ob->ex_pos.x = ob->st_pos.x = p1.x;

  
  if (ob->is_multiple) {
    w += OBJET_MARGIN_M(ob);
  }
    
  elem->width = w;
  elem->height = h - elem->corner.y;

  /* Update connections: */
  element_update_connections_rectangle(elem, ob->connections);
  
  element_update_boundingbox(elem);
  obj->position = elem->corner;
  element_update_handles(elem);
}
コード例 #5
0
ファイル: component.c プロジェクト: krattai/monoflow
static void
component_update_data(Component *cmp)
{
  Element *elem = &cmp->element;
  DiaObject *obj = &elem->object;
  Point p;
  real cw2, ch;

  cmp->stereotype = remove_stereotype_from_string(cmp->stereotype);
  if (!cmp->st_stereotype) {
    cmp->st_stereotype =  string_to_stereotype(cmp->stereotype);
  }

  text_calc_boundingbox(cmp->text, NULL);
  elem->width = cmp->text->max_width + 2*COMPONENT_MARGIN_X + COMPONENT_CWIDTH;
  elem->width = MAX(elem->width, 2*COMPONENT_CWIDTH);
  elem->height =  cmp->text->height*cmp->text->numlines +
    cmp->text->descent + 0.1 + 2*COMPONENT_MARGIN_Y ;
  elem->height = MAX(elem->height, 5*COMPONENT_CHEIGHT);

  p = elem->corner;
  p.x += COMPONENT_CWIDTH + COMPONENT_MARGIN_X;
  p.y += COMPONENT_CHEIGHT;
  p.y += cmp->text->ascent;
  if (cmp->stereotype &&
      cmp->stereotype[0] != '\0') {
    p.y += cmp->text->height;
  }
  text_set_position(cmp->text, &p);

  if (cmp->st_stereotype &&
      cmp->st_stereotype[0] != '\0') {
    DiaFont *font;
    font = cmp->text->font;
    elem->height += cmp->text->height;
    elem->width = MAX(elem->width, dia_font_string_width(cmp->st_stereotype,
						     font, cmp->text->height) +
		      2*COMPONENT_MARGIN_X + COMPONENT_CWIDTH);
  }

  cw2 = COMPONENT_CWIDTH/2;
  ch = COMPONENT_CHEIGHT;
  /* Update connections: */
  connpoint_update(&cmp->connections[0],
		   elem->corner.x + cw2,
		   elem->corner.y,
		   DIR_NORTH|DIR_WEST);
  connpoint_update(&cmp->connections[1],
		   elem->corner.x + cw2 + (elem->width - cw2) / 2,
		   elem->corner.y,
		   DIR_NORTH);
  connpoint_update(&cmp->connections[2],
		   elem->corner.x + elem->width,
		   elem->corner.y,
		   DIR_NORTH|DIR_EAST);
  connpoint_update(&cmp->connections[3],
		   elem->corner.x + cw2,
		   elem->corner.y + elem->height / 2.0,
		   DIR_WEST);
  connpoint_update(&cmp->connections[4],
		   elem->corner.x + elem->width,
		   elem->corner.y + elem->height / 2.0,
		   DIR_EAST);
  connpoint_update(&cmp->connections[5],
		   elem->corner.x + cw2,
		   elem->corner.y + elem->height,
		   DIR_SOUTH|DIR_WEST);
  connpoint_update(&cmp->connections[6],
		   elem->corner.x + cw2 + (elem->width - cw2)/2,
		   elem->corner.y + elem->height,
		   DIR_SOUTH);
  connpoint_update(&cmp->connections[7],
		   elem->corner.x + elem->width,
		   elem->corner.y + elem->height,
		   DIR_SOUTH|DIR_EAST);
  connpoint_update(&cmp->connections[8],
		   elem->corner.x,
		   elem->corner.y + elem->height / 2.0 - ch,
		   DIR_WEST);
  connpoint_update(&cmp->connections[9],
		   elem->corner.x,
		   elem->corner.y + elem->height / 2.0 + ch,
		   DIR_WEST);
  connpoint_update(&cmp->connections[10],
		   elem->corner.x + (elem->width-cw2)/2,
		   elem->corner.y + elem->height / 2.0 + ch,
		   DIR_ALL);

  element_update_boundingbox(elem);

  obj->position = elem->corner;

  element_update_handles(elem);
}