|
import java.awt.*;
|
import java.awt.event.*;
|
import javax.swing.*;
|
import javax.swing.event.*;
|
|
import grafeme.ui.*;
|
|
class PhysicsEditor extends ObjEditor implements //ItemListener,
|
ChangeListener, ObjectUI, ActionListener
|
{
|
PhysicsEditor(PhysicsNode inBP, GroupEditor callee)
|
{
|
super(inBP,callee);
|
|
objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
|
|
physicsnode = inBP;
|
// parent = p;
|
|
//SetupUI2(callee.objEditor);
|
SetupUI2(objEditor);
|
}
|
|
// TEMP
|
PhysicsEditor(PhysicsNode inClient, Object3D localCopy, GroupEditor callee)
|
{
|
this(inClient, localCopy, null, callee);
|
}
|
|
PhysicsEditor(PhysicsNode inBP, ObjectUI p, GroupEditor callee)
|
{
|
super(inBP,callee);
|
|
objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
|
|
physicsnode = inBP;
|
parent = p;
|
|
SetupUI2(callee.objEditor);
|
}
|
|
PhysicsEditor(PhysicsNode inBP, Object3D copy, ObjectUI p, GroupEditor callee) // boolean ends)
|
{
|
//super(inBP, copy, callee);
|
super(inBP, copy, p, callee);
|
objEditor = this;
|
|
//objEditor = new ObjEditor(inBP, copy, this, callee);
|
// ?? super.parent = p;
|
physicsnode = (PhysicsNode) copy;
|
parent = p;
|
|
//objEditor.SetupUI(false); // ?
|
//objEditor.SetupViews(); // ?
|
SetupUI2(objEditor);
|
}
|
|
void SetupUI2(ObjEditor oe)
|
{
|
/*
|
oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
oe.aConstraints.gridx = 0;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH+1;
|
oe.ctrlPanel.add(nameField = new JTextField(biparam.name), oe.aConstraints);
|
nameField.addActionListener(this);
|
oe.aConstraints.gridy += 1;
|
oe.aConstraints.gridwidth = 1;
|
*/
|
super.SetupUI2(oe);
|
|
gravityPanel = AddSlider(oe.ctrlPanel, "Gravity:", 0, 10.0, physicsnode.gravity, 1);
|
gravityField = (cNumberSlider)gravityPanel.getComponent(1);
|
|
// oe.ctrlPanel.add(gravityLabel = new JLabel("Gravity: ")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.ctrlPanel.Return();
|
// oe.ctrlPanel.add(gravityField = new NumberSlider(0, 100.0)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
|
oe.ctrlPanel.Return();
|
|
windPanel = AddSlider(oe.ctrlPanel, "Wind:", 0, 10.0, physicsnode.wind, 1);
|
windField = (cNumberSlider)windPanel.getComponent(1);
|
|
// oe.ctrlPanel.add(windLabel = new JLabel("Wind: ")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.ctrlPanel.Return();
|
// oe.ctrlPanel.add(windField = new NumberSlider(0, 100.0)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
|
oe.ctrlPanel.Return();
|
|
floorPanel = AddSlider(oe.ctrlPanel, "Floor:", 0, 20.0, physicsnode.floor, 1);
|
floorField = (cNumberSlider)floorPanel.getComponent(1);
|
|
// oe.ctrlPanel.add(floorLabel = new JLabel("Floor: ")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.ctrlPanel.Return();
|
// oe.ctrlPanel.add(floorField = new NumberSlider(0, 100.0)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
|
oe.ctrlPanel.Return();
|
|
gravityField.addChangeListener(this);
|
windField.addChangeListener(this);
|
floorField.addChangeListener(this);
|
}
|
|
void Clear()
|
{
|
objEditor.Clear();
|
|
physicsnode = null;
|
}
|
|
|
// public void itemStateChanged(ItemEvent e)
|
// {
|
// if (//e.getSource() == nameField ||
|
// e.getSource() == endcaps)
|
// {
|
// //System.out.println(e);
|
// frameselect.endcaps = (e.getStateChange() == ItemEvent.SELECTED);
|
// //Refresh();
|
// frameselect.retile();
|
// applySelf();
|
// //super.applySelf();
|
// objEditor.refreshContents();
|
// }
|
// else
|
// {
|
// super.itemStateChanged(e);
|
// }
|
// }
|
|
// public void actionPerformed(ActionEvent e)
|
// {
|
// if (//e.getSource() == nameField ||
|
// e.getSource() == endcaps)
|
// {
|
// //System.out.println(e);
|
// applySelf();
|
// //super.applySelf();
|
// refreshContents();
|
// //Refresh();
|
// }
|
// else
|
// {
|
// super.actionPerformed(e);
|
// }
|
// }
|
|
public void stateChanged(ChangeEvent e)
|
{
|
//System.out.println("Biparam :: stateChanged");
|
if (e.getSource() == gravityField ||
|
e.getSource() == windField ||
|
e.getSource() == floorField)
|
{
|
//System.out.println("#U = " + biparam.uDivs);
|
//System.out.println("#V = " + biparam.vDivs);
|
//new Exception().printStackTrace();
|
//System.out.println(e);
|
applySelf();
|
//super.applySelf();
|
objEditor.refreshContents();
|
//Refresh();
|
}
|
else
|
super.stateChanged(e);
|
}
|
|
void Refresh()
|
{
|
new Exception().printStackTrace();
|
System.exit(0);
|
System.out.println("Biparam :: Refresh");
|
physicsnode.gravity = (float)gravityField.getFloat(); // biparam.minUDivs, 99);
|
|
refreshContents();
|
}
|
|
/*
|
public void doLayout()
|
{
|
super.doLayout();
|
labelAndField(uDivsLabel, uDivsField);
|
labelAndField(vDivsLabel, vDivsField);
|
if (endcaps != null)
|
{
|
int h = endcaps.getPreferredSize().height;
|
int w = endcaps.getPreferredSize().width;
|
endcaps.setBounds(5, widgetPos, w, h);
|
widgetPos += h;
|
}
|
widgetPos += 5;
|
}
|
*/
|
|
/**/
|
public void applySelf()
|
{
|
//System.out.println("Biparam :: applySelf");
|
//super.applySelf();
|
physicsnode.gravity = (float)gravityField.getFloat(); // biparam.minUDivs, 99);
|
physicsnode.wind = (float)windField.getFloat(); // biparam.minUDivs, 99);
|
physicsnode.floor = (float)floorField.getFloat(); // biparam.minUDivs, 99);
|
//biparam.name = nameField.getText();
|
|
physicsnode.transientDynamicsWorld.setGravity(new javax.vecmath.Vector3f(0, -physicsnode.gravity, physicsnode.wind));
|
// june 2013 super.applySelf();
|
}
|
/**/
|
|
public void closeUI()
|
{
|
ObjEditor oe = objEditor;
|
|
gravityField.removeChangeListener(this);
|
windField.removeChangeListener(this);
|
floorField.removeChangeListener(this);
|
|
oe.ctrlPanel.remove(gravityPanel);
|
oe.ctrlPanel.remove(windPanel);
|
oe.ctrlPanel.remove(floorPanel);
|
|
//oe.ctrlPanel.remove(gravityField);
|
//oe.ctrlPanel.remove(gravityLabel);
|
//oe.ctrlPanel.remove(windField);
|
//oe.ctrlPanel.remove(windLabel);
|
//oe.ctrlPanel.remove(floorField);
|
//oe.ctrlPanel.remove(floorLabel);
|
//oe.ctrlPanel.repaint();
|
|
super.closeUI();
|
}
|
|
public ObjEditor GetEditor()
|
{
|
return objEditor;
|
}
|
|
void refreshContents2()
|
{
|
objEditor.refreshContents();
|
}
|
|
PhysicsNode physicsnode;
|
|
cGridBag gravityPanel;
|
cGridBag windPanel;
|
cGridBag floorPanel;
|
|
//JLabel gravityLabel;
|
cNumberSlider gravityField;
|
//JLabel windLabel;
|
cNumberSlider windField;
|
//JLabel floorLabel;
|
cNumberSlider floorField;
|
|
ObjectUI parent;
|
|
//ObjEditor objEditor;
|
}
|