68 lines
1.6 KiB
Java
68 lines
1.6 KiB
Java
/*
|
|
* 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.CommandConnect;
|
|
import ChatProgramm.controller.commands.CommandInvoker;
|
|
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;
|
|
import java.awt.Component;
|
|
|
|
/**
|
|
*
|
|
* @author le
|
|
*/
|
|
public class GrafikController extends MouseAdapter implements MouseMotionListener
|
|
{
|
|
private GrafikView view;
|
|
private GrafikModel model;
|
|
private CommandControler commandController;
|
|
|
|
public GrafikController(GrafikView view, GrafikModel model, CommandController controller_commands)
|
|
{
|
|
this.view = view;
|
|
this.model = model;
|
|
}
|
|
|
|
public void registerEvents()
|
|
{
|
|
view.addMouseMotionListener(this);
|
|
view.addMouseListener(this);
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public void mouseDragged(MouseEvent evt)
|
|
{
|
|
Point p = evt.getPoint();
|
|
model.addPoint(p);
|
|
view.drawPoint(p);
|
|
}
|
|
|
|
@Override
|
|
public void mouseMoved(MouseEvent e)
|
|
{
|
|
}
|
|
|
|
@Override
|
|
public void mouseReleased(MouseEvent evt)
|
|
{
|
|
model.endShape();
|
|
Component key = (Component)evt.getSource();
|
|
invoker.executeCommand(key);
|
|
// if (evt.getButton() == MouseEvent.BUTTON3)
|
|
// {
|
|
// view.doPrint();
|
|
// }
|
|
}
|
|
}
|