GrafikModel und Figur eingefügt
This commit is contained in:
parent
22efa7c18f
commit
78c5d8eedf
@ -1067,6 +1067,15 @@ is divided into following sections:
|
||||
<propertyfile file="${built-jar.properties}">
|
||||
<entry key="${basedir}" value=""/>
|
||||
</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 depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
||||
<target depends="init" name="-check-automatic-build">
|
||||
@ -1738,6 +1747,15 @@ is divided into following sections:
|
||||
<propertyfile file="${built-clean.properties}">
|
||||
<entry key="${basedir}" value=""/>
|
||||
</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 depends="init" name="-do-clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
|
@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=05f3ad23
|
||||
build.xml.data.CRC32=d624b1fd
|
||||
build.xml.script.CRC32=1a88b66a
|
||||
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.
|
||||
# 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=05f3ad23
|
||||
nbproject/build-impl.xml.script.CRC32=fdc076e6
|
||||
nbproject/build-impl.xml.data.CRC32=d624b1fd
|
||||
nbproject/build-impl.xml.script.CRC32=476a1ac9
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.108.0.48
|
||||
|
@ -37,7 +37,8 @@ endorsed.classpath=
|
||||
excludes=
|
||||
includes=**
|
||||
jar.compress=false
|
||||
javac.classpath=
|
||||
javac.classpath=\
|
||||
${reference.Aufgabe9_mvcGrafik.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
@ -78,6 +79,8 @@ manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
platform.active=default_platform
|
||||
project.Aufgabe9_mvcGrafik=../../T9_mvcGrafik/Aufgabe9_mvcGrafik
|
||||
reference.Aufgabe9_mvcGrafik.jar=${project.Aufgabe9_mvcGrafik}/dist/Aufgabe9_mvcGrafik.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
@ -11,5 +11,15 @@
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
<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>
|
||||
</project>
|
||||
|
39
src/ChatProgramm/model/Figur.java
Normal file
39
src/ChatProgramm/model/Figur.java
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ahren
|
||||
*/
|
||||
public class Figur implements Serializable
|
||||
{
|
||||
private ArrayList<Point> punkte;
|
||||
|
||||
public Figur(){
|
||||
punkte = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addPoint(Point p){
|
||||
punkte.add(p);
|
||||
}
|
||||
|
||||
public List<Point> getPunkte()
|
||||
{
|
||||
return Collections.unmodifiableList(punkte);
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
punkte.clear();
|
||||
}
|
||||
|
||||
}
|
121
src/ChatProgramm/model/GrafikModel.java
Normal file
121
src/ChatProgramm/model/GrafikModel.java
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,7 @@ public class ChatView extends javax.swing.JFrame
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents()
|
||||
{
|
||||
private void initComponents() {
|
||||
|
||||
dialogChooseMode = new javax.swing.JDialog();
|
||||
lblMode = new javax.swing.JLabel();
|
||||
@ -48,10 +47,8 @@ public class ChatView extends javax.swing.JFrame
|
||||
|
||||
BtnGrpMode.add(BtnServer);
|
||||
BtnServer.setText("Server");
|
||||
BtnServer.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt)
|
||||
{
|
||||
BtnServer.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
BtnServerActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
@ -59,20 +56,16 @@ public class ChatView extends javax.swing.JFrame
|
||||
|
||||
BtnGrpMode.add(BtnClient);
|
||||
BtnClient.setText("Client");
|
||||
BtnClient.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt)
|
||||
{
|
||||
BtnClient.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
BtnClientActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
dialogChooseMode.getContentPane().add(BtnClient);
|
||||
|
||||
BtnConnect.setText("Connect");
|
||||
BtnConnect.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt)
|
||||
{
|
||||
BtnConnect.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
BtnConnectActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
@ -98,26 +91,20 @@ public class ChatView extends javax.swing.JFrame
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(568, 548));
|
||||
addWindowListener(new java.awt.event.WindowAdapter()
|
||||
{
|
||||
public void windowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
public void windowOpened(java.awt.event.WindowEvent evt) {
|
||||
formWindowOpened(evt);
|
||||
}
|
||||
});
|
||||
|
||||
tfNachricht.setToolTipText("");
|
||||
tfNachricht.addMouseListener(new java.awt.event.MouseAdapter()
|
||||
{
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt)
|
||||
{
|
||||
tfNachricht.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
tfNachrichtMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
tfNachricht.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt)
|
||||
{
|
||||
tfNachricht.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
tfNachrichtActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user