Listener.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* File : Listener.java
  2. * Program : Handle Reduction Aimation - Applet
  3. * By Jean Fromentin <jfroment@info.unicaen.fr>
  4. * Copyright 2008 Jean Fromentin
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. import java.awt.event.ActionListener;
  17. import java.awt.event.AdjustmentListener;
  18. import java.awt.event.ActionEvent;
  19. import java.awt.event.AdjustmentEvent;
  20. public class Listener implements ActionListener, AdjustmentListener{
  21. private Components components;
  22. public Listener(Components components){
  23. this.components=components;
  24. }
  25. public void actionPerformed(ActionEvent event){
  26. String action=event.getActionCommand();
  27. if(action.equals("draw")){
  28. components.draw();
  29. }
  30. else if(action.equals("drawApply")){
  31. components.drawBraid();
  32. components.closeDraw();
  33. }
  34. else if(action.equals("drawCancel")){
  35. components.closeDraw();
  36. }
  37. else if(action.equals("reduce")){
  38. components.reduce();
  39. }
  40. else if(action.equals("controls")){
  41. components.controls();
  42. }
  43. else if(action.equals("compare")){
  44. components.compare();
  45. }
  46. else if(action.equals("compareApply")){
  47. components.compareBraids();
  48. components.closeCompare();
  49. }
  50. else if(action.equals("compareClose")){
  51. components.closeCompare();
  52. }
  53. else if(action.equals("controlsApply")){
  54. components.saveParameters();
  55. components.closeControls();
  56. }
  57. else if(action.equals("controlsCancel")){
  58. components.closeControls();
  59. }
  60. else if(action.equals("tic")){
  61. components.tic();
  62. }
  63. else{
  64. System.out.println(action);
  65. }
  66. }
  67. public void adjustmentValueChanged(AdjustmentEvent event){
  68. components.delayAdjust();
  69. }
  70. }