Normand Briere
2019-09-24 767be784dc7fe293bf5c5ee6507df242526be3ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
// 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;
}