svn commit: r12764 - branches/gsoc2007/maurelio1234/argouml: ext org/argouml/uml/diagram/ui org/argouml/uml/profile

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2007-06-05 18:34:08-0700
New Revision: 12764

Added:
   branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigProfileIcon.java
Modified:
   branches/gsoc2007/maurelio1234/argouml/ext/profile-javabeans.jar
   branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigNodeModelElement.java
   branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java
   branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java

Log:


Modified: branches/gsoc2007/maurelio1234/argouml/ext/profile-javabeans.jar
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/argouml/ext/profile-javabeans.jar?view=diff&rev=12764&p1=branches/gsoc2007/maurelio1234/argouml/ext/profile-javabeans.jar&p2=branches/gsoc2007/maurelio1234/argouml/ext/profile-javabeans.jar&r1=12763&r2=12764
==============================================================================
Binary files. No diff available.

Modified: branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigNodeModelElement.java?view=diff&rev=12764&p1=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigNodeModelElement.java&p2=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigNodeModelElement.java&r1=12763&r2=12764
==============================================================================
--- branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigNodeModelElement.java	(original)
+++ branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigNodeModelElement.java	2007-06-05 18:34:08-0700
@@ -28,6 +28,7 @@
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Graphics;
+import java.awt.Image;
 import java.awt.Rectangle;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
@@ -46,6 +47,7 @@
 
 import javax.swing.Action;
 import javax.swing.Icon;
+import javax.swing.JComponent;
 import javax.swing.JSeparator;
 import javax.swing.SwingUtilities;
 
@@ -86,13 +88,11 @@
 import org.tigris.gef.base.Editor;
 import org.tigris.gef.base.Globals;
 import org.tigris.gef.base.Layer;
-import org.tigris.gef.base.LayerDiagram;
 import org.tigris.gef.base.LayerPerspective;
 import org.tigris.gef.base.Selection;
 import org.tigris.gef.graph.MutableGraphSupport;
 import org.tigris.gef.presentation.Fig;
 import org.tigris.gef.presentation.FigGroup;
-import org.tigris.gef.presentation.FigImage;
 import org.tigris.gef.presentation.FigNode;
 import org.tigris.gef.presentation.FigRect;
 import org.tigris.gef.presentation.FigText;
@@ -224,30 +224,11 @@
     private Fig stereotypeFig;
 
     /**
-     * Icon used instead of actual figure when provided by some profile
      */
-    private Fig stereotypeIcon;
-
-    /**
-     * Icon used instead of actual figure when provided by some profile
-     */
-    private FigSingleLineText stereotypeIconText;
-
-    /**
-     * Icon used instead of actual figure when provided by some profile
-     */
-    private Fig defaultBigPort;
+    private FigProfileIcon stereotypeFigProfileIcon;
+    
+    private FigText originalNameFig;
     
