📄 particleappearancepanel.java
字号:
new Insets(5, 5, 0, 5), 0, 0));
rampPanel.add(rampEditButton, new GridBagConstraints(0, 2, 1,
1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
rampPanel.add(rampMoveUpButton, new GridBagConstraints(0, 3, 1,
1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
rampPanel.add(rampMoveDownButton, new GridBagConstraints(0, 4, 1,
1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
animList = new JList(animModel);
animList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
animList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int selected = animList.getSelectedIndex();
animRemoveButton.setEnabled(selected != -1);
animEditButton.setEnabled(selected != -1);
animMoveUpButton.setEnabled(selected > 0);
animMoveDownButton.setEnabled(selected != -1 && selected < animModel.getSize()-1);
}
});
animList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
animEditButton.doClick();
e.consume();
}
}
});
animAddButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Thread() {
public void run() {
AnimationEntry entry = new AnimationEntry();
getEdittedParticles().getTexAnimation().addEntry(entry);
showEditWindow(entry);
updateAnimModel();
animList.setSelectedValue(entry, true);
}
}.start();
}
});
animEditButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Thread() {
public void run() {
int index = animList.getSelectedIndex();
AnimationEntry entry = (AnimationEntry) animList
.getSelectedValue();
showEditWindow(entry);
updateAnimModel();
animList.setSelectedIndex(index);
};
}.start();
}
});
animRemoveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AnimationEntry entry = (AnimationEntry)animList.getSelectedValue();
getEdittedParticles().getTexAnimation().removeEntry(entry);
updateAnimModel();
}
});
animMoveUpButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int index = animList.getSelectedIndex();
AnimationEntry entry = (AnimationEntry)animList.getSelectedValue();
getEdittedParticles().getTexAnimation().removeEntry(entry);
getEdittedParticles().getTexAnimation().addEntry(index-1, entry);
updateAnimModel();
animList.setSelectedValue(entry, true);
}
});
animMoveDownButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int index = animList.getSelectedIndex();
AnimationEntry entry = (AnimationEntry)animList.getSelectedValue();
getEdittedParticles().getTexAnimation().removeEntry(entry);
getEdittedParticles().getTexAnimation().addEntry(index+1, entry);
updateAnimModel();
animList.setSelectedValue(entry, true);
}
});
animRemoveButton.setEnabled(false);
animEditButton.setEnabled(false);
animMoveUpButton.setEnabled(false);
animMoveDownButton.setEnabled(false);
JPanel animPanel = new JPanel(new GridBagLayout());
animPanel.setBorder(createTitledBorder("ANIMATION TIMELINE"));
animPanel.add(new JScrollPane(animList,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
new GridBagConstraints(1, 0, 1, 6, 1.0, 1.0,
GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
new Insets(5, 5, 5, 5), 0, 0));
animPanel.add(animAddButton, new GridBagConstraints(0, 0, 1,
1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
animPanel.add(animRemoveButton, new GridBagConstraints(0, 1, 1,
1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
animPanel.add(animEditButton, new GridBagConstraints(0, 2, 1,
1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
animPanel.add(animMoveUpButton, new GridBagConstraints(0, 3, 1,
1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
animPanel.add(animMoveDownButton, new GridBagConstraints(0, 4, 1,
1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
additiveBlendingBox = new JCheckBox(new AbstractAction(
"Additive Blending") {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent e) {
updateBlendState(additiveBlendingBox.isSelected());
}
});
additiveBlendingBox.setFont(new Font("Arial", Font.BOLD, 13));
JPanel blendPanel = new JPanel(new GridBagLayout());
blendPanel.setBorder(createTitledBorder("PARTICLE BLENDING"));
blendPanel.add(additiveBlendingBox, new GridBagConstraints(0, 0, 1, 1,
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
JLabel textureLabel = createBoldLabel("Texture Image:");
JButton changeTextureButton = new JButton(new AbstractAction(
"Browse...") {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent e) {
changeTexture();
}
});
changeTextureButton.setFont(new Font("Arial", Font.BOLD, 12));
changeTextureButton.setMargin(new Insets(2, 2, 2, 2));
JButton clearTextureButton = new JButton(new AbstractAction("Clear") {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent e) {
((TextureState) getEdittedParticles().getRenderState(RenderState.StateType.Texture)).setTexture(null);
imageLabel.setIcon(null);
}
});
clearTextureButton.setFont(new Font("Arial", Font.BOLD, 12));
clearTextureButton.setMargin(new Insets(2, 2, 2, 2));
imageLabel.setBackground(Color.lightGray);
imageLabel.setMaximumSize(new Dimension(128, 128));
imageLabel.setMinimumSize(new Dimension(0, 0));
imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
imageLabel.setOpaque(false);
texturePanel = new JPanel(new GridBagLayout());
texturePanel.setBorder(createTitledBorder("PARTICLE TEXTURE"));
texturePanel.add(textureLabel, new GridBagConstraints(0, 0, 1, 1, 0.0,
0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
texturePanel.add(changeTextureButton, new GridBagConstraints(0, 1, 1,
1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL,
new Insets(0, 5, 5, 5), 0, 0));
texturePanel.add(clearTextureButton, new GridBagConstraints(0, 2, 1, 1,
0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL,
new Insets(0, 5, 5, 5), 0, 0));
texturePanel.add(imageLabel, new GridBagConstraints(1, 0, 1, 3, 1.0,
1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
texPanel = new ValuePanel("Sub Images: ", "", 1, Integer.MAX_VALUE, 1);
texPanel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
getEdittedParticles().setTexQuantity(texPanel.getIntValue());
}
});
texturePanel.add(texPanel, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.0,
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
startTexPanel = new ValuePanel("Start Index: ", "", 0, Integer.MAX_VALUE, 1);
startTexPanel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
getEdittedParticles().setStartTexIndex(startTexPanel.getIntValue());
}
});
texturePanel.add(startTexPanel, new GridBagConstraints(0, 4, 2, 1, 1.0, 0.0,
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
add(geomPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 5, 10), 0, 0));
add(texturePanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 5, 10), 0, 0));
add(blendPanel, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 5, 10), 0, 0));
add(rampPanel, new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 5, 10), 0, 0));
add(animPanel, new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0,
GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 5, 10), 0, 0));
}
protected void showEditWindow(final RampEntry entry) {
RampEntryEditDialog dialog = new RampEntryEditDialog(entry);
dialog.setLocationRelativeTo(ParticleAppearancePanel.this);
dialog.setModal(true);
dialog.setVisible(true);
dialog.toFront();
}
protected void showEditWindow(final AnimationEntry entry) {
AnimationEntryEditDialog dialog = new AnimationEntryEditDialog(entry);
dialog.setLocationRelativeTo(ParticleAppearancePanel.this);
dialog.setModal(true);
dialog.setVisible(true);
dialog.toFront();
}
protected void updateRampModel() {
rampModel.clear();
rampModel.addElement(new StartRamp(getEdittedParticles()));
Iterator<RampEntry> it = getEdittedParticles().getRamp().getEntries();
while (it.hasNext()) {
RampEntry e = it.next();
rampModel.addElement(e);
}
rampModel.addElement(new EndRamp(getEdittedParticles()));
}
protected void updateAnimModel() {
animModel.clear();
Iterator<AnimationEntry> it = getEdittedParticles().getTexAnimation().getEntries();
while (it.hasNext()) {
AnimationEntry e = it.next();
animModel.addElement(e);
}
}
private void changeParticleType(ParticleType newType) {
ParticleType oldType = getEdittedParticles().getParticleType();
if (newType == oldType) {
return;
}
ParticleSystem oldGeom = getEdittedParticles(), newGeom;
if (newType == ParticleSystem.ParticleType.Point) {
ParticlePoints pPoints = ParticleFactory.buildPointParticles(oldGeom.getName(),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -