Scrolling added
This commit is contained in:
+20
-4
@@ -30,7 +30,7 @@ public class Panel extends JPanel {
|
||||
BufferedImage background;
|
||||
BufferedImage podiumImage, toiletImage;
|
||||
|
||||
private int panelInfox, panelInfoy;
|
||||
private int panelInfox, panelInfoy,scrollfactor;
|
||||
|
||||
private ArrayList<BufferedImage> panelInfo = new ArrayList<BufferedImage>();
|
||||
private ArrayList<Object> panelTypes = new ArrayList<Object>();
|
||||
@@ -67,7 +67,7 @@ public class Panel extends JPanel {
|
||||
|
||||
panelInfox = 0;
|
||||
panelInfoy = 0;
|
||||
|
||||
scrollfactor = 0;
|
||||
|
||||
// objects.add(new Podium(new Point2D.Double(100, 100)));
|
||||
// objects.add(new Podium(new Point2D.Double(500, 100)));
|
||||
@@ -90,7 +90,7 @@ public class Panel extends JPanel {
|
||||
case 1:
|
||||
return new Toilet(null);
|
||||
case 2:
|
||||
return new Toilet(null);
|
||||
return new Podium(null);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class Panel extends JPanel {
|
||||
// g2.drawImage(podiumImage, 0, 0, null);
|
||||
for(BufferedImage image : panelInfo)
|
||||
{
|
||||
g2.drawImage(image, panelInfox, panelInfoy, null);
|
||||
g2.drawImage(image, panelInfox - scrollfactor, panelInfoy, null);
|
||||
panelInfox += image.getWidth();
|
||||
}
|
||||
panelInfox = 0;
|
||||
@@ -249,6 +249,22 @@ public class Panel extends JPanel {
|
||||
public void setPanelTypes(ArrayList<Object> panelTypes) {
|
||||
this.panelTypes = panelTypes;
|
||||
}
|
||||
|
||||
public int getScrollfactor() {
|
||||
return scrollfactor;
|
||||
}
|
||||
|
||||
public void setScrollfactor(int scrollfactor) {
|
||||
this.scrollfactor = scrollfactor;
|
||||
}
|
||||
|
||||
public int getPanelInfox() {
|
||||
return panelInfox;
|
||||
}
|
||||
|
||||
public void setPanelInfox(int panelInfox) {
|
||||
this.panelInfox = panelInfox;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Mouse extends MouseAdapter {
|
||||
int last = 0;
|
||||
for(BufferedImage image : panel.getPanelInfo())
|
||||
{
|
||||
if(e.getX() < last + image.getWidth())
|
||||
if(e.getX() < last + image.getWidth() - panel.getScrollfactor())
|
||||
{
|
||||
DrawObject tempDrawObj = panel.createNewDrawObject(i);
|
||||
tempDrawObj.setPosition(clickPoint);
|
||||
|
||||
@@ -9,12 +9,14 @@ import Applicatie.Panel;
|
||||
|
||||
public class MouseWheel implements MouseWheelListener {
|
||||
private Panel panel;
|
||||
|
||||
private int scrollfactor, min, max;
|
||||
|
||||
public MouseWheel(Panel panel)
|
||||
{
|
||||
this.panel = panel;
|
||||
scrollfactor = 20;
|
||||
}
|
||||
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
Point2D clickPoint = panel.getClickPoint(e.getPoint());
|
||||
for(DrawObject o : panel.getObjects())
|
||||
@@ -27,10 +29,29 @@ public class MouseWheel implements MouseWheelListener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// cameraPoint
|
||||
double cameraScale = panel.getCameraScale() * 1 - (e.getPreciseWheelRotation()/10);
|
||||
panel.setCameraScale((float) cameraScale);
|
||||
|
||||
if(e.getY() < 150)
|
||||
{
|
||||
|
||||
if(e.getPreciseWheelRotation() < 0)
|
||||
{
|
||||
panel.setScrollfactor(panel.getScrollfactor() - scrollfactor);
|
||||
}
|
||||
else
|
||||
{
|
||||
panel.setScrollfactor(panel.getScrollfactor() + scrollfactor);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// cameraPoint
|
||||
double cameraScale = panel.getCameraScale() * 1 - (e.getPreciseWheelRotation()/10);
|
||||
panel.setCameraScale((float) cameraScale);
|
||||
|
||||
}
|
||||
|
||||
|
||||
panel.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user