You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GrafikController.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  3. * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
  4. */
  5. package ChatProgramm.controller;
  6. import ChatProgramm.controller.commands.CommandConnect;
  7. import ChatProgramm.controller.commands.CommandInvoker;
  8. import ChatProgramm.controller.commands.CommandSend;
  9. import java.awt.Point;
  10. import java.awt.event.MouseAdapter;
  11. import java.awt.event.MouseEvent;
  12. import java.awt.event.MouseMotionListener;
  13. import ChatProgramm.model.GrafikModel;
  14. import ChatProgramm.view.GrafikView;
  15. import java.awt.Component;
  16. /**
  17. *
  18. * @author le
  19. */
  20. public class GrafikController extends MouseAdapter implements MouseMotionListener
  21. {
  22. private GrafikView view;
  23. private GrafikModel model;
  24. private CommandInvoker invoker;
  25. public GrafikController(GrafikView view, GrafikModel model)
  26. {
  27. this.view = view;
  28. this.model = model;
  29. }
  30. public void registerEvents()
  31. {
  32. view.addMouseMotionListener(this);
  33. view.addMouseListener(this);
  34. }
  35. public void registerCommands(){
  36. CommandSend commandSend = new CommandSend(view);
  37. invoker.addCommand(view.getTfNachricht(), commandSend);
  38. }
  39. @Override
  40. public void mouseDragged(MouseEvent evt)
  41. {
  42. Point p = evt.getPoint();
  43. model.addPoint(p);
  44. view.drawPoint(p);
  45. }
  46. @Override
  47. public void mouseMoved(MouseEvent e)
  48. {
  49. }
  50. @Override
  51. public void mouseReleased(MouseEvent evt)
  52. {
  53. model.endShape();
  54. Component key = (Component)evt.getSource();
  55. invoker.executeCommand(key);
  56. // if (evt.getButton() == MouseEvent.BUTTON3)
  57. // {
  58. // view.doPrint();
  59. // }
  60. }
  61. }