Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73300b3cc1 | ||
|
|
a8660820e3 | ||
|
|
2eb2d0825c | ||
|
|
547ebfbf6a | ||
|
|
d75016f9a9 | ||
|
|
13ab1900d2 | ||
|
|
7ffc00110f | ||
|
|
fc16b4c019 | ||
|
|
ab91a7f1aa | ||
|
|
07b083453c | ||
|
|
867486f6ad | ||
|
|
a82809c959 | ||
|
|
f571189849 | ||
|
|
7c66edad14 | ||
|
|
a6eb4578da | ||
|
|
420e596590 | ||
|
|
a03463442c | ||
|
|
9066d0212f | ||
|
|
1e5d95733f | ||
|
|
e1f88aba2d | ||
|
|
4e277e7d5f | ||
|
|
9cce659329 | ||
|
|
3d0324e80b | ||
|
|
2dcdc954ae | ||
|
|
ad62094ee7 | ||
|
|
0c9d41585c | ||
|
|
701f2aed4b | ||
|
|
e31b44d43f | ||
|
|
82a94ba456 | ||
|
|
2a8ff8e29a | ||
|
|
33bb880018 | ||
|
|
a164f7b781 | ||
|
|
8ed04d356a | ||
|
|
1f6811332e | ||
|
|
f2c1544d71 | ||
|
|
32de28204c | ||
|
|
0c59eb5dd3 | ||
|
|
d6b511bab5 | ||
|
|
d60924a05b | ||
|
|
ad4eacc20c | ||
|
|
284823c28b | ||
|
|
41b4c5db8f | ||
|
|
cba61d4dc5 | ||
|
|
050493a70b | ||
|
|
5a0def924a | ||
|
|
ea7ecfcd56 | ||
|
|
2d56ac1b89 | ||
|
|
1684976a47 | ||
|
|
5a9c3f259a | ||
|
|
3920354ae2 | ||
|
|
bcbc9b1027 | ||
|
|
6f58084554 | ||
|
|
c8c1d85eba | ||
|
|
a138807c2a | ||
|
|
fe5a8a5c2d | ||
|
|
24790d8d19 | ||
|
|
7e5c09da58 | ||
|
|
30192ec4aa | ||
|
|
65cd07af6f | ||
|
|
df8fdd803b | ||
|
|
8131464be7 | ||
|
|
d0c92db9f7 | ||
|
|
f289bec571 | ||
|
|
6dec40e70a | ||
|
|
c21af8db1a | ||
|
|
a0a0e604a9 | ||
|
|
297026bf11 | ||
|
|
140d5803ef | ||
|
|
8bf08d4e1d | ||
|
|
ddf5e4e908 | ||
|
|
fd6e334649 | ||
|
|
47345f70c4 | ||
|
|
583e447b81 | ||
|
|
1eb4f8df41 | ||
|
|
ecdb50320a | ||
|
|
b551f91b90 | ||
|
|
fe8fb76759 | ||
|
|
ea487bd24f | ||
|
|
47f04ee68f | ||
|
|
fa146df5a6 | ||
|
|
c00a542ffc | ||
|
|
01b538b3b4 | ||
|
|
b9eb9965dc | ||
|
|
f6bb5a8f44 | ||
|
|
dfee405657 | ||
|
|
d08e226650 | ||
|
|
99e52ebc1a | ||
|
|
87fb690de7 | ||
|
|
ceaabb37c7 | ||
|
|
836f058c85 | ||
|
|
d31272622c | ||
|
|
388021d93d | ||
|
|
23020d03b6 | ||
|
|
7e51fe541a | ||
|
|
fefffeef19 | ||
|
|
fa726f062e | ||
|
|
d0f9601737 | ||
|
|
33f0105337 | ||
|
|
be6aba1e38 | ||
|
|
08c411070d | ||
|
|
be342a5976 |
@@ -1,41 +0,0 @@
|
||||
package Agenda;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Stage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public Stage(String name, String description)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package Applicatie;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class AddPeoplePanel extends JFrame {
|
||||
|
||||
public AddPeoplePanel(Panel topPanel) {
|
||||
super("Adding people");
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
setResizable(false);
|
||||
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
JLabel label;
|
||||
JButton button;
|
||||
|
||||
//Top:
|
||||
JPanel panel = new JPanel();
|
||||
label = new JLabel("Enter the amount of people you want to add: ");
|
||||
panel.add(label);
|
||||
mainPanel.add(panel,BorderLayout.NORTH);
|
||||
//Center:
|
||||
panel = new JPanel();
|
||||
JTextField amountOfPeopleField = new JTextField("0");
|
||||
amountOfPeopleField.setPreferredSize(new Dimension(100,20));
|
||||
amountOfPeopleField.addKeyListener(new KeyListener() {
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
try {
|
||||
amountOfPeopleField.setBackground(Color.WHITE);
|
||||
int amountOfPeople = Integer.parseInt(amountOfPeopleField.getText());
|
||||
amountOfPeopleField.setText(amountOfPeople + "");
|
||||
}
|
||||
catch(NumberFormatException nf) {
|
||||
amountOfPeopleField.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
label = new JLabel("people ");
|
||||
panel.add(amountOfPeopleField);
|
||||
panel.add(label);
|
||||
mainPanel.add(panel,BorderLayout.CENTER);
|
||||
//Bottom:
|
||||
panel = new JPanel();
|
||||
button = new JButton("Cancel");
|
||||
button.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
AddPeoplePanel.this.dispose();
|
||||
}
|
||||
});
|
||||
panel.add(button);
|
||||
button = new JButton("Apply");
|
||||
button.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(amountOfPeopleField.getBackground() != Color.RED) {
|
||||
topPanel.addVisitors(Integer.parseInt(amountOfPeopleField.getText()));
|
||||
AddPeoplePanel.this.dispose();
|
||||
}
|
||||
else
|
||||
JOptionPane.showMessageDialog(topPanel, "Only numbers are accepted");
|
||||
}
|
||||
});
|
||||
panel.add(button);
|
||||
mainPanel.add(panel,BorderLayout.SOUTH);
|
||||
|
||||
add(mainPanel);
|
||||
|
||||
//Finishing off
|
||||
pack();
|
||||
setSize(290,150);
|
||||
setLocationRelativeTo(null);
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -1,268 +0,0 @@
|
||||
package Applicatie;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.NoninvertibleTransformException;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public abstract class DrawObject
|
||||
{
|
||||
Point2D position;
|
||||
double rotation;
|
||||
double scale;
|
||||
private Image image;
|
||||
protected boolean selected;
|
||||
private Rectangle2D rektAngle;
|
||||
private Rectangle2D upperLeftCorner;
|
||||
private Rectangle2D upperRightCorner;
|
||||
private Rectangle2D bottomLeftCorner;
|
||||
private Rectangle2D bottomRightCorner;
|
||||
private Ellipse2D rotateDot;
|
||||
static final int UPPERLEFT = 0;
|
||||
static final int UPPERRIGHT = 1;
|
||||
static final int BOTTOMLEFT = 2;
|
||||
static final int BOTTOMRIGHT = 3;
|
||||
private Color rectangleColor;
|
||||
|
||||
public DrawObject(String filename, Point2D position)
|
||||
{
|
||||
image = new ImageIcon(filename).getImage();
|
||||
scale = 1;
|
||||
rotation = 0;
|
||||
this.position = position;
|
||||
rectangleColor = Color.BLACK;
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public void draw(Graphics2D g)
|
||||
{
|
||||
AffineTransform tx = getTransform();
|
||||
g.drawImage(image, tx, null);
|
||||
if (selected)
|
||||
{
|
||||
// g.rotate(Math.toRadians(rotation), image.getWidth(null)/2,
|
||||
// image.getHeight(null)/2);
|
||||
|
||||
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(rotation), position.getX() + image.getWidth(null) / 2, position.getY() + image.getHeight(null) / 2);
|
||||
//g.transform(rotate);
|
||||
g.setColor(rectangleColor);
|
||||
g.setStroke(new BasicStroke(7));
|
||||
rektAngle = new Rectangle2D.Double((int) position.getX(), (int) position.getY(), image.getWidth(null), image.getHeight(null));
|
||||
tx = getTransformRectangle();
|
||||
rektAngle.setFrame(tx.createTransformedShape(rektAngle).getBounds());
|
||||
g.draw(rektAngle);
|
||||
g.setColor(Color.YELLOW);
|
||||
upperLeftCorner = new Rectangle2D.Double(rektAngle.getX() - 7, rektAngle.getY() - 7, 15, 15);
|
||||
upperRightCorner = new Rectangle2D.Double(rektAngle.getX() + rektAngle.getWidth() - 8, rektAngle.getY() - 7, 15, 15);
|
||||
bottomLeftCorner = new Rectangle2D.Double(rektAngle.getX() - 7, rektAngle.getY() + rektAngle.getHeight() - 8, 15, 15);
|
||||
bottomRightCorner = new Rectangle2D.Double(rektAngle.getX() + rektAngle.getWidth() - 8, rektAngle.getY() + rektAngle.getHeight() - 8, 15, 15);
|
||||
g.fill(upperLeftCorner); // upperleft
|
||||
g.fill(upperRightCorner); // upperright
|
||||
g.fill(bottomLeftCorner); // bottomleft
|
||||
g.fill(bottomRightCorner); // bottomright
|
||||
g.setColor(Color.RED);
|
||||
rotateDot = new Ellipse2D.Double((rektAngle.getX() + (rektAngle.getWidth() / 2)) - 8, rektAngle.getY() - 8, 15, 15);
|
||||
g.fill(rotateDot);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected AffineTransform getTransform()
|
||||
{
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.scale(scale, scale);
|
||||
tx.translate(position.getX(), position.getY());
|
||||
tx.rotate(Math.toRadians(rotation), image.getWidth(null) / 2, image.getHeight(null) / 2);
|
||||
return tx;
|
||||
}
|
||||
|
||||
protected AffineTransform getTransformSelection()
|
||||
{
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.scale(scale, scale);
|
||||
tx.translate(position.getX(), position.getY());
|
||||
return tx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special transformation for the selection rectangle, because the
|
||||
* translation of the image one places the rectangle translated from the
|
||||
* image.
|
||||
*
|
||||
* @return affineTransform
|
||||
*/
|
||||
private AffineTransform getTransformRectangle()
|
||||
{
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.scale(scale, scale);
|
||||
return tx;
|
||||
}
|
||||
|
||||
public boolean contains(Point2D clickPoint)
|
||||
{
|
||||
Shape shape;
|
||||
if (rektAngle == null)
|
||||
{
|
||||
shape = new Rectangle2D.Double(0, 0, image.getWidth(null), image.getHeight(null));
|
||||
return getTransform().createTransformedShape(shape).contains(clickPoint);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
shape = new Rectangle2D.Double(-9, -9, image.getWidth(null) + 13, image.getHeight(null) + 13);
|
||||
return getTransformSelection().createTransformedShape(shape).contains(clickPoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Point2D getObjectPoint(Point2D point)
|
||||
{
|
||||
try
|
||||
{
|
||||
return getTransform().inverseTransform(point, null);
|
||||
|
||||
}
|
||||
catch (NoninvertibleTransformException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking collision.
|
||||
* @param object. the drawObject to check collision with.
|
||||
* @return if there is a collision.
|
||||
*/
|
||||
public boolean collision(DrawObject object)
|
||||
{
|
||||
Shape ownShape = getRectangle();
|
||||
Rectangle2D otherRectangle = object.getTransform().createTransformedShape(object.getImageRectangle()).getBounds2D();
|
||||
if(ownShape.intersects(otherRectangle))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks if the place thats clicked is inside one of the
|
||||
* corners.
|
||||
*
|
||||
* @param point
|
||||
* @param corner
|
||||
* @return if the clicked point is inside one of the corners
|
||||
*/
|
||||
public boolean containsCorner(Point2D point, int corner)
|
||||
{
|
||||
Rectangle2D chosenCorner = null;
|
||||
switch (corner)
|
||||
{
|
||||
case 0:
|
||||
chosenCorner = upperLeftCorner;
|
||||
break;
|
||||
case 1:
|
||||
chosenCorner = upperRightCorner;
|
||||
break;
|
||||
case 2:
|
||||
chosenCorner = bottomLeftCorner;
|
||||
break;
|
||||
case 3:
|
||||
chosenCorner = bottomRightCorner;
|
||||
break;
|
||||
case 4:
|
||||
if (point.getX() > rotateDot.getX() && point.getX() < rotateDot.getX() + rotateDot.getWidth() && point.getY() > rotateDot.getY() && point.getY() < rotateDot.getY() + rotateDot.getHeight())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
if (point.getX() > chosenCorner.getX() && point.getX() < chosenCorner.getX() + chosenCorner.getWidth() && point.getY() > chosenCorner.getY() && point.getY() < chosenCorner.getY() + chosenCorner.getHeight())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setSelected(boolean b)
|
||||
{
|
||||
selected = b;
|
||||
}
|
||||
|
||||
public Point2D getPosition()
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Point2D position)
|
||||
{
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public double getRotation()
|
||||
{
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public void setRotation(double rotation)
|
||||
{
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
public double getScale()
|
||||
{
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(double scale)
|
||||
{
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public Image getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(Image image)
|
||||
{
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public boolean isSelected()
|
||||
{
|
||||
return selected;
|
||||
}
|
||||
|
||||
public Rectangle2D getRectangle()
|
||||
{
|
||||
return rektAngle;
|
||||
}
|
||||
|
||||
public void setRectangle(Rectangle2D rectangle)
|
||||
{
|
||||
rektAngle = rectangle;
|
||||
}
|
||||
|
||||
public Color getRectangleColor()
|
||||
{
|
||||
return rectangleColor;
|
||||
}
|
||||
|
||||
public void setRectangleColor(Color rectangleColor)
|
||||
{
|
||||
this.rectangleColor = rectangleColor;
|
||||
}
|
||||
|
||||
public Rectangle2D getImageRectangle() {
|
||||
return new Rectangle2D.Double(0,0, image.getWidth(null), image.getHeight(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,6 +63,7 @@ public class Panel extends JPanel implements ActionListener
|
||||
private Path currentPath;
|
||||
private static int width = 1920;
|
||||
private static int height = 1080;
|
||||
private boolean play = false;
|
||||
|
||||
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
|
||||
float cameraScale = 1;
|
||||
@@ -73,7 +74,7 @@ public class Panel extends JPanel implements ActionListener
|
||||
Point lastMousePosition = new Point(0, 0);
|
||||
Point2D selectionPosition = new Point(0, 0);
|
||||
Images images = new Images();
|
||||
javax.swing.Timer t;
|
||||
Timer t;
|
||||
|
||||
SimpleDateFormat formatter;
|
||||
GregorianCalendar date;
|
||||
@@ -146,10 +147,9 @@ public class Panel extends JPanel implements ActionListener
|
||||
addMouseMotionListener(new MouseMotion(this));
|
||||
|
||||
addMouseWheelListener(new MouseWheel(this));
|
||||
|
||||
|
||||
addFocusListener(new WindowFocusListener(this));
|
||||
|
||||
t = new Timer(1000 / 10, this);
|
||||
t = new Timer(1000 / 100, this);
|
||||
}
|
||||
|
||||
public int getPanelInfoLength()
|
||||
@@ -171,18 +171,21 @@ public class Panel extends JPanel implements ActionListener
|
||||
ArrayList<AgendaStage> stages = agenda.getStages();
|
||||
Object[] s = new Object[stages.size()];
|
||||
AgendaStage stage = null;
|
||||
if (stages.size() != 0) {
|
||||
for (int i = 0; i < stages.size(); i++) {
|
||||
if (stages.size() != 0)
|
||||
{
|
||||
for (int i = 0; i < stages.size(); i++)
|
||||
{
|
||||
s[i] = stages.get(i);
|
||||
}
|
||||
|
||||
stage = (AgendaStage) JOptionPane.showInputDialog(null,
|
||||
"Select the right Stage", "Select Stage",
|
||||
JOptionPane.PLAIN_MESSAGE, null, s, "stage");
|
||||
stage = (AgendaStage) JOptionPane.showInputDialog(null, "Select the right Stage", "Select Stage", JOptionPane.PLAIN_MESSAGE, null, s, "stage");
|
||||
}
|
||||
if (stage != null){
|
||||
if (stage != null)
|
||||
{
|
||||
return new Stage(null, stage);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
case 1:
|
||||
@@ -209,6 +212,18 @@ public class Panel extends JPanel implements ActionListener
|
||||
{
|
||||
waypoints.add(w);
|
||||
}
|
||||
|
||||
public Waypoint getWaypoint(int i)
|
||||
{
|
||||
for(Waypoint w : waypoints)
|
||||
{
|
||||
if(w.getSelf() == i)
|
||||
{
|
||||
return w;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<Waypoint> getWaypoints()
|
||||
{
|
||||
@@ -226,10 +241,10 @@ public class Panel extends JPanel implements ActionListener
|
||||
if(!entrances.isEmpty()) {
|
||||
DrawObject entrance = entrances.get((int) Math.floor(Math.random()*entrances.size()));
|
||||
Point point = new Point((int)entrance.getPosition().getX(),(int)entrance.getPosition().getY());
|
||||
visitors.add(new Visitor("visitor",point, agenda, objects));
|
||||
visitors.add(new Visitor("visitor",point, agenda, objects, waypoints, date));
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(this, "You don't have a entrance");
|
||||
JOptionPane.showMessageDialog(this, "You don't have an entrance");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,13 +564,27 @@ public class Panel extends JPanel implements ActionListener
|
||||
{
|
||||
if (path.containsPoint(point))
|
||||
{
|
||||
|
||||
setcurrentPath(path);
|
||||
setClickedOption("Path");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Path getClickedPath(Point2D point)
|
||||
{
|
||||
for (Path path : paths)
|
||||
{
|
||||
if (path.containsPoint(point))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a path from the list.
|
||||
@@ -588,17 +617,17 @@ public class Panel extends JPanel implements ActionListener
|
||||
{
|
||||
this.agenda = agenda;
|
||||
}
|
||||
|
||||
|
||||
public static int getFieldWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
public static int getFieldHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
@@ -614,7 +643,7 @@ public class Panel extends JPanel implements ActionListener
|
||||
|
||||
for (Visitor v : visitors)
|
||||
{
|
||||
v.update(objects, currentTime, visitors, paths);
|
||||
v.update(objects, currentTime, visitors, paths, this);
|
||||
}
|
||||
repaint();
|
||||
|
||||
@@ -634,6 +663,16 @@ public class Panel extends JPanel implements ActionListener
|
||||
{
|
||||
this.t = t;
|
||||
}
|
||||
|
||||
public void setPlay(boolean play)
|
||||
{
|
||||
this.play = play;
|
||||
}
|
||||
|
||||
public boolean getPlay()
|
||||
{
|
||||
return play;
|
||||
}
|
||||
|
||||
public void newWorld(int width, int height, int terrainIndex)
|
||||
{
|
||||
@@ -644,21 +683,22 @@ public class Panel extends JPanel implements ActionListener
|
||||
cameraScale = 1;
|
||||
switch (terrainIndex)
|
||||
{
|
||||
case 0:
|
||||
background = grass;
|
||||
break;
|
||||
case 1:
|
||||
background = grass2;
|
||||
break;
|
||||
case 2:
|
||||
background = sand;
|
||||
break;
|
||||
case 3:
|
||||
background = sand2;
|
||||
break;
|
||||
case 4:
|
||||
background = stone;
|
||||
break;
|
||||
case 0:
|
||||
background = grass;
|
||||
break;
|
||||
case 1:
|
||||
background = grass2;
|
||||
break;
|
||||
case 2:
|
||||
background = sand;
|
||||
break;
|
||||
case 3:
|
||||
background = sand2;
|
||||
break;
|
||||
case 4:
|
||||
background = stone;
|
||||
break;
|
||||
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package Applicatie;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import Objects.Path;
|
||||
|
||||
public class PathPopup extends JFrame
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
public PathPopup(Path p, Panel panel)
|
||||
{
|
||||
super("");
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
JPanel content = new JPanel();
|
||||
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
|
||||
JPanel south = new JPanel(new FlowLayout());
|
||||
JPanel center = new JPanel();
|
||||
JPanel panel1 = new JPanel();
|
||||
JLabel name = new JLabel("Add WayPoint");
|
||||
name.setFont(new Font("Dialog", Font.BOLD, 20));
|
||||
panel1.add(name);
|
||||
content.add(panel1);
|
||||
content.add(center);
|
||||
content.add(south);
|
||||
|
||||
JTextField tf = new JTextField(10);
|
||||
center.add(tf);
|
||||
|
||||
JButton edit = new JButton("Done");
|
||||
edit.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
p.addWaypoint(Integer.valueOf(tf.getText()), panel);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
JButton cancel = new JButton("Cancel");
|
||||
cancel.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
south.add(edit);
|
||||
south.add(cancel);
|
||||
|
||||
setContentPane(content);
|
||||
setVisible(true);
|
||||
setSize(200, 150);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public class Visitor
|
||||
Agenda agenda;
|
||||
ArrayList<DrawObject> objects;
|
||||
int target;
|
||||
int finalTarget;
|
||||
|
||||
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects)
|
||||
{
|
||||
@@ -41,7 +42,8 @@ public class Visitor
|
||||
this.objects = objects;
|
||||
fillActions();
|
||||
System.out.println(actions.size());
|
||||
target = 0;
|
||||
target = 1;
|
||||
finalTarget = 4;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2)
|
||||
@@ -63,17 +65,17 @@ public class Visitor
|
||||
|
||||
public DrawObject getEntrance()
|
||||
{
|
||||
for(DrawObject o : objects)
|
||||
for (DrawObject o : objects)
|
||||
{
|
||||
if(o instanceof Entrance)
|
||||
if (o instanceof Entrance)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths)
|
||||
|
||||
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths, Panel panel)
|
||||
{
|
||||
DrawObject target = getEntrance();
|
||||
for (Action a : actions)
|
||||
@@ -85,7 +87,99 @@ public class Visitor
|
||||
|
||||
}
|
||||
|
||||
moveToTarget(target, objects, visitors, paths);
|
||||
// moveToTarget(target, objects, visitors, paths);
|
||||
move(target, panel);
|
||||
}
|
||||
|
||||
public void move(DrawObject tar, Panel panel)
|
||||
{
|
||||
Point2D targetPoint = panel.getWaypoint(target).getPosition();
|
||||
|
||||
double newRot = Math.atan2(targetPoint.getY() - position.getY(), targetPoint.getX() - position.getX());
|
||||
|
||||
int difx = (int) (targetPoint.getX() - position.getX());
|
||||
int dify = (int) (targetPoint.getY() - position.getY());
|
||||
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
||||
|
||||
if (rotation > newRot && distance > 10)
|
||||
{
|
||||
rotation -= 0.15;
|
||||
}
|
||||
else if (rotation < newRot && distance > 10)
|
||||
{
|
||||
rotation += 0.15;
|
||||
}
|
||||
|
||||
Point2D oldPosition = position;
|
||||
|
||||
// face direction
|
||||
float directionX = (float) Math.cos(rotation);
|
||||
float directionY = (float) Math.sin(rotation);
|
||||
|
||||
if (distance > 10)
|
||||
{
|
||||
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
|
||||
}
|
||||
|
||||
boolean possible = true;
|
||||
for (DrawObject object : objects)
|
||||
{
|
||||
if (object instanceof Entrance || object instanceof Waypoint)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (hitTest(object))
|
||||
{
|
||||
possible = false;
|
||||
}
|
||||
}
|
||||
if (possible == false)
|
||||
{
|
||||
position = oldPosition;
|
||||
rotation += 0.2;
|
||||
}
|
||||
if (checkIfOnWaypoint(panel))
|
||||
{
|
||||
HashMap<Integer, int[]> options = new HashMap<Integer, int[]>();
|
||||
for (Waypoint w : panel.getWaypoints())
|
||||
{
|
||||
options.put(w.getSelf(), w.getOptions());
|
||||
}
|
||||
for (Map.Entry<Integer, int[]> e : options.entrySet())
|
||||
{
|
||||
for (int i : e.getValue())
|
||||
{
|
||||
System.out.println("KEY:" + e.getKey());
|
||||
System.out.println("VAL:" + i);
|
||||
System.out.println("TAR: " + target);
|
||||
|
||||
System.out.println("____________");
|
||||
if (finalTarget != target)
|
||||
{
|
||||
if (finalTarget == i && e.getKey() == target)
|
||||
{
|
||||
target = finalTarget;
|
||||
break;
|
||||
}
|
||||
else if (finalTarget == i)
|
||||
{
|
||||
target = e.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean checkIfOnWaypoint(Panel panel)
|
||||
{
|
||||
if (panel.getWaypoint(target).contains(position))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void moveToTarget(DrawObject target, ArrayList<DrawObject> objects, ArrayList<Visitor> visitors, ArrayList<Path> paths)
|
||||
@@ -100,7 +194,7 @@ public class Visitor
|
||||
break;
|
||||
}
|
||||
Shape containsShape = p.containsPointShape(position);
|
||||
if(containsShape != null)
|
||||
if (containsShape != null)
|
||||
{
|
||||
tar = new Point2D.Double(containsShape.getBounds().getCenterX(), containsShape.getBounds().getCenterY());
|
||||
}
|
||||
@@ -208,27 +302,23 @@ public class Visitor
|
||||
}
|
||||
}
|
||||
lastShape = values.get(lastdistance);
|
||||
|
||||
|
||||
Point2D.Double target2 = new Point2D.Double(lastShape.getBounds().getCenterX(), lastShape.getBounds().getCenterY());
|
||||
|
||||
|
||||
double newRot = Math.atan2(target2.getY() - position.getY(), target2.getX() - position.getX());
|
||||
|
||||
int difx = (int) (target2.getX() - position.getX());
|
||||
int dify = (int) (target2.getY() - position.getY());
|
||||
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
||||
|
||||
System.out.println(rotation);
|
||||
System.out.println(newRot);
|
||||
System.out.println("--------------");
|
||||
// if (rotation > newRot && distance > 10)
|
||||
// {
|
||||
// rotation -= 0.15;
|
||||
// }
|
||||
// else if (rotation < newRot && distance > 10)
|
||||
// {
|
||||
// rotation += 0.15;
|
||||
// }
|
||||
rotation = newRot;
|
||||
if (rotation > newRot && distance > 10)
|
||||
{
|
||||
rotation -= 0.15;
|
||||
}
|
||||
else if (rotation < newRot && distance > 10)
|
||||
{
|
||||
rotation += 0.15;
|
||||
}
|
||||
|
||||
Point2D oldPosition = position;
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package Applicatie;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
@@ -16,25 +19,82 @@ import Objects.DrawObject;
|
||||
public class WaypointPopup extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
private JLabel title;
|
||||
|
||||
public WaypointPopup(DrawObject w)
|
||||
public WaypointPopup(DrawObject w, Panel panel)
|
||||
{
|
||||
super("Artist editscreen!");
|
||||
super("Edit WayPoint");
|
||||
Waypoint wp = (Waypoint) w;
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
JPanel south = new JPanel(new FlowLayout());
|
||||
JPanel center = new JPanel(new GridLayout(5,2));
|
||||
JPanel north = new JPanel();
|
||||
if(wp.getSelf() == 0)
|
||||
{
|
||||
title = new JLabel("Edit WayPoint");
|
||||
}
|
||||
else
|
||||
{
|
||||
title = new JLabel("Edit WayPoint " + wp.getSelf());
|
||||
}
|
||||
title.setFont(new Font("Dialog", Font.BOLD, 24));
|
||||
north.add(title);
|
||||
content.add(north, BorderLayout.NORTH);
|
||||
JPanel center = new JPanel(new FlowLayout());
|
||||
JPanel row1 = new JPanel();
|
||||
row1.setLayout(new BoxLayout(row1, BoxLayout.Y_AXIS));
|
||||
JPanel row2 = new JPanel();
|
||||
row2.setLayout(new BoxLayout(row2, BoxLayout.Y_AXIS));
|
||||
JPanel south = new JPanel();
|
||||
content.add(south, BorderLayout.SOUTH);
|
||||
content.add(center, BorderLayout.CENTER);
|
||||
center.add(row1);
|
||||
center.add(row2);
|
||||
|
||||
JPanel empty = new JPanel();
|
||||
empty.add(Box.createRigidArea(new Dimension(0, 20)));
|
||||
row2.add(empty);
|
||||
|
||||
JPanel panel1 = new JPanel();
|
||||
JLabel name = new JLabel("Waypoint");
|
||||
name.setFont(new Font("Dialog", Font.PLAIN, 20));
|
||||
panel1.add(name);
|
||||
center.add(panel1);
|
||||
row1.add(panel1);
|
||||
|
||||
JTextField tf = new JTextField(5);
|
||||
center.add(tf);
|
||||
JTextField tf = new JTextField(wp.getSelf() + "", 10);
|
||||
row2.add(tf);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
JLabel options = new JLabel("Options");
|
||||
options.setFont(new Font("Dialog", Font.PLAIN, 20));
|
||||
panel2.add(options);
|
||||
row1.add(panel2);
|
||||
|
||||
JPanel empty2 = new JPanel();
|
||||
empty2.add(Box.createRigidArea(new Dimension(0, 5)));
|
||||
row2.add(empty2);
|
||||
|
||||
String optionss = "";
|
||||
if(wp.getOptions() != null)
|
||||
{
|
||||
if(wp.getOptions().length != 0)
|
||||
{
|
||||
int[] optionsa = wp.getOptions();
|
||||
optionss += optionsa[0];
|
||||
for(int i = 1; i < optionsa.length; i++)
|
||||
{
|
||||
optionss += "-" + optionsa[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JTextField tx = new JTextField("" + optionss, 8);
|
||||
row2.add(tx);
|
||||
|
||||
JPanel help = new JPanel();
|
||||
JLabel example = new JLabel("example: '1-2-3'");
|
||||
example.setFont(new Font("Dialog", Font.PLAIN, 12));
|
||||
help.add(example);
|
||||
row2.add(help);
|
||||
|
||||
JButton edit = new JButton("Done");
|
||||
edit.addActionListener(new ActionListener()
|
||||
@@ -44,14 +104,35 @@ public class WaypointPopup extends JFrame {
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
wp.setSelf(Integer.valueOf(tf.getText()));
|
||||
panel.addWaypoint(wp);
|
||||
dispose();
|
||||
String options[] = tx.getText().split("-");
|
||||
int ioptions[] = new int[options.length];
|
||||
for(int i = 0; i < options.length; i++)
|
||||
{
|
||||
ioptions[i] = Integer.valueOf(options[i]);
|
||||
System.out.println(ioptions[i]);
|
||||
}
|
||||
wp.setOptions(ioptions);
|
||||
|
||||
}
|
||||
});
|
||||
south.add(edit);
|
||||
|
||||
JButton cancel = new JButton("Cancel");
|
||||
cancel.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
south.add(cancel);
|
||||
|
||||
setContentPane(content);
|
||||
setVisible(true);
|
||||
setSize(500,320);
|
||||
setSize(300,250);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.awt.image.BufferedImage;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import Applicatie.Panel;
|
||||
import Applicatie.PathPopup;
|
||||
|
||||
import Applicatie.Waypoint;
|
||||
import Applicatie.WaypointPopup;
|
||||
import Objects.DrawObject;
|
||||
@@ -33,115 +35,133 @@ 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.getPlay())
|
||||
{
|
||||
if (e.getY() < 150)
|
||||
if (!panel.getClickedOption().equals("Path"))
|
||||
{
|
||||
int i = 0;
|
||||
int last = 0;
|
||||
for (BufferedImage image : panel.getPanelInfo())
|
||||
if (e.getY() < 150)
|
||||
{
|
||||
if (e.getX() >= panel.getScrollfactor() && e.getX() < last + image.getWidth() + panel.getScrollfactor())
|
||||
int i = 0;
|
||||
int last = 0;
|
||||
for (BufferedImage image : panel.getPanelInfo())
|
||||
{
|
||||
DrawObject tempDrawObj = panel.createNewDrawObject(i);
|
||||
if (tempDrawObj != null)
|
||||
if (e.getX() >= panel.getScrollfactor() && e.getX() < last + image.getWidth() + panel.getScrollfactor())
|
||||
{
|
||||
tempDrawObj.setPosition(clickPoint);
|
||||
if (!panel.getObjects().isEmpty())
|
||||
panel.clearObjectSelection();
|
||||
panel.setDragObject(tempDrawObj);
|
||||
panel.getDragObject().setSelected(true);
|
||||
panel.getPP().setSelected(tempDrawObj);
|
||||
panel.setSelectedObject(tempDrawObj);
|
||||
selectedObject = tempDrawObj;
|
||||
DrawObject tempDrawObj = panel.createNewDrawObject(i);
|
||||
if (tempDrawObj != null)
|
||||
{
|
||||
tempDrawObj.setPosition(clickPoint);
|
||||
if (!panel.getObjects().isEmpty())
|
||||
panel.clearObjectSelection();
|
||||
panel.setDragObject(tempDrawObj);
|
||||
panel.getDragObject().setSelected(true);
|
||||
panel.getPP().setSelected(tempDrawObj);
|
||||
panel.setSelectedObject(tempDrawObj);
|
||||
selectedObject = tempDrawObj;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
i++;
|
||||
last += image.getWidth();
|
||||
}
|
||||
if (panel.getDragObject() != null)
|
||||
{
|
||||
panel.add(panel.getDragObject());
|
||||
}
|
||||
i++;
|
||||
last += image.getWidth();
|
||||
}
|
||||
if (panel.getDragObject() != null)
|
||||
else
|
||||
{
|
||||
panel.add(panel.getDragObject());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (DrawObject o : panel.getObjects())
|
||||
{
|
||||
if (o.contains(clickPoint))
|
||||
for (DrawObject o : panel.getObjects())
|
||||
{
|
||||
if (o.contains(clickPoint))
|
||||
{
|
||||
if (SwingUtilities.isRightMouseButton(e))
|
||||
{
|
||||
if (o instanceof Waypoint)
|
||||
{
|
||||
new WaypointPopup(o, panel);
|
||||
|
||||
}
|
||||
}
|
||||
if (o == selectedObject)
|
||||
{
|
||||
boolean upperLeft = o.containsCorner(clickPoint, 0);
|
||||
boolean upperRight = o.containsCorner(clickPoint, 1);
|
||||
boolean bottomLeft = o.containsCorner(clickPoint, 2);
|
||||
boolean bottomRight = o.containsCorner(clickPoint, 3);
|
||||
boolean rotate = o.containsCorner(clickPoint, 4);
|
||||
if (upperLeft)
|
||||
{
|
||||
panel.setClickedOption("upperLeft");
|
||||
}
|
||||
else if (upperRight)
|
||||
{
|
||||
panel.setClickedOption("upperRight");
|
||||
}
|
||||
else if (bottomLeft)
|
||||
{
|
||||
panel.setClickedOption("bottomLeft");
|
||||
}
|
||||
else if (bottomRight)
|
||||
{
|
||||
panel.setClickedOption("bottomRight");
|
||||
}
|
||||
else if (rotate)
|
||||
{
|
||||
panel.setClickedOption("rotate");
|
||||
}
|
||||
else
|
||||
{
|
||||
panel.setClickedOption("drag");
|
||||
}
|
||||
}
|
||||
if (selectedObject != null)
|
||||
selectedObject.setSelected(false);
|
||||
o.setSelected(true);
|
||||
selectedObject = o;
|
||||
panel.setDragObject(o);
|
||||
panel.getPP().setSelected(o);
|
||||
panel.setSelectedObject(o);
|
||||
panel.setSelectionPosition(panel.getDragObject().getPosition());
|
||||
|
||||
}
|
||||
}
|
||||
Path clickedPath = panel.getClickedPath(clickPoint);
|
||||
if (clickedPath != null)
|
||||
{
|
||||
if (SwingUtilities.isRightMouseButton(e))
|
||||
{
|
||||
if (o instanceof Waypoint)
|
||||
{
|
||||
new WaypointPopup(o);
|
||||
}
|
||||
new PathPopup(clickedPath, panel);
|
||||
}
|
||||
if (o == selectedObject)
|
||||
{
|
||||
boolean upperLeft = o.containsCorner(clickPoint, 0);
|
||||
boolean upperRight = o.containsCorner(clickPoint, 1);
|
||||
boolean bottomLeft = o.containsCorner(clickPoint, 2);
|
||||
boolean bottomRight = o.containsCorner(clickPoint, 3);
|
||||
boolean rotate = o.containsCorner(clickPoint, 4);
|
||||
if (upperLeft)
|
||||
{
|
||||
panel.setClickedOption("upperLeft");
|
||||
}
|
||||
else if (upperRight)
|
||||
{
|
||||
panel.setClickedOption("upperRight");
|
||||
}
|
||||
else if (bottomLeft)
|
||||
{
|
||||
panel.setClickedOption("bottomLeft");
|
||||
}
|
||||
else if (bottomRight)
|
||||
{
|
||||
panel.setClickedOption("bottomRight");
|
||||
}
|
||||
else if (rotate)
|
||||
{
|
||||
panel.setClickedOption("rotate");
|
||||
}
|
||||
else
|
||||
{
|
||||
panel.setClickedOption("drag");
|
||||
}
|
||||
}
|
||||
if (selectedObject != null)
|
||||
selectedObject.setSelected(false);
|
||||
o.setSelected(true);
|
||||
selectedObject = o;
|
||||
panel.setDragObject(o);
|
||||
panel.getPP().setSelected(o);
|
||||
panel.setSelectedObject(o);
|
||||
panel.setSelectionPosition(panel.getDragObject().getPosition());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
panel.checkPath(clickPoint);
|
||||
}
|
||||
|
||||
}
|
||||
if (panel.getDragObject() == null && selectedObject != null)
|
||||
{
|
||||
selectedObject.setSelected(false);
|
||||
panel.setSelectedObject(null);
|
||||
panel.getPP().clearSelected();
|
||||
selectedObject = null;
|
||||
}
|
||||
panel.checkPath(clickPoint);
|
||||
}
|
||||
if (panel.getDragObject() == null && selectedObject != null)
|
||||
{
|
||||
selectedObject.setSelected(false);
|
||||
panel.setSelectedObject(null);
|
||||
panel.getPP().clearSelected();
|
||||
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() != null && !panel.getPlay())
|
||||
{
|
||||
if (panel.getDragObject().getRectangleColor() != Color.RED)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import Applicatie.Panel;
|
||||
import Applicatie.Waypoint;
|
||||
|
||||
/**
|
||||
@@ -95,7 +96,7 @@ public class Path
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if one of the lines contains the given point.
|
||||
*
|
||||
@@ -114,12 +115,13 @@ public class Path
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean intersectsRect(Rectangle2D rect)
|
||||
{
|
||||
for(Shape line : getPath())
|
||||
for (Shape line : getPath())
|
||||
{
|
||||
if(line.intersects(rect))
|
||||
if (line.intersects(rect))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -144,13 +146,23 @@ public class Path
|
||||
lines.add(stroke.createStrokedShape(line));
|
||||
}
|
||||
return lines;
|
||||
|
||||
}
|
||||
|
||||
public void addWaypoint(Waypoint w)
|
||||
|
||||
public void addWaypoint(int i, Panel panel)
|
||||
{
|
||||
waypoints.add(w);
|
||||
for (Waypoint w : panel.getWaypoints())
|
||||
{
|
||||
if (w.getSelf() == i)
|
||||
{
|
||||
waypoints.add(w);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a point to the path.
|
||||
*
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package Objects;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import Applicatie.DrawObject;
|
||||
|
||||
|
||||
public class Podium extends DrawObject {
|
||||
|
||||
public Podium(Point2D position) {
|
||||
super("images/stage3.png", position);
|
||||
}
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 897 B |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 180 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 202 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 911 B |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 155 B |
|
After Width: | Height: | Size: 197 B |