svn commit: r16601 - trunk/src/argouml-app/src/org/argouml: ui uml/diagram/ui

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2009-01-14 12:05:14-0800
New Revision: 16601

Added:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StereotypeStyled.java   (contents, props changed)
Modified:
   trunk/src/argouml-app/src/org/argouml/ui/StylePanelFig.java
   trunk/src/argouml-app/src/org/argouml/ui/StylePanelFigNodeModelElement.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionEdgeClarifiers.java

Log:
Issue 4789: Missing pieces of commit. Use interfaces to reduce dependencies.

Modified: trunk/src/argouml-app/src/org/argouml/ui/StylePanelFig.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/StylePanelFig.java?view=diff&pathrev=16601&r1=16600&r2=16601
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/StylePanelFig.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/StylePanelFig.java	2009-01-14 12:05:14-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2003-2008 The Regents of the University of California. All
+// Copyright (c) 2003-2009 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
@@ -46,6 +46,7 @@
 import org.argouml.uml.diagram.ui.ArgoFig;
 import org.argouml.uml.diagram.ui.FigEdgeModelElement;
 import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.uml.diagram.ui.StereotypeStyled;
 import org.argouml.util.ArgoFrame;
 import org.tigris.gef.presentation.Fig;
 import org.tigris.gef.ui.ColorRenderer;
@@ -271,6 +272,7 @@
 
         if (target.getLineWidth() > 0) {
             Color c = target.getLineColor();
+            // TODO: This is going to cause the color to be reset on a refresh
             lineField.setSelectedItem(c);
             if (c != null && !lineField.getSelectedItem().equals(c)) {
                 lineField.insertItemAt(c, lineField.getItemCount() - 1);
@@ -280,11 +282,11 @@
             lineField.setSelectedIndex(0);
         }
 
-        stereoField.setEnabled(target instanceof FigNodeModelElement);
-        stereoLabel.setEnabled(target instanceof FigNodeModelElement);
+        stereoField.setEnabled(target instanceof StereotypeStyled);
+        stereoLabel.setEnabled(target instanceof StereotypeStyled);
         
-        if (target instanceof FigNodeModelElement) {
-            FigNodeModelElement fig = (FigNodeModelElement) target;
+        if (target instanceof StereotypeStyled) {
+            StereotypeStyled fig = (StereotypeStyled) target;
             stereoField.setSelectedIndex(fig.getStereotypeStyle().ordinal());
         }
     }
@@ -494,12 +496,12 @@
                 }
                 setTargetLine();
             } else if (src == stereoField) {
-                if (target instanceof FigNodeModelElement) {
+                if (target instanceof StereotypeStyled) {
                     Object item = e.getItem();
                     DefaultComboBoxModel model = 
                         (DefaultComboBoxModel) stereoField.getModel();
                     int idx = model.getIndexOf(item);
-                    FigNodeModelElement fig = (FigNodeModelElement) target;
+                    StereotypeStyled fig = (StereotypeStyled) target;
 
                     fig.setStereotypeStyle(StereotypeStyle.getEnum(idx));
 

Modified: trunk/src/argouml-app/src/org/argouml/ui/StylePanelFigNodeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/StylePanelFigNodeModelElement.java?view=diff&pathrev=16601&r1=16600&r2=16601
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/StylePanelFigNodeModelElement.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/StylePanelFigNodeModelElement.java	2009-01-14 12:05:14-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2009 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
@@ -169,4 +169,5 @@
         }
     }
 
-} /* end class StylePanelFigNodeModelElement */
+}
+

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java?view=diff&pathrev=16601&r1=16600&r2=16601
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java	2009-01-14 12:05:14-0800
@@ -123,7 +123,8 @@
         ArgoDiagramAppearanceEventListener,
         Highlightable,
         IItemUID,
-        ArgoFig {
+        ArgoFig,
+        Clarifiable {
 
     private static final Logger LOG =
         Logger.getLogger(FigEdgeModelElement.class);
@@ -197,6 +198,7 @@
      */
     protected FigEdgeModelElement(Object element, 
             DiagramSettings renderSettings) {
+        super();
         // TODO: We don't have any settings that can change per-fig currently
         // so we can just use the default settings;
 //        settings = new DiagramSettings(renderSettings);
@@ -421,7 +423,7 @@
     /**
      * @param g the <code>Graphics</code> object
      */
-    protected void paintClarifiers(Graphics g) {
+    public void paintClarifiers(Graphics g) {
         int iconPos = 25, gap = 1, xOff = -4, yOff = -4;
         Point p = new Point();
         ToDoList tdList = Designer.theDesigner().getToDoList();
@@ -1165,6 +1167,8 @@
     @Override
     public final void removeFromDiagram() {
         Fig delegate = getRemoveDelegate();
+        // TODO: Dependency cycle between FigNodeModelElement and FigEdgeME
+        // Is this needed?  If so, introduce a Removable interface to decouple
         if (delegate instanceof FigNodeModelElement) {
             ((FigNodeModelElement) delegate).removeFromDiagramImpl();
         } else if (delegate instanceof FigEdgeModelElement) {
@@ -1657,4 +1661,20 @@
     protected NotationSettings getNotationSettings() {
         return getSettings().getNotationSettings();
     }
+    
+//    public void setLineWidth(int w) {
+//        super.setLineWidth(w);
+//    }
+    
+    public void setLineColor(Color c) {
+        super.setLineColor(c);
+    }
+    
+    public void setFig(Fig f) {
+        super.setFig(f);
+        // GEF sets a different Fig than the one that we had at construction
+        // time, so we need to set its color and width
+        f.setLineColor(getLineColor());
+        f.setLineWidth(getLineWidth());
+    }
 }

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java?view=diff&pathrev=16601&r1=16600&r2=16601
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java	2009-01-14 12:05:14-0800
@@ -131,7 +131,8 @@
         Highlightable,
         IItemUID,
         Clarifiable,
-        ArgoFig {
+        ArgoFig,
+        StereotypeStyled {
 
 
     private static final Logger LOG =
@@ -150,6 +151,20 @@
      */
     protected static final int WIDTH = 64;
 
+    /**
+     * The default minimum height of the name fig, computed to allow room for
+     * the Critics "clarifiers" (red squiggly line) with the default font. This
+     * should really go away and be managed internally to the name figs and
+     * fetched through getMinimumSize(). The final height can change based on
+     * the font selected.
+     */
+    protected static final int NAME_FIG_HEIGHT = 21;
+    
+    /**
+     * Padding to be used above and below the name.
+     */
+    protected static final int NAME_V_PADDING = 2;
+    
     private DiElement diElement;
 
     private NotationProvider notationProviderName;
@@ -312,8 +327,8 @@
         // is inside it:
         bigPort = new FigRect(X0, Y0, 0, 0, DEBUG_COLOR, DEBUG_COLOR);
         
-        nameFig = new FigNameWithAbstractAndBold(X0, Y0, WIDTH, 21, true);
-        stereotypeFig = new FigStereotypesGroup(X0, Y0, WIDTH, 15);
+        nameFig = new FigNameWithAbstractAndBold(X0, Y0, WIDTH, NAME_FIG_HEIGHT, true);
+        stereotypeFig = new FigStereotypesGroup(X0, Y0, WIDTH, STEREOHEIGHT);
         constructFigs();
     }
     
@@ -323,7 +338,6 @@
      */
     private void constructFigs() {
         // TODO: Why isn't this stuff managed by the nameFig itself?
-        nameFig.setLineWidth(LINE_WIDTH);
         nameFig.setFilled(true);
         nameFig.setText(placeString());
         nameFig.setBotMargin(7); // make space for the clarifier
@@ -399,7 +413,7 @@
         // is inside it:
         bigPort = new FigRect(X0, Y0, 0, 0, DEBUG_COLOR, DEBUG_COLOR);
         nameFig = new FigNameWithAbstractAndBold(element, 
-                new Rectangle(X0, Y0, WIDTH, 21), getSettings(), true);
+                new Rectangle(X0, Y0, WIDTH, NAME_FIG_HEIGHT), getSettings(), true);
         stereotypeFig = new FigStereotypesGroup(element, 
                 new Rectangle(X0, Y0, WIDTH, STEREOHEIGHT), settings);
         constructFigs();
@@ -2277,7 +2291,8 @@
     }
     
     /**
-     * @return the rendering style for stereotypes
+     * @return
+     * @see org.argouml.uml.diagram.ui.StereotypeStyled#getStereotypeStyle()
      */
     public StereotypeStyle getStereotypeStyle() {
         return stereotypeStyle;
@@ -2487,6 +2502,13 @@
     protected NotationSettings getNotationSettings() {
         return notationSettings;
     }
+
+    public void setLineWidth(int w) {
+        super.setLineWidth(w);
+        // Default for name and stereotype is no border
+        getNameFig().setLineWidth(0);
+        getStereotypeFig().setLineWidth(0);
+    }
     
     /**
      * A default "clarifier" to be used for selection if the subclass doesn't

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionEdgeClarifiers.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionEdgeClarifiers.java?view=diff&pathrev=16601&r1=16600&r2=16601
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionEdgeClarifiers.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SelectionEdgeClarifiers.java	2009-01-14 12:05:14-0800
@@ -28,7 +28,6 @@
 
 import org.tigris.gef.base.Globals;
 import org.tigris.gef.base.PathItemPlacementStrategy;
-import org.tigris.gef.base.SelectionManager;
 import org.tigris.gef.base.SelectionReshape;
 import org.tigris.gef.presentation.Fig;
 import org.tigris.gef.presentation.FigEdge;
@@ -41,11 +40,10 @@
  */
 public class SelectionEdgeClarifiers extends SelectionReshape {
 
-    ////////////////////////////////////////////////////////////////
-    // constructors
 
-    /** Construct a new SelectionEdgeClarifiers for the given Fig
-     *
+    /**
+     * Construct a new SelectionEdgeClarifiers for the given Fig
+     * 
      * @param f the given fig
      */
     public SelectionEdgeClarifiers(Fig f) { super(f); }
@@ -62,10 +60,12 @@
     public void paint(Graphics g) {
         super.paint(g);
         int selectionCount =
-            Globals.curEditor().getSelectionManager().selections().size();
+            Globals.curEditor().getSelectionManager().getSelections().size();
         if (selectionCount == 1) {
-            FigEdgeModelElement edge = (FigEdgeModelElement) getContent();
-            edge.paintClarifiers(g);
+            FigEdge edge = (FigEdge) getContent();
+            if (edge instanceof Clarifiable) {
+                ((Clarifiable) edge).paintClarifiers(g);
+            }
 	    for (PathItemPlacementStrategy strategy
 	            : edge.getPathItemStrategies()) {
 	        strategy.paint(g);
@@ -73,5 +73,4 @@
 	}
     }
 
-} /* end class SelectionEdgeClarifiers */
-
+}

Added: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StereotypeStyled.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StereotypeStyled.java?view=markup&pathrev=16601
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/StereotypeStyled.java	2009-01-14 12:05:14-0800
@@ -0,0 +1,49 @@
+// $Id$
+// Copyright (c) 2009 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.uml.diagram.ui;
+
+import org.argouml.uml.diagram.DiagramSettings.StereotypeStyle;
+
+/**
+ * An interface for figs which implement stereotype styles.  It exists
+ * primarily to break a cyclic dependency on Fig*ModelElement.
+ * 
+ * @author Tom Morris <[email protected]>
+ */
+public interface StereotypeStyled {
+
+    /**
+     * @return the rendering style for stereotypes
+     */
+    public abstract StereotypeStyle getStereotypeStyle();
+
+    /**
+     * Set the stereotype style to be used for rendering this fig.
+     * 
+     * @param style the stereotype style to be set
+     */
+    public abstract void setStereotypeStyle(StereotypeStyle style);
+
+}
\ No newline at end of file

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

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.