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.

FlaecheWeg.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.Weg;
  8. import java.awt.BasicStroke;
  9. import java.awt.Color;
  10. import java.awt.Graphics;
  11. import java.awt.Graphics2D;
  12. import java.util.ArrayList;
  13. import javax.swing.JPanel;
  14. /**
  15. *
  16. * @author Jan
  17. */
  18. public class FlaecheWeg extends JPanel
  19. {
  20. int[] randomwertex;
  21. int[] randomwertey;
  22. private BasicStroke pinsel;
  23. private ArrayList<Weg> weg;
  24. Color colorWeg;
  25. public FlaecheWeg()
  26. {
  27. weg = new ArrayList<>();
  28. randomwertex = new int[4];
  29. randomwertey = new int[4];
  30. pinsel = new BasicStroke(6f);
  31. colorWeg = new Color(190, 190, 190);
  32. }
  33. public void paintComponent(Graphics g)
  34. {
  35. super.paintComponent(g);
  36. Graphics2D g2 = (Graphics2D) g;
  37. g2.setColor(colorWeg);
  38. g2.setStroke(pinsel);
  39. for(Weg w : weg)
  40. {
  41. randomwertex = w.getKoordinaten();
  42. g2.drawLine(randomwertex[0], randomwertex[1], randomwertex[2], randomwertex[3]);
  43. }
  44. }
  45. public void zeichneWeg(ArrayList<Weg> tempWeg)
  46. {
  47. weg.addAll(0, tempWeg);
  48. repaint();
  49. }
  50. }