Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73300b3cc1 | ||
|
|
a8660820e3 | ||
|
|
2eb2d0825c |
@@ -51,20 +51,7 @@ public class Agenda implements Serializable {
|
|||||||
{
|
{
|
||||||
return stages;
|
return stages;
|
||||||
}
|
}
|
||||||
public ArrayList<Event> eventsForStage(AgendaStage st)
|
|
||||||
{
|
|
||||||
ArrayList<Event> stageEvents = new ArrayList<Event>();
|
|
||||||
for(Event e: events)
|
|
||||||
{
|
|
||||||
if(e.getStage() == st)
|
|
||||||
{
|
|
||||||
stageEvents.add(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return stageEvents;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
public void saveAgenda()
|
public void saveAgenda()
|
||||||
{
|
{
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
@@ -192,7 +179,7 @@ public class Agenda implements Serializable {
|
|||||||
{
|
{
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
String name = e.getStage().getName();
|
String name = e.getStage().getName();
|
||||||
for (Stage s : stages)
|
for (AgendaStage s : stages)
|
||||||
{
|
{
|
||||||
if ( s.getName().equals(name) ) {
|
if ( s.getName().equals(name) ) {
|
||||||
exists = true;
|
exists = true;
|
||||||
@@ -215,8 +202,7 @@ public class Agenda implements Serializable {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public void clearAgenda()
|
public void clearAgenda()
|
||||||
{
|
{
|
||||||
@@ -225,12 +211,10 @@ public class Agenda implements Serializable {
|
|||||||
artists.clear();
|
artists.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public void fillAllLists()
|
public void fillAllLists()
|
||||||
{
|
{
|
||||||
loadAgenda();
|
loadAgenda();
|
||||||
fillStages();
|
fillStages();
|
||||||
fillArtists();
|
fillArtists();
|
||||||
}
|
}
|
||||||
*/
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class EditArtistPanel extends JFrame {
|
|||||||
|
|
||||||
public EditArtistPanel(Agenda agenda, Artist art, TabbedPane tab)
|
public EditArtistPanel(Agenda agenda, Artist art, TabbedPane tab)
|
||||||
{
|
{
|
||||||
super("Artist editscreen");
|
super("Artist editscreen!");
|
||||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
JPanel content = new JPanel(new BorderLayout());
|
JPanel content = new JPanel(new BorderLayout());
|
||||||
JPanel south = new JPanel(new FlowLayout());
|
JPanel south = new JPanel(new FlowLayout());
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class EditEventPanel extends JFrame{
|
|||||||
|
|
||||||
public EditEventPanel(Agenda agenda, Event e, TabbedPane tab)
|
public EditEventPanel(Agenda agenda, Event e, TabbedPane tab)
|
||||||
{
|
{
|
||||||
super("Event editscreen");
|
super("Event editscreen!");
|
||||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
JPanel content = new JPanel(new BorderLayout());
|
JPanel content = new JPanel(new BorderLayout());
|
||||||
JPanel south = new JPanel(new FlowLayout());
|
JPanel south = new JPanel(new FlowLayout());
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class EditStagePanel extends JFrame{
|
|||||||
|
|
||||||
public EditStagePanel(Agenda agenda, AgendaStage sta)
|
public EditStagePanel(Agenda agenda, AgendaStage sta)
|
||||||
{
|
{
|
||||||
super("Stage editscreen");
|
super("Stage editscreen!");
|
||||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
JPanel content = new JPanel(new BorderLayout());
|
JPanel content = new JPanel(new BorderLayout());
|
||||||
JPanel south = new JPanel(new FlowLayout());
|
JPanel south = new JPanel(new FlowLayout());
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -55,11 +55,11 @@ public class Event implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getStart(){
|
public int getStart(){
|
||||||
return (startHour * 60) + startMinute;
|
return (startHour * 100) + startMinute;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStop(){
|
public int getStop(){
|
||||||
return (stopHour * 60) + stopMinute;
|
return (stopHour * 100) + stopMinute;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStopHour(){
|
public int getStopHour(){
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ public class MenuBar extends JMenuBar {
|
|||||||
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Applicatie.SaveLoad.load(w.getPanel());
|
w.getAgenda().loadAgenda();
|
||||||
w.setAgenda(w.getPanel().getAgenda());
|
|
||||||
Window.updatePanel();
|
Window.updatePanel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -73,7 +72,7 @@ public class MenuBar extends JMenuBar {
|
|||||||
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
|
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
|
||||||
save.addActionListener(new ActionListener() {
|
save.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Applicatie.SaveLoad.save(w.getPanel());
|
w.getAgenda().saveAgenda();
|
||||||
Window.updatePanel();
|
Window.updatePanel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -134,4 +133,4 @@ public class MenuBar extends JMenuBar {
|
|||||||
view.add(art_sta);
|
view.add(art_sta);
|
||||||
add(view);
|
add(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package Agenda;
|
package Agenda;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
@@ -35,16 +36,14 @@ public class Window extends JFrame {
|
|||||||
private static GregorianCalendar date;
|
private static GregorianCalendar date;
|
||||||
private static Agenda agenda;
|
private static Agenda agenda;
|
||||||
private static String currentPanel = "table";
|
private static String currentPanel = "table";
|
||||||
private Applicatie.Panel ap;
|
|
||||||
|
|
||||||
public Window(Applicatie.Panel ap)
|
public Window()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Initialize window
|
* Initialize window
|
||||||
*/
|
*/
|
||||||
super("Agenda");
|
super("Agenda");
|
||||||
this.ap = ap;
|
agenda = new Agenda();
|
||||||
agenda = ap.getAgenda();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
@@ -182,7 +181,7 @@ public class Window extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void changePanel(String panel)
|
public static void changePanel(String panel)
|
||||||
{
|
{
|
||||||
currentPanel = panel;
|
currentPanel = panel;
|
||||||
@@ -232,13 +231,7 @@ public class Window extends JFrame {
|
|||||||
public void setAgenda(Agenda a)
|
public void setAgenda(Agenda a)
|
||||||
{
|
{
|
||||||
agenda = a;
|
agenda = a;
|
||||||
ap.setAgenda(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Applicatie.Panel getPanel()
|
|
||||||
{
|
|
||||||
return ap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,8 +44,4 @@ public class Action
|
|||||||
{
|
{
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Waypoint getWaypoint(){
|
|
||||||
return waypoint;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -19,17 +19,13 @@ public class ControlPanel extends JPanel
|
|||||||
private static final long serialVersionUID = 6805244250902524351L;
|
private static final long serialVersionUID = 6805244250902524351L;
|
||||||
|
|
||||||
private Panel p;
|
private Panel p;
|
||||||
private int people;
|
|
||||||
JLabel timeLabel;
|
JLabel timeLabel;
|
||||||
JLabel peopleLabel;
|
|
||||||
JLabel runningLabel;
|
|
||||||
|
|
||||||
public ControlPanel()
|
public ControlPanel()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
BoxLayout box = new BoxLayout(this, BoxLayout.X_AXIS);
|
BoxLayout box = new BoxLayout(this, BoxLayout.X_AXIS);
|
||||||
setLayout(box);
|
setLayout(box);
|
||||||
people = 0;
|
|
||||||
|
|
||||||
setPreferredSize(new Dimension(0,50));
|
setPreferredSize(new Dimension(0,50));
|
||||||
setBorder(BorderFactory.createLineBorder(new Color(180, 180, 180)));
|
setBorder(BorderFactory.createLineBorder(new Color(180, 180, 180)));
|
||||||
@@ -37,8 +33,8 @@ public class ControlPanel extends JPanel
|
|||||||
setFocusable(false);
|
setFocusable(false);
|
||||||
|
|
||||||
JPanel simulatorPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel simulatorPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
simulatorPanel.setPreferredSize(new Dimension(290,50));
|
simulatorPanel.setPreferredSize(new Dimension(350,50));
|
||||||
simulatorPanel.setMaximumSize(new Dimension(290,50));
|
simulatorPanel.setMaximumSize(new Dimension(350,50));
|
||||||
add(simulatorPanel);
|
add(simulatorPanel);
|
||||||
{
|
{
|
||||||
JLabel simulatorLabel = new JLabel("Simulator: ");
|
JLabel simulatorLabel = new JLabel("Simulator: ");
|
||||||
@@ -52,12 +48,21 @@ public class ControlPanel extends JPanel
|
|||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
p.getT().start();
|
p.getT().start();
|
||||||
p.setPlay(true);
|
|
||||||
runningLabel.setText("Simulation Started");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
simulatorPanel.add(playButton);
|
simulatorPanel.add(playButton);
|
||||||
|
|
||||||
|
JButton pauseButton = new JButton("Pause");
|
||||||
|
pauseButton.setFocusable(false);
|
||||||
|
pauseButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||||
|
pauseButton.addActionListener(new ActionListener(){
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
p.getT().stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
simulatorPanel.add(pauseButton);
|
||||||
|
|
||||||
JButton stopButton = new JButton("Stop");
|
JButton stopButton = new JButton("Stop");
|
||||||
stopButton.setFocusable(false);
|
stopButton.setFocusable(false);
|
||||||
stopButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
stopButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||||
@@ -65,8 +70,6 @@ public class ControlPanel extends JPanel
|
|||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
p.getT().stop();
|
p.getT().stop();
|
||||||
p.setPlay(false);
|
|
||||||
runningLabel.setText("Simulation Stopped");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
simulatorPanel.add(stopButton);
|
simulatorPanel.add(stopButton);
|
||||||
@@ -102,7 +105,7 @@ public class ControlPanel extends JPanel
|
|||||||
peoplePanel.setMaximumSize(new Dimension(285,50));
|
peoplePanel.setMaximumSize(new Dimension(285,50));
|
||||||
add(peoplePanel);
|
add(peoplePanel);
|
||||||
{
|
{
|
||||||
peopleLabel = new JLabel(people + " People");
|
JLabel peopleLabel = new JLabel("0/0 People");
|
||||||
peopleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
peopleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||||
peoplePanel.add(peopleLabel);
|
peoplePanel.add(peopleLabel);
|
||||||
|
|
||||||
@@ -112,7 +115,7 @@ public class ControlPanel extends JPanel
|
|||||||
peopleButton.addActionListener(new ActionListener(){
|
peopleButton.addActionListener(new ActionListener(){
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
new AddPeoplePanel(p);
|
p.addVisitors();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
peoplePanel.add(peopleButton);
|
peoplePanel.add(peopleButton);
|
||||||
@@ -125,7 +128,7 @@ public class ControlPanel extends JPanel
|
|||||||
runningPanel.setMaximumSize(new Dimension(195,50));
|
runningPanel.setMaximumSize(new Dimension(195,50));
|
||||||
add(runningPanel);
|
add(runningPanel);
|
||||||
{
|
{
|
||||||
runningLabel = new JLabel("Simulation stopped");
|
JLabel runningLabel = new JLabel("Simulation stopped");
|
||||||
runningLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
runningLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||||
runningPanel.add(runningLabel);
|
runningPanel.add(runningLabel);
|
||||||
}
|
}
|
||||||
@@ -144,7 +147,6 @@ public class ControlPanel extends JPanel
|
|||||||
|
|
||||||
public void setPeople(int people)
|
public void setPeople(int people)
|
||||||
{
|
{
|
||||||
this.people = people;
|
|
||||||
peopleLabel.setText(people + " People");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package Applicatie;
|
|||||||
|
|
||||||
public class Main
|
public class Main
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
new Window();
|
new Window();
|
||||||
|
|||||||
@@ -33,13 +33,11 @@ public class MenuBar extends JMenuBar
|
|||||||
{
|
{
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
new Agenda.Window(w.getPanel());
|
new Agenda.Window();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
file.add(agenda);
|
file.add(agenda);
|
||||||
|
|
||||||
file.addSeparator();
|
|
||||||
|
|
||||||
item = new JMenuItem("Open");
|
item = new JMenuItem("Open");
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@@ -62,12 +60,22 @@ public class MenuBar extends JMenuBar
|
|||||||
|
|
||||||
file.addSeparator();
|
file.addSeparator();
|
||||||
|
|
||||||
|
item = new JMenuItem("Load agenda");
|
||||||
|
item.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
w.getPanel().agenda.loadAgenda();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
file.add(item);
|
||||||
|
|
||||||
item = new JMenuItem("Agenda");
|
item = new JMenuItem("Agenda");
|
||||||
item.addActionListener(new ActionListener()
|
item.addActionListener(new ActionListener()
|
||||||
{
|
{
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
new Agenda.Window(w.getPanel());
|
new Agenda.Window();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
file.add(item);
|
file.add(item);
|
||||||
@@ -79,7 +87,8 @@ public class MenuBar extends JMenuBar
|
|||||||
{
|
{
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
System.exit(0);
|
w.setVisible(false);
|
||||||
|
w.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -149,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/60, this);
|
t = new Timer(1000 / 100, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPanelInfoLength()
|
public int getPanelInfoLength()
|
||||||
@@ -230,16 +230,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
return waypoints;
|
return waypoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addVisitors(ArrayList<DrawObject> entrances)
|
public void addVisitors()
|
||||||
{
|
|
||||||
|
|
||||||
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, waypoints, date));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addVisitors(int count)
|
|
||||||
{
|
{
|
||||||
ArrayList<DrawObject> entrances = new ArrayList<>();
|
ArrayList<DrawObject> entrances = new ArrayList<>();
|
||||||
for(DrawObject object : objects) {
|
for(DrawObject object : objects) {
|
||||||
@@ -248,14 +239,21 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!entrances.isEmpty()) {
|
if(!entrances.isEmpty()) {
|
||||||
for (int i = 0; i < count; i++)
|
DrawObject entrance = entrances.get((int) Math.floor(Math.random()*entrances.size()));
|
||||||
{
|
Point point = new Point((int)entrance.getPosition().getX(),(int)entrance.getPosition().getY());
|
||||||
addVisitors(entrances);
|
visitors.add(new Visitor("visitor",point, agenda, objects, waypoints, date));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
JOptionPane.showMessageDialog(this, "You don't have an entrance");
|
JOptionPane.showMessageDialog(this, "You don't have an entrance");
|
||||||
cp.setPeople(visitors.size());
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addVisitors(int count)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
addVisitors();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paintComponent(Graphics g)
|
public void paintComponent(Graphics g)
|
||||||
@@ -390,9 +388,6 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
public void clearObjects()
|
public void clearObjects()
|
||||||
{
|
{
|
||||||
objects.clear();
|
objects.clear();
|
||||||
visitors.clear();
|
|
||||||
waypoints.clear();
|
|
||||||
paths.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getLastMousePosition()
|
public Point getLastMousePosition()
|
||||||
@@ -643,6 +638,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
currentTime++;
|
currentTime++;
|
||||||
date.setTimeInMillis(date.getTimeInMillis() + 1000);
|
date.setTimeInMillis(date.getTimeInMillis() + 1000);
|
||||||
cp.setTime(formatter.format(date.getTime()));
|
cp.setTime(formatter.format(date.getTime()));
|
||||||
|
System.out.println(currentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Visitor v : visitors)
|
for (Visitor v : visitors)
|
||||||
@@ -672,7 +668,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
{
|
{
|
||||||
this.play = play;
|
this.play = play;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getPlay()
|
public boolean getPlay()
|
||||||
{
|
{
|
||||||
return play;
|
return play;
|
||||||
@@ -684,7 +680,6 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
paths.clear();
|
paths.clear();
|
||||||
objects.clear();
|
objects.clear();
|
||||||
visitors.clear();
|
|
||||||
cameraScale = 1;
|
cameraScale = 1;
|
||||||
switch (terrainIndex)
|
switch (terrainIndex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package Applicatie;
|
package Applicatie;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
import java.awt.GridLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import java.awt.event.ActionListener;
|
|||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
@@ -22,11 +20,8 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
import Agenda.AgendaStage;
|
|
||||||
import Agenda.Event;
|
|
||||||
import Objects.DrawObject;
|
import Objects.DrawObject;
|
||||||
import Objects.Path;
|
import Objects.Path;
|
||||||
import Objects.Stage;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class PropertiesPanel extends JPanel
|
public class PropertiesPanel extends JPanel
|
||||||
@@ -41,7 +36,6 @@ public class PropertiesPanel extends JPanel
|
|||||||
|
|
||||||
JLabel nameLabel;
|
JLabel nameLabel;
|
||||||
JPanel areaPanel;
|
JPanel areaPanel;
|
||||||
JPanel agendaPanel;
|
|
||||||
Component rigidArea;
|
Component rigidArea;
|
||||||
|
|
||||||
JTextField locationXField;
|
JTextField locationXField;
|
||||||
@@ -506,9 +500,12 @@ public class PropertiesPanel extends JPanel
|
|||||||
add(Box.createRigidArea(spacerDimension));
|
add(Box.createRigidArea(spacerDimension));
|
||||||
|
|
||||||
// AGENDA
|
// AGENDA
|
||||||
agendaPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel agendaPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
agendaPanel.setVisible(false);
|
JLabel agendaLabel = new JLabel("Agenda");
|
||||||
|
agendaLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
||||||
|
agendaPanel.setPreferredSize(new Dimension(200, 100));
|
||||||
|
agendaPanel.setMaximumSize(new Dimension(200, 100));
|
||||||
|
agendaPanel.add(agendaLabel);
|
||||||
add(agendaPanel);
|
add(agendaPanel);
|
||||||
|
|
||||||
enableComponents(this, false);
|
enableComponents(this, false);
|
||||||
@@ -569,19 +566,12 @@ public class PropertiesPanel extends JPanel
|
|||||||
nameLabel.setText("No Selection");
|
nameLabel.setText("No Selection");
|
||||||
areaPanel.setVisible(false);
|
areaPanel.setVisible(false);
|
||||||
rigidArea.setVisible(false);
|
rigidArea.setVisible(false);
|
||||||
agendaPanel.setVisible(false);
|
|
||||||
agendaPanel.removeAll();
|
|
||||||
agendaPanel.validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillFields()
|
private void fillFields()
|
||||||
{
|
{
|
||||||
|
|
||||||
nameLabel.setText(selectedObject.getName());
|
nameLabel.setText(selectedObject.getName());
|
||||||
|
|
||||||
agendaPanel.removeAll();
|
|
||||||
agendaPanel.validate();
|
|
||||||
agendaPanel.setVisible(false);
|
|
||||||
|
|
||||||
locationXField.setText(Math.round(selectedObject.getPosition().getX()) + "");
|
locationXField.setText(Math.round(selectedObject.getPosition().getX()) + "");
|
||||||
locationYField.setText(Math.round(selectedObject.getPosition().getY()) + "");
|
locationYField.setText(Math.round(selectedObject.getPosition().getY()) + "");
|
||||||
@@ -592,31 +582,7 @@ public class PropertiesPanel extends JPanel
|
|||||||
areaBottomField.setText(selectedObject.getAreaBottom() + "");
|
areaBottomField.setText(selectedObject.getAreaBottom() + "");
|
||||||
areaLeftField.setText(selectedObject.getAreaLeft() + "");
|
areaLeftField.setText(selectedObject.getAreaLeft() + "");
|
||||||
areaRightField.setText(selectedObject.getAreaRight() + "");
|
areaRightField.setText(selectedObject.getAreaRight() + "");
|
||||||
|
|
||||||
if(selectedObject instanceof Stage)
|
|
||||||
{
|
|
||||||
|
|
||||||
agendaPanel.setVisible(true);
|
|
||||||
JLabel agendaLabel = new JLabel("Agenda");
|
|
||||||
agendaLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
|
||||||
agendaPanel.add(agendaLabel);
|
|
||||||
|
|
||||||
AgendaStage st = ((Stage) selectedObject).getStage();
|
|
||||||
nameLabel.setText("Stage: " + st.getName());
|
|
||||||
ArrayList<Event> events = p.getAgenda().eventsForStage(st);
|
|
||||||
agendaPanel.setPreferredSize(new Dimension(200, ((30*events.size())+50) ));
|
|
||||||
agendaPanel.setMaximumSize(new Dimension(200, ((30*events.size())+50) ));
|
|
||||||
for(Event e : events)
|
|
||||||
{
|
|
||||||
JPanel eventPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
||||||
JLabel eventLabel = new JLabel(e.getEventName() + " - " + e.getArtist().getName());
|
|
||||||
eventLabel.setFont(new Font("Segoe UI", Font.PLAIN, 15));
|
|
||||||
eventPanel.setPreferredSize(new Dimension(200, 30));
|
|
||||||
eventPanel.setMaximumSize(new Dimension(200, 30));
|
|
||||||
eventPanel.add(eventLabel);
|
|
||||||
agendaPanel.add(eventPanel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPanel(Panel p)
|
public void setPanel(Panel p)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package Applicatie;
|
package Applicatie;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -8,62 +7,48 @@ import java.io.IOException;
|
|||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
import Agenda.Agenda;
|
|
||||||
import Objects.DrawObject;
|
import Objects.DrawObject;
|
||||||
import Objects.Path;
|
|
||||||
|
|
||||||
public class SaveLoad
|
public class SaveLoad {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public static void save(Panel panel)
|
public static void save(Panel panel)
|
||||||
{
|
{
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
|
|
||||||
fileChooser.setFileFilter(new FileFilter()
|
fileChooser.setFileFilter(new FileFilter() {
|
||||||
{
|
@Override
|
||||||
@Override
|
public boolean accept(File pathname) {
|
||||||
public boolean accept(File pathname)
|
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
||||||
{
|
{
|
||||||
if (pathname.isFile() && pathname.getName().endsWith(".agn"))
|
return true;
|
||||||
{
|
}else if(pathname.isDirectory()){return true;}else{return false;}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else if (pathname.isDirectory())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription()
|
|
||||||
{
|
|
||||||
return ".agn";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return ".agn";
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
fileChooser.setDialogTitle("Choose save location");
|
fileChooser.setDialogTitle("Choose save location");
|
||||||
int userSelection = fileChooser.showSaveDialog(null);
|
int userSelection = fileChooser.showSaveDialog(null);
|
||||||
|
|
||||||
if (userSelection == JFileChooser.APPROVE_OPTION)
|
if(userSelection == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
File file = fileChooser.getSelectedFile();
|
File file = fileChooser.getSelectedFile();
|
||||||
if (!file.getName().endsWith(".agn"))
|
if(!file.getName().endsWith(".agn"))
|
||||||
{
|
{
|
||||||
file = new File(file.getAbsolutePath() + ".agn");
|
file = new File(file.getAbsolutePath() + ".agn");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.exists())
|
if(file.exists())
|
||||||
{
|
{
|
||||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you want to overwrite: " + file.getName(), "Overwrite", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to overwrite: " + file.getName(), "Overwrite", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||||
{
|
{
|
||||||
saveTerrain(file, panel);
|
saveTerrain(file, panel);
|
||||||
}
|
}
|
||||||
@@ -74,70 +59,49 @@ public class SaveLoad
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void saveTerrain(File file, Panel panel) {
|
||||||
|
|
||||||
public static void saveTerrain(File file, Panel panel)
|
try {
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FileOutputStream fos = new FileOutputStream(file);
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
oos.writeObject(panel.getAgenda());
|
for (DrawObject object : panel.objects) {
|
||||||
for (DrawObject object : panel.objects)
|
|
||||||
{
|
|
||||||
object.setSelected(false);
|
|
||||||
oos.writeObject(object);
|
oos.writeObject(object);
|
||||||
}
|
}
|
||||||
for(Path p : panel.paths)
|
|
||||||
{
|
|
||||||
oos.writeObject(p);
|
|
||||||
}
|
|
||||||
oos.close();
|
oos.close();
|
||||||
JOptionPane.showMessageDialog(null, "Saved succesfully");
|
JOptionPane.showMessageDialog(null, "Saved succesfully");
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load(Panel panel)
|
public static void load(Panel panel)
|
||||||
{
|
{
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
fileChooser.setFileFilter(new FileFilter()
|
fileChooser.setFileFilter(new FileFilter() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File pathname)
|
public boolean accept(File pathname) {
|
||||||
{
|
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
||||||
if (pathname.isFile() && pathname.getName().endsWith(".agn"))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}else if(pathname.isDirectory()){return true;}else{return false;}
|
||||||
else if (pathname.isDirectory())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
|
||||||
return ".agn";
|
return ".agn";
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fileChooser.setDialogTitle("Choose file");
|
fileChooser.setDialogTitle("Choose file");
|
||||||
int userSelection = fileChooser.showOpenDialog(null);
|
int userSelection = fileChooser.showOpenDialog(null);
|
||||||
|
|
||||||
if (userSelection == JFileChooser.APPROVE_OPTION)
|
if(userSelection == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
File file = fileChooser.getSelectedFile();
|
File file = fileChooser.getSelectedFile();
|
||||||
if (!file.exists())
|
if(!file.exists())
|
||||||
{
|
{
|
||||||
JOptionPane.showMessageDialog(null, "This file does not exist: " + file.getName());
|
JOptionPane.showMessageDialog(null, "This file does not exist: " + file.getName());
|
||||||
}
|
}
|
||||||
@@ -148,54 +112,33 @@ public class SaveLoad
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fillTerrain(File file, Panel panel)
|
|
||||||
{
|
public static void fillTerrain(File file, Panel panel) {
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
ObjectInputStream ois = null;
|
ObjectInputStream ois = null;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
|
|
||||||
fis = new FileInputStream(file);
|
fis = new FileInputStream(file);
|
||||||
ois = new ObjectInputStream(fis);
|
ois = new ObjectInputStream(fis);
|
||||||
|
|
||||||
Object object;
|
Object object;
|
||||||
Agenda a = (Agenda) ois.readObject();
|
object = ois.readObject();
|
||||||
panel.setAgenda(a);
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
object = ois.readObject();
|
|
||||||
panel.clearObjects();
|
panel.clearObjects();
|
||||||
while (object != null)
|
while (object != null) {
|
||||||
{
|
panel.objects.add((DrawObject) object);
|
||||||
if (object instanceof Waypoint)
|
|
||||||
{
|
|
||||||
panel.addWaypoint((Waypoint) object);
|
|
||||||
panel.objects.add((DrawObject) object);
|
|
||||||
}
|
|
||||||
if (object instanceof Path)
|
|
||||||
{
|
|
||||||
Path p = (Path) object;
|
|
||||||
p.updateImage();
|
|
||||||
panel.paths.add((Path) object);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
panel.objects.add((DrawObject) object);
|
|
||||||
}
|
|
||||||
object = ois.readObject();
|
object = ois.readObject();
|
||||||
}
|
}
|
||||||
|
} catch (EOFException e) {
|
||||||
}
|
}
|
||||||
catch (EOFException e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
panel.update();
|
panel.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,20 +5,16 @@ 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;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import Agenda.Agenda;
|
import Agenda.Agenda;
|
||||||
import Agenda.Event;
|
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
|
||||||
{
|
{
|
||||||
@@ -31,28 +27,23 @@ 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, ArrayList<DrawObject> objects, ArrayList<Waypoint> waypoints, GregorianCalendar date)
|
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects)
|
||||||
|
|
||||||
{
|
{
|
||||||
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());
|
||||||
target = 1;
|
target = 1;
|
||||||
finalTarget = 0;
|
finalTarget = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2)
|
public void draw(Graphics2D g2)
|
||||||
@@ -87,16 +78,15 @@ public class Visitor
|
|||||||
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths, Panel panel)
|
public void update(ArrayList<DrawObject> objects, int currentTime, 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())
|
||||||
{
|
{
|
||||||
this.finalTarget = a.getWaypoint().getSelf();
|
target = a.getTargetObject();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// moveToTarget(target, objects, visitors, paths);
|
// moveToTarget(target, objects, visitors, paths);
|
||||||
move(target, panel);
|
move(target, panel);
|
||||||
}
|
}
|
||||||
@@ -119,6 +109,7 @@ public class Visitor
|
|||||||
{
|
{
|
||||||
rotation += 0.15;
|
rotation += 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2D oldPosition = position;
|
Point2D oldPosition = position;
|
||||||
|
|
||||||
// face direction
|
// face direction
|
||||||
@@ -137,10 +128,8 @@ public class Visitor
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (hitTest(object))
|
||||||
if (hasCollisionDO(object))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,25 +138,24 @@ public class Visitor
|
|||||||
position = oldPosition;
|
position = oldPosition;
|
||||||
rotation += 0.2;
|
rotation += 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkIfOnWaypoint(panel))
|
if (checkIfOnWaypoint(panel))
|
||||||
{
|
{
|
||||||
|
|
||||||
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())
|
||||||
if (finalTarget != target)
|
|
||||||
{
|
{
|
||||||
for (Map.Entry<Integer, int[]> e : options.entrySet())
|
for (int i : e.getValue())
|
||||||
{
|
{
|
||||||
// System.out.println("KEY: " + e.getKey());
|
System.out.println("KEY:" + e.getKey());
|
||||||
for (int i : e.getValue())
|
System.out.println("VAL:" + i);
|
||||||
{
|
System.out.println("TAR: " + target);
|
||||||
// System.out.println("VAL: " + i);
|
|
||||||
|
|
||||||
|
System.out.println("____________");
|
||||||
|
if (finalTarget != target)
|
||||||
|
{
|
||||||
if (finalTarget == i && e.getKey() == target)
|
if (finalTarget == i && e.getKey() == target)
|
||||||
{
|
{
|
||||||
target = finalTarget;
|
target = finalTarget;
|
||||||
@@ -179,10 +167,10 @@ public class Visitor
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkIfOnWaypoint(Panel panel)
|
public boolean checkIfOnWaypoint(Panel panel)
|
||||||
@@ -243,17 +231,15 @@ public class Visitor
|
|||||||
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 (hitTestVisitor(object) && object != this)
|
||||||
if (hasCollision(object) && object != this)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
possible = false;
|
possible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,14 +334,14 @@ public class Visitor
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@@ -368,7 +354,6 @@ public class Visitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
|
||||||
public void fillActions()
|
public void fillActions()
|
||||||
{
|
{
|
||||||
int startTime = 540;
|
int startTime = 540;
|
||||||
@@ -381,105 +366,61 @@ public class Visitor
|
|||||||
{
|
{
|
||||||
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)
|
||||||
}
|
|
||||||
}
|
|
||||||
int totalPopularity = 0;
|
|
||||||
for (Event ev : posEvents)
|
|
||||||
{
|
|
||||||
totalPopularity += ev.getExpectedPopularity();
|
|
||||||
}
|
|
||||||
|
|
||||||
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(e.getStage().getName()))
|
||||||
{
|
{
|
||||||
if (d.getFileName().equals("stage"))
|
position = d.getPosition();
|
||||||
{
|
targetStage = d;
|
||||||
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, targetStage));
|
||||||
actions.add(new Action(position, startTime, randomtime, 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 (position != null)
|
||||||
if (toilets.size() != 0)
|
|
||||||
{
|
{
|
||||||
int r = (int) Math.floor(Math.random() * toilets.size());
|
actions.add(new Action(position, startTime, 35, targetDrawobj));
|
||||||
position = toilets.get(r).getPosition();
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -487,71 +428,35 @@ public class Visitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Waypoint getClosedWaypoint(Point2D point)
|
public int convertMinutesToHours(int startTime)
|
||||||
{
|
{
|
||||||
Waypoint waypoint = null;
|
int time = 0;
|
||||||
int distance = 10000;
|
int hours = startTime / 60;
|
||||||
for (Waypoint w : waypoints)
|
int minutes = startTime % 60;
|
||||||
{
|
time = (hours * 100) + minutes;
|
||||||
if (w.getPosition().distance(point) < distance)
|
return time;
|
||||||
{
|
|
||||||
|
|
||||||
waypoint = w;
|
|
||||||
distance = (int) w.getPosition().distance(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return waypoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCollisionDO(DrawObject object)
|
public int getEndX()
|
||||||
{
|
|
||||||
|
|
||||||
Image image = Images.getImage(filename);
|
|
||||||
Image image2 = Images.getImage(object.getFileName());
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
Image image = Images.getImage(filename);
|
Image image = Images.getImage(filename);
|
||||||
Rectangle a = new Rectangle((int) position.getX(), (int) position.getY(), image.getWidth(null), image.getHeight(null));
|
return (int) (position.getX() + image.getWidth(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 int getEndY()
|
||||||
|
{
|
||||||
|
Image image = Images.getImage(filename);
|
||||||
|
return (int) (position.getY() + image.getHeight(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,11 +13,6 @@ public class Waypoint extends DrawObject
|
|||||||
super("waypoint", position);
|
super("waypoint", position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point2D getAccuratePoint()
|
|
||||||
{
|
|
||||||
return new Point2D.Double(super.getPosition().getX() + (super.getImageRectangle().getWidth()/2), super.getPosition().getY() + super.getImageRectangle().getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
@@ -41,6 +36,7 @@ public class Waypoint extends DrawObject
|
|||||||
|
|
||||||
public void setSelf(int self)
|
public void setSelf(int self)
|
||||||
{
|
{
|
||||||
|
System.out.println(self);
|
||||||
this.self = self;
|
this.self = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,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);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.awt.Color;
|
|||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
@@ -15,6 +16,7 @@ import Applicatie.Waypoint;
|
|||||||
import Applicatie.WaypointPopup;
|
import Applicatie.WaypointPopup;
|
||||||
import Objects.DrawObject;
|
import Objects.DrawObject;
|
||||||
import Objects.Path;
|
import Objects.Path;
|
||||||
|
import Objects.Entrance;
|
||||||
|
|
||||||
public class Mouse extends MouseAdapter
|
public class Mouse extends MouseAdapter
|
||||||
{
|
{
|
||||||
@@ -33,126 +35,126 @@ 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.getPlay())
|
if(!panel.getPlay())
|
||||||
{
|
{
|
||||||
if (!panel.getClickedOption().equals("Path"))
|
if (!panel.getClickedOption().equals("Path"))
|
||||||
{
|
|
||||||
if (e.getY() < 150)
|
|
||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
@@ -170,15 +172,8 @@ public class Mouse extends MouseAdapter
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (panel.getDragObject() instanceof Waypoint == false)
|
panel.getDragObject().setPosition(panel.getSelectionPosition());
|
||||||
{
|
panel.getDragObject().setRectangleColor(Color.BLACK);
|
||||||
panel.getDragObject().setPosition(panel.getSelectionPosition());
|
|
||||||
panel.getDragObject().setRectangleColor(Color.BLACK);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
panel.getDragObject().setRectangleColor(Color.BLACK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
panel.setSelectionPosition(panel.getSelectedObject().getPosition());
|
panel.setSelectionPosition(panel.getSelectedObject().getPosition());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import java.io.Serializable;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import Applicatie.Images;
|
import Applicatie.Images;
|
||||||
import Applicatie.Panel;
|
|
||||||
|
|
||||||
public abstract class DrawObject implements Serializable
|
public abstract class DrawObject implements Serializable
|
||||||
{
|
{
|
||||||
@@ -233,30 +232,13 @@ public abstract class DrawObject implements Serializable
|
|||||||
|
|
||||||
public void setPosition(Point2D position)
|
public void setPosition(Point2D position)
|
||||||
{
|
{
|
||||||
if(position.getX() < -Panel.getFieldWidth()/2)
|
|
||||||
{
|
|
||||||
position.setLocation(-Panel.getFieldWidth()/2, position.getY());
|
|
||||||
}
|
|
||||||
if(position.getY() < -Panel.getFieldHeight()/2)
|
|
||||||
{
|
|
||||||
position.setLocation(position.getX(), -Panel.getFieldHeight()/2);
|
|
||||||
}
|
|
||||||
if(position.getX() > Panel.getFieldWidth()/2 - width)
|
|
||||||
{
|
|
||||||
position.setLocation(Panel.getFieldWidth()/2-width, position.getY());
|
|
||||||
}
|
|
||||||
if(position.getY() > Panel.getFieldHeight()/2 - height)
|
|
||||||
{
|
|
||||||
position.setLocation(position.getX(), Panel.getFieldHeight()/2-height);
|
|
||||||
}
|
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
public void setPosition(Point2D position, boolean b)
|
public void setPosition(Point2D position, boolean b)
|
||||||
{
|
{
|
||||||
setPosition(position);
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getRotation()
|
public double getRotation()
|
||||||
{
|
{
|
||||||
return rotation;
|
return rotation;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -24,15 +23,13 @@ import Applicatie.Waypoint;
|
|||||||
* @author Wesley de Hek
|
* @author Wesley de Hek
|
||||||
* @version 1.2
|
* @version 1.2
|
||||||
*/
|
*/
|
||||||
public class Path implements Serializable
|
public class Path
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 5345485798486018597L;
|
|
||||||
|
|
||||||
private ArrayList<Point2D> points;
|
private ArrayList<Point2D> points;
|
||||||
private ArrayList<Shape> lines;
|
private ArrayList<Shape> lines;
|
||||||
private Point2D tempPoint;
|
private Point2D tempPoint;
|
||||||
public transient BufferedImage pathBackground = null;;
|
private BufferedImage pathBackground;
|
||||||
private ArrayList<Waypoint> waypoints;
|
private ArrayList<Waypoint> waypoints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,18 +49,6 @@ public class Path implements Serializable
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateImage()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pathBackground = ImageIO.read(new File("images/newPath.png"));
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the path.
|
* Draws the path.
|
||||||
|
|||||||
|
After Width: | Height: | Size: 494 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 |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 14 KiB |