merge banaan dev
This commit is contained in:
@@ -82,8 +82,12 @@ public class MenuBar extends JMenuBar {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to close this program?", "Close Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to close this program?", "Close Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
w.setVisible(false);
|
w.setVisible(false);
|
||||||
w.dispose();
|
w.dispose();
|
||||||
|
=======
|
||||||
|
System.exit(0);
|
||||||
|
>>>>>>> origin/Banaan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ package Agenda;
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
<<<<<<< HEAD
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
|
=======
|
||||||
|
>>>>>>> origin/Banaan
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|||||||
+16
-3
@@ -43,7 +43,7 @@ public class MenuBar extends JMenuBar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SaveLoad.load(w.getPanel());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
file.add(item);
|
file.add(item);
|
||||||
@@ -53,7 +53,19 @@ public class MenuBar extends JMenuBar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SaveLoad.save(w.getPanel());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
file.add(item);
|
||||||
|
|
||||||
|
file.addSeparator();
|
||||||
|
|
||||||
|
item = new JMenuItem("Agenda");
|
||||||
|
item.addActionListener(new ActionListener()
|
||||||
|
{
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
new Agenda.Window();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
file.add(item);
|
file.add(item);
|
||||||
@@ -65,7 +77,8 @@ public class MenuBar extends JMenuBar
|
|||||||
{
|
{
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
System.exit(0);
|
w.setVisible(false);
|
||||||
|
w.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,17 @@ package Applicatie;
|
|||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
@@ -14,12 +20,24 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class NewWorldPanel extends JFrame {
|
public class NewWorldPanel extends JFrame {
|
||||||
|
|
||||||
|
BufferedImage grass,sand,selectedImage;
|
||||||
|
|
||||||
public NewWorldPanel(Panel topPanel) {
|
public NewWorldPanel(Panel topPanel) {
|
||||||
super("New World");
|
super("New World");
|
||||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
|
setResizable(false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
grass = ImageIO.read(new File("images/grassIcon.jpg"));
|
||||||
|
sand = ImageIO.read(new File("images/sand.jpg"));
|
||||||
|
selectedImage = grass;
|
||||||
|
}
|
||||||
|
catch(IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
String[] terrains = {"Grass", "Sand"};
|
String[] terrains = {"Grass", "Sand"};
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
JButton button;
|
JButton button;
|
||||||
@@ -27,17 +45,20 @@ public class NewWorldPanel extends JFrame {
|
|||||||
JTextField heightTextField;
|
JTextField heightTextField;
|
||||||
JTextField widthTextField;
|
JTextField widthTextField;
|
||||||
JComboBox terrainBox;
|
JComboBox terrainBox;
|
||||||
|
JLabel imageLabel;
|
||||||
|
|
||||||
//Top:
|
//Top:
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
BoxLayout box = new BoxLayout(panel, BoxLayout.Y_AXIS);
|
BoxLayout box = new BoxLayout(panel, BoxLayout.Y_AXIS);
|
||||||
panel.setLayout(box);
|
panel.setLayout(box);
|
||||||
panel.add(Box.createRigidArea(new Dimension(0,20)));
|
panel.add(Box.createRigidArea(new Dimension(0,10)));
|
||||||
label = new JLabel("Enter your preferences: ");
|
JPanel linePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
panel.add(label);
|
label = new JLabel(" Enter your preferences: ");
|
||||||
panel.add(Box.createRigidArea(new Dimension(0,15)));
|
linePanel.add(label);
|
||||||
|
panel.add(linePanel);
|
||||||
|
panel.add(Box.createRigidArea(new Dimension(0,10)));
|
||||||
//Width:
|
//Width:
|
||||||
JPanel linePanel = new JPanel();
|
linePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||||
label = new JLabel("Width: ");
|
label = new JLabel("Width: ");
|
||||||
widthTextField = new JTextField("1920");
|
widthTextField = new JTextField("1920");
|
||||||
widthTextField.setPreferredSize(new Dimension(100,20));
|
widthTextField.setPreferredSize(new Dimension(100,20));
|
||||||
@@ -45,7 +66,7 @@ public class NewWorldPanel extends JFrame {
|
|||||||
linePanel.add(widthTextField);
|
linePanel.add(widthTextField);
|
||||||
panel.add(linePanel);
|
panel.add(linePanel);
|
||||||
//Height:
|
//Height:
|
||||||
linePanel = new JPanel();
|
linePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||||
label = new JLabel("Height: ");
|
label = new JLabel("Height: ");
|
||||||
heightTextField = new JTextField("1080");
|
heightTextField = new JTextField("1080");
|
||||||
heightTextField.setPreferredSize(new Dimension(100,20));
|
heightTextField.setPreferredSize(new Dimension(100,20));
|
||||||
@@ -53,17 +74,33 @@ public class NewWorldPanel extends JFrame {
|
|||||||
linePanel.add(heightTextField);
|
linePanel.add(heightTextField);
|
||||||
panel.add(linePanel);
|
panel.add(linePanel);
|
||||||
//Terrain:
|
//Terrain:
|
||||||
linePanel = new JPanel();
|
linePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||||
label = new JLabel("Terrain: ");
|
label = new JLabel("Terrain: ");
|
||||||
terrainBox = new JComboBox(terrains);
|
terrainBox = new JComboBox(terrains);
|
||||||
terrainBox.setPreferredSize(new Dimension(100,20));
|
terrainBox.setPreferredSize(new Dimension(100,20));
|
||||||
|
imageLabel = new JLabel(new ImageIcon(selectedImage));
|
||||||
|
terrainBox.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
switch(terrainBox.getSelectedIndex()) {
|
||||||
|
case 0:
|
||||||
|
selectedImage = grass;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
selectedImage = sand;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
imageLabel.setIcon(new ImageIcon(selectedImage));
|
||||||
|
}
|
||||||
|
});
|
||||||
linePanel.add(label);
|
linePanel.add(label);
|
||||||
linePanel.add(terrainBox);
|
linePanel.add(terrainBox);
|
||||||
panel.add(linePanel);
|
panel.add(linePanel);
|
||||||
//Image:
|
//Image:
|
||||||
|
linePanel = new JPanel();
|
||||||
|
linePanel.add(imageLabel);
|
||||||
|
panel.add(linePanel);
|
||||||
|
|
||||||
mainPanel.add(panel,BorderLayout.NORTH);
|
mainPanel.add(panel,BorderLayout.NORTH);
|
||||||
//Bottom:
|
//Bottom:
|
||||||
@@ -90,13 +127,12 @@ public class NewWorldPanel extends JFrame {
|
|||||||
});
|
});
|
||||||
panel.add(button);
|
panel.add(button);
|
||||||
|
|
||||||
|
|
||||||
mainPanel.add(panel,BorderLayout.SOUTH);
|
mainPanel.add(panel,BorderLayout.SOUTH);
|
||||||
add(mainPanel);
|
add(mainPanel);
|
||||||
|
|
||||||
//Finishing off
|
//Finishing off
|
||||||
pack();
|
pack();
|
||||||
setSize(300,350);
|
setSize(290,330);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import Agenda.Event;
|
|||||||
import Objects.DrawObject;
|
import Objects.DrawObject;
|
||||||
import Objects.Path;
|
import Objects.Path;
|
||||||
|
|
||||||
|
|
||||||
public class Visitor
|
public class Visitor
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -50,7 +51,6 @@ public class Visitor
|
|||||||
AffineTransform tx = new AffineTransform();
|
AffineTransform tx = new AffineTransform();
|
||||||
tx.scale(scale, scale);
|
tx.scale(scale, scale);
|
||||||
tx.translate(position.getX(), position.getY());
|
tx.translate(position.getX(), position.getY());
|
||||||
// System.out.println(position.getX());
|
|
||||||
tx.rotate(rotation, image.getWidth(null) / 2, image.getHeight(null) / 2);
|
tx.rotate(rotation, image.getWidth(null) / 2, image.getHeight(null) / 2);
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,7 @@ public class Visitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
moveToTarget(target, objects, visitors, paths);
|
moveToTarget(target, objects, visitors, paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import java.awt.event.KeyEvent;
|
|||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
import Applicatie.NewWorldPanel;
|
||||||
import Applicatie.Panel;
|
import Applicatie.Panel;
|
||||||
|
import Applicatie.SaveLoad;
|
||||||
|
|
||||||
public class Keyboard implements KeyListener {
|
public class Keyboard implements KeyListener {
|
||||||
|
|
||||||
@@ -54,6 +56,15 @@ public class Keyboard implements KeyListener {
|
|||||||
else if(e.getKeyCode() == e.VK_P) {
|
else if(e.getKeyCode() == e.VK_P) {
|
||||||
panel.startPath();
|
panel.startPath();
|
||||||
}
|
}
|
||||||
|
else if(e.getKeyCode() == e.VK_N) {
|
||||||
|
NewWorldPanel world = new NewWorldPanel(panel);
|
||||||
|
}
|
||||||
|
else if(e.getKeyCode() == e.VK_S) {
|
||||||
|
SaveLoad.save(panel);
|
||||||
|
}
|
||||||
|
else if(e.getKeyCode() == e.VK_O) {
|
||||||
|
SaveLoad.load(panel);
|
||||||
|
}
|
||||||
panel.repaint();
|
panel.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
Reference in New Issue
Block a user