source: git/Singular/LIB/surfex/SaveMovieDialog.java @ 3de2ca

spielwiese
Last change on this file since 3de2ca was 3de2ca, checked in by Hans Schönemann <hannes@…>, 16 years ago
*hannes: surfex_0_90_00 git-svn-id: file:///usr/local/Singular/svn/trunk@11070 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 45.3 KB
Line 
1////////////////////////////////////////////////////////////////////////
2//
3// This file SaveMovieDialog.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
33import java.awt.BorderLayout;
34import java.awt.Color;
35import java.awt.Container;
36import java.awt.FlowLayout;
37import java.awt.GridLayout;
38import java.awt.*;
39import java.awt.event.ActionEvent;
40import java.awt.event.ActionListener;
41import java.awt.event.KeyEvent;
42import java.awt.event.KeyListener;
43import java.io.File;
44import java.awt.BorderLayout;
45import java.awt.Color;
46import java.awt.Container;
47import java.awt.FlowLayout;
48import java.awt.GridLayout;
49import java.awt.*;
50import java.awt.event.ActionEvent;
51import java.awt.event.ActionListener;
52import java.awt.event.KeyEvent;
53import java.awt.event.KeyListener;
54import java.io.File;
55
56import javax.swing.AbstractButton;
57import javax.swing.ButtonGroup;
58import javax.swing.JButton;
59import javax.swing.JCheckBox;
60import javax.swing.*;
61import javax.swing.JFileChooser;
62import javax.swing.JFrame;
63import javax.swing.JLabel;
64import javax.swing.JOptionPane;
65import javax.swing.JPanel;
66import javax.swing.JRadioButton;
67import javax.swing.JTextField;
68import javax.swing.event.ChangeEvent;
69import javax.swing.event.ChangeListener;
70import javax.swing.event.DocumentEvent;
71import javax.swing.event.DocumentListener;
72import javax.swing.event.ListSelectionEvent;
73import javax.swing.filechooser.FileFilter;
74import javax.swing.AbstractButton;
75import javax.swing.ButtonGroup;
76import javax.swing.JButton;
77import javax.swing.JCheckBox;
78import javax.swing.*;
79import javax.swing.JFileChooser;
80import javax.swing.JFrame;
81import javax.swing.JLabel;
82import javax.swing.JOptionPane;
83import javax.swing.JPanel;
84import javax.swing.JRadioButton;
85import javax.swing.JTextField;
86import javax.swing.event.ChangeEvent;
87import javax.swing.event.ChangeListener;
88import javax.swing.filechooser.FileFilter;
89
90//////////////////////////////////////////////////////////////
91//
92// class SaveMovieDialog
93//
94//////////////////////////////////////////////////////////////
95
96public class SaveMovieDialog extends JFrame {
97    JTextField tf;
98   
99    RayFrame rayFrame;
100    //JComboBox outputFormat;
101   
102    JComboBox colorType;
103
104    JComboBox omitType;
105   
106    JComboBox antialiasingQuality;
107   
108    JComboBox standardDim;
109   
110   
111    JSpinner XrotSpinner =new JSpinner(new SpinnerNumberModel(1,0,5,1));
112    JSpinner YrotSpinner =new JSpinner(new SpinnerNumberModel(2,0,5,1));
113    JSpinner ZrotSpinner =new JSpinner(new SpinnerNumberModel(0,0,5,1));
114    JSpinner FramesPerSecond=new JSpinner(new SpinnerNumberModel(5,1,60,1));
115   
116    JScrollPane listScrollPane;
117   
118    private JList parameterList;
119    private DefaultListModel listModel;
120   
121    private static final String addString = "add";
122    private static final String removeString = "remove from list";
123    private JLabel addLabel;
124    private JButton removeButton;
125    private JComboBox paramName;
126   
127   
128    JRadioButton ROTATE = new JRadioButton("ROTATE_Y_AXIS");
129   
130   
131    JComboBox measure;
132   
133    JPanel panel = new JPanel();/*
134                                 
135//              JRadioButton povCode = new JRadioButton("PovRay code");
136
137//JRadioButton surfCode = new JRadioButton("Surf code");
138
139//JRadioButton raytracedPic = new JRadioButton("Raytraced pic", true);
140
141//JRadioButton rb[] = new JRadioButton[11];
142
143//int aufloesungen[][] = { { 300, 300 }, { 600, 600 }, { 900, 900 },
144//              { 1200, 1200 }, { 240, 240 }, { 360, 360 }, { 480, 480 },
145//              { 640, 640 } };
146
147                                */      ChangeListener CL;
148   
149    //boolean last[] = { true, false, false, false, false, false, false, false,
150    //          false, false, false, true, false, false, true, false };
151   
152    //boolean actionWasPerformed = false;
153   
154    JTextField width;
155   
156    JTextField height;
157   
158    int heightvalue=0;
159    int widthvalue=0;
160   
161    JCheckBox aspectRatio = new JCheckBox("Preserve aspect ratio", false);
162   
163    //JRadioButton unitPixels = new JRadioButton("Pixels", true);
164   
165    JTextField dpi = new JTextField("300");
166   
167    //JRadioButton unitCm = new JRadioButton("cm");
168   
169    //JRadioButton unitInches = new JRadioButton("inches");
170   
171    //int i, j;
172   
173    //JCheckBox ditheredCb = new JCheckBox("dithered - black/white", false);
174   
175    //public JCheckBox antialiasing = new JCheckBox("antialiasing", false);
176   
177    JButton SaveButton = new JButton("create and save as");
178   
179    boolean actionWasPerformed = false;
180   
181   
182    JButton CancelButton = new JButton("cancel");
183   
184    JButton DefaultButton = new JButton("default");
185   
186    JLabel newSize = new JLabel();
187   
188    JTextField Time = new JTextField("10");
189   
190   
191    Project project;
192   
193    surfex surfex_;
194   
195    String projectName;
196   
197    SaveMovieDialog(String proName, RayFrame ray, Project pro, surfex su) {
198        super("save movie " + proName);
199        surfex_ = su;
200        rayFrame = ray;
201        project = pro;
202        this.projectName = proName;
203        //setSize(790, 400);
204       
205        JPanel contentPane = (JPanel) getContentPane();
206        JPanel contentPane1l = new JPanel(new BorderLayout());
207        JPanel contentPane1l2 = new JPanel(new BorderLayout());
208        JPanel contentPane1r = new JPanel(new BorderLayout());
209       
210        JPanel contentPane2 = new JPanel(new BorderLayout());
211        JPanel contentPane3 = new JPanel(new BorderLayout());
212        JPanel contentPane4 = new JPanel(new BorderLayout());
213        JPanel contentPane5 = new JPanel(new BorderLayout());
214        JPanel contentPane6 = new JPanel(new BorderLayout());
215        JPanel contentPane7 = new JPanel(new BorderLayout());
216        JPanel contentPane8 = new JPanel(new BorderLayout());
217        JPanel contentPane9 = new JPanel(new BorderLayout());
218       
219        JPanel sizePanel=new JPanel();//new GridLayout(2,3));
220        JPanel newSizePanel=new JPanel(new BorderLayout());
221        //JPanel DpiPanel=new JPanel(new GridLayout(1,2));
222        JPanel fpsPanel=new JPanel(new GridLayout(1,2));
223        JPanel lengthPanel=new JPanel(new GridLayout(1,2));
224        JPanel omitTypePanel=new JPanel();
225       
226        JPanel someStandardDimPanel=new JPanel();//(new GridLayout(2,3));
227        JPanel colorTypePanel=new JPanel();//(new GridLayout(2,3));
228        JPanel antialiasingPanel=new JPanel();//(new GridLayout(2,3));
229       
230        JPanel paramPanel=new JPanel(new BorderLayout());//(new GridLayout(2,3));
231        JPanel paramAddPanel=new JPanel();//(new GridLayout(2,3));
232        JPanel rotatePanel=new JPanel(new GridLayout(1,6));
233       
234       
235        sizePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("current size"),BorderFactory.createEmptyBorder(5,5,5,5)));
236        newSizePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("set size"),BorderFactory.createEmptyBorder(5,5,5,5)));
237        //DpiPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Dpi"),BorderFactory.createEmptyBorder(5,5,5,5)));
238        fpsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("smoothness"),BorderFactory.createEmptyBorder(5,5,5,5)));
239        lengthPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("length"),BorderFactory.createEmptyBorder(5,5,5,5)));
240        omitTypePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("omit selected frames"),BorderFactory.createEmptyBorder(5,5,5,5)));
241        someStandardDimPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("some standard sizes (in pixels):"),BorderFactory.createEmptyBorder(5,5,5,5)));
242        colorTypePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("select color type"),BorderFactory.createEmptyBorder(5,5,5,5)));
243        antialiasingPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("select antialiasing quality"),BorderFactory.createEmptyBorder(5,5,5,5)));
244        paramPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("parameters to run"),BorderFactory.createEmptyBorder(5,5,5,5)));
245        paramAddPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("add parameters"),BorderFactory.createEmptyBorder(5,5,5,5)));
246        rotatePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("rotations"),BorderFactory.createEmptyBorder(5,5,5,5)));
247        contentPane1l.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("resolution"),BorderFactory.createEmptyBorder(5,5,5,5)));
248        contentPane1l2.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("frames"),BorderFactory.createEmptyBorder(5,5,5,5)));
249        contentPane1r.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("general settings"),BorderFactory.createEmptyBorder(5,5,5,5)));
250       
251
252        JPanel paneLeft = new JPanel(new BorderLayout());
253       
254        contentPane.setLayout(new BorderLayout());
255        paneLeft.add(contentPane1l,BorderLayout.NORTH);
256        paneLeft.add(contentPane1l2,BorderLayout.SOUTH);
257        contentPane.add(paneLeft,BorderLayout.CENTER);
258        contentPane.add(contentPane1r,BorderLayout.EAST);
259        contentPane1l.add(sizePanel, BorderLayout.NORTH);
260        contentPane1l.add(contentPane2,BorderLayout.CENTER);
261        contentPane2.add(newSizePanel, BorderLayout.NORTH);
262        contentPane2.add(contentPane3,BorderLayout.CENTER);
263        contentPane3.add(contentPane4,BorderLayout.CENTER);
264
265        // frames:
266        contentPane1l2.add(fpsPanel, BorderLayout.NORTH);
267        contentPane1l2.add(lengthPanel, BorderLayout.CENTER);
268        contentPane1l2.add(omitTypePanel, BorderLayout.SOUTH);
269
270        //
271        contentPane4.add(contentPane5,BorderLayout.CENTER);
272        contentPane5.add(someStandardDimPanel, BorderLayout.NORTH);
273        //contentPane4.add(contentPane5,BorderLayout.CENTER);
274        contentPane1r.add(colorTypePanel, BorderLayout.NORTH);
275        contentPane1r.add(contentPane6,BorderLayout.CENTER);
276        contentPane6.add(antialiasingPanel, BorderLayout.NORTH);
277        contentPane6.add(contentPane7,BorderLayout.CENTER);
278        contentPane7.add(paramPanel, BorderLayout.NORTH);
279       
280        contentPane7.add(contentPane8,BorderLayout.CENTER);
281        contentPane8.add(paramAddPanel, BorderLayout.NORTH);
282        contentPane8.add(contentPane9,BorderLayout.CENTER);
283        contentPane9.add(rotatePanel, BorderLayout.NORTH);
284        //*///contentPane6.add(contentPane2,BorderLayout.CENTER);
285       
286        //outputFormat=new JComboBox();
287       
288        //outputFormat.insertItemAt("raytraced picture",0);
289       
290        if (true || surfex_.inAnApplet) {
291           
292            //          outputFormat.insertItemAt("povray code",1);
293            //  outputFormat.insertItemAt("surf code",2);       
294        }
295        //outputFormat.setSelectedIndex(0);
296       
297        CL = new ChangeListener() {
298                public void stateChanged(ChangeEvent ev) {
299                    String command = ((AbstractButton) ev.getSource()).getText();
300                    //         System.out.println(command );
301                    int i;
302                    /*  for (i = 0; i <= 7; i++) {
303                    // System.out.println(command +" t"+ rb[i].getText() );
304                    if (command.hashCode() == rb[i].getText().hashCode()
305                    && rb[i].isSelected()) {
306                    //System.out.println("text" );
307                    width.setText(new String((new Integer(
308                    aufloesungen[i][0])).toString()));
309                    height.setText(new String((new Integer(
310                    aufloesungen[i][1])).toString()));
311                    aspectRatio.setSelected(false);
312                    //width.disable();
313                    // height.disable();
314                    measure.setSelectedIndex(0);
315                    updateLabel_newSize();
316                    //raytracedPic.setSelected(true);
317                    if (last[i] != rb[i].isSelected()) {
318                    outputFormat.setSelectedIndex(0);//raytracedPic.setSelected(true);
319                    for (j = 0; j <= 10; j++) {
320                    last[j] = false;
321                    }
322                    last[i] = rb[i].isSelected();
323                    }
324                    }
325                    }
326                   
327                    if (command.hashCode() == rb[8].getText().hashCode()
328                    && rb[8].isSelected()) {
329                    //      System.out.println("funktion nicht geschrieben ...");
330                    //raytracedPic.setSelected(true);
331                    if (last[8] != rb[8].isSelected()) {
332                    outputFormat.setSelectedIndex(0);//raytracedPic.setSelected(true);
333                    for (i = 0; i <= 10; i++) {
334                    last[i] = false;
335                    }
336                    last[8] = rb[8].isSelected();
337                    }
338                    }
339                    if (command.hashCode() == rb[9].getText().hashCode()
340                    && rb[9].isSelected()) {
341                    //      System.out.println("funktion nicht geschrieben ...");
342                    //raytracedPic.setSelected(true);
343                    if (last[9] != rb[9].isSelected()) {
344                    outputFormat.setSelectedIndex(0);//raytracedPic.setSelected(true);
345                    for (i = 0; i <= 10; i++) {
346                    last[i] = false;
347                    }
348                    last[9] = rb[9].isSelected();
349                    }
350                    }
351                    if (command.hashCode() == rb[10].getText().hashCode()
352                    && rb[10].isSelected()) {
353                    //  /* width.enable();
354                    //   raytracedPic.setSelected(true);
355                    //   height.enable();
356                    //   dpi.enable();
357                    //   unitPixels.enable();
358                    //   unitInches.enable();
359                    //   unitCm.enable();
360                    //raytracedPic.setSelected(true);
361                    if (last[10] != rb[10].isSelected()) {
362                    outputFormat.setSelectedIndex(0);//raytracedPic.setSelected(true);
363                    for (i = 0; i <= 10; i++) {
364                    last[i] = false;
365                    }
366                    last[10] = rb[10].isSelected();
367                    }
368                    }
369                    if (command.hashCode() == unitPixels.getText().hashCode()
370                    && unitPixels.isSelected()) {
371                    updateLabel_newSize();
372                    if (last[11] != unitPixels.isSelected()) {
373                    outputFormat.setSelectedIndex(0);//raytracedPic.setSelected(true);
374                    for (i = 11; i <= 13; i++) {
375                    last[i] = false;
376                    }
377                    last[11] = unitPixels.isSelected();
378                    }
379                    //raytracedPic.setSelected(true);
380                    }
381                    if (command.hashCode() == unitCm.getText().hashCode()
382                                                && unitCm.isSelected()) {
383                                        if (!rb[10].isSelected()) {
384                                                //unitPixels.setSelected(true);
385                                                // besser:
386                                                rb[10].setSelected(true);
387                                        }
388                                        if (last[12] != unitCm.isSelected()) {
389                                                outputFormat.setSelectedIndex(0);
390                                                for (i = 11; i <= 13; i++) {
391                                                        last[i] = false;
392                                                }
393                                                last[12] = unitCm.isSelected();
394                                        }
395                                        updateLabel_newSize();
396                                        //outputFormat.setSelectedIndex(0)
397                                }
398                                if (command.hashCode() == unitInches.getText().hashCode()
399                                                && unitInches.isSelected()) {
400                                        if (!rb[10].isSelected()) {
401                                                // unitPixels.setSelected(true);
402                                                // besser:
403                                                rb[10].setSelected(true);
404                                        }
405                                        if (last[13] != unitInches.isSelected()) {
406                                                outputFormat.setSelectedIndex(0);
407                                                for (i = 11; i <= 13; i++) {
408                                                        last[i] = false;
409                                                }
410                                                last[13] = unitInches.isSelected();
411                                        }
412                                        updateLabel_newSize();
413                                        //outputFormat.setSelectedIndex(0)
414                                }
415                                if (command.hashCode() == aspectRatio.getText().hashCode()) {
416                                        if (aspectRatio.isSelected()) {
417                                                height.setText(new Integer(Integer.parseInt(width
418                                                                .getText())
419                                                                * rayFrame.getContentPane().getSize().height
420                                                                / rayFrame.getContentPane().getSize().width)
421                                                                .toString());
422                                                for (i = 0; i <= 10; i++) {
423                                                        last[i] = false;
424                                                }
425                                                rb[10].setSelected(true);
426                                                last[10] = true;
427                                                updateLabel_newSize();
428                                        }
429                                        if (last[14] != aspectRatio.isSelected()) {
430                                                outputFormat.setSelectedIndex(0);
431                                                last[14] = aspectRatio.isSelected();
432                                        }
433                                }
434                                if (command.hashCode() == ditheredCb.getText().hashCode()) {
435                                        if (last[15] != ditheredCb.isSelected()) {
436                                                outputFormat.setSelectedIndex(0);
437                                                last[15] = ditheredCb.isSelected();
438                                        }
439                                }
440                                if (command.hashCode() == outputFormat.getItemAt(1).toString().hashCode()) {
441                                        for (i = 0; i <= 10; i++) {
442                                                rb[10].setSelected(false);
443                                        }
444                                }
445                                if (command.hashCode() == outputFormat.getItemAt(2).toString().hashCode()) {
446                                        for (i = 0; i <= 10; i++) {
447                                                rb[10].setSelected(false);
448                                        }
449                                }
450
451                                // System.out.println("clicked" );
452                        */
453                        }
454                       
455                };
456
457       
458//      width = new JTextField(rayFrame.getContentPane().getSize().width+"");
459//      height = new JTextField(rayFrame.getContentPane().getSize().height+"");
460        width = new JTextField("300");
461        height = new JTextField("300");
462        //      rb[10] = new JRadioButton("Set new size:", true);
463       
464       
465        //      ButtonGroup group = new ButtonGroup();
466        //      ButtonGroup standardDim = new ButtonGroup();
467       
468        // adding container
469        //      panel.setLayout(new GridLayout(9, 2));
470        //      panel.add(new JLabel("output format:"));
471       
472        //outputFormatPanel.add(outputFormat);
473       
474/*              panel.add(surfCode);
475                panel.add(new JLabel(""));
476               
477                panel.add(raytracedPic);
478                panel.add(new JLabel(""));
479*/
480       
481        colorType=new JComboBox();
482        colorType.insertItemAt("color",0);
483        colorType.insertItemAt("dithered - black/white",1);
484//      colorType.insertItemAt("stereo - red/green",2);
485//      colorType.insertItemAt("stereo - red/blue",3);
486        colorType.setSelectedIndex(0);
487        panel.add(new JLabel("color type:"));
488        colorTypePanel.add(colorType);
489
490        omitType=new JComboBox();
491        omitType.insertItemAt("omit no frame",0);
492        omitType.insertItemAt("omit first frame",1);
493        omitType.insertItemAt("omit last frame",2);
494        omitType.setSelectedIndex(0);
495        omitTypePanel.add(omitType);
496       
497        antialiasingQuality=new JComboBox();
498        antialiasingQuality.insertItemAt("1",0);
499        antialiasingQuality.insertItemAt("2",1);
500        antialiasingQuality.insertItemAt("3",2);
501        antialiasingQuality.insertItemAt("4",3);
502        antialiasingQuality.insertItemAt("5",4);
503        antialiasingQuality.insertItemAt("6",5);
504        antialiasingQuality.setSelectedIndex(0);
505        panel.add(new JLabel("antialiasing level:"));
506        antialiasingPanel.add(antialiasingQuality);
507       
508        paramPanel.add(new JLabel());
509        // p6N.add(new JLabel("Parameters to run:"));
510        // p6N.add(new JLabel());
511       
512        // p6C.add(new JLabel());
513        listModel = new DefaultListModel();
514       
515        //Create the list and put it in a scroll pane.
516        parameterList = new JList(listModel);
517        parameterList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
518        parameterList.setSelectedIndex(0);
519       
520        // parameterList.addListSelectionListener(this);
521        parameterList.setVisibleRowCount(2);
522        listScrollPane = new JScrollPane(parameterList);
523       
524        //   addLabel = new JLabel("Add Params to List:");
525       
526       
527       
528////////////////////////        //
529        //addButton .... in JLabel aendern
530       
531       
532       
533       
534        addListener addListener = new addListener(addLabel);
535        //  addButton.setActionCommand(addString);
536        //  addButton.addActionListener(addListener);
537        //  addButton.setEnabled(false);
538       
539        removeButton = new JButton(removeString);
540        removeButton.setActionCommand(removeString);
541        removeButton.addActionListener(new removeListener());
542        removeButton.setEnabled(false);
543       
544        paramName = pro.parAdmin.paramComboBox;
545        paramName.addActionListener(addListener);
546        // paramName.setEnabled(false);
547        //  paramName.getDocument().addDocumentListener(addListener);
548        //String name = listModel.getElementAt(
549        //                    parameterList.getSelectedIndex()).toString();
550       
551       
552       
553        paramPanel.add(listScrollPane,BorderLayout.CENTER);
554        paramPanel.add(removeButton,BorderLayout.SOUTH);
555        // p6S.add(new JLabel());
556        // p6S.add(addLabel);
557        paramAddPanel.add(paramName);
558       
559        rotatePanel.add(new JLabel("#x-rot"));
560        //XrotSpinner.set
561        rotatePanel.add(XrotSpinner);
562        rotatePanel.add(new JLabel("#y-rot"));
563        rotatePanel.add(YrotSpinner);
564        rotatePanel.add(new JLabel("#z-rot"));
565        rotatePanel.add(ZrotSpinner);
566       
567       
568        panel.add(new JLabel("  Current size:"));
569        sizePanel.add(newSize);//
570        //new JLabel(rayFrame.getContentPane().getSize().width + " x "
571        //              + rayFrame.getContentPane().getSize().height));
572        panel.add(new JLabel("  New size:"));
573       
574        JPanel p1 = new JPanel(new GridLayout(3, 2));
575        newSizePanel.add(p1,BorderLayout.CENTER);
576       
577//      setNewSize(rayFrame.getContentPane().getSize().height,rayFrame.getContentPane().getSize().width);
578        setNewSize(300, 300);
579       
580        //      p1.add(newSize);
581        //      p1.add(new JLabel(" "));
582       
583        //panel.add(rb[10]);
584        //standardDim.add(rb[10]);
585        //rb[10].addChangeListener(CL);
586       
587//              panel.add(new JLabel(""));
588       
589       
590        p1.add(new JLabel("  width:"));
591        width.addKeyListener(new KeyListener() {
592                public void keyReleased(KeyEvent keyEvent) {
593                    if (aspectRatio.isSelected()) {
594                        // musste mitm Dreisatz den height updaten
595                        setHeight(Double.valueOf(width.getText()).doubleValue()
596                                  * rayFrame.getContentPane().getSize().height
597                                  / rayFrame.getContentPane().getSize().width);
598                    }
599                    standardDim.setSelectedIndex(0);
600                    //rb[10].setSelected(true);
601                    updateLabel_newSize();
602                    //  outputFormat.setSelectedIndex(0);
603                }
604               
605                public void keyPressed(KeyEvent keyEvent) {
606                }
607               
608                public void keyTyped(KeyEvent keyEvent) {
609                }
610            });
611        p1.add(width);
612       
613        //JPanel p2 = new JPanel(new GridLayout(1, 2));
614        //panel.add(p2);
615        p1.add(new JLabel("  height:"));
616        height.addKeyListener(new KeyListener() {
617                public void keyReleased(KeyEvent keyEvent) {
618                    if (aspectRatio.isSelected()) {
619                        // musste mitm Dreisatz den height updaten
620                        setWidth((Double.valueOf(height.getText()).doubleValue()
621                                  * rayFrame.getContentPane().getSize().width
622                                  / rayFrame.getContentPane().getSize().height));
623                    }
624                    standardDim.setSelectedIndex(0);
625                    //outputFormat.setSelectedIndex(0);
626                    //rb[10].setSelected(true);
627                    updateLabel_newSize();
628                }
629               
630                public void keyPressed(KeyEvent keyEvent) {
631                }
632               
633                public void keyTyped(KeyEvent keyEvent) {
634                }
635            });
636        p1.add(height);
637       
638        JPanel p3 = new JPanel(new GridLayout(1, 2));
639        //DpiPanel.add(p3);
640        p3.add(new JLabel("  DPI:"));
641        dpi.addKeyListener(new KeyListener() {
642                public void keyReleased(KeyEvent keyEvent) {
643                   
644                    updateLabel_newSize();
645                    //outputFormat.setSelectedIndex(0);
646                }
647               
648                public void keyPressed(KeyEvent keyEvent) {
649                }
650               
651                public void keyTyped(KeyEvent keyEvent) {
652                }
653            });
654        //      p3.add(dpi);
655       
656        measure=new JComboBox();
657       
658        measure.insertItemAt("pixel",0);
659        measure.insertItemAt("cm",1);
660        measure.insertItemAt("inch",2);
661       
662        measure.setSelectedIndex(0);
663       
664        measure.addActionListener(new ActionListener(){
665                public void actionPerformed(ActionEvent ae){
666                    setHeight(Double.valueOf(height.getText()).doubleValue());
667                    setWidth(Double.valueOf(width.getText()).doubleValue());
668                    if(measure.getSelectedIndex()==0){
669                        setNewSize(Double.valueOf(height.getText()).intValue(),
670                                   Double.valueOf(width.getText()).intValue());
671                    }
672                    if(measure.getSelectedIndex()==1){
673                        setNewSize((int)((Double.valueOf(dpi.getText()).intValue())*(Double.valueOf(height.getText()).doubleValue())/2.4),
674                                   (int)((Double.valueOf(dpi.getText()).intValue())*(Double.valueOf(width.getText()).doubleValue())/2.4));
675                    }
676                    if(measure.getSelectedIndex()==2){
677                        setNewSize((int)((Double.valueOf(dpi.getText()).intValue())*(Double.valueOf(height.getText()).doubleValue())),(int)((Double.valueOf(dpi.getText()).intValue())*(Double.valueOf(width.getText()).doubleValue())));
678                    }
679                }
680            });
681       
682       
683        //JPanel p35 = new JPanel(new GridLayout(1, 2));
684        //panel.add(p35);
685        //      p1.add(new JLabel("Unit:"));
686        //      p1.add(measure);
687/*
688  JPanel p4 = new JPanel(new GridLayout(1, 2));
689  panel.add(p4);
690  p4.add(new JLabel("  Units:"));
691  ButtonGroup units = new ButtonGroup();
692  units.add(unitPixels);
693  unitPixels.addChangeListener(CL);
694  p4.add(unitPixels);
695 
696  panel.add(new JLabel(""));
697 
698  JPanel p5 = new JPanel(new GridLayout(1, 2));
699  panel.add(p5);
700  units.add(unitCm);
701  unitCm.addChangeListener(CL);
702  p5.add(new JLabel(""));
703  p5.add(unitCm);
704 
705  panel.add(new JLabel(""));
706 
707  JPanel p6 = new JPanel(new GridLayout(1, 2));
708  panel.add(p6);
709  units.add(unitInches);
710  unitInches.addChangeListener(CL);
711  p6.add(new JLabel(""));
712  p6.add(unitInches);
713*/
714//      newSizePanel.add(aspectRatio,BorderLayout.SOUTH);
715        aspectRatio.addChangeListener(CL);
716        //      panel.add(new JLabel("(raytraced preview)"));
717       
718       
719        fpsPanel.add(new JLabel(" frames per sec.: "));
720        fpsPanel.add(this.FramesPerSecond);
721       
722        lengthPanel.add(new JLabel(" seconds: "));
723        lengthPanel.add(this.Time);
724       
725        Time.addKeyListener(new KeyListener() {
726                public void keyReleased(KeyEvent keyEvent) {
727                   
728                    updateLabel_newSize();
729                    //ROTATE_Y_AXIS_Button.setSelected(true);
730                }
731               
732                public void keyPressed(KeyEvent keyEvent) {
733                }
734               
735                public void keyTyped(KeyEvent keyEvent) {
736                }
737            });
738       
739       
740        standardDim=new JComboBox();
741        standardDim.insertItemAt("choose a size (in pixels)",0);       
742        standardDim.insertItemAt("for presentation (600x600)",1);
743        standardDim.insertItemAt("for web (300x300)",2);
744        standardDim.insertItemAt("240 x 240",3);
745        standardDim.insertItemAt("300 x 300",4);
746        standardDim.insertItemAt("360 x 360",5);
747        standardDim.insertItemAt("480 x 480",6);
748        standardDim.insertItemAt("600 x 600",7);
749        standardDim.insertItemAt("728 x 728",8);
750        standardDim.insertItemAt("900 x 900",9);
751        standardDim.insertItemAt("1024 x 1024",10);
752        standardDim.insertItemAt("1200 x 1200",11);
753       
754        standardDim.addActionListener(new ActionListener(){
755                public void actionPerformed(ActionEvent ae){
756                    int i=standardDim.getSelectedIndex();
757                    switch (i){
758                        case 0:break;//nix passiert;
759                        case 1:updateSize(600,600);break;//updateSize(h,w);
760                        case 2:updateSize(300,300);break;//updateSize(,);
761                        case 3:updateSize(240,240);break;
762                        case 4:updateSize(300,300);break;
763                        case 5:updateSize(360,360);break;
764                        case 6:updateSize(480,480);break;
765                        case 7:updateSize(600,600);break;
766                        case 8:updateSize(728,728);break;
767                        case 9:updateSize(900,900);break;
768                        case 10:updateSize(1024,1024);break;
769                        case 11:updateSize(1200,1200);break;
770                    }
771                }
772            });
773       
774        standardDim.setSelectedIndex(0);
775       
776        //panel.add(new JLabel("some standard dimensions:"));
777        someStandardDimPanel.add(standardDim);
778       
779       
780/*              JPanel panel2 = new JPanel(new GridLayout(12, 3));
781               
782panel2.add(new JLabel());
783panel2.add(new JLabel());
784panel2.add(new JLabel());
785panel2.add(new JLabel());
786panel2.add(new JLabel());
787panel2.add(new JLabel());
788panel2.add(new JLabel());
789panel2.add(new JLabel());
790panel2.add(new JLabel());
791panel2.add(new JLabel());
792panel2.add(new JLabel());
793panel2.add(new JLabel());
794panel2.add(new JLabel());
795panel2.add(new JLabel("Some standard dimensions:"));
796panel2.add(new JLabel());
797
798rb[8] = new JRadioButton("Best fit to desktop");
799                rb[8].addChangeListener(CL);
800                rb[9] = new JRadioButton("Screen size");
801                rb[9].addChangeListener(CL);
802
803                for (i = 0; i <= 7; i++) {
804                        if (i % 2 == 0) {
805                                panel2.add(new JLabel());
806                        }
807                        rb[i] = new JRadioButton(aufloesungen[i][0] + " x "
808                                        + aufloesungen[i][1]);
809                        panel2.add(rb[i]);
810                //      standardDim.add(rb[i]);
811                        rb[i].addChangeListener(CL);
812                }
813                panel2.add(new JLabel());
814                panel2.add(rb[8]);
815                standardDim.add(rb[8]);
816                panel2.add(new JLabel());
817                panel2.add(new JLabel());
818                panel2.add(rb[9]);
819                standardDim.add(rb[9]);
820
821                panel2.add(new JLabel());
822
823                contentPane.add(panel2, BorderLayout.EAST);
824*/
825                JPanel panel3 = new JPanel(new FlowLayout());
826
827
828                 ActionListener AL = new ActionListener() {
829                      public void actionPerformed(ActionEvent evt) {
830                        String command = ((JButton) evt.getSource()).getText();
831                        if (command.hashCode() == SaveButton.getText().hashCode()) {
832                          //      System.out.println("saveButton!");
833                          setVisible(false);
834
835                          // creating new Frame
836                          final JFrame frame2 = new JFrame("save movie " + projectName);
837
838                          // adding container
839                          Container contentPane = frame2.getContentPane();
840
841                          if (surfex_.inAnApplet) {
842                            ActionListener aL = new ActionListener() {
843                              public void actionPerformed(ActionEvent actionEvent) {
844                                String command2 = actionEvent
845                                    .getActionCommand();
846                                //          System.out.println("com:"+command2);
847                                // check if doubleclickt or if "open" was pressed
848                                if (command2.equals("create and save as")) {
849                                  // creating complete filepath
850                                  String filelocation = tf.getText();
851                                  //              System.out.println("file:"+filelocation);
852                                  // ausgabe fehler bein z.B.: d:\ -> d:\\ bzw \ -> \\
853                                  //          System.out.println("filelocation : "+ filelocation + "\n");
854
855                                  /*    project.saveMovie(filelocation, 3,
856                                   ditheredCb.isSelected(),
857                                   antialiasing.isSelected(),
858                                   _3d.isSelected(),
859                                   Integer.parseInt(height
860                                   .getText()),
861                                   Integer.parseInt(width
862                                   .getText()),
863                                   Integer.parseInt(dpi
864                                   .getText()));
865                                   */
866                                  /*
867                                   saveMovie(filelocation, 3,
868                                   ditheredCb.isSelected(),
869                                   antialiasing.isSelected(),
870                                   _3d.isSelected(),
871                                   Integer.parseInt(height
872                                   .getText()),
873                                   Integer.parseInt(width
874                                   .getText()),
875                                   Integer.parseInt(dpi
876                                   .getText()));
877                                   */
878//                                System.out.println("fps:"+((Integer)FramesPerSecond.getModel().getValue()).intValue());
879                                  surfex_.showMoviePreview = true;
880                                  SaveMovie saveThread = new SaveMovie(
881                                      filelocation, 
882                                      surfex_, 
883                                      ((Integer)FramesPerSecond.getModel().getValue()).intValue(),
884                                      Integer.parseInt(dpi.getText()),
885                                      ((colorType.getSelectedIndex())==1),
886                                      ((antialiasingQuality.getSelectedIndex())!=0), 
887                                      Integer.parseInt(Time.getText()),
888                                      omitType.getSelectedIndex(),
889                                      Integer.parseInt(height.getText()),
890                                      Integer.parseInt(width.getText()),
891                                      (colorType.getSelectedIndex()==2), //RotType
892                                      1, 
893                                      surfex_.getCurrentProject(),
894                                      surfex_.getCurrentProject().jv4sx.getCamPos(), 
895                                      surfex_.getCurrentProject().jv4sx.getViewDir(), 
896                                      surfex_.getCurrentProject().jv4sx.getUpVector(), 
897                                      surfex_.getCurrentProject().jv4sx.getRightVector(),
898                                      ((Integer)XrotSpinner.getModel().getValue()).intValue(),
899                                      ((Integer)YrotSpinner.getModel().getValue()).intValue(),
900                                      ((Integer)ZrotSpinner.getModel().getValue()).intValue(),
901                                      getParametersToRun());
902                                  saveThread.start();
903
904                                  //              saveFile(filelocation);
905                                  frame2.dispose();
906                                } else {
907                                  //if(command.equals(JFileChooser.CANCEL_SELECTION)){
908                                  frame2.dispose();
909                                  //}
910                                }
911                              }
912                            };
913                            contentPane.setLayout(new BorderLayout());
914                            contentPane.add(new JLabel("Give filename: "),
915                                BorderLayout.WEST);
916                            if (colorType.getSelectedIndex()==1) {
917                              tf = new JTextField("test.tif");
918                            } else {
919                              tf = new JTextField("test.jpg");
920                            }
921                            contentPane.add(tf, BorderLayout.CENTER);
922                            JPanel tmpPanel = new JPanel();
923                            tmpPanel.setLayout(new FlowLayout());
924                            if (colorType.getSelectedIndex()==1) {
925                              String strFormats[] = { "tif" };
926                              tmpPanel.add(new JComboBox(strFormats));
927                            } else {
928                              String strFormats[] = { "jpg" };
929                              tmpPanel.add(new JComboBox(strFormats));
930                            }
931                            JButton jbsave = new JButton("create and save as");
932                            jbsave.addActionListener(aL);
933                            tmpPanel.add(jbsave);
934                            JButton jbcancel = new JButton("  cancel  ");
935                            jbcancel.addActionListener(aL);
936                            tmpPanel.add(jbcancel);
937                            contentPane.add(tmpPanel, BorderLayout.EAST);
938                            frame2.setSize(500, 75);
939                          } else {
940                            //          System.out.println("filechooser...");
941                            // creating Filechooser
942                            JFileChooser fileChooser = new JFileChooser(
943                                surfex_.currentDirectory);
944                            fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
945                            // adding filechooser
946                            contentPane.add(fileChooser, BorderLayout.CENTER);
947
948                            // Create ActionListener
949                            ActionListener actionListener = new ActionListener() {
950                              public void actionPerformed(ActionEvent actionEvent) {
951                                JFileChooser theFileChooser = (JFileChooser) actionEvent
952                                    .getSource();
953
954                                // get command2
955                                String command2 = actionEvent
956                                    .getActionCommand();
957
958                                // check if doubleclickt or if "open" was pressed
959                                if (command2.equals(JFileChooser.APPROVE_SELECTION)) {
960                                  File selectedFile = theFileChooser
961                                      .getSelectedFile();
962                                  surfex_.currentDirectory = theFileChooser.getCurrentDirectory().getAbsolutePath();
963
964                                  // making savepopup invisible/removing it
965                                  frame2.dispose();
966
967                                  // creating complete filepath
968                                  String filelocation = new String(
969                                      selectedFile.getParent()
970                                          + File.separator
971                                          + selectedFile.getName());
972
973                                  // ausgabe fehler bein z.B.: d:\ -> d:\\ bzw \ -> \\
974                                  //          System.out.println("filelocation : "+ filelocation + "\n");
975
976                                  //                System.out.println("saveFile...");
977                                  /*    project.saveFile(filelocation, 3,
978                                   ditheredCb.isSelected(),
979                                   antialiasing.isSelected(),
980                                   Integer.parseInt(height
981                                   .getText()),
982                                   Integer.parseInt(width
983                                   .getText()),
984                                   Integer.parseInt(dpi
985                                   .getText()));
986                                   */
987//                                System.out.println("fps:"+((Integer)FramesPerSecond.getModel().getValue()).intValue());
988                                  SaveMovie saveThread2 = new SaveMovie(
989                                      filelocation, surfex_, //Integer
990                                          //.parseInt((Integer)
991                                      ((Integer)FramesPerSecond.getModel().getValue()).intValue(),//),
992                                      Integer.parseInt(dpi.getText()),
993                                      (colorType.getSelectedIndex()==1),
994                                      (antialiasingQuality.getSelectedIndex()!=0), Integer
995                                          .parseInt(Time.getText()),
996                                      omitType.getSelectedIndex(),
997                                      Integer.parseInt(height.getText()),
998                                      Integer.parseInt(width.getText()),
999                                      (colorType.getSelectedIndex()==3), //RotType
1000                                      0, surfex_.getCurrentProject(),
1001                                      surfex_.getCurrentProject().jv4sx
1002                                          .getCamPos(), surfex_
1003                                          .getCurrentProject().jv4sx
1004                                          .getViewDir(), surfex_
1005                                          .getCurrentProject().jv4sx
1006                                          .getUpVector(), surfex_
1007                                          .getCurrentProject().jv4sx
1008                                          .getRightVector(),
1009                                          ((Integer)XrotSpinner.getModel().getValue()).intValue(),
1010                                          ((Integer)YrotSpinner.getModel().getValue()).intValue(),
1011                                          ((Integer)ZrotSpinner.getModel().getValue()).intValue()
1012                                          ,getParametersToRun());
1013                                  saveThread2.start();
1014
1015                                  //              saveFile(filelocation);
1016                                } else {
1017                                  //if(command.equals(JFileChooser.CANCEL_SELECTION)){
1018                                  frame2.setVisible(false);
1019                                  //}
1020                                }
1021                              }
1022                             };
1023
1024                         
1025                                FileFilter acfFilter = new ExtensionFileFilter(
1026                                    "all common files", new String[] {
1027                                        "gif", "mng"});
1028                                fileChooser.addChoosableFileFilter(acfFilter);
1029                                FileFilter spcFilter;
1030                                spcFilter = new ExtensionFileFilter("*.mng",
1031                                    new String[] { "mng" });
1032                                fileChooser.addChoosableFileFilter(spcFilter);
1033                                spcFilter = new ExtensionFileFilter("*.gif",
1034                                      new String[] { "gif" });
1035                                fileChooser.addChoosableFileFilter(spcFilter);
1036                               
1037                           
1038
1039                            // adding actionListener
1040                            fileChooser.addActionListener(actionListener);
1041                            frame2.pack();
1042                          } // end of else (i.e. !inAnApplet)
1043
1044                          frame2.setVisible(true);
1045
1046                          //oeffen den Kram unter filename;
1047
1048                          // end: command == "load"
1049                        }
1050                        if (command.hashCode() == 
1051                            DefaultButton.getText().hashCode()) {
1052                            //setVisible(false);
1053                            newSize.setText(rayFrame.getContentPane().getSize().width
1054                                            + " x "
1055                                            + rayFrame.getContentPane().getSize().height);
1056                            // rb[10].setSelected(true);
1057                            dpi.setText("72");
1058                            //FramesPerSecond.setText("15");
1059                            Time.setText("10");
1060                            height.setText(new String((new Integer(rayFrame
1061                                                                   .getContentPane().getSize().height)).toString()));
1062                            width.setText(new String((new Integer(rayFrame
1063                                                                  .getContentPane().getSize().width)).toString()));
1064                            colorType.setSelectedIndex(0);
1065                            antialiasingQuality.setSelectedIndex(0);//(true);
1066                            //_3d.setSelected(false);
1067                            aspectRatio.setSelected(true);
1068                            //ROTATE_Y_AXIS_Button.setSelected(true);
1069                           
1070                           
1071                           
1072                         
1073                         
1074                          /*
1075                          for (i = 0; i <= 15; i++) {
1076                            last[i] = false;
1077                          }
1078                          last[0] = true;
1079                          last[11] = true;
1080                          last[14] = true;
1081*/
1082                          updateLabel_newSize();
1083                        }
1084                        if (command.hashCode() == CancelButton.getText().hashCode()) {
1085                          setVisible(false);
1086                        }
1087                      }
1088                    };
1089                //panel3.add(new JLabel());
1090                SaveButton.addActionListener(AL);
1091                SaveButton.setDefaultCapable(true);
1092                panel3.add(SaveButton);
1093                CancelButton.addActionListener(AL);
1094                panel3.add(CancelButton);
1095                DefaultButton.addActionListener(AL);
1096                panel3.add(DefaultButton);
1097                //panel3.add(new JLabel());
1098
1099                contentPane.add(panel3, BorderLayout.SOUTH);
1100/*
1101                group.add(raytracedPic);
1102                group.add(povCode);
1103                group.add(surfCode);
1104               
1105        */     
1106                this.pack();
1107                setVisible(false);
1108       
1109                this.setLocation(200,100);
1110                setVisible(false);
1111        }
1112
1113        //     void saveFile(String filelocation) {
1114        //  project.saveFile(filelocation);
1115        //     } // end of saveFile(String filelocation)
1116
1117        public void updateLabel_newSize() {
1118                if (width.getText() != "" && height.getText() != ""
1119                                && dpi.getText() != "") {
1120                        if (measure.getSelectedIndex()==0) {
1121                                // pixel selektiert
1122                                setNewSize(Double.valueOf(height.getText()).intValue(),Double.valueOf(width.getText()).intValue());
1123                        }
1124                        if (measure.getSelectedIndex()==2) {
1125                                // inch selektiert
1126
1127                                setNewSize((int)(Double.parseDouble(height.getText()) * Integer
1128                                                .parseInt(dpi.getText())),(int)(Double.parseDouble(width.getText()) * Integer
1129                                                                .parseInt(dpi.getText())));
1130                        }
1131                        if (measure.getSelectedIndex()==1) {
1132                                // cm selektiert
1133                                setNewSize((int)(Math.round((Double.parseDouble(height.getText())
1134                                                * Integer.parseInt(dpi.getText()) * 0.3937))),(int)(Math.round((Double.parseDouble(width.getText())
1135                                                                * Integer.parseInt(dpi.getText()) * 0.3937))));
1136                        }
1137                }
1138                // SwingUtilities.updateComponentTreeUI(this);
1139        }
1140       
1141        public void updateSize(int h,int w){
1142                setNewSize(h,w);
1143                if(measure.getSelectedIndex()==0){
1144                        setWidth(h);
1145                        setHeight(w);
1146                }
1147                if(measure.getSelectedIndex()==1){
1148                        setWidth(((w/(Double.valueOf(dpi.getText()).doubleValue())*2.4)));
1149                        setHeight(((h/(Double.valueOf(dpi.getText()).doubleValue())*2.4)));
1150                }
1151                if(measure.getSelectedIndex()==2){
1152                        setWidth(w/(Double.valueOf(dpi.getText()).doubleValue()));
1153                        setHeight(h/(Double.valueOf(dpi.getText()).doubleValue()));
1154                }
1155               
1156        }
1157       
1158        public void setNewSize(int h, int w){
1159                heightvalue=h;
1160                widthvalue=w;
1161                newSize.setText(h+" x "+w);
1162        }
1163       
1164        public void setHeight(double h){
1165                if(measure.getSelectedIndex()==0){
1166                        //pixel ist selektiert, d.h. keine Nachkommastellen anzeigen!
1167
1168                        height.setText(((int)h)+"");
1169                }else{
1170                        // angabe in cm / inch:
1171                        // bis zu acht stellen (mit komma ) anzeigen:
1172                        height.setText((h+"        ").substring(0,8).replaceAll(" ",""));
1173       
1174                }               
1175        }public void setWidth(double w){
1176                if(measure.getSelectedIndex()==0){
1177                        //pixel ist selektiert, d.h. keine Nachkommastellen anzeigen!
1178
1179                        width.setText(((int)w)+"");
1180                }else{
1181                        // angabe in cm / inch:
1182                        // bieigen:
1183                        width.setText((w+"        ").substring(0,8).replaceAll(" ",""));
1184       
1185                }
1186        }
1187
1188         
1189          class removeListener implements ActionListener {
1190                public void actionPerformed(ActionEvent e) {
1191                    //This method can be called only if
1192                    //there's a valid selection
1193                    //so go ahead and remove whatever's selected.
1194                    int index = parameterList.getSelectedIndex();
1195                   
1196//                rausfinden, wo man den Parameter in ComboBox einfuegen kann:
1197                int i=0;
1198                //System.out.;
1199                for(i=0;i<paramName.getItemCount();i++){
1200                  if(((String)paramName.getItemAt(i)).compareTo((String)parameterList.getSelectedValue())>=0){
1201                //    i--;
1202                    break;
1203                  }
1204                }
1205               
1206                paramName.insertItemAt(parameterList.getSelectedValue(),i);
1207               
1208                   
1209                   
1210                    listModel.remove(index);
1211
1212                    int size = listModel.getSize();
1213
1214                    if (size == 0) { //Nobody's left, disable firing.
1215                        removeButton.setEnabled(false);
1216
1217                    } else { //Select an index.
1218                        if (index == listModel.getSize()) {
1219                            //removed item in last position
1220                            index--;
1221                        }
1222                       
1223                        parameterList.setSelectedIndex(index);
1224                        parameterList.ensureIndexIsVisible(index);
1225                    }
1226                   
1227
1228                    SwingUtilities.updateComponentTreeUI(paramName);
1229
1230                    SwingUtilities.updateComponentTreeUI(listScrollPane);
1231                }
1232               
1233               
1234               
1235            }
1236
1237            //This listener is shared by the text field and the hire button.
1238            class addListener implements ActionListener, DocumentListener {
1239                private boolean alreadyEnabled = false;
1240                private JLabel button;
1241
1242                public addListener(JLabel button) {
1243                    this.button = button;
1244                }
1245
1246                //Required by ActionListener.
1247                public void actionPerformed(ActionEvent e) {
1248                    String name = (String) paramName.getSelectedItem();
1249
1250                    if(paramName.getItemCount()!=0){
1251                 //   System.out.println("dabei --------------");
1252                      removeButton.setEnabled(true);
1253                    int index = parameterList.getSelectedIndex(); //get selected index
1254                    if (index == -1) { //no selection, so insert at beginning
1255                        index = 0;
1256                    } else {           //add after the selected item
1257                        index++;
1258                    }
1259                   
1260                    // In ScrollPane kopieren und aus ComboBox loeschen
1261                    int i;
1262                    String Item =(String)paramName.getSelectedItem();
1263                    for(i=0;i<parameterList.getModel().getSize();i++){
1264                  if(((String)parameterList.getModel().getElementAt(i)).compareTo(Item)>=0){
1265                //    i--;
1266                    break;
1267                  }
1268                }
1269                   
1270                    listModel.insertElementAt(Item, i);
1271                    //System.out.println();
1272                    paramName.removeItemAt(paramName.getSelectedIndex());
1273                    SwingUtilities.updateComponentTreeUI(paramName);
1274                    //If we just wanted to add to the end, we'd do this:
1275                    //listModel.addElement(employeeName.getText());
1276
1277                    //Reset the text field.
1278                    paramName.requestFocusInWindow();
1279                   // paramName.setText("");
1280
1281                    //Select the new item and make it visible.
1282                    parameterList.setSelectedIndex(index);
1283                    parameterList.ensureIndexIsVisible(index);
1284                    }
1285                }
1286               
1287//            Required by DocumentListener.
1288                public void insertUpdate(DocumentEvent e) {
1289                    enableButton();
1290                }
1291
1292                //Required by DocumentListener.
1293                public void removeUpdate(DocumentEvent e) {
1294                    handleEmptyTextField(e);
1295                }
1296
1297                //Required by DocumentListener.
1298                public void changedUpdate(DocumentEvent e) {
1299                    if (!handleEmptyTextField(e)) {
1300                        enableButton();
1301                    }
1302                }
1303               
1304                private void enableButton() {
1305                    if (!alreadyEnabled) {
1306                        button.setEnabled(true);
1307                    }
1308                }
1309                private boolean handleEmptyTextField(DocumentEvent e) {
1310                    if (e.getDocument().getLength() <= 0) {
1311                        button.setEnabled(false);
1312                        alreadyEnabled = false;
1313                        return true;
1314                    }
1315                    return false;
1316                }
1317            }
1318
1319            //This method is required by ListSelectionListener.
1320            public void valueChanged(ListSelectionEvent e) {
1321                if (e.getValueIsAdjusting() == false) {
1322
1323                    if (parameterList.getSelectedIndex() == -1) {
1324                    //No selection, disable fire button.
1325                        removeButton.setEnabled(false);
1326
1327                    } else {
1328                    //Selection, enable the fire button.
1329                        removeButton.setEnabled(true);
1330                    }
1331                }
1332            }
1333           
1334
1335           
1336            private String[] getParametersToRun(){
1337              String[] l=new String[parameterList.getModel().getSize()];
1338              int i;
1339              for(i=0;i<parameterList.getModel().getSize();i++){
1340                l[i]=(String)parameterList.getModel().getElementAt(i);
1341              }
1342             
1343              return l;
1344            }
1345} // end class SavePicDialog
1346
Note: See TracBrowser for help on using the repository browser.