Author: bobtarling
Date: 2011-04-26 14:51:06-0700
New Revision: 19284

Modified:
   
trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java

Log:
The constructor for a compartment take a list of allowable types to display, 
not the actual items to display.

Modified: 
trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java?view=diff&pathrev=19284&r1=19283&r2=19284
==============================================================================
--- 
trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java
     (original)
+++ 
trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java
     2011-04-26 14:51:06-0700
@@ -15,9 +15,13 @@
 
 import java.awt.Dimension;
 import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.argouml.model.InvalidElementException;
+import org.argouml.model.Model;
 import org.argouml.notation2.NotationType;
 import org.argouml.uml.diagram.DiagramSettings;
 import org.tigris.gef.presentation.Fig;
@@ -35,23 +39,37 @@
  * @author Bob Tarling
  */
 class FigCompartment extends FigComposite {
+
+    public FigCompartment(Object owner, Rectangle bounds,
+            DiagramSettings settings, Object metaType) {
+        this(owner, bounds, settings, Arrays.asList(new Object[] {metaType}));
+    }
     
+    /**
+     * @param owner the model element that owns the compartment
+     * @param bounds the initial bounds of the compartment
+     * @param settings the diagram settings
+     * @param metaType the different metatype that can be displayed in the 
compartment
+     */
     public FigCompartment(Object owner, Rectangle bounds,
-            DiagramSettings settings, List elements) {
+            DiagramSettings settings, List<Object> metaTypes) {
         
         super(owner, settings);
         
-        for (Object element : elements) {
-            try {
-                int y = bounds.y + getTopMargin();
-                int x = bounds.x + getLeftMargin();
-                Rectangle childBounds = new Rectangle(x, y, 0, 0);
-                FigNotation fn =
-                    new FigNotation(element, childBounds, settings, 
NotationType.NAME);
-                addFig(fn);
-                y += fn.getHeight();
-            } catch (InvalidElementException e) {
-            } 
+        Model.getFacade().getModelElementContents(owner);
+        for (Object element : 
Model.getFacade().getModelElementContents(owner)) {
+            if (metaTypes.contains(element.getClass())) {
+                try {
+                    int y = bounds.y + getTopMargin();
+                    int x = bounds.x + getLeftMargin();
+                    Rectangle childBounds = new Rectangle(x, y, 0, 0);
+                    FigNotation fn =
+                        new FigNotation(element, childBounds, settings, 
NotationType.NAME);
+                    addFig(fn);
+                    y += fn.getHeight();
+                } catch (InvalidElementException e) {
+                }
+            }
         }
     }

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

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

Reply via email to