After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 84367 - UML Association
UML Association
Status: VERIFIED INCOMPLETE
Product: dia
Classification: Other
Component: general
0.90
Other other
: Normal normal
: ---
Assigned To: Dia maintainers
Dia maintainers
Depends on:
Blocks:
 
 
Reported: 2002-06-06 13:51 UTC by Olivier Samyn
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The patch as an attachement.... (2.80 KB, patch)
2002-06-11 07:08 UTC, Olivier Samyn
none Details | Review

Description Olivier Samyn 2002-06-06 13:51:12 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 *
Comment 1 Lars Clausen 2002-06-10 21:56:31 UTC
Could you add the diff as an attachment, please?  Cut and paste from a browser messes up the patch.
Comment 2 Olivier Samyn 2002-06-11 07:08:45 UTC
Created attachment 9124 [details] [review]
The patch as an attachement....
Comment 3 Lars Clausen 2002-06-11 21:10:00 UTC
Excellent.  It works quite nicely.  It is now in CVS.