Browse Source

Merge origin/master

Conflicts:
	src/wuerfelthreads/Start.java
	src/wuerfelthreads/view/WuerfelView.form
	src/wuerfelthreads/view/WuerfelView.java
no_lib
BakeOrDie 3 years ago
parent
commit
b71a6cf6b2

+ 2
- 1
src/graphicChat/controller/CommandSend.java View File

if(src == view.getBtnSend()){ if(src == view.getBtnSend()){
/* view get figures*/ /* view get figures*/
msg = model.getFigures();
msg = model.getSendFigures();
model.sendMessage(msg); model.sendMessage(msg);
model.saveFigures(msg);
view.getLblStatus().setText("Nachricht gesendet"); view.getLblStatus().setText("Nachricht gesendet");
} }
} }

+ 1
- 1
src/graphicChat/controller/ReceiveAdapter.java View File

public void onNext(List<Figure> msg) public void onNext(List<Figure> msg)
{ {
view.getLblStatus().setText("Nachricht empfangen"); view.getLblStatus().setText("Nachricht empfangen");
model.addList(msg);
view.repaint();
subscription.request(1); subscription.request(1);
} }



+ 17
- 36
src/graphicChat/model/ChatModel.java View File

import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;


/** /**
try { try {
try try
{ {
lg.info("test");
msg = (List<Figure>)objectInput.readObject();
msg = (List<Figure>)objectInput.readObject();
lg.info("Nachricht empfangen" + String.valueOf(msg.size()));
} }
catch (ClassNotFoundException ex) catch (ClassNotFoundException ex)
{ {
lg.log(Level.SEVERE, null, ex); lg.log(Level.SEVERE, null, ex);
} }
lg.info("Nachricht empfangen: ");
addList(msg); addList(msg);
iPublisher.submit(msg);//wenn neue Nachricht iPublisher.submit(msg);//wenn neue Nachricht
} catch (IOException ex) { } catch (IOException ex) {
public void sendMessage(List<Figure> msg) public void sendMessage(List<Figure> msg)
{ {
if(laufend){ if(laufend){
lg.log(Level.INFO, "Sende Nachricht: ");
lg.log(Level.INFO, "Sende Nachricht: " + String.valueOf(msg.size()));
try try
{ {
objectOutput.writeObject(msg);
//objectOutput.flush();
List<Figure> cloned_list = new ArrayList<Figure>(msg);
objectOutput.writeObject(cloned_list);
objectOutput.flush();
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.getLogger(ChatModel.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(ChatModel.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
else{ else{
{ {
return gdata.getFigures(); return gdata.getFigures();
} }
public List<Figure> getSendFigures()
{
return gdata.getSendFigures();
}
public void addList(List<Figure> list) public void addList(List<Figure> list)
{ {
gdata.addList(list); gdata.addList(list);
} }
// public void speichereDatei(String dateiname) throws FileNotFoundException, IOException
// {
// FileOutputStream fos = new FileOutputStream(dateiname);
// BufferedOutputStream buffout = new BufferedOutputStream(fos);
// ObjectOutputStream oos = new ObjectOutputStream(buffout);
// oos.writeObject(figures);
// oos.flush();
// oos.close();
//
// }
//
// public void ladeDatei(String dateiname) throws FileNotFoundException, IOException, ClassNotFoundException
// {
// FileInputStream fis = new FileInputStream(dateiname);
// BufferedInputStream buffin = new BufferedInputStream(fis);
// ObjectInputStream ois = new ObjectInputStream(buffin);
// Object obj = ois.readObject();
//// if (obj instanceof ArrayList)
//// {
//// punkte = (ArrayList<Point>) obj;
//// }
//// else
//// {
//// Fehler ....
//// }
// figures = (ArrayList<Figure>) ois.readObject();
// ois.close();
// }
public void saveFigures(List<Figure> list)
{
gdata.saveFigures(list);
}
} }

+ 2
- 1
src/graphicChat/model/Figure.java View File

package graphicChat.model; package graphicChat.model;


import java.awt.Point; import java.awt.Point;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
* *
* @author chris, hd * @author chris, hd
*/ */
public class Figure
public class Figure implements Serializable
{ {
private ArrayList<Point> punkte; private ArrayList<Point> punkte;

+ 27
- 13
src/graphicChat/model/GraphicData.java View File



package graphicChat.model; package graphicChat.model;


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import graphicChat.logger.OhmLogger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Logger;


/** /**
* *
public class GraphicData public class GraphicData
{ {
private ArrayList<Figure> figures; private ArrayList<Figure> figures;
private ArrayList<Figure> send_figures;
private static final Logger lg = OhmLogger.getLogger();
public GraphicData() public GraphicData()
{ {
figures = new ArrayList<>(); figures = new ArrayList<>();
send_figures = new ArrayList<>();
} }
public void addList(List<Figure> list) public void addList(List<Figure> list)
{ {
figures.addAll(list);
figures.addAll(list);
}
public void saveFigures(List<Figure> list)
{
figures.addAll(list);
send_figures.clear();
} }
public Figure addFigure()
// public Figure addFigure()
// {
// figures.add(new Figure());
// return figures.get(figures.size() - 1);
//
// }
public Figure addFigure()
{ {
figures.add(new Figure());
return figures.get(figures.size() - 1);
send_figures.add(new Figure());
return send_figures.get(send_figures.size() - 1);
} }



public List<Figure> getFigures() public List<Figure> getFigures()
{ {
return Collections.unmodifiableList(figures); return Collections.unmodifiableList(figures);
} }
public List<Figure> getSendFigures()
{
return Collections.unmodifiableList(send_figures);
}
} }

Loading…
Cancel
Save