📄 bloompasseditor.java
字号:
exposurePanel.add(cutoffField);
final JPanel blurPanel = new JPanel();
blurPanel.setBorder(new TitledBorder(null, "Blur Settings", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
blurPanel.setLayout(new GridLayout(0, 2));
final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints();
gridBagConstraints_3.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints_3.weightx = 1;
gridBagConstraints_3.gridy = 4;
gridBagConstraints_3.gridx = 0;
add(blurPanel, gridBagConstraints_3);
final JLabel blurPassesLabel = new JLabel();
blurPassesLabel.setText("Passes:");
blurPanel.add(blurPassesLabel);
passesField = new ValueSpinner(0, 16, 1);
passesField.setValue(pass.getNrBlurPasses());
passesField.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
pass.setNrBlurPasses(((Number) passesField.getValue()).intValue());
}
});
blurPanel.add(passesField);
final JLabel intensityLabel = new JLabel();
intensityLabel.setText("Intensity:");
blurPanel.add(intensityLabel);
intensityField = new ValueSpinner(0, 16, .01f);
intensityField.setValue(pass.getBlurIntensityMultiplier());
intensityField.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
pass.setBlurIntensityMultiplier(((Number) intensityField.getValue()).floatValue());
}
});
blurPanel.add(intensityField);
final JLabel sizeLabel = new JLabel();
sizeLabel.setText("Size:");
blurPanel.add(sizeLabel);
sizeField = new ValueSpinner(0, 16, .001f);
sizeField.setValue(pass.getBlurSize());
sizeField.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
pass.setBlurSize(((Number) sizeField.getValue()).floatValue());
}
});
blurPanel.add(sizeField);
setSize(218, 359);
final JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridBagLayout());
final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints();
gridBagConstraints_4.gridy = 5;
gridBagConstraints_4.gridx = 0;
add(buttonPanel, gridBagConstraints_4);
final JButton saveButton = new JButton();
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
// find out what file to save to:
JFileChooser chooser;
if (lastDir != null)
chooser = new JFileChooser(lastDir);
else
chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(false);
int result = chooser.showSaveDialog(BloomPassEditor.this);
if (result == JFileChooser.CANCEL_OPTION)
return;
// save this dir as last opened
lastDir = chooser.getCurrentDirectory();
// store current as our new "go back" values.
origCutoff = pass.getExposureCutoff();
origIntens = pass.getBlurIntensityMultiplier();
origPasses = pass.getNrBlurPasses();
origThrottleMS = (int)(pass.getThrottle()*1000);
origPower = pass.getExposurePow();
origSize = pass.getBlurSize();
origUseCurrent = pass.useCurrentScene();
File file = chooser.getSelectedFile();
Properties p = new Properties();
p.put("cutoff", ""+origCutoff);
p.put("intensity", ""+origIntens);
p.put("passes", ""+origPasses);
p.put("throttleMS", ""+origThrottleMS);
p.put("power", ""+origPower);
p.put("size", ""+origSize);
p.put("useCurrent", ""+origUseCurrent);
try {
p.storeToXML(new FileOutputStream(file), "Bloom properties.");
} catch (Exception e1) {
logger.logp(Level.SEVERE, this.getClass().toString(),
"BloomPassEditor(pass)", "Exception", e1);
}
}
});
saveButton.setText("Export...");
final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints();
gridBagConstraints_5.insets = new Insets(2, 2, 0, 4);
gridBagConstraints_5.gridx = 0;
gridBagConstraints_5.gridy = 0;
buttonPanel.add(saveButton, gridBagConstraints_5);
final JButton importButton = new JButton();
importButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
// find out what file to save to:
JFileChooser chooser;
if (lastDir != null)
chooser = new JFileChooser(lastDir);
else
chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(false);
int result = chooser.showOpenDialog(BloomPassEditor.this);
if (result == JFileChooser.CANCEL_OPTION)
return;
// save this dir as last opened
lastDir = chooser.getCurrentDirectory();
File file = chooser.getSelectedFile();
Properties p = new Properties();
try {
p.loadFromXML(new BufferedInputStream(new FileInputStream(file)));
} catch (Exception ex) {
logger.logp(Level.SEVERE, this.getClass().toString(),
"actionPerformed(e)", "Exception", ex);
return;
}
// read in our new values
origCutoff = Float.parseFloat(p.getProperty("cutoff", "0.0"));
origIntens = Float.parseFloat(p.getProperty("intensity", "1.3"));
origPasses = Integer.parseInt(p.getProperty("passes", "2"));
origThrottleMS = Integer.parseInt(p.getProperty("throttleMS", "20"));
origPower = Float.parseFloat(p.getProperty("power", "3.0"));
origSize = Float.parseFloat(p.getProperty("size", "0.02"));
origUseCurrent = Boolean.parseBoolean(p.getProperty("useCurrent", "true"));
// reapply to editor and in turn, to our pass
revert(pass);
}
});
importButton.setText("Import...");
final GridBagConstraints gridBagConstraints_7 = new GridBagConstraints();
gridBagConstraints_7.insets = new Insets(2, 4, 0, 2);
gridBagConstraints_7.gridx = 1;
gridBagConstraints_7.gridy = 0;
buttonPanel.add(importButton, gridBagConstraints_7);
final JButton resetButton = new JButton();
final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();
gridBagConstraints_6.insets = new Insets(2, 2, 2, 2);
gridBagConstraints_6.gridwidth = 2;
gridBagConstraints_6.gridx = 0;
gridBagConstraints_6.gridy = 1;
buttonPanel.add(resetButton, gridBagConstraints_6);
resetButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
revert(pass);
}
});
resetButton.setText("Reset");
}
private void revert(final BloomRenderPass pass) {
intensityField.setValue(origIntens);
sizeField.setValue(origSize);
cutoffField.setValue(origCutoff);
powerField.setValue(origPower);
throttleField.setValue(origThrottleMS);
passesField.setValue(origPasses);
pass.setUseCurrentScene(origUseCurrent);
if (origUseCurrent) {
reuseFramebufferRadioButton.setSelected(true);
} else {
rerenderToPbufferRadioButton.setSelected(true);
}
}
public static JFrame makeFrame(BloomRenderPass pass) {
JFrame rVal = new JFrame("Bloom Settings");
BloomPassEditor edit = new BloomPassEditor(pass);
rVal.getContentPane().setLayout(new BorderLayout());
rVal.getContentPane().add(edit, BorderLayout.CENTER);
rVal.pack();
return rVal;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -