GNOME Bugzilla – Bug 84367
UML Association
Last modified: 2009-08-15 18:40:50 UTC
Hi dia developpers, This is a small patch to dia-0.90 objects/UML/association.c tweaking a little bit the multiplicity text position. Before this patch, multiplicity overlaps the end symbol (diamond or arrow). Simply using some text_pos modifications, the multiplicity is now placed before the end symbol and doesn't overlaps it anymore. this is a quick hack, more can be done, but is it very usefull since you're working on gtk-2.0 version ? -----------cut here for patch------------- diff -ru dia-0.90/objects/UML/association.c dia-0.90.os/objects/UML/association.c --- dia-0.90/objects/UML/association.c Sat Feb 2 00:21:56 2002 +++ dia-0.90.os/objects/UML/association.c Wed Jun 5 18:42:31 2002 @@ -144,6 +144,7 @@ const char *filename); static void association_update_data(Association *assoc); +static coord get_aggregate_pos_diff(AssociationEnd *end); static ObjectTypeOps association_type_ops = { @@ -487,14 +488,25 @@ end->text_pos = points[0]; switch (assoc->orth.orientation[0]) { case HORIZONTAL: - end->text_pos.y -= font_descent(assoc_font, ASSOCIATION_FONTHEIGHT); - if (points[0].x < points[1].x) + if (points[0].x < points[1].x) { end->text_align = ALIGN_LEFT; - else - end->text_align = ALIGN_RIGHT; + end->text_pos.x += get_aggregate_pos_diff(end); + } else { + end->text_align = ALIGN_RIGHT; + end->text_pos.x -= get_aggregate_pos_diff(end); + } break; case VERTICAL: end->text_pos.y += font_ascent(assoc_font, ASSOCIATION_FONTHEIGHT); + if (points[0].y > points[1].y) { + if (end->role!=NULL) + end->text_pos.y -= ASSOCIATION_FONTHEIGHT; + if (end->multiplicity!=NULL) + end->text_pos.y -= ASSOCIATION_FONTHEIGHT; + end->text_pos.y -= get_aggregate_pos_diff(end); + } else { + end->text_pos.y += get_aggregate_pos_diff(end); + } end->text_align = ALIGN_LEFT; break; } @@ -513,10 +525,13 @@ switch (assoc->orth.orientation[n-1]) { case HORIZONTAL: end->text_pos.y -= font_descent(assoc_font, ASSOCIATION_FONTHEIGHT); - if (points[n].x < points[n-1].x) + if (points[n].x < points[n-1].x) { end->text_align = ALIGN_LEFT; - else + end->text_pos.x += get_aggregate_pos_diff(end); + } else { end->text_align = ALIGN_RIGHT; + end->text_pos.x -= get_aggregate_pos_diff(end); + } break; case VERTICAL: end->text_pos.y += font_ascent(assoc_font, ASSOCIATION_FONTHEIGHT); @@ -525,6 +540,9 @@ end->text_pos.y -= ASSOCIATION_FONTHEIGHT; if (end->multiplicity!=NULL) end->text_pos.y -= ASSOCIATION_FONTHEIGHT; + end->text_pos.y -= get_aggregate_pos_diff(end); + } else { + end->text_pos.y += get_aggregate_pos_diff(end); } end->text_align = ALIGN_LEFT; break; @@ -536,6 +554,23 @@ rect.bottom = rect.top + 2*ASSOCIATION_FONTHEIGHT; rectangle_union(&obj->bounding_box, &rect); +} + +static coord get_aggregate_pos_diff(AssociationEnd *end) +{ + coord width=0; + if(end->arrow){ + width = ASSOCIATION_TRIANGLESIZE; + } + switch(end->aggregate){ + case AGGREGATE_COMPOSITION: + case AGGREGATE_NORMAL: + if(width!=0) width = MAX(ASSOCIATION_TRIANGLESIZE, ASSOCIATION_DIAMONDLEN); + else width = ASSOCIATION_DIAMONDLEN; + case AGGREGATE_NONE: + break; + } + return width; } static Object *
Could you add the diff as an attachment, please? Cut and paste from a browser messes up the patch.
Created attachment 9124 [details] [review] The patch as an attachement....
Excellent. It works quite nicely. It is now in CVS.