Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73300b3cc1 | ||
|
|
a8660820e3 | ||
|
|
2eb2d0825c | ||
|
|
547ebfbf6a | ||
|
|
d75016f9a9 | ||
|
|
13ab1900d2 | ||
|
|
7ffc00110f | ||
|
|
fc16b4c019 | ||
|
|
ab91a7f1aa | ||
|
|
07b083453c | ||
|
|
867486f6ad | ||
|
|
a82809c959 | ||
|
|
f571189849 | ||
|
|
7c66edad14 | ||
|
|
a6eb4578da | ||
|
|
420e596590 | ||
|
|
7c28dd3a16 | ||
|
|
a03463442c | ||
|
|
9066d0212f | ||
|
|
1e5d95733f | ||
|
|
e1f88aba2d | ||
|
|
4e277e7d5f | ||
|
|
9cce659329 | ||
|
|
3d0324e80b | ||
|
|
2dcdc954ae | ||
|
|
ad62094ee7 | ||
|
|
0c9d41585c | ||
|
|
701f2aed4b | ||
|
|
e31b44d43f | ||
|
|
82a94ba456 | ||
|
|
2a8ff8e29a | ||
|
|
33bb880018 | ||
|
|
a164f7b781 | ||
|
|
8ed04d356a | ||
|
|
1f6811332e | ||
|
|
f2c1544d71 | ||
|
|
32de28204c | ||
|
|
98af73b15e | ||
|
|
0c59eb5dd3 | ||
|
|
5ec737e707 | ||
|
|
d6b511bab5 | ||
|
|
d60924a05b | ||
|
|
ad4eacc20c | ||
|
|
65f428c572 | ||
|
|
284823c28b | ||
|
|
41b4c5db8f | ||
|
|
cba61d4dc5 | ||
|
|
050493a70b | ||
|
|
5a0def924a | ||
|
|
ea7ecfcd56 | ||
|
|
2d56ac1b89 | ||
|
|
1684976a47 | ||
|
|
5a9c3f259a | ||
|
|
3920354ae2 | ||
|
|
b2b2388f6f | ||
|
|
bcbc9b1027 | ||
|
|
6f58084554 | ||
|
|
c8c1d85eba | ||
|
|
a138807c2a | ||
|
|
fe5a8a5c2d | ||
|
|
24790d8d19 | ||
|
|
7e5c09da58 | ||
|
|
30192ec4aa | ||
|
|
65cd07af6f | ||
|
|
a45d37a4d5 | ||
|
|
040859ac2a | ||
|
|
df8fdd803b | ||
|
|
10951fe225 | ||
|
|
34bc4526fc | ||
|
|
8131464be7 | ||
|
|
d0c92db9f7 | ||
|
|
f289bec571 | ||
|
|
6dec40e70a | ||
|
|
c21af8db1a | ||
|
|
a0a0e604a9 | ||
|
|
297026bf11 | ||
|
|
140d5803ef | ||
|
|
8bf08d4e1d | ||
|
|
ddf5e4e908 | ||
|
|
fd6e334649 | ||
|
|
47345f70c4 | ||
|
|
583e447b81 | ||
|
|
1eb4f8df41 | ||
|
|
ecdb50320a | ||
|
|
b551f91b90 | ||
|
|
fe8fb76759 | ||
|
|
ea487bd24f | ||
|
|
47f04ee68f | ||
|
|
fa146df5a6 | ||
|
|
f1e6abae76 | ||
|
|
c00a542ffc | ||
|
|
01b538b3b4 | ||
|
|
b9eb9965dc | ||
|
|
f6bb5a8f44 | ||
|
|
dfee405657 | ||
|
|
d08e226650 | ||
|
|
99e52ebc1a | ||
|
|
c3ca87ad8f | ||
|
|
87fb690de7 | ||
|
|
ceaabb37c7 | ||
|
|
836f058c85 | ||
|
|
d31272622c | ||
|
|
dccdccb573 | ||
|
|
388021d93d | ||
|
|
23020d03b6 | ||
|
|
7e51fe541a | ||
|
|
fefffeef19 | ||
|
|
fa726f062e | ||
|
|
d0f9601737 | ||
|
|
33f0105337 | ||
|
|
be6aba1e38 | ||
|
|
ae35416cf9 | ||
|
|
08c411070d | ||
|
|
be342a5976 |
@@ -34,8 +34,8 @@ public class Event implements Serializable {
|
|||||||
endHour, endMinute);
|
endHour, endMinute);
|
||||||
this.startHour = startHour;
|
this.startHour = startHour;
|
||||||
this.startMinute = startMinute;
|
this.startMinute = startMinute;
|
||||||
this.stopHour = endHour;
|
this.stopHour = stopHour;
|
||||||
this.stopMinute = endMinute;
|
this.stopMinute = stopMinute;
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.artist = artist;
|
this.artist = artist;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|||||||
@@ -11,15 +11,13 @@ public class Action
|
|||||||
private int starttime;
|
private int starttime;
|
||||||
private int duration;
|
private int duration;
|
||||||
private DrawObject target;
|
private DrawObject target;
|
||||||
private Waypoint waypoint;
|
|
||||||
|
|
||||||
public Action(Point2D position, int starttime, int duration, DrawObject tar, Waypoint waypoint)
|
public Action(Point2D position, int starttime, int duration, DrawObject tar)
|
||||||
{
|
{
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.starttime = starttime;
|
this.starttime = starttime;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.target = tar;
|
this.target = tar;
|
||||||
this.waypoint = waypoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point2D getPosition()
|
public Point2D getPosition()
|
||||||
@@ -46,9 +44,4 @@ public class Action
|
|||||||
{
|
{
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Waypoint getWaypoint(){
|
|
||||||
return waypoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,6 +63,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
private Path currentPath;
|
private Path currentPath;
|
||||||
private static int width = 1920;
|
private static int width = 1920;
|
||||||
private static int height = 1080;
|
private static int height = 1080;
|
||||||
|
private boolean play = false;
|
||||||
|
|
||||||
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
|
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
|
||||||
float cameraScale = 1;
|
float cameraScale = 1;
|
||||||
@@ -148,7 +149,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
addMouseWheelListener(new MouseWheel(this));
|
addMouseWheelListener(new MouseWheel(this));
|
||||||
|
|
||||||
addFocusListener(new WindowFocusListener(this));
|
addFocusListener(new WindowFocusListener(this));
|
||||||
t = new Timer(1000 / 10, this);
|
t = new Timer(1000 / 100, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPanelInfoLength()
|
public int getPanelInfoLength()
|
||||||
@@ -662,6 +663,16 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
{
|
{
|
||||||
this.t = t;
|
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)
|
public void newWorld(int width, int height, int terrainIndex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package Applicatie;
|
|||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
@@ -21,20 +23,21 @@ public class PathPopup extends JFrame
|
|||||||
|
|
||||||
public PathPopup(Path p, Panel panel)
|
public PathPopup(Path p, Panel panel)
|
||||||
{
|
{
|
||||||
super("Artist editscreen!");
|
super("");
|
||||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
JPanel content = new JPanel(new BorderLayout());
|
JPanel content = new JPanel();
|
||||||
|
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
|
||||||
JPanel south = new JPanel(new FlowLayout());
|
JPanel south = new JPanel(new FlowLayout());
|
||||||
JPanel center = new JPanel(new GridLayout(5, 2));
|
JPanel center = new JPanel();
|
||||||
content.add(south, BorderLayout.SOUTH);
|
|
||||||
content.add(center, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
JPanel panel1 = new JPanel();
|
JPanel panel1 = new JPanel();
|
||||||
JLabel name = new JLabel("Path");
|
JLabel name = new JLabel("Add WayPoint");
|
||||||
|
name.setFont(new Font("Dialog", Font.BOLD, 20));
|
||||||
panel1.add(name);
|
panel1.add(name);
|
||||||
center.add(panel1);
|
content.add(panel1);
|
||||||
|
content.add(center);
|
||||||
|
content.add(south);
|
||||||
|
|
||||||
JTextField tf = new JTextField(5);
|
JTextField tf = new JTextField(10);
|
||||||
center.add(tf);
|
center.add(tf);
|
||||||
|
|
||||||
JButton edit = new JButton("Done");
|
JButton edit = new JButton("Done");
|
||||||
@@ -47,11 +50,22 @@ public class PathPopup extends JFrame
|
|||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
JButton cancel = new JButton("Cancel");
|
||||||
|
cancel.addActionListener(new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
south.add(edit);
|
south.add(edit);
|
||||||
|
south.add(cancel);
|
||||||
|
|
||||||
setContentPane(content);
|
setContentPane(content);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
setSize(500, 320);
|
setSize(200, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ import java.awt.Image;
|
|||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Area;
|
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -17,9 +15,9 @@ import Agenda.Event;
|
|||||||
import Objects.DrawObject;
|
import Objects.DrawObject;
|
||||||
import Objects.Entrance;
|
import Objects.Entrance;
|
||||||
import Objects.Path;
|
import Objects.Path;
|
||||||
import Objects.Stage;
|
|
||||||
|
|
||||||
public class Visitor {
|
public class Visitor
|
||||||
|
{
|
||||||
|
|
||||||
Point2D position;
|
Point2D position;
|
||||||
double rotation;
|
double rotation;
|
||||||
@@ -29,40 +27,34 @@ public class Visitor {
|
|||||||
ArrayList<Action> actions;
|
ArrayList<Action> actions;
|
||||||
Agenda agenda;
|
Agenda agenda;
|
||||||
ArrayList<DrawObject> objects;
|
ArrayList<DrawObject> objects;
|
||||||
ArrayList<Waypoint> waypoints;
|
|
||||||
GregorianCalendar date;
|
|
||||||
int target;
|
int target;
|
||||||
int finalTarget;
|
int finalTarget;
|
||||||
|
|
||||||
public Visitor(String filename, Point2D position, Agenda agenda,
|
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects)
|
||||||
ArrayList<DrawObject> objects, ArrayList<Waypoint> waypoints,
|
{
|
||||||
GregorianCalendar date) {
|
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.rotation = 0;
|
this.rotation = 0;
|
||||||
this.speed = 1 + Math.random() * 4;
|
this.speed = 1 + Math.random() * 4;
|
||||||
this.waypoints = waypoints;
|
|
||||||
this.date = date;
|
|
||||||
scale = 1;
|
scale = 1;
|
||||||
actions = new ArrayList<Action>();
|
actions = new ArrayList<Action>();
|
||||||
this.agenda = agenda;
|
this.agenda = agenda;
|
||||||
this.objects = objects;
|
this.objects = objects;
|
||||||
fillActions();
|
fillActions();
|
||||||
System.out.println(actions.size());
|
System.out.println(actions.size());
|
||||||
for (Action a : actions){
|
|
||||||
System.out.println("" + a.getStartTime());
|
|
||||||
}
|
|
||||||
target = 1;
|
target = 1;
|
||||||
finalTarget = 4;
|
finalTarget = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2)
|
||||||
|
{
|
||||||
AffineTransform tx = getTransform();
|
AffineTransform tx = getTransform();
|
||||||
Image image = Images.getImage(filename);
|
Image image = Images.getImage(filename);
|
||||||
g2.drawImage(image, tx, null);
|
g2.drawImage(image, tx, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AffineTransform getTransform() {
|
private AffineTransform getTransform()
|
||||||
|
{
|
||||||
Image image = Images.getImage(filename);
|
Image image = Images.getImage(filename);
|
||||||
AffineTransform tx = new AffineTransform();
|
AffineTransform tx = new AffineTransform();
|
||||||
tx.scale(scale, scale);
|
tx.scale(scale, scale);
|
||||||
@@ -71,22 +63,26 @@ public class Visitor {
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawObject getEntrance() {
|
public DrawObject getEntrance()
|
||||||
for (DrawObject o : objects) {
|
{
|
||||||
if (o instanceof Entrance) {
|
for (DrawObject o : objects)
|
||||||
|
{
|
||||||
|
if (o instanceof Entrance)
|
||||||
|
{
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(ArrayList<DrawObject> objects, int currentTime,
|
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths, Panel panel)
|
||||||
ArrayList<Visitor> visitors, ArrayList<Path> paths, Panel panel) {
|
{
|
||||||
DrawObject target = getEntrance();
|
DrawObject target = getEntrance();
|
||||||
for (Action a : actions) {
|
for (Action a : actions)
|
||||||
if (currentTime >= a.getStartTime()
|
{
|
||||||
&& currentTime < a.getStoptime()) {
|
if (currentTime >= a.getStartTime() && currentTime < a.getStoptime())
|
||||||
finalTarget = a.getWaypoint().getSelf();
|
{
|
||||||
|
target = a.getTargetObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -95,19 +91,22 @@ public class Visitor {
|
|||||||
move(target, panel);
|
move(target, panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(DrawObject tar, Panel panel) {
|
public void move(DrawObject tar, Panel panel)
|
||||||
|
{
|
||||||
Point2D targetPoint = panel.getWaypoint(target).getPosition();
|
Point2D targetPoint = panel.getWaypoint(target).getPosition();
|
||||||
|
|
||||||
double newRot = Math.atan2(targetPoint.getY() - position.getY(),
|
double newRot = Math.atan2(targetPoint.getY() - position.getY(), targetPoint.getX() - position.getX());
|
||||||
targetPoint.getX() - position.getX());
|
|
||||||
|
|
||||||
int difx = (int) (targetPoint.getX() - position.getX());
|
int difx = (int) (targetPoint.getX() - position.getX());
|
||||||
int dify = (int) (targetPoint.getY() - position.getY());
|
int dify = (int) (targetPoint.getY() - position.getY());
|
||||||
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
||||||
|
|
||||||
if (rotation > newRot && distance > 10) {
|
if (rotation > newRot && distance > 10)
|
||||||
|
{
|
||||||
rotation -= 0.15;
|
rotation -= 0.15;
|
||||||
} else if (rotation < newRot && distance > 10) {
|
}
|
||||||
|
else if (rotation < newRot && distance > 10)
|
||||||
|
{
|
||||||
rotation += 0.15;
|
rotation += 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,85 +116,104 @@ public class Visitor {
|
|||||||
float directionX = (float) Math.cos(rotation);
|
float directionX = (float) Math.cos(rotation);
|
||||||
float directionY = (float) Math.sin(rotation);
|
float directionY = (float) Math.sin(rotation);
|
||||||
|
|
||||||
if (distance > 10) {
|
if (distance > 10)
|
||||||
position = new Point2D.Double(
|
{
|
||||||
(position.getX() + directionX * speed),
|
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
|
||||||
(position.getY() + directionY * speed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean possible = true;
|
boolean possible = true;
|
||||||
for (DrawObject object : objects) {
|
for (DrawObject object : objects)
|
||||||
if (object instanceof Entrance || object instanceof Waypoint) {
|
{
|
||||||
|
if (object instanceof Entrance || object instanceof Waypoint)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (hasCollisionDO(object)) {
|
if (hitTest(object))
|
||||||
|
{
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (possible == false) {
|
if (possible == false)
|
||||||
|
{
|
||||||
position = oldPosition;
|
position = oldPosition;
|
||||||
rotation += 0.2;
|
rotation += 0.2;
|
||||||
}
|
}
|
||||||
if (checkIfOnWaypoint(panel)) {
|
if (checkIfOnWaypoint(panel))
|
||||||
// for(int i : panel.getWaypoint(target).getOptions())
|
{
|
||||||
// {
|
|
||||||
// if(i == finalTarget)
|
|
||||||
// {
|
|
||||||
// target = finalTarget;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ArrayList<int[]> options = new ArrayList<int[]>();
|
|
||||||
HashMap<Integer, int[]> options = new HashMap<Integer, int[]>();
|
HashMap<Integer, int[]> options = new HashMap<Integer, int[]>();
|
||||||
for (Waypoint w : panel.getWaypoints()) {
|
for (Waypoint w : panel.getWaypoints())
|
||||||
|
{
|
||||||
options.put(w.getSelf(), w.getOptions());
|
options.put(w.getSelf(), w.getOptions());
|
||||||
}
|
}
|
||||||
for (Map.Entry<Integer, int[]> e : options.entrySet()) {
|
for (Map.Entry<Integer, int[]> e : options.entrySet())
|
||||||
System.out.println(e.getKey());
|
{
|
||||||
System.out.println("=====================");
|
for (int i : e.getValue())
|
||||||
for (int i : e.getValue()) {
|
{
|
||||||
System.out.println(i);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
System.out.println("----------");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkIfOnWaypoint(Panel panel) {
|
public boolean checkIfOnWaypoint(Panel panel)
|
||||||
if (panel.getWaypoint(target).contains(position)) {
|
{
|
||||||
|
if (panel.getWaypoint(target).contains(position))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveToTarget(DrawObject target, ArrayList<DrawObject> objects,
|
public void moveToTarget(DrawObject target, ArrayList<DrawObject> objects, ArrayList<Visitor> visitors, ArrayList<Path> paths)
|
||||||
ArrayList<Visitor> visitors, ArrayList<Path> paths) {
|
{
|
||||||
Point2D tar = target.getPosition();
|
Point2D tar = target.getPosition();
|
||||||
boolean hasPathBelow = false;
|
boolean hasPathBelow = false;
|
||||||
for (Path p : paths) {
|
for (Path p : paths)
|
||||||
if (p.containsPoint(position)) {
|
{
|
||||||
|
if (p.containsPoint(position))
|
||||||
|
{
|
||||||
hasPathBelow = true;
|
hasPathBelow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Shape containsShape = p.containsPointShape(position);
|
Shape containsShape = p.containsPointShape(position);
|
||||||
if (containsShape != null) {
|
if (containsShape != null)
|
||||||
tar = new Point2D.Double(
|
{
|
||||||
containsShape.getBounds().getCenterX(), containsShape
|
tar = new Point2D.Double(containsShape.getBounds().getCenterX(), containsShape.getBounds().getCenterY());
|
||||||
.getBounds().getCenterY());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasPathBelow) {
|
if (hasPathBelow)
|
||||||
double newRot = Math.atan2(tar.getY() - position.getY(), tar.getX()
|
{
|
||||||
- position.getX());
|
double newRot = Math.atan2(tar.getY() - position.getY(), tar.getX() - position.getX());
|
||||||
|
|
||||||
int difx = (int) (tar.getX() - position.getX());
|
int difx = (int) (tar.getX() - position.getX());
|
||||||
int dify = (int) (tar.getY() - position.getY());
|
int dify = (int) (tar.getY() - position.getY());
|
||||||
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
||||||
|
|
||||||
if (rotation > newRot && distance > 10) {
|
if (rotation > newRot && distance > 10)
|
||||||
|
{
|
||||||
rotation -= 0.15;
|
rotation -= 0.15;
|
||||||
} else if (rotation < newRot && distance > 10) {
|
}
|
||||||
|
else if (rotation < newRot && distance > 10)
|
||||||
|
{
|
||||||
rotation += 0.15;
|
rotation += 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,30 +223,39 @@ public class Visitor {
|
|||||||
float directionX = (float) Math.cos(rotation);
|
float directionX = (float) Math.cos(rotation);
|
||||||
float directionY = (float) Math.sin(rotation);
|
float directionY = (float) Math.sin(rotation);
|
||||||
|
|
||||||
if (distance > 10) {
|
if (distance > 10)
|
||||||
position = new Point2D.Double((position.getX() + directionX
|
{
|
||||||
* speed), (position.getY() + directionY * speed));
|
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean possible = true;
|
boolean possible = true;
|
||||||
for (DrawObject object : objects) {
|
for (DrawObject object : objects)
|
||||||
if (hasCollisionDO(object)) {
|
{
|
||||||
|
if (hitTest(object))
|
||||||
|
{
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Visitor object : visitors) {
|
for (Visitor object : visitors)
|
||||||
if (hasCollision(object) && object != this) {
|
{
|
||||||
|
if (hitTestVisitor(object) && object != this)
|
||||||
|
{
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (possible == false) {
|
if (possible == false)
|
||||||
|
{
|
||||||
position = oldPosition;
|
position = oldPosition;
|
||||||
rotation += 0.2;
|
rotation += 0.2;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
HashMap<Double, Shape> values = new HashMap<Double, Shape>();
|
HashMap<Double, Shape> values = new HashMap<Double, Shape>();
|
||||||
for (Path p : paths) {
|
for (Path p : paths)
|
||||||
for (Shape s : p.getPath()) {
|
{
|
||||||
|
for (Shape s : p.getPath())
|
||||||
|
{
|
||||||
Rectangle b = s.getBounds();
|
Rectangle b = s.getBounds();
|
||||||
double maxx = b.getMaxX();
|
double maxx = b.getMaxX();
|
||||||
double minx = b.getMinX();
|
double minx = b.getMinX();
|
||||||
@@ -242,14 +269,16 @@ public class Visitor {
|
|||||||
points[3] = new Point2D.Double(maxx, maxy);
|
points[3] = new Point2D.Double(maxx, maxy);
|
||||||
|
|
||||||
Double lastdistance = null;
|
Double lastdistance = null;
|
||||||
for (Point2D.Double point : points) {
|
for (Point2D.Double point : points)
|
||||||
double distance = Point2D.distance(point.getX(),
|
{
|
||||||
point.getY(), position.getX(), position.getY());
|
double distance = Point2D.distance(point.getX(), point.getY(), position.getX(), position.getY());
|
||||||
if (lastdistance == null) {
|
if (lastdistance == null)
|
||||||
|
{
|
||||||
lastdistance = distance;
|
lastdistance = distance;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (distance < lastdistance) {
|
if (distance < lastdistance)
|
||||||
|
{
|
||||||
lastdistance = distance;
|
lastdistance = distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,31 +288,35 @@ public class Visitor {
|
|||||||
}
|
}
|
||||||
Double lastdistance = null;
|
Double lastdistance = null;
|
||||||
Shape lastShape = null;
|
Shape lastShape = null;
|
||||||
for (Map.Entry<Double, Shape> e : values.entrySet()) {
|
for (Map.Entry<Double, Shape> e : values.entrySet())
|
||||||
|
{
|
||||||
double distance = e.getKey();
|
double distance = e.getKey();
|
||||||
if (lastdistance == null) {
|
if (lastdistance == null)
|
||||||
|
{
|
||||||
lastdistance = distance;
|
lastdistance = distance;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (distance < lastdistance) {
|
if (distance < lastdistance)
|
||||||
|
{
|
||||||
lastdistance = distance;
|
lastdistance = distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastShape = values.get(lastdistance);
|
lastShape = values.get(lastdistance);
|
||||||
|
|
||||||
Point2D.Double target2 = new Point2D.Double(lastShape.getBounds()
|
Point2D.Double target2 = new Point2D.Double(lastShape.getBounds().getCenterX(), lastShape.getBounds().getCenterY());
|
||||||
.getCenterX(), lastShape.getBounds().getCenterY());
|
|
||||||
|
|
||||||
double newRot = Math.atan2(target2.getY() - position.getY(),
|
double newRot = Math.atan2(target2.getY() - position.getY(), target2.getX() - position.getX());
|
||||||
target2.getX() - position.getX());
|
|
||||||
|
|
||||||
int difx = (int) (target2.getX() - position.getX());
|
int difx = (int) (target2.getX() - position.getX());
|
||||||
int dify = (int) (target2.getY() - position.getY());
|
int dify = (int) (target2.getY() - position.getY());
|
||||||
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
|
||||||
|
|
||||||
if (rotation > newRot && distance > 10) {
|
if (rotation > newRot && distance > 10)
|
||||||
|
{
|
||||||
rotation -= 0.15;
|
rotation -= 0.15;
|
||||||
} else if (rotation < newRot && distance > 10) {
|
}
|
||||||
|
else if (rotation < newRot && distance > 10)
|
||||||
|
{
|
||||||
rotation += 0.15;
|
rotation += 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,119 +326,101 @@ public class Visitor {
|
|||||||
float directionX = (float) Math.cos(rotation);
|
float directionX = (float) Math.cos(rotation);
|
||||||
float directionY = (float) Math.sin(rotation);
|
float directionY = (float) Math.sin(rotation);
|
||||||
|
|
||||||
if (distance > 10) {
|
if (distance > 10)
|
||||||
position = new Point2D.Double((position.getX() + directionX
|
{
|
||||||
* speed), (position.getY() + directionY * speed));
|
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean possible = true;
|
boolean possible = true;
|
||||||
for (DrawObject object : objects) {
|
for (DrawObject object : objects)
|
||||||
if (hasCollisionDO(object)) {
|
{
|
||||||
|
if (hitTest(object))
|
||||||
|
{
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Visitor object : visitors) {
|
for (Visitor object : visitors)
|
||||||
if (hasCollision(object) && object != this) {
|
{
|
||||||
|
if (hitTestVisitor(object) && object != this)
|
||||||
|
{
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (possible == false) {
|
if (possible == false)
|
||||||
|
{
|
||||||
position = oldPosition;
|
position = oldPosition;
|
||||||
rotation += 0.2;
|
rotation += 0.2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fillActions()
|
||||||
public void fillActions() {
|
{
|
||||||
int startTime = 540;
|
int startTime = 540;
|
||||||
int stopTime = 1260;
|
int stopTime = 1260;
|
||||||
|
|
||||||
while (startTime < stopTime) {
|
while (startTime < stopTime)
|
||||||
|
{
|
||||||
int random = (int) Math.floor(Math.random() * 51);
|
int random = (int) Math.floor(Math.random() * 51);
|
||||||
if (random < 30) {
|
if (random < 30)
|
||||||
|
{
|
||||||
Point2D position = null;
|
Point2D position = null;
|
||||||
DrawObject targetStage = null;
|
DrawObject targetStage = null;
|
||||||
ArrayList<Event> posEvents = new ArrayList<Event>();
|
for (Event e : agenda.getEvents())
|
||||||
for (Event e : agenda.getEvents()) {
|
{
|
||||||
if (startTime >= e.getStart() && startTime < e.getStop()) {
|
if (convertMinutesToHours(startTime) > e.getStart() && convertMinutesToHours(startTime) < e.getStop())
|
||||||
posEvents.add(e);
|
{
|
||||||
}
|
for (DrawObject d : objects)
|
||||||
}
|
{
|
||||||
|
if (d.getFileName().equals(e.getStage().getName()))
|
||||||
int totalPopularity = 0;
|
{
|
||||||
for (Event ev : posEvents){
|
position = d.getPosition();
|
||||||
totalPopularity += ev.getExpectedPopularity();
|
targetStage = d;
|
||||||
}
|
|
||||||
|
|
||||||
Random rand = new Random();
|
|
||||||
int n = rand.nextInt(totalPopularity) + 1;
|
|
||||||
int currentPop = 0;
|
|
||||||
if (posEvents != null){
|
|
||||||
for (Event evs : posEvents){
|
|
||||||
int before = currentPop;
|
|
||||||
currentPop = currentPop + evs.getExpectedPopularity();
|
|
||||||
if (before < n && currentPop >= n){
|
|
||||||
for (DrawObject d : objects) {
|
|
||||||
if (d.getFileName().equals("stage")) {
|
|
||||||
Stage s = (Stage) d;
|
|
||||||
if (s.getStage().getName()
|
|
||||||
.equals(evs.getStage().getName())) {
|
|
||||||
position = s.getPosition();
|
|
||||||
targetStage = d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int randomtime = (int) (40 + (Math.random() * (60 - 40)));
|
int randomtime = (int) (40 + (Math.random() * (60 - 40)));
|
||||||
if (position != null) {
|
if (position != null)
|
||||||
Waypoint w = getClosedWaypoint(position);
|
{
|
||||||
actions.add(new Action(position, startTime, randomtime,
|
actions.add(new Action(position, startTime, randomtime, targetStage));
|
||||||
targetStage, w));
|
|
||||||
}
|
}
|
||||||
startTime = startTime + randomtime;
|
startTime = startTime + randomtime;
|
||||||
|
|
||||||
} else if (random >= 30 && random < 40) {
|
}
|
||||||
|
else if (random >= 30 && random < 35)
|
||||||
|
{
|
||||||
Point2D position = null;
|
Point2D position = null;
|
||||||
DrawObject targetStage = null;
|
DrawObject targetDraw = null;
|
||||||
ArrayList<DrawObject> foodPlaces = new ArrayList<DrawObject>();
|
for (DrawObject d : objects)
|
||||||
for (DrawObject d : objects) {
|
{
|
||||||
if (d.getFileName().equals("food")) {
|
if (d.getFileName().equals("entrance"))
|
||||||
foodPlaces.add(d);
|
{
|
||||||
|
position = d.getPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (position != null)
|
||||||
if (foodPlaces.size() != 0) {
|
{
|
||||||
int r = (int) Math.floor(Math.random() * foodPlaces.size());
|
actions.add(new Action(position, startTime, 35, targetDraw));
|
||||||
position = foodPlaces.get(r).getPosition();
|
startTime = startTime + 35;
|
||||||
targetStage = foodPlaces.get(r);
|
|
||||||
Waypoint w = getClosedWaypoint(position);
|
|
||||||
actions.add(new Action(position, startTime, 35,
|
|
||||||
targetStage, w));
|
|
||||||
startTime = startTime + 20;
|
|
||||||
}
|
}
|
||||||
startTime = startTime + 35;
|
startTime = startTime + 35;
|
||||||
|
|
||||||
} else if (random >= 40) {
|
}
|
||||||
|
else if (random > 35)
|
||||||
|
{
|
||||||
Point2D position = null;
|
Point2D position = null;
|
||||||
DrawObject targetStage = null;
|
DrawObject targetDrawobj = null;
|
||||||
ArrayList<DrawObject> toilets = new ArrayList<DrawObject>();
|
for (DrawObject d : objects)
|
||||||
for (DrawObject d : objects) {
|
{
|
||||||
if (d.getFileName().equals("wc")) {
|
if (d.getFileName().equals("wc"))
|
||||||
toilets.add(d);
|
{
|
||||||
|
position = d.getPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toilets.size() != 0) {
|
if (position != null)
|
||||||
int r = (int) Math.floor(Math.random() * toilets.size());
|
{
|
||||||
position = toilets.get(r).getPosition();
|
actions.add(new Action(position, startTime, 35, targetDrawobj));
|
||||||
targetStage = toilets.get(r);
|
|
||||||
Waypoint w = getClosedWaypoint(position);
|
|
||||||
actions.add(new Action(position, startTime, 35,
|
|
||||||
targetStage, w));
|
|
||||||
startTime = startTime + 20;
|
|
||||||
}
|
}
|
||||||
startTime = startTime + 35;
|
startTime = startTime + 35;
|
||||||
|
|
||||||
@@ -413,71 +428,35 @@ public class Visitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Waypoint getClosedWaypoint(Point2D point) {
|
public int convertMinutesToHours(int startTime)
|
||||||
Waypoint waypoint = null;
|
{
|
||||||
int distance = 10000;
|
int time = 0;
|
||||||
for (Waypoint w : waypoints) {
|
int hours = startTime / 60;
|
||||||
if (w.getPosition().distance(point) < distance) {
|
int minutes = startTime % 60;
|
||||||
waypoint = w;
|
time = (hours * 100) + minutes;
|
||||||
distance = (int) w.getPosition().distance(point);
|
return time;
|
||||||
}
|
|
||||||
}
|
|
||||||
return waypoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCollisionDO(DrawObject object) {
|
public int getEndX()
|
||||||
|
{
|
||||||
Image image = Images.getImage(filename);
|
Image image = Images.getImage(filename);
|
||||||
Image image2 = Images.getImage(object.getFileName());
|
return (int) (position.getX() + image.getWidth(null));
|
||||||
Rectangle recta = new Rectangle((int) position.getX(),
|
|
||||||
(int) position.getY(), image.getWidth(null),
|
|
||||||
image.getHeight(null));
|
|
||||||
Rectangle rectb = new Rectangle((int) object.getPosition().getX(),
|
|
||||||
(int) object.getPosition().getY(), image2.getWidth(null),
|
|
||||||
image2.getHeight(null));
|
|
||||||
|
|
||||||
Area a = new Area(recta);
|
|
||||||
Area b = new Area(rectb);
|
|
||||||
|
|
||||||
AffineTransform transA = new AffineTransform();
|
|
||||||
transA.rotate(rotation, position.getX(), position.getY());
|
|
||||||
|
|
||||||
AffineTransform transB = new AffineTransform();
|
|
||||||
transB.rotate(Math.toRadians(object.getRotation()), object
|
|
||||||
.getPosition().getX(), object.getPosition().getY());
|
|
||||||
|
|
||||||
Area aa = a.createTransformedArea(transA);
|
|
||||||
Area bb = b.createTransformedArea(transB);
|
|
||||||
|
|
||||||
if (bb.intersects(aa.getBounds2D())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCollision(Visitor v) {
|
public int getEndY()
|
||||||
|
{
|
||||||
Image image = Images.getImage(filename);
|
Image image = Images.getImage(filename);
|
||||||
Rectangle a = new Rectangle((int) position.getX(),
|
return (int) (position.getY() + image.getHeight(null));
|
||||||
(int) position.getY(), image.getWidth(null),
|
|
||||||
image.getHeight(null));
|
|
||||||
Rectangle b = new Rectangle((int) v.position.getX(),
|
|
||||||
(int) v.position.getY(), image.getWidth(null),
|
|
||||||
image.getHeight(null));
|
|
||||||
|
|
||||||
Area aa = new Area(a);
|
|
||||||
Area bb = new Area(b);
|
|
||||||
|
|
||||||
AffineTransform af = new AffineTransform();
|
|
||||||
af.rotate(rotation, position.getX(), position.getY());
|
|
||||||
|
|
||||||
AffineTransform bf = new AffineTransform();
|
|
||||||
bf.rotate(v.rotation, v.position.getX(), v.position.getY());
|
|
||||||
|
|
||||||
Area ra = aa.createTransformedArea(af);
|
|
||||||
Area rb = bb.createTransformedArea(bf);
|
|
||||||
|
|
||||||
if (ra.intersects(rb.getBounds2D())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public boolean hitTest(DrawObject to2)
|
||||||
|
{
|
||||||
|
return (getEndX() >= to2.getPosition().getX() && getEndY() >= to2.getPosition().getY() && to2.getEndX() >= position.getX() && to2.getEndY() >= position.getY());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hitTestVisitor(Visitor v)
|
||||||
|
{
|
||||||
|
return (getEndX() >= v.position.getX() && getEndY() >= v.position.getY() && v.getEndX() >= position.getX() && v.getEndY() >= position.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,7 +60,7 @@ public class WaypointPopup extends JFrame {
|
|||||||
panel1.add(name);
|
panel1.add(name);
|
||||||
row1.add(panel1);
|
row1.add(panel1);
|
||||||
|
|
||||||
JTextField tf = new JTextField(10);
|
JTextField tf = new JTextField(wp.getSelf() + "", 10);
|
||||||
row2.add(tf);
|
row2.add(tf);
|
||||||
|
|
||||||
JPanel panel2 = new JPanel();
|
JPanel panel2 = new JPanel();
|
||||||
@@ -73,7 +73,21 @@ public class WaypointPopup extends JFrame {
|
|||||||
empty2.add(Box.createRigidArea(new Dimension(0, 5)));
|
empty2.add(Box.createRigidArea(new Dimension(0, 5)));
|
||||||
row2.add(empty2);
|
row2.add(empty2);
|
||||||
|
|
||||||
JTextField tx = new JTextField(8);
|
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);
|
row2.add(tx);
|
||||||
|
|
||||||
JPanel help = new JPanel();
|
JPanel help = new JPanel();
|
||||||
@@ -97,6 +111,7 @@ public class WaypointPopup extends JFrame {
|
|||||||
for(int i = 0; i < options.length; i++)
|
for(int i = 0; i < options.length; i++)
|
||||||
{
|
{
|
||||||
ioptions[i] = Integer.valueOf(options[i]);
|
ioptions[i] = Integer.valueOf(options[i]);
|
||||||
|
System.out.println(ioptions[i]);
|
||||||
}
|
}
|
||||||
wp.setOptions(ioptions);
|
wp.setOptions(ioptions);
|
||||||
|
|
||||||
@@ -104,6 +119,17 @@ public class WaypointPopup extends JFrame {
|
|||||||
});
|
});
|
||||||
south.add(edit);
|
south.add(edit);
|
||||||
|
|
||||||
|
JButton cancel = new JButton("Cancel");
|
||||||
|
cancel.addActionListener(new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
south.add(cancel);
|
||||||
|
|
||||||
setContentPane(content);
|
setContentPane(content);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
setSize(300,250);
|
setSize(300,250);
|
||||||
|
|||||||
@@ -35,130 +35,133 @@ public class Mouse extends MouseAdapter
|
|||||||
Point2D clickPoint = panel.getClickPoint(e.getPoint());
|
Point2D clickPoint = panel.getClickPoint(e.getPoint());
|
||||||
panel.setLastClickPosition(clickPoint);
|
panel.setLastClickPosition(clickPoint);
|
||||||
panel.setLastMousePosition(e.getPoint());
|
panel.setLastMousePosition(e.getPoint());
|
||||||
|
|
||||||
if (!panel.getClickedOption().equals("Path"))
|
if(!panel.getPlay())
|
||||||
{
|
{
|
||||||
if (e.getY() < 150)
|
if (!panel.getClickedOption().equals("Path"))
|
||||||
{
|
{
|
||||||
int i = 0;
|
if (e.getY() < 150)
|
||||||
int last = 0;
|
|
||||||
for (BufferedImage image : panel.getPanelInfo())
|
|
||||||
{
|
{
|
||||||
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 (e.getX() >= panel.getScrollfactor() && e.getX() < last + image.getWidth() + panel.getScrollfactor())
|
||||||
if (tempDrawObj != null)
|
|
||||||
{
|
{
|
||||||
tempDrawObj.setPosition(clickPoint);
|
DrawObject tempDrawObj = panel.createNewDrawObject(i);
|
||||||
if (!panel.getObjects().isEmpty())
|
if (tempDrawObj != null)
|
||||||
panel.clearObjectSelection();
|
{
|
||||||
panel.setDragObject(tempDrawObj);
|
tempDrawObj.setPosition(clickPoint);
|
||||||
panel.getDragObject().setSelected(true);
|
if (!panel.getObjects().isEmpty())
|
||||||
panel.getPP().setSelected(tempDrawObj);
|
panel.clearObjectSelection();
|
||||||
panel.setSelectedObject(tempDrawObj);
|
panel.setDragObject(tempDrawObj);
|
||||||
selectedObject = tempDrawObj;
|
panel.getDragObject().setSelected(true);
|
||||||
|
panel.getPP().setSelected(tempDrawObj);
|
||||||
|
panel.setSelectedObject(tempDrawObj);
|
||||||
|
selectedObject = tempDrawObj;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
i++;
|
||||||
|
last += image.getWidth();
|
||||||
}
|
}
|
||||||
i++;
|
if (panel.getDragObject() != null)
|
||||||
last += image.getWidth();
|
|
||||||
}
|
|
||||||
if (panel.getDragObject() != null)
|
|
||||||
{
|
|
||||||
panel.add(panel.getDragObject());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (DrawObject o : panel.getObjects())
|
|
||||||
{
|
|
||||||
if (o.contains(clickPoint))
|
|
||||||
{
|
{
|
||||||
if (SwingUtilities.isRightMouseButton(e))
|
panel.add(panel.getDragObject());
|
||||||
{
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
new PathPopup(clickedPath, panel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
panel.checkPath(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))
|
||||||
|
{
|
||||||
|
new PathPopup(clickedPath, panel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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()));
|
||||||
|
|
||||||
}
|
}
|
||||||
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()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
panel.repaint();
|
panel.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent e)
|
public void mouseReleased(MouseEvent e)
|
||||||
{
|
{
|
||||||
if (panel.getDragObject() != null)
|
if (panel.getDragObject() != null && !panel.getPlay())
|
||||||
{
|
{
|
||||||
if (panel.getDragObject().getRectangleColor() != Color.RED)
|
if (panel.getDragObject().getRectangleColor() != Color.RED)
|
||||||
{
|
{
|
||||||
|
|||||||
|
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: 494 KiB |
|
After Width: | Height: | Size: 180 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 5.0 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: 1.6 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 46 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 |
|
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 |