// Decompiled by Jad v1.5.7b. Copyright 1997-99 Pavel Kouznetsov.
|
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
|
// Decompiler options: packimports(3)
|
// Source File Name: BlobEditor.java
|
|
import java.awt.*;
|
import java.awt.event.*;
|
import java.util.Vector;
|
import javax.swing.*;
|
|
class BlobEditor extends ObjEditor implements ActionListener, ObjectUI
|
{
|
BlobEditor(Blob b, GroupEditor callee)
|
{
|
super(b, callee);
|
objEditor = callee.GetEditor();
|
|
this.blob = b;
|
selectees = b.selection;
|
|
SetupUI2(objEditor);
|
}
|
|
BlobEditor(Blob b, Object3D copy, GroupEditor callee)
|
{
|
//objEditor = new ObjEditor(b, copy, callee);
|
super(b, copy, callee);
|
objEditor = this;
|
|
this.blob = (Blob) copy;
|
selectees = b.selection;
|
|
objEditor.SetupWindow();
|
SetupUI2(objEditor);
|
}
|
|
public ObjEditor GetEditor()
|
{
|
return objEditor;
|
}
|
|
void SetupUI2(ObjEditor oe)
|
{
|
super.SetupUI2(oe);
|
|
oe.ctrlPanel.add(thresholdLabel = new JLabel("Threshold:")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
|
oe.ctrlPanel.Return();
|
|
oe.ctrlPanel.add(thresholdField = new NumberField()); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
thresholdField.addActionListener(this);
|
thresholdField.setFloat(blob.threshold);
|
|
oe.ctrlPanel.Return();
|
|
oe.ctrlPanel.add(newButton = new JButton("New Ball")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
newButton.addActionListener(this);
|
oe.ctrlPanel.Return();
|
|
oe.ctrlPanel.add(deleteButton = new JButton("Delete Ball")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
deleteButton.addActionListener(this);
|
oe.ctrlPanel.Return();
|
|
/*
|
oe.ctrlPanel.add(strengthLabel = new JLabel("Strength:")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
|
oe.ctrlPanel.Return();
|
|
oe.ctrlPanel.add(strengthField = new NumberField()); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
strengthField.addActionListener(this);
|
|
oe.ctrlPanel.Return();
|
*/
|
|
toCompFields();
|
|
oe.ctrlPanel.add(sizeLabel = new JLabel("Depth:")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
|
oe.ctrlPanel.Return();
|
|
oe.ctrlPanel.add(sizeField = new NumberField()); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
sizeField.addActionListener(this);
|
sizeField.setFloat(blob.cellSize);
|
|
oe.ctrlPanel.Return();
|
|
oe.ctrlPanel.add(tolLabel = new JLabel("Tolerance:")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
|
oe.ctrlPanel.Return();
|
|
oe.ctrlPanel.add(tolField = new NumberField()); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
tolField.addActionListener(this);
|
tolField.setFloat(blob.tolerance);
|
|
oe.ctrlPanel.Return();
|
}
|
|
public void closeUI()
|
{
|
ObjEditor oe = GetEditor();
|
|
newButton.removeActionListener(this);
|
deleteButton.removeActionListener(this);
|
thresholdField.removeActionListener(this);
|
strengthField.removeActionListener(this);
|
sizeField.removeActionListener(this);
|
tolField.removeActionListener(this);
|
oe.ctrlPanel.remove(newButton);
|
oe.ctrlPanel.remove(deleteButton);
|
oe.ctrlPanel.remove(thresholdLabel);
|
oe.ctrlPanel.remove(strengthLabel);
|
oe.ctrlPanel.remove(sizeLabel);
|
oe.ctrlPanel.remove(tolLabel);
|
oe.ctrlPanel.remove(thresholdField);
|
oe.ctrlPanel.remove(strengthField);
|
oe.ctrlPanel.remove(sizeField);
|
oe.ctrlPanel.remove(tolField);
|
//oe.ctrlPanel.repaint();
|
|
super.closeUI();
|
}
|
|
void Clear()
|
{
|
objEditor.Clear();
|
|
blob = null;
|
}
|
|
public void actionPerformed(ActionEvent e)
|
{
|
if (e.getSource() == thresholdField ||
|
e.getSource() == strengthField ||
|
e.getSource() == sizeField ||
|
e.getSource() == tolField)
|
{
|
applySelf();
|
refreshContents();
|
}
|
else if (e.getSource() == newButton)
|
{
|
fromCompFields();
|
BlobComponent comp = new BlobComponent();
|
blob.deselectAll();
|
blob.addChild(comp);
|
blob.addSelectee(comp);
|
applySelf();
|
refreshContents();
|
}
|
else if (e.getSource() == deleteButton)
|
{
|
BlobComponent comp;
|
for (; selectees.size() > 0; blob.removeChild(comp))
|
comp = (BlobComponent)selectees.elementAt(0);
|
|
applySelf();
|
refreshContents();
|
}
|
else
|
super.actionPerformed(e);
|
}
|
|
/*
|
public boolean action(Event event, Object arg)
|
{
|
if (event.target == newButton)
|
{
|
fromCompFields();
|
BlobComponent comp = new BlobComponent();
|
blob.deselectAll();
|
blob.addChild(comp);
|
blob.addSelectee(comp);
|
refreshContents();
|
return true;
|
}
|
if (event.target == deleteButton)
|
{
|
BlobComponent comp;
|
for (; selectees.size() > 0; blob.removeChild(comp))
|
comp = (BlobComponent)selectees.elementAt(0);
|
|
refreshContents();
|
return true;
|
} else
|
{
|
return super.action(event, arg);
|
}
|
}
|
*/
|
|
/*
|
public void doLayout()
|
{
|
super.doLayout();
|
labelAndField(thresholdLabel, thresholdField);
|
widgetPos += 5;
|
newButton.setBounds(5, widgetPos, 190, buttonHeight);
|
widgetPos += buttonHeight;
|
labelAndField(strengthLabel, strengthField);
|
deleteButton.setBounds(5, widgetPos, 190, buttonHeight);
|
widgetPos += buttonHeight + 5;
|
labelAndField(sizeLabel, sizeField);
|
widgetPos += 5;
|
}
|
*/
|
|
public void applySelf()
|
{
|
// june 2013 super.applySelf();
|
blob.cellSize = sizeField.getFloat(1, 100);
|
blob.tolerance = tolField.getFloat(0, 100);
|
blob.threshold = thresholdField.getFloat(0, 10000);
|
fromCompFields();
|
blob.retile();
|
}
|
|
void refreshContents()
|
{
|
objEditor.refreshContents();
|
toCompFields();
|
}
|
|
void toCompFields()
|
{
|
// if (selectees.size() == 1)
|
// {
|
// BlobComponent comp = (BlobComponent)selectees.get(0);
|
// strengthField.setFloat(comp.strength);
|
// } else
|
// {
|
// strengthField.setText("");
|
// }
|
}
|
|
void fromCompFields()
|
{
|
// if (selectees.size() == 1)
|
// {
|
// BlobComponent comp = (BlobComponent)selectees.elementAt(0);
|
// comp.strength = strengthField.getFloat(0, 10000);
|
// }
|
}
|
|
Blob blob;
|
Vector selectees;
|
JLabel thresholdLabel;
|
JLabel strengthLabel;
|
JLabel sizeLabel;
|
JLabel tolLabel;
|
NumberField thresholdField;
|
NumberField strengthField;
|
NumberField sizeField;
|
NumberField tolField;
|
JButton newButton;
|
JButton deleteButton;
|
|
//ObjEditor objEditor;
|
}
|