|
import java.awt.*;
|
import java.awt.event.*;
|
import javax.swing.*;
|
import javax.swing.event.*;
|
|
import grafeme.ui.*;
|
|
class SwitchEditor extends ObjEditor implements //ItemListener,
|
ChangeListener, ObjectUI, ActionListener
|
{
|
private cGridBag dampPanel;
|
private cGridBag framePanel;
|
|
SwitchEditor(SwitchNode inBP, GroupEditor callee)
|
{
|
super(inBP,callee);
|
|
objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
|
|
switchnode = (SwitchNode) inBP;
|
// parent = p;
|
|
//SetupUI2(callee.objEditor);
|
SetupUI2(objEditor);
|
}
|
|
// TEMP
|
SwitchEditor(SwitchNode inClient, Object3D localCopy, GroupEditor callee)
|
{
|
this(inClient, localCopy, null, callee);
|
}
|
|
SwitchEditor(SwitchNode inBP, ObjectUI p, GroupEditor callee)
|
{
|
super(inBP,callee);
|
|
objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
|
|
switchnode = (SwitchNode) inBP;
|
parent = p;
|
|
SetupUI2(callee.objEditor);
|
}
|
|
SwitchEditor(SwitchNode 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;
|
switchnode = (SwitchNode) 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);
|
framePanel = AddSlider(oe.ctrlPanel, "Child: ", 0, switchnode.getNumFrames()-1, switchnode.child);
|
|
// oe.aConstraints.gridx = 0;
|
// oe.aConstraints.gridwidth = 1;
|
// oe.aConstraints.fill = GridBagConstraints.VERTICAL;
|
// oe.ctrlPanel.add(frameLabel = new JLabel("Child: "), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; // 1;
|
// oe.aConstraints.gridx += 1;
|
// oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
// oe.ctrlPanel.add(frameField = new NumberSlider(0, frameselect.getNumFrames()-1), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
//
|
// frameField.setInteger(frameselect.child);
|
|
frameField = (cNumberSlider)framePanel.getComponent(1);
|
oe.ctrlPanel.Return();
|
dampPanel = AddSlider(oe.ctrlPanel, "Damp: ", 0, 300, switchnode.speed);
|
|
speedField = (cNumberSlider)dampPanel.getComponent(1);
|
oe.ctrlPanel.Return();
|
|
// oe.aConstraints.gridy += 1;
|
//
|
// oe.aConstraints.gridx = 0;
|
// oe.aConstraints.gridwidth = 1;
|
// oe.aConstraints.fill = GridBagConstraints.VERTICAL;
|
// oe.ctrlPanel.add(speedLabel = new JLabel("Damp: "), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; // 1;
|
// oe.aConstraints.gridx += 1;
|
// oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
// oe.ctrlPanel.add(speedField = new NumberSlider(0, 500), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
//
|
// speedField.setInteger(frameselect.speed);
|
//
|
// oe.aConstraints.gridy += 1;
|
// oe.aConstraints.gridwidth = 1;
|
// oe.aConstraints.fill = 0;
|
// oe.aConstraints.gridx -= 1;
|
// oe.aConstraints.fill = GridBagConstraints.VERTICAL;
|
// oe.aConstraints.gridy += 1;
|
// oe.aConstraints.gridx = 0;
|
// frameField.addChangeListener(this);
|
// speedField.addChangeListener(this);
|
}
|
|
void Clear()
|
{
|
objEditor.Clear();
|
|
switchnode = 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() == frameField || e.getSource() == speedField)
|
{
|
//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()
|
{
|
// System.out.println("Biparam :: Refresh");
|
switchnode.child = frameField.getInteger(); // 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()
|
{
|
int s = switchnode.speed;
|
|
//System.out.println("Biparam :: applySelf");
|
//super.applySelf();
|
switchnode.child = frameField.getInteger(); // biparam.minUDivs, 99);
|
switchnode.speed = speedField.getInteger(); // biparam.minUDivs, 99);
|
//biparam.name = nameField.getText();
|
|
Globals.lighttouched = true;
|
|
// june 2013 super.applySelf();
|
if (switchnode.speed != s)
|
System.out.println("Damp = " + switchnode.speed);
|
}
|
/**/
|
|
public void closeUI()
|
{
|
ObjEditor oe = objEditor;
|
|
// frameField.removeChangeListener(this);
|
// oe.ctrlPanel.remove(frameField);
|
// oe.ctrlPanel.remove(frameLabel);
|
// oe.ctrlPanel.remove(speedField);
|
// oe.ctrlPanel.remove(speedLabel);
|
// Remove(frameField);
|
// Remove(speedField);
|
|
oe.ctrlPanel.remove(framePanel);
|
oe.ctrlPanel.remove(dampPanel);
|
//oe.ctrlPanel.repaint();
|
|
super.closeUI();
|
}
|
|
public ObjEditor GetEditor()
|
{
|
return objEditor;
|
}
|
|
void refreshContents2()
|
{
|
objEditor.refreshContents();
|
}
|
|
SwitchNode switchnode;
|
// JLabel frameLabel;
|
cNumberSlider frameField;
|
// JLabel speedLabel;
|
cNumberSlider speedField;
|
|
ObjectUI parent;
|
|
//ObjEditor objEditor;
|
}
|