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