Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package model;
- import java.util.ArrayList;
- import java.util.List;
- public class GestionPoint
- {
- private List<PointColor> points;
- public GestionPoint()
- {
- this.points = new ArrayList<PointColor>();
- }
- public boolean ajouter(PointColor point)
- {
- if (points.contains(point))
- return false;
- return points.add(point.clone());
- }
- public void supprimer(PointColor point)
- {
- points.remove(point);
- }
- public List<PointColor> getPoints()
- {
- List<PointColor> clnPoints = new ArrayList<PointColor>();
- for (PointColor pc : points)
- clnPoints.add(pc.clone());
- return clnPoints;
- }
- public boolean setPoint(PointColor pcOld, PointColor pcNew)
- {
- if (points.contains(pcNew))
- return false;
- int index = points.indexOf(pcOld);
- PointColor pc = points.get(index);
- pc.setX(pcNew.getX());
- pc.setY(pcNew.getY());
- pc.setColor(pcNew.getColor());
- pcOld.setX(pcNew.getX());
- pcOld.setY(pcNew.getY());
- pcOld.setColor(pcNew.getColor());
- return true;
- }
- @Override
- public String toString()
- {
- return "GestionPoint [points=" + points + "]";
- }
- public void removeAll(List<PointColor> list)
- {
- points.removeAll(list);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement