12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package garten.view;
-
- import garten.model.Beet;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.util.ArrayList;
- import javax.swing.JPanel;
-
- /**
- *
- * @author Jan
- */
- public class FlaecheBeet extends JPanel
- {
- int[] temppunkte;
- Color colorBeet;
- private ArrayList<Beet> beete;
-
- public FlaecheBeet()
- {
- temppunkte = new int[4];
- colorBeet = new Color(153, 102, 51);
- beete = new ArrayList<>();
- }
-
- public void paintComponent(Graphics g)
- {
- super.paintComponent(g);
- g.setColor(colorBeet);
-
- for (Beet b : beete)
- {
- temppunkte = b.getKoordinaten();
- g.fillRect(temppunkte[0], temppunkte[1], temppunkte[2], temppunkte[3]);
- }
-
- }
-
- public void zeichneBeete(ArrayList<Beet> tempBeet)
- {
-
- beete.addAll(0, tempBeet);
- repaint();
- }
- public void löscheBeete()
- {
- beete.removeAll(beete);
- repaint();
- }
- }
|