20 Commits
Author SHA1 Message Date
guusvdongen 911714f9b5 Update Visitor.java 2015-04-08 21:15:45 +02:00
unknown 254167ba15 print out line op 2015-04-08 17:40:22 +02:00
unknown b8a7d9c02d change 2015-04-08 17:24:29 +02:00
unknown 69c05da3fd laatste versie 2015-04-08 15:56:46 +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
41 changed files with 356 additions and 484 deletions
+2 -2
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;
+8 -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,9 @@ public class Action
{
return duration;
}
public Waypoint getWaypoint(){
return waypoint;
}
}
-100
View File
@@ -1,100 +0,0 @@
package Applicatie;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class AddPeoplePanel extends JFrame {
public AddPeoplePanel(Panel topPanel) {
super("Adding people");
setDefaultCloseOperation(HIDE_ON_CLOSE);
setResizable(false);
JPanel mainPanel = new JPanel(new BorderLayout());
JLabel label;
JButton button;
//Top:
JPanel panel = new JPanel();
label = new JLabel("Enter the amount of people you want to add: ");
panel.add(label);
mainPanel.add(panel,BorderLayout.NORTH);
//Center:
panel = new JPanel();
JTextField amountOfPeopleField = new JTextField("0");
amountOfPeopleField.setPreferredSize(new Dimension(100,20));
amountOfPeopleField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
try {
amountOfPeopleField.setBackground(Color.WHITE);
int amountOfPeople = Integer.parseInt(amountOfPeopleField.getText());
amountOfPeopleField.setText(amountOfPeople + "");
}
catch(NumberFormatException nf) {
amountOfPeopleField.setBackground(Color.RED);
}
}
@Override
public void keyPressed(KeyEvent e) {
}
});
label = new JLabel("people ");
panel.add(amountOfPeopleField);
panel.add(label);
mainPanel.add(panel,BorderLayout.CENTER);
//Bottom:
panel = new JPanel();
button = new JButton("Cancel");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AddPeoplePanel.this.dispose();
}
});
panel.add(button);
button = new JButton("Apply");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(amountOfPeopleField.getBackground() != Color.RED) {
topPanel.addVisitors(Integer.parseInt(amountOfPeopleField.getText()));
AddPeoplePanel.this.dispose();
}
else
JOptionPane.showMessageDialog(topPanel, "Only numbers are accepted");
}
});
panel.add(button);
mainPanel.add(panel,BorderLayout.SOUTH);
add(mainPanel);
//Finishing off
pack();
setSize(290,150);
setLocationRelativeTo(null);
setVisible(true);
}
}
+1 -12
View File
@@ -63,7 +63,6 @@ public class Panel extends JPanel implements ActionListener
private Path currentPath;
private static int width = 1920;
private static int height = 1080;
private boolean play = false;
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
float cameraScale = 1;
@@ -149,7 +148,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 / 10, this);
}
public int getPanelInfoLength()
@@ -663,16 +662,6 @@ public class Panel extends JPanel implements ActionListener
{
this.t = t;
}
public void setPlay(boolean play)
{
this.play = play;
}
public boolean getPlay()
{
return play;
}
public void newWorld(int width, int height, int terrainIndex)
{
+13 -27
View File
@@ -2,12 +2,10 @@ package Applicatie;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -23,21 +21,20 @@ public class PathPopup extends JFrame
public PathPopup(Path p, Panel panel)
{
super("");
super("Artist editscreen!");
setDefaultCloseOperation(HIDE_ON_CLOSE);
JPanel content = new JPanel();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
JPanel content = new JPanel(new BorderLayout());
JPanel south = new JPanel(new FlowLayout());
JPanel center = new JPanel();
JPanel panel1 = new JPanel();
JLabel name = new JLabel("Add WayPoint");
name.setFont(new Font("Dialog", Font.BOLD, 20));
panel1.add(name);
content.add(panel1);
content.add(center);
content.add(south);
JPanel center = new JPanel(new GridLayout(5, 2));
content.add(south, BorderLayout.SOUTH);
content.add(center, BorderLayout.CENTER);
JTextField tf = new JTextField(10);
JPanel panel1 = new JPanel();
JLabel name = new JLabel("Path");
panel1.add(name);
center.add(panel1);
JTextField tf = new JTextField(5);
center.add(tf);
JButton edit = new JButton("Done");
@@ -50,22 +47,11 @@ public class PathPopup extends JFrame
dispose();
}
});
JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
dispose();
}
});
south.add(edit);
south.add(cancel);
setContentPane(content);
setVisible(true);
setSize(200, 150);
setSize(500, 320);
}
}
+227 -206
View File
@@ -5,8 +5,10 @@ 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;
@@ -15,9 +17,9 @@ import Agenda.Event;
import Objects.DrawObject;
import Objects.Entrance;
import Objects.Path;
import Objects.Stage;
public class Visitor
{
public class Visitor {
Point2D position;
double rotation;
@@ -27,34 +29,40 @@ 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());
for (Action a : actions){
System.out.println("" + a.getStartTime());
}
target = 1;
finalTarget = 4;
}
public void draw(Graphics2D g2)
{
public void draw(Graphics2D g2) {
AffineTransform tx = getTransform();
Image image = Images.getImage(filename);
g2.drawImage(image, tx, null);
}
private AffineTransform getTransform()
{
private AffineTransform getTransform() {
Image image = Images.getImage(filename);
AffineTransform tx = new AffineTransform();
tx.scale(scale, scale);
@@ -63,26 +71,22 @@ public class Visitor
return tx;
}
public DrawObject getEntrance()
{
for (DrawObject o : objects)
{
if (o instanceof Entrance)
{
public DrawObject getEntrance() {
for (DrawObject o : objects) {
if (o instanceof Entrance) {
return o;
}
}
return null;
}
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();
for (Action a : actions)
{
if (currentTime >= a.getStartTime() && currentTime < a.getStoptime())
{
target = a.getTargetObject();
for (Action a : actions) {
if (currentTime >= a.getStartTime()
&& currentTime < a.getStoptime()) {
finalTarget = a.getWaypoint().getSelf();
}
}
@@ -91,22 +95,19 @@ public class Visitor
move(target, panel);
}
public void move(DrawObject tar, Panel panel)
{
public void move(DrawObject tar, Panel panel) {
Point2D targetPoint = panel.getWaypoint(target).getPosition();
double newRot = Math.atan2(targetPoint.getY() - position.getY(), targetPoint.getX() - position.getX());
double newRot = Math.atan2(targetPoint.getY() - position.getY(),
targetPoint.getX() - position.getX());
int difx = (int) (targetPoint.getX() - position.getX());
int dify = (int) (targetPoint.getY() - position.getY());
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
if (rotation > newRot && distance > 10)
{
if (rotation > newRot && distance > 10) {
rotation -= 0.15;
}
else if (rotation < newRot && distance > 10)
{
} else if (rotation < newRot && distance > 10) {
rotation += 0.15;
}
@@ -116,104 +117,85 @@ public class Visitor
float directionX = (float) Math.cos(rotation);
float directionY = (float) Math.sin(rotation);
if (distance > 10)
{
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
if (distance > 10) {
position = new Point2D.Double(
(position.getX() + directionX * speed),
(position.getY() + directionY * speed));
}
boolean possible = true;
for (DrawObject object : objects)
{
if (object instanceof Entrance || object instanceof Waypoint)
{
for (DrawObject object : objects) {
if (object instanceof Entrance || object instanceof Waypoint) {
continue;
}
if (hitTest(object))
{
if (hasCollisionDO(object)) {
possible = false;
}
}
if (possible == false)
{
if (possible == false) {
position = oldPosition;
rotation += 0.2;
}
if (checkIfOnWaypoint(panel))
{
if (checkIfOnWaypoint(panel)) {
// for(int i : panel.getWaypoint(target).getOptions())
// {
// if(i == finalTarget)
// {
// target = finalTarget;
// }
// }
// ArrayList<int[]> options = new ArrayList<int[]>();
HashMap<Integer, int[]> options = new HashMap<Integer, int[]>();
for (Waypoint w : panel.getWaypoints())
{
for (Waypoint w : panel.getWaypoints()) {
options.put(w.getSelf(), w.getOptions());
}
for (Map.Entry<Integer, int[]> e : options.entrySet())
{
for (int i : e.getValue())
{
System.out.println("KEY:" + e.getKey());
System.out.println("VAL:" + i);
System.out.println("TAR: " + target);
System.out.println("____________");
if (finalTarget != target)
{
if (finalTarget == i && e.getKey() == target)
{
target = finalTarget;
break;
}
else if (finalTarget == i)
{
target = e.getKey();
break;
}
}
for (Map.Entry<Integer, int[]> e : options.entrySet()) {
System.out.println(e.getKey());
System.out.println("=====================");
for (int i : e.getValue()) {
System.out.println(i);
}
System.out.println("----------");
}
}
}
public boolean checkIfOnWaypoint(Panel panel)
{
if (panel.getWaypoint(target).contains(position))
{
public boolean checkIfOnWaypoint(Panel panel) {
if (panel.getWaypoint(target).contains(position)) {
return true;
}
return false;
}
public void moveToTarget(DrawObject target, ArrayList<DrawObject> objects, ArrayList<Visitor> visitors, ArrayList<Path> paths)
{
public void moveToTarget(DrawObject target, ArrayList<DrawObject> objects,
ArrayList<Visitor> visitors, ArrayList<Path> paths) {
Point2D tar = target.getPosition();
boolean hasPathBelow = false;
for (Path p : paths)
{
if (p.containsPoint(position))
{
for (Path p : paths) {
if (p.containsPoint(position)) {
hasPathBelow = true;
break;
}
Shape containsShape = p.containsPointShape(position);
if (containsShape != null)
{
tar = new Point2D.Double(containsShape.getBounds().getCenterX(), containsShape.getBounds().getCenterY());
if (containsShape != null) {
tar = new Point2D.Double(
containsShape.getBounds().getCenterX(), containsShape
.getBounds().getCenterY());
}
}
if (hasPathBelow)
{
double newRot = Math.atan2(tar.getY() - position.getY(), tar.getX() - position.getX());
if (hasPathBelow) {
double newRot = Math.atan2(tar.getY() - position.getY(), tar.getX()
- position.getX());
int difx = (int) (tar.getX() - position.getX());
int dify = (int) (tar.getY() - position.getY());
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
if (rotation > newRot && distance > 10)
{
if (rotation > newRot && distance > 10) {
rotation -= 0.15;
}
else if (rotation < newRot && distance > 10)
{
} else if (rotation < newRot && distance > 10) {
rotation += 0.15;
}
@@ -223,39 +205,30 @@ public class Visitor
float directionX = (float) Math.cos(rotation);
float directionY = (float) Math.sin(rotation);
if (distance > 10)
{
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
if (distance > 10) {
position = new Point2D.Double((position.getX() + directionX
* speed), (position.getY() + directionY * speed));
}
boolean possible = true;
for (DrawObject object : objects)
{
if (hitTest(object))
{
for (DrawObject object : objects) {
if (hasCollisionDO(object)) {
possible = false;
}
}
for (Visitor object : visitors)
{
if (hitTestVisitor(object) && object != this)
{
for (Visitor object : visitors) {
if (hasCollision(object) && object != this) {
possible = false;
}
}
if (possible == false)
{
if (possible == false) {
position = oldPosition;
rotation += 0.2;
}
}
else
{
} else {
HashMap<Double, Shape> values = new HashMap<Double, Shape>();
for (Path p : paths)
{
for (Shape s : p.getPath())
{
for (Path p : paths) {
for (Shape s : p.getPath()) {
Rectangle b = s.getBounds();
double maxx = b.getMaxX();
double minx = b.getMinX();
@@ -269,16 +242,14 @@ public class Visitor
points[3] = new Point2D.Double(maxx, maxy);
Double lastdistance = null;
for (Point2D.Double point : points)
{
double distance = Point2D.distance(point.getX(), point.getY(), position.getX(), position.getY());
if (lastdistance == null)
{
for (Point2D.Double point : points) {
double distance = Point2D.distance(point.getX(),
point.getY(), position.getX(), position.getY());
if (lastdistance == null) {
lastdistance = distance;
continue;
}
if (distance < lastdistance)
{
if (distance < lastdistance) {
lastdistance = distance;
}
}
@@ -288,35 +259,31 @@ public class Visitor
}
Double lastdistance = null;
Shape lastShape = null;
for (Map.Entry<Double, Shape> e : values.entrySet())
{
for (Map.Entry<Double, Shape> e : values.entrySet()) {
double distance = e.getKey();
if (lastdistance == null)
{
if (lastdistance == null) {
lastdistance = distance;
continue;
}
if (distance < lastdistance)
{
if (distance < lastdistance) {
lastdistance = distance;
}
}
lastShape = values.get(lastdistance);
Point2D.Double target2 = new Point2D.Double(lastShape.getBounds().getCenterX(), lastShape.getBounds().getCenterY());
Point2D.Double target2 = new Point2D.Double(lastShape.getBounds()
.getCenterX(), lastShape.getBounds().getCenterY());
double newRot = Math.atan2(target2.getY() - position.getY(), target2.getX() - position.getX());
double newRot = Math.atan2(target2.getY() - position.getY(),
target2.getX() - position.getX());
int difx = (int) (target2.getX() - position.getX());
int dify = (int) (target2.getY() - position.getY());
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
if (rotation > newRot && distance > 10)
{
if (rotation > newRot && distance > 10) {
rotation -= 0.15;
}
else if (rotation < newRot && distance > 10)
{
} else if (rotation < newRot && distance > 10) {
rotation += 0.15;
}
@@ -326,101 +293,119 @@ public class Visitor
float directionX = (float) Math.cos(rotation);
float directionY = (float) Math.sin(rotation);
if (distance > 10)
{
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
if (distance > 10) {
position = new Point2D.Double((position.getX() + directionX
* speed), (position.getY() + directionY * speed));
}
boolean possible = true;
for (DrawObject object : objects)
{
if (hitTest(object))
{
for (DrawObject object : objects) {
if (hasCollisionDO(object)) {
possible = false;
}
}
for (Visitor object : visitors)
{
if (hitTestVisitor(object) && object != this)
{
for (Visitor object : visitors) {
if (hasCollision(object) && object != this) {
possible = false;
}
}
if (possible == false)
{
if (possible == false) {
position = oldPosition;
rotation += 0.2;
}
}
}
public void fillActions()
{
public void fillActions() {
int startTime = 540;
int stopTime = 1260;
while (startTime < stopTime)
{
while (startTime < stopTime) {
int random = (int) Math.floor(Math.random() * 51);
if (random < 30)
{
if (random < 30) {
Point2D position = null;
DrawObject targetStage = null;
for (Event e : agenda.getEvents())
{
if (convertMinutesToHours(startTime) > e.getStart() && convertMinutesToHours(startTime) < e.getStop())
{
for (DrawObject d : objects)
{
if (d.getFileName().equals(e.getStage().getName()))
{
position = d.getPosition();
targetStage = d;
ArrayList<Event> posEvents = new ArrayList<Event>();
for (Event e : agenda.getEvents()) {
if (startTime >= e.getStart() && startTime < e.getStop()) {
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){
for (DrawObject d : objects) {
if (d.getFileName().equals("stage")) {
Stage s = (Stage) d;
if (s.getStage().getName()
.equals(evs.getStage().getName())) {
position = s.getPosition();
targetStage = d;
}
}
}
}
}
}
int randomtime = (int) (40 + (Math.random() * (60 - 40)));
if (position != null)
{
actions.add(new Action(position, startTime, randomtime, targetStage));
if (position != null) {
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;
for (DrawObject d : objects)
{
if (d.getFileName().equals("entrance"))
{
position = d.getPosition();
DrawObject targetStage = null;
ArrayList<DrawObject> foodPlaces = new ArrayList<DrawObject>();
for (DrawObject d : objects) {
if (d.getFileName().equals("food")) {
foodPlaces.add(d);
}
}
if (position != null)
{
actions.add(new Action(position, startTime, 35, targetDraw));
startTime = startTime + 35;
if (foodPlaces.size() != 0) {
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;
for (DrawObject d : objects)
{
if (d.getFileName().equals("wc"))
{
position = d.getPosition();
DrawObject targetStage = null;
ArrayList<DrawObject> toilets = new ArrayList<DrawObject>();
for (DrawObject d : objects) {
if (d.getFileName().equals("wc")) {
toilets.add(d);
}
}
if (position != null)
{
actions.add(new Action(position, startTime, 35, targetDrawobj));
if (toilets.size() != 0) {
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 +413,71 @@ public class Visitor
}
}
public int convertMinutesToHours(int startTime)
{
int time = 0;
int hours = startTime / 60;
int minutes = startTime % 60;
time = (hours * 100) + minutes;
return time;
public Waypoint getClosedWaypoint(Point2D point) {
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);
return (int) (position.getX() + image.getWidth(null));
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 int getEndY()
{
public boolean hasCollision(Visitor v) {
Image image = Images.getImage(filename);
return (int) (position.getY() + image.getHeight(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 boolean hitTest(DrawObject to2)
{
return (getEndX() >= to2.getPosition().getX() && getEndY() >= to2.getPosition().getY() && to2.getEndX() >= position.getX() && to2.getEndY() >= position.getY());
Area aa = new Area(a);
Area bb = new Area(b);
}
AffineTransform af = new AffineTransform();
af.rotate(rotation, position.getX(), position.getY());
public boolean hitTestVisitor(Visitor v)
{
return (getEndX() >= v.position.getX() && getEndY() >= v.position.getY() && v.getEndX() >= position.getX() && v.getEndY() >= 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;
}
}
}
+2 -28
View File
@@ -60,7 +60,7 @@ public class WaypointPopup extends JFrame {
panel1.add(name);
row1.add(panel1);
JTextField tf = new JTextField(wp.getSelf() + "", 10);
JTextField tf = new JTextField(10);
row2.add(tf);
JPanel panel2 = new JPanel();
@@ -73,21 +73,7 @@ public class WaypointPopup extends JFrame {
empty2.add(Box.createRigidArea(new Dimension(0, 5)));
row2.add(empty2);
String optionss = "";
if(wp.getOptions() != null)
{
if(wp.getOptions().length != 0)
{
int[] optionsa = wp.getOptions();
optionss += optionsa[0];
for(int i = 1; i < optionsa.length; i++)
{
optionss += "-" + optionsa[i];
}
}
}
JTextField tx = new JTextField("" + optionss, 8);
JTextField tx = new JTextField(8);
row2.add(tx);
JPanel help = new JPanel();
@@ -111,7 +97,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);
@@ -119,17 +104,6 @@ public class WaypointPopup extends JFrame {
});
south.add(edit);
JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
dispose();
}
});
south.add(cancel);
setContentPane(content);
setVisible(true);
setSize(300,250);
+103 -106
View File
@@ -35,133 +35,130 @@ 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();
}
public void mouseReleased(MouseEvent e)
{
if (panel.getDragObject() != null && !panel.getPlay())
if (panel.getDragObject() != null)
{
if (panel.getDragObject().getRectangleColor() != Color.RED)
{
-2
View File
@@ -1,2 +0,0 @@
# FestivalPlanner
Festival Planner
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 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

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 911 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B