Author: maurelio1234
Date: 2007-06-05 00:56:50-0700
New Revision: 12755
Modified:
branches/gsoc2007/maurelio1234/argouml/ext/profile-javabeans.jar
branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/UmlDiagramRenderer.java
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:
week 1: displaying icons for stereotyped classifiers
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=12755&p1=branches/gsoc2007/maurelio1234/argouml/ext/profile-javabeans.jar&p2=branches/gsoc2007/maurelio1234/argouml/ext/profile-javabeans.jar&r1=12754&r2=12755
==============================================================================
Binary files. No diff available.
Modified: branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/UmlDiagramRenderer.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/UmlDiagramRenderer.java?view=diff&rev=12755&p1=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/UmlDiagramRenderer.java&p2=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/UmlDiagramRenderer.java&r1=12754&r2=12755
==============================================================================
--- branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/UmlDiagramRenderer.java (original)
+++ branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/diagram/UmlDiagramRenderer.java 2007-06-05 00:56:50-0700
@@ -219,14 +219,6 @@
"Failed to construct a FigNode for " + node);
}
- Fig[] fig = ProjectManager.getManager().getCurrentProject()
- .getProfileConfiguration().getFigNodeStrategy()
- .getExtraFiguresForNode(node);
-
- for(int i=0;i<fig.length;++i) {
- figNode.addFig(fig[i]);
- }
-
setStyleAttributes(figNode, styleAttributes);
return figNode;
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=12755&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=12754&r2=12755
==============================================================================
--- 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 00:56:50-0700
@@ -86,11 +86,13 @@
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;
@@ -222,6 +224,31 @@
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;
+
+ /**
+ * 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
* that are on this figure. This is not the same as the figures in the
@@ -268,6 +295,9 @@
// 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);
@@ -308,7 +338,7 @@
setOwner(element);
nameFig.setText(placeString());
readyToEdit = false;
- setLocation(x, y);
+ setLocation(x, y);
}
/*
@@ -1092,6 +1122,7 @@
addElementListener(mee.getNewValue(), "name");
}
updateStereotypeText();
+ updateStereotypeIcon();
damage();
}
}
@@ -1238,7 +1269,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...");
@@ -1246,9 +1277,74 @@
}
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.
*/
@@ -1257,6 +1353,14 @@
if (getOwner() == null) {
return;
}
+ FigText nameFig = null;
+
+ if (showStereotypeIcon) {
+ nameFig = stereotypeIconText;
+ } else {
+ nameFig = this.nameFig;
+ }
+
if (notationProviderName != null) {
nameFig.setText(notationProviderName.toString(
getOwner(), npArguments));
@@ -1406,7 +1510,8 @@
public void renderingChanged() {
updateNameText();
updateStereotypeText();
- updateBounds();
+ updateStereotypeIcon();
+ updateBounds();
damage();
}
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=12755&p1=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java&p2=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java&r1=12754&r2=12755
==============================================================================
--- branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java (original)
+++ branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/FigNodeStrategy.java 2007-06-05 00:56:50-0700
@@ -24,10 +24,10 @@
package org.argouml.uml.profile;
-import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigImage;
public interface FigNodeStrategy {
- Fig[] getExtraFiguresForNode(Object element);
+ FigImage 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=12755&p1=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java&p2=branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java&r1=12754&r2=12755
==============================================================================
--- branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java (original)
+++ branches/gsoc2007/maurelio1234/argouml/org/argouml/uml/profile/ProfileConfiguration.java 2007-06-05 00:56:50-0700
@@ -31,6 +31,7 @@
import org.argouml.uml.profile.java.ProfileJava;
import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigImage;
/**
* This class captures the configurable behavior of Argo.
*
@@ -80,7 +81,7 @@
FigNodeStrategy fns = p.getFigureStrategy();
if (fns!=null) {
- figNodeStrategies.add(p);
+ figNodeStrategies.add(fns);
}
}
@@ -99,7 +100,7 @@
FigNodeStrategy fns = p.getFigureStrategy();
if (fns!=null) {
- figNodeStrategies.remove(p);
+ figNodeStrategies.remove(fns);
}
}
@@ -108,21 +109,18 @@
@SuppressWarnings("unchecked")
private FigNodeStrategy compositeFigNodeStrategy = new FigNodeStrategy() {
- public Fig[] getExtraFiguresForNode(Object element) {
+ public FigImage getIconForStereotype(Object element) {
Iterator it = figNodeStrategies.iterator();
- Vector cont = new Vector();
while(it.hasNext()) {
FigNodeStrategy strat = (FigNodeStrategy) it.next();
- Fig[] extra = strat.getExtraFiguresForNode(element);
+ FigImage extra = strat.getIconForStereotype(element);
- for(int i=0;i<extra.length;++i) {
- cont.add(extra[i]);
+ if (extra != null) {
+ return extra;
}
}
-
- LOG.info("RETURNING " + cont.size() + " elements");
- return (Fig[])cont.toArray(new Fig[0]);
+ return null;
}
};
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.