svn commit: r12864 - 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-17 04:49:28-0700
New Revision: 12864

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

Log:
improving loading strategy

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=12864&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=12863&r2=12864
==============================================================================
--- 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-17 04:49:28-0700
@@ -8,21 +8,22 @@
 import org.argouml.model.Model;

 import org.argouml.uml.profile.FigNodeStrategy;

 

+/**

+ * Sample JavaBeans Profile 

+ * 

+ * @author Marcos Aurélio

+ *

+ */

 public class JavaBeansFigNodeStrategy implements FigNodeStrategy {

 

-    private Image iconBean = null;

-    private Image iconRay  = null;

-    

-    public JavaBeansFigNodeStrategy() {

-	iconBean = readImage("bean.GIF");

-	iconRay  = readImage("event.gif");

-    }

-   

-    private Image readImage(String fileName) {

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

+    private static  final Image iconBean = readImage("bean.GIF", 2904);

+    private static final Image iconRay  = readImage("event.gif", 243);

+       

+    private static Image readImage(String fileName, int fileSize) {

+	BufferedInputStream bis = new BufferedInputStream(JavaBeansFigNodeStrategy.class

 		.getResourceAsStream(fileName));

 	

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

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

 	try {

 	    bis.read(buf);

 	} catch (IOException e) {

@@ -31,6 +32,9 @@
 	return Toolkit.getDefaultToolkit().createImage(buf);

     }

     

+    /**

+     * @see org.argouml.uml.profile.FigNodeStrategy#getIconForStereotype(java.lang.Object)

+     */

     public Image getIconForStereotype(Object stereotype) {

 	if ("Bean".equals(Model.getFacade().getName(stereotype))) {

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