1 | //////////////////////////////////////////////////////////////////////// |
---|
2 | // |
---|
3 | // This file LampAdmin.java is part of SURFEX. |
---|
4 | // |
---|
5 | //////////////////////////////////////////////////////////////////////// |
---|
6 | |
---|
7 | //////////////////////////////////////////////////////////////////////// |
---|
8 | // |
---|
9 | // SURFEX version 0.90.00 |
---|
10 | // ================= |
---|
11 | // |
---|
12 | // Saarland University at Saarbruecken, Germany |
---|
13 | // Department of Mathematics and Computer Science |
---|
14 | // |
---|
15 | // SURFEX on the web: www.surfex.AlgebraicSurface.net |
---|
16 | // |
---|
17 | // Authors: Oliver Labs (2001-2008), Stephan Holzer (2004-2005) |
---|
18 | // |
---|
19 | // Copyright (C) 2001-2008 |
---|
20 | // |
---|
21 | // |
---|
22 | // *NOTICE* |
---|
23 | // ======== |
---|
24 | // |
---|
25 | // This program is free software; you can redistribute it and/or modify it |
---|
26 | // under the terms of the GNU General Public License as published by the |
---|
27 | // Free Software Foundation ( version 3 or later of the License ). |
---|
28 | // |
---|
29 | // See LICENCE.TXT for details. |
---|
30 | // |
---|
31 | ///////////////////////////////////////////////////////////////////////// |
---|
32 | |
---|
33 | import java.awt.BorderLayout; |
---|
34 | import java.awt.Color; |
---|
35 | import java.awt.FlowLayout; |
---|
36 | import java.awt.GridLayout; |
---|
37 | import java.awt.event.ActionEvent; |
---|
38 | import java.awt.event.ActionListener; |
---|
39 | import java.awt.event.WindowAdapter; |
---|
40 | import java.awt.event.WindowEvent; |
---|
41 | import java.io.BufferedReader; |
---|
42 | import java.io.IOException; |
---|
43 | import java.net.MalformedURLException; |
---|
44 | import java.net.URL; |
---|
45 | import java.util.ListIterator; |
---|
46 | import java.util.*; |
---|
47 | |
---|
48 | import javax.swing.*; |
---|
49 | import javax.swing.SwingUtilities; |
---|
50 | import javax.swing.event.ChangeEvent; |
---|
51 | import javax.swing.event.ChangeListener; |
---|
52 | |
---|
53 | import jv.vecmath.*; |
---|
54 | ////////////////////////////////////////////////////////////// |
---|
55 | // |
---|
56 | // class ParameterAdmin |
---|
57 | // |
---|
58 | ////////////////////////////////////////////////////////////// |
---|
59 | |
---|
60 | public class LampAdmin extends JFrame implements ActionListener { |
---|
61 | |
---|
62 | final int N=7; // ANzahl Objekte pro Lampe in GUI |
---|
63 | JPanel[] lampPanel=new JPanel[N+1]; |
---|
64 | JPanel[] lampPanelContent=new JPanel[N+1]; |
---|
65 | |
---|
66 | boolean lastRAB; |
---|
67 | |
---|
68 | //LampAdminUpdater lampAdminUpdater; |
---|
69 | |
---|
70 | //JComboBox paramComboBox; // used for SaveMovieDialog |
---|
71 | |
---|
72 | public Vector lampList = new Vector(); |
---|
73 | |
---|
74 | // updateJV4SX(); |
---|
75 | double lastScale = 1.0; |
---|
76 | PdVector lastViewDir = new PdVector(3.2, 0.3, -0.9); |
---|
77 | PdVector lastPosition = new PdVector(10.0, 20.0, -20.0); |
---|
78 | PdVector lastUpVector = new PdVector(0.0, 0.0, 0.0); |
---|
79 | PdVector lastInterest = new PdVector(0.0, 0.0, 0.0); |
---|
80 | |
---|
81 | Project pro; |
---|
82 | |
---|
83 | Lamp theDarkLamp; |
---|
84 | |
---|
85 | int selectedLamp; |
---|
86 | |
---|
87 | boolean lampIsSelected=false; |
---|
88 | |
---|
89 | surfex surfex; |
---|
90 | |
---|
91 | RayFrame LampPrevRayFrame;// |
---|
92 | |
---|
93 | JButton addButton = new JButton(); |
---|
94 | |
---|
95 | JSlider scaleSlider; |
---|
96 | |
---|
97 | public jv4surfex jv4sx = null; |
---|
98 | |
---|
99 | boolean showOnlySelectedLamp=true; |
---|
100 | |
---|
101 | JLabel scaleLabel; |
---|
102 | |
---|
103 | JPanel Panel = new JPanel(new BorderLayout()); |
---|
104 | |
---|
105 | JButton bt7 = new JButton(); |
---|
106 | |
---|
107 | // JCheckBox raytraceAlways = new JCheckBox("permanently", true); |
---|
108 | |
---|
109 | JCheckBox raytracePreview = new JCheckBox("ray preview", true); |
---|
110 | |
---|
111 | JCheckBox showTriangPrev = new JCheckBox("triang prev", true); |
---|
112 | |
---|
113 | JCheckBox antialiasing = new JCheckBox("antialiasing", false); |
---|
114 | |
---|
115 | JButton bgColorButton = null; |
---|
116 | |
---|
117 | String tmp_surfex_file = "tmp_surfex.jpg"; |
---|
118 | |
---|
119 | UpdateRayframeImmediatlyThread updateRayframeImmediatlyThread; |
---|
120 | |
---|
121 | LampAdmin(surfex su, Project pro) { |
---|
122 | |
---|
123 | super("Configure lamps of " + pro.filename); |
---|
124 | surfex = su; |
---|
125 | |
---|
126 | makeDarkLamp(); |
---|
127 | this.pro = pro; |
---|
128 | // create a new temporary filename: tmp_surfex_file |
---|
129 | Random myRNG = new Random(); |
---|
130 | int myRN = myRNG.nextInt(99999999); |
---|
131 | //System.out.println("rn:"+myRN); |
---|
132 | tmp_surfex_file = "tmp_surfex_lampPrev" + myRN + "_" |
---|
133 | + pro.ProjectNumber + ".jpg"; |
---|
134 | |
---|
135 | |
---|
136 | if (surfex.iaa) { |
---|
137 | jv4sx = new jv4surfex(true, surfex.theApplet, surfex, 624,100); |
---|
138 | // surfex.theApplet = theApplet; |
---|
139 | } else { |
---|
140 | jv4sx = new jv4surfex(false, null, surfex,624,100);//, 624); |
---|
141 | } |
---|
142 | //System.out.println(vec2Str(jv4sx.getCamPos())); |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | //jv4sx.show(); |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | //paramComboBox=new JComboBox(); |
---|
151 | |
---|
152 | JPanel controlPanel = new JPanel(new FlowLayout()); |
---|
153 | //JPanel flowPanel = new JPanel(new FlowLayout()); |
---|
154 | JButton saveas; |
---|
155 | try { |
---|
156 | if ((surfex.filePrefix).equals("")) { |
---|
157 | saveas = new JButton(new ImageIcon("saveas.gif")); |
---|
158 | } else { |
---|
159 | saveas = new JButton(new ImageIcon(new URL(surfex.filePrefix |
---|
160 | + "saveas.gif"))); |
---|
161 | } |
---|
162 | } catch (MalformedURLException e) { |
---|
163 | System.out.println(e.toString()); |
---|
164 | saveas = new JButton(); |
---|
165 | } |
---|
166 | saveas.setToolTipText("save this Lamp settings" + pro.projectName |
---|
167 | + " as"); |
---|
168 | saveas.addActionListener(this); |
---|
169 | saveas.setActionCommand("saveas"); |
---|
170 | //if(!surfex_.inAnApplet) { |
---|
171 | controlPanel.add(saveas); |
---|
172 | |
---|
173 | getContentPane().setLayout(new BorderLayout()); |
---|
174 | |
---|
175 | |
---|
176 | lampPanel[0]=new JPanel(new BorderLayout()); |
---|
177 | for(int kkk=0;kkk<N;kkk++){ |
---|
178 | lampPanel[kkk+1]=new JPanel(new BorderLayout()); |
---|
179 | lampPanelContent[kkk]=new JPanel(new GridLayout(11,1)); |
---|
180 | lampPanel[kkk].add(lampPanelContent[kkk],BorderLayout.WEST); |
---|
181 | lampPanel[kkk].add(lampPanel[kkk+1],BorderLayout.CENTER); |
---|
182 | } |
---|
183 | //lampPanel[N]=new JPanel(new BorderLayout()); |
---|
184 | //lampPanel[N]=new JPanel(new BorderLayout()); |
---|
185 | |
---|
186 | |
---|
187 | lampPanelContent[N]=new JPanel(new GridLayout(11,1)); |
---|
188 | |
---|
189 | lampPanel[N].add(lampPanelContent[N],BorderLayout.WEST); |
---|
190 | lampPanelContent[0].add(new JLabel(" Lamp ")); |
---|
191 | lampPanelContent[1].add(new JLabel(" preview ")); |
---|
192 | lampPanelContent[2].add(new JLabel(" x-Koord ")); |
---|
193 | lampPanelContent[3].add(new JLabel(" y-Koord ")); |
---|
194 | lampPanelContent[4].add(new JLabel(" z-Koord ")); |
---|
195 | lampPanelContent[5].add(new JLabel(" intensity ")); |
---|
196 | lampPanelContent[6].add(new JLabel(" color ")); |
---|
197 | lampPanelContent[7].add(new JLabel(" shines ")); |
---|
198 | |
---|
199 | |
---|
200 | //lampPanel[N].add(lampPanel[N-1],BorderLayout.CENTER); |
---|
201 | |
---|
202 | |
---|
203 | |
---|
204 | // add(lampPanelGes, BorderLayout.CENTER); |
---|
205 | |
---|
206 | |
---|
207 | |
---|
208 | // ADD-BUTTON |
---|
209 | /* addButton.setText("add lamp"); |
---|
210 | addButton.setToolTipText("add lamp"); |
---|
211 | // getContentPane().add(bt1); |
---|
212 | addButton.addActionListener(new ActionListener() { |
---|
213 | public void actionPerformed(ActionEvent evt) { |
---|
214 | addButtonActionPerformed(evt); |
---|
215 | } |
---|
216 | }); |
---|
217 | |
---|
218 | controlPanel.add(addButton); |
---|
219 | */ |
---|
220 | // a button for choosing the background color: |
---|
221 | bgColorButton = new JButton(); |
---|
222 | bgColorButton.setBackground(Color.white); |
---|
223 | bgColorButton.setToolTipText("select the background color"); |
---|
224 | bgColorButton.addActionListener(new ActionListener() { |
---|
225 | public void actionPerformed(ActionEvent evt) { |
---|
226 | bgColorButton.setBackground(JColorChooser.showDialog(null, |
---|
227 | "change the background color", bgColorButton |
---|
228 | .getBackground())); |
---|
229 | } |
---|
230 | }); |
---|
231 | //controlPanel.add(new JLabel("bg-color:")); |
---|
232 | // controlPanel.add(bgColorButton); |
---|
233 | |
---|
234 | /* raytraceAlways.addChangeListener(new ChangeListener() { |
---|
235 | public void stateChanged(ChangeEvent evt) { |
---|
236 | raytraceAlwaysChanged(evt); |
---|
237 | } |
---|
238 | }); |
---|
239 | controlPanel.add(raytraceAlways); |
---|
240 | */ |
---|
241 | raytracePreview.addChangeListener(new ChangeListener() { |
---|
242 | public void stateChanged(ChangeEvent evt) { |
---|
243 | |
---|
244 | //if(ChangeEvent.) |
---|
245 | //System.out.println("1 prev invisible"); |
---|
246 | raytraceAlwaysChanged(evt); |
---|
247 | |
---|
248 | } |
---|
249 | }); |
---|
250 | controlPanel.add(raytracePreview); |
---|
251 | |
---|
252 | showTriangPrev.addChangeListener(new ChangeListener() { |
---|
253 | public void stateChanged(ChangeEvent evt) { |
---|
254 | showTriangPrevChanged(evt); |
---|
255 | } |
---|
256 | }); |
---|
257 | controlPanel.add(showTriangPrev); |
---|
258 | |
---|
259 | JScrollPane lampPane = new JScrollPane(lampPanel[0]); |
---|
260 | |
---|
261 | Panel.add(controlPanel, BorderLayout.NORTH); |
---|
262 | Panel.add(lampPane, BorderLayout.CENTER); |
---|
263 | |
---|
264 | |
---|
265 | |
---|
266 | this.addWindowListener(new WindowAdapter() { |
---|
267 | public void windowClosing(WindowEvent evt) { |
---|
268 | System.out.println("closeevent"); |
---|
269 | lampManagerInvisible(); |
---|
270 | } |
---|
271 | }); |
---|
272 | |
---|
273 | |
---|
274 | int tret; |
---|
275 | |
---|
276 | |
---|
277 | loadDefaultLampSettig1(); |
---|
278 | |
---|
279 | lampPanelContent[0].add(new JLabel(" ")); // looks nicer |
---|
280 | |
---|
281 | |
---|
282 | |
---|
283 | this.setContentPane(Panel); |
---|
284 | Panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); |
---|
285 | this.pack(); |
---|
286 | this.setVisible(false); |
---|
287 | |
---|
288 | lastRAB=this.raytracePreview.isSelected(); |
---|
289 | //showall(); |
---|
290 | |
---|
291 | LampPrevRayFrame = new RayFrame("raytraced lamp preview"); |
---|
292 | LampPrevRayFrame.setSize(200 + LampPrevRayFrame.getInsets().left |
---|
293 | + LampPrevRayFrame.getInsets().right, 200 |
---|
294 | + LampPrevRayFrame.getInsets().top |
---|
295 | + LampPrevRayFrame.getInsets().bottom); |
---|
296 | LampPrevRayFrame.setLocation(624, 200); |
---|
297 | LampPrevRayFrame.setInfo("your viewing direction\n is the lamp's one"); |
---|
298 | |
---|
299 | jv4sx.setPosTextFields2(getSelectedLamp().xPos,getSelectedLamp().yPos,getSelectedLamp().zPos); |
---|
300 | |
---|
301 | updateJV4SXandReconstructLastView(); |
---|
302 | // System.out.println(vec2Str(jv4sx.getCamPos())); |
---|
303 | |
---|
304 | // jv4sx.showDefault(); |
---|
305 | |
---|
306 | |
---|
307 | updateRayframeImmediatlyThread = new UpdateRayframeImmediatlyThread( |
---|
308 | LampPrevRayFrame, surfex, pro, jv4sx,pro.jv4sx, getModifiedLampList(), |
---|
309 | showOnlySelectedLamp,getSelectedLamp()); |
---|
310 | updateRayframeImmediatlyThread.start(); |
---|
311 | |
---|
312 | |
---|
313 | |
---|
314 | // |
---|
315 | |
---|
316 | SwingUtilities.updateComponentTreeUI(this); |
---|
317 | } |
---|
318 | |
---|
319 | public String vec2Str(double[] v) { |
---|
320 | return ("<" + v[0] + "," + v[1] + "," + v[2] + ">"); |
---|
321 | } |
---|
322 | |
---|
323 | public Lamp getSelectedLamp(){ |
---|
324 | //System.out.println("sdgdfgfdgfdg"); |
---|
325 | return ((Lamp)lampList.elementAt(selectedLamp)); |
---|
326 | } |
---|
327 | |
---|
328 | public Lamp getCameraLamp(){ |
---|
329 | // Lampe die von der Kamera aus strahlt |
---|
330 | // mit helligkeit und farbe der SelectedLamp |
---|
331 | // die man gerade einstellen will |
---|
332 | return getSelectedLamp().previewLamp(0.0,0.0,100.0); |
---|
333 | } |
---|
334 | |
---|
335 | public Vector getModifiedLampList(){ |
---|
336 | Vector lamps=new Vector(); |
---|
337 | lamps.add(getCameraLamp()); |
---|
338 | |
---|
339 | // switch off other lamps |
---|
340 | makeDarkLamp(); |
---|
341 | lamps.add(theDarkLamp); |
---|
342 | lamps.add(theDarkLamp); |
---|
343 | lamps.add(theDarkLamp); |
---|
344 | lamps.add(theDarkLamp); |
---|
345 | lamps.add(theDarkLamp); |
---|
346 | lamps.add(theDarkLamp); |
---|
347 | lamps.add(theDarkLamp); |
---|
348 | lamps.add(theDarkLamp); |
---|
349 | return lamps; |
---|
350 | |
---|
351 | } |
---|
352 | |
---|
353 | public void loadDefaultLampSettig1(){ |
---|
354 | |
---|
355 | newLamp(-100.000000,100.000000,100.000000,255,255,255,50,true); |
---|
356 | newLamp(0.000000,100.000000,100.000000,255,255,255,50,false); |
---|
357 | newLamp(100.000000,100.000000,100.000000,255,255,255,70,true); |
---|
358 | newLamp(-100.000000,0.000000,100.000000,255,255,255,50,false); |
---|
359 | newLamp(0.000000,0.000000,100.000000,255,255,255,50,false); |
---|
360 | newLamp(100.000000,0.000000,100.000000,255,255,255,50,false); |
---|
361 | newLamp(-100.000000,-100.000000,100.000000,255,255,255,50,false); |
---|
362 | newLamp(0.000000,-100.000000,100.000000,255,255,255,30,true); |
---|
363 | newLamp(100.000000,-100.000000,100.000000,255,255,255,50,false); |
---|
364 | |
---|
365 | |
---|
366 | lampIsSelected=true; |
---|
367 | setSelectedLamp(2); // Lampe 3 als selected betrachten |
---|
368 | // lampIsSelected=true |
---|
369 | // System.out.println("t1"+getSelectedLamp().getXpos()); |
---|
370 | } |
---|
371 | |
---|
372 | public void makeDarkLamp(){ |
---|
373 | Color c=new Color(0,0,0); |
---|
374 | theDarkLamp=getNewLamp(0.0,0.0,0.0,c,0,true); |
---|
375 | } |
---|
376 | |
---|
377 | public Lamp getNewLamp(double x, double y, double z, |
---|
378 | Color c, |
---|
379 | int i, |
---|
380 | boolean shines){ |
---|
381 | |
---|
382 | Lamp lamp=new Lamp(pro,this);//(Lamp)lampList.lastElement(); |
---|
383 | lamp.setKoords(x,y,z); |
---|
384 | lamp.setIntensity( i); |
---|
385 | lamp.setColor(c); |
---|
386 | lamp.setIsShining(shines); |
---|
387 | //SwingUtilities.updateComponentTreeUI(lamp); |
---|
388 | return lamp; |
---|
389 | |
---|
390 | } |
---|
391 | |
---|
392 | public Vector getLampsForJv4sx(){ |
---|
393 | // returned alle Lampen die angeschaltet sind. |
---|
394 | |
---|
395 | Vector list=new Vector(); |
---|
396 | ListIterator li=lampList.listIterator(); |
---|
397 | Lamp tmp; |
---|
398 | while(li.hasNext()){ |
---|
399 | tmp=((Lamp)li.next()); |
---|
400 | if((tmp.isShining()) && (tmp.lampNo-1 != selectedLamp)){ |
---|
401 | list.add(tmp); |
---|
402 | // System.out.println(tmp.lampNo+" "+selectedLamp); |
---|
403 | } |
---|
404 | } |
---|
405 | // while(list.size()<9){ |
---|
406 | // list.add(theDarkLamp); |
---|
407 | // System.out.println(theDarkLamp.getXpos()); |
---|
408 | |
---|
409 | // } |
---|
410 | return list; |
---|
411 | } |
---|
412 | |
---|
413 | public boolean lampIsSelected(){ |
---|
414 | return lampIsSelected;//selectedLamp)==null)?false:true; |
---|
415 | } |
---|
416 | public synchronized void setSelectedLamp(int no){ |
---|
417 | |
---|
418 | if(lampIsSelected()){ |
---|
419 | if(updateRayframeImmediatlyThread!=null){ |
---|
420 | updateRayframeImmediatlyThread.stop(); |
---|
421 | } |
---|
422 | getSelectedLamp().setSelected(false); |
---|
423 | selectedLamp=no; |
---|
424 | if(jv4sx!=null){ |
---|
425 | jv4sx.setPosTextFields2( |
---|
426 | getSelectedLamp().xPos,getSelectedLamp().yPos,getSelectedLamp().zPos); |
---|
427 | //System.out.println("joahr----"+((Lamp)getAllLamps().firstElement()).getXpos()); |
---|
428 | jv4sx.setLamps(getLampsForJv4sx()); |
---|
429 | // System.out.println("joahr2"); |
---|
430 | |
---|
431 | } |
---|
432 | lampIsSelected=true; |
---|
433 | }else{ |
---|
434 | selectedLamp=no; |
---|
435 | } |
---|
436 | |
---|
437 | |
---|
438 | getSelectedLamp().setSelected(true); |
---|
439 | // System.out.println("7"+vec2Str(jv4sx.getCamPos())); |
---|
440 | // System.out.println("t1"+getSelectedLamp().getXpos()); |
---|
441 | |
---|
442 | updatePreview(); |
---|
443 | // System.out.println("8"+vec2Str(jv4sx.getCamPos())); |
---|
444 | // System.out.println("t1"+getSelectedLamp().getXpos()); |
---|
445 | // System.out.println("joahr3"); |
---|
446 | } |
---|
447 | |
---|
448 | public void updatePreview(){ |
---|
449 | jv4sx.showDefault(); |
---|
450 | jv4sx.disp.getCamera().setPosition(getSelectedLamp().getPos()); |
---|
451 | |
---|
452 | |
---|
453 | newUpdateRayframeImmediatlyThread(); |
---|
454 | jv4sx.updateDisp(); |
---|
455 | } |
---|
456 | |
---|
457 | public Vector getAllLamps(){ |
---|
458 | // returned alle Lampen die angeschaltet sind. |
---|
459 | |
---|
460 | Vector list=new Vector(); |
---|
461 | ListIterator li=lampList.listIterator(); |
---|
462 | Lamp tmp; |
---|
463 | while(li.hasNext()){ |
---|
464 | tmp=((Lamp)li.next()); |
---|
465 | if(tmp.isShining()){ |
---|
466 | list.add(tmp); |
---|
467 | } |
---|
468 | } |
---|
469 | while(list.size()<9){ |
---|
470 | list.add(theDarkLamp); |
---|
471 | // System.out.println(theDarkLamp.getXpos()); |
---|
472 | |
---|
473 | } |
---|
474 | return list; |
---|
475 | } |
---|
476 | |
---|
477 | public void newLamp(double x, double y, double z, |
---|
478 | int r, int g, int b, |
---|
479 | int i, |
---|
480 | boolean shines){ |
---|
481 | newLamp(); |
---|
482 | Lamp lamp=(Lamp)lampList.lastElement(); |
---|
483 | lamp.setKoords(x,y,z); |
---|
484 | lamp.setIntensity( i); |
---|
485 | lamp.setColor(r,g,b); |
---|
486 | lamp.setIsShining(shines); |
---|
487 | //SwingUtilities.updateComponentTreeUI(lamp); |
---|
488 | |
---|
489 | |
---|
490 | } |
---|
491 | |
---|
492 | |
---|
493 | |
---|
494 | public void raytracePreviewChanged(ChangeEvent evt) { |
---|
495 | |
---|
496 | } |
---|
497 | |
---|
498 | public void showTriangPrevChanged(ChangeEvent evt) { |
---|
499 | // System.out.println( raytracePreviewisValid() +" "+ lastRAB); |
---|
500 | if (showTriangPrev.isSelected() != lastRAB) { |
---|
501 | |
---|
502 | // System.out.println("34 prev invisible"); |
---|
503 | if (showTriangPrev.isSelected()) { |
---|
504 | // System.out.println("22prev invisible"); |
---|
505 | //startRaytraceAlways(); |
---|
506 | jv4sx.setVisible(true); |
---|
507 | lastRAB = showTriangPrev.isSelected(); |
---|
508 | }else { |
---|
509 | // System.out.println("prev invisible"); |
---|
510 | jv4sx.setVisible(false); |
---|
511 | |
---|
512 | lastRAB = showTriangPrev.isSelected(); |
---|
513 | } |
---|
514 | } |
---|
515 | } |
---|
516 | |
---|
517 | public synchronized void raytraceAlwaysChanged(ChangeEvent evt) { |
---|
518 | |
---|
519 | //System.out.println( raytracePreviewisValid() +" "+ lastRAB); |
---|
520 | if (raytracePreview.isSelected() != lastRAB) { |
---|
521 | |
---|
522 | // System.out.println("34 prev invisible"); |
---|
523 | if (raytracePreview.isSelected()) { |
---|
524 | // System.out.println("22prev invisible"); |
---|
525 | startRaytraceAlways(); |
---|
526 | this.LampPrevRayFrame.setVisible(true); |
---|
527 | lastRAB = raytracePreview.isSelected(); |
---|
528 | }else { |
---|
529 | // System.out.println("prev invisible"); |
---|
530 | this.LampPrevRayFrame.setVisible(false); |
---|
531 | |
---|
532 | lastRAB = raytracePreview.isSelected(); |
---|
533 | } |
---|
534 | } |
---|
535 | } |
---|
536 | |
---|
537 | public void startRaytraceAlways() { |
---|
538 | // surfex_.configFrame.last[4] = true; |
---|
539 | // double ang[] = surfex_.getCurrentProject().eqAdm.getAngles(); |
---|
540 | // double scale[] = surfex_.getCurrentProject().eqAdm.getScales(); |
---|
541 | newUpdateRayframeImmediatlyThread(); |
---|
542 | // updateRayframeImmediatlyThread.start(); |
---|
543 | |
---|
544 | } |
---|
545 | |
---|
546 | public void newUpdateRayframeImmediatlyThread() { |
---|
547 | /* if(updateRayframeImmediatlyThread!=null){ |
---|
548 | updateRayframeImmediatlyThread.stop(); |
---|
549 | }*/ |
---|
550 | // updateRayframeImmediatlyThread = new UpdateRayframeImmediatlyThread( |
---|
551 | // this.LampPrevRayFrame, surfex, pro, jv4sx, this.getModifiedLampList(),showOnlySelectedLamp,getSelectedLamp()); |
---|
552 | } |
---|
553 | |
---|
554 | public void addButtonActionPerformed(ActionEvent evt) { |
---|
555 | newLamp(); |
---|
556 | } |
---|
557 | |
---|
558 | public void actionPerformed(ActionEvent e) { |
---|
559 | // jede Action die Performed wird kann nur ein close sein ... |
---|
560 | // --> close all connected windows |
---|
561 | System.out.println("close"); |
---|
562 | lampManagerInvisible(); |
---|
563 | } |
---|
564 | |
---|
565 | |
---|
566 | |
---|
567 | public void lampManagerInvisible(){ |
---|
568 | setVisible(false); |
---|
569 | this.LampPrevRayFrame.setVisible(false); |
---|
570 | jv4sx.setVisible(false); |
---|
571 | } |
---|
572 | |
---|
573 | public void newLamp() { |
---|
574 | // System.out.println("newParameter"); |
---|
575 | Lamp lamp = new Lamp(pro, this,lampPanelContent); |
---|
576 | |
---|
577 | // find a non-used parameter number: |
---|
578 | int n = lampList.size() + 1; |
---|
579 | ListIterator li = lampList.listIterator(); |
---|
580 | while (li.hasNext()) { |
---|
581 | if (n == ((Lamp) (li.next())).lampNo) { |
---|
582 | // if the parameter number n is already in use |
---|
583 | n = n + 1; // try the next number |
---|
584 | // reset the list iterator to the first element in the list: |
---|
585 | while (li.hasPrevious()) { |
---|
586 | li.previous(); |
---|
587 | } |
---|
588 | } |
---|
589 | } |
---|
590 | lamp.setLampNo(n); |
---|
591 | // System.out.println("parNo:"+n); |
---|
592 | |
---|
593 | // add this parameter to the list: |
---|
594 | lampList.add(lamp); |
---|
595 | // System.out.println("lampList:"+lampList.size()); |
---|
596 | //lampPanel.add(lamp); |
---|
597 | /* |
---|
598 | if (this.surfex.getCurrentProject()!=null){ |
---|
599 | if (this.surfex.getCurrentProject().saveMovieDialog != null) { |
---|
600 | // update only if exists... |
---|
601 | SwingUtilities.updateComponentTreeUI(this.surfex |
---|
602 | .getCurrentProject().saveMovieDialog); |
---|
603 | } |
---|
604 | }*/ |
---|
605 | //SwingUtilities.updateComponentTreeUI(this); |
---|
606 | //SwingUtilities.updateComponentTreeUI(this); |
---|
607 | } |
---|
608 | |
---|
609 | public String save() { |
---|
610 | String str = ""; |
---|
611 | ListIterator li = lampList.listIterator(); |
---|
612 | str += "////////////////// LAMPS: /////////////////////////" + "\n"; |
---|
613 | str += lampList.size() + "\n"; |
---|
614 | while (li.hasNext()) { |
---|
615 | str += ((Lamp) li.next()).saveYourself(); |
---|
616 | } |
---|
617 | return (str); |
---|
618 | } |
---|
619 | |
---|
620 | public void loadParameters(BufferedReader bs, String datatype) { |
---|
621 | int k; |
---|
622 | try { |
---|
623 | String nix = bs.readLine(); |
---|
624 | String zeile1; |
---|
625 | boolean first = true; |
---|
626 | |
---|
627 | for (k = Integer.parseInt(bs.readLine()); k > 0; k--) { |
---|
628 | zeile1 = bs.readLine();//) != null) { |
---|
629 | newLamp(); |
---|
630 | if (datatype.equals("specify")) { |
---|
631 | String strline; |
---|
632 | try { |
---|
633 | bs.mark(255); |
---|
634 | strline = bs.readLine(); |
---|
635 | while ((strline.equals("parno:")) |
---|
636 | || (strline.equals("fromtoval:"))) { |
---|
637 | // System.out.println("strline:"+strline); |
---|
638 | if (strline.equals("parno:")) { |
---|
639 | ((OneParameter) lampList.lastElement()) |
---|
640 | .setParNo(Integer.parseInt(bs |
---|
641 | .readLine())); |
---|
642 | } |
---|
643 | if (strline.equals("fromtoval:")) { |
---|
644 | ((OneParameter) lampList.lastElement()).oldFrom = Double |
---|
645 | .parseDouble(bs.readLine()); |
---|
646 | ((OneParameter) lampList.lastElement()).newFrom = ((OneParameter) lampList |
---|
647 | .lastElement()).oldFrom; |
---|
648 | |
---|
649 | ((OneParameter) lampList.lastElement()).oldTo = Double |
---|
650 | .parseDouble(bs.readLine()); |
---|
651 | ((OneParameter) lampList.lastElement()).newTo = ((OneParameter) lampList |
---|
652 | .lastElement()).oldTo; |
---|
653 | |
---|
654 | ((OneParameter) lampList.lastElement()).parSlider |
---|
655 | .setValue(Integer.parseInt(bs |
---|
656 | .readLine())); |
---|
657 | ((OneParameter) lampList.lastElement()) |
---|
658 | .updateparSliderAndLabel(); |
---|
659 | } |
---|
660 | bs.mark(255); |
---|
661 | strline = bs.readLine(); |
---|
662 | } // end while() |
---|
663 | bs.reset(); |
---|
664 | } catch (Exception nex) { |
---|
665 | bs.reset(); |
---|
666 | } |
---|
667 | } |
---|
668 | if (datatype.equals("complete") || datatype.equals("onlyeqns") |
---|
669 | || datatype.equals("eqnsvis")) { |
---|
670 | ((OneParameter) lampList.lastElement()).setParNo(Integer |
---|
671 | .parseInt(bs.readLine())); |
---|
672 | ((OneParameter) lampList.lastElement()).oldFrom = Double |
---|
673 | .parseDouble(bs.readLine()); |
---|
674 | ((OneParameter) lampList.lastElement()).newFrom = ((OneParameter) lampList |
---|
675 | .lastElement()).oldFrom; |
---|
676 | ((OneParameter) lampList.lastElement()).oldTo = Double |
---|
677 | .parseDouble(bs.readLine()); |
---|
678 | ((OneParameter) lampList.lastElement()).newTo = ((OneParameter) lampList |
---|
679 | .lastElement()).oldTo; |
---|
680 | ((OneParameter) lampList.lastElement()).parSlider |
---|
681 | .setValue(Integer.parseInt(bs.readLine())); |
---|
682 | ((OneParameter) lampList.lastElement()).from.setText("" |
---|
683 | + ((OneParameter) lampList.lastElement()).newFrom); |
---|
684 | ((OneParameter) lampList.lastElement()).to.setText("" |
---|
685 | + ((OneParameter) lampList.lastElement()).newTo); |
---|
686 | ((OneParameter) lampList.lastElement()) |
---|
687 | .updateparSliderAndLabel(); |
---|
688 | ((OneParameter) lampList.lastElement()).repaint(); |
---|
689 | } |
---|
690 | if (datatype.equals("complete") || datatype.equals("onlystyle")) { |
---|
691 | // ((OneParameter) lampList.lastElement()).cbox.setSelected((Boolean.valueOf(bs.readLine())).booleanValue()); |
---|
692 | } |
---|
693 | } |
---|
694 | } catch (IOException e) { |
---|
695 | System.out.println(e); |
---|
696 | } |
---|
697 | } |
---|
698 | |
---|
699 | /*public Vector getParameterNames(){ |
---|
700 | Vector l = new Vector();//new String[lampList.size()]; |
---|
701 | |
---|
702 | ListIterator li = lampList.listIterator(); |
---|
703 | while (li.hasNext()) { |
---|
704 | l.add(((OneParameter)li.next()).nameLabel.getText()) ; |
---|
705 | //i++; |
---|
706 | } |
---|
707 | return l; |
---|
708 | }*/ |
---|
709 | |
---|
710 | public OneParameter getParameter(String s) { |
---|
711 | ListIterator li = lampList.listIterator(); |
---|
712 | OneParameter tmpParameter; |
---|
713 | while (li.hasNext()) { |
---|
714 | tmpParameter = ((OneParameter) li.next()); |
---|
715 | if (tmpParameter.nameLabel.getText().compareTo(s) == 0) { |
---|
716 | return tmpParameter; |
---|
717 | } |
---|
718 | |
---|
719 | //i++; |
---|
720 | } |
---|
721 | return null; |
---|
722 | } |
---|
723 | |
---|
724 | public void showall() { |
---|
725 | jv4sx.show(); |
---|
726 | LampPrevRayFrame.setVisible(true); |
---|
727 | LampPrevRayFrame.toFront(); |
---|
728 | setVisible(true); |
---|
729 | toFront(); |
---|
730 | } |
---|
731 | |
---|
732 | public void lampManagerToFront(){ |
---|
733 | this.setVisible(true); |
---|
734 | LampPrevRayFrame.setVisible(true); |
---|
735 | jv4sx.setVisible(true); |
---|
736 | } |
---|
737 | |
---|
738 | public void updateJV4SXandReconstructLastView() { |
---|
739 | // System.out.println("updateJV4SXandRec..."); |
---|
740 | // jv4sx.disp.getCamera().setUpVector(lastUpVector); |
---|
741 | // jv4sx.disp.getCamera().setViewDir(lastViewDir); |
---|
742 | //jv4sx.disp.getCamera().setFullPosition(lastInterest, lastPosition, lastUpVector); |
---|
743 | |
---|
744 | jv4sx.changeFrameTitle("Lamppreview "+pro.projectName |
---|
745 | + "(uses JavaView)"); |
---|
746 | jv4sx.updateDisp(); |
---|
747 | } |
---|
748 | |
---|
749 | |
---|
750 | |
---|
751 | } // end class ParameterAdmin |
---|
752 | |
---|