Author: bobtarling
Date: 2011-03-24 07:57:39-0700
New Revision: 19127

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java

Log:
Do not cache the value for arrowType - just generate it and return it when 
getArrowType is called.

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java?view=diff&pathrev=19127&r1=19126&r2=19127
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java    
(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java    
2011-03-24 07:57:39-0700
@@ -151,8 +151,6 @@
         if (Model.getFacade().getUmlVersion().charAt(0) == '2'
                 && pce instanceof AssociationChangeEvent
                 && pce.getPropertyName().equals("navigableOwnedEnd")) {
-            srcEnd.getGroup().determineArrowHead();
-            destEnd.getGroup().determineArrowHead();
             applyArrowHeads();
             damage();
         }
@@ -855,7 +853,6 @@
     
     private FigRole role;
     private FigOrdering ordering;
-    private int arrowType = 0;
     private FigEdgeModelElement figEdge;
 
     FigAssociationEndAnnotation(FigEdgeModelElement edge, Object owner,
@@ -869,7 +866,6 @@
         ordering = new FigOrdering(owner, settings);
         addFig(ordering);
 
-        determineArrowHead();
         Model.getPump().addModelEventListener(this, owner, 
                 new String[] {"isNavigable", "aggregation", "participant"});
     }
@@ -893,7 +889,6 @@
         if (pce instanceof AttributeChangeEvent
             && (pce.getPropertyName().equals("isNavigable")
                 || pce.getPropertyName().equals("aggregation"))) {
-            determineArrowHead();
             ((FigAssociation) figEdge).applyArrowHeads();
             damage();
         }
@@ -923,27 +918,6 @@
     }
 
     /**
-     * Decide which arrow head should appear
-     */
-    void determineArrowHead() {
-        assert getOwner() != null;
-
-        final Object ak = getAggregateKind();
-        boolean nav = Model.getFacade().isNavigable(getOwner());
-
-        if (Model.getAggregationKind().getAggregate().equals(ak)) {
-            arrowType = AGGREGATE;
-        } else if (Model.getAggregationKind().getComposite().equals(ak)) {
-            arrowType = COMPOSITE;
-        } else {
-            arrowType = NONE;
-        }
-        if (nav) {
-            arrowType += 3;
-        }
-    }
-    
-    /**
      * Get the aggregation kind to display at this end
      * @return the aggregation kind or null if this is not a binary association
      */
@@ -954,7 +928,9 @@
         Object ass = Model.getFacade().getAssociation(getOwner());
         Collection ends = Model.getFacade().getConnections(ass);
         if (ends.size() != 2) {
-            return null;
+            // Aggregation is meaningless in a n-ary association
+            // so always assume none.
+            return Model.getAggregationKind().getNone();
         }
         Iterator it = ends.iterator();
         Object aggEnd = it.next();
@@ -969,6 +945,23 @@
      * @return the current arrow type of this end of the association
      */
     public int getArrowType() {
+        assert getOwner() != null;
+        
+
+        final Object ak = getAggregateKind();
+        boolean nav = Model.getFacade().isNavigable(getOwner());
+
+        int arrowType;
+        if (Model.getAggregationKind().getAggregate().equals(ak)) {
+            arrowType = AGGREGATE;
+        } else if (Model.getAggregationKind().getComposite().equals(ak)) {
+            arrowType = COMPOSITE;
+        } else {
+            arrowType = NONE;
+        }
+        if (nav) {
+            arrowType += NAV;
+        }
         return arrowType;
     }

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2713847

To unsubscribe from this discussion, e-mail: 
[[email protected]].

Reply via email to