53 Commits
Author SHA1 Message Date
Yorick 719d58aae9 done 2015-04-09 01:55:12 +02:00
Yorick 4897a9440b ohgodwhy 2015-04-09 01:30:38 +02:00
Yorick 2e947589be merge 2015-04-09 00:56:42 +02:00
Remco a6f32b5739 Editing disabled while running simulator 2015-04-09 00:51:18 +02:00
Yorick 6178311c4b Merge remote-tracking branch 'origin/kenneth' into develop 2015-04-09 00:35:30 +02:00
Yorick 920fd8117e KUT 2015-04-09 00:33:18 +02:00
kennyboy55 8a92a7a571 Added Stages to save file.
Remove selection from save.
2015-04-08 22:42:40 +02:00
kennyboy55 1563368bf8 removed pause button 2015-04-08 22:06:50 +02:00
kennyboy55 eab4aedc1d Added text to button actions 2015-04-08 21:53:18 +02:00
Yorick be53c1f138 kaas kenneth 2015-04-08 21:47:12 +02:00
Yorick a7d811f956 Merge remote-tracking branch 'origin/kenneth' into develop 2015-04-08 21:46:42 +02:00
Yorick f2f0b36d0e Load waypoints from filez 2015-04-08 21:45:27 +02:00
kennyboy55 04fa453e49 Added agenda stuff 2015-04-08 21:45:03 +02:00
Remco 9d88f92a98 Deleted useless exclamation points 2015-04-08 21:38:04 +02:00
Yorick d3e9b578eb Merge banan dev 2015-04-08 21:37:48 +02:00
Yorick 8ba874bec6 visitors kinda working? 2015-04-08 21:29:17 +02:00
Wesley 4c11d4ad2f fixed stuff
lol
2015-04-08 21:25:08 +02:00
guusvdongen 911714f9b5 Update Visitor.java 2015-04-08 21:15:45 +02:00
Wesley 77dae9741e added addPeoplePanel 2015-04-08 21:07:59 +02:00
Yorick 19f48ad3e9 Merge remote-tracking branch 'origin/kenneth' into develop 2015-04-08 21:03:46 +02:00
Yorick 26265b5a3e Waypoint move 2015-04-08 21:03:29 +02:00
kennyboy55 457da54a5c Fixed agenda module sync 2015-04-08 21:01:13 +02:00
kennyboy55 c3973cc4e4 Fixed stuff 2015-04-08 20:57:06 +02:00
kennyboy55 d0baf5673f Merge branch 'kenneth' of https://github.com/ProjectgroepA4/FestivalPlanner into kenneth
Conflicts:
	Applicatie/Panel.java
	Applicatie/Visitor.java
	Applicatie/WaypointPopup.java
	Listeners/Mouse.java
2015-04-08 20:55:44 +02:00
Yorick 8167fec369 WOOOOOOOOOOOOOOOOOOOO 2015-04-08 20:31:18 +02:00
unknown 254167ba15 print out line op 2015-04-08 17:40:22 +02:00
Yorick bdcc40f00f Merge branch 'develop' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-04-08 17:32:28 +02:00
Yorick d0c0b16585 kaas 2015-04-08 17:32:10 +02:00
Remco 6f265063b4 Edited Waypointpopup 2015-04-08 17:31:06 +02:00
unknown b8a7d9c02d change 2015-04-08 17:24:29 +02:00
Yorick 89036d27af Actions is nul wtf 2015-04-08 17:17:53 +02:00
Yorick b5cf44b44c woo 2015-04-08 16:46:02 +02:00
kennyboy55 7a6bca5ed3 Merge branch 'kenneth' of https://github.com/ProjectgroepA4/FestivalPlanner into kenneth 2015-04-08 16:39:23 +02:00
kennyboy55 9d853babdc Combined Agenda 2015-04-08 16:38:55 +02:00
unknown 69c05da3fd laatste versie 2015-04-08 15:56:46 +02:00
kennyboy55 b50c4d2c33 Objects can no longer move outside field 2015-04-08 13:51:01 +02:00
kennyboy55 a360286c48 Stuff 2015-04-08 13:16:12 +02:00
unknown c2cb07cf3e ok 2015-04-08 13:11:16 +02:00
unknown 90ca17e28a ok 2015-04-08 12:13:39 +02:00
unknown c29ccec789 ok 2015-04-07 14:58:47 +02:00
unknown 0535d98427 ok 2015-04-07 14:29:24 +02:00
unknown a2110d3e58 ok 2015-04-07 12:36:14 +02:00
unknown d8efbc8616 laatste update 2015-03-26 12:05:33 +01:00
unknown b9d42cd4eb new 2015-03-24 13:47:45 +01:00
unknown ca90d98d9a fix 2015-03-17 12:58:20 +01:00
unknown a3479fc37a fix 2015-03-17 12:35:57 +01:00
unknown 2f53d1353f added stuff 2015-03-17 12:23:43 +01:00
guusvdongen 87bf6d9295 festivaldemo methodes
Tekenobject & podium moeten Serializable worden.
In tekenobject moet de image variablen een String filepath worden.
Dan kun je moet je voor elke methode in tekenobject waar je die image voor nodig had (Image image = new ImageIcon(filepath).getImage();) doen. Dit komt, omdat een image niet serializable is :(
2015-03-12 18:18:03 +01:00
guusvdongen a89feaaaab Delete selection.png 2015-03-12 18:14:00 +01:00
guusvdongen df02d793eb Delete grass.jpg 2015-03-12 18:13:42 +01:00
guusvdongen a00ccbe085 Delete commons-lang3-3.3.2.jar 2015-03-12 18:13:27 +01:00
guusvdongen 835d126d80 Delete README.md 2015-03-12 18:13:22 +01:00
guusvdongen dd7893375e Agenda load/save fix 2015-03-12 18:12:25 +01:00
29 changed files with 555 additions and 309 deletions
+19 -3
View File
@@ -51,7 +51,20 @@ public class Agenda implements Serializable {
{
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()
{
JFileChooser fileChooser = new JFileChooser();
@@ -179,7 +192,7 @@ public class Agenda implements Serializable {
{
boolean exists = false;
String name = e.getStage().getName();
for (AgendaStage s : stages)
for (Stage s : stages)
{
if ( s.getName().equals(name) ) {
exists = true;
@@ -202,7 +215,8 @@ public class Agenda implements Serializable {
} catch (IOException e) {
e.printStackTrace();
}
}
}
*/
public void clearAgenda()
{
@@ -211,10 +225,12 @@ public class Agenda implements Serializable {
artists.clear();
}
/*
public void fillAllLists()
{
loadAgenda();
fillStages();
fillArtists();
}
}
*/
}
+1 -1
View File
@@ -19,7 +19,7 @@ public class EditArtistPanel extends JFrame {
public EditArtistPanel(Agenda agenda, Artist art, TabbedPane tab)
{
super("Artist editscreen!");
super("Artist editscreen");
setDefaultCloseOperation(HIDE_ON_CLOSE);
JPanel content = new JPanel(new BorderLayout());
JPanel south = new JPanel(new FlowLayout());
+1 -1
View File
@@ -24,7 +24,7 @@ public class EditEventPanel extends JFrame{
public EditEventPanel(Agenda agenda, Event e, TabbedPane tab)
{
super("Event editscreen!");
super("Event editscreen");
setDefaultCloseOperation(HIDE_ON_CLOSE);
JPanel content = new JPanel(new BorderLayout());
JPanel south = new JPanel(new FlowLayout());
+1 -1
View File
@@ -20,7 +20,7 @@ public class EditStagePanel extends JFrame{
public EditStagePanel(Agenda agenda, AgendaStage sta)
{
super("Stage editscreen!");
super("Stage editscreen");
setDefaultCloseOperation(HIDE_ON_CLOSE);
JPanel content = new JPanel(new BorderLayout());
JPanel south = new JPanel(new FlowLayout());
+4 -4
View File
@@ -34,8 +34,8 @@ public class Event implements Serializable {
endHour, endMinute);
this.startHour = startHour;
this.startMinute = startMinute;
this.stopHour = stopHour;
this.stopMinute = stopMinute;
this.stopHour = endHour;
this.stopMinute = endMinute;
this.stage = stage;
this.artist = artist;
this.description = description;
@@ -55,11 +55,11 @@ public class Event implements Serializable {
}
public int getStart(){
return (startHour * 100) + startMinute;
return (startHour * 60) + startMinute;
}
public int getStop(){
return (stopHour * 100) + stopMinute;
return (stopHour * 60) + stopMinute;
}
public int getStopHour(){
+4 -3
View File
@@ -63,7 +63,8 @@ public class MenuBar extends JMenuBar {
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
open.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
w.getAgenda().loadAgenda();
Applicatie.SaveLoad.load(w.getPanel());
w.setAgenda(w.getPanel().getAgenda());
Window.updatePanel();
}
});
@@ -72,7 +73,7 @@ public class MenuBar extends JMenuBar {
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
w.getAgenda().saveAgenda();
Applicatie.SaveLoad.save(w.getPanel());
Window.updatePanel();
}
});
@@ -133,4 +134,4 @@ public class MenuBar extends JMenuBar {
view.add(art_sta);
add(view);
}
}
}
+12 -5
View File
@@ -1,6 +1,5 @@
package Agenda;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@@ -36,14 +35,16 @@ public class Window extends JFrame {
private static GregorianCalendar date;
private static Agenda agenda;
private static String currentPanel = "table";
private Applicatie.Panel ap;
public Window()
public Window(Applicatie.Panel ap)
{
/*
* Initialize window
*/
super("Agenda");
agenda = new Agenda();
this.ap = ap;
agenda = ap.getAgenda();
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@@ -181,7 +182,7 @@ public class Window extends JFrame {
}
});
}
public static void changePanel(String panel)
{
currentPanel = panel;
@@ -231,7 +232,13 @@ public class Window extends JFrame {
public void setAgenda(Agenda a)
{
agenda = a;
ap.setAgenda(a);
}
public Applicatie.Panel getPanel()
{
return ap;
}
}
}
+7 -1
View File
@@ -11,13 +11,15 @@ public class Action
private int starttime;
private int duration;
private DrawObject target;
private Waypoint waypoint;
public Action(Point2D position, int starttime, int duration, DrawObject tar)
public Action(Point2D position, int starttime, int duration, DrawObject tar, Waypoint waypoint)
{
this.position = position;
this.starttime = starttime;
this.duration = duration;
this.target = tar;
this.waypoint = waypoint;
}
public Point2D getPosition()
@@ -44,4 +46,8 @@ public class Action
{
return duration;
}
public Waypoint getWaypoint(){
return waypoint;
}
}
+15 -17
View File
@@ -19,13 +19,17 @@ public class ControlPanel extends JPanel
private static final long serialVersionUID = 6805244250902524351L;
private Panel p;
private int people;
JLabel timeLabel;
JLabel peopleLabel;
JLabel runningLabel;
public ControlPanel()
{
super();
BoxLayout box = new BoxLayout(this, BoxLayout.X_AXIS);
setLayout(box);
people = 0;
setPreferredSize(new Dimension(0,50));
setBorder(BorderFactory.createLineBorder(new Color(180, 180, 180)));
@@ -33,8 +37,8 @@ public class ControlPanel extends JPanel
setFocusable(false);
JPanel simulatorPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
simulatorPanel.setPreferredSize(new Dimension(350,50));
simulatorPanel.setMaximumSize(new Dimension(350,50));
simulatorPanel.setPreferredSize(new Dimension(290,50));
simulatorPanel.setMaximumSize(new Dimension(290,50));
add(simulatorPanel);
{
JLabel simulatorLabel = new JLabel("Simulator: ");
@@ -48,21 +52,12 @@ public class ControlPanel extends JPanel
public void actionPerformed(ActionEvent e)
{
p.getT().start();
p.setPlay(true);
runningLabel.setText("Simulation Started");
}
});
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");
stopButton.setFocusable(false);
stopButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
@@ -70,6 +65,8 @@ public class ControlPanel extends JPanel
public void actionPerformed(ActionEvent e)
{
p.getT().stop();
p.setPlay(false);
runningLabel.setText("Simulation Stopped");
}
});
simulatorPanel.add(stopButton);
@@ -105,7 +102,7 @@ public class ControlPanel extends JPanel
peoplePanel.setMaximumSize(new Dimension(285,50));
add(peoplePanel);
{
JLabel peopleLabel = new JLabel("0/0 People");
peopleLabel = new JLabel(people + " People");
peopleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
peoplePanel.add(peopleLabel);
@@ -115,7 +112,7 @@ public class ControlPanel extends JPanel
peopleButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
p.addVisitors();
new AddPeoplePanel(p);
}
});
peoplePanel.add(peopleButton);
@@ -128,7 +125,7 @@ public class ControlPanel extends JPanel
runningPanel.setMaximumSize(new Dimension(195,50));
add(runningPanel);
{
JLabel runningLabel = new JLabel("Simulation stopped");
runningLabel = new JLabel("Simulation stopped");
runningLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
runningPanel.add(runningLabel);
}
@@ -147,6 +144,7 @@ public class ControlPanel extends JPanel
public void setPeople(int people)
{
this.people = people;
peopleLabel.setText(people + " People");
}
}
-1
View File
@@ -2,7 +2,6 @@ package Applicatie;
public class Main
{
public static void main(String[] args)
{
new Window();
+5 -14
View File
@@ -33,11 +33,13 @@ public class MenuBar extends JMenuBar
{
public void actionPerformed(ActionEvent e)
{
new Agenda.Window();
new Agenda.Window(w.getPanel());
}
});
file.add(agenda);
file.addSeparator();
item = new JMenuItem("Open");
item.addActionListener(new ActionListener() {
@@ -60,22 +62,12 @@ public class MenuBar extends JMenuBar
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.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new Agenda.Window();
new Agenda.Window(w.getPanel());
}
});
file.add(item);
@@ -87,8 +79,7 @@ public class MenuBar extends JMenuBar
{
public void actionPerformed(ActionEvent e)
{
w.setVisible(false);
w.dispose();
System.exit(0);
}
});
+22 -17
View File
@@ -149,7 +149,7 @@ public class Panel extends JPanel implements ActionListener
addMouseWheelListener(new MouseWheel(this));
addFocusListener(new WindowFocusListener(this));
t = new Timer(1000 / 100, this);
t = new Timer(1000 / 5000, this);
}
public int getPanelInfoLength()
@@ -230,7 +230,16 @@ public class Panel extends JPanel implements ActionListener
return waypoints;
}
public void addVisitors()
public void addVisitors(ArrayList<DrawObject> entrances)
{
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<>();
for(DrawObject object : objects) {
@@ -239,21 +248,14 @@ public class Panel extends JPanel implements ActionListener
}
}
if(!entrances.isEmpty()) {
DrawObject entrance = entrances.get((int) Math.floor(Math.random()*entrances.size()));
Point point = new Point((int)entrance.getPosition().getX(),(int)entrance.getPosition().getY());
visitors.add(new Visitor("visitor",point, agenda, objects, waypoints, date));
for (int i = 0; i < count; i++)
{
addVisitors(entrances);
}
}
else {
else
JOptionPane.showMessageDialog(this, "You don't have an entrance");
}
}
public void addVisitors(int count)
{
for (int i = 0; i < count; i++)
{
addVisitors();
}
cp.setPeople(visitors.size());
}
public void paintComponent(Graphics g)
@@ -388,6 +390,9 @@ public class Panel extends JPanel implements ActionListener
public void clearObjects()
{
objects.clear();
visitors.clear();
waypoints.clear();
paths.clear();
}
public Point getLastMousePosition()
@@ -638,7 +643,6 @@ public class Panel extends JPanel implements ActionListener
currentTime++;
date.setTimeInMillis(date.getTimeInMillis() + 1000);
cp.setTime(formatter.format(date.getTime()));
System.out.println(currentTime);
}
for (Visitor v : visitors)
@@ -668,7 +672,7 @@ public class Panel extends JPanel implements ActionListener
{
this.play = play;
}
public boolean getPlay()
{
return play;
@@ -680,6 +684,7 @@ public class Panel extends JPanel implements ActionListener
this.height = height;
paths.clear();
objects.clear();
visitors.clear();
cameraScale = 1;
switch (terrainIndex)
{
-2
View File
@@ -1,9 +1,7 @@
package Applicatie;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+41 -7
View File
@@ -11,6 +11,8 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.BorderFactory;
import javax.swing.Box;
@@ -20,8 +22,11 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import Agenda.AgendaStage;
import Agenda.Event;
import Objects.DrawObject;
import Objects.Path;
import Objects.Stage;
@SuppressWarnings("serial")
public class PropertiesPanel extends JPanel
@@ -36,6 +41,7 @@ public class PropertiesPanel extends JPanel
JLabel nameLabel;
JPanel areaPanel;
JPanel agendaPanel;
Component rigidArea;
JTextField locationXField;
@@ -500,12 +506,9 @@ public class PropertiesPanel extends JPanel
add(Box.createRigidArea(spacerDimension));
// AGENDA
JPanel agendaPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
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);
agendaPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
agendaPanel.setVisible(false);
add(agendaPanel);
enableComponents(this, false);
@@ -566,12 +569,19 @@ public class PropertiesPanel extends JPanel
nameLabel.setText("No Selection");
areaPanel.setVisible(false);
rigidArea.setVisible(false);
agendaPanel.setVisible(false);
agendaPanel.removeAll();
agendaPanel.validate();
}
private void fillFields()
{
nameLabel.setText(selectedObject.getName());
agendaPanel.removeAll();
agendaPanel.validate();
agendaPanel.setVisible(false);
locationXField.setText(Math.round(selectedObject.getPosition().getX()) + "");
locationYField.setText(Math.round(selectedObject.getPosition().getY()) + "");
@@ -582,7 +592,31 @@ public class PropertiesPanel extends JPanel
areaBottomField.setText(selectedObject.getAreaBottom() + "");
areaLeftField.setText(selectedObject.getAreaLeft() + "");
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)
+111 -54
View File
@@ -1,4 +1,5 @@
package Applicatie;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
@@ -7,48 +8,62 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import Agenda.Agenda;
import Objects.DrawObject;
import Objects.Path;
public class SaveLoad {
public class SaveLoad
{
public static void save(Panel panel)
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new FileFilter() {
@Override
public boolean accept(File pathname) {
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
{
return true;
}else if(pathname.isDirectory()){return true;}else{return false;}
}
@Override
public String getDescription() {
return ".agn";
fileChooser.setFileFilter(new FileFilter()
{
@Override
public boolean accept(File pathname)
{
if (pathname.isFile() && pathname.getName().endsWith(".agn"))
{
return true;
}
else if (pathname.isDirectory())
{
return true;
}
else
{
return false;
}
}
@Override
public String getDescription()
{
return ".agn";
}
});
fileChooser.setDialogTitle("Choose save location");
int userSelection = fileChooser.showSaveDialog(null);
if(userSelection == JFileChooser.APPROVE_OPTION)
if (userSelection == JFileChooser.APPROVE_OPTION)
{
File file = fileChooser.getSelectedFile();
if(!file.getName().endsWith(".agn"))
if (!file.getName().endsWith(".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);
}
@@ -59,49 +74,70 @@ public class SaveLoad {
}
}
}
public static void saveTerrain(File file, Panel panel) {
try {
public static void saveTerrain(File file, Panel panel)
{
try
{
FileOutputStream fos = new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(fos);
for (DrawObject object : panel.objects) {
oos.writeObject(panel.getAgenda());
for (DrawObject object : panel.objects)
{
object.setSelected(false);
oos.writeObject(object);
}
for(Path p : panel.paths)
{
oos.writeObject(p);
}
oos.close();
JOptionPane.showMessageDialog(null, "Saved succesfully");
} catch (IOException e) {
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
public static void load(Panel panel)
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new FileFilter() {
fileChooser.setFileFilter(new FileFilter()
{
@Override
public boolean accept(File pathname) {
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
public boolean accept(File pathname)
{
if (pathname.isFile() && pathname.getName().endsWith(".agn"))
{
return true;
}else if(pathname.isDirectory()){return true;}else{return false;}
}
else if (pathname.isDirectory())
{
return true;
}
else
{
return false;
}
}
@Override
public String getDescription() {
public String getDescription()
{
return ".agn";
}
});
fileChooser.setDialogTitle("Choose file");
int userSelection = fileChooser.showOpenDialog(null);
if(userSelection == JFileChooser.APPROVE_OPTION)
if (userSelection == JFileChooser.APPROVE_OPTION)
{
File file = fileChooser.getSelectedFile();
if(!file.exists())
if (!file.exists())
{
JOptionPane.showMessageDialog(null, "This file does not exist: " + file.getName());
}
@@ -112,33 +148,54 @@ public class SaveLoad {
}
}
}
public static void fillTerrain(File file, Panel panel) {
public static void fillTerrain(File file, Panel panel)
{
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
try
{
fis = new FileInputStream(file);
ois = new ObjectInputStream(fis);
Object object;
object = ois.readObject();
try {
Agenda a = (Agenda) ois.readObject();
panel.setAgenda(a);
try
{
object = ois.readObject();
panel.clearObjects();
while (object != null) {
panel.objects.add((DrawObject) object);
while (object != null)
{
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();
}
} catch (EOFException e) {
}
} catch (Exception e) {
catch (EOFException e)
{
}
}
catch (Exception e)
{
e.printStackTrace();
}
panel.update();
}
}
}
+158 -63
View File
@@ -5,16 +5,20 @@ import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import Agenda.Agenda;
import Agenda.Event;
import Objects.DrawObject;
import Objects.Entrance;
import Objects.Path;
import Objects.Stage;
public class Visitor
{
@@ -27,23 +31,28 @@ public class Visitor
ArrayList<Action> actions;
Agenda agenda;
ArrayList<DrawObject> objects;
ArrayList<Waypoint> waypoints;
GregorianCalendar date;
int target;
int finalTarget;
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects)
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects, ArrayList<Waypoint> waypoints, GregorianCalendar date)
{
this.position = position;
this.filename = filename;
this.rotation = 0;
this.speed = 1 + Math.random() * 4;
this.waypoints = waypoints;
this.date = date;
scale = 1;
actions = new ArrayList<Action>();
this.agenda = agenda;
this.objects = objects;
fillActions();
System.out.println(actions.size());
target = 1;
finalTarget = 4;
finalTarget = 0;
}
public void draw(Graphics2D g2)
@@ -78,15 +87,16 @@ public class Visitor
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths, Panel panel)
{
DrawObject target = getEntrance();
for (Action a : actions)
{
if (currentTime >= a.getStartTime() && currentTime < a.getStoptime())
{
target = a.getTargetObject();
this.finalTarget = a.getWaypoint().getSelf();
}
}
// moveToTarget(target, objects, visitors, paths);
move(target, panel);
}
@@ -109,7 +119,6 @@ public class Visitor
{
rotation += 0.15;
}
Point2D oldPosition = position;
// face direction
@@ -128,8 +137,10 @@ public class Visitor
{
continue;
}
if (hitTest(object))
if (hasCollisionDO(object))
{
possible = false;
}
}
@@ -138,24 +149,25 @@ public class Visitor
position = oldPosition;
rotation += 0.2;
}
if (checkIfOnWaypoint(panel))
{
HashMap<Integer, int[]> options = new HashMap<Integer, int[]>();
for (Waypoint w : panel.getWaypoints())
{
options.put(w.getSelf(), w.getOptions());
}
for (Map.Entry<Integer, int[]> e : options.entrySet())
{
for (int i : e.getValue())
{
System.out.println("KEY:" + e.getKey());
System.out.println("VAL:" + i);
System.out.println("TAR: " + target);
System.out.println("____________");
if (finalTarget != target)
if (finalTarget != target)
{
for (Map.Entry<Integer, int[]> e : options.entrySet())
{
// System.out.println("KEY: " + e.getKey());
for (int i : e.getValue())
{
// System.out.println("VAL: " + i);
if (finalTarget == i && e.getKey() == target)
{
target = finalTarget;
@@ -167,10 +179,10 @@ public class Visitor
break;
}
}
}
}
}
}
public boolean checkIfOnWaypoint(Panel panel)
@@ -231,15 +243,17 @@ public class Visitor
boolean possible = true;
for (DrawObject object : objects)
{
if (hitTest(object))
if (hasCollisionDO(object))
{
possible = false;
}
}
for (Visitor object : visitors)
{
if (hitTestVisitor(object) && object != this)
if (hasCollision(object) && object != this)
{
possible = false;
}
}
@@ -334,14 +348,14 @@ public class Visitor
boolean possible = true;
for (DrawObject object : objects)
{
if (hitTest(object))
if (hasCollisionDO(object))
{
possible = false;
}
}
for (Visitor object : visitors)
{
if (hitTestVisitor(object) && object != this)
if (hasCollision(object) && object != this)
{
possible = false;
}
@@ -354,10 +368,11 @@ public class Visitor
}
}
@SuppressWarnings("static-access")
public void fillActions()
{
int startTime = 540;
int stopTime = 1260;
int startTime = 840;
int stopTime = 1440;
while (startTime < stopTime)
{
@@ -366,61 +381,105 @@ public class Visitor
{
Point2D position = null;
DrawObject targetStage = null;
ArrayList<Event> posEvents = new ArrayList<Event>();
for (Event e : agenda.getEvents())
{
if (convertMinutesToHours(startTime) > e.getStart() && convertMinutesToHours(startTime) < e.getStop())
if (startTime >= e.getStart() && startTime < e.getStop())
{
for (DrawObject d : objects)
posEvents.add(e);
}
}
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)
{
if (d.getFileName().equals(e.getStage().getName()))
for (DrawObject d : objects)
{
position = d.getPosition();
targetStage = d;
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)));
if (position != null)
{
actions.add(new Action(position, startTime, randomtime, targetStage));
Waypoint w = getClosedWaypoint(position);
actions.add(new Action(position, startTime, randomtime, targetStage, w));
}
startTime = startTime + randomtime;
}
else if (random >= 30 && random < 35)
else if (random >= 30 && random < 40)
{
Point2D position = null;
DrawObject targetDraw = null;
DrawObject targetStage = null;
ArrayList<DrawObject> foodPlaces = new ArrayList<DrawObject>();
for (DrawObject d : objects)
{
if (d.getFileName().equals("entrance"))
if (d.getFileName().equals("food"))
{
position = d.getPosition();
foodPlaces.add(d);
}
}
if (position != null)
if (foodPlaces.size() != 0)
{
actions.add(new Action(position, startTime, 35, targetDraw));
startTime = startTime + 35;
int r = (int) Math.floor(Math.random() * foodPlaces.size());
position = foodPlaces.get(r).getPosition();
targetStage = foodPlaces.get(r);
Waypoint w = getClosedWaypoint(position);
actions.add(new Action(position, startTime, 35, targetStage, w));
startTime = startTime + 20;
}
startTime = startTime + 35;
}
else if (random > 35)
else if (random >= 40)
{
Point2D position = null;
DrawObject targetDrawobj = null;
DrawObject targetStage = null;
ArrayList<DrawObject> toilets = new ArrayList<DrawObject>();
for (DrawObject d : objects)
{
if (d.getFileName().equals("wc"))
{
position = d.getPosition();
toilets.add(d);
}
}
if (position != null)
if (toilets.size() != 0)
{
actions.add(new Action(position, startTime, 35, targetDrawobj));
int r = (int) Math.floor(Math.random() * toilets.size());
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;
@@ -428,35 +487,71 @@ public class Visitor
}
}
public int convertMinutesToHours(int startTime)
public Waypoint getClosedWaypoint(Point2D point)
{
int time = 0;
int hours = startTime / 60;
int minutes = startTime % 60;
time = (hours * 100) + minutes;
return time;
Waypoint waypoint = null;
int distance = 10000;
for (Waypoint w : waypoints)
{
if (w.getPosition().distance(point) < distance)
{
waypoint = w;
distance = (int) w.getPosition().distance(point);
}
}
return waypoint;
}
public int getEndX()
public boolean hasCollisionDO(DrawObject object)
{
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);
return (int) (position.getX() + image.getWidth(null));
}
Rectangle a = new Rectangle((int) position.getX(), (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));
public int getEndY()
{
Image image = Images.getImage(filename);
return (int) (position.getY() + image.getHeight(null));
}
Area aa = new Area(a);
Area bb = new Area(b);
public boolean hitTest(DrawObject to2)
{
return (getEndX() >= to2.getPosition().getX() && getEndY() >= to2.getPosition().getY() && to2.getEndX() >= position.getX() && to2.getEndY() >= position.getY());
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());
public boolean hitTestVisitor(Visitor v)
{
return (getEndX() >= v.position.getX() && getEndY() >= v.position.getY() && v.getEndX() >= position.getX() && v.getEndY() >= position.getY());
Area ra = aa.createTransformedArea(af);
Area rb = bb.createTransformedArea(bf);
if (ra.intersects(rb.getBounds2D()))
{
return true;
}
return false;
}
}
}
+5 -1
View File
@@ -13,6 +13,11 @@ public class Waypoint extends DrawObject
super("waypoint", position);
}
public Point2D getAccuratePoint()
{
return new Point2D.Double(super.getPosition().getX() + (super.getImageRectangle().getWidth()/2), super.getPosition().getY() + super.getImageRectangle().getHeight());
}
@Override
public String getName()
{
@@ -36,7 +41,6 @@ public class Waypoint extends DrawObject
public void setSelf(int self)
{
System.out.println(self);
this.self = self;
}
-1
View File
@@ -111,7 +111,6 @@ public class WaypointPopup extends JFrame {
for(int i = 0; i < options.length; i++)
{
ioptions[i] = Integer.valueOf(options[i]);
System.out.println(ioptions[i]);
}
wp.setOptions(ioptions);
+113 -108
View File
@@ -4,7 +4,6 @@ import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import javax.swing.SwingUtilities;
@@ -16,7 +15,6 @@ import Applicatie.Waypoint;
import Applicatie.WaypointPopup;
import Objects.DrawObject;
import Objects.Path;
import Objects.Entrance;
public class Mouse extends MouseAdapter
{
@@ -35,126 +33,126 @@ public class Mouse extends MouseAdapter
Point2D clickPoint = panel.getClickPoint(e.getPoint());
panel.setLastClickPosition(clickPoint);
panel.setLastMousePosition(e.getPoint());
if(!panel.getPlay())
{
if (!panel.getClickedOption().equals("Path"))
if (!panel.getClickedOption().equals("Path"))
{
if (e.getY() < 150)
{
if (e.getY() < 150)
int i = 0;
int last = 0;
for (BufferedImage image : panel.getPanelInfo())
{
int i = 0;
int last = 0;
for (BufferedImage image : panel.getPanelInfo())
if (e.getX() >= panel.getScrollfactor() && e.getX() < last + image.getWidth() + panel.getScrollfactor())
{
if (e.getX() >= panel.getScrollfactor() && e.getX() < last + image.getWidth() + panel.getScrollfactor())
DrawObject tempDrawObj = panel.createNewDrawObject(i);
if (tempDrawObj != null)
{
DrawObject tempDrawObj = panel.createNewDrawObject(i);
if (tempDrawObj != null)
{
tempDrawObj.setPosition(clickPoint);
if (!panel.getObjects().isEmpty())
panel.clearObjectSelection();
panel.setDragObject(tempDrawObj);
panel.getDragObject().setSelected(true);
panel.getPP().setSelected(tempDrawObj);
panel.setSelectedObject(tempDrawObj);
selectedObject = tempDrawObj;
}
break;
tempDrawObj.setPosition(clickPoint);
if (!panel.getObjects().isEmpty())
panel.clearObjectSelection();
panel.setDragObject(tempDrawObj);
panel.getDragObject().setSelected(true);
panel.getPP().setSelected(tempDrawObj);
panel.setSelectedObject(tempDrawObj);
selectedObject = tempDrawObj;
}
i++;
last += image.getWidth();
break;
}
if (panel.getDragObject() != null)
i++;
last += image.getWidth();
}
if (panel.getDragObject() != null)
{
panel.add(panel.getDragObject());
}
}
else
{
for (DrawObject o : panel.getObjects())
{
if (o.contains(clickPoint))
{
panel.add(panel.getDragObject());
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
{
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);
}
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();
}
@@ -172,8 +170,15 @@ public class Mouse extends MouseAdapter
}
else
{
panel.getDragObject().setPosition(panel.getSelectionPosition());
panel.getDragObject().setRectangleColor(Color.BLACK);
if (panel.getDragObject() instanceof Waypoint == false)
{
panel.getDragObject().setPosition(panel.getSelectionPosition());
panel.getDragObject().setRectangleColor(Color.BLACK);
}
else
{
panel.getDragObject().setRectangleColor(Color.BLACK);
}
}
panel.setSelectionPosition(panel.getSelectedObject().getPosition());
}
+19 -1
View File
@@ -15,6 +15,7 @@ import java.io.Serializable;
import javax.swing.ImageIcon;
import Applicatie.Images;
import Applicatie.Panel;
public abstract class DrawObject implements Serializable
{
@@ -232,13 +233,30 @@ public abstract class DrawObject implements Serializable
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;
}
public void setPosition(Point2D position, boolean b)
{
this.position = position;
setPosition(position);
}
public double getRotation()
{
return rotation;
+17 -2
View File
@@ -10,6 +10,7 @@ import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import javax.imageio.ImageIO;
@@ -23,13 +24,15 @@ import Applicatie.Waypoint;
* @author Wesley de Hek
* @version 1.2
*/
public class Path
public class Path implements Serializable
{
private static final long serialVersionUID = 5345485798486018597L;
private ArrayList<Point2D> points;
private ArrayList<Shape> lines;
private Point2D tempPoint;
private BufferedImage pathBackground;
public transient BufferedImage pathBackground = null;;
private ArrayList<Waypoint> waypoints;
/**
@@ -49,6 +52,18 @@ public class Path
e.printStackTrace();
}
}
public void updateImage()
{
try
{
pathBackground = ImageIO.read(new File("images/newPath.png"));
}
catch (IOException e)
{
e.printStackTrace();
}
}
/**
* Draws the path.
-2
View File
@@ -1,2 +0,0 @@
# FestivalPlanner
Festival Planner
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB