Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 6
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 3856 times and has 5 replies Next Thread
enzymer
Newbie




Joined: Dec 13, 2007
Post Count: 4
Status: Offline
Reply to this Post  Reply with Quote 
Question about DefaultFurnitureCatalog.java

Hi, puybaret:
I'am currently reading the source code of sweethome3d for better software understanding. Unfortuantely, when it comes to com.eteks.sweethome3d.io.DefaultFurnitureCatalog.java, which defines the default catalog categories and nodes, something unexpected happens:
I inserted a line in the constructor of this file: System.out.println("test"), and many (about more than 30 lines, I guess) "test" was printed on the console when sweethome3d is recompiled and run. It seems like when the software is initialized, many DefaultFurnitureCatalog class is created (at least the permanent part is initialized repeatedly) - I wish this is special for my system environment. :-)
Another question is about the Furniture initialization in this file. There are 2 relative property files: ContributedFurnitureCatalog.properties and DefaultFurnitureCatalog.properties, but only the information in ContributedFurnitureCatalog.properties could be imported, if I delete the readFurniture method of ContributedFurnitureCatalog.properties, no furniture will be shown - so it seems like the DefaultFurnitureCatalog.properties does not function at all. I analyze the code but still could not understand why :-(
I apologize if these are caused by my lack of programming skills.
^_^





[Note: this thread was started on sourceforge.net forums]
[Dec 13, 2007, 4:35:00 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Question about DefaultFurnitureCatalog.ja

Hi enzymer,

I just tested the issue you mentioned, but on my side, DefaultFurnitureCatalog is called only once at application launch, and if I comment the readFurniture call for ContributedFurnitureCatalog.properties, Sweet Home 3D shows only the furniture of DefaultFurnitureCatalog.properties as expected !?!

Are you sure you didn't make any other change in the code ?
On which system and JRE did you do these tests ?


----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Dec 14, 2007, 8:57:00 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
enzymer
Newbie




Joined: Dec 13, 2007
Post Count: 4
Status: Offline
Reply to this Post  Reply with Quote 
Re: Question about DefaultFurnitureCatalog.ja

Hi epuybaret,

Thank you for your test. My OS is Windows XP and IDE is Eclipse 3.2.2 - An hour ago, I tested again but still met the same 2 problems: The DefaultFurnitureCatalog is called exactly 316 times, so the initialization is slowed down (but eventually it will work).
I went to another "clean" computer with Windows XP as OS and installed JAVA 1.6 & Eclipse 3.2.2(so, it's not because of my developing environment), re-extract the v1.2 source code from zip file and run(so i just change the constructor of DefaultFurnitureCatalog, nothing else), unfortunately, the same 2 problems happened to me, and exactly 316 times too!
For software running under windows, I copy the 4 j3d dll lib files to C:\WINDOWS\System32\ . Is this the key to this problem , i don't know much about dll.

Thanks again!


[Dec 15, 2007, 4:37:00 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Question about DefaultFurnitureCatalog.ja

I tested it again under Windows XP this time with Java 1.6 & Eclipse 3.3 (but I don't see what it could change), and I still have no problem on my side.
At application startup, com.eteks.sweethome3d.io.DefaultFurnitureCatalog constructor is called once from com.eteks.sweethome3d.io.FileUserPreferences constructor, and only one FileUserPreferences instance is created in com.eteks.sweethome3d.SweetHome3D class, which is unique also.
So I guess, that in your configuration, SweetHome3D is in fact launched many times. Instead of adding a simple System.out.println call, could you program a call to Thread.dumpStack() and check if all the stack traces are the same (you can post them here if you want to).
Does Sweet Home 3D launch is also slow when you run it with its default installer ?

> For software running under windows, I copy the 4 j3d dll lib files to C:\WINDOWS\System32\ .
> Is this the key to this problem , i don't know much about dll.

I don't think this is a problem, but personally, I don't like to copy files and I prefer to run Sweet Home 3D from Eclipse by adding the following VM arguments:

-Djava.library.path="${project_loc}\lib\windows"

in the Arguments tab of the dialog displayed by Run > Open Run dialog...


----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Dec 15, 2007, 12:03:00 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
enzymer
Newbie




Joined: Dec 13, 2007
Post Count: 4
Status: Offline
Reply to this Post  Reply with Quote 
Re: Question about DefaultFurnitureCatalog.ja

Hi,epuybaret :
Thank you! Using debug in Eclipse, i find the problem is really caused by code in DefaultFurnitureCatalog - it seems like something unexpected happens in ResourceBundle reading. I write a small program below (coded just like DefaultFurnitureCatalog):
----------------------------------------------------------------------------
/*
* This program aims to read information from ResourceBundle (first the testBundle, then the testBundle2). However, only the second
* bundle is readed.
*/
package testBean;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class testBundle{
private static final String NAME = "name#";
private static final String CATEGORY = "category#";

public static void main(String[] args){
new testBundle();
}

public testBundle(){
System.out.println("initialTest");
//When in debug, i can see the method below could not be executed,
//and the above sentence repeatedly print "initialTest".
read(ResourceBundle.getBundle(testBundle.class.getName()));

String classPackage = testBundle.class.getName();
classPackage = classPackage.substring(0, classPackage.lastIndexOf("."));
read(ResourceBundle.getBundle(classPackage + ".testBundle2"));
}

private void read(ResourceBundle resource){
System.out.println("initialReadTest");
for(int i = 1; ; i++){
String name = null;
try{
name = resource.getString(NAME + i);
System.out.println("Node Name: " + name);
}catch(MissingResourceException ex){
//Stop the loop when this node does not exist.
break;
}

String category = resource.getString(CATEGORY + i);
System.out.println("Category Name: " + category);
}
}
}
------------------------------------------------
So, this program has some problems (i don't know where or why) -- i think it is the same problem that i met before in Sweet Home 3D.
I add Thread.dumpStack() in the constructor of this small program, and find some unexpected things (but i have no experience on stack trace so...:( )
I installed Sweet Home 3D before using install file, the initialization seems a bit slow in my computer (But i cannot tell whether it is because of DefaultFurnitureCatalog).
Could you run the small program above? (the property file is just like DefaultFurnitureCatalog), I wish it is OK on your side, anyway, i could not find any bug in this program.
-------
and you are right, the j3d dll files will not cause such problem.
-----------------------------------------------
Really thank you for help! I will run this program on other computers including Linux environment, I wish all these are caused by my OS or Eclipse setting.
Kind regards.


[Dec 15, 2007, 5:17:00 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
enzymer
Newbie




Joined: Dec 13, 2007
Post Count: 4
Status: Offline
Reply to this Post  Reply with Quote 
Re: Question about DefaultFurnitureCatalog.ja

Finally, i solved this problem, it is because of my CLASSPATH setting, although i'm still not very clear why some other computers are OK with the same setting:
---------------------------------------
http://forum.java.sun.com/thread.jspa?threadID=660477&messageID=4231534
I've solved the problem the best way possible. Basically what i've done is added a new class folder named config to the project home dir. Then i added this classfolder to the classpath in project properties. After doing all of this you only need to reference the properties file by "Email".

Hope this helps anyone else who is having similiar problems.
---------------------------------------
now, the sweet home 3d is initialized really fast.


[Dec 17, 2007, 2:44:00 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved