| .. | .. |
|---|
| 10 | 10 | |
|---|
| 11 | 11 | import java.util.Vector; |
|---|
| 12 | 12 | |
|---|
| 13 | +import grafeme.ui.*; |
|---|
| 14 | + |
|---|
| 13 | 15 | class CSGEditor extends ObjEditor implements ChangeListener, ActionListener, ObjectUI |
|---|
| 14 | 16 | { |
|---|
| 15 | 17 | |
|---|
| .. | .. |
|---|
| 44 | 46 | super.SetupUI2(oe); // Shows composite UI !! |
|---|
| 45 | 47 | //super.SetupName(oe); |
|---|
| 46 | 48 | |
|---|
| 47 | | - oe.aConstraints.weighty = 0; |
|---|
| 49 | + oe.ctrlPanel.add(refreshButton = new JButton("Refresh")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 50 | + oe.ctrlPanel.Return(); |
|---|
| 48 | 51 | |
|---|
| 49 | | - oe.aConstraints.fill = 0; |
|---|
| 50 | | - oe.aConstraints.gridwidth = 1; |
|---|
| 51 | | - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 52 | | - oe.ctrlPanel.add(refreshButton = new JButton("Refresh"), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 53 | | - oe.aConstraints.gridwidth = 1; |
|---|
| 54 | | - oe.aConstraints.gridx /* = 0; |
|---|
| 55 | | - oe.aConstraints.gridy */ += 1; |
|---|
| 56 | | - |
|---|
| 57 | | - oe.aConstraints.fill = 0; |
|---|
| 58 | | - oe.aConstraints.gridwidth = 1; |
|---|
| 59 | | - //this.csg = (CSG) copy; |
|---|
| 52 | + menuPane = new cGridBag(); |
|---|
| 53 | + oe.ctrlPanel.add(menuPane); |
|---|
| 54 | + oe.ctrlPanel.Return(); |
|---|
| 55 | + |
|---|
| 56 | + menuPane2 = new cGridBag(); |
|---|
| 57 | + oe.ctrlPanel.add(menuPane2); |
|---|
| 58 | + oe.ctrlPanel.Return(); |
|---|
| 59 | + |
|---|
| 60 | + //this.csg = (CSG) copy; |
|---|
| 60 | 61 | /* |
|---|
| 61 | 62 | oe.ctrlPanel.add(typeLabel = new JLabel("Type"), oe.aConstraints); |
|---|
| 62 | 63 | oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| .. | .. |
|---|
| 67 | 68 | list.add("Merge"); |
|---|
| 68 | 69 | list.add("Intersection"); |
|---|
| 69 | 70 | list.add("Difference"); |
|---|
| 70 | | - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 71 | | - oe.ctrlPanel.add(typeMenu = new JComboBox(new ObjEditor.cListModel(list, csg.csgType - 1)), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 71 | + menuPane.add(typeMenu = new JComboBox(new ObjEditor.cListModel(list, csg.csgType - 1))); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 72 | 72 | //typeMenu.select(csg.csgType - 1); |
|---|
| 73 | 73 | |
|---|
| 74 | | - oe.aConstraints.gridx += 1; |
|---|
| 75 | | - //oe.aConstraints.gridy += 1; |
|---|
| 76 | | - //oe.aConstraints.gridx = 0; |
|---|
| 77 | | - |
|---|
| 74 | + oe.ctrlPanel.Return(); |
|---|
| 75 | + |
|---|
| 78 | 76 | list = new Vector(); |
|---|
| 79 | 77 | list.add("Surface"); |
|---|
| 80 | 78 | list.add("Volume"); |
|---|
| 81 | 79 | list.add("Inner"); |
|---|
| 82 | 80 | list.add("Outer"); |
|---|
| 83 | 81 | list.add("Boundary"); |
|---|
| 82 | + |
|---|
| 84 | 83 | /* |
|---|
| 85 | 84 | oe.aConstraints.fill = 0; |
|---|
| 86 | 85 | oe.ctrlPanel.add(genLabel = new JLabel("Generation"), oe.aConstraints); |
|---|
| 87 | 86 | oe.aConstraints.gridx += 1; |
|---|
| 88 | 87 | */ |
|---|
| 89 | | - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 90 | | - oe.ctrlPanel.add(genMenu = new JComboBox(new ObjEditor.cListModel(list, 0)), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 88 | + menuPane.add(genMenu = new JComboBox(new ObjEditor.cListModel(list, 0))); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 91 | 89 | //typeMenu.select(csg.csgType - 1); |
|---|
| 92 | | - //oe.aConstraints.gridy += 1; |
|---|
| 93 | | - oe.aConstraints.gridx += 1; |
|---|
| 94 | 90 | |
|---|
| 95 | | - oe.ctrlPanel.Return(); |
|---|
| 96 | | - |
|---|
| 97 | 91 | list = new Vector(); |
|---|
| 98 | 92 | list.add("Smooth"); |
|---|
| 99 | 93 | list.add("Flat"); |
|---|
| .. | .. |
|---|
| 102 | 96 | oe.ctrlPanel.add(normalsLabel = new JLabel("Shading"), oe.aConstraints); |
|---|
| 103 | 97 | oe.aConstraints.gridx += 1; |
|---|
| 104 | 98 | */ |
|---|
| 105 | | - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 106 | | - oe.ctrlPanel.add(normalsMenu = new JComboBox(new ObjEditor.cListModel(list, 0)), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 99 | + menuPane2.add(normalsMenu = new JComboBox(new ObjEditor.cListModel(list, 0))); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 107 | 100 | //typeMenu.select(csg.csgType - 1); |
|---|
| 108 | | - oe.aConstraints.gridx += 1; |
|---|
| 109 | | - oe.aConstraints.gridwidth = 1; |
|---|
| 110 | 101 | |
|---|
| 111 | 102 | list = new Vector(); |
|---|
| 112 | 103 | list.add("Strip"); |
|---|
| .. | .. |
|---|
| 117 | 108 | oe.ctrlPanel.add(normalsLabel = new JLabel("Shading"), oe.aConstraints); |
|---|
| 118 | 109 | oe.aConstraints.gridx += 1; |
|---|
| 119 | 110 | */ |
|---|
| 120 | | - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 121 | | - oe.ctrlPanel.add(stripifyMenu = new JComboBox(new ObjEditor.cListModel(list, 0)), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 111 | + menuPane2.add(stripifyMenu = new JComboBox(new ObjEditor.cListModel(list, 0))); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 122 | 112 | //typeMenu.select(csg.csgType - 1); |
|---|
| 123 | | - oe.aConstraints.gridy += 1; |
|---|
| 124 | | - oe.aConstraints.gridx = 0; |
|---|
| 125 | | - oe.aConstraints.gridwidth = 1; |
|---|
| 126 | 113 | |
|---|
| 127 | | - //oe.aConstraints.fill = 0; |
|---|
| 128 | | - oe.ctrlPanel.add(sizeLabel = new JLabel("Depth"), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 129 | | - oe.aConstraints.gridx += 1; |
|---|
| 130 | | - oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; |
|---|
| 131 | | - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 132 | | - oe.ctrlPanel.add(sizeField = new NumberSlider(0,10), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 133 | | - oe.aConstraints.gridy += 1; |
|---|
| 134 | | - oe.aConstraints.gridx = 0; |
|---|
| 114 | +// oe.ctrlPanel.add(sizeLabel = new JLabel("Depth")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 115 | +// oe.ctrlPanel.add(sizeSlider = new NumberSlider(0,10)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 116 | + sizeSliderPane = AddSlider(oe.ctrlPanel, "Depth", 0, 10, 0); |
|---|
| 117 | + sizeSlider = (cNumberSlider)sizeSliderPane.getComponent(1); |
|---|
| 118 | + oe.ctrlPanel.Return(); |
|---|
| 135 | 119 | |
|---|
| 136 | | - oe.aConstraints.fill = 0; |
|---|
| 137 | | - oe.aConstraints.gridwidth = 1; |
|---|
| 138 | | - oe.ctrlPanel.add(size2Label = new JLabel("Depth2"), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 139 | | - oe.aConstraints.gridx += 1; |
|---|
| 140 | | - oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; |
|---|
| 141 | | - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 142 | | - oe.ctrlPanel.add(size2Field = new NumberSlider(0,10), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 143 | | - oe.aConstraints.gridy += 1; |
|---|
| 144 | | - oe.aConstraints.gridx = 0; |
|---|
| 120 | +// oe.ctrlPanel.add(size2Label = new JLabel("Depth2")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 121 | +// oe.ctrlPanel.add(size2Slider = new NumberSlider(0,10)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 122 | + size2SliderPane = AddSlider(oe.ctrlPanel, "Depth2", 0, 10, 0); |
|---|
| 123 | + size2Slider = (cNumberSlider)size2SliderPane.getComponent(1); |
|---|
| 124 | + oe.ctrlPanel.Return(); |
|---|
| 145 | 125 | |
|---|
| 146 | | - oe.aConstraints.gridwidth = 1; |
|---|
| 147 | | - oe.aConstraints.fill = 0; |
|---|
| 148 | | - oe.ctrlPanel.add(tolLabel = new JLabel("Tolerance"), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 149 | | - oe.aConstraints.gridx += 1; |
|---|
| 150 | | - oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; |
|---|
| 151 | | - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 152 | | - oe.ctrlPanel.add(tolField = new NumberSlider(0,10,1), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 153 | | - oe.aConstraints.gridy += 1; |
|---|
| 154 | | - oe.aConstraints.gridx = 0; |
|---|
| 155 | | - oe.aConstraints.gridwidth = 1; |
|---|
| 126 | +// oe.ctrlPanel.add(tolLabel = new JLabel("Tolerance")); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 127 | +// oe.ctrlPanel.add(toleranceSlider = new NumberSlider(0,10,1)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2); |
|---|
| 128 | + toleranceSliderPane = AddSlider(oe.ctrlPanel, "Tolerance", 0, 10, 1, 1); |
|---|
| 129 | + toleranceSlider = (cNumberSlider)toleranceSliderPane.getComponent(1); |
|---|
| 130 | + oe.ctrlPanel.Return(); |
|---|
| 156 | 131 | |
|---|
| 157 | | - sizeField.setInteger(csg.cellSize); |
|---|
| 158 | | - size2Field.setInteger(csg.cellSize2); |
|---|
| 132 | + sizeSlider.setInteger(csg.cellSize); |
|---|
| 133 | + size2Slider.setInteger(csg.cellSize2); |
|---|
| 159 | 134 | System.out.println("csg.tolerance = " + csg.tolerance); |
|---|
| 160 | | - tolField.setFloat(csg.tolerance); |
|---|
| 135 | + toleranceSlider.setFloat(csg.tolerance); |
|---|
| 161 | 136 | normalsMenu.setSelectedIndex(csg.normals?0:1); |
|---|
| 162 | 137 | typeMenu.setSelectedIndex(csg.csgType - 1); |
|---|
| 163 | 138 | genMenu.setSelectedIndex(csg.genType); |
|---|
| 164 | 139 | stripifyMenu.setSelectedIndex(csg.userType); // ==0?0:1); |
|---|
| 165 | 140 | |
|---|
| 166 | | - sizeField.addChangeListener(this); |
|---|
| 167 | | - size2Field.addChangeListener(this); |
|---|
| 168 | | - tolField.addChangeListener(this); |
|---|
| 141 | + sizeSlider.addChangeListener(this); |
|---|
| 142 | + size2Slider.addChangeListener(this); |
|---|
| 143 | + toleranceSlider.addChangeListener(this); |
|---|
| 169 | 144 | |
|---|
| 170 | 145 | typeMenu.addActionListener(this); |
|---|
| 171 | 146 | genMenu.addActionListener(this); |
|---|
| .. | .. |
|---|
| 199 | 174 | normalsMenu.removeActionListener(this); |
|---|
| 200 | 175 | refreshButton.removeActionListener(this); |
|---|
| 201 | 176 | |
|---|
| 202 | | - sizeField.removeChangeListener(this); |
|---|
| 203 | | - size2Field.removeChangeListener(this); |
|---|
| 204 | | - tolField.removeChangeListener(this); |
|---|
| 205 | | - oe.ctrlPanel.remove(sizeField); |
|---|
| 206 | | - oe.ctrlPanel.remove(size2Field); |
|---|
| 207 | | - oe.ctrlPanel.remove(tolField); |
|---|
| 208 | | - oe.ctrlPanel.remove(sizeLabel); |
|---|
| 209 | | - oe.ctrlPanel.remove(size2Label); |
|---|
| 210 | | - oe.ctrlPanel.remove(tolLabel); |
|---|
| 211 | | - oe.ctrlPanel.remove(typeMenu); |
|---|
| 212 | | - //oe.ctrlPanel.remove(typeLabel); |
|---|
| 213 | | - oe.ctrlPanel.remove(genMenu); |
|---|
| 214 | | - //oe.ctrlPanel.remove(genLabel); |
|---|
| 215 | | - oe.ctrlPanel.remove(normalsMenu); |
|---|
| 216 | | - oe.ctrlPanel.remove(stripifyMenu); |
|---|
| 217 | | - //oe.ctrlPanel.remove(normalsLabel); |
|---|
| 218 | | - oe.ctrlPanel.remove(refreshButton); |
|---|
| 219 | | - //oe.ctrlPanel.repaint(); |
|---|
| 177 | + sizeSlider.removeChangeListener(this); |
|---|
| 178 | + size2Slider.removeChangeListener(this); |
|---|
| 179 | + toleranceSlider.removeChangeListener(this); |
|---|
| 180 | + |
|---|
| 181 | + oe.ctrlPanel.remove(this.refreshButton); |
|---|
| 182 | + oe.ctrlPanel.remove(menuPane); |
|---|
| 183 | + oe.ctrlPanel.remove(menuPane2); |
|---|
| 184 | + oe.ctrlPanel.remove(sizeSliderPane); |
|---|
| 185 | + oe.ctrlPanel.remove(size2SliderPane); |
|---|
| 186 | + oe.ctrlPanel.remove(toleranceSliderPane); |
|---|
| 187 | + |
|---|
| 188 | +// oe.ctrlPanel.remove(sizeLabel); |
|---|
| 189 | +// oe.ctrlPanel.remove(size2Label); |
|---|
| 190 | +// oe.ctrlPanel.remove(tolLabel); |
|---|
| 191 | +// oe.ctrlPanel.remove(typeMenu); |
|---|
| 192 | +// //oe.ctrlPanel.remove(typeLabel); |
|---|
| 193 | +// oe.ctrlPanel.remove(genMenu); |
|---|
| 194 | +// //oe.ctrlPanel.remove(genLabel); |
|---|
| 195 | +// oe.ctrlPanel.remove(normalsMenu); |
|---|
| 196 | +// oe.ctrlPanel.remove(stripifyMenu); |
|---|
| 197 | +// //oe.ctrlPanel.remove(normalsLabel); |
|---|
| 198 | +// oe.ctrlPanel.remove(refreshButton); |
|---|
| 199 | +// //oe.ctrlPanel.repaint(); |
|---|
| 220 | 200 | |
|---|
| 221 | 201 | super.closeUI(); |
|---|
| 222 | 202 | } |
|---|
| .. | .. |
|---|
| 226 | 206 | { |
|---|
| 227 | 207 | super.doLayout(); |
|---|
| 228 | 208 | labelAndField(typeLabel, typeMenu); |
|---|
| 229 | | - labelAndField(sizeLabel, sizeField); |
|---|
| 209 | + labelAndField(sizeLabel, sizeSlider); |
|---|
| 230 | 210 | widgetPos += 5; |
|---|
| 231 | 211 | } |
|---|
| 232 | 212 | */ |
|---|
| .. | .. |
|---|
| 252 | 232 | |
|---|
| 253 | 233 | public void stateChanged(ChangeEvent e) |
|---|
| 254 | 234 | { |
|---|
| 255 | | - if (e.getSource() == sizeField || |
|---|
| 256 | | - e.getSource() == size2Field || |
|---|
| 257 | | - e.getSource() == tolField) |
|---|
| 235 | + if (e.getSource() == sizeSlider || |
|---|
| 236 | + e.getSource() == size2Slider || |
|---|
| 237 | + e.getSource() == toleranceSlider) |
|---|
| 258 | 238 | { |
|---|
| 259 | 239 | // Can't choose... |
|---|
| 260 | 240 | //applySelf(); |
|---|
| .. | .. |
|---|
| 272 | 252 | csg.genType = genMenu.getSelectedIndex(); |
|---|
| 273 | 253 | csg.normals = normalsMenu.getSelectedIndex() == 0; |
|---|
| 274 | 254 | csg.userType = stripifyMenu.getSelectedIndex(); |
|---|
| 275 | | - csg.cellSize = sizeField.getInteger(); |
|---|
| 276 | | - csg.cellSize2 = size2Field.getInteger(); |
|---|
| 277 | | - csg.tolerance = tolField.getFloat(); |
|---|
| 255 | + csg.cellSize = sizeSlider.getInteger(); |
|---|
| 256 | + csg.cellSize2 = size2Slider.getInteger(); |
|---|
| 257 | + csg.tolerance = toleranceSlider.getFloat(); |
|---|
| 278 | 258 | |
|---|
| 279 | 259 | if (csg.link2master) |
|---|
| 280 | 260 | csg.retile(); |
|---|
| 281 | 261 | } |
|---|
| 282 | 262 | |
|---|
| 283 | 263 | CSG csg; |
|---|
| 264 | + |
|---|
| 284 | 265 | JLabel typeLabel; |
|---|
| 285 | 266 | JLabel genLabel; |
|---|
| 286 | 267 | JLabel normalsLabel; |
|---|
| .. | .. |
|---|
| 291 | 272 | JComboBox genMenu; |
|---|
| 292 | 273 | JComboBox normalsMenu; |
|---|
| 293 | 274 | JComboBox stripifyMenu; |
|---|
| 294 | | - NumberSlider sizeField; |
|---|
| 295 | | - NumberSlider size2Field; |
|---|
| 296 | | - NumberSlider tolField; |
|---|
| 275 | + cNumberSlider sizeSlider; |
|---|
| 276 | + cNumberSlider size2Slider; |
|---|
| 277 | + cNumberSlider toleranceSlider; |
|---|
| 297 | 278 | |
|---|
| 279 | + cGridBag menuPane; |
|---|
| 280 | + cGridBag menuPane2; |
|---|
| 281 | + cGridBag sizeSliderPane; |
|---|
| 282 | + cGridBag size2SliderPane; |
|---|
| 283 | + cGridBag toleranceSliderPane; |
|---|
| 284 | + |
|---|
| 298 | 285 | JButton refreshButton; |
|---|
| 299 | 286 | |
|---|
| 300 | 287 | //GroupEditor objEditor; |
|---|