|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
- */
-
- package ChatProgramm.controller;
-
- import ChatProgramm.controller.commands.CommandSend;
- import java.awt.Point;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseMotionListener;
- import ChatProgramm.model.GrafikModel;
- import ChatProgramm.view.GrafikView;
-
- /**
- *
- * @author le
- */
- public class GrafikController extends MouseAdapter implements MouseMotionListener
- {
- private GrafikView view;
- private GrafikModel model;
- private CommandSend commandSend;
-
- public GrafikController(GrafikView view, GrafikModel model)
- {
- this.view = view;
- this.model = model;
- commandSend = null;
- }
-
- void setCommand(CommandSend command){
- this.commandSend = command;
- }
-
- public void registerEvents()
- {
- view.addMouseMotionListener(this);
- view.addMouseListener(this);
- }
-
-
-
- @Override
- public void mouseDragged(MouseEvent evt)
- {
- Point p = evt.getPoint();
- model.addPoint(p);
- view.drawPoint();
- }
-
- @Override
- public void mouseMoved(MouseEvent e)
- {
- }
-
- @Override
- public void mouseReleased(MouseEvent evt)
- {
- model.endShape();
- if(commandSend != null){
- commandSend.execute();
- }
-
- }
- }
|