.
This commit is contained in:
parent
ff45d56d68
commit
6e93868830
@ -10,21 +10,21 @@ package garten.model;
|
||||
*
|
||||
* @author Jan
|
||||
*/
|
||||
class Beet extends Gartenkomponente
|
||||
public class Beet extends Gartenkomponente
|
||||
{
|
||||
int positionx2;
|
||||
int positiony2;
|
||||
int laenge;
|
||||
int breite;
|
||||
|
||||
Beet(int x, int y,int x2, int y2)
|
||||
public Beet(int x, int y,int laenge, int breite)
|
||||
{
|
||||
positionx = x;
|
||||
positiony = y;
|
||||
positionx2 = x2;
|
||||
positiony2 = y2;
|
||||
this.laenge = laenge;
|
||||
this.breite = breite;
|
||||
}
|
||||
public int [] getKoordinaten()
|
||||
{
|
||||
int[] temp = {positionx,positiony,positionx2,positiony2};
|
||||
int[] temp = {positionx,positiony,laenge,breite};
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
@ -73,20 +73,14 @@ public class Gaertner
|
||||
meinGarten.hinzufuegenBeet(randomwertex[i] + 10, randomwertey[j] + 10, randomwertex[i + 1]-randomwertex[i]-20,randomwertey[j+1] - randomwertey[j]-20);
|
||||
}
|
||||
}
|
||||
|
||||
//Beet * Weg zeichen, muss noch in Garten (geht halt so recht schön)
|
||||
flbeet.setBeet(randomwertex,randomwertey);
|
||||
flweg.setWeg(randomwertex,randomwertey);
|
||||
meinGarten.zeichneWeg();
|
||||
meinGarten.zeichneBeete();
|
||||
|
||||
for (int i = 0; i<5; i++)
|
||||
{
|
||||
pfl = new Pflanze1(100+(i*50),100+(i*50),3);
|
||||
meinGarten.hinzufuegenPflanze(pfl);
|
||||
}
|
||||
|
||||
meinGarten.zeichnePflanzen();
|
||||
//pfl = new Pflanze1(100,100,3);
|
||||
//pfl2 = new Pflanze1(200,400,4);
|
||||
meinGarten.zeichnePflanzen();
|
||||
}
|
||||
/*
|
||||
|
@ -45,7 +45,11 @@ public class Garten extends Kompositum
|
||||
}
|
||||
public void zeichneBeete()
|
||||
{
|
||||
|
||||
flbeet.zeichneBeete(beete);
|
||||
}
|
||||
public void hinzufuegenPflanze(Pflanze pflanze)
|
||||
{
|
||||
pflanzen.add(pflanze);
|
||||
}
|
||||
public void zeichnePflanzen()
|
||||
{
|
||||
@ -57,11 +61,11 @@ public class Garten extends Kompositum
|
||||
Weg neuerWeg = new Weg(sx, sy, ex, ey);
|
||||
wege.add(neuerWeg);
|
||||
}
|
||||
|
||||
public void hinzufuegenPflanze(Pflanze pflanze)
|
||||
public void zeichneWeg()
|
||||
{
|
||||
pflanzen.add(pflanze);
|
||||
flweg.zeichneWeg(wege);
|
||||
}
|
||||
|
||||
/*
|
||||
public Pflanze naechstePflanze(int x, int y)
|
||||
{
|
||||
|
@ -10,10 +10,11 @@ package garten.model;
|
||||
*
|
||||
* @author Jan
|
||||
*/
|
||||
class Weg extends Gartenkomponente
|
||||
public class Weg extends Gartenkomponente
|
||||
{
|
||||
|
||||
int startpositionx,startpositiony,endpositionx,endpositiony;
|
||||
public int startpositionx,startpositiony,endpositionx,endpositiony;
|
||||
|
||||
Weg(int sx, int sy, int ex, int ey)
|
||||
{
|
||||
startpositionx = sx;
|
||||
@ -22,15 +23,9 @@ class Weg extends Gartenkomponente
|
||||
endpositiony = ey;
|
||||
}
|
||||
|
||||
public void zeichnen()
|
||||
{/*
|
||||
fill(105,105,105);
|
||||
strokeWeight(10);
|
||||
strokeCap(PROJECT);
|
||||
line(startpositionx,startpositiony,endpositionx,endpositiony);
|
||||
strokeWeight(1);
|
||||
noFill();
|
||||
*/
|
||||
public int [] getKoordinaten()
|
||||
{
|
||||
int[] temp = {startpositionx,startpositiony,endpositionx,endpositiony};
|
||||
return temp;
|
||||
}
|
||||
|
||||
}
|
@ -5,8 +5,10 @@
|
||||
*/
|
||||
package garten.view;
|
||||
|
||||
import garten.model.Beet;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
@ -15,16 +17,16 @@ import javax.swing.JPanel;
|
||||
*/
|
||||
public class FlaecheBeet extends JPanel
|
||||
{
|
||||
int[] randomwertex;
|
||||
int[] randomwertey;
|
||||
int[] temppunkte;
|
||||
|
||||
Color colorBeet;
|
||||
private ArrayList<Beet> beete;
|
||||
|
||||
public FlaecheBeet()
|
||||
{
|
||||
randomwertex = new int[4];
|
||||
randomwertey = new int[4];
|
||||
temppunkte = new int[4];
|
||||
colorBeet = new Color(153, 102, 51);
|
||||
beete = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g)
|
||||
@ -32,18 +34,17 @@ public class FlaecheBeet extends JPanel
|
||||
super.paintComponent(g);
|
||||
g.setColor(colorBeet);
|
||||
|
||||
for (int i = 0; i < randomwertex.length - 1; i++)
|
||||
for (Beet b : beete)
|
||||
{
|
||||
for (int j = 0; j < randomwertey.length - 1; j++)
|
||||
{
|
||||
g.fillRect(randomwertex[i] + 10, randomwertey[j] + 10, randomwertex[i + 1] - randomwertex[i] - 20, randomwertey[j + 1] - randomwertey[j] - 20);
|
||||
}
|
||||
temppunkte = b.getKoordinaten();
|
||||
g.fillRect(temppunkte[0], temppunkte[1], temppunkte[2], temppunkte[3]);
|
||||
}
|
||||
|
||||
}
|
||||
public void setBeet(int[] x, int[] y) //set = automatisch zeichnen
|
||||
|
||||
public void zeichneBeete(ArrayList<Beet> tempBeet)
|
||||
{
|
||||
randomwertex = x;
|
||||
randomwertey = y;
|
||||
beete.addAll(0, tempBeet);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,12 @@
|
||||
*/
|
||||
package garten.view;
|
||||
|
||||
import garten.model.Weg;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
@ -20,10 +22,12 @@ public class FlaecheWeg extends JPanel
|
||||
int[] randomwertex;
|
||||
int[] randomwertey;
|
||||
private BasicStroke pinsel;
|
||||
private ArrayList<Weg> weg;
|
||||
Color colorWeg;
|
||||
|
||||
public FlaecheWeg()
|
||||
{
|
||||
weg = new ArrayList<>();
|
||||
randomwertex = new int[4];
|
||||
randomwertey = new int[4];
|
||||
pinsel = new BasicStroke(6f);
|
||||
@ -37,17 +41,16 @@ public class FlaecheWeg extends JPanel
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setColor(colorWeg);
|
||||
g2.setStroke(pinsel);
|
||||
for (int i = 0; i < randomwertex.length; i++)
|
||||
for(Weg w : weg)
|
||||
{
|
||||
g2.drawLine(randomwertex[i], randomwertey[0], randomwertex[i], randomwertey[3]);
|
||||
g2.drawLine(randomwertex[0], randomwertey[i], randomwertex[3], randomwertey[i]);
|
||||
randomwertex = w.getKoordinaten();
|
||||
g2.drawLine(randomwertex[0], randomwertex[1], randomwertex[2], randomwertex[3]);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWeg(int[] x, int[] y)//set = automatisch zeichnen
|
||||
public void zeichneWeg(ArrayList<Weg> tempWeg)
|
||||
{
|
||||
randomwertex = x;
|
||||
randomwertey = y;
|
||||
weg.addAll(0, tempWeg);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user