Compare commits
6
Commits
64a6047ca4
..
Toni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75cdcf7202 | ||
|
|
ba0f12561b | ||
|
|
e7034fc7a4 | ||
|
|
19fd23c638 | ||
|
|
f7a0de0041 | ||
|
|
0da0f2cc5b |
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
/nbproject/private/
|
||||||
|
/build/
|
||||||
|
/dist/
|
||||||
@@ -6,7 +6,10 @@
|
|||||||
package ChatProgramm;
|
package ChatProgramm;
|
||||||
|
|
||||||
import ChatProgramm.controller.CommandController;
|
import ChatProgramm.controller.CommandController;
|
||||||
|
import ChatProgramm.controller.GrafikController;
|
||||||
|
import ChatProgramm.model.GrafikModel;
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
|
import ChatProgramm.view.GrafikView;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
@@ -18,8 +21,13 @@ public class Start
|
|||||||
{
|
{
|
||||||
public Start()
|
public Start()
|
||||||
{
|
{
|
||||||
|
GrafikModel model = new GrafikModel();
|
||||||
ChatView view = new ChatView();
|
ChatView view = new ChatView();
|
||||||
CommandController controller_commands = new CommandController(view);
|
GrafikView zeichenflaeche = view.getGvZeichenflaeche();
|
||||||
|
zeichenflaeche.setModel(model);
|
||||||
|
GrafikController controller = new GrafikController(zeichenflaeche, model);
|
||||||
|
controller.registerEvents();
|
||||||
|
CommandController controller_commands = new CommandController(view, model, controller, zeichenflaeche);
|
||||||
controller_commands.registerEvents();
|
controller_commands.registerEvents();
|
||||||
controller_commands.registerCommands();
|
controller_commands.registerCommands();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ package ChatProgramm.controller;
|
|||||||
import ChatProgramm.controller.commands.CommandConnect;
|
import ChatProgramm.controller.commands.CommandConnect;
|
||||||
import ChatProgramm.controller.commands.CommandInvoker;
|
import ChatProgramm.controller.commands.CommandInvoker;
|
||||||
import ChatProgramm.controller.commands.CommandSend;
|
import ChatProgramm.controller.commands.CommandSend;
|
||||||
|
import ChatProgramm.model.GrafikModel;
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
|
import ChatProgramm.view.GrafikView;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -20,11 +22,17 @@ import java.awt.event.ActionListener;
|
|||||||
public class CommandController implements ActionListener{
|
public class CommandController implements ActionListener{
|
||||||
|
|
||||||
private ChatView view;
|
private ChatView view;
|
||||||
|
private GrafikModel model;
|
||||||
|
private GrafikView gView;
|
||||||
private CommandInvoker invoker;
|
private CommandInvoker invoker;
|
||||||
|
private GrafikController controller;
|
||||||
|
|
||||||
public CommandController(ChatView view){
|
public CommandController(ChatView view, GrafikModel model, GrafikController controller, GrafikView gView){
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
|
this.gView = gView;
|
||||||
this.invoker = new CommandInvoker();
|
this.invoker = new CommandInvoker();
|
||||||
|
this.controller = controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEvents(){
|
public void registerEvents(){
|
||||||
@@ -34,9 +42,9 @@ public class CommandController implements ActionListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommands(){
|
public void registerCommands(){
|
||||||
CommandSend commandSend = new CommandSend(view);
|
CommandSend commandSend = new CommandSend(view.getGvZeichenflaeche(), model);
|
||||||
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view, commandSend));
|
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view, commandSend, model, gView));
|
||||||
//invoker.addCommand(view.getTfNachricht(), commandSend);
|
this.controller.setCommand(commandSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,11 +55,11 @@ public class CommandController implements ActionListener{
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Component key = (Component)e.getSource();
|
Component key = (Component)e.getSource();
|
||||||
invoker.executeCommand(key);
|
invoker.executeCommand(key);
|
||||||
// if(key == view.getBtnOpen()|| key==view.getMiOpen())
|
|
||||||
// invoker.deleteStack();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,11 @@
|
|||||||
package ChatProgramm.controller.commands;
|
package ChatProgramm.controller.commands;
|
||||||
|
|
||||||
import ChatProgramm.model.Client;
|
import ChatProgramm.model.Client;
|
||||||
|
import ChatProgramm.model.GrafikModel;
|
||||||
import ChatProgramm.model.Server;
|
import ChatProgramm.model.Server;
|
||||||
import ChatProgramm.util.OhmLogger;
|
import ChatProgramm.util.OhmLogger;
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
|
import ChatProgramm.view.GrafikView;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
@@ -20,24 +22,29 @@ import javax.swing.JRadioButton;
|
|||||||
*/
|
*/
|
||||||
public class CommandConnect implements CommandInterface
|
public class CommandConnect implements CommandInterface
|
||||||
{
|
{
|
||||||
private JRadioButton rBtnServer;
|
private JRadioButton rBtnServer;
|
||||||
private JRadioButton rBtnClient;
|
private JRadioButton rBtnClient;
|
||||||
private JDialog dialogFenster;
|
private JDialog dialogFenster;
|
||||||
private static Logger lg = OhmLogger.getLogger();
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
private CommandSend commandSend;
|
private CommandSend commandSend;
|
||||||
private ChatView view;
|
private ChatView view;
|
||||||
|
private GrafikModel model;
|
||||||
|
private GrafikView gView;
|
||||||
|
|
||||||
public CommandConnect(ChatView view, CommandInterface value)
|
public CommandConnect(ChatView view, CommandInterface value, GrafikModel model, GrafikView gView)
|
||||||
{
|
{
|
||||||
rBtnServer = view.getBtnServer();
|
rBtnServer = view.getBtnServer();
|
||||||
rBtnClient = view.getBtnClient();
|
rBtnClient = view.getBtnClient();
|
||||||
dialogFenster = view.getjDialog1();
|
dialogFenster = view.getjDialog1();
|
||||||
|
|
||||||
commandSend = (CommandSend) value;
|
commandSend = (CommandSend) value;
|
||||||
|
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
|
this.gView = gView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,13 +6,15 @@
|
|||||||
package ChatProgramm.controller.commands;
|
package ChatProgramm.controller.commands;
|
||||||
|
|
||||||
import ChatProgramm.model.Client;
|
import ChatProgramm.model.Client;
|
||||||
|
import ChatProgramm.model.Figur;
|
||||||
|
import ChatProgramm.model.GrafikModel;
|
||||||
import ChatProgramm.model.Server;
|
import ChatProgramm.model.Server;
|
||||||
import ChatProgramm.model.TransmitterInterface;
|
import ChatProgramm.model.TransmitterInterface;
|
||||||
import ChatProgramm.util.OhmLogger;
|
import ChatProgramm.util.OhmLogger;
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import ChatProgramm.model.Nachricht;
|
import ChatProgramm.view.GrafikView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -23,17 +25,16 @@ public class CommandSend implements CommandInterface
|
|||||||
private static Logger lg = OhmLogger.getLogger();
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
private JTextField eingabeFeld;
|
private JTextField eingabeFeld;
|
||||||
private String nachricht;
|
private String nachricht;
|
||||||
private ChatView view;
|
private GrafikView view;
|
||||||
|
private GrafikModel model;
|
||||||
public TransmitterInterface transmitterInterface;
|
public TransmitterInterface transmitterInterface;
|
||||||
public Server server;
|
public Server server;
|
||||||
public Client client;
|
public Client client;
|
||||||
|
|
||||||
|
public CommandSend(GrafikView view, GrafikModel model)
|
||||||
|
|
||||||
|
|
||||||
public CommandSend(ChatView view)
|
|
||||||
{
|
{
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
//ToDo: Hier muss auch der gFrame referenziert werden
|
//ToDo: Hier muss auch der gFrame referenziert werden
|
||||||
//this.eingabeFeld = view.getTfNachricht();
|
//this.eingabeFeld = view.getTfNachricht();
|
||||||
transmitterInterface = null;
|
transmitterInterface = null;
|
||||||
@@ -42,6 +43,14 @@ public class CommandSend implements CommandInterface
|
|||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
{
|
{
|
||||||
|
lg.info("wir sind drin");
|
||||||
|
Figur aktuelleFigur = model.getFiguren().getLast();
|
||||||
|
if(transmitterInterface != null){
|
||||||
|
transmitterInterface.send(aktuelleFigur);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lg.info("Der Transmitter ist immernoch null");
|
||||||
|
}
|
||||||
//ToDo in dieser methode muss die Figur serialisiert werden und zum
|
//ToDo in dieser methode muss die Figur serialisiert werden und zum
|
||||||
//übermitteln bereitgestellt werden
|
//übermitteln bereitgestellt werden
|
||||||
|
|
||||||
@@ -62,4 +71,15 @@ public class CommandSend implements CommandInterface
|
|||||||
public void undo()
|
public void undo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
void setTransmitter(TransmitterInterface transmitter) {
|
||||||
|
lg.info("Transmitter wird gesetzt");
|
||||||
|
if(transmitter != null){
|
||||||
|
this.transmitterInterface = transmitter;
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lg.info("der transmitter kommt hier als null an");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -96,6 +96,11 @@ public class GrafikModel
|
|||||||
figuren.add(aktuelleFigur);
|
figuren.add(aktuelleFigur);
|
||||||
aktuelleFigur = new Figur();
|
aktuelleFigur = new Figur();
|
||||||
}
|
}
|
||||||
|
public void setFigur(Figur figur){
|
||||||
|
aktuelleFigur = figur;
|
||||||
|
figuren.add(figur);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bestimmt die Adresse des zuletzt besuchten Ordners
|
* Bestimmt die Adresse des zuletzt besuchten Ordners
|
||||||
|
|||||||
@@ -4,21 +4,33 @@
|
|||||||
*/
|
*/
|
||||||
package ChatProgramm.model;
|
package ChatProgramm.model;
|
||||||
|
|
||||||
|
import ChatProgramm.util.OhmLogger;
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
|
import ChatProgramm.view.GrafikView;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
import java.util.concurrent.Flow.Subscriber;
|
import java.util.concurrent.Flow.Subscriber;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ahren
|
* @author ahren
|
||||||
*/
|
*/
|
||||||
public class ReceiveAdapter implements Subscriber<Nachricht> {
|
public class ReceiveAdapter implements Subscriber<Figur> {
|
||||||
|
|
||||||
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
|
|
||||||
private ChatView view;
|
private ChatView view;
|
||||||
|
private GrafikModel model;
|
||||||
|
private GrafikView gView;
|
||||||
private Flow.Subscription subscription;
|
private Flow.Subscription subscription;
|
||||||
|
|
||||||
public ReceiveAdapter(ChatView view) {
|
public ReceiveAdapter(ChatView view, GrafikModel model, GrafikView gView) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
|
this.gView = gView;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -27,10 +39,11 @@ public class ReceiveAdapter implements Subscriber<Nachricht> {
|
|||||||
this.subscription.request(1);
|
this.subscription.request(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void onNext(Figur item) {
|
||||||
public void onNext(Nachricht item) {
|
|
||||||
|
|
||||||
//ToDo: hier muss der gFrame aufgerufen werden
|
lg.info("Figur wurde dem Grafikmodel hinzugefügt");
|
||||||
|
model.setFigur(item);
|
||||||
|
gView.drawFigur();
|
||||||
// evtl muss die Figur aber zuerst serialisiert werden
|
// evtl muss die Figur aber zuerst serialisiert werden
|
||||||
//view.getTxtChat().append(item.getNachricht());
|
//view.getTxtChat().append(item.getNachricht());
|
||||||
this.subscription.request(1);
|
this.subscription.request(1);
|
||||||
@@ -43,4 +56,5 @@ public class ReceiveAdapter implements Subscriber<Nachricht> {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete(){
|
public void onComplete(){
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
@@ -5,10 +5,15 @@
|
|||||||
package ChatProgramm.model;
|
package ChatProgramm.model;
|
||||||
|
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
|
import ChatProgramm.view.GrafikView;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -34,32 +39,35 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
|
|||||||
private static Logger lg = Logger.getLogger("netz");
|
private static Logger lg = Logger.getLogger("netz");
|
||||||
|
|
||||||
protected Socket socket;
|
protected Socket socket;
|
||||||
protected BufferedReader reader;
|
protected ObjectInputStream reader;
|
||||||
protected PrintWriter writer;
|
protected ObjectOutputStream writer;
|
||||||
|
|
||||||
private Nachricht nachricht;
|
private Figur figur;
|
||||||
private String txtNachricht;
|
private String txtNachricht;
|
||||||
private boolean laufend;
|
private boolean laufend;
|
||||||
private SubmissionPublisher<Nachricht> textPublisher;
|
private SubmissionPublisher<Figur> figurPublisher;
|
||||||
private ExecutorService eService;
|
private ExecutorService eService;
|
||||||
private String receivedString;
|
private String receivedString;
|
||||||
private ChatView view;
|
private ChatView view;
|
||||||
|
private GrafikView gView;
|
||||||
|
private GrafikModel model;
|
||||||
|
|
||||||
private ReceiveAdapter receiveAdapter;
|
private ReceiveAdapter receiveAdapter;
|
||||||
|
|
||||||
public Transmitter(ChatView view)
|
public Transmitter(ChatView view)
|
||||||
{
|
{
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
eService = null;
|
eService = null;
|
||||||
receiveAdapter = new ReceiveAdapter(view);
|
receiveAdapter = new ReceiveAdapter(view, model, gView);
|
||||||
textPublisher = new SubmissionPublisher<>();
|
figurPublisher = new SubmissionPublisher<>();
|
||||||
this.view = view;
|
this.view = view;
|
||||||
addWertSubscription(receiveAdapter);
|
addWertSubscription(receiveAdapter);
|
||||||
nachricht = new Nachricht("");
|
figur = new Figur();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWertSubscription(Subscriber<Nachricht> subscriber)
|
public void addWertSubscription(Subscriber<Figur> subscriber)
|
||||||
{
|
{
|
||||||
textPublisher.subscribe(subscriber);
|
figurPublisher.subscribe(subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void connect() throws IOException;
|
public abstract void connect() throws IOException;
|
||||||
@@ -69,12 +77,11 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
|
|||||||
lg.info("Initialisiere reader und writer");
|
lg.info("Initialisiere reader und writer");
|
||||||
InputStream is = socket.getInputStream();
|
InputStream is = socket.getInputStream();
|
||||||
OutputStream os = socket.getOutputStream();
|
OutputStream os = socket.getOutputStream();
|
||||||
|
|
||||||
|
writer = new ObjectOutputStream(os);
|
||||||
|
writer.flush();
|
||||||
|
reader = new ObjectInputStream(is);
|
||||||
|
|
||||||
InputStreamReader isr = new InputStreamReader(is, "UTF-8");
|
|
||||||
OutputStreamWriter osr = new OutputStreamWriter(os, "UTF-8");
|
|
||||||
|
|
||||||
reader = new BufferedReader(isr);
|
|
||||||
writer = new PrintWriter(osr);
|
|
||||||
lg.info("Reader / Writer Initialisierung abgeschlossen");
|
lg.info("Reader / Writer Initialisierung abgeschlossen");
|
||||||
startempfangen();
|
startempfangen();
|
||||||
lg.info("Warte auf Nachricht");
|
lg.info("Warte auf Nachricht");
|
||||||
@@ -86,27 +93,42 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(String txtNachricht){
|
/**
|
||||||
|
*
|
||||||
writer.println(txtNachricht);
|
* @param figur
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void send(Figur figur){
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writer.writeObject(figur);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
lg.info("Nachricht gesendet");
|
lg.info("Nachricht gesendet");
|
||||||
nachricht.setNachricht("\nDu: " + txtNachricht);
|
figurPublisher.submit(figur);
|
||||||
textPublisher.submit(nachricht);
|
|
||||||
}
|
}
|
||||||
public Nachricht receive(){
|
public Figur receive(){
|
||||||
|
Object receivedObject;
|
||||||
try {
|
try {
|
||||||
txtNachricht = reader.readLine();
|
receivedObject = reader.readObject();
|
||||||
if(!txtNachricht.isEmpty()){
|
if(receivedObject instanceof Figur){
|
||||||
lg.info("Nachricht erhalten");
|
lg.info("Figur erhalten");
|
||||||
nachricht.setNachricht("\nEr / Sie: " + txtNachricht);
|
figur = (Figur) receivedObject;
|
||||||
return nachricht;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return nachricht;
|
catch (ClassNotFoundException ex)
|
||||||
|
{
|
||||||
|
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
return figur;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void disconnect (){
|
// public void disconnect (){
|
||||||
@@ -120,9 +142,9 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
|
|||||||
while (true) {
|
while (true) {
|
||||||
lg.info("Warte auf Nachricht");
|
lg.info("Warte auf Nachricht");
|
||||||
if(laufend) {
|
if(laufend) {
|
||||||
nachricht = receive();
|
figur = receive();
|
||||||
if(!nachricht.getNachricht().isEmpty()){
|
if(!figur.getPunkte().isEmpty()){
|
||||||
textPublisher.submit(nachricht);
|
figurPublisher.submit(figur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import ChatProgramm.model.Nachricht;
|
|||||||
*/
|
*/
|
||||||
public interface TransmitterInterface
|
public interface TransmitterInterface
|
||||||
{
|
{
|
||||||
public void send(String txtNachricht);
|
public void send(Figur figur);
|
||||||
public Nachricht receive();
|
public Figur receive();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -107,24 +107,15 @@
|
|||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
<Container class="ChatProgramm.view.GrafikView" name="gvZeichenflaeche">
|
||||||
<Constraints>
|
<Constraints>
|
||||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||||
<BorderConstraints direction="Center"/>
|
<BorderConstraints direction="Center"/>
|
||||||
</Constraint>
|
</Constraint>
|
||||||
</Constraints>
|
</Constraints>
|
||||||
|
|
||||||
<Layout>
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||||
<DimensionLayout dim="0">
|
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
|
||||||
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</DimensionLayout>
|
|
||||||
<DimensionLayout dim="1">
|
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
|
||||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</DimensionLayout>
|
|
||||||
</Layout>
|
</Layout>
|
||||||
</Container>
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ package ChatProgramm.view;
|
|||||||
public class ChatView extends javax.swing.JFrame
|
public class ChatView extends javax.swing.JFrame
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the gvZeichenflaeche
|
||||||
|
*/
|
||||||
|
public ChatProgramm.view.GrafikView getGvZeichenflaeche()
|
||||||
|
{
|
||||||
|
return gvZeichenflaeche;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form ChatView
|
* Creates new form ChatView
|
||||||
*/
|
*/
|
||||||
@@ -25,91 +33,88 @@ public class ChatView extends javax.swing.JFrame
|
|||||||
* regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
private void initComponents() {
|
private void initComponents()
|
||||||
|
{
|
||||||
|
|
||||||
dialogChooseMode = new javax.swing.JDialog();
|
dialogChooseMode = new javax.swing.JDialog();
|
||||||
lblMode = new javax.swing.JLabel();
|
lblMode = new javax.swing.JLabel();
|
||||||
BtnServer = new javax.swing.JRadioButton();
|
BtnServer = new javax.swing.JRadioButton();
|
||||||
BtnClient = new javax.swing.JRadioButton();
|
BtnClient = new javax.swing.JRadioButton();
|
||||||
jPanel1 = new javax.swing.JPanel();
|
jPanel1 = new javax.swing.JPanel();
|
||||||
BtnConnect = new javax.swing.JButton();
|
BtnConnect = new javax.swing.JButton();
|
||||||
BtnGrpMode = new javax.swing.ButtonGroup();
|
BtnGrpMode = new javax.swing.ButtonGroup();
|
||||||
jPanel2 = new javax.swing.JPanel();
|
gvZeichenflaeche = new ChatProgramm.view.GrafikView();
|
||||||
|
|
||||||
dialogChooseMode.setMinimumSize(new java.awt.Dimension(278, 208));
|
dialogChooseMode.setMinimumSize(new java.awt.Dimension(278, 208));
|
||||||
dialogChooseMode.getContentPane().setLayout(new java.awt.GridLayout(0, 1));
|
dialogChooseMode.getContentPane().setLayout(new java.awt.GridLayout(0, 1));
|
||||||
|
|
||||||
lblMode.setText(" Choose your mode:");
|
lblMode.setText(" Choose your mode:");
|
||||||
dialogChooseMode.getContentPane().add(lblMode);
|
dialogChooseMode.getContentPane().add(lblMode);
|
||||||
|
|
||||||
BtnGrpMode.add(BtnServer);
|
BtnGrpMode.add(BtnServer);
|
||||||
BtnServer.setText("Server");
|
BtnServer.setText("Server");
|
||||||
BtnServer.addActionListener(new java.awt.event.ActionListener() {
|
BtnServer.addActionListener(new java.awt.event.ActionListener()
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
{
|
||||||
BtnServerActionPerformed(evt);
|
public void actionPerformed(java.awt.event.ActionEvent evt)
|
||||||
}
|
{
|
||||||
});
|
BtnServerActionPerformed(evt);
|
||||||
dialogChooseMode.getContentPane().add(BtnServer);
|
}
|
||||||
|
});
|
||||||
|
dialogChooseMode.getContentPane().add(BtnServer);
|
||||||
|
|
||||||
BtnGrpMode.add(BtnClient);
|
BtnGrpMode.add(BtnClient);
|
||||||
BtnClient.setText("Client");
|
BtnClient.setText("Client");
|
||||||
BtnClient.addActionListener(new java.awt.event.ActionListener() {
|
BtnClient.addActionListener(new java.awt.event.ActionListener()
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
{
|
||||||
BtnClientActionPerformed(evt);
|
public void actionPerformed(java.awt.event.ActionEvent evt)
|
||||||
}
|
{
|
||||||
});
|
BtnClientActionPerformed(evt);
|
||||||
dialogChooseMode.getContentPane().add(BtnClient);
|
}
|
||||||
|
});
|
||||||
|
dialogChooseMode.getContentPane().add(BtnClient);
|
||||||
|
|
||||||
BtnConnect.setText("Connect");
|
BtnConnect.setText("Connect");
|
||||||
BtnConnect.addActionListener(new java.awt.event.ActionListener() {
|
BtnConnect.addActionListener(new java.awt.event.ActionListener()
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
{
|
||||||
BtnConnectActionPerformed(evt);
|
public void actionPerformed(java.awt.event.ActionEvent evt)
|
||||||
}
|
{
|
||||||
});
|
BtnConnectActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||||
jPanel1.setLayout(jPanel1Layout);
|
jPanel1.setLayout(jPanel1Layout);
|
||||||
jPanel1Layout.setHorizontalGroup(
|
jPanel1Layout.setHorizontalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap(65, Short.MAX_VALUE)
|
.addContainerGap(65, Short.MAX_VALUE)
|
||||||
.addComponent(BtnConnect)
|
.addComponent(BtnConnect)
|
||||||
.addContainerGap(76, Short.MAX_VALUE))
|
.addContainerGap(76, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
jPanel1Layout.setVerticalGroup(
|
jPanel1Layout.setVerticalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(BtnConnect)
|
.addComponent(BtnConnect)
|
||||||
.addContainerGap(57, Short.MAX_VALUE))
|
.addContainerGap(57, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
dialogChooseMode.getContentPane().add(jPanel1);
|
dialogChooseMode.getContentPane().add(jPanel1);
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||||
setMinimumSize(new java.awt.Dimension(568, 548));
|
setMinimumSize(new java.awt.Dimension(568, 548));
|
||||||
addWindowListener(new java.awt.event.WindowAdapter() {
|
addWindowListener(new java.awt.event.WindowAdapter()
|
||||||
public void windowOpened(java.awt.event.WindowEvent evt) {
|
{
|
||||||
formWindowOpened(evt);
|
public void windowOpened(java.awt.event.WindowEvent evt)
|
||||||
}
|
{
|
||||||
});
|
formWindowOpened(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
getContentPane().add(gvZeichenflaeche, java.awt.BorderLayout.CENTER);
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
pack();
|
||||||
jPanel2.setLayout(jPanel2Layout);
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
jPanel2Layout.setHorizontalGroup(
|
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGap(0, 400, Short.MAX_VALUE)
|
|
||||||
);
|
|
||||||
jPanel2Layout.setVerticalGroup(
|
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGap(0, 300, Short.MAX_VALUE)
|
|
||||||
);
|
|
||||||
|
|
||||||
getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
|
|
||||||
|
|
||||||
pack();
|
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
|
||||||
|
|
||||||
private void BtnClientActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_BtnClientActionPerformed
|
private void BtnClientActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_BtnClientActionPerformed
|
||||||
{//GEN-HEADEREND:event_BtnClientActionPerformed
|
{//GEN-HEADEREND:event_BtnClientActionPerformed
|
||||||
@@ -180,16 +185,16 @@ public class ChatView extends javax.swing.JFrame
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JRadioButton BtnClient;
|
private javax.swing.JRadioButton BtnClient;
|
||||||
private javax.swing.JButton BtnConnect;
|
private javax.swing.JButton BtnConnect;
|
||||||
private javax.swing.ButtonGroup BtnGrpMode;
|
private javax.swing.ButtonGroup BtnGrpMode;
|
||||||
private javax.swing.JRadioButton BtnServer;
|
private javax.swing.JRadioButton BtnServer;
|
||||||
private javax.swing.JDialog dialogChooseMode;
|
private javax.swing.JDialog dialogChooseMode;
|
||||||
private javax.swing.JPanel jPanel1;
|
private ChatProgramm.view.GrafikView gvZeichenflaeche;
|
||||||
private javax.swing.JPanel jPanel2;
|
private javax.swing.JPanel jPanel1;
|
||||||
private javax.swing.JLabel lblMode;
|
private javax.swing.JLabel lblMode;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the BtnClient
|
* @return the BtnClient
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
|
|
||||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
|
||||||
<NonVisualComponents>
|
|
||||||
<Component class="javax.swing.JFileChooser" name="FcFileChooser">
|
|
||||||
</Component>
|
|
||||||
</NonVisualComponents>
|
|
||||||
<Properties>
|
|
||||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
|
||||||
</Properties>
|
|
||||||
<SyntheticProperties>
|
|
||||||
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-100,0,0,2,28"/>
|
|
||||||
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
|
|
||||||
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
|
|
||||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
|
||||||
</SyntheticProperties>
|
|
||||||
<AuxValues>
|
|
||||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
|
||||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
|
||||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
|
||||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
|
||||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
|
||||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
|
||||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
|
||||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
|
||||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
|
||||||
</AuxValues>
|
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
|
||||||
<SubComponents>
|
|
||||||
<Container class="mvcgrafik.view.GrafikView" name="gZeichenflaeche">
|
|
||||||
<Constraints>
|
|
||||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
|
||||||
<BorderConstraints direction="Center"/>
|
|
||||||
</Constraint>
|
|
||||||
</Constraints>
|
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
|
||||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
|
||||||
</Layout>
|
|
||||||
</Container>
|
|
||||||
<Container class="javax.swing.JToolBar" name="jToolBar1">
|
|
||||||
<Properties>
|
|
||||||
<Property name="rollover" type="boolean" value="true"/>
|
|
||||||
</Properties>
|
|
||||||
<Constraints>
|
|
||||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
|
||||||
<BorderConstraints direction="First"/>
|
|
||||||
</Constraint>
|
|
||||||
</Constraints>
|
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
|
||||||
<SubComponents>
|
|
||||||
<Component class="javax.swing.JButton" name="btnFileOpen">
|
|
||||||
<Properties>
|
|
||||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
|
||||||
<Image iconType="3" name="/mvcgrafik/view/Open24.gif"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="toolTipText" type="java.lang.String" value="Open File"/>
|
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
|
||||||
</Properties>
|
|
||||||
</Component>
|
|
||||||
<Component class="javax.swing.JButton" name="btnFileSave">
|
|
||||||
<Properties>
|
|
||||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
|
||||||
<Image iconType="3" name="/mvcgrafik/view/Save24.gif"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="toolTipText" type="java.lang.String" value="Safe File"/>
|
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
|
||||||
</Properties>
|
|
||||||
</Component>
|
|
||||||
<Component class="javax.swing.JButton" name="btnPrint">
|
|
||||||
<Properties>
|
|
||||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
|
||||||
<Image iconType="3" name="/mvcgrafik/view/Print24.gif"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="toolTipText" type="java.lang.String" value="Print File"/>
|
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
|
||||||
</Properties>
|
|
||||||
</Component>
|
|
||||||
</SubComponents>
|
|
||||||
</Container>
|
|
||||||
</SubComponents>
|
|
||||||
</Form>
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
/*
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
|
|
||||||
*/
|
|
||||||
package ChatProgramm.view;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author le
|
|
||||||
*/
|
|
||||||
public class GrafikFrame extends javax.swing.JFrame
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the FcFileChooser
|
|
||||||
*/
|
|
||||||
public javax.swing.JFileChooser getFcFileChooser()
|
|
||||||
{
|
|
||||||
return FcFileChooser;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the btnFileOpen
|
|
||||||
*/
|
|
||||||
public javax.swing.JButton getBtnFileOpen()
|
|
||||||
{
|
|
||||||
return btnFileOpen;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the btnFileSave
|
|
||||||
*/
|
|
||||||
public javax.swing.JButton getBtnFileSave()
|
|
||||||
{
|
|
||||||
return btnFileSave;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return the gZeichenflaeche
|
|
||||||
*/
|
|
||||||
public mvcgrafik.view.GrafikView getgZeichenflaeche()
|
|
||||||
{
|
|
||||||
return gZeichenflaeche;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new form GrafikFrame
|
|
||||||
*/
|
|
||||||
public GrafikFrame()
|
|
||||||
{
|
|
||||||
initComponents();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called from within the constructor to initialize the form.
|
|
||||||
* WARNING: Do NOT modify this code. The content of this method is always
|
|
||||||
* regenerated by the Form Editor.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
||||||
private void initComponents() {
|
|
||||||
|
|
||||||
FcFileChooser = new javax.swing.JFileChooser();
|
|
||||||
gZeichenflaeche = new mvcgrafik.view.GrafikView();
|
|
||||||
jToolBar1 = new javax.swing.JToolBar();
|
|
||||||
btnFileOpen = new javax.swing.JButton();
|
|
||||||
btnFileSave = new javax.swing.JButton();
|
|
||||||
btnPrint = new javax.swing.JButton();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
||||||
getContentPane().add(gZeichenflaeche, java.awt.BorderLayout.CENTER);
|
|
||||||
|
|
||||||
jToolBar1.setRollover(true);
|
|
||||||
|
|
||||||
btnFileOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mvcgrafik/view/Open24.gif"))); // NOI18N
|
|
||||||
btnFileOpen.setToolTipText("Open File");
|
|
||||||
btnFileOpen.setFocusable(false);
|
|
||||||
btnFileOpen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
|
||||||
btnFileOpen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
|
||||||
jToolBar1.add(btnFileOpen);
|
|
||||||
|
|
||||||
btnFileSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mvcgrafik/view/Save24.gif"))); // NOI18N
|
|
||||||
btnFileSave.setToolTipText("Safe File");
|
|
||||||
btnFileSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
|
||||||
btnFileSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
|
||||||
jToolBar1.add(btnFileSave);
|
|
||||||
|
|
||||||
btnPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mvcgrafik/view/Print24.gif"))); // NOI18N
|
|
||||||
btnPrint.setToolTipText("Print File");
|
|
||||||
btnPrint.setFocusable(false);
|
|
||||||
btnPrint.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
|
||||||
btnPrint.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
|
||||||
jToolBar1.add(btnPrint);
|
|
||||||
|
|
||||||
getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START);
|
|
||||||
|
|
||||||
setSize(new java.awt.Dimension(540, 412));
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args the command line arguments
|
|
||||||
*/
|
|
||||||
public static void main(String args[])
|
|
||||||
{
|
|
||||||
/* Set the Nimbus look and feel */
|
|
||||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
|
||||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
|
||||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
|
||||||
*/
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
|
|
||||||
{
|
|
||||||
if ("Nimbus".equals(info.getName()))
|
|
||||||
{
|
|
||||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException ex)
|
|
||||||
{
|
|
||||||
java.util.logging.Logger.getLogger(GrafikFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
catch (InstantiationException ex)
|
|
||||||
{
|
|
||||||
java.util.logging.Logger.getLogger(GrafikFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
catch (IllegalAccessException ex)
|
|
||||||
{
|
|
||||||
java.util.logging.Logger.getLogger(GrafikFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
catch (javax.swing.UnsupportedLookAndFeelException ex)
|
|
||||||
{
|
|
||||||
java.util.logging.Logger.getLogger(GrafikFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
//</editor-fold>
|
|
||||||
//</editor-fold>
|
|
||||||
|
|
||||||
/* Create and display the form */
|
|
||||||
java.awt.EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
new GrafikFrame().setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
||||||
private javax.swing.JFileChooser FcFileChooser;
|
|
||||||
private javax.swing.JButton btnFileOpen;
|
|
||||||
private javax.swing.JButton btnFileSave;
|
|
||||||
private javax.swing.JButton btnPrint;
|
|
||||||
private mvcgrafik.view.GrafikView gZeichenflaeche;
|
|
||||||
private javax.swing.JToolBar jToolBar1;
|
|
||||||
// End of variables declaration//GEN-END:variables
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the btnPrint
|
|
||||||
*/
|
|
||||||
public javax.swing.JButton getBtnPrint() {
|
|
||||||
return btnPrint;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -58,14 +58,23 @@ public class GrafikView extends JComponent implements Printable
|
|||||||
* Zeichnet den aktuellen Pfad (solange die maus gedrückt gehalten wird)
|
* Zeichnet den aktuellen Pfad (solange die maus gedrückt gehalten wird)
|
||||||
* @param p -> Der aktuelle punkt als x-y-Koordinate
|
* @param p -> Der aktuelle punkt als x-y-Koordinate
|
||||||
*/
|
*/
|
||||||
public void drawPoint(Point p)
|
public void drawFigur()
|
||||||
|
{
|
||||||
|
Graphics2D g2 = (Graphics2D)this.getGraphics(); // gefährlich!
|
||||||
|
|
||||||
|
drawPath(model.getFiguren().getLast().getPunkte(),g2);
|
||||||
|
|
||||||
|
g2.dispose(); //SEEEEHHHHRRRR WICHTIG!!!!!!!
|
||||||
|
}
|
||||||
|
public void drawPoint()
|
||||||
{
|
{
|
||||||
Graphics2D g2 = (Graphics2D)this.getGraphics(); // gefährlich!
|
Graphics2D g2 = (Graphics2D)this.getGraphics(); // gefährlich!
|
||||||
|
|
||||||
drawPath(model.getPunkte(),g2);
|
drawPath(model.getPunkte(),g2);
|
||||||
|
|
||||||
g2.dispose(); //SEEEEHHHHRRRR WICHTIG!!!!!!!
|
g2.dispose(); //SEEEEHHHHRRRR WICHTIG!!!!!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user