Print at Dec 19, 2025, 4:07:23 AM

Posted by kerfmas4 at Aug 31, 2011, 9:19:47 PM
Re: Background Image from command line
First of all, thanks a lot for your help. Now the code result that worked.

package com.eteks.test;

import java.net.URL;
import java.net.MalformedURLException;
import com.eteks.sweethome3d.plugin.Plugin;
import com.eteks.sweethome3d.plugin.PluginAction;
import com.eteks.sweethome3d.model.BackgroundImage;
import com.eteks.sweethome3d.model.Content;
import com.eteks.sweethome3d.tools.URLContent;

public class SetBackgroundPlugin extends Plugin {
public BackgroundImage ImagenFondo() throws MalformedURLException {
URL u = new URL( "file:/c:/4683.jpg");
Content content = new URLContent(u);
return new BackgroundImage(content, 2500, 0, 0, 700, 700, 0, 0);
}

public class SetBackgroundAction extends PluginAction {
public SetBackgroundAction() {
putPropertyValue(Property.NAME, "Compute volume");
putPropertyValue(Property.MENU, "Tools");
// Enables the action by default
setEnabled(true);
}

@Override public void execute() {
}
}

@Override
public PluginAction[] getActions() {
try {
getHome().setBackgroundImage(ImagenFondo());
} catch (MalformedURLException e) {
e.printStackTrace();
}
return new PluginAction [] {new SetBackgroundAction()};
}
}


Thanks again.

[Note from moderator: fixed code format]