Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ec7e6bc4c | ||
|
|
e8f0fd53d6 | ||
|
|
7ae10ac02f | ||
|
|
68eb43c715 | ||
|
|
541b497796 | ||
|
|
43de325d71 | ||
|
|
0e71917727 | ||
|
|
dc1f783e00 | ||
|
|
2fc05ae87f | ||
|
|
5117ecdb6f | ||
|
|
a4a45ed5f2 | ||
|
|
6642dc8179 | ||
|
|
f05b0f0014 | ||
|
|
1aa5b51e78 |
@@ -1067,15 +1067,6 @@ is divided into following sections:
|
|||||||
<propertyfile file="${built-jar.properties}">
|
<propertyfile file="${built-jar.properties}">
|
||||||
<entry key="${basedir}" value=""/>
|
<entry key="${basedir}" value=""/>
|
||||||
</propertyfile>
|
</propertyfile>
|
||||||
<antcall target="-maybe-call-dep">
|
|
||||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
|
||||||
<param location="${project.Aufgabe9_mvcGrafik}" name="call.subproject"/>
|
|
||||||
<param location="${project.Aufgabe9_mvcGrafik}/build.xml" name="call.script"/>
|
|
||||||
<param name="call.target" value="jar"/>
|
|
||||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
|
||||||
<param name="transfer.not.archive.disabled" value="true"/>
|
|
||||||
<param name="transfer.do.jlink" value="false"/>
|
|
||||||
</antcall>
|
|
||||||
</target>
|
</target>
|
||||||
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
||||||
<target depends="init" name="-check-automatic-build">
|
<target depends="init" name="-check-automatic-build">
|
||||||
@@ -1747,15 +1738,6 @@ is divided into following sections:
|
|||||||
<propertyfile file="${built-clean.properties}">
|
<propertyfile file="${built-clean.properties}">
|
||||||
<entry key="${basedir}" value=""/>
|
<entry key="${basedir}" value=""/>
|
||||||
</propertyfile>
|
</propertyfile>
|
||||||
<antcall target="-maybe-call-dep">
|
|
||||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
|
||||||
<param location="${project.Aufgabe9_mvcGrafik}" name="call.subproject"/>
|
|
||||||
<param location="${project.Aufgabe9_mvcGrafik}/build.xml" name="call.script"/>
|
|
||||||
<param name="call.target" value="clean"/>
|
|
||||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
|
||||||
<param name="transfer.not.archive.disabled" value="true"/>
|
|
||||||
<param name="transfer.do.jlink" value="false"/>
|
|
||||||
</antcall>
|
|
||||||
</target>
|
</target>
|
||||||
<target depends="init" name="-do-clean">
|
<target depends="init" name="-do-clean">
|
||||||
<delete dir="${build.dir}"/>
|
<delete dir="${build.dir}"/>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
build.xml.data.CRC32=d624b1fd
|
build.xml.data.CRC32=126b3ece
|
||||||
build.xml.script.CRC32=1a88b66a
|
build.xml.script.CRC32=1a88b66a
|
||||||
build.xml.stylesheet.CRC32=f85dc8f2@1.108.0.48
|
build.xml.stylesheet.CRC32=f85dc8f2@1.108.0.48
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
nbproject/build-impl.xml.data.CRC32=d624b1fd
|
nbproject/build-impl.xml.data.CRC32=126b3ece
|
||||||
nbproject/build-impl.xml.script.CRC32=476a1ac9
|
nbproject/build-impl.xml.script.CRC32=fdc076e6
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.108.0.48
|
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.108.0.48
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ endorsed.classpath=
|
|||||||
excludes=
|
excludes=
|
||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
javac.classpath=\
|
javac.classpath=
|
||||||
${reference.Aufgabe9_mvcGrafik.jar}
|
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
@@ -79,8 +78,6 @@ manifest.file=manifest.mf
|
|||||||
meta.inf.dir=${src.dir}/META-INF
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
mkdist.disabled=false
|
mkdist.disabled=false
|
||||||
platform.active=default_platform
|
platform.active=default_platform
|
||||||
project.Aufgabe9_mvcGrafik=../../T9_mvcGrafik/Aufgabe9_mvcGrafik
|
|
||||||
reference.Aufgabe9_mvcGrafik.jar=${project.Aufgabe9_mvcGrafik}/dist/Aufgabe9_mvcGrafik.jar
|
|
||||||
run.classpath=\
|
run.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}
|
${build.classes.dir}
|
||||||
|
|||||||
+1
-10
@@ -11,15 +11,6 @@
|
|||||||
<root id="test.src.dir"/>
|
<root id="test.src.dir"/>
|
||||||
</test-roots>
|
</test-roots>
|
||||||
</data>
|
</data>
|
||||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1"/>
|
||||||
<reference>
|
|
||||||
<foreign-project>Aufgabe9_mvcGrafik</foreign-project>
|
|
||||||
<artifact-type>jar</artifact-type>
|
|
||||||
<script>build.xml</script>
|
|
||||||
<target>jar</target>
|
|
||||||
<clean-target>clean</clean-target>
|
|
||||||
<id>jar</id>
|
|
||||||
</reference>
|
|
||||||
</references>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -6,10 +6,8 @@
|
|||||||
package ChatProgramm;
|
package ChatProgramm;
|
||||||
|
|
||||||
import ChatProgramm.controller.CommandController;
|
import ChatProgramm.controller.CommandController;
|
||||||
import ChatProgramm.controller.GrafikController;
|
import ChatProgramm.model.ChatModel;
|
||||||
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;
|
||||||
|
|
||||||
@@ -21,13 +19,10 @@ public class Start
|
|||||||
{
|
{
|
||||||
public Start()
|
public Start()
|
||||||
{
|
{
|
||||||
GrafikModel model = new GrafikModel();
|
|
||||||
ChatView view = new ChatView();
|
ChatView view = new ChatView();
|
||||||
GrafikView zeichenflaeche = view.getGvZeichenflaeche();
|
ChatModel model = new ChatModel(view);
|
||||||
zeichenflaeche.setModel(model);
|
view.getGvZeichenflaeche().setModel(model.getGrafikDaten());
|
||||||
GrafikController controller = new GrafikController(zeichenflaeche, model);
|
CommandController controller_commands = new CommandController(view, model);
|
||||||
controller.registerEvents();
|
|
||||||
CommandController controller_commands = new CommandController(view);
|
|
||||||
controller_commands.registerEvents();
|
controller_commands.registerEvents();
|
||||||
controller_commands.registerCommands();
|
controller_commands.registerCommands();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
|
|||||||
@@ -8,35 +8,43 @@ 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.ChatModel;
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.Point;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import static java.awt.event.MouseEvent.MOUSE_RELEASED;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ahren
|
* @author ahren
|
||||||
*/
|
*/
|
||||||
public class CommandController implements ActionListener{
|
public class CommandController extends MouseAdapter implements MouseMotionListener, ActionListener{
|
||||||
|
|
||||||
private ChatView view;
|
private ChatView view;
|
||||||
|
private ChatModel model;
|
||||||
private CommandInvoker invoker;
|
private CommandInvoker invoker;
|
||||||
|
|
||||||
public CommandController(ChatView view){
|
public CommandController(ChatView view, ChatModel model){
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
this.invoker = new CommandInvoker();
|
this.invoker = new CommandInvoker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEvents(){
|
public void registerEvents(){
|
||||||
view.getBtnConnect().addActionListener(this);
|
view.getBtnConnect().addActionListener(this);
|
||||||
//ToDo: muss auf gFrame referenzieren
|
view.addMouseMotionListener(this);
|
||||||
//view.getTfNachricht().addActionListener(this);
|
view.addMouseListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommands(){
|
public void registerCommands(){
|
||||||
CommandSend commandSend = new CommandSend(view.getGvZeichenflaeche());
|
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view, model));
|
||||||
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view, commandSend));
|
|
||||||
//invoker.addCommand(view.getTfNachricht(), commandSend);
|
invoker.addCommand(view.getGvZeichenflaeche(), new CommandSend(view, model));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,9 +55,21 @@ 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();
|
}
|
||||||
// }
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent evt)
|
||||||
|
{
|
||||||
|
Point p = evt.getPoint();
|
||||||
|
model.getGrafikDaten().addPoint(p);
|
||||||
|
view.getGvZeichenflaeche().drawPoint();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent evt)
|
||||||
|
{
|
||||||
|
model.getGrafikDaten().endShape();
|
||||||
|
invoker.executeCommand(view.getGvZeichenflaeche());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +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.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 = new CommandSend(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerEvents()
|
|
||||||
{
|
|
||||||
view.addMouseMotionListener(this);
|
|
||||||
view.addMouseListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDragged(MouseEvent evt)
|
|
||||||
{
|
|
||||||
Point p = evt.getPoint();
|
|
||||||
model.addPoint(p);
|
|
||||||
view.drawPoint(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent evt)
|
|
||||||
{
|
|
||||||
model.endShape();
|
|
||||||
commandSend.execute();
|
|
||||||
// if (evt.getButton() == MouseEvent.BUTTON3)
|
|
||||||
// {
|
|
||||||
// view.doPrint();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,10 +5,14 @@
|
|||||||
|
|
||||||
package ChatProgramm.controller.commands;
|
package ChatProgramm.controller.commands;
|
||||||
|
|
||||||
|
import ChatProgramm.model.ChatModel;
|
||||||
import ChatProgramm.model.Client;
|
import ChatProgramm.model.Client;
|
||||||
|
import ChatProgramm.model.GrafikDaten;
|
||||||
import ChatProgramm.model.Server;
|
import ChatProgramm.model.Server;
|
||||||
|
import ChatProgramm.model.Transmitter;
|
||||||
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;
|
||||||
@@ -24,18 +28,16 @@ public class CommandConnect implements CommandInterface
|
|||||||
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 ChatView view;
|
private ChatView view;
|
||||||
|
private ChatModel model;
|
||||||
|
|
||||||
public CommandConnect(ChatView view, CommandInterface value)
|
public CommandConnect(ChatView view, ChatModel model)
|
||||||
{
|
{
|
||||||
rBtnServer = view.getBtnServer();
|
rBtnServer = view.getBtnServer();
|
||||||
rBtnClient = view.getBtnClient();
|
rBtnClient = view.getBtnClient();
|
||||||
dialogFenster = view.getjDialog1();
|
dialogFenster = view.getjDialog1();
|
||||||
|
|
||||||
commandSend = (CommandSend) value;
|
|
||||||
|
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -44,7 +46,7 @@ public class CommandConnect implements CommandInterface
|
|||||||
if(rBtnServer.isSelected()){
|
if(rBtnServer.isSelected()){
|
||||||
lg.info("Server ausgewählt");
|
lg.info("Server ausgewählt");
|
||||||
try {
|
try {
|
||||||
commandSend.transmitterInterface = new Server(view);
|
model.setTransmitterToServer();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
lg.info("Die Verbindung zum Server ist Fehlgeschlagen");
|
lg.info("Die Verbindung zum Server ist Fehlgeschlagen");
|
||||||
}
|
}
|
||||||
@@ -53,13 +55,12 @@ public class CommandConnect implements CommandInterface
|
|||||||
if(rBtnClient.isSelected()){
|
if(rBtnClient.isSelected()){
|
||||||
lg.info("Client ausgewählt");
|
lg.info("Client ausgewählt");
|
||||||
try {
|
try {
|
||||||
commandSend.transmitterInterface = new Client(view);
|
model.setTransmitterToClient();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
lg.info("Die Verbindung zum Client ist Fehlgeschlagen");
|
lg.info("Die Verbindung zum Client ist Fehlgeschlagen");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogFenster.setVisible(false);
|
dialogFenster.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,11 @@
|
|||||||
|
|
||||||
package ChatProgramm.controller.commands;
|
package ChatProgramm.controller.commands;
|
||||||
|
|
||||||
import ChatProgramm.model.Client;
|
import ChatProgramm.model.ChatModel;
|
||||||
import ChatProgramm.model.Server;
|
import ChatProgramm.model.Figur;
|
||||||
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 ChatProgramm.model.Nachricht;
|
|
||||||
import ChatProgramm.view.GrafikView;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -22,37 +18,29 @@ 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;
|
|
||||||
public TransmitterInterface transmitterInterface;
|
|
||||||
public Server server;
|
|
||||||
public Client client;
|
|
||||||
|
|
||||||
|
private ChatView view;
|
||||||
|
private ChatModel model;
|
||||||
|
|
||||||
|
public CommandSend(ChatView view, ChatModel model)
|
||||||
|
|
||||||
public CommandSend(GrafikView view)
|
|
||||||
{
|
{
|
||||||
this.view = view;
|
this.view = view;
|
||||||
//ToDo: Hier muss auch der gFrame referenziert werden
|
this.model = model;
|
||||||
//this.eingabeFeld = view.getTfNachricht();
|
|
||||||
transmitterInterface = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
{
|
{
|
||||||
lg.info("wir sind drin");
|
Figur aktuelleFigur = model.getGrafikDaten().getFiguren().getLast();
|
||||||
//ToDo in dieser methode muss die Figur serialisiert werden und zum
|
try
|
||||||
//übermitteln bereitgestellt werden
|
{
|
||||||
|
model.getTransmitter().send(aktuelleFigur);
|
||||||
// if(transmitterInterface != null && !eingabeFeld.getText().isEmpty()){
|
}
|
||||||
// transmitterInterface.send(eingabeFeld.getText());
|
catch(Exception NullPointerExeption)
|
||||||
// eingabeFeld.setText("");
|
{
|
||||||
// }
|
lg.info("Der Transmitter ist null");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUndoable()
|
public boolean isUndoable()
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import ChatProgramm.util.OhmLogger;
|
||||||
|
import ChatProgramm.view.ChatView;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author ahren
|
||||||
|
*/
|
||||||
|
public class ChatModel
|
||||||
|
{
|
||||||
|
|
||||||
|
private Transmitter transmitter;
|
||||||
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
|
private GrafikDaten grafikdaten = new GrafikDaten();
|
||||||
|
private ChatView view;
|
||||||
|
|
||||||
|
public ChatModel(ChatView view)
|
||||||
|
{
|
||||||
|
this.view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GrafikDaten getGrafikDaten()
|
||||||
|
{
|
||||||
|
return grafikdaten;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransmitterToClient() throws IOException
|
||||||
|
{
|
||||||
|
transmitter = new Client(view, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransmitterToServer()throws IOException
|
||||||
|
{
|
||||||
|
transmitter = new Server(view, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Transmitter getTransmitter()
|
||||||
|
{
|
||||||
|
return transmitter;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
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.*;
|
||||||
@@ -16,13 +18,13 @@ 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 = "127.0.0.1";
|
||||||
|
|
||||||
|
|
||||||
public Client(ChatView view) throws IOException {
|
public Client(ChatView view, ChatModel model) throws IOException {
|
||||||
super(view);
|
super(view, model);
|
||||||
connect();
|
connect();
|
||||||
initIO();
|
initIO();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
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 java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
|
import ChatProgramm.util.OhmLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author le
|
||||||
|
*/
|
||||||
|
public class GrafikDaten {
|
||||||
|
|
||||||
|
private Figur aktuelleFigur;
|
||||||
|
private ArrayList<Figur> figuren;
|
||||||
|
private Preferences pref;
|
||||||
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
|
|
||||||
|
public GrafikDaten() {
|
||||||
|
aktuelleFigur = new Figur();
|
||||||
|
figuren = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPoint(Point p) {
|
||||||
|
aktuelleFigur.addPoint(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFigure(Figur figur) {
|
||||||
|
figuren.add(figur);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Point> getPunkte() {
|
||||||
|
return aktuelleFigur.getPunkte();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Figur> getFiguren() {
|
||||||
|
return Collections.unmodifiableList(figuren);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endShape() {
|
||||||
|
figuren.add(aktuelleFigur);
|
||||||
|
aktuelleFigur = new Figur();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,121 +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;
|
|
||||||
|
|
||||||
import java.awt.Point;
|
|
||||||
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 java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.prefs.Preferences;
|
|
||||||
import ChatProgramm.util.OhmLogger;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author le
|
|
||||||
*/
|
|
||||||
public class GrafikModel
|
|
||||||
{
|
|
||||||
private Figur aktuelleFigur;
|
|
||||||
private ArrayList<Figur> figuren;
|
|
||||||
private Preferences pref;
|
|
||||||
private static Logger lg = OhmLogger.getLogger();
|
|
||||||
|
|
||||||
public GrafikModel()
|
|
||||||
{
|
|
||||||
aktuelleFigur = new Figur();
|
|
||||||
figuren = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPoint(Point p)
|
|
||||||
{
|
|
||||||
aktuelleFigur.addPoint(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Point> getPunkte()
|
|
||||||
{
|
|
||||||
return aktuelleFigur.getPunkte();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Figur> getFiguren(){
|
|
||||||
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() {
|
|
||||||
figuren.add(aktuelleFigur);
|
|
||||||
aktuelleFigur = new 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,9 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -14,11 +17,15 @@ import java.util.concurrent.Flow.Subscriber;
|
|||||||
*/
|
*/
|
||||||
public class ReceiveAdapter implements Subscriber<Figur> {
|
public class ReceiveAdapter implements Subscriber<Figur> {
|
||||||
|
|
||||||
|
private static Logger lg = OhmLogger.getLogger();
|
||||||
|
|
||||||
private ChatView view;
|
private ChatView view;
|
||||||
|
private ChatModel model;
|
||||||
private Flow.Subscription subscription;
|
private Flow.Subscription subscription;
|
||||||
|
|
||||||
public ReceiveAdapter(ChatView view) {
|
public ReceiveAdapter(ChatView view, ChatModel model) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -27,11 +34,10 @@ public class ReceiveAdapter implements Subscriber<Figur> {
|
|||||||
this.subscription.request(1);
|
this.subscription.request(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNext(Nachricht item) {
|
public void onNext(Figur item) {
|
||||||
|
model.getGrafikDaten().addFigure(item);
|
||||||
//ToDo: hier muss der gFrame aufgerufen werden
|
view.getGvZeichenflaeche().drawFigur();
|
||||||
// evtl muss die Figur aber zuerst serialisiert werden
|
lg.info("Figur wurde dem Grafikmodel hinzugefügt");
|
||||||
//view.getTxtChat().append(item.getNachricht());
|
|
||||||
this.subscription.request(1);
|
this.subscription.request(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,8 +49,4 @@ public class ReceiveAdapter implements Subscriber<Figur> {
|
|||||||
public void onComplete(){
|
public void onComplete(){
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(Figur item)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
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.*;
|
||||||
@@ -16,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, ChatModel model) throws IOException {
|
||||||
|
super(view, model);
|
||||||
|
connect();
|
||||||
|
initIO();
|
||||||
|
}
|
||||||
|
|
||||||
public void connect() throws IOException
|
public void connect() throws IOException
|
||||||
{
|
{
|
||||||
@@ -34,12 +41,5 @@ 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();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,11 @@
|
|||||||
package ChatProgramm.model;
|
package ChatProgramm.model;
|
||||||
|
|
||||||
import ChatProgramm.view.ChatView;
|
import ChatProgramm.view.ChatView;
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
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.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
@@ -30,7 +24,7 @@ import java.util.logging.Logger;
|
|||||||
*
|
*
|
||||||
* @author ahren
|
* @author ahren
|
||||||
*/
|
*/
|
||||||
public abstract class Transmitter implements Runnable, Subscriber<String>, TransmitterInterface {
|
public abstract class Transmitter implements Runnable {
|
||||||
|
|
||||||
static final int timeout = 60000;
|
static final int timeout = 60000;
|
||||||
private static final int PORT = 35000;
|
private static final int PORT = 35000;
|
||||||
@@ -42,19 +36,18 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
|
|||||||
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 ChatModel model;
|
||||||
private ReceiveAdapter receiveAdapter;
|
private ReceiveAdapter receiveAdapter;
|
||||||
|
|
||||||
public Transmitter(ChatView view)
|
public Transmitter(ChatView view, ChatModel model)
|
||||||
{
|
{
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
eService = null;
|
eService = null;
|
||||||
receiveAdapter = new ReceiveAdapter(view);
|
receiveAdapter = new ReceiveAdapter(view, model);
|
||||||
figurPublisher = new SubmissionPublisher<>();
|
figurPublisher = new SubmissionPublisher<>();
|
||||||
this.view = view;
|
this.view = view;
|
||||||
addWertSubscription(receiveAdapter);
|
addWertSubscription(receiveAdapter);
|
||||||
@@ -74,19 +67,12 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
|
|||||||
InputStream is = socket.getInputStream();
|
InputStream is = socket.getInputStream();
|
||||||
OutputStream os = socket.getOutputStream();
|
OutputStream os = socket.getOutputStream();
|
||||||
|
|
||||||
lg.info("1");
|
writer = new ObjectOutputStream(os);
|
||||||
BufferedOutputStream bos = new BufferedOutputStream(os);
|
writer.flush();
|
||||||
|
reader = new ObjectInputStream(is);
|
||||||
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(is);
|
|
||||||
lg.info("2");
|
|
||||||
// InputStreamReader isr = new InputStreamReader(is, "UTF-8");
|
|
||||||
// OutputStreamWriter osr = new OutputStreamWriter(os, "UTF-8");
|
|
||||||
|
|
||||||
reader = new ObjectInputStream(bis);
|
|
||||||
writer = new ObjectOutputStream(bos);
|
|
||||||
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);
|
||||||
@@ -100,7 +86,6 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
|
|||||||
* @param figur
|
* @param figur
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public void send(Figur figur){
|
public void send(Figur figur){
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -115,71 +100,41 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
|
|||||||
figurPublisher.submit(figur);
|
figurPublisher.submit(figur);
|
||||||
}
|
}
|
||||||
public Figur receive(){
|
public Figur receive(){
|
||||||
|
|
||||||
|
Object receivedObject;
|
||||||
try {
|
try {
|
||||||
figur = (Figur) reader.readObject();
|
receivedObject = reader.readObject();
|
||||||
if(!txtNachricht.isEmpty()){
|
|
||||||
lg.info("Nachricht erhalten");
|
|
||||||
|
|
||||||
return figur;
|
if (receivedObject instanceof Figur) {
|
||||||
|
lg.info("Figur erhalten");
|
||||||
|
figur = (Figur) receivedObject;
|
||||||
}
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
} catch (IOException e) {
|
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
throw new RuntimeException(e);
|
} catch (ClassNotFoundException ex) {
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Flow.Subscription subscription) {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(String item) {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable throwable) {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startempfangen()
|
private void startempfangen()
|
||||||
{
|
{
|
||||||
synchronized (this){
|
synchronized (this){
|
||||||
laufend = true;
|
|
||||||
}
|
}
|
||||||
if (eService == null){
|
if (eService == null){
|
||||||
eService = Executors.newSingleThreadExecutor();
|
eService = Executors.newSingleThreadExecutor();
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
|
||||||
*/
|
|
||||||
package ChatProgramm.model;
|
|
||||||
|
|
||||||
import ChatProgramm.model.Nachricht;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author ahren
|
|
||||||
*/
|
|
||||||
public interface TransmitterInterface
|
|
||||||
{
|
|
||||||
public void send(Figur figur);
|
|
||||||
public Figur receive();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -22,7 +22,7 @@ import javax.print.attribute.HashPrintRequestAttributeSet;
|
|||||||
import javax.print.attribute.standard.DialogTypeSelection;
|
import javax.print.attribute.standard.DialogTypeSelection;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import ChatProgramm.model.GrafikModel;
|
import ChatProgramm.model.GrafikDaten;
|
||||||
import ChatProgramm.util.OhmLogger;
|
import ChatProgramm.util.OhmLogger;
|
||||||
|
|
||||||
|
|
||||||
@@ -30,13 +30,13 @@ 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
|
||||||
private Rectangle2D.Float pixel;
|
private Rectangle2D.Float pixel;
|
||||||
private Line2D.Float line;
|
private Line2D.Float line;
|
||||||
private GrafikModel model;
|
private GrafikDaten model;
|
||||||
|
|
||||||
private Point from = null;
|
private Point from = null;
|
||||||
private Point to = null;
|
private Point to = null;
|
||||||
@@ -47,7 +47,7 @@ public class GrafikView extends JComponent implements Printable
|
|||||||
line = new Line2D.Float();
|
line = new Line2D.Float();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModel(GrafikModel model)
|
public void setModel(GrafikDaten model)
|
||||||
{
|
{
|
||||||
this.model = model;
|
this.model = model;
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,16 @@ 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!
|
||||||
|
|
||||||
@@ -100,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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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