svn commit: r16607 - trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2009-01-15 10:36:34-0800
New Revision: 16607

Modified:
   trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigActivation.java
   trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigClassifierRole.java
   trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigHead.java
   trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigLifeLine.java
   trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigMessage.java
   trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/SequenceDiagramRenderer.java

Log:
Issue 5500 - Update sequence diag figs to new constructors.  Based on Christian's (penyaskito) patch.  Also make sure figs set colors and line widths where needed.

Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigActivation.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigActivation.java?view=diff&pathrev=16607&r1=16606&r2=16607
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigActivation.java	(original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigActivation.java	2009-01-15 10:36:34-0800
@@ -24,30 +24,34 @@
 
 package org.argouml.sequence2.diagram;
 
-import org.tigris.gef.presentation.FigGroup;
+import org.argouml.uml.diagram.ui.ArgoFigGroup;
 import org.tigris.gef.presentation.FigRect;
 
 /**
- *
+ * TODO: Document!
+ * 
  * @author penyaskito
  */
-class FigActivation extends FigGroup {
-
-    
-    private FigRect rectFig;
-    private FigDestroy destroyFig;
+class FigActivation extends ArgoFigGroup {
     
     static final int DEFAULT_HEIGHT = 40;
     static final int DEFAULT_WIDTH = 20;
     
+    private FigRect rectFig;
+    private FigDestroy destroyFig;
+
+    
     /**
+     * TODO: Document!
+     * 
      * @param x
      * @param y
      * @param destroy 
      */
     public FigActivation(int x, int y, boolean destroy) {
         rectFig = new FigRect(x - DEFAULT_WIDTH / 2, y,
-                DEFAULT_WIDTH, DEFAULT_HEIGHT);
+                DEFAULT_WIDTH, DEFAULT_HEIGHT, LINE_COLOR, FILL_COLOR);
+        rectFig.setLineWidth(LINE_WIDTH);
         addFig(rectFig);
         setDestroy(destroy);
     }

Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigClassifierRole.java?view=diff&pathrev=16607&r1=16606&r2=16607
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigClassifierRole.java	(original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigClassifierRole.java	2009-01-15 10:36:34-0800
@@ -34,6 +34,7 @@
 import org.apache.log4j.Logger;
 import org.argouml.model.Model;
 import org.argouml.notation.NotationProviderFactory2;
+import org.argouml.uml.diagram.DiagramSettings;
 import org.argouml.uml.diagram.ui.FigEmptyRect;
 import org.argouml.uml.diagram.ui.FigNodeModelElement;
 import org.tigris.gef.base.Geometry;
@@ -48,11 +49,7 @@
  */
 public class FigClassifierRole extends FigNodeModelElement {
 
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-        Logger.getLogger(FigClassifierRole.class);
+    private static final Logger LOG = Logger.getLogger(FigClassifierRole.class);
 
     /**
      * This is an empty rectangle placed above HeadFig. It creates a space
@@ -81,24 +78,63 @@
     
     /**
      * Constructor 
+     * @deprecated for 0.28.alpha3 by penyaskito. Use
+     *           {@link #FigClassifierRole(Object, Rectangle, DiagramSettings)}.
      */
     public FigClassifierRole() {
         super();
+        initialize();
+    }
+
+    /**
+     * Constructor.
+     * @param node The model element
+     * @deprecated for 0.28.alpha3 by penyaskito. Use
+     *           {@link #FigClassifierRole(Object, Rectangle, DiagramSettings)}.
+
+     */
+    public FigClassifierRole(Object node) {
+        this();
+        setOwner(node);
+    }
+    
+    /**
+     * Construct a use case figure with the given owner, bounds, and rendering 
+     * settings.  This constructor is used by the PGML parser.
+     * 
+     * @param owner owning model element
+     * @param bounds position and size
+     * @param settings rendering settings
+     */
+    public FigClassifierRole(Object owner, Rectangle bounds,
+            DiagramSettings settings) {
+        super(owner, bounds, settings);
+        initialize();
+        if (bounds != null) {
+            setLocation(bounds.x, bounds.y);
+        }
+    }
+    
+    /**
+     * Initialization which is common to multiple constructors.
+     */
+    private void initialize() {
         setBigPort(new FigClassifierRolePort());
         
         emptyFig = new FigEmptyRect(getX(), getY(), getWidth(), offset);
+        emptyFig.setLineWidth(0);
         
         headFig = new FigHead(getStereotypeFig(), getNameFig());
         headFig.setBounds(getX(), getY() + offset,
                 getWidth(), headFig.getHeight());
+        
         lifeLineFig = new FigLifeLine(headFig.getX(), 
-                getY() + offset + headFig.getHeight());
+                getY() + offset + headFig.getHeight() - getLineWidth());
         
         addFig(getBigPort());        
         getBigPort().setVisible(false);
-        
-        emptyFig.setLineWidth(0);
-        
+
+        // TODO: Move magic number 10 to descriptive constant
         minimumHeight = headFig.getMinimumHeight() + 10;
         
         addFig(emptyFig);        
@@ -109,15 +145,6 @@
     }
 
     /**
-     * Constructor.
-     * @param node The model element
-     */
-    public FigClassifierRole(Object node) {
-        this();
-        setOwner(node);
-    }
-
-    /**
      * The NotationProvider for the ClassifierRole. <p>
      * 
      * The syntax is for UML is:
@@ -130,7 +157,7 @@
      * See ClassifierRoleNotationUml for details.<p>
      *
      * This syntax is compatible with the UML 1.4 specification.
-     * 
+     * @return TYPE_CLASSIFIERROLE
      */
     @Override
     protected int getNotationProviderType() {
@@ -147,7 +174,8 @@
         
         emptyFig.setBounds(x, y, ww, offset);
         headFig.setBounds(x, y + offset, ww, headFig.getMinimumHeight());
-        lifeLineFig.setBounds(x, y + offset + headFig.getHeight(),
+        lifeLineFig.setBounds(x, 
+                y + offset + headFig.getHeight() - lifeLineFig.getLineWidth(), 
                 ww, h - offset - headFig.getHeight());
         getBigPort().setBounds(x, y, ww, h);
 
@@ -164,6 +192,8 @@
      */
     public void superTranslate(int dx, int dy) {
         setBounds(getX() + dx, getY(), getWidth(), getHeight());
+        // TODO: Wouldn't the following be simpler?
+//        super.superTranslate(dx, 0);
     }
      
     /**
@@ -200,13 +230,17 @@
     }
     
     /**
-     * Gets the minimum size of the Fig<br>
+     * Gets the minimum size of the Fig.<p>
+     * 
      * The width is restricted by the notation making sure that the full
-     * classifier role description is displayed.<br>
+     * classifier role description is displayed.<p>
+     * 
      * The minimum height is restricted so that the all attached message will
      * remain in the same position relative to the Fig. If no messages are
      * attached then the minimum height will ensure box is shown plus at least
      * 10 pixels of the lifeline.
+     * 
+     * @return dimensions of the minimum size
      */
     public Dimension getMinimumSize() {       
          /**
@@ -235,6 +269,7 @@
         // TODO: Is this next line safe? What happens if there is just one
         // comment edge or a comment edge and a single message?
         if (figsEdges.size() == 1 && createMessage != null) {
+            // TODO: Move magic number 10 to descriptive constant
             minimumHeight = headFig.getMinimumSize().height + offset + 10;
         } else {
             for (Fig fig : figsEdges) {
@@ -246,6 +281,7 @@
                     yMax = ((FigMessage) fig).getY();
                 }
             }
+            // TODO: Move magic number 10 to descriptive constant
             minimumHeight = yMax - getY() + 10;
         }
     }

Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigHead.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigHead.java?view=diff&pathrev=16607&r1=16606&r2=16607
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigHead.java	(original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigHead.java	2009-01-15 10:36:34-0800
@@ -24,6 +24,7 @@
 
 package org.argouml.sequence2.diagram;
 
+import java.awt.Color;
 import java.awt.Dimension;
 
 import org.argouml.uml.diagram.ui.ArgoFigGroup;
@@ -43,17 +44,23 @@
     /**
      * Constructor.
      *
-     * @param stereotypeFigure
-     * @param nameFigure
+     * @param stereotypeFigure the stereotype fig
+     * @param nameFigure the name fig
      */
+    // TODO: Define a constructor which doesn't use deprecated super constructor
     FigHead(Fig stereotypeFigure, FigText nameFigure) {
         this.stereotypeFig = stereotypeFigure;
         this.nameFig = nameFigure;
+        
+        nameFig.setFilled(false);
+        nameFig.setLineWidth(0);
+        
         rectFig =
             new FigRect(0, 0,
                 DEFAULT_WIDTH,
                 DEFAULT_HEIGHT,
                 LINE_COLOR, FILL_COLOR);
+        rectFig.setLineWidth(LINE_WIDTH);
         addFig(rectFig);
         addFig(nameFig);
         addFig(stereotypeFig);
@@ -76,9 +83,7 @@
                     stereotypeFig.getMinimumSize().height);
             yy += stereotypeFig.getMinimumSize().height;
         }
-        nameFig.setFilled(false);
-        nameFig.setLineWidth(0);
-        nameFig.setTextColor(TEXT_COLOR);
+
         nameFig.setBounds(x, yy, w, nameFig.getHeight());
         _x = x;
         _y = y;
@@ -93,9 +98,11 @@
     
     int getMinimumHeight() {
         int h = stereotypeFig.getMinimumSize().height
+        // TODO: Move the magic number 4 to a descriptive constant
             + nameFig.getMinimumHeight() + 4;
-        if (h < DEFAULT_HEIGHT)
+        if (h < DEFAULT_HEIGHT) {
             h = DEFAULT_HEIGHT;
+        }
         return h;
     }
     
@@ -119,4 +126,12 @@
     public void setLineWidth(int w) {
         rectFig.setLineWidth(w);
     }
+    
+    public void setFillColor(Color c) {
+        rectFig.setFillColor(c);
+    }
+    
+    public void setLineColor(Color c) {
+        rectFig.setLineColor(c);
+    }
 }

Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigLifeLine.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigLifeLine.java?view=diff&pathrev=16607&r1=16606&r2=16607
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigLifeLine.java	(original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigLifeLine.java	2009-01-15 10:36:34-0800
@@ -59,7 +59,7 @@
      */
     FigLifeLine(int x, int y) {
         super();
-       
+
         activations = new LinkedList<FigActivation>();
         stackedActivations = new LinkedList<FigActivation>();
         
@@ -68,7 +68,8 @@
         rectFig.setLineWidth(0);
         lineFig = new FigLine(x + WIDTH / 2, y, 
                 x + WIDTH / 2, y + HEIGHT, LINE_COLOR);
-        lineFig.setDashed(true);       
+        lineFig.setDashed(true);
+        lineFig.setLineWidth(LINE_WIDTH);
         
         addFig(rectFig);
         addFig(lineFig);
@@ -83,15 +84,9 @@
         stackedActivations = createStackedActivations(messages);
         
         for (FigActivation figAct : activations) {
-            // TODO: shouldn't this be done in creation, and
-            // with the info from DiagramSettings?
-            figAct.setFillColor(getFillColor());
             addFig(figAct);
         }
         for (FigActivation figAct : stackedActivations) {
-            // TODO: shouldn't this be done in creation, and
-            // with the info from DiagramSettings?
-            figAct.setFillColor(getFillColor());
             addFig(figAct);
         }       
         calcBounds();
@@ -276,4 +271,12 @@
         calcBounds();        
         firePropChange("bounds", oldBounds, getBounds());
     }
+    
+    public int getLineWidth() {
+        return lineFig.getLineWidth();
+    }
+    
+    public void setLineWidth(int w) {
+        lineFig.setLineWidth(w);
+    }
 }

Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigMessage.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigMessage.java?view=diff&pathrev=16607&r1=16606&r2=16607
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigMessage.java	(original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/FigMessage.java	2009-01-15 10:36:34-0800
@@ -30,11 +30,11 @@
 import org.argouml.model.Model;
 import org.argouml.notation.NotationProviderFactory2;
 import org.argouml.notation.SDNotationSettings;
+import org.argouml.uml.diagram.DiagramSettings;
 import org.argouml.uml.diagram.ui.FigEdgeModelElement;
 import org.argouml.uml.diagram.ui.FigTextGroup;
 import org.tigris.gef.base.PathConvPercent;
 import org.tigris.gef.base.Selection;
-import org.tigris.gef.presentation.ArrowHead;
 import org.tigris.gef.presentation.ArrowHeadGreater;
 import org.tigris.gef.presentation.ArrowHeadTriangle;
 import org.tigris.gef.presentation.Fig;
@@ -48,12 +48,7 @@
 
     private static final long serialVersionUID = -2961220746360335159L;
     private FigTextGroup textGroup; 
-    
-    /**
-     * The arrow head. It depends on the owner attached action. 
-     */
-    private ArrowHead arrowHead;
-    
+
     /**
      * The action owned by the message
      */
@@ -65,17 +60,37 @@
      * Constructs a new figlink and sets the owner of the figlink.
      *
      * @param owner is the owner.
+     * @deprecated for 0.28.alpha3 by penyaskito. Use
+     *             {@link #FigMessage(Object, DiagramSettings)}
      */
     public FigMessage(Object owner) {
         super();
         textGroup = new FigTextGroup();
+        initialize();
+        setOwner(owner);
+    }
+
+    /**
+     * Construct a fig owned by the given UML element with the provided render
+     * settings.
+     * @param edge owning UML element
+     * @param settings rendering settings
+     */
+    public FigMessage(Object edge, DiagramSettings settings) {
+        super(edge, settings);
+        textGroup = new FigTextGroup(edge, settings);
+        initialize();
+        action = Model.getFacade().getAction(getOwner());
+        updateArrow();
+    }
+    
+    private void initialize() {
         textGroup.addFig(getNameFig());
         textGroup.addFig(getStereotypeFig());
         addPathItem(textGroup, new PathConvPercent(this, 50, 10));
         notationSettings = new SDNotationSettings();
-        setOwner(owner);
     }
-    
+        
     @Override
     protected int getNotationProviderType() {
         /* Use a different notation as Messages on a collaboration diagram: */
@@ -110,7 +125,12 @@
         return notationSettings;
     }
 
+    /**
+     * @deprecated for 0.28.alpha3 by penyaskito. Owner must be specified in the
+     * constructor and can't be changed afterwards.
+     */
     @Override
+    @Deprecated
     public void setOwner(Object owner) {       
         super.setOwner(owner);
         action = Model.getFacade().getAction(owner);
@@ -138,30 +158,30 @@
      * to the action type..
      */
     private void updateArrow() {
-	Object action = getAction();
-	if (Model.getFacade().isAReturnAction(action)) {
-	    arrowHead = new ArrowHeadGreater();
+	if (Model.getFacade().isAReturnAction(getAction())) {
+	    setDestArrowHead(new ArrowHeadGreater());
 	    getFig().setDashed(true);
 	}
-	else if (Model.getFacade().isADestroyAction(action)) {
-	    arrowHead = new ArrowHeadGreater();
+	else if (Model.getFacade().isADestroyAction(getAction())) {
+	    setDestArrowHead(new ArrowHeadGreater());
 	    getFig().setDashed(true);
 	}
-	else if (Model.getFacade().isACreateAction(action)) {
-	    arrowHead = new ArrowHeadTriangle();
-	    // dashed it's false by default.
+	else if (Model.getFacade().isACreateAction(getAction())) {
+	    setDestArrowHead(new ArrowHeadTriangle());
+            getFig().setDashed(false);
 	}
-	else if (Model.getFacade().isACallAction(action)) {
-	    arrowHead = new ArrowHeadTriangle();
-	    // dashed it's false by default.
+	else if (Model.getFacade().isACallAction(getAction())) {
+	    setDestArrowHead(new ArrowHeadTriangle());
+            getFig().setDashed(false);
 	}
-
-	setDestArrowHead(arrowHead);
+	getDestArrowHead().setLineColor(getLineColor());
+	getDestArrowHead().setFillColor(getLineColor());
     }
 
     /**
      * Constructor here for saving and loading purposes.
-     *
+     * @deprecated for 0.28.alpha3 by penyaskito. Use
+     *             {@link #FigMessage(Object, DiagramSettings)}
      */
     public FigMessage() {
         this(null);
@@ -191,16 +211,18 @@
     int getFinalY() {
 	int finalY = 0;
         Point[] points = getFig().getPoints();
-        if (points.length > 0)
+        if (points.length > 0) {
             finalY = points[points.length - 1].y;
+        }
         return finalY;
     }    
 
     int getStartY() {
 	int finalY = 0;
         Point[] points = getFig().getPoints();
-        if (points.length > 0)
+        if (points.length > 0) {
             finalY = points[0].y;
+        }
         return finalY;
     }    
 
@@ -242,22 +264,24 @@
     private synchronized void updateActivations() {
 	// we update the activations...
 	FigClassifierRole source = (FigClassifierRole) getSourceFigNode();
-	if (source != null)
+	if (source != null) {
 	    source.createActivations();
+	}
 	
 	// for performance, we check if this is a selfmessage 
 	// if it is, we have just updated the activations
 	if (!isSelfMessage()) {
 	    FigClassifierRole dest = (FigClassifierRole) getDestFigNode();
-	    if (dest != null)
+	    if (dest != null) {
 		dest.createActivations();
+	    }
 	}
     }
 
     @Override
     public void setLineColor(Color c) {
     	super.setLineColor(c);
-    	arrowHead.setFillColor(c);
+    	getDestArrowHead().setFillColor(c);
     }
 
     @Override
@@ -285,7 +309,7 @@
     @Override
     public void translate(int dx, int dy) {
         if (isSelfMessage()) {
-            ((FigMessageSpline)getFig()).translateFig(dx, dy);
+            ((FigMessageSpline) getFig()).translateFig(dx, dy);
         }        
         super.translate(dx, dy);
     }

Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/SequenceDiagramRenderer.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/SequenceDiagramRenderer.java?view=diff&pathrev=16607&r1=16606&r2=16607
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/SequenceDiagramRenderer.java	(original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/sequence2/diagram/SequenceDiagramRenderer.java	2009-01-15 10:36:34-0800
@@ -91,7 +91,7 @@
         if (edge instanceof CommentEdge) {
             figEdge = new FigEdgeNote(edge, lay);
         } else if (Model.getFacade().isAMessage(edge)) {
-            figEdge = new FigMessage(edge);
+            figEdge = new FigMessage(edge, settings);
         } else {
             figEdge = getFigEdgeFor(edge, styleAttributes);
         }

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

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.