本文整理汇总了Java中org.newdawn.slick.particles.ParticleIO.loadEmitter方法的典型用法代码示例。如果您正苦于以下问题:Java ParticleIO.loadEmitter方法的具体用法?Java ParticleIO.loadEmitter怎么用?Java ParticleIO.loadEmitter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.particles.ParticleIO
的用法示例。
在下文中一共展示了ParticleIO.loadEmitter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cloneEmitter
import org.newdawn.slick.particles.ParticleIO; //导入方法依赖的package包/类
/**
* Clone the selected emitter
*/
public void cloneEmitter() {
if (selected == null) {
return;
}
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ParticleIO.saveEmitter(bout, selected);
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
ConfigurableEmitter emitter = ParticleIO.loadEmitter(bin);
emitter.name = emitter.name + "_clone";
addEmitter(emitter);
emitters.setSelected(emitter);
} catch (IOException e) {
Log.error(e);
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
示例2: importEmitter
import org.newdawn.slick.particles.ParticleIO; //导入方法依赖的package包/类
/**
* Import an emitter XML file
*/
public void importEmitter() {
chooser.setDialogTitle("Open");
int resp = chooser.showOpenDialog(this);
if (resp == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
File path = file.getParentFile();
try {
final ConfigurableEmitter emitter = ParticleIO.loadEmitter(file);
if (emitter.getImageName() != null) {
File possible = new File(path, emitter.getImageName());
if (possible.exists()) {
emitter.setImageName(possible.getAbsolutePath());
} else {
chooser.setDialogTitle("Locate the image: "+emitter.getImageName());
resp = chooser.showOpenDialog(this);
FileFilter filter = new FileFilter() {
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
return (f.getName().equals(emitter.getImageName()));
}
public String getDescription() {
return emitter.getImageName();
}
};
chooser.addChoosableFileFilter(filter);
if (resp == JFileChooser.APPROVE_OPTION) {
File image = chooser.getSelectedFile();
emitter.setImageName(image.getAbsolutePath());
path = image.getParentFile();
}
chooser.resetChoosableFileFilters();
chooser.addChoosableFileFilter(xmlFileFilter);
}
}
addEmitter(emitter);
emitters.setSelected(emitter);
} catch (IOException e) {
Log.error(e);
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
}