001    package demo;
002    
003    import java.awt.*;
004    import java.awt.event.*;
005    import javax.swing.*;
006    
007    import lrs.*;
008    import lrs.visitor.*;
009    import counter.*;
010    import lrs.lazyLRSEvaluators.*;
011    import logic.*;
012    
013    
014    public class LazyLRSDemoFrame extends JFrame {
015      GridLayout gridLayout1 = new GridLayout();
016      JTextArea textArea1 = new JTextArea();
017      JPanel algoPnl = new JPanel();
018      JLabel displayLenLbl = new JLabel();
019      JLabel ioALbl = new JLabel();
020      JLabel ioBLbl = new JLabel();
021      JTextField ioATF = new JTextField();
022      JTextField ioBTF = new JTextField();
023      JTextField displayLenTF = new JTextField();
024      JPanel ctrlPnl = new JPanel();
025      JPanel displayLenIOABPnl = new JPanel();
026      JPanel displayLenPnl = new JPanel();
027      JPanel ioAPnl = new JPanel();
028      JPanel ioBPnl = new JPanel();
029      JPanel displayLenIOABCtrlPnl = new JPanel();
030      JRadioButton chkBxConst = new JRadioButton();
031      JRadioButton chkBxInc = new JRadioButton();
032      JRadioButton chkBxFibonacci = new JRadioButton();
033      JRadioButton chkBxFilter = new JRadioButton();
034      JRadioButton chkBxRangeFilter = new JRadioButton();
035      JRadioButton chkBxMultMNodFilter = new JRadioButton();
036      JRadioButton chkBxSieve = new JRadioButton();
037      JRadioButton chkBxNInv = new JRadioButton();
038      JRadioButton chkBxLambda = new JRadioButton();
039      ButtonGroup buttonGroup = new ButtonGroup();
040      
041      LRStruct list = new LRStruct();
042      ICounterFactory cf = CounterFactory.Singleton;
043      
044      JScrollPane jScrollPane1 = new JScrollPane();
045      JButton selSortBtn = new JButton();
046      JButton selSortBtn1 = new JButton();
047      JButton nthCdrBtn = new JButton();
048      JButton trimBtn = new JButton();
049      JButton btnSetNth = new JButton();
050      JButton btnRemNth = new JButton();
051      JButton btnNth = new JButton();
052      JButton sumBtn = new JButton();
053      JButton sumNBtn = new JButton();
054      JButton sumLambdaNBtn = new JButton();
055      JButton appendBtn = new JButton();
056      JButton getLastBtn = new JButton();
057      JButton removeBtn = new JButton();
058      JButton ordInsertBtn = new JButton();
059      JButton consBtn = new JButton();
060      JButton clearBtn = new JButton();
061      GridLayout gridLayout5 = new GridLayout();
062      GridLayout gridLayout6 = new GridLayout();
063      GridLayout gridLayout7 = new GridLayout();
064      GridLayout gridLayout8 = new GridLayout();
065      BorderLayout borderLayout1 = new BorderLayout();
066      BorderLayout borderLayout2 = new BorderLayout();
067      BorderLayout borderLayout3 = new BorderLayout();
068      
069      //Construct the frame
070      public LazyLRSDemoFrame() {
071        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
072        try  {
073          jbInit();
074        }
075        catch(Exception e) {
076          e.printStackTrace();
077        }
078        addWindowListener(new WindowAdapter() {
079          public void windowClosing(WindowEvent e) {
080            System.exit(0);
081          }
082        });
083        
084        buttonGroup.add(chkBxConst);
085        buttonGroup.add(chkBxInc);
086        buttonGroup.add(chkBxFibonacci);
087        buttonGroup.add(chkBxFilter);
088        buttonGroup.add(chkBxRangeFilter);
089        buttonGroup.add(chkBxMultMNodFilter);
090        buttonGroup.add(chkBxSieve);
091        buttonGroup.add(chkBxNInv);
092        buttonGroup.add(chkBxLambda);
093        validate();
094        pack();
095      }
096      
097      //Component initialization
098      private void jbInit() throws Exception  {
099        gridLayout1.setColumns(3);
100        gridLayout1.setHgap(2);
101        gridLayout1.setVgap(2);
102        this.getContentPane().setLayout(gridLayout1);
103       // this.setSize(new Dimension(810, 737));
104        this.setTitle("Lazy Evaluation of LRStructs");
105        
106        displayLenLbl.setFont(new java.awt.Font("Dialog", 1, 18));
107        displayLenLbl.setHorizontalAlignment(SwingConstants.LEFT);
108        displayLenLbl.setLabelFor(displayLenTF);
109        displayLenLbl.setText("Display length:");
110      
111        ioALbl.setFont(new java.awt.Font("Dialog", 1, 18));
112        ioALbl.setHorizontalAlignment(SwingConstants.LEFT);
113        ioALbl.setText("Input/Output A:");
114        
115        ioBLbl.setFont(new java.awt.Font("Dialog", 1, 18));
116        ioBLbl.setHorizontalAlignment(SwingConstants.LEFT);
117        ioBLbl.setText("Input/Output B:");
118        
119        ioATF.setColumns(6);
120        ioATF.setHorizontalAlignment(SwingConstants.CENTER);
121        ioATF.setBackground(Color.lightGray);
122        ioATF.setFont(new java.awt.Font("SansSerif", 1, 20));
123        ioATF.setBorder(null);
124        ioATF.setOpaque(false);
125        ioATF.setText("1");    
126        
127        ioBTF.setFont(new java.awt.Font("SansSerif", 1, 20));
128        ioBTF.setColumns(6);
129        ioBTF.setBorder(null);
130        ioBTF.setOpaque(false);
131        ioBTF.setText("1");
132        ioBTF.setHorizontalAlignment(SwingConstants.CENTER);
133        
134        displayLenTF.setBackground(Color.lightGray);
135        displayLenTF.setFont(new java.awt.Font("Dialog", 1, 20));
136        displayLenTF.setBorder(null);
137        displayLenTF.setOpaque(false);
138        displayLenTF.setPreferredSize(new Dimension(102, 27));
139        displayLenTF.setText("15");
140        displayLenTF.setHorizontalAlignment(SwingConstants.CENTER);
141        displayLenTF.addActionListener(new java.awt.event.ActionListener() {
142          public void actionPerformed(ActionEvent e) {
143            displayLenTF_actionPerformed(e);
144          }
145        });
146        ctrlPnl.setLayout(gridLayout6);
147        ctrlPnl.setBackground(Color.cyan);
148        //ctrlPnl.setPreferredSize(new Dimension(227, 500));
149        displayLenIOABPnl.setLayout(gridLayout7);
150        displayLenPnl.setLayout(borderLayout2);
151        ioAPnl.setLayout(borderLayout1);
152        ioBPnl.setLayout(borderLayout3);
153        displayLenIOABCtrlPnl.setLayout(gridLayout8);
154        chkBxConst.setToolTipText("value <- A");
155        chkBxConst.setOpaque(false);
156        chkBxConst.setText("Constant List");
157        chkBxConst.setFont(new java.awt.Font("Dialog", 1, 18));
158        chkBxConst.addActionListener(new java.awt.event.ActionListener() {
159          public void actionPerformed(ActionEvent e) {
160            chkBxConst_actionPerformed(e);
161          }
162        });
163        chkBxInc.addActionListener(new java.awt.event.ActionListener() {
164          public void actionPerformed(ActionEvent e) {
165            chkBxInc_actionPerformed(e);
166          }
167        });
168        chkBxInc.setText("Arithmetic List");
169        chkBxInc.setFont(new java.awt.Font("Dialog", 1, 18));
170        chkBxInc.setToolTipText("x0 <- A, inc <- B");
171        chkBxInc.setOpaque(false);
172        chkBxFibonacci.setOpaque(false);
173        chkBxFibonacci.setText("Fibonacci List");
174        chkBxFibonacci.setFont(new java.awt.Font("Dialog", 1, 18));
175        chkBxFibonacci.addActionListener(new java.awt.event.ActionListener() {
176          public void actionPerformed(ActionEvent e) {
177            chkBxFibonacci_actionPerformed(e);
178          }
179        });
180        chkBxFilter.setToolTipText("value <- A");
181        chkBxFilter.setOpaque(false);
182        chkBxFilter.setText("Modulo Filter");
183        chkBxFilter.setFont(new java.awt.Font("Dialog", 1, 18));
184        chkBxFilter.addActionListener(new java.awt.event.ActionListener() {
185          public void actionPerformed(ActionEvent e) {
186            chkBxFilter_actionPerformed(e);
187          }
188        });
189        chkBxRangeFilter.setToolTipText("min <- A, max <- B");
190        chkBxRangeFilter.setOpaque(false);
191        chkBxRangeFilter.setText("Range Filtered List");
192        chkBxRangeFilter.setFont(new java.awt.Font("Dialog", 1, 18));
193        chkBxRangeFilter.addActionListener(new java.awt.event.ActionListener() {
194          public void actionPerformed(ActionEvent e) {
195            chkBxRangeFilter_actionPerformed(e);
196          }
197        });
198        chkBxMultMNodFilter.setToolTipText("value 1 <- A, value 2 <- B");
199        chkBxMultMNodFilter.setOpaque(false);
200        chkBxMultMNodFilter.setText("Multiple Modulo Filtered List");
201        chkBxMultMNodFilter.setFont(new java.awt.Font("Dialog", 1, 18));
202        chkBxMultMNodFilter.addActionListener(new java.awt.event.ActionListener() {
203          public void actionPerformed(ActionEvent e) {
204            chkBxMultMNodFilter_actionPerformed(e);
205          }
206        });
207        chkBxSieve.setOpaque(false);
208        chkBxSieve.setText("Prime Numbers List");
209        chkBxSieve.setFont(new java.awt.Font("Dialog", 1, 18));
210        chkBxSieve.addActionListener(new java.awt.event.ActionListener() {
211          public void actionPerformed(ActionEvent e) {
212            chkBxSieve_actionPerformed(e);
213          }
214        });
215        
216        chkBxNInv.setOpaque(false);
217        chkBxNInv.setText("1/N! list");
218        chkBxNInv.setFont(new java.awt.Font("Dialog", 1, 18));
219        chkBxNInv.addActionListener(new java.awt.event.ActionListener() {
220          public void actionPerformed(ActionEvent e) {
221            chkBxNInv_actionPerformed(e);
222          }
223        });
224    
225        chkBxLambda.setOpaque(false);
226        chkBxLambda.setText("Lambda list");
227        chkBxLambda.setFont(new java.awt.Font("Dialog", 1, 18));
228        chkBxLambda.addActionListener(new java.awt.event.ActionListener() {
229          public void actionPerformed(ActionEvent e) {
230            chkBxLambda_actionPerformed(e);
231          }
232        });
233        
234        textArea1.setMargin(new Insets(10, 50, 10, 10));
235        textArea1.setEditable(false);
236        textArea1.setFont(new java.awt.Font("Serif", 1, 30));
237        selSortBtn.setBackground(Color.yellow);
238        selSortBtn.setFont(new java.awt.Font("Dialog", 1, 18));
239        selSortBtn.setText("Selection Sort  <");
240        selSortBtn.addActionListener(new java.awt.event.ActionListener() {
241          public void actionPerformed(ActionEvent e) {
242            selSortBtn_actionPerformed(e);
243          }
244        });
245        algoPnl.setLayout(gridLayout5);
246        algoPnl.setBackground(new java.awt.Color(135, 104, 151));
247        selSortBtn1.setText("Selection Sort  >");
248        selSortBtn1.addActionListener(new java.awt.event.ActionListener() {
249          public void actionPerformed(ActionEvent e)
250          {
251            selSortBtn1_actionPerformed(e);
252          }
253        });
254        selSortBtn1.setFont(new java.awt.Font("Dialog", 1, 18));
255        selSortBtn1.setBackground(Color.yellow);
256        nthCdrBtn.setText("n\'th Cdr");
257        nthCdrBtn.addActionListener(new java.awt.event.ActionListener() {
258          public void actionPerformed(ActionEvent e)
259          {
260            nthCdrBtn_actionPerformed(e);
261          }
262        });
263        nthCdrBtn.setFont(new java.awt.Font("Dialog", 1, 18));
264        nthCdrBtn.setToolTipText("n <- A");
265        nthCdrBtn.setBackground(Color.yellow);
266        trimBtn.setText("Trim at n\'th");
267        trimBtn.addActionListener(new java.awt.event.ActionListener() {
268          public void actionPerformed(ActionEvent e)
269          {
270            trimBtn_actionPerformed(e);
271          }
272        });
273        trimBtn.setFont(new java.awt.Font("Dialog", 1, 18));
274        trimBtn.setToolTipText("n <- A");
275        trimBtn.setBackground(Color.yellow);
276        btnSetNth.setText("Set n\'th");
277        btnSetNth.addActionListener(new java.awt.event.ActionListener() {
278          public void actionPerformed(ActionEvent e)
279          {
280            btnSetNth_actionPerformed(e);
281          }
282        });
283        btnSetNth.setFont(new java.awt.Font("Dialog", 1, 18));
284        btnSetNth.setToolTipText("n <- A, value <- B");
285        btnSetNth.setBackground(Color.yellow);
286        btnRemNth.setText("Remove n\'th");
287        btnRemNth.addActionListener(new java.awt.event.ActionListener() {
288          public void actionPerformed(ActionEvent e)
289          {
290            btnRemNth_actionPerformed(e);
291          }
292        });
293        btnRemNth.setFont(new java.awt.Font("Dialog", 1, 18));
294        btnRemNth.setToolTipText("n <- A, B <- value");
295        btnRemNth.setBackground(Color.yellow);
296        btnNth.setText("n\'th Element");
297        btnNth.addActionListener(new java.awt.event.ActionListener() {
298          public void actionPerformed(ActionEvent e)
299          {
300            btnNth_actionPerformed(e);
301          }
302        });
303        btnNth.setFont(new java.awt.Font("Dialog", 1, 18));
304        btnNth.setToolTipText("n <- A,  B <- value");
305        btnNth.setBackground(Color.yellow);
306        sumBtn.setText("Sum");
307        sumBtn.addActionListener(new java.awt.event.ActionListener() {
308          public void actionPerformed(ActionEvent e)
309          {
310            sumBtn_actionPerformed(e);
311          }
312        });
313        sumBtn.setFont(new java.awt.Font("Dialog", 1, 18));
314        sumBtn.setToolTipText("A <- sum");
315        sumBtn.setBackground(Color.yellow);
316    
317        sumNBtn.setText("Sum N terms");
318        sumNBtn.addActionListener(new java.awt.event.ActionListener(){
319          public void actionPerformed(ActionEvent e)
320          {
321            sumNBtn_actionPerformed(e);
322          }
323        });
324        
325        sumNBtn.setFont(new java.awt.Font("Dialog", 1, 18));
326        sumNBtn.setToolTipText("A = N, B <- sum");
327        sumNBtn.setBackground(Color.yellow);
328        
329        sumLambdaNBtn.setText("Sum N Lamba terms");
330        sumLambdaNBtn.addActionListener(new java.awt.event.ActionListener(){
331          public void actionPerformed(ActionEvent e)
332          {
333            sumLambdaNBtn_actionPerformed(e);
334          }
335        });
336        
337        sumLambdaNBtn.setFont(new java.awt.Font("Dialog", 1, 18));
338        sumLambdaNBtn.setToolTipText("A = N, B = 0<x<1, B <- sum");
339        sumLambdaNBtn.setBackground(Color.yellow);
340        
341        appendBtn.setText("Append");
342        appendBtn.addActionListener(new java.awt.event.ActionListener() {
343          public void actionPerformed(ActionEvent e)
344          {
345            appendBtn_actionPerformed(e);
346          }
347        });
348        appendBtn.setFont(new java.awt.Font("Dialog", 1, 18));
349        appendBtn.setToolTipText("value <- A");
350        appendBtn.setBackground(Color.yellow);
351        getLastBtn.setText("Get Last");
352        getLastBtn.addActionListener(new java.awt.event.ActionListener() {
353          public void actionPerformed(ActionEvent e)
354          {
355            getLastBtn_actionPerformed(e);
356          }
357        });
358        getLastBtn.setFont(new java.awt.Font("Dialog", 1, 18));
359        getLastBtn.setToolTipText("A <- value");
360        getLastBtn.setBackground(Color.yellow);
361        removeBtn.setText("Remove Car");
362        removeBtn.addActionListener(new java.awt.event.ActionListener() {
363          public void actionPerformed(ActionEvent e) {
364            removeBtn_actionPerformed(e);
365          }
366        });
367        removeBtn.setFont(new java.awt.Font("Dialog", 1, 18));
368        removeBtn.setToolTipText("A <- value");
369        removeBtn.setBackground(Color.yellow);
370        ordInsertBtn.setText("Ordered Insert +");
371        ordInsertBtn.addActionListener(new java.awt.event.ActionListener() {
372          public void actionPerformed(ActionEvent e) {
373            ordInsertBtn_actionPerformed(e);
374          }
375        });
376        ordInsertBtn.setFont(new java.awt.Font("Dialog", 1, 18));
377        ordInsertBtn.setToolTipText("value <- A");
378        ordInsertBtn.setBackground(Color.yellow);
379        consBtn.setText("Cons");
380        consBtn.addActionListener(new java.awt.event.ActionListener() {
381          public void actionPerformed(ActionEvent e) {
382            consBtn_actionPerformed(e);
383          }
384        });
385        consBtn.setFont(new java.awt.Font("Dialog", 1, 18));
386        consBtn.setToolTipText("car <- A ");
387        consBtn.setBackground(Color.yellow);
388        clearBtn.setText("Clear");
389        clearBtn.addActionListener(new java.awt.event.ActionListener() {
390          public void actionPerformed(ActionEvent e) {
391            clearBtn_actionPerformed(e);
392          }
393        });
394        clearBtn.setFont(new java.awt.Font("Dialog", 1, 18));
395        clearBtn.setBackground(Color.yellow);
396        gridLayout5.setColumns(1);
397        gridLayout5.setHgap(2);
398        gridLayout5.setRows(0);
399        gridLayout5.setVgap(2);
400        gridLayout6.setColumns(1);
401        gridLayout6.setHgap(2);
402        gridLayout6.setRows(0);
403        gridLayout6.setVgap(2);
404        gridLayout7.setColumns(1);
405        gridLayout7.setHgap(2);
406        gridLayout7.setRows(0);
407        gridLayout7.setVgap(2);
408        gridLayout8.setColumns(1);
409        gridLayout8.setHgap(2);
410        gridLayout8.setRows(0);
411        gridLayout8.setVgap(2);
412        displayLenIOABPnl.setBackground(Color.white);
413        displayLenPnl.setBorder(BorderFactory.createRaisedBevelBorder());
414        ioAPnl.setBorder(BorderFactory.createRaisedBevelBorder());
415        ioBPnl.setBorder(BorderFactory.createRaisedBevelBorder());
416        this.getContentPane().add(displayLenIOABCtrlPnl, null);
417        displayLenIOABCtrlPnl.add(displayLenIOABPnl, null);
418        displayLenIOABPnl.add(displayLenPnl, null);
419        displayLenPnl.add(displayLenLbl, BorderLayout.CENTER);
420        displayLenPnl.add(displayLenTF, BorderLayout.EAST);
421        displayLenIOABPnl.add(ioAPnl, null);
422        ioAPnl.add(ioALbl, BorderLayout.WEST);
423        ioAPnl.add(ioATF, BorderLayout.CENTER);
424        displayLenIOABPnl.add(ioBPnl, null);
425        ioBPnl.add(ioBLbl, BorderLayout.WEST);
426        ioBPnl.add(ioBTF, BorderLayout.CENTER);
427        displayLenIOABCtrlPnl.add(ctrlPnl, null);
428        ctrlPnl.add(chkBxConst, null);
429        ctrlPnl.add(chkBxInc, null);
430        ctrlPnl.add(chkBxFilter, null);
431        ctrlPnl.add(chkBxFibonacci, null);
432        ctrlPnl.add(chkBxRangeFilter, null);
433        ctrlPnl.add(chkBxMultMNodFilter, null);
434        ctrlPnl.add(chkBxSieve, null);
435        ctrlPnl.add(chkBxNInv, null);
436        ctrlPnl.add(chkBxLambda, null);
437    
438        this.getContentPane().add(algoPnl, null);
439        algoPnl.add(clearBtn, null);
440        algoPnl.add(consBtn, null);
441        algoPnl.add(ordInsertBtn, null);
442        algoPnl.add(removeBtn, null);
443        algoPnl.add(getLastBtn, null);
444        algoPnl.add(appendBtn, null);
445        algoPnl.add(sumBtn, null);
446        algoPnl.add(sumNBtn, null);
447        algoPnl.add(sumLambdaNBtn, null);
448        algoPnl.add(btnNth, null);
449        algoPnl.add(btnRemNth, null);
450        algoPnl.add(btnSetNth, null);
451        algoPnl.add(trimBtn, null);
452        algoPnl.add(nthCdrBtn, null);
453        algoPnl.add(selSortBtn1, null);
454        algoPnl.add(selSortBtn, null);
455        this.getContentPane().add(jScrollPane1, null);
456        jScrollPane1.getViewport().add(textArea1, null);
457      }
458      
459      
460      void displayLenTF_actionPerformed(ActionEvent e) {
461        printList();
462      }
463      
464      void chkBxConst_actionPerformed(ActionEvent e) {
465        list = new LazyConstantEval (Integer.parseInt(ioATF.getText())).makeLRS ();
466        printList ();
467      }
468      
469      void chkBxInc_actionPerformed(ActionEvent e) {
470        list = new LazyIncEval (Integer.parseInt(ioATF.getText()),
471                                Integer.parseInt(ioBTF.getText())).makeLRS ();
472        printList ();
473      }
474      
475      void chkBxFibonacci_actionPerformed(ActionEvent e) {
476        list =  (new LazyFibEval(0, 1)).makeLRS();
477        printList();
478      }
479      
480      void chkBxFilter_actionPerformed(ActionEvent e){
481        list = new LazyFilterEval (new ModPredStrategy(Integer.parseInt (ioATF.getText ())), list).makeLRS ();
482        printList ();
483      }
484      
485      void chkBxRangeFilter_actionPerformed(ActionEvent e) {
486        list = new LazyFilterEval (new RangePredicate(
487                                                      Integer.parseInt (ioATF.getText ()),
488                                                      Integer.parseInt (ioBTF.getText ())),
489                                   list).makeLRS ();
490        printList ();
491      }
492      
493      void chkBxMultMNodFilter_actionPerformed(ActionEvent e) {
494        list = new LazyFilterEval (new MultModPredicate(Integer.parseInt (ioATF.getText ()),
495                                                        Integer.parseInt (ioBTF.getText ())),
496                                   list).makeLRS ();
497        printList ();
498      }
499      
500      void chkBxSieve_actionPerformed(ActionEvent e) {
501        list =  (new LazySieveEval()).makeLRS();
502        printList();
503      }
504      
505      void chkBxNInv_actionPerformed(ActionEvent e) {
506        list =  (new LazyNFacInvEval()).makeLRS();
507        printList();
508      }
509    
510      void chkBxLambda_actionPerformed(ActionEvent e) {
511        list =  (new LazyLambdaEval()).makeLRS();
512        printList();
513      }
514      
515      void printList(){
516        textArea1.setText("");
517        list.execute(new LRSPrintN(textArea1), cf.makeCounter(Integer.parseInt(displayLenTF.getText())));
518        validate();
519        pack();   
520      }
521      
522      void clearBtn_actionPerformed(ActionEvent e) {
523        list.execute(LRSClear.Singleton);
524        printList();  
525      }
526      
527      void consBtn_actionPerformed(ActionEvent e) {
528        list.insertFront(new Integer(ioATF.getText()));
529        printList();
530      }
531      
532      void ordInsertBtn_actionPerformed(ActionEvent e){
533        list.execute( LRSOrderedInsert.Singleton, new Integer(ioATF.getText()));
534        printList();
535      }
536      
537      void removeBtn_actionPerformed(ActionEvent e) {
538        ioATF.setText(((Integer)list.removeFront()).toString());
539        printList();
540      }
541      
542      void getLastBtn_actionPerformed(ActionEvent e) {
543        ioATF.setText(((Integer)list.execute(GetLast.Singleton,list)).toString());
544      }
545      
546      void appendBtn_actionPerformed(ActionEvent e) {
547        list.execute( LRSAppend.Singleton, new Integer(ioATF.getText()));
548        printList();
549      }
550      
551      void sumBtn_actionPerformed(ActionEvent e) {
552        ioATF.setText(((Integer) list.execute(LRSSum.Singleton)).toString());
553      }
554      
555      void sumNBtn_actionPerformed(ActionEvent e) {
556        ioBTF.setText(list.execute(LRSSumN.Singleton,
557                                   cf.makeCounter(Integer.parseInt(ioATF.getText()))).toString());
558      }
559      
560      void sumLambdaNBtn_actionPerformed(ActionEvent e) {
561        ioBTF.setText(list.execute(LRSSumLambdaN.Singleton,
562                                   cf.makeCounter(Integer.parseInt(ioATF.getText())),
563                                   Double.parseDouble(ioBTF.getText())).toString());
564      }
565    
566      void btnNth_actionPerformed(ActionEvent e) {
567        ioBTF.setText(list.execute(Nth.Singleton, 
568                                   cf.makeCounter(Integer.parseInt(ioATF.getText()))).toString());
569      }
570      
571      void btnRemNth_actionPerformed(ActionEvent e) {
572        ioBTF.setText(list.execute(RemoveNth.Singleton, 
573                                   cf.makeCounter(Integer.parseInt(ioATF.getText ()))).toString());
574        printList ();
575      }
576      
577      void btnSetNth_actionPerformed(ActionEvent e){
578        int ix = Integer.parseInt (ioATF.getText ());
579        Integer dat = Integer.parseInt (ioBTF.getText ());
580        list.execute(SetNth.Singleton, cf.makeCounter(ix), dat);
581        printList ();
582      }
583      
584      void trimBtn_actionPerformed(ActionEvent e) {
585        list.execute(LRSTrim.Singleton, 
586                     cf.makeCounter(Integer.parseInt(ioATF.getText())));
587        printList();
588      }
589      
590      void nthCdrBtn_actionPerformed(ActionEvent e){
591        list = (LRStruct) list.execute(NthCdr.Singleton, 
592                                       cf.makeCounter(Integer.parseInt(ioATF.getText())));
593        printList();
594      }
595      
596      void selSortBtn1_actionPerformed(ActionEvent e){
597        list.execute(new SelectionSort(GetMax.Singleton));
598        printList();
599      }
600      
601      void selSortBtn_actionPerformed(ActionEvent e){
602        list.execute(new SelectionSort(GetMin.Singleton));
603        printList();
604      }  
605    }