svn commit: r12756 - branches/gsoc2007/maurelio1234/examples/javabeans/src/org/argouml/uml/profile/javabeans/JavaBeansFigNodeStrategy.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2007-06-05 00:56:56-0700
New Revision: 12756

Modified:
   branches/gsoc2007/maurelio1234/examples/javabeans/src/org/argouml/uml/profile/javabeans/JavaBeansFigNodeStrategy.java

Log:
week 1: displaying icons for stereotyped classifiers

Modified: branches/gsoc2007/maurelio1234/examples/javabeans/src/org/argouml/uml/profile/javabeans/JavaBeansFigNodeStrategy.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/examples/javabeans/src/org/argouml/uml/profile/javabeans/JavaBeansFigNodeStrategy.java?view=diff&rev=12756&p1=branches/gsoc2007/maurelio1234/examples/javabeans/src/org/argouml/uml/profile/javabeans/JavaBeansFigNodeStrategy.java&p2=branches/gsoc2007/maurelio1234/examples/javabeans/src/org/argouml/uml/profile/javabeans/JavaBeansFigNodeStrategy.java&r1=12755&r2=12756
==============================================================================
--- branches/gsoc2007/maurelio1234/examples/javabeans/src/org/argouml/uml/profile/javabeans/JavaBeansFigNodeStrategy.java	(original)
+++ branches/gsoc2007/maurelio1234/examples/javabeans/src/org/argouml/uml/profile/javabeans/JavaBeansFigNodeStrategy.java	2007-06-05 00:56:56-0700
@@ -1,21 +1,40 @@
 package org.argouml.uml.profile.javabeans;

 

-import java.util.logging.Logger;

+import java.awt.Image;

+import java.awt.Toolkit;

+import java.io.BufferedInputStream;

+import java.io.IOException;

 

 import org.argouml.model.Model;

 import org.argouml.uml.profile.FigNodeStrategy;

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

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

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

 

 public class JavaBeansFigNodeStrategy implements FigNodeStrategy {

 

-    public Fig[] getExtraFiguresForNode(Object element) {

-	Fig ret = null;

-//	if (Model.getExtensionMechanismsHelper().hasStereoType(element, "Bean")) {

-	    ret = new FigRect(10, 10, 16, 16);

-//	}

+    private FigImage icon = null;

+    

+    public JavaBeansFigNodeStrategy() {

+	BufferedInputStream bis = new BufferedInputStream(this.getClass()

+		.getResourceAsStream("bean.GIF"));

+	byte[] buf = new byte[10000];

+	try {

+	    bis.read(buf);

+	} catch (IOException e) {

+	    e.printStackTrace();

+	}

+	Image img = Toolkit.getDefaultToolkit().createImage(buf);

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

+    }

+    

+    public FigImage getIconForStereotype(Object stereotype) {

+	FigImage ret = null;

+	String s = Model.getFacade().getName(stereotype);

+	

+	if ("Bean".equals(s)) {

+	    ret = icon; 

+	}

 	    

-	return new Fig[] { ret };

+	return ret;

     }

     

 }
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.