Author: bobtarling
Date: 2011-05-11 07:56:06-0700
New Revision: 19401

Added:
   
trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/SelectionVertex.java
Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigRegion.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java

Log:
Display dashed lines between different regions in an orthogonal state

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigRegion.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigRegion.java?view=diff&pathrev=19401&r1=19400&r2=19401
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigRegion.java   
(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigRegion.java   
2011-05-11 07:56:06-0700
@@ -13,9 +13,7 @@
 
 package org.argouml.uml.diagram.state.ui;
 
-import java.awt.Color;
 import java.awt.Dimension;
-import java.awt.Rectangle;
 import org.tigris.gef.presentation.FigRect;
 
 /**
@@ -32,8 +30,8 @@
     public FigRegion(
             final Object region) {
         super(0,0,0,0);
+        setLineWidth(0);
         setOwner(region);
-        setFillColor(Color.red);
     }
     
     /*

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java?view=diff&pathrev=19401&r1=19400&r2=19401
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java   
(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java   
2011-05-11 07:56:06-0700
@@ -16,6 +16,7 @@
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Font;
+import java.awt.Graphics;
 import java.awt.Rectangle;
 import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
@@ -45,7 +46,6 @@
 import org.tigris.gef.presentation.Fig;
 import org.tigris.gef.presentation.FigGroup;
 import org.tigris.gef.presentation.FigRRect;
-import org.tigris.gef.presentation.FigRect;
 import org.tigris.gef.presentation.FigText;
 
 /**
@@ -135,9 +135,9 @@
 
     @Override
     public Selection makeSelection() {
-        return new SelectionState(this);
+        return new SelectionVertex(this);
     }
-
+    
     @Override
     protected Fig createBigPortFig() {
         return new FigRRect(0, 0, 0, 0, LINE_COLOR, FILL_COLOR);
@@ -180,9 +180,9 @@
     }
 
     // Temporary start
-    private static final Color[] COLOR_ARRAY = {
-        Color.RED, Color.BLUE, Color.CYAN, Color.YELLOW, Color.GREEN}; 
-    private int nextColor = 0;
+//    private static final Color[] COLOR_ARRAY = {
+//        Color.RED, Color.BLUE, Color.CYAN, Color.YELLOW, Color.GREEN}; 
+//    private int nextColor = 0;
     // Temporary end
     
     @Override
@@ -202,24 +202,29 @@
                     regionCompartment.getX(), regionCompartment.getY(),
                     rg.getMinimumSize().width, rg.getMinimumSize().height);
             
-            // Temporary start
-            rg.setFillColor(COLOR_ARRAY[nextColor++]);
-            if (nextColor >= COLOR_ARRAY.length) {
-                nextColor = 0;
-            }
+            // Temporary start - colour the regions so that we can see them 
for now
+//            rg.setFillColor(COLOR_ARRAY[nextColor++]);
+//            if (nextColor >= COLOR_ARRAY.length) {
+//                nextColor = 0;
+//            }
             // Temporary end
             
             regionCompartment.addFig(rg);
-            
-            // TODO: After adding a new region resize the node to
-            // include it.
+            setSize(getMinimumSize());
         }
         if (mee instanceof RemoveAssociationEvent) {
             Object oldRegion = mee.getNewValue();
+            for (DiagramElement de : regionCompartment.getDiagramElements()) {
+                if (de.getOwner() == oldRegion) {
+                    regionCompartment.removeFig((Fig) de);
+                    // TODO: After removing a region reset the overall
+                    // size of the node.
+                    renderingChanged();
+                    damage();
+                }
+            }
             LOG.debug("Removing region " + oldRegion);
         }
-        renderingChanged();
-        damage();
     }
 
     /*
@@ -295,6 +300,8 @@
             + nameSize.height
             + getBottomMargin();
 
+        h += regionCompartment.getMinimumSize().height;
+        
         if (getBodyText().getText().length() > 0) {
             h += bodySize.height;
         }
@@ -431,7 +438,7 @@
                 final int x,
                 int y,
                 final int w,
-                final int h) {
+                int h) {
 
             _x = x;
             _y = y;
@@ -442,11 +449,50 @@
                 Fig fig = (Fig) it.next();
                 if (it.hasNext()) {
                     fig.setBounds(x, y, w, fig.getMinimumSize().height);
+                    h -= fig.getMinimumSize().height;
                 } else {
-                    fig.setBounds(x, y, w, h - y);
+                    fig.setBounds(x, y, w, h);
                 }
                 y += fig.getHeight();
             }
         }
+        
+        
+        @Override
+        public Dimension getMinimumSize() {
+            int minWidth = 0;
+            int minHeight = 0;
+            for (Iterator it = getFigs().iterator(); it.hasNext(); ) {
+                Fig fig = (Fig) it.next();
+                minWidth = Math.max(fig.getMinimumSize().width, minWidth);
+                if (it.hasNext()) {
+                    minHeight += fig.getHeight();
+                } else {
+                    minHeight += fig.getMinimumSize().height;
+                }
+            }
+
+            return new Dimension(minWidth, minHeight);
+        }
+        
+        public void paint(Graphics g) {
+            super.paint(g);
+            
+            for (Iterator it = getFigs().iterator(); it.hasNext(); ) {
+                Fig fig = (Fig) it.next();
+                if (it.hasNext()) {
+                    g.setColor(getLineColor());
+                    
+                    drawDashedLine(
+                            g, 1, 
+                            fig.getX(), 
+                            fig.getY() + fig.getHeight(),
+                            fig.getX() + fig.getWidth(),
+                            fig.getY() + fig.getHeight(),
+                            0, new float [] { 5.0f, 5.0f }, 10);            
+                }
+            }
+            
+        }
     }
 }

Added: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/SelectionVertex.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/SelectionVertex.java?view=markup&pathrev=19401
==============================================================================
--- (empty file)
+++ 
trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/SelectionVertex.java 
    2011-05-11 07:56:06-0700
@@ -0,0 +1,43 @@
+/* $Id: $
+ *****************************************************************************
+ * Copyright (c) 2011 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Bob Tarling
+ *****************************************************************************
+ */
+
+package org.argouml.uml.diagram.state.ui;
+
+import java.awt.Graphics;
+
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * A selection for a vertex (which can be an orthogonal state).
+ * This acts the same as its superclass unless the vertex is in fact an
+ * orthogonal state in which case extra handles are painted for moving
+ * the region separators.
+ *
+ * @author Bob Tarling
+ */
+public class SelectionVertex extends SelectionState {
+
+    /**
+     * Construct a new SelectionState for the given Fig.
+     *
+     * @param f The given Fig.
+     */
+    public SelectionVertex(Fig f) {
+       super(f);
+    }
+
+    @Override
+    public void paint(Graphics g) {
+        super.paint(g);
+    }
+}

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

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

Reply via email to