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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package mvcgrafik.controller;
  7. import java.awt.Point;
  8. import java.awt.event.MouseEvent;
  9. import java.awt.event.MouseListener;
  10. import java.awt.event.MouseMotionListener;
  11. import mvcgrafik.model.GrafikModel;
  12. import mvcgrafik.view.GrafikView;
  13. /**
  14. *
  15. * @author le
  16. */
  17. public class GrafikController implements MouseMotionListener, MouseListener
  18. {
  19. private GrafikView view;
  20. private GrafikModel model;
  21. public GrafikController(GrafikView view, GrafikModel model)
  22. {
  23. this.view = view;
  24. this.model = model;
  25. }
  26. public void registerEvents()
  27. {
  28. view.addMouseMotionListener(this);
  29. view.addMouseListener(this);
  30. }
  31. @Override
  32. public void mouseDragged(MouseEvent evt)
  33. {
  34. Point p = evt.getPoint();
  35. view.drawPoint(p);
  36. model.addPoint(p);
  37. }
  38. @Override
  39. public void mouseMoved(MouseEvent e)
  40. {
  41. }
  42. @Override
  43. public void mouseClicked(MouseEvent e)
  44. {
  45. }
  46. @Override
  47. public void mousePressed(MouseEvent e)
  48. {
  49. }
  50. @Override
  51. public void mouseReleased(MouseEvent evt)
  52. {
  53. if (evt.getButton() == MouseEvent.BUTTON3)
  54. {
  55. view.doPrint();
  56. }
  57. }
  58. @Override
  59. public void mouseEntered(MouseEvent e)
  60. {
  61. }
  62. @Override
  63. public void mouseExited(MouseEvent e)
  64. {
  65. }
  66. }