-    /**
-     * Icon used instead of actual figure when provided by some profile
-     */
-    private boolean showStereotypeIcon = false;
-
-    /**
-     * Icon used instead of actual figure when provided by some profile
-     */
-    private boolean smallStereotype = true;
-
     /**
      * EnclosedFigs are the Figs that are enclosed by this figure. Say that
      * it is a Package then these are the Classes, Interfaces, Packages etc
@@ -295,9 +276,6 @@
         // is inside it:
         bigPort = new FigRect(10, 10, 0, 0, Color.cyan, Color.cyan);
 
-        stereotypeIconText = new FigSingleLineText(0, 0, 0, 0, true);
-	stereotypeIconText.setJustification(FigSingleLineText.JUSTIFY_CENTER);
-	
         nameFig = new FigSingleLineText(10, 10, 90, 21, true);
         nameFig.setLineWidth(1);
         nameFig.setFilled(true);
@@ -338,7 +316,7 @@
         setOwner(element);
         nameFig.setText(placeString());
         readyToEdit = false;
-        setLocation(x, y);        
+        setLocation(x, y);
     }
 
     /*
@@ -1269,7 +1247,7 @@
      * wanted behaviour.
      */
     protected void updateStereotypeText() {
-	if (getOwner() == null) {
+        if (getOwner() == null) {
             LOG.warn("Owner of [" + this.toString() + "/" + this.getClass()
                     + "] is null.");
             LOG.warn("I return...");
@@ -1277,74 +1255,9 @@
         }
 
         Object modelElement = getOwner();
-        stereotypeFig.setOwner(modelElement);        
+        stereotypeFig.setOwner(modelElement);
     }
 
-    protected void updateStereotypeIcon() {
-	System.out.println("UPDATING ICON!");
-	if (getOwner() == null) {
-            LOG.warn("Owner of [" + this.toString() + "/" + this.getClass()
-                    + "] is null.");
-            LOG.warn("I return...");
-            return;
-        }
-
-   	this.removeFig(stereotypeIcon);
-	if (showStereotypeIcon && !smallStereotype) {
-           	this.setBigPort(defaultBigPort);
-	}	
-	
-	showStereotypeIcon = false;	
-        Object modelElement = getOwner();
-        Collection stereos = Model.getFacade().getStereotypes(modelElement);
-
-        if (stereos != null) {
-            FigImage replaceIcon = null;
-            for (Object stereo : stereos) {
-		replaceIcon = ProjectManager.getManager().getCurrentProject()
-			.getProfileConfiguration().getFigNodeStrategy()
-			.getIconForStereotype(stereo);
-		if (replaceIcon != null) {
-		    break;
-		}
-	    }
-            
-            if (replaceIcon != null) {
-        	replaceIcon = (FigImage) replaceIcon.clone();
-        	
-        	if (smallStereotype) {
-        	    stereotypeIcon = replaceIcon;
-        	    stereotypeIcon.setLocation(getBigPort().getWidth() - 40, 2);
-        	    stereotypeIcon.setSize(32, 32);
-        	} else {
-        		stereotypeIconText.setText(getName());
-        		stereotypeIconText.setLocation(0, replaceIcon.getHeight() + 2);
-        		stereotypeIconText.setJustification(FigSingleLineText.JUSTIFY_CENTER);
-                	
-                	stereotypeIcon = new FigGroup();
-        
-                	((FigGroup)stereotypeIcon).addFig(replaceIcon);        	
-                	
-                	defaultBigPort = this.getBigPort();
-        		this.setBigPort(stereotypeIcon);		                	
-                	showStereotypeIcon = true;		
-        	}
-
-        	this.addFig(stereotypeIcon);				
-        	stereotypeIcon.setOwner(getOwner());
-		this.redraw();
-	    }
-        }
-    }
-    
-    public void paint(Graphics g) {
-	if (!showStereotypeIcon) {
-	    super.paint(g);
-	} else {
-	    stereotypeIcon.paint(g);
-	}
-    }
-    
     /**
      * Updates the text of the name FigText.
      */
@@ -1353,14 +1266,6 @@
             if (getOwner() == null) {
                 return;
             }
-            FigText nameFig = null;
-            
-            if (showStereotypeIcon) {
-        	nameFig = stereotypeIconText;
-            } else {
-        	nameFig = this.nameFig;
-            }
-            
             if (notationProviderName != null) {
                 nameFig.setText(notationProviderName.toString(
                         getOwner(), npArguments));
@@ -1510,11 +1415,69 @@
     public void renderingChanged() {
         updateNameText();
         updateStereotypeText();
-        updateStereotypeIcon();
-        updateBounds();        
+        updateStereotypeIcon();        
+        updateBounds();
         damage();
     }
 
+    private void updateStereotypeIcon() {
+	if (getOwner() == null) {
+            LOG.warn("Owner of [" + this.toString() + "/" + this.getClass()
+                    + "] is null.");
+            LOG.warn("I return...");
+            return;
+        }
+
+	if (stereotypeFigProfileIcon != null) {
+	    this.removeFig(stereotypeFigProfileIcon);
+	}	
+	if (originalNameFig != null) {
+		this.setNameFig(originalNameFig);        	    
+	}
+	
+        Object modelElement = getOwner();
+        Collection stereos = Model.getFacade().getStereotypes(modelElement);
+
+        if (stereos != null) {
+            Image replaceIcon = null;
+            for (Object stereo : stereos) {
+		replaceIcon = ProjectManager.getManager().getCurrentProject()
+			.getProfileConfiguration().getFigNodeStrategy()
+			.getIconForStereotype(stereo);
+		if (replaceIcon != null) {
+		    break;
+		}
+	    }
+            
+            if (replaceIcon != null) {        	
+        	stereotypeFigProfileIcon = new FigProfileIcon(replaceIcon, getName());
+            	stereotypeFigProfileIcon.setOwner(getOwner());
+        	this.addFig(stereotypeFigProfileIcon);
+
+        	originalNameFig = this.getNameFig();
+        	this.setNameFig(stereotypeFigProfileIcon.getLabelFig());
+
+        	for (Object fig : getFigs()) {
+		    ((Fig) fig).setVisible(fig==stereotypeFigProfileIcon);
+            	}		
+	    } else {
+		stereotypeFigProfileIcon = null;
+                for (Object fig : getFigs()) {
+		    ((Fig) fig).setVisible(fig!=stereotypeFigProfileIcon);
+            	}
+	    }
+    	    this.redraw();
+        }	
+    }
+
+    protected void setBoundsImpl(int x, int y, int w, int h) {	
+	if (stereotypeFigProfileIcon != null) {
+	    stereotypeFigProfileIcon.setBounds(x, y, w, h);
+	} else {
+	    super.setBoundsImpl(x, y, w, h);
+	}
+    }
+    
     /*
      * @see org.tigris.gef.presentation.Fig#calcBounds()
      */

Added: branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigProfileIcon.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigProfileIcon.java?view=auto&rev=12764
==============================================================================
--- (empty file)
+++ branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/ui/FigProfileIcon.java	2007-06-05 18:34:08-0700
@@ -0,0 +1,75 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $

+// Copyright (c) 2007 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 java.awt.Image;

+

+import org.tigris.gef.presentation.FigGroup;

+import org.tigris.gef.presentation.FigImage;

+import org.tigris.gef.presentation.FigText;

+

+public class FigProfileIcon extends FigGroup {

+

+    private FigImage image = null;

+    

+    private FigText  label = null;

+

+    private static final int GAP = 2;

+    public FigProfileIcon(Image icon, String str) {

+	image = new FigImage(0, 0, icon);

+	label = new FigSingleLineText(0, image.getHeight()+GAP, 0, 0, true);	

+	label.setText(str);

+	label.calcBounds();

+	

+	addFig(image);

+	addFig(label);

+

+	image.setResizable(false);

+	image.setLocked(true);

+    }

+        

+    protected void setBoundsImpl(int x, int y, int w, int h) {	

+	int width = Math.max(image.getWidth(), label.getWidth());

+	

+	image.setLocation(x + (width - image.getWidth())/2, y);

+	label.setLocation(x + (width - label.getWidth())/2, y + image.getHeight()+GAP);

+    }

+

+    public FigText getLabelFig() {

+        return label;

+    }

+    

+    public String getLabel() {

+        return label.getText();

+    }

+

+    public void setLabel(String label) {

+        this.label.setText(label);

+	this.label.calcBounds();

+	this.calcBounds();

+    }

+    

+    

+}


Modified: branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java?view=diff&rev=12764&p1=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java&p2=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java&r1=12763&r2=12764
==============================================================================
--- branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java	(original)
+++ branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java	2007-06-05 18:34:08-0700
@@ -24,10 +24,10 @@
 

 package org.argouml.uml.profile;

 

-import org.tigris.gef.presentation.FigImage;

+import java.awt.Image;

 

 public interface FigNodeStrategy {

     

-    FigImage getIconForStereotype(Object element);

+    Image getIconForStereotype(Object element);

     

 }


Modified: branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java?view=diff&rev=12764&p1=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java&p2=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java&r1=12763&r2=12764
==============================================================================
--- branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java	(original)
+++ branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java	2007-06-05 18:34:08-0700
@@ -25,6 +25,7 @@
 

 package org.argouml.uml.profile;

 

+import java.awt.Image;

 import java.util.Iterator;

 import java.util.Vector;

 import org.apache.log4j.Logger;

@@ -109,12 +110,12 @@
     @SuppressWarnings("unchecked")

     private FigNodeStrategy compositeFigNodeStrategy = new FigNodeStrategy() {

 

-	public FigImage getIconForStereotype(Object element) {

+	public Image getIconForStereotype(Object element) {

 	    Iterator it = figNodeStrategies.iterator();

 

 	    while(it.hasNext()) {

 		FigNodeStrategy strat = (FigNodeStrategy) it.next();

-		FigImage extra = strat.getIconForStereotype(element);

+		Image extra = strat.getIconForStereotype(element);

 

 		if (extra != null) {

 		    return extra;
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.