
org.jgraph.pad.actions.GraphBackgroundImage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of freak-core Show documentation
Show all versions of freak-core Show documentation
Core library of the Free Evolutionary Algorithm Toolkit
package org.jgraph.pad.actions;
import org.jgraph.GPGraphpad;
import org.jgraph.pad.resources.Translator;
import java.awt.*;
import java.awt.event.ActionEvent;
/**
* Action opens a file dialog to select an image.
* Afterthat the Action applies the selected image
* to the graph background.
*
* @author sven.luzar
*
*/
public class GraphBackgroundImage extends AbstractActionFile {
/**
* Constructor for GraphBackgroundImage.
* @param graphpad
*/
public GraphBackgroundImage(GPGraphpad graphpad) {
super(graphpad);
}
public void actionPerformed(ActionEvent e) {
String name =
openDialog(Translator.getString("ImageDialog"), null, null);
if (name != null) {
try {
// JDK 1.3
//File f = new File(name);
//Image value = new ImageIcon(ImageIO.read(f)).getImage();
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image value = toolkit.getImage(name);
graphpad.getCurrentGraph() .setBackgroundImage(value);
graphpad.getCurrentGraph() .repaint();
} catch (Exception ex) {
graphpad.error(ex.toString());
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy