Nur aufgeraumt, keine Funktionalen Aenderungen
This commit is contained in:
parent
0e71917727
commit
43de325d71
@ -37,8 +37,6 @@ public CommandController(ChatView view, GrafikModel model, GrafikController cont
|
|||||||
|
|
||||||
public void registerEvents(){
|
public void registerEvents(){
|
||||||
view.getBtnConnect().addActionListener(this);
|
view.getBtnConnect().addActionListener(this);
|
||||||
//ToDo: muss auf gFrame referenzieren
|
|
||||||
//view.getTfNachricht().addActionListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommands(){
|
public void registerCommands(){
|
||||||
|
@ -51,7 +51,6 @@ public class CommandConnect implements CommandInterface
|
|||||||
lg.info("Server ausgewählt");
|
lg.info("Server ausgewählt");
|
||||||
try {
|
try {
|
||||||
commandSend.setTransmitter(new Server(view, model, gView));
|
commandSend.setTransmitter(new Server(view, model, gView));
|
||||||
//commandSend.transmitterInterface = new Server(view);
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
lg.info("Die Verbindung zum Server ist Fehlgeschlagen");
|
lg.info("Die Verbindung zum Server ist Fehlgeschlagen");
|
||||||
}
|
}
|
||||||
@ -61,7 +60,6 @@ public class CommandConnect implements CommandInterface
|
|||||||
lg.info("Client ausgewählt");
|
lg.info("Client ausgewählt");
|
||||||
try {
|
try {
|
||||||
commandSend.setTransmitter(new Client(view, model, gView));
|
commandSend.setTransmitter(new Client(view, model, gView));
|
||||||
//commandSend.transmitterInterface = new Client(view);
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
lg.info("Die Verbindung zum Client ist Fehlgeschlagen");
|
lg.info("Die Verbindung zum Client ist Fehlgeschlagen");
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ 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;
|
import ChatProgramm.view.GrafikView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,10 +23,10 @@ import ChatProgramm.view.GrafikView;
|
|||||||
public class CommandSend implements CommandInterface
|
public class CommandSend implements CommandInterface
|
||||||
{
|
{
|
||||||
private static Logger lg = OhmLogger.getLogger();
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
private JTextField eingabeFeld;
|
|
||||||
private String nachricht;
|
|
||||||
private GrafikView view;
|
private GrafikView view;
|
||||||
private GrafikModel model;
|
private GrafikModel model;
|
||||||
|
|
||||||
public TransmitterInterface transmitterInterface;
|
public TransmitterInterface transmitterInterface;
|
||||||
public Server server;
|
public Server server;
|
||||||
public Client client;
|
public Client client;
|
||||||
@ -47,21 +46,16 @@ public class CommandSend implements CommandInterface
|
|||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
{
|
{
|
||||||
lg.info("wir sind drin");
|
|
||||||
Figur aktuelleFigur = model.getFiguren().getLast();
|
Figur aktuelleFigur = model.getFiguren().getLast();
|
||||||
if(transmitterInterface != null){
|
try
|
||||||
|
{
|
||||||
transmitterInterface.send(aktuelleFigur);
|
transmitterInterface.send(aktuelleFigur);
|
||||||
}
|
|
||||||
else{
|
|
||||||
lg.info("Der Transmitter ist immernoch null");
|
|
||||||
}
|
|
||||||
//ToDo in dieser methode muss die Figur serialisiert werden und zum
|
|
||||||
//übermitteln bereitgestellt werden
|
|
||||||
|
|
||||||
// if(transmitterInterface != null && !eingabeFeld.getText().isEmpty()){
|
}
|
||||||
// transmitterInterface.send(eingabeFeld.getText());
|
catch(Exception NullPointerExeption)
|
||||||
// eingabeFeld.setText("");
|
{
|
||||||
// }
|
lg.info("Der Transmitter ist null");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package ChatProgramm.model;
|
package ChatProgramm.model;
|
||||||
|
|
||||||
|
import ChatProgramm.util.OhmLogger;
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
import ChatProgramm.view.GrafikView;
|
import ChatProgramm.view.GrafikView;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -17,9 +18,9 @@ import java.util.logging.*;
|
|||||||
*/
|
*/
|
||||||
public class Client extends Transmitter {
|
public class Client extends Transmitter {
|
||||||
|
|
||||||
private static Logger lg = Logger.getLogger("netz");
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
private static final int PORT = 35000; //lt. iana port > 2¹⁵
|
private static final int PORT = 35000; //lt. iana port > 2¹⁵
|
||||||
private static final String IP = "127.0.0.1";
|
private static final String IP = "141.75.213.191";
|
||||||
|
|
||||||
|
|
||||||
public Client(ChatView view, GrafikModel model, GrafikView gView) throws IOException {
|
public Client(ChatView view, GrafikModel model, GrafikView gView) throws IOException {
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* 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
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ChatProgramm.model;
|
package ChatProgramm.model;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
@ -20,49 +19,42 @@ import java.util.List;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import ChatProgramm.util.OhmLogger;
|
import ChatProgramm.util.OhmLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author le
|
* @author le
|
||||||
*/
|
*/
|
||||||
public class GrafikModel
|
public class GrafikModel {
|
||||||
{
|
|
||||||
private Figur aktuelleFigur;
|
|
||||||
private ArrayList<Figur> figuren;
|
|
||||||
private Preferences pref;
|
|
||||||
private static Logger lg = OhmLogger.getLogger();
|
|
||||||
|
|
||||||
public GrafikModel()
|
private Figur aktuelleFigur;
|
||||||
{
|
private ArrayList<Figur> figuren;
|
||||||
aktuelleFigur = new Figur();
|
private Preferences pref;
|
||||||
figuren = new ArrayList<>();
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
}
|
|
||||||
|
|
||||||
public void addPoint(Point p)
|
public GrafikModel() {
|
||||||
{
|
aktuelleFigur = new Figur();
|
||||||
aktuelleFigur.addPoint(p);
|
figuren = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Point> getPunkte()
|
public void addPoint(Point p) {
|
||||||
{
|
aktuelleFigur.addPoint(p);
|
||||||
return aktuelleFigur.getPunkte();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public List<Figur> getFiguren(){
|
public void addFigure(Figur figur) {
|
||||||
return Collections.unmodifiableList(figuren);
|
figuren.add(figur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Point> getPunkte() {
|
||||||
|
return aktuelleFigur.getPunkte();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Figur> getFiguren() {
|
||||||
|
return Collections.unmodifiableList(figuren);
|
||||||
|
}
|
||||||
|
|
||||||
public void endShape() {
|
public void endShape() {
|
||||||
figuren.add(aktuelleFigur);
|
figuren.add(aktuelleFigur);
|
||||||
aktuelleFigur = new Figur();
|
aktuelleFigur = new Figur();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFigur(Figur figur){
|
|
||||||
//aktuelleFigur = figur;
|
|
||||||
figuren.add(figur);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author ahren
|
|
||||||
*/
|
|
||||||
public class Nachricht
|
|
||||||
{
|
|
||||||
private String nachricht;
|
|
||||||
|
|
||||||
public Nachricht(String nachricht)
|
|
||||||
{
|
|
||||||
this.nachricht = nachricht;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the nachricht
|
|
||||||
*/
|
|
||||||
public String getNachricht() {
|
|
||||||
return nachricht;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNachricht(String nachricht) {
|
|
||||||
this.nachricht = nachricht;
|
|
||||||
}
|
|
||||||
}
|
|
@ -39,12 +39,10 @@ public class ReceiveAdapter implements Subscriber<Figur> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onNext(Figur item) {
|
public void onNext(Figur item) {
|
||||||
|
model.addFigure(item);
|
||||||
|
gView.drawFigur();
|
||||||
|
|
||||||
lg.info("Figur wurde dem Grafikmodel hinzugefügt");
|
lg.info("Figur wurde dem Grafikmodel hinzugefügt");
|
||||||
model.setFigur(item);
|
|
||||||
gView.drawFigur();
|
|
||||||
// evtl muss die Figur aber zuerst serialisiert werden
|
|
||||||
//view.getTxtChat().append(item.getNachricht());
|
|
||||||
this.subscription.request(1);
|
this.subscription.request(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package ChatProgramm.model;
|
package ChatProgramm.model;
|
||||||
|
|
||||||
|
import ChatProgramm.util.OhmLogger;
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
import ChatProgramm.view.GrafikView;
|
import ChatProgramm.view.GrafikView;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -17,9 +18,14 @@ import java.util.logging.*;
|
|||||||
*/
|
*/
|
||||||
public class Server extends Transmitter
|
public class Server extends Transmitter
|
||||||
{
|
{
|
||||||
private static Logger lg = Logger.getLogger("netz");
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
private static final int PORT = 35000; //lt. iana port > 2¹⁵
|
private static final int PORT = 35000; //lt. iana port > 2¹⁵
|
||||||
|
|
||||||
|
public Server(ChatView view, GrafikModel model, GrafikView gView) throws IOException {
|
||||||
|
super(view, model, gView);
|
||||||
|
connect();
|
||||||
|
initIO();
|
||||||
|
}
|
||||||
|
|
||||||
public void connect() throws IOException
|
public void connect() throws IOException
|
||||||
{
|
{
|
||||||
@ -35,12 +41,5 @@ public class Server extends Transmitter
|
|||||||
{
|
{
|
||||||
lg.warning("Timeout"+"("+timeout/1000+"s)");
|
lg.warning("Timeout"+"("+timeout/1000+"s)");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public Server(ChatView view, GrafikModel model, GrafikView gView) throws IOException {
|
|
||||||
super(view, model, gView);
|
|
||||||
connect();
|
|
||||||
initIO();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,17 +76,12 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
|
|||||||
InputStream is = socket.getInputStream();
|
InputStream is = socket.getInputStream();
|
||||||
OutputStream os = socket.getOutputStream();
|
OutputStream os = socket.getOutputStream();
|
||||||
|
|
||||||
|
|
||||||
// Bruh im ernst mann muss zuerst den writer und dann den reader initialisieren
|
|
||||||
// andersrum ist das blockiert weil die Streams von hinten nach vorne gelesen werden
|
|
||||||
writer = new ObjectOutputStream(os);
|
writer = new ObjectOutputStream(os);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
|
||||||
reader = new ObjectInputStream(is);
|
reader = new ObjectInputStream(is);
|
||||||
|
|
||||||
lg.info("Reader / Writer Initialisierung abgeschlossen");
|
lg.info("Reader / Writer Initialisierung abgeschlossen");
|
||||||
startempfangen();
|
startempfangen();
|
||||||
lg.info("Warte auf Nachricht");
|
|
||||||
|
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} catch (UnsupportedEncodingException ex) {
|
||||||
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
@ -123,7 +118,6 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
|
|||||||
if (receivedObject instanceof Figur) {
|
if (receivedObject instanceof Figur) {
|
||||||
lg.info("Figur erhalten");
|
lg.info("Figur erhalten");
|
||||||
figur = (Figur) receivedObject;
|
figur = (Figur) receivedObject;
|
||||||
// Verarbeiten Sie die empfangene Figur
|
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
@ -135,11 +129,7 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
|
|||||||
return figur;
|
return figur;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void disconnect (){
|
|
||||||
// in.close();
|
|
||||||
// out.close();
|
|
||||||
// s.close();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package ChatProgramm.model;
|
package ChatProgramm.model;
|
||||||
|
|
||||||
import ChatProgramm.model.Nachricht;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ahren
|
* @author ahren
|
||||||
|
@ -30,7 +30,7 @@ import ChatProgramm.util.OhmLogger;
|
|||||||
*
|
*
|
||||||
* @author le
|
* @author le
|
||||||
*/
|
*/
|
||||||
public class GrafikView extends JComponent implements Printable
|
public class GrafikView extends JComponent
|
||||||
{
|
{
|
||||||
private static Logger lg = OhmLogger.getLogger();
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
private static Dimension EINS = new Dimension(1, 1); // Dimension ist eine Klasse die width udn height hält
|
private static Dimension EINS = new Dimension(1, 1); // Dimension ist eine Klasse die width udn height hält
|
||||||
@ -109,44 +109,4 @@ public class GrafikView extends JComponent implements Printable
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void doPrint()
|
|
||||||
{
|
|
||||||
HashPrintRequestAttributeSet printSet =
|
|
||||||
new HashPrintRequestAttributeSet();
|
|
||||||
printSet.add(DialogTypeSelection.NATIVE);
|
|
||||||
PrinterJob pj = PrinterJob.getPrinterJob();
|
|
||||||
pj.setPrintable(this);
|
|
||||||
//Dialog
|
|
||||||
if (pj.printDialog(printSet))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pj.print(printSet);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(this, ex.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int print(Graphics gp, PageFormat pf, int pageIndex) throws PrinterException
|
|
||||||
{
|
|
||||||
Graphics2D g2p = (Graphics2D)gp;
|
|
||||||
if (pageIndex == 0)
|
|
||||||
{
|
|
||||||
g2p.translate(pf.getImageableX(), pf.getImageableY());
|
|
||||||
g2p.scale(pf.getImageableWidth() / this.getWidth(),
|
|
||||||
pf.getImageableHeight() / this.getHeight());
|
|
||||||
super.print(g2p);
|
|
||||||
return Printable.PAGE_EXISTS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Printable.NO_SUCH_PAGE; // wichtig sonst Papiervernichtung
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user