Conflicts: src/wuerfelthreads/Start.java src/wuerfelthreads/view/WuerfelView.form src/wuerfelthreads/view/WuerfelView.javano_lib
@@ -47,8 +47,9 @@ public class CommandSend implements ActionListener | |||
if(src == view.getBtnSend()){ | |||
/* view get figures*/ | |||
msg = model.getFigures(); | |||
msg = model.getSendFigures(); | |||
model.sendMessage(msg); | |||
model.saveFigures(msg); | |||
view.getLblStatus().setText("Nachricht gesendet"); | |||
} | |||
} |
@@ -49,7 +49,7 @@ public class ReceiveAdapter implements Flow.Subscriber<List<Figure>> | |||
public void onNext(List<Figure> msg) | |||
{ | |||
view.getLblStatus().setText("Nachricht empfangen"); | |||
model.addList(msg); | |||
view.repaint(); | |||
subscription.request(1); | |||
} | |||
@@ -27,6 +27,7 @@ import java.util.logging.Logger; | |||
import java.io.IOException; | |||
import java.io.ObjectInputStream; | |||
import java.io.ObjectOutputStream; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
@@ -80,14 +81,13 @@ public class ChatModel implements Runnable | |||
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) | |||
{ | |||
lg.log(Level.SEVERE, null, ex); | |||
} | |||
lg.info("Nachricht empfangen: "); | |||
addList(msg); | |||
iPublisher.submit(msg);//wenn neue Nachricht | |||
} catch (IOException ex) { | |||
@@ -151,15 +151,16 @@ public class ChatModel implements Runnable | |||
public void sendMessage(List<Figure> msg) | |||
{ | |||
if(laufend){ | |||
lg.log(Level.INFO, "Sende Nachricht: "); | |||
lg.log(Level.INFO, "Sende Nachricht: " + String.valueOf(msg.size())); | |||
try | |||
{ | |||
objectOutput.writeObject(msg); | |||
//objectOutput.flush(); | |||
List<Figure> cloned_list = new ArrayList<Figure>(msg); | |||
objectOutput.writeObject(cloned_list); | |||
objectOutput.flush(); | |||
} | |||
catch (IOException ex) | |||
{ | |||
Logger.getLogger(ChatModel.class.getName()).log(Level.SEVERE, null, ex); | |||
Logger.getLogger(ChatModel.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
} | |||
else{ | |||
@@ -176,38 +177,18 @@ public class ChatModel implements Runnable | |||
{ | |||
return gdata.getFigures(); | |||
} | |||
public List<Figure> getSendFigures() | |||
{ | |||
return gdata.getSendFigures(); | |||
} | |||
public void addList(List<Figure> 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); | |||
} | |||
} |
@@ -7,6 +7,7 @@ | |||
package graphicChat.model; | |||
import java.awt.Point; | |||
import java.io.Serializable; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
@@ -15,7 +16,7 @@ import java.util.List; | |||
* | |||
* @author chris, hd | |||
*/ | |||
public class Figure | |||
public class Figure implements Serializable | |||
{ | |||
private ArrayList<Point> punkte; | |||
@@ -6,17 +6,11 @@ | |||
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.Collections; | |||
import java.util.List; | |||
import java.util.logging.Logger; | |||
/** | |||
* | |||
@@ -25,24 +19,44 @@ import java.util.List; | |||
public class GraphicData | |||
{ | |||
private ArrayList<Figure> figures; | |||
private ArrayList<Figure> send_figures; | |||
private static final Logger lg = OhmLogger.getLogger(); | |||
public GraphicData() | |||
{ | |||
figures = new ArrayList<>(); | |||
send_figures = new ArrayList<>(); | |||
} | |||
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() | |||
{ | |||
return Collections.unmodifiableList(figures); | |||
} | |||
public List<Figure> getSendFigures() | |||
{ | |||
return Collections.unmodifiableList(send_figures); | |||
} | |||
} |