Merge
This commit is contained in:
@@ -106,11 +106,13 @@ public class Panel extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setBackground(BufferedImage background) {
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ArrayList<DrawObject> getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
+24
-22
@@ -5,40 +5,42 @@ import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import Applicatie.DrawObject;
|
||||
import Applicatie.Panel;
|
||||
import Objects.Podium;
|
||||
import Objects.Toilet;
|
||||
import Applicatie.Panel;
|
||||
|
||||
public class Mouse extends MouseAdapter {
|
||||
private Panel panel;
|
||||
|
||||
private Panel panel;
|
||||
|
||||
public Mouse(Panel panel)
|
||||
{
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
Point2D clickPoint = panel.getClickPoint(e.getPoint());
|
||||
panel.setLastClickPosition(clickPoint);
|
||||
panel.setLastMousePosition(e.getPoint());
|
||||
if(e.getX() < 200)
|
||||
{
|
||||
if(e.getY() < 300)
|
||||
panel.setDragObject(new Podium(clickPoint));
|
||||
else
|
||||
panel.setDragObject(new Toilet(clickPoint));
|
||||
panel.add(panel.getDragObject());
|
||||
}
|
||||
Point2D clickPoint = panel.getClickPoint(e.getPoint());
|
||||
panel.setLastClickPosition(clickPoint);
|
||||
|
||||
if(e.getX() < 200)
|
||||
{
|
||||
if(e.getY() < 300)
|
||||
panel.setDragObject(new Podium(clickPoint));
|
||||
else
|
||||
{
|
||||
for(DrawObject o : panel.getObjects())
|
||||
if(o.contains(clickPoint))
|
||||
panel.setDragObject(o);
|
||||
}
|
||||
panel.setDragObject(new Toilet(clickPoint));
|
||||
panel.add(panel.getDragObject());
|
||||
}
|
||||
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
panel.setDragObject(null);
|
||||
else
|
||||
{
|
||||
for(DrawObject o : panel.getObjects())
|
||||
if(o.contains(clickPoint))
|
||||
panel.setDragObject(o);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
panel.setDragObject(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ import java.awt.geom.Point2D;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import Applicatie.Panel;
|
||||
|
||||
public class MouseMotion extends MouseMotionAdapter {
|
||||
|
||||
private Panel panel;
|
||||
|
||||
public MouseMotion(Panel panel)
|
||||
|
||||
Reference in New Issue
Block a user