Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75cdcf7202 |
@@ -25,17 +25,11 @@ public class Start
|
|||||||
ChatView view = new ChatView();
|
ChatView view = new ChatView();
|
||||||
GrafikView zeichenflaeche = view.getGvZeichenflaeche();
|
GrafikView zeichenflaeche = view.getGvZeichenflaeche();
|
||||||
zeichenflaeche.setModel(model);
|
zeichenflaeche.setModel(model);
|
||||||
|
|
||||||
GrafikController controller = new GrafikController(zeichenflaeche, model);
|
GrafikController controller = new GrafikController(zeichenflaeche, model);
|
||||||
controller.registerEvents();
|
controller.registerEvents();
|
||||||
|
|
||||||
CommandController controller_commands = new CommandController(view, model, controller, zeichenflaeche);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ 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(){
|
||||||
@@ -56,6 +58,8 @@ public CommandController(ChatView view, GrafikModel model, GrafikController cont
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,13 +44,14 @@ public class CommandConnect implements CommandInterface
|
|||||||
this.gView = gView;
|
this.gView = gView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
{
|
{
|
||||||
if(rBtnServer.isSelected()){
|
if(rBtnServer.isSelected()){
|
||||||
lg.info("Server ausgewählt");
|
lg.info("Server ausgewählt");
|
||||||
try {
|
try {
|
||||||
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");
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,7 @@ public class CommandConnect implements CommandInterface
|
|||||||
if(rBtnClient.isSelected()){
|
if(rBtnClient.isSelected()){
|
||||||
lg.info("Client ausgewählt");
|
lg.info("Client ausgewählt");
|
||||||
try {
|
try {
|
||||||
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");
|
||||||
|
|
||||||
|
|||||||
@@ -23,17 +23,14 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CommandSend(GrafikView view, GrafikModel model)
|
public CommandSend(GrafikView view, GrafikModel model)
|
||||||
{
|
{
|
||||||
this.view = view;
|
this.view = view;
|
||||||
@@ -46,16 +43,21 @@ 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();
|
||||||
try
|
if(transmitterInterface != null){
|
||||||
{
|
|
||||||
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()){
|
||||||
catch(Exception NullPointerExeption)
|
// transmitterInterface.send(eingabeFeld.getText());
|
||||||
{
|
// eingabeFeld.setText("");
|
||||||
lg.info("Der Transmitter ist null");
|
// }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +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 java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
@@ -18,13 +16,13 @@ import java.util.logging.*;
|
|||||||
*/
|
*/
|
||||||
public class Client extends Transmitter {
|
public class Client extends Transmitter {
|
||||||
|
|
||||||
private static Logger lg = OhmLogger.getLogger();
|
private static Logger lg = Logger.getLogger("netz");
|
||||||
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 = "127.0.0.1";
|
||||||
|
|
||||||
|
|
||||||
public Client(ChatView view, GrafikModel model, GrafikView gView) throws IOException {
|
public Client(ChatView view) throws IOException {
|
||||||
super(view, model, gView);
|
super(view);
|
||||||
connect();
|
connect();
|
||||||
initIO();
|
initIO();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* 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;
|
||||||
@@ -19,42 +20,107 @@ 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 Figur aktuelleFigur;
|
||||||
private ArrayList<Figur> figuren;
|
private ArrayList<Figur> figuren;
|
||||||
private Preferences pref;
|
private Preferences pref;
|
||||||
private static Logger lg = OhmLogger.getLogger();
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
|
|
||||||
public GrafikModel() {
|
public GrafikModel()
|
||||||
|
{
|
||||||
aktuelleFigur = new Figur();
|
aktuelleFigur = new Figur();
|
||||||
figuren = new ArrayList<>();
|
figuren = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPoint(Point p) {
|
public void addPoint(Point p)
|
||||||
|
{
|
||||||
aktuelleFigur.addPoint(p);
|
aktuelleFigur.addPoint(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFigure(Figur figur) {
|
public List<Point> getPunkte()
|
||||||
figuren.add(figur);
|
{
|
||||||
}
|
|
||||||
|
|
||||||
public List<Point> getPunkte() {
|
|
||||||
return aktuelleFigur.getPunkte();
|
return aktuelleFigur.getPunkte();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Figur> getFiguren() {
|
public List<Figur> getFiguren(){
|
||||||
return Collections.unmodifiableList(figuren);
|
return Collections.unmodifiableList(figuren);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persistenz via Serialisierung
|
||||||
|
* @param dateiname
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void speicherePunkte(String dateiname) throws FileNotFoundException, IOException
|
||||||
|
{
|
||||||
|
// an Preferences denken!!
|
||||||
|
FileOutputStream fos = new FileOutputStream(dateiname);
|
||||||
|
//wichtig Puffer -> Performance
|
||||||
|
BufferedOutputStream bos = new BufferedOutputStream(fos);
|
||||||
|
//Serialisierung
|
||||||
|
ObjectOutputStream oos = new ObjectOutputStream(bos);
|
||||||
|
oos.writeObject(figuren);
|
||||||
|
oos.flush(); // Puffer
|
||||||
|
oos.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void lesePunkte(String dateiname) throws FileNotFoundException, IOException, ClassNotFoundException
|
||||||
|
{
|
||||||
|
// an Preferences denken!!
|
||||||
|
FileInputStream fis = new FileInputStream(dateiname);
|
||||||
|
//wichtig Puffer -> Performance
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(fis);
|
||||||
|
//Serialisierung
|
||||||
|
ObjectInputStream ois = new ObjectInputStream(bis);
|
||||||
|
Object daten = ois.readObject(); // Achtung
|
||||||
|
// if (daten instanceof ArrayList)
|
||||||
|
// {
|
||||||
|
// punkte = (ArrayList<Point>)daten;
|
||||||
|
// }
|
||||||
|
//eleganter
|
||||||
|
if (daten instanceof ArrayList liste)
|
||||||
|
{
|
||||||
|
figuren = liste;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bestimmt die Adresse des zuletzt besuchten Ordners
|
||||||
|
* @return letzter Ordner
|
||||||
|
*/
|
||||||
|
public String getPref()
|
||||||
|
{
|
||||||
|
pref = Preferences.userNodeForPackage(getClass());
|
||||||
|
return pref.get("lastDirectory", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt die Preferenz zu dem zuletzt besuchten Ordner
|
||||||
|
* @param lastDirectory Bezeichner "lastDirectory"
|
||||||
|
* @param lastAdress Adresse des zuletzt besuchten Ordners
|
||||||
|
*/
|
||||||
|
public void putPref(String lastDirectory, String lastAdress)
|
||||||
|
{
|
||||||
|
pref.put(lastDirectory, lastAdress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import java.util.concurrent.Flow;
|
|||||||
import java.util.concurrent.Flow.Subscriber;
|
import java.util.concurrent.Flow.Subscriber;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ahren
|
* @author ahren
|
||||||
@@ -39,10 +40,12 @@ 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,9 +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 java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
@@ -18,14 +16,9 @@ import java.util.logging.*;
|
|||||||
*/
|
*/
|
||||||
public class Server extends Transmitter
|
public class Server extends Transmitter
|
||||||
{
|
{
|
||||||
private static Logger lg = OhmLogger.getLogger();
|
private static Logger lg = Logger.getLogger("netz");
|
||||||
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
|
||||||
{
|
{
|
||||||
@@ -41,5 +34,12 @@ public class Server extends Transmitter
|
|||||||
{
|
{
|
||||||
lg.warning("Timeout"+"("+timeout/1000+"s)");
|
lg.warning("Timeout"+"("+timeout/1000+"s)");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
public Server(ChatView view) throws IOException {
|
||||||
|
super(view);
|
||||||
|
connect();
|
||||||
|
initIO();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.logging.Logger;
|
|||||||
*
|
*
|
||||||
* @author ahren
|
* @author ahren
|
||||||
*/
|
*/
|
||||||
public abstract class Transmitter implements Runnable, Subscriber<Figur>, TransmitterInterface {
|
public abstract class Transmitter implements Runnable, Subscriber<String>, TransmitterInterface {
|
||||||
|
|
||||||
static final int timeout = 60000;
|
static final int timeout = 60000;
|
||||||
private static final int PORT = 35000;
|
private static final int PORT = 35000;
|
||||||
@@ -43,14 +43,18 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
|
|||||||
protected ObjectOutputStream writer;
|
protected ObjectOutputStream writer;
|
||||||
|
|
||||||
private Figur figur;
|
private Figur figur;
|
||||||
|
private String txtNachricht;
|
||||||
|
private boolean laufend;
|
||||||
private SubmissionPublisher<Figur> figurPublisher;
|
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 GrafikModel model;
|
||||||
|
|
||||||
private ReceiveAdapter receiveAdapter;
|
private ReceiveAdapter receiveAdapter;
|
||||||
|
|
||||||
public Transmitter(ChatView view, GrafikModel model, GrafikView gView)
|
public Transmitter(ChatView view)
|
||||||
{
|
{
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
eService = null;
|
eService = null;
|
||||||
@@ -80,6 +84,7 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
|
|||||||
|
|
||||||
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);
|
||||||
@@ -108,36 +113,44 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
|
|||||||
figurPublisher.submit(figur);
|
figurPublisher.submit(figur);
|
||||||
}
|
}
|
||||||
public Figur receive(){
|
public Figur receive(){
|
||||||
|
|
||||||
Object receivedObject;
|
Object receivedObject;
|
||||||
try {
|
try {
|
||||||
receivedObject = reader.readObject();
|
receivedObject = reader.readObject();
|
||||||
|
if(receivedObject instanceof Figur){
|
||||||
if (receivedObject instanceof Figur) {
|
|
||||||
lg.info("Figur erhalten");
|
lg.info("Figur erhalten");
|
||||||
figur = (Figur) receivedObject;
|
figur = (Figur) receivedObject;
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
} catch (IOException e) {
|
||||||
} catch (ClassNotFoundException ex) {
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException ex)
|
||||||
|
{
|
||||||
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return figur;
|
return figur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public void disconnect (){
|
||||||
|
// in.close();
|
||||||
|
// out.close();
|
||||||
|
// s.close();
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (true) {
|
while (true) {
|
||||||
lg.info("Warte auf Nachricht");
|
lg.info("Warte auf Nachricht");
|
||||||
|
if(laufend) {
|
||||||
figur = receive();
|
figur = receive();
|
||||||
if(!figur.getPunkte().isEmpty()){
|
if(!figur.getPunkte().isEmpty()){
|
||||||
figurPublisher.submit(figur);
|
figurPublisher.submit(figur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -147,7 +160,7 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(Figur item) {
|
public void onNext(String item) {
|
||||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +177,7 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
|
|||||||
private void startempfangen()
|
private void startempfangen()
|
||||||
{
|
{
|
||||||
synchronized (this){
|
synchronized (this){
|
||||||
|
laufend = true;
|
||||||
}
|
}
|
||||||
if (eService == null){
|
if (eService == null){
|
||||||
eService = Executors.newSingleThreadExecutor();
|
eService = Executors.newSingleThreadExecutor();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
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
|
public class GrafikView extends JComponent implements Printable
|
||||||
{
|
{
|
||||||
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
|
||||||
@@ -66,7 +66,6 @@ public class GrafikView extends JComponent
|
|||||||
|
|
||||||
g2.dispose(); //SEEEEHHHHRRRR WICHTIG!!!!!!!
|
g2.dispose(); //SEEEEHHHHRRRR WICHTIG!!!!!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawPoint()
|
public void drawPoint()
|
||||||
{
|
{
|
||||||
Graphics2D g2 = (Graphics2D)this.getGraphics(); // gefährlich!
|
Graphics2D g2 = (Graphics2D)this.getGraphics(); // gefährlich!
|
||||||
@@ -77,6 +76,7 @@ public class GrafikView extends JComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hier werden alle Pfade aus dem model neu gezeichnet
|
* Hier werden alle Pfade aus dem model neu gezeichnet
|
||||||
* Jedes mal wenn die Maus los gelassen wird, wird dder aktuelle Pfad gespeichert
|
* Jedes mal wenn die Maus los gelassen wird, wird dder aktuelle Pfad gespeichert
|
||||||
@@ -109,4 +109,44 @@ public class GrafikView extends JComponent
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
log.level=INFO
|
log.level=INFO
|
||||||
|
|
||||||
# log.directory=../Aufgabe7_bandit
|
log.directory=../Aufgabe7_bandit
|
||||||
# log.filename=ohmLog
|
log.filename=ohmLog
|
||||||
|
|
||||||
# Beispiel f\u00fcr verschiedene Level f\u00fcr unterschiedliche Pakete
|
# Beispiel f\u00fcr verschiedene Level f\u00fcr unterschiedliche Pakete
|
||||||
# log.level.bandit.Zahlengenerator=FINE
|
# log.level.bandit.Zahlengenerator=FINE
|
||||||
|
|||||||
Reference in New Issue
Block a user