You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FlaecheBeet.java 984B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package garten.view;
  7. import garten.model.Beet;
  8. import java.awt.Color;
  9. import java.awt.Graphics;
  10. import java.util.ArrayList;
  11. import javax.swing.JPanel;
  12. /**
  13. *
  14. * @author Jan
  15. */
  16. public class FlaecheBeet extends JPanel
  17. {
  18. int[] temppunkte;
  19. Color colorBeet;
  20. private ArrayList<Beet> beete;
  21. public FlaecheBeet()
  22. {
  23. temppunkte = new int[4];
  24. colorBeet = new Color(153, 102, 51);
  25. beete = new ArrayList<>();
  26. }
  27. public void paintComponent(Graphics g)
  28. {
  29. super.paintComponent(g);
  30. g.setColor(colorBeet);
  31. for (Beet b : beete)
  32. {
  33. temppunkte = b.getKoordinaten();
  34. g.fillRect(temppunkte[0], temppunkte[1], temppunkte[2], temppunkte[3]);
  35. }
  36. }
  37. public void zeichneBeete(ArrayList<Beet> tempBeet)
  38. {
  39. beete.addAll(0, tempBeet);
  40. repaint();
  41. }
  42. }