Compare commits
No commits in common. "6bdad9c08aabdeb7d5d049c1490eac7b98b41bc1" and "b3d25ed5382a0d4ce0b794272b27026dbf7df16e" have entirely different histories.
6bdad9c08a
...
b3d25ed538
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
||||
/build/
|
||||
/dist/
|
||||
|
@ -1,39 +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 mvcgrafik.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();
|
||||
}
|
||||
|
||||
}
|
@ -17,37 +17,35 @@ 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 mvcgrafik.util.OhmLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author le
|
||||
*/
|
||||
public class GrafikModel
|
||||
{
|
||||
private Figur aktuelleFigur;
|
||||
private ArrayList<Figur> figuren;
|
||||
private Preferences pref;
|
||||
private static Logger lg = OhmLogger.getLogger();
|
||||
private ArrayList<Point> punkte;
|
||||
private ArrayList<ArrayList> figuren;
|
||||
private Preferences pref;
|
||||
|
||||
public GrafikModel()
|
||||
{
|
||||
aktuelleFigur = new Figur();
|
||||
punkte = new ArrayList<>();
|
||||
figuren = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addPoint(Point p)
|
||||
{
|
||||
aktuelleFigur.addPoint(p);
|
||||
punkte.add(p);
|
||||
}
|
||||
|
||||
public List<Point> getPunkte()
|
||||
{
|
||||
return aktuelleFigur.getPunkte();
|
||||
return Collections.unmodifiableList(punkte);
|
||||
}
|
||||
|
||||
public List<Figur> getFiguren(){
|
||||
public List<ArrayList> getFiguren(){
|
||||
return Collections.unmodifiableList(figuren);
|
||||
}
|
||||
|
||||
@ -88,13 +86,13 @@ public class GrafikModel
|
||||
if (daten instanceof ArrayList liste)
|
||||
{
|
||||
figuren = liste;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void endShape() {
|
||||
figuren.add(aktuelleFigur);
|
||||
aktuelleFigur = new Figur();
|
||||
figuren.add(new ArrayList<Point>(punkte));
|
||||
punkte.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,6 +114,6 @@ public class GrafikModel
|
||||
{
|
||||
pref.put(lastDirectory, lastAdress);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +70,6 @@ public class GrafikView extends JComponent implements Printable
|
||||
* Jedes mal wenn die Maus los gelassen wird, wird dder aktuelle Pfad gespeichert
|
||||
* @param g
|
||||
*/
|
||||
@Override
|
||||
public void paintComponent(Graphics g)
|
||||
{
|
||||
if (model == null) return;
|
||||
@ -80,8 +79,9 @@ public class GrafikView extends JComponent implements Printable
|
||||
|
||||
model.getFiguren().forEach(figuren->
|
||||
{
|
||||
drawPath(figuren.getPunkte(),g2);
|
||||
drawPath(figuren,g2);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void drawPath(List<Point> path, Graphics2D g2){
|
||||
|
Loading…
x
Reference in New Issue
Block a user