1 | //////////////////////////////////////////////////////////////////////// |
---|
2 | // |
---|
3 | // This file Lamp.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.event.ActionEvent; |
---|
37 | import java.awt.event.ActionListener; |
---|
38 | import java.io.PrintWriter; |
---|
39 | import java.text.NumberFormat; |
---|
40 | |
---|
41 | import javax.swing.*;//JButton; |
---|
42 | import javax.swing.JCheckBox; |
---|
43 | import javax.swing.JColorChooser; |
---|
44 | import javax.swing.JLabel; |
---|
45 | import javax.swing.JPanel; |
---|
46 | import javax.swing.JSlider; |
---|
47 | import javax.swing.JTextField; |
---|
48 | import javax.swing.event.ChangeEvent; |
---|
49 | import javax.swing.event.ChangeListener; |
---|
50 | import java.util.*; |
---|
51 | |
---|
52 | import jv.vecmath.*; |
---|
53 | |
---|
54 | ////////////////////////////////////////////////////////////// |
---|
55 | // |
---|
56 | // class Lamp |
---|
57 | // |
---|
58 | ////////////////////////////////////////////////////////////// |
---|
59 | |
---|
60 | public class Lamp extends JPanel { |
---|
61 | |
---|
62 | // Anfang Variablen |
---|
63 | |
---|
64 | // JButton deleteLampButton = new JButton("del"); |
---|
65 | |
---|
66 | JButton colorButton; |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | String lastX = "0"; |
---|
71 | |
---|
72 | String lastY = "0"; |
---|
73 | |
---|
74 | String lastZ = "0"; |
---|
75 | |
---|
76 | String lastXj = "0"; |
---|
77 | |
---|
78 | String lastYj = "0"; |
---|
79 | |
---|
80 | String lastZj = "0"; |
---|
81 | |
---|
82 | //Lichtstaerke lichtstaerke; |
---|
83 | |
---|
84 | ////////////////////////////// |
---|
85 | Project project; |
---|
86 | |
---|
87 | public int lampNo = 0; |
---|
88 | |
---|
89 | public JCheckBox cbox = new JCheckBox("", true); |
---|
90 | |
---|
91 | public int oldFrom = 0; |
---|
92 | |
---|
93 | public int oldTo = 1; |
---|
94 | |
---|
95 | public int newFrom = 0; |
---|
96 | |
---|
97 | public int newTo = 1; |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | // zum rechnen |
---|
102 | // pcalc polyCalc = new pcalc(); |
---|
103 | |
---|
104 | public JLabel intenseLabel = new JLabel("50"); |
---|
105 | |
---|
106 | |
---|
107 | public JTextField from = new JTextField("0"); |
---|
108 | |
---|
109 | public JTextField to = new JTextField("100"); |
---|
110 | |
---|
111 | JLabel toLabel = new JLabel("to:"); |
---|
112 | |
---|
113 | JLabel fromLabel = new JLabel("from:"); |
---|
114 | |
---|
115 | JSlider intenseSlider = new JSlider(0, 100);//intenseSlider = null; |
---|
116 | |
---|
117 | |
---|
118 | // GUI |
---|
119 | |
---|
120 | public JLabel nameLabel = null; |
---|
121 | |
---|
122 | public JTextField xPos = new JTextField("0.000"); |
---|
123 | |
---|
124 | public JTextField yPos = new JTextField("1.000"); |
---|
125 | |
---|
126 | public JTextField zPos = new JTextField("0.000"); |
---|
127 | |
---|
128 | //public JLabel parLabel = new JLabel("0.50000"); |
---|
129 | |
---|
130 | JLabel xLabel = new JLabel(" x: "); |
---|
131 | |
---|
132 | JLabel zLabel = new JLabel(" z: "); |
---|
133 | |
---|
134 | JLabel yLabel = new JLabel(" y: "); |
---|
135 | |
---|
136 | JLabel PreviewPic; |
---|
137 | |
---|
138 | Lamp previewLamp; |
---|
139 | |
---|
140 | JButton setPos = new JButton("set Pos");; |
---|
141 | |
---|
142 | JButton intensity = new JButton("Intensity"); |
---|
143 | |
---|
144 | LampAdmin lampAdmin; |
---|
145 | |
---|
146 | // Ende Variablen |
---|
147 | |
---|
148 | // Konstruktor |
---|
149 | Lamp(Project pro, LampAdmin lampAdmin,JPanel[] lampPanel) { |
---|
150 | project = pro; |
---|
151 | this.lampAdmin = lampAdmin; |
---|
152 | |
---|
153 | nameLabel = new JLabel(" " + lampNo+" "); |
---|
154 | lampPanel[0].add(nameLabel); |
---|
155 | |
---|
156 | // polyCalc.doPrint = false; |
---|
157 | // lichtstaerke = new Lichtstaerke(" intensity of " + nameLabel.getText()+" "); |
---|
158 | //panel.add(KoordsPanel); |
---|
159 | //panel.add(flowPanel); |
---|
160 | // flowPanel.add(cbox); |
---|
161 | |
---|
162 | PreviewPic = new JLabel(); |
---|
163 | lampPanel[1].add(setPos); |
---|
164 | // lampPanel[2].add(xLabel); |
---|
165 | |
---|
166 | //xPos.setBounds(200, 40, 250, 100);//.setSize(200,50); |
---|
167 | lampPanel[2].add(xPos); |
---|
168 | // lampPanel[4].add(yLabel); |
---|
169 | lampPanel[3].add(yPos); |
---|
170 | |
---|
171 | // lampPanel[6].add(zLabel); |
---|
172 | lampPanel[4].add(zPos); |
---|
173 | setPos.addActionListener(new ActionListener() { |
---|
174 | public void actionPerformed(ActionEvent ae) { |
---|
175 | |
---|
176 | updateLampAdmin(); |
---|
177 | // PreviewFenser anpassen |
---|
178 | |
---|
179 | //lichtstaerke.setVisible(true); |
---|
180 | } |
---|
181 | }); |
---|
182 | |
---|
183 | // lampPanel[8].add(setPos); |
---|
184 | |
---|
185 | //lampPanel[9].add(deleteLampButton); |
---|
186 | // deleteLampButton.setEnabled(false); |
---|
187 | |
---|
188 | //flowPanel.add(new JLabel(" ")); |
---|
189 | |
---|
190 | /* intensity.addActionListener(new ActionListener() { |
---|
191 | public void actionPerformed(ActionEvent ae) { |
---|
192 | lichtstaerke.setVisible(true); |
---|
193 | } |
---|
194 | }); |
---|
195 | |
---|
196 | */ |
---|
197 | |
---|
198 | |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | intenseSlider.setValue(50); |
---|
203 | intenseSlider.setMinorTickSpacing(1); |
---|
204 | intenseSlider.setMajorTickSpacing(10); |
---|
205 | intenseSlider.setPaintTicks(true); |
---|
206 | intenseSlider.addChangeListener(new ChangeListener() { |
---|
207 | public void stateChanged(ChangeEvent evt) { |
---|
208 | updateintenseSliderLabel(); |
---|
209 | } |
---|
210 | }); |
---|
211 | |
---|
212 | lampPanel[5].add(intenseSlider); |
---|
213 | |
---|
214 | colorButton = new JButton(); |
---|
215 | // colorButton.setBorderPainted(true); |
---|
216 | // colorButton.setBorder(BorderFactory.createBevelBorder(5,new Color(100,100,100),new Color(200,200,200)));//.createEtchedBorder()); |
---|
217 | |
---|
218 | //colorButton.setText(""); |
---|
219 | colorButton.setBackground(new Color(0, 180, 240)); |
---|
220 | colorButton.setToolTipText("Select the \"light\" color"); |
---|
221 | colorButton.addActionListener(new ActionListener() { |
---|
222 | public void actionPerformed(ActionEvent evt) { |
---|
223 | setColor(JColorChooser.showDialog(null, |
---|
224 | "Change light color", colorButton.getBackground())); |
---|
225 | } |
---|
226 | }); |
---|
227 | |
---|
228 | // lampPanel[10].add(new JLabel(" color: ")); |
---|
229 | lampPanel[6].add(colorButton); |
---|
230 | |
---|
231 | // lampPanel[2].add(new JLabel(" shines: ")); |
---|
232 | lampPanel[7].add(cbox); |
---|
233 | |
---|
234 | |
---|
235 | } |
---|
236 | |
---|
237 | public synchronized void updateLampAdmin(){ |
---|
238 | lampAdmin.setSelectedLamp(lampNo-1); |
---|
239 | } |
---|
240 | |
---|
241 | // Konstruktor ohne GUI: |
---|
242 | |
---|
243 | Lamp(Project pro, LampAdmin lampAdmin) { |
---|
244 | project = pro; |
---|
245 | this.lampAdmin = lampAdmin; |
---|
246 | // polyCalc.doPrint = false; |
---|
247 | intenseSlider.setValue(50); |
---|
248 | colorButton = new JButton(); |
---|
249 | colorButton.setBackground(new Color(0, 180, 240)); |
---|
250 | } |
---|
251 | |
---|
252 | public Lamp previewLamp(double x, double y, double z){ |
---|
253 | previewLamp=getNewLamp(x,y,z,colorButton.getBackground(),getVol(),isShining()); |
---|
254 | |
---|
255 | |
---|
256 | return previewLamp; |
---|
257 | } |
---|
258 | |
---|
259 | public Lamp getNewLamp(double x, double y, double z, |
---|
260 | Color c, |
---|
261 | int i, |
---|
262 | boolean shines){ |
---|
263 | |
---|
264 | Lamp lamp=new Lamp(project,lampAdmin);//(Lamp)lampList.lastElement(); |
---|
265 | lamp.setKoords(x,y,z); |
---|
266 | lamp.setIntensity( i); |
---|
267 | lamp.setColor(c); |
---|
268 | lamp.setIsShining(shines); |
---|
269 | //SwingUtilities.updateComponentTreeUI(lamp); |
---|
270 | return lamp; |
---|
271 | |
---|
272 | } |
---|
273 | |
---|
274 | public void setColor(Color c){ |
---|
275 | colorButton.setBackground(c); |
---|
276 | if(previewLamp!=null){ |
---|
277 | previewLamp.setColor(c); |
---|
278 | } |
---|
279 | } |
---|
280 | |
---|
281 | public int getIntensity(){ |
---|
282 | |
---|
283 | return intenseSlider.getValue(); |
---|
284 | } |
---|
285 | |
---|
286 | public void setIntensity(int i){ |
---|
287 | intenseSlider.setValue(i); |
---|
288 | updateintenseSliderLabel(); |
---|
289 | if(previewLamp!=null){ |
---|
290 | previewLamp.setIntensity(i); |
---|
291 | } |
---|
292 | } |
---|
293 | |
---|
294 | public synchronized void updateintenseSliderLabel() { |
---|
295 | intenseLabel.setText(""+intenseSlider.getValue()); |
---|
296 | //SwingUtilities.updateComponentTreeUI(this); |
---|
297 | } |
---|
298 | |
---|
299 | public void setKoords(double x, double y, double z) { |
---|
300 | //grosses Pronlem :: NumberFormat arbeitet buggy. |
---|
301 | // d.h. er gibt manchmal nen leeren String zurueck, |
---|
302 | // was ihn spaeter z.b. in getXpos() abschiesst |
---|
303 | |
---|
304 | // bloss nicht die previewLamp updaten ;-) |
---|
305 | |
---|
306 | NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); |
---|
307 | nf.setMaximumFractionDigits(3);//.setsetMinimumIntegerDigits(5); // |
---|
308 | // ggf. mit fuehrenden Nullen ausgeben |
---|
309 | nf.setMinimumFractionDigits(3);//.setsetMinimumIntegerDigits(5); // |
---|
310 | // ggf. mit fuehrenden Nullen ausgeben |
---|
311 | |
---|
312 | String newx = nf.format(x); |
---|
313 | int i = 0; |
---|
314 | while (newx.compareTo("") != 0 && ++i < 10) { |
---|
315 | newx = nf.format(x); |
---|
316 | } |
---|
317 | xPos.setText(newx); |
---|
318 | i = 0; |
---|
319 | |
---|
320 | String newy = nf.format(y); |
---|
321 | while (newy.compareTo("") != 0 && ++i < 10) { |
---|
322 | newy = nf.format(y); |
---|
323 | } |
---|
324 | yPos.setText(newy); |
---|
325 | |
---|
326 | i = 0; |
---|
327 | String newz = nf.format(z); |
---|
328 | while (newz.compareTo("") != 0 && ++i < 10) { |
---|
329 | newz = nf.format(z); |
---|
330 | } |
---|
331 | zPos.setText(newz); |
---|
332 | // System.out.println("new coords:"+xPos.getText()+","+yPos.getText()+","+zPos.getText()+"."); |
---|
333 | } |
---|
334 | |
---|
335 | |
---|
336 | |
---|
337 | public void setColor(int r, int g, int b) { |
---|
338 | colorButton.setBackground(new Color(r, g, b)); |
---|
339 | if(previewLamp!=null){ |
---|
340 | previewLamp.setColor(r,g,b); |
---|
341 | } |
---|
342 | } |
---|
343 | |
---|
344 | public boolean isSelected() { |
---|
345 | return (cbox.isSelected()); |
---|
346 | } |
---|
347 | |
---|
348 | public void setIsShining(boolean b) { |
---|
349 | cbox.setSelected(b); |
---|
350 | //if(previewLamp!=nul) |
---|
351 | if(previewLamp!=null){ |
---|
352 | previewLamp.setIsShining(b); |
---|
353 | } |
---|
354 | } |
---|
355 | |
---|
356 | /* public synchronized void updateKoords_InvokedByUpdateFrameImmediatlyThread_LampAdmin( |
---|
357 | jv4surfex jv4sx) { |
---|
358 | |
---|
359 | // bloss nicht die previewLamp updaten ;-) |
---|
360 | |
---|
361 | |
---|
362 | double[] ang = new double[3]; |
---|
363 | ang[0] = jv4sx.getCamPos()[0];//-jv4sx.getCamPos()[0]; |
---|
364 | ang[1] = jv4sx.getCamPos()[1];//.getCameraRotationYXZ()[1];//-jv4sx.getCamPos()[1]; |
---|
365 | ang[2] = jv4sx.getCamPos()[2];//getCameraRotationYXZ()[2];//)-jv4sx.getCamPos()[2]; |
---|
366 | // System.out.println("r" + vec2Str(jv4sx.getCamPos())); |
---|
367 | |
---|
368 | if (!((lastX.compareTo(getXpos_str()) == 0) |
---|
369 | && (lastY.compareTo(getYpos_str()) == 0) && (lastZ |
---|
370 | .compareTo(getZpos_str()) == 0))) { |
---|
371 | |
---|
372 | // der Benutzer hat die Koordinaten schriftlich geaendert |
---|
373 | // -> jv4sx anpassen!! |
---|
374 | try{ |
---|
375 | PdVector v = getPos(); |
---|
376 | v.multScalar(1.0); |
---|
377 | jv4sx.disp.getCamera().setPosition(v); |
---|
378 | jv4sx.setParameterWarning(false); |
---|
379 | //jv4sx.updateScaleSliderValue(); |
---|
380 | |
---|
381 | // System.out.println(10/getVecLength()+" - "+jv4sx.disp.getCamera().getScale()); |
---|
382 | |
---|
383 | |
---|
384 | jv4sx.updateDisp(); |
---|
385 | |
---|
386 | |
---|
387 | |
---|
388 | }catch(Exception e){ |
---|
389 | //er hat wahrschinlich nen parameter im Textfeld stehehn und kann deswegen nicht nach double konvertieren |
---|
390 | jv4sx.setParameterWarning(true); |
---|
391 | |
---|
392 | |
---|
393 | } |
---|
394 | |
---|
395 | |
---|
396 | // geaenderte Daten speichern |
---|
397 | // damit man merkt, falls er sie wieder aendert |
---|
398 | //lastXj=Double.valueOf(ang[0]).toString(); |
---|
399 | //lastYj=Double.valueOf(ang[1]).toString(); |
---|
400 | //lastZj=Double.valueOf(ang[2]).toString(); |
---|
401 | lastX = getXpos_str(); |
---|
402 | lastY = getYpos_str(); |
---|
403 | lastZ = getZpos_str(); |
---|
404 | |
---|
405 | } |
---|
406 | if (!((lastXj.compareTo(Double.valueOf(ang[0]).toString()) == 0) |
---|
407 | && (lastYj.compareTo(Double.valueOf(ang[1]).toString()) == 0) && (lastZj |
---|
408 | .compareTo(Double.valueOf(ang[2]).toString()) == 0))) { |
---|
409 | // d.h der Benutzer hat die Koordinaten nicht schriftlich geaendert |
---|
410 | // aber moeglicherweise im jv4sx-previefenster: |
---|
411 | // |
---|
412 | // d.h. Benutzer hat jvview gedreht |
---|
413 | setKoords(ang[0], ang[1], ang[2]); |
---|
414 | // geaenderte Daten speichern |
---|
415 | // dami man merkt, falls er sie wieder aendert |
---|
416 | lastXj = Double.valueOf(ang[0]).toString(); |
---|
417 | lastYj = Double.valueOf(ang[1]).toString(); |
---|
418 | lastZj = Double.valueOf(ang[2]).toString(); |
---|
419 | lastX = getXpos_str(); |
---|
420 | lastY = getYpos_str(); |
---|
421 | lastZ = getZpos_str(); |
---|
422 | } |
---|
423 | |
---|
424 | |
---|
425 | }*/ |
---|
426 | |
---|
427 | public String vec2Str(double[] v) { |
---|
428 | return ("<" + v[0] + "," + v[1] + "," + v[2] + ">"); |
---|
429 | } |
---|
430 | |
---|
431 | public PdVector getPos() { |
---|
432 | return new PdVector(getXpos(), getYpos(), getZpos()); |
---|
433 | } |
---|
434 | |
---|
435 | public double getVecLength(){ |
---|
436 | |
---|
437 | // System.out.println(Math.sqrt(2)); |
---|
438 | return Math.sqrt(Math.pow(this.getXpos(),2)+Math.pow(this.getYpos(),2)+Math.pow(this.getZpos(),2)); |
---|
439 | } |
---|
440 | |
---|
441 | public boolean isShining() { |
---|
442 | //System.out.println("sel"); |
---|
443 | return cbox.isSelected(); |
---|
444 | } |
---|
445 | |
---|
446 | public void setSelected(boolean b) { |
---|
447 | if(previewLamp!=null){ |
---|
448 | previewLamp.setSelected(b); |
---|
449 | } |
---|
450 | if (b) { |
---|
451 | setPos.setBackground(new Color(0, 255, 0)); |
---|
452 | } else { |
---|
453 | // System.out.println("set false -----------------------------------------"); |
---|
454 | setPos.setBackground(null);//new Color(100, 100, 100)); |
---|
455 | } |
---|
456 | setPos.repaint(); |
---|
457 | } |
---|
458 | |
---|
459 | |
---|
460 | |
---|
461 | public synchronized String getXpos_str() { |
---|
462 | String str = ""; |
---|
463 | while (str.compareTo("") == 0) { |
---|
464 | str = xPos.getText(); |
---|
465 | // Achtung, liefert manchmal den leeren String statt den richtigen |
---|
466 | } |
---|
467 | // System.out.println("xPos:"+str+"."); |
---|
468 | return str; |
---|
469 | } |
---|
470 | |
---|
471 | public synchronized String getYpos_str() { |
---|
472 | String str = ""; |
---|
473 | while (str.compareTo("") == 0) { |
---|
474 | str = yPos.getText(); |
---|
475 | // Achtung, liefert manchmal den leeren String statt den richtigen |
---|
476 | } |
---|
477 | return str; |
---|
478 | } |
---|
479 | |
---|
480 | public synchronized String getZpos_str() { |
---|
481 | String str = ""; |
---|
482 | while (str.compareTo("") == 0) { |
---|
483 | str = zPos.getText(); |
---|
484 | // Achtung, liefert manchmal den leeren String statt den richtigen |
---|
485 | } |
---|
486 | return str; |
---|
487 | } |
---|
488 | |
---|
489 | public synchronized double getXpos() { |
---|
490 | String str = ""; |
---|
491 | while (str.compareTo("") == 0) { |
---|
492 | str = xPos.getText(); |
---|
493 | // Achtung, liefert manchmal den leeren String statt den richtigen |
---|
494 | } |
---|
495 | // System.out.println("xPos:"+str+"."); |
---|
496 | return Double.valueOf(str).doubleValue(); |
---|
497 | } |
---|
498 | |
---|
499 | public synchronized double getYpos() { |
---|
500 | String str = ""; |
---|
501 | while (str.compareTo("") == 0) { |
---|
502 | str = yPos.getText(); |
---|
503 | // Achtung, liefert manchmal den leeren String statt den richtigen |
---|
504 | } |
---|
505 | return Double.valueOf(str).doubleValue(); |
---|
506 | } |
---|
507 | |
---|
508 | public synchronized double getZpos() { |
---|
509 | String str = ""; |
---|
510 | while (str.compareTo("") == 0) { |
---|
511 | str = zPos.getText(); |
---|
512 | // Achtung, liefert manchmal den leeren String statt den richtigen |
---|
513 | } |
---|
514 | return Double.valueOf(str).doubleValue(); |
---|
515 | } |
---|
516 | |
---|
517 | public int getVol() { |
---|
518 | return getIntensity(); |
---|
519 | } |
---|
520 | |
---|
521 | public int getRed() { |
---|
522 | return colorButton.getBackground().getRed(); |
---|
523 | } |
---|
524 | |
---|
525 | public int getGreen() { |
---|
526 | return colorButton.getBackground().getGreen(); |
---|
527 | } |
---|
528 | |
---|
529 | public int getBlue() { |
---|
530 | return colorButton.getBackground().getBlue(); |
---|
531 | } |
---|
532 | |
---|
533 | public void setLampNo(int no) { |
---|
534 | if(previewLamp!=null){ |
---|
535 | previewLamp.setLampNo(no); |
---|
536 | } |
---|
537 | lampNo = no; |
---|
538 | nameLabel.setText(" " + lampNo); |
---|
539 | //lichtstaerke.setTitle("l" + lampNo); |
---|
540 | //SwingUtilities.updateComponentTreeUI(lichtstaerke); |
---|
541 | } |
---|
542 | |
---|
543 | public void updateActionCommands(int internalCunr) { |
---|
544 | } |
---|
545 | |
---|
546 | public String getSurfCode(int lampNo, String[] runningParams, |
---|
547 | double[] runningParamsValue) { |
---|
548 | String str=""; |
---|
549 | str+="light"+lampNo+"_x ="+evalWithPar(getXpos_str(),runningParams,runningParamsValue)+";\n"; |
---|
550 | str+="light"+lampNo+"_y ="+evalWithPar(getYpos_str(),runningParams,runningParamsValue)+";\n"; |
---|
551 | str+="light"+lampNo+"_z ="+evalWithPar(getZpos_str(),runningParams,runningParamsValue)+";\n"; |
---|
552 | str+="light"+lampNo+"_vol ="+getVol()+";\n"; |
---|
553 | str+="light"+lampNo+"_red ="+getRed()+";\n"; |
---|
554 | str+="light"+lampNo+"_green ="+getGreen()+";\n"; |
---|
555 | str+="light"+lampNo+"_blue ="+getBlue()+";\n"; |
---|
556 | return str; |
---|
557 | } |
---|
558 | |
---|
559 | public double evalWithPar(String s,String[] runningParams, |
---|
560 | double[] runningParamsValue){ |
---|
561 | int i=0; |
---|
562 | // System.out.println(s); |
---|
563 | if(runningParams!=null){ |
---|
564 | for(int j=0;j<runningParams.length;j++){ |
---|
565 | // System.out.println("rv:"+runningParamsValue[j]); |
---|
566 | s=s.replaceAll(runningParams[j],(new Double(runningParamsValue[j])).toString()); |
---|
567 | |
---|
568 | } |
---|
569 | } |
---|
570 | |
---|
571 | s=s.replaceAll(" ",""); |
---|
572 | |
---|
573 | s=s.replaceAll("\\*"," "); |
---|
574 | /* |
---|
575 | System.out.println("s1:"+s); |
---|
576 | |
---|
577 | s= polyCalc.showAsPovrayCode(s); |
---|
578 | System.out.println("s2:"+s); |
---|
579 | |
---|
580 | if(s.length()>4){ |
---|
581 | s=s.substring(4,s.length()-1); |
---|
582 | } //Double.valueOf(s).doubleValue()*genauigkeit; |
---|
583 | |
---|
584 | // damit es waehrend der Eingabe keine Probleme gibt: |
---|
585 | s=s.replaceAll("\\+",""); |
---|
586 | if(s.charAt(0)=='-'){ |
---|
587 | s=s.replaceAll("-",""); |
---|
588 | s="-"+s; |
---|
589 | }else{ |
---|
590 | s=s.replaceAll("-",""); |
---|
591 | } |
---|
592 | s=s.replaceAll("\\*",""); |
---|
593 | s=s.replaceAll("/",""); |
---|
594 | s=s.replaceAll("^",""); |
---|
595 | System.out.println("s3:"+s); |
---|
596 | */ |
---|
597 | |
---|
598 | try{ |
---|
599 | return Double.valueOf(s).doubleValue(); |
---|
600 | }catch(Exception e){ |
---|
601 | // System.out.println("ERROR: erst parameter auswaehlen ("+s+")"); |
---|
602 | } |
---|
603 | |
---|
604 | return 0.0; |
---|
605 | } |
---|
606 | |
---|
607 | public void saveYourself(PrintWriter pw) { |
---|
608 | String str = ""; |
---|
609 | pw.println("////////////////// Parameter: /////////////////////////" |
---|
610 | + "\n"); |
---|
611 | |
---|
612 | pw.println("" + lampNo + "\n"); |
---|
613 | pw.println("" + newFrom + "\n"); |
---|
614 | pw.println("" + newTo + "\n"); |
---|
615 | pw.println("" + intenseSlider.getValue() + "\n"); |
---|
616 | // pw.println(parLabel.getText()+"\n"); |
---|
617 | // pw.println(cbox.isSelected()+"\n"); |
---|
618 | //optionButtonPane.saveYourself(pw); |
---|
619 | } |
---|
620 | |
---|
621 | public String saveYourself() { |
---|
622 | String str = ""; |
---|
623 | str += "////////////////// Parameter: /////////////////////////\n"; |
---|
624 | str += ("" + lampNo + "\n"); |
---|
625 | str += ("" + newFrom + "\n"); |
---|
626 | str += ("" + newTo + "\n"); |
---|
627 | str += ("" + intenseSlider.getValue() + "\n"); |
---|
628 | // str += (parLabel.getText()+"\n"); |
---|
629 | // str += (cbox.isSelected()+"\n"); |
---|
630 | return (str); |
---|
631 | } |
---|
632 | } // end of class OneParameter |
---|
633 | |
---|