Started with waypoints
This commit is contained in:
@@ -82,12 +82,8 @@ public class MenuBar extends JMenuBar {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to close this program?", "Close Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
w.setVisible(false);
|
||||
w.dispose();
|
||||
=======
|
||||
System.exit(0);
|
||||
>>>>>>> origin/Banaan
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,10 +4,7 @@ package Agenda;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
<<<<<<< HEAD
|
||||
import java.awt.FlowLayout;
|
||||
=======
|
||||
>>>>>>> origin/Banaan
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Images
|
||||
images.put("stage1", loadImage("images/stage3.png"));
|
||||
images.put("visitor", loadImage("images/visitor.png"));
|
||||
images.put("food", loadImage("images/food.png"));
|
||||
images.put("waypoint", loadImage("images/waypoint.png"));
|
||||
}
|
||||
|
||||
public static Image loadImage(String path)
|
||||
|
||||
+36
-2
@@ -43,14 +43,14 @@ public class Panel extends JPanel implements ActionListener
|
||||
|
||||
BufferedImage grass, sand;
|
||||
BufferedImage background;
|
||||
BufferedImage podiumImage, toiletImage, entranceImage, pathImage, wallImage, foodImage;
|
||||
BufferedImage podiumImage, toiletImage, entranceImage, pathImage, wallImage, foodImage, waypointImage;
|
||||
|
||||
private int panelInfox, panelInfoy, scrollfactor;
|
||||
|
||||
private ArrayList<BufferedImage> panelInfo = new ArrayList<BufferedImage>();
|
||||
// private ArrayList<Object> panelTypes = new ArrayList<Object>();
|
||||
ArrayList<Visitor> visitors = new ArrayList<>();
|
||||
|
||||
ArrayList<Waypoint> waypoints = new ArrayList<Waypoint>();
|
||||
ArrayList<DrawObject> objects = new ArrayList<>();
|
||||
ArrayList<Path> paths = new ArrayList<>();
|
||||
DrawObject dragObject = null;
|
||||
@@ -103,6 +103,7 @@ public class Panel extends JPanel implements ActionListener
|
||||
pathImage = ImageIO.read(new File("images/pathIcon.png"));
|
||||
wallImage = ImageIO.read(new File("images/wallIcon.png"));
|
||||
foodImage = ImageIO.read(new File("images/foodIcon.png"));
|
||||
waypointImage = ImageIO.read(new File("images/waypointIcon.png"));
|
||||
background = grass;
|
||||
}
|
||||
catch (IOException e)
|
||||
@@ -115,6 +116,7 @@ public class Panel extends JPanel implements ActionListener
|
||||
panelInfo.add(pathImage);
|
||||
panelInfo.add(wallImage);
|
||||
panelInfo.add(foodImage);
|
||||
panelInfo.add(waypointImage);
|
||||
|
||||
agenda = new Agenda();
|
||||
|
||||
@@ -161,6 +163,8 @@ public class Panel extends JPanel implements ActionListener
|
||||
return new Wall(null);
|
||||
case 5:
|
||||
return new Food(null);
|
||||
case 6:
|
||||
return new Waypoint(null);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -171,6 +175,31 @@ public class Panel extends JPanel implements ActionListener
|
||||
objects.add(dragObject);
|
||||
}
|
||||
|
||||
public void addWaypoint(Waypoint w)
|
||||
{
|
||||
waypoints.add(w);
|
||||
}
|
||||
|
||||
public ArrayList<Waypoint> getWaypoints()
|
||||
{
|
||||
return waypoints;
|
||||
}
|
||||
|
||||
public int getNextTarget()
|
||||
{
|
||||
int last = 0;
|
||||
for (Waypoint w : waypoints)
|
||||
{
|
||||
System.out.println(waypoints);
|
||||
if (w.getSelf() > last)
|
||||
{
|
||||
last = w.getSelf();
|
||||
}
|
||||
}
|
||||
System.out.println(last);
|
||||
return last;
|
||||
}
|
||||
|
||||
public void addVisitors()
|
||||
{
|
||||
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects));
|
||||
@@ -553,6 +582,11 @@ public class Panel extends JPanel implements ActionListener
|
||||
return t;
|
||||
}
|
||||
|
||||
public ArrayList<Path> getPaths()
|
||||
{
|
||||
return paths;
|
||||
}
|
||||
|
||||
public void setT(Timer t)
|
||||
{
|
||||
this.t = t;
|
||||
|
||||
@@ -27,6 +27,7 @@ public class Visitor
|
||||
ArrayList<Action> actions;
|
||||
Agenda agenda;
|
||||
ArrayList<DrawObject> objects;
|
||||
char target;
|
||||
|
||||
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects)
|
||||
{
|
||||
@@ -39,6 +40,7 @@ public class Visitor
|
||||
this.agenda = agenda;
|
||||
this.objects = objects;
|
||||
fillActions();
|
||||
target = 'z';
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package Applicatie;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import Objects.DrawObject;
|
||||
|
||||
public class Waypoint extends DrawObject
|
||||
{
|
||||
private int[] options;
|
||||
private int self;
|
||||
public Waypoint(Point2D position)
|
||||
{
|
||||
super("waypoint", position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Waypoint";
|
||||
}
|
||||
|
||||
public int[] getOptions()
|
||||
{
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(int[] options)
|
||||
{
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public int getSelf()
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
public void setSelf(int self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
}
|
||||
+16
-10
@@ -4,11 +4,13 @@ import java.awt.Color;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import Applicatie.Panel;
|
||||
import Applicatie.Waypoint;
|
||||
import Objects.DrawObject;
|
||||
import Objects.Stage;
|
||||
import Objects.Path;
|
||||
|
||||
public class Mouse extends MouseAdapter
|
||||
{
|
||||
@@ -27,7 +29,8 @@ public class Mouse extends MouseAdapter
|
||||
Point2D clickPoint = panel.getClickPoint(e.getPoint());
|
||||
panel.setLastClickPosition(clickPoint);
|
||||
panel.setLastMousePosition(e.getPoint());
|
||||
if(!panel.getClickedOption().equals("Path")) {
|
||||
if (!panel.getClickedOption().equals("Path"))
|
||||
{
|
||||
if (e.getY() < 150)
|
||||
{
|
||||
int i = 0;
|
||||
@@ -38,7 +41,7 @@ public class Mouse extends MouseAdapter
|
||||
{
|
||||
DrawObject tempDrawObj = panel.createNewDrawObject(i);
|
||||
tempDrawObj.setPosition(clickPoint);
|
||||
if(!panel.getObjects().isEmpty())
|
||||
if (!panel.getObjects().isEmpty())
|
||||
panel.clearObjectSelection();
|
||||
panel.setDragObject(tempDrawObj);
|
||||
panel.getDragObject().setSelected(true);
|
||||
@@ -101,7 +104,7 @@ public class Mouse extends MouseAdapter
|
||||
panel.getPP().setSelected(o);
|
||||
panel.setSelectedObject(o);
|
||||
panel.setSelectionPosition(panel.getDragObject().getPosition());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
panel.checkPath(clickPoint);
|
||||
@@ -114,21 +117,24 @@ public class Mouse extends MouseAdapter
|
||||
selectedObject = null;
|
||||
}
|
||||
}
|
||||
else { //Making path.
|
||||
panel.getCurrentPath().addPoint(new Point2D.Double(clickPoint.getX(),clickPoint.getY()));
|
||||
else
|
||||
{ // Making path.
|
||||
panel.getCurrentPath().addPoint(new Point2D.Double(clickPoint.getX(), clickPoint.getY()));
|
||||
}
|
||||
panel.repaint();
|
||||
}
|
||||
|
||||
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
if(panel.getDragObject() != null) {
|
||||
if(panel.getDragObject().getRectangleColor() != Color.RED) {
|
||||
if (panel.getDragObject() != null)
|
||||
{
|
||||
if (panel.getDragObject().getRectangleColor() != Color.RED)
|
||||
{
|
||||
panel.setDragObject(null);
|
||||
panel.setClickedOption("drag");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
panel.getDragObject().setPosition(panel.getSelectionPosition());
|
||||
panel.getDragObject().setRectangleColor(Color.BLACK);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,18 @@ public class Path
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean intersectsRect(Rectangle2D rect)
|
||||
{
|
||||
for(Shape line : getPath())
|
||||
{
|
||||
if(line.intersects(rect))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array with line's from the points.
|
||||
|
||||
Reference in New Issue
Block a user