|
import java.awt.*;
|
import java.awt.event.*;
|
import javax.swing.*;
|
import javax.swing.event.*;
|
|
import grafeme.ui.*;
|
|
class BiparamEditor extends ObjEditor implements ItemListener, ChangeListener, ObjectUI, ActionListener
|
{
|
BiparamEditor(Biparam inBP, GroupEditor callee)
|
{
|
super(inBP,callee);
|
|
objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
|
|
biparam = (Biparam) inBP;
|
// parent = p;
|
|
//SetupUI2(callee.objEditor);
|
}
|
|
// TEMP
|
BiparamEditor(Biparam inClient, Object3D localCopy, GroupEditor callee)
|
{
|
this(inClient, localCopy, null, callee);
|
}
|
|
BiparamEditor(Biparam inBP, ObjectUI p, GroupEditor callee)
|
{
|
super(inBP,callee);
|
|
objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
|
|
biparam = (Biparam) inBP;
|
parent = p;
|
|
SetupUI2(callee.objEditor);
|
}
|
|
BiparamEditor(Biparam 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;
|
biparam = (Biparam) 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);
|
|
uvPanel = new cGridBag().setVertical(true);
|
|
int count = 50;
|
|
uDivsField = (cNumberSlider)AddSlider(uvPanel, "U #", biparam.minUDivs, (int)(count*this.biparam.uStretch()) + biparam.minUDivs, biparam.uDivs).getComponent(1);
|
vDivsField = (cNumberSlider)AddSlider(uvPanel, "V #", biparam.minVDivs, (int)(count) + biparam.minVDivs, biparam.vDivs).getComponent(1);
|
|
oe.ctrlPanel.add(uvPanel);
|
oe.ctrlPanel.Return();
|
// oe.aConstraints.gridwidth = 1;
|
// oe.aConstraints.fill = GridBagConstraints.VERTICAL;
|
// oe.ctrlPanel.add(uDivsLabel = new JLabel("U #"), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; // 1;
|
// oe.aConstraints.gridx += 1;
|
// oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
// oe.ctrlPanel.add(uDivsField = new NumberSlider(biparam.minUDivs, 256+biparam.minUDivs), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.aConstraints.gridy += 1;
|
// oe.aConstraints.gridwidth = 1;
|
// oe.aConstraints.fill = 0;
|
// oe.aConstraints.gridx -= 1;
|
// oe.aConstraints.fill = GridBagConstraints.VERTICAL;
|
// oe.ctrlPanel.add(vDivsLabel = new JLabel("V #"), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; // 1;
|
// oe.aConstraints.gridx += 1;
|
// oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
// oe.ctrlPanel.add(vDivsField = new NumberSlider(biparam.minVDivs, 256+biparam.minVDivs), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// uDivsField.setInteger(biparam.uDivs);
|
// vDivsField.setInteger(biparam.vDivs);
|
// uDivsField.addChangeListener(this);
|
// vDivsField.addChangeListener(this);
|
// oe.aConstraints.fill = 0;
|
// oe.aConstraints.gridx -= 1;
|
// oe.aConstraints.gridwidth = 1;
|
if (biparam instanceof Cone) // ends)
|
{
|
oe.ctrlPanel.add(optionCB = new JCheckBox("Close Surface", biparam.endcaps)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
optionCB.addItemListener(this);
|
oe.ctrlPanel.Return();
|
//endcaps.setState(!biparam.endcaps);
|
}
|
}
|
|
void Clear()
|
{
|
objEditor.Clear();
|
|
biparam = null;
|
}
|
|
|
public void itemStateChanged(ItemEvent e)
|
{
|
if (//e.getSource() == nameField ||
|
e.getSource() == optionCB)
|
{
|
//System.out.println(e);
|
biparam.endcaps = (e.getStateChange() == ItemEvent.SELECTED);
|
//Refresh();
|
biparam.retile();
|
applySelf();
|
//super.applySelf();
|
objEditor.refreshContents();
|
}
|
else
|
{
|
super.itemStateChanged(e);
|
}
|
}
|
|
public void actionPerformed(ActionEvent e)
|
{
|
if (//e.getSource() == nameField ||
|
e.getSource() == optionCB)
|
{
|
new Exception().printStackTrace();
|
//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() == uDivsField ||
|
e.getSource() == vDivsField)
|
{
|
//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");
|
biparam.uDivs = uDivsField.getInteger(); // biparam.minUDivs, 99);
|
biparam.vDivs = vDivsField.getInteger(); // biparam.minVDivs, 99);
|
//if (endcaps != null)
|
//biparam.endcaps = !endcaps.getState();
|
biparam.retile();
|
|
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();
|
int udivs = uDivsField.getInteger(); // biparam.minUDivs, 99);
|
int vdivs = vDivsField.getInteger(); // biparam.minUDivs, 99);
|
//biparam.name = nameField.getText();
|
|
if (//true) // TRIMMING ISSUE ...
|
biparam.uDivs != udivs || biparam.vDivs != vdivs)
|
{
|
System.out.print("#U = " + udivs);
|
System.out.print("; #V = " + vdivs);
|
System.out.println("; U*V = " + (udivs*vdivs));
|
|
biparam.uDivs = udivs;
|
biparam.vDivs = vdivs;
|
//if (endcaps != null)
|
//biparam.endcaps = !endcaps.getState();
|
biparam.retile();
|
}
|
// june 2013 super.applySelf();
|
}
|
/**/
|
|
public void closeUI()
|
{
|
ObjEditor oe = objEditor;
|
|
// uDivsField.removeChangeListener(this);
|
// vDivsField.removeChangeListener(this);
|
if (optionCB != null)
|
{
|
//optionCB.removeItemListener(this);
|
//oe.ctrlPanel.remove(optionCB);
|
Remove(optionCB);
|
}
|
// oe.ctrlPanel.remove(uDivsField);
|
// oe.ctrlPanel.remove(vDivsField);
|
// oe.ctrlPanel.remove(uDivsLabel);
|
// oe.ctrlPanel.remove(vDivsLabel);
|
// //oe.ctrlPanel.repaint();
|
// Remove(uDivsField);
|
// Remove(vDivsField);
|
oe.ctrlPanel.remove(uvPanel);
|
|
super.closeUI();
|
}
|
|
public ObjEditor GetEditor()
|
{
|
return objEditor;
|
}
|
|
void refreshContents2()
|
{
|
objEditor.refreshContents();
|
}
|
|
Biparam biparam;
|
//JLabel uDivsLabel;
|
//JLabel vDivsLabel;
|
cNumberSlider uDivsField;
|
cNumberSlider vDivsField;
|
JCheckBox optionCB;
|
|
cGridBag uvPanel;
|
|
ObjectUI parent;
|
|
//ObjEditor objEditor;
|
}
|