Re: Background Image from command line
Code: Select all
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()};
}
}