Merge guus dev

This commit is contained in:
Yorick
2015-04-07 13:59:34 +02:00
parent 5a0def924a
commit cba61d4dc5
4 changed files with 37 additions and 6 deletions
-1
View File
@@ -1,6 +1,5 @@
package Agenda;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+29 -2
View File
@@ -8,6 +8,8 @@ import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Stroke;
import java.awt.TexturePaint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
@@ -17,6 +19,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Timer;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
@@ -35,7 +38,7 @@ import Objects.Toilet;
import Objects.Wall;
@SuppressWarnings("serial")
public class Panel extends JPanel
public class Panel extends JPanel implements ActionListener
{
BufferedImage background;
@@ -62,6 +65,9 @@ public class Panel extends JPanel
Point lastMousePosition = new Point(0, 0);
Point2D selectionPosition = new Point(0, 0);
Images images = new Images();
int currentTime = 540;
int tick = 0;
// how to nieuwe dingen aan het panel toe te voegen:
// maak bufferedimage global aan, voeg er een image aan toe, en voeg de
// image aan panelInfo toe en het object aan panelTypes.
@@ -118,6 +124,7 @@ public class Panel extends JPanel
addMouseMotionListener(new MouseMotion(this));
addMouseWheelListener(new MouseWheel(this));
new javax.swing.Timer(1000/20, this).start();;
}
public int getPanelInfoLength()
@@ -198,6 +205,11 @@ public class Panel extends JPanel
{
o.draw(g2);
}
for (Visitor v : visitors){
v.draw(g2);
}
g2.setTransform(oldTransform);
if (currentPath != null)
{ // Display text while in path making modes.
@@ -205,7 +217,6 @@ public class Panel extends JPanel
g2.setFont(new Font("Verdana", Font.ITALIC, 25));
g2.drawString("Press enter to finish the path.", 20, 185);
}
g2.setClip(null);
}
@@ -501,4 +512,20 @@ public class Panel extends JPanel
{
this.agenda = agenda;
}
@Override
public void actionPerformed(ActionEvent e) {
tick++;
if ( tick >= 10 && visitors.size() > 0){
tick = 0;
currentTime++;
System.out.println(currentTime);
}
for (Visitor v: visitors){
v.update(objects, currentTime, visitors);
}
repaint();
}
}
+7 -3
View File
@@ -16,6 +16,7 @@ public class Visitor
Point2D position;
double rotation;
double scale;
double speed;
String filename;
ArrayList<Action> actions;
@@ -28,6 +29,7 @@ public class Visitor
this.filename = filename;
this.rotation = 0;
this.speed = 1 + Math.random() * 4;
scale = 1;
actions = new ArrayList<Action>();
this.agenda = agenda;
this.objects = objects;
@@ -43,16 +45,18 @@ public class Visitor
private AffineTransform getTransform()
{
AffineTransform tx = new AffineTransform();
tx.translate(position.getX(), position.getY());
Image image = Images.getImage(filename);
AffineTransform tx = new AffineTransform();
tx.scale(scale, scale);
tx.translate(position.getX(), position.getY());
// System.out.println(position.getX());
tx.rotate(rotation, image.getWidth(null) / 2, image.getHeight(null) / 2);
return tx;
}
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors)
{
Point2D target = new Point(-100, -100);
Point2D target = new Point(500, 500);
for (Action a : actions)
{
if (currentTime >= a.getStartTime() && currentTime < a.getStoptime())
+1
View File
@@ -104,6 +104,7 @@ public abstract class DrawObject implements Serializable
AffineTransform tx = new AffineTransform();
tx.scale(scale, scale);
tx.translate(position.getX(), position.getY());
System.out.println(position.getX());
tx.rotate(Math.toRadians(rotation), (width + areaLeft + areaRight) / 2, (height + areaTop + areaBottom) / 2);
return tx;
}