| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package gui.simulator;
- import gui.simulator.facilities.ImageType;
- import java.awt.BasicStroke;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.TexturePaint;
- import java.io.Serializable;
- import java.util.ArrayList;
- public class WalkingPath implements Serializable {
- private ArrayList<Point> path;
- private DrawEngine object1,object2;
- private ImageType texture;
-
- public WalkingPath(ImageType itype){
- path = new ArrayList<Point>();
- texture = itype;
- }
- public void addPoint(Point p){
- path.add(p);
- }
- public void removeLastPoint(){
- if(path.size() != 0){
- path.remove(path.size()-1);
- }
- }
- public Point get(int i){
- return path.get(i);
- }
- public ArrayList<Point> getPath() {
- return path;
- }
- public void setPath(ArrayList<Point> path) {
- this.path = path;
- }
- public DrawEngine getObject1() {
- return object1;
- }
- public void setObject1(DrawEngine object1) {
- this.object1 = object1;
- }
- public DrawEngine getObject2() {
- return object2;
- }
- public void setObject2(DrawEngine object2) {
- this.object2 = object2;
- }
- public void reCalculate(){
- if(object1 != null && object2 != null){
- path.get(0).setLocation(new Point((int)object1.getCenter().getX(), (int)object1.getCenter().getY()));
- path.get(path.size()-1).setLocation(new Point((int)object2.getCenter().getX(), (int)object2.getCenter().getY()));
- }
- }
- public void paint(Graphics2D g2){
- g2.setStroke(new BasicStroke(30,BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
- g2.setPaint(new TexturePaint(Images.getImage(texture), new Rectangle(0,0,100,100)));
- for(int i = 1; i < getPath().size(); i++){
- g2.drawLine((int)get(i-1).getX(),(int)get(i-1).getY(), (int)get(i).getX(),(int)get(i).getY());
- }
- }
-
-
- }
|