Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. package model;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class GestionPoint
  7. {
  8. private List<PointColor> points;
  9.  
  10. public GestionPoint()
  11. {
  12. this.points = new ArrayList<PointColor>();
  13. }
  14.  
  15. public boolean ajouter(PointColor point)
  16. {
  17. if (points.contains(point))
  18. return false;
  19.  
  20. return points.add(point.clone());
  21. }
  22.  
  23. public void supprimer(PointColor point)
  24. {
  25. points.remove(point);
  26. }
  27.  
  28. public List<PointColor> getPoints()
  29. {
  30. List<PointColor> clnPoints = new ArrayList<PointColor>();
  31. for (PointColor pc : points)
  32. clnPoints.add(pc.clone());
  33.  
  34. return clnPoints;
  35. }
  36.  
  37. public boolean setPoint(PointColor pcOld, PointColor pcNew)
  38. {
  39. if (points.contains(pcNew))
  40. return false;
  41.  
  42. int index = points.indexOf(pcOld);
  43. PointColor pc = points.get(index);
  44.  
  45. pc.setX(pcNew.getX());
  46. pc.setY(pcNew.getY());
  47. pc.setColor(pcNew.getColor());
  48.  
  49. pcOld.setX(pcNew.getX());
  50. pcOld.setY(pcNew.getY());
  51. pcOld.setColor(pcNew.getColor());
  52. return true;
  53. }
  54.  
  55. @Override
  56. public String toString()
  57. {
  58. return "GestionPoint [points=" + points + "]";
  59. }
  60.  
  61. public void removeAll(List<PointColor> list)
  62. {
  63. points.removeAll(list);
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement