svn commit: r16446 - trunk/src/argouml-app/src/org/argouml/uml/diagram: activity/ui state/ui

Michiel van der Wulp <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2008-12-27 13:41:18-0800
New Revision: 16446

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigActionState.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/UMLActivityDiagram.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigSimpleState.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigState.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigStateVertex.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/UMLStateDiagram.java

Log:
Made the state and activity diagram renderer use the new Fig constructors for some figs.
Made more conform Class diagrams.
Still to do: Comment Edge, other classes that construct Figs, other node Figs.

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigActionState.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigActionState.java?view=diff&pathrev=16446&r1=16445&r2=16446
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigActionState.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigActionState.java	2008-12-27 13:41:18-0800
@@ -36,6 +36,7 @@
 import org.argouml.model.Model;
 import org.argouml.notation.NotationProvider;
 import org.argouml.notation.NotationProviderFactory2;
+import org.argouml.uml.diagram.DiagramSettings;
 import org.argouml.uml.diagram.state.ui.FigStateVertex;
 import org.argouml.uml.diagram.ui.FigMultiLineTextWithBold;
 import org.tigris.gef.graph.GraphModel;
@@ -52,7 +53,7 @@
 
     private static final int HEIGHT = 25;
 
-    private static final int WIDTH = 90;
+    private static final int STATE_WIDTH = 90;
 
     private static final int PADDING = 8;
 
@@ -66,17 +67,59 @@
 
     /**
      * Constructor FigActionState.
+     * 
+     * @deprecated for 0.27.3 by mvw.  Use 
+     * {@link #FigActionState(Object, Rectangle, DiagramSettings)}.
      */
+    @SuppressWarnings("deprecation")
+    @Deprecated
     public FigActionState() {
-        setBigPort(new FigRRect(X0 + 1, Y0 + 1, WIDTH - 2, HEIGHT - 2,
+        initializeActionState();
+    }
+
+    /**
+     * Constructor FigActionState.
+     *
+     * @param gm ignored!
+     * @param node owner
+     * 
+     * @deprecated for 0.27.3 by mvw.  Use 
+     * {@link #FigActionState(Object, Rectangle, DiagramSettings)}.
+     */
+    @SuppressWarnings("deprecation")
+    @Deprecated
+    public FigActionState(@SuppressWarnings("unused") GraphModel gm, Object node) {
+        setOwner(node);
+        initializeActionState();
+    }
+    
+    /**
+     * Constructor used by PGML parser.
+     * 
+     * @param owner the owning UML element
+     * @param bounds rectangle describing bounds
+     * @param settings rendering settings
+     */
+    public FigActionState(Object owner, Rectangle bounds, DiagramSettings settings) {
+        super(owner, bounds, settings);
+        initializeActionState();
+    }
+
+    private void initializeActionState() {
+        
+        setBigPort(new FigRRect(X0 + 1, Y0 + 1, STATE_WIDTH - 2, HEIGHT - 2,
                 Color.cyan, Color.cyan));
         ((FigRRect) getBigPort()).setCornerRadius(getBigPort().getHeight() / 2);
-        cover = new FigRRect(X0, Y0, WIDTH, HEIGHT, Color.black, Color.white);
+        cover = new FigRRect(X0, Y0, STATE_WIDTH, HEIGHT, Color.black, Color.white);
         cover.setCornerRadius(getHeight() / 2);
 
-        // overrule the single-line namefig created by the parent
-        setNameFig(new FigMultiLineTextWithBold(X0 + PADDING, Y0, 
-                WIDTH - PADDING * 2, HEIGHT,
+        // overrule the single-line name-fig created by the parent
+        Rectangle bounds = new Rectangle(X0 + PADDING, Y0, 
+                STATE_WIDTH - PADDING * 2, HEIGHT);
+        setNameFig(new FigMultiLineTextWithBold(
+                getOwner(),
+                bounds,
+                getSettings(),
                 true));
         getNameFig().setText(placeString());
         getNameFig().setBotMargin(7); // make space for the clarifier
@@ -98,17 +141,6 @@
         setBounds(r.x, r.y, r.width, r.height);
     }
 
-    /**
-     * Constructor FigActionState.
-     *
-     * @param gm ignored!
-     * @param node owner
-     */
-    public FigActionState(GraphModel gm, Object node) {
-        this();
-        setOwner(node);
-    }
-
     /*
      * @see org.argouml.uml.diagram.state.ui.FigStateVertex#initNotationProviders(java.lang.Object)
      */

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/UMLActivityDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/UMLActivityDiagram.java?view=diff&pathrev=16446&r1=16445&r2=16446
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/UMLActivityDiagram.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/UMLActivityDiagram.java	2008-12-27 13:41:18-0800
@@ -25,6 +25,7 @@
 package org.argouml.uml.diagram.activity.ui;
 
 import java.awt.Point;
+import java.awt.Rectangle;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyVetoException;
 import java.util.ArrayList;
@@ -43,6 +44,7 @@
 import org.argouml.model.DeleteInstanceEvent;
 import org.argouml.model.Model;
 import org.argouml.ui.CmdCreateNode;
+import org.argouml.uml.diagram.DiagramSettings;
 import org.argouml.uml.diagram.UMLMutableGraphSupport;
 import org.argouml.uml.diagram.activity.ActivityDiagramGraphModel;
 import org.argouml.uml.diagram.state.StateDiagramGraphModel;
@@ -794,11 +796,18 @@
     public FigNode drop(Object droppedObject, Point location) {
         FigNode figNode = null;
         GraphModel gm = getGraphModel();
-        
+
+        // If location is non-null, convert to a rectangle that we can use
+        Rectangle bounds = null;
+        if (location != null) {
+            bounds = new Rectangle(location.x, location.y, 0, 0);
+        }
+        DiagramSettings settings = getDiagramSettings();
+
         if (Model.getFacade().isAPartition(droppedObject)) {
             figNode = new FigPartition(gm, droppedObject);
         } else if (Model.getFacade().isAActionState(droppedObject)) {
-            figNode = new FigActionState(gm, droppedObject);
+            figNode = new FigActionState(droppedObject, bounds, settings);
         } else if (Model.getFacade().isACallState(droppedObject)) {
             figNode = new FigCallState(gm, droppedObject);
         } else if (Model.getFacade().isAObjectFlowState(droppedObject)) {

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigSimpleState.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigSimpleState.java?view=diff&pathrev=16446&r1=16445&r2=16446
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigSimpleState.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigSimpleState.java	2008-12-27 13:41:18-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -29,6 +29,7 @@
 import java.awt.Rectangle;
 import java.util.Iterator;
 
+import org.argouml.uml.diagram.DiagramSettings;
 import org.tigris.gef.graph.GraphModel;
 import org.tigris.gef.presentation.FigLine;
 import org.tigris.gef.presentation.FigRRect;
@@ -46,45 +47,70 @@
     private FigLine divider;
 
     /**
-     * The main constructor
+     * The main constructor.
+     * 
+     * @deprecated for 0.27.3 by mvw.  Use 
+     * {@link #FigSimpleState(Object, Rectangle, DiagramSettings)}.
      */
+    @SuppressWarnings("deprecation")
+    @Deprecated
     public FigSimpleState() {
-	cover =
-	    new FigRRect(getInitialX(), getInitialY(),
-			 getInitialWidth(), getInitialHeight(),
-			 Color.black, Color.white);
-
-	getBigPort().setLineWidth(0);
-
-	divider =
-	    new FigLine(getInitialX(),
-			getInitialY() + 2 + getNameFig().getBounds().height + 1,
-			getInitialWidth() - 1,
-			getInitialY() + 2 + getNameFig().getBounds().height + 1,
-			Color.black);
-
-	// add Figs to the FigNode in back-to-front order
-	addFig(getBigPort());
-	addFig(cover);
-	addFig(getNameFig());
-	addFig(divider);
-	addFig(getInternal());
-
-	//setBlinkPorts(false); //make port invisble unless mouse enters
-	Rectangle r = getBounds();
-	setBounds(r.x, r.y, r.width, r.height);
+        initializeSimpleState();
     }
 
     /**
      * The constructor that hooks into an existing UML element
      * @param gm ignored
      * @param node the UML element
-     */
-    public FigSimpleState(GraphModel gm, Object node) {
+     * 
+     * @deprecated for 0.27.3 by mvw.  Use 
+     * {@link #FigSimpleState(Object, Rectangle, DiagramSettings)}.
+     */
+    @SuppressWarnings("deprecation")
+    @Deprecated
+    public FigSimpleState(@SuppressWarnings("unused") GraphModel gm, Object node) {
 	this();
 	setOwner(node);
     }
 
+    /**
+     * Constructor used by PGML parser.
+     * 
+     * @param owner the owning UML element
+     * @param bounds rectangle describing bounds
+     * @param settings rendering settings
+     */
+    public FigSimpleState(Object owner, Rectangle bounds, DiagramSettings settings) {
+        super(owner, bounds, settings);
+        initializeSimpleState();
+    }
+
+    private void initializeSimpleState() {
+        cover =
+            new FigRRect(getInitialX(), getInitialY(),
+                         getInitialWidth(), getInitialHeight(),
+                         Color.black, Color.white);
+
+        getBigPort().setLineWidth(0);
+
+        divider =
+            new FigLine(getInitialX(),
+                        getInitialY() + 2 + getNameFig().getBounds().height + 1,
+                        getInitialWidth() - 1,
+                        getInitialY() + 2 + getNameFig().getBounds().height + 1,
+                        Color.black);
+
+        // add Figs to the FigNode in back-to-front order
+        addFig(getBigPort());
+        addFig(cover);
+        addFig(getNameFig());
+        addFig(divider);
+        addFig(getInternal());
+
+        //setBlinkPorts(false); //make port invisble unless mouse enters
+        Rectangle r = getBounds();
+        setBounds(r.x, r.y, r.width, r.height);
+    }
 
     @Override
     public Object clone() {

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigState.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigState.java?view=diff&pathrev=16446&r1=16445&r2=16446
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigState.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigState.java	2008-12-27 13:41:18-0800
@@ -26,6 +26,7 @@
 
 import java.awt.Color;
 import java.awt.Font;
+import java.awt.Rectangle;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyVetoException;
 
@@ -34,6 +35,7 @@
 import org.argouml.model.Model;
 import org.argouml.notation.NotationProvider;
 import org.argouml.notation.NotationProviderFactory2;
+import org.argouml.uml.diagram.DiagramSettings;
 import org.tigris.gef.graph.GraphModel;
 import org.tigris.gef.presentation.FigRRect;
 import org.tigris.gef.presentation.FigText;
@@ -67,9 +69,45 @@
 
     /**
      * Constructor for FigState.
+     * 
+     * @deprecated for 0.27.3 by mvw.  Use 
+     * {@link #FigState(Object, Rectangle, DiagramSettings)}.
      */
+    @SuppressWarnings("deprecation")
+    @Deprecated
     public FigState() {
         super();
+        initializeState();
+    }
+
+    /**
+     * Constructor for FigState, used when an UML elm already exists.
+     *
+     * @param gm ignored
+     * @param node the UML element
+     * 
+     * @deprecated for 0.27.3 by mvw.  Use 
+     * {@link #FigState(Object, Rectangle, DiagramSettings)}.
+     */
+    @Deprecated
+    public FigState(@SuppressWarnings("unused") GraphModel gm, Object node) {
+        this();
+        setOwner(node);
+    }
+
+    /**
+     * Constructor used by PGML parser.
+     * 
+     * @param owner the owning UML element
+     * @param bounds rectangle describing bounds
+     * @param settings rendering settings
+     */
+    public FigState(Object owner, Rectangle bounds, DiagramSettings settings) {
+        super(owner, bounds, settings);
+        initializeState();
+    }
+
+    private void initializeState() {
         setBigPort(new FigRRect(getInitialX() + 1, getInitialY() + 1,
                 getInitialWidth() - 2, getInitialHeight() - 2,
                 Color.cyan, Color.cyan));
@@ -93,20 +131,11 @@
         internal.setJustification(FigText.JUSTIFY_LEFT);
     }
 
-    /**
-     * Constructor for FigState, used when an UML elm already exists.
-     *
-     * @param gm ignored
-     * @param node the UML element
-     */
-    public FigState(GraphModel gm, Object node) {
-        this();
-        setOwner(node);
-    }
-
     /*
      * @see org.tigris.gef.presentation.Fig#setOwner(java.lang.Object)
      */
+    @SuppressWarnings("deprecation")
+    @Deprecated
     @Override
     public void setOwner(Object newOwner) {
         super.setOwner(newOwner);

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigStateVertex.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigStateVertex.java?view=diff&pathrev=16446&r1=16445&r2=16446
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigStateVertex.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigStateVertex.java	2008-12-27 13:41:18-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -25,11 +25,13 @@
 package org.argouml.uml.diagram.state.ui;
 
 import java.awt.Point;
+import java.awt.Rectangle;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
 import org.argouml.model.Model;
+import org.argouml.uml.diagram.DiagramSettings;
 import org.argouml.uml.diagram.activity.ui.SelectionActionState;
 import org.argouml.uml.diagram.ui.FigNodeModelElement;
 import org.tigris.gef.base.Editor;
@@ -43,14 +45,18 @@
 import org.tigris.gef.presentation.FigNode;
 
 /**
- * Abstract class to with common behavior for nestable nodes in UML Statechart
- * diagrams.
+ * Abstract class for a State Vertex 
+ * which has behavior for nestable nodes in UML Statechart diagrams.
  */
 public abstract class FigStateVertex extends FigNodeModelElement {
 
     /**
      * The main constructor
+     * @deprecated for 0.27.3 by mvw.  Use 
+     * {@link #FigStateVertex(Object, Rectangle, DiagramSettings)}.
      */
+    @SuppressWarnings("deprecation")
+    @Deprecated
     public FigStateVertex() {
         this.allowRemoveFromDiagram(false);
     }
@@ -62,14 +68,30 @@
      *            ignored
      * @param node
      *            the UML elm
+     * @deprecated for 0.27.3 by mvw.  Use 
+     * {@link #FigStateVertex(Object, Rectangle, DiagramSettings)}.
      */
-    public FigStateVertex(GraphModel gm, Object node) {
+    @SuppressWarnings("deprecation")
+    @Deprecated
+    public FigStateVertex(@SuppressWarnings("unused") GraphModel gm, Object node) {
         this();
         setOwner(node);
     }
 
+    /**
+     * Constructor used by PGML parser.
+     * 
+     * @param owner the owning UML element
+     * @param bounds rectangle describing bounds
+     * @param settings rendering settings
+     */
+    public FigStateVertex(Object owner, Rectangle bounds, DiagramSettings settings) {
+        super(owner, bounds, settings);
+        this.allowRemoveFromDiagram(false);
+    }
+
     /*
-     * Overriden to make it possible to include a statevertex in a composite
+     * Overridden to make it possible to include a stateVertex in a composite
      * state.
      * @see org.tigris.gef.presentation.Fig#setEnclosingFig(org.tigris.gef.presentation.Fig)
      */
@@ -162,7 +184,7 @@
      * Return a list of gravity points around circle which is enclosed
      * in the bounding box.  Convenience method for use by FigInitialState
      * and FigFinalState.
-     * TODO: As this method is not required by all sub classes then should we
+     * TODO: As this method is not required by all sub classes,
      * it would seem sensible to extend FigStateVertex with FigCircleVertex
      * and only have the relevant concrete Figs extend that and gain this
      * functionality.

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/UMLStateDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/UMLStateDiagram.java?view=diff&pathrev=16446&r1=16445&r2=16446
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/UMLStateDiagram.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/UMLStateDiagram.java	2008-12-27 13:41:18-0800
@@ -25,6 +25,7 @@
 package org.argouml.uml.diagram.state.ui;
 
 import java.awt.Point;
+import java.awt.Rectangle;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyVetoException;
 import java.util.Collection;
@@ -38,6 +39,7 @@
 import org.argouml.model.Model;
 import org.argouml.ui.CmdCreateNode;
 import org.argouml.uml.diagram.DiagramFactory;
+import org.argouml.uml.diagram.DiagramSettings;
 import org.argouml.uml.diagram.UMLMutableGraphSupport;
 import org.argouml.uml.diagram.activity.ui.FigActionState;
 import org.argouml.uml.diagram.state.StateDiagramGraphModel;
@@ -756,9 +758,16 @@
     public FigNode drop(Object droppedObject, Point location) {
         FigNode figNode = null;
         GraphModel gm = getGraphModel();
-        
+
+        // If location is non-null, convert to a rectangle that we can use
+        Rectangle bounds = null;
+        if (location != null) {
+            bounds = new Rectangle(location.x, location.y, 0, 0);
+        }
+        DiagramSettings settings = getDiagramSettings();
+
         if (Model.getFacade().isAActionState(droppedObject)) {
-            figNode = new FigActionState(gm, droppedObject);
+            figNode = new FigActionState(droppedObject, bounds, settings);
         } else if (Model.getFacade().isAFinalState(droppedObject)) {
             figNode = new FigFinalState(gm, droppedObject);
         } else if (Model.getFacade().isAStubState(droppedObject)) {

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

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.