laatste versie
This commit is contained in:
@@ -234,6 +234,10 @@ public abstract class DrawObject implements Serializable
|
||||
{
|
||||
this.position = position;
|
||||
}
|
||||
public void setPosition(Point2D position, boolean b)
|
||||
{
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public double getRotation()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package Objects;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import Applicatie.Panel;
|
||||
|
||||
public class Entrance extends DrawObject
|
||||
{
|
||||
@@ -15,5 +18,35 @@ public class Entrance extends DrawObject
|
||||
{
|
||||
return "Entrance";
|
||||
}
|
||||
|
||||
public void setPosition(Point2D position, boolean b)
|
||||
{
|
||||
//this.position = position;
|
||||
Rectangle2D rect = getRectangle();
|
||||
double xl = (Panel.getFieldWidth()/2) + rect.getMinX();
|
||||
double xr = Panel.getFieldWidth() - (Panel.getFieldWidth()/2 + rect.getMaxX());
|
||||
double yt = (Panel.getFieldHeight()/2) + rect.getMinY();
|
||||
double yb = Panel.getFieldHeight() - (Panel.getFieldHeight()/2 + rect.getMaxY());
|
||||
if(xl < xr && xl < yt && xl < yb)
|
||||
{
|
||||
this.position = new Point2D.Double(-Panel.getFieldWidth()/2, position.getY());
|
||||
}
|
||||
else if(xr < xl && xr < yt && xr < yb)
|
||||
{
|
||||
this.position = new Point2D.Double(Panel.getFieldWidth()/2 - rect.getWidth(), position.getY());
|
||||
}
|
||||
else if(yt < xl && yt < xr && yt < yb)
|
||||
{
|
||||
this.position = new Point2D.Double(position.getX(), -Panel.getFieldHeight()/2);
|
||||
}
|
||||
else if(yb < xl && yb < yt && yb < xr)
|
||||
{
|
||||
this.position = new Point2D.Double(position.getX(), Panel.getFieldHeight()/2 - rect.getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.position = new Point2D.Double(-Panel.getFieldWidth()/2, -Panel.getFieldHeight()/2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-4
@@ -14,6 +14,9 @@ import java.util.ArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import Applicatie.Panel;
|
||||
import Applicatie.Waypoint;
|
||||
|
||||
/**
|
||||
* Create's a path.
|
||||
*
|
||||
@@ -27,6 +30,7 @@ public class Path
|
||||
private ArrayList<Shape> lines;
|
||||
private Point2D tempPoint;
|
||||
private BufferedImage pathBackground;
|
||||
private ArrayList<Waypoint> waypoints;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -35,6 +39,7 @@ public class Path
|
||||
{
|
||||
points = new ArrayList<>();
|
||||
lines = new ArrayList<>();
|
||||
waypoints = new ArrayList<Waypoint>();
|
||||
try
|
||||
{
|
||||
pathBackground = ImageIO.read(new File("images/newPath.png"));
|
||||
@@ -91,7 +96,7 @@ public class Path
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if one of the lines contains the given point.
|
||||
*
|
||||
@@ -110,12 +115,13 @@ public class Path
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean intersectsRect(Rectangle2D rect)
|
||||
{
|
||||
for(Shape line : getPath())
|
||||
for (Shape line : getPath())
|
||||
{
|
||||
if(line.intersects(rect))
|
||||
if (line.intersects(rect))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -140,8 +146,23 @@ public class Path
|
||||
lines.add(stroke.createStrokedShape(line));
|
||||
}
|
||||
return lines;
|
||||
|
||||
}
|
||||
|
||||
public void addWaypoint(int i, Panel panel)
|
||||
{
|
||||
for (Waypoint w : panel.getWaypoints())
|
||||
{
|
||||
if (w.getSelf() == i)
|
||||
{
|
||||
waypoints.add(w);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a point to the path.
|
||||
*
|
||||
|
||||
+15
-10
@@ -1,28 +1,33 @@
|
||||
package Objects;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import Agenda.Agenda;
|
||||
import Agenda.AgendaStage;
|
||||
|
||||
public class Stage extends DrawObject {
|
||||
public class Stage extends DrawObject
|
||||
{
|
||||
AgendaStage stage;
|
||||
|
||||
public Stage(Point2D position, AgendaStage stage) {
|
||||
|
||||
public Stage(Point2D position, AgendaStage st)
|
||||
{
|
||||
super("stage", position);
|
||||
this.stage = stage;
|
||||
stage = st;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getName()
|
||||
{
|
||||
return "Stage";
|
||||
}
|
||||
|
||||
public AgendaStage getStage() {
|
||||
public AgendaStage getStage()
|
||||
{
|
||||
return stage;
|
||||
}
|
||||
|
||||
public void setStage(AgendaStage stage)
|
||||
{
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user