merge banaan dev

This commit is contained in:
Yorick
2015-04-07 19:35:38 +02:00
8 changed files with 84 additions and 16 deletions
+4
View File
@@ -82,8 +82,12 @@ public class MenuBar extends JMenuBar {
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)
{
<<<<<<< HEAD
w.setVisible(false);
w.dispose();
=======
System.exit(0);
>>>>>>> origin/Banaan
}
}
});
+3
View File
@@ -4,7 +4,10 @@ package Agenda;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
<<<<<<< HEAD
import java.awt.FlowLayout;
=======
>>>>>>> origin/Banaan
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+16 -3
View File
@@ -43,7 +43,7 @@ public class MenuBar extends JMenuBar
@Override
public void actionPerformed(ActionEvent e) {
SaveLoad.load(w.getPanel());
}
});
file.add(item);
@@ -53,7 +53,19 @@ public class MenuBar extends JMenuBar
@Override
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);
@@ -65,7 +77,8 @@ public class MenuBar extends JMenuBar
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
w.setVisible(false);
w.dispose();
}
});
+48 -12
View File
@@ -2,11 +2,17 @@ package Applicatie;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
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.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
@@ -14,12 +20,24 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
@SuppressWarnings("serial")
public class NewWorldPanel extends JFrame {
BufferedImage grass,sand,selectedImage;
public NewWorldPanel(Panel topPanel) {
super("New World");
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"};
JPanel mainPanel = new JPanel(new BorderLayout());
JButton button;
@@ -27,17 +45,20 @@ public class NewWorldPanel extends JFrame {
JTextField heightTextField;
JTextField widthTextField;
JComboBox terrainBox;
JLabel imageLabel;
//Top:
JPanel panel = new JPanel();
BoxLayout box = new BoxLayout(panel, BoxLayout.Y_AXIS);
panel.setLayout(box);
panel.add(Box.createRigidArea(new Dimension(0,20)));
label = new JLabel("Enter your preferences: ");
panel.add(label);
panel.add(Box.createRigidArea(new Dimension(0,15)));
panel.add(Box.createRigidArea(new Dimension(0,10)));
JPanel linePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
label = new JLabel(" Enter your preferences: ");
linePanel.add(label);
panel.add(linePanel);
panel.add(Box.createRigidArea(new Dimension(0,10)));
//Width:
JPanel linePanel = new JPanel();
linePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
label = new JLabel("Width: ");
widthTextField = new JTextField("1920");
widthTextField.setPreferredSize(new Dimension(100,20));
@@ -45,7 +66,7 @@ public class NewWorldPanel extends JFrame {
linePanel.add(widthTextField);
panel.add(linePanel);
//Height:
linePanel = new JPanel();
linePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
label = new JLabel("Height: ");
heightTextField = new JTextField("1080");
heightTextField.setPreferredSize(new Dimension(100,20));
@@ -53,17 +74,33 @@ public class NewWorldPanel extends JFrame {
linePanel.add(heightTextField);
panel.add(linePanel);
//Terrain:
linePanel = new JPanel();
linePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
label = new JLabel("Terrain: ");
terrainBox = new JComboBox(terrains);
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(terrainBox);
panel.add(linePanel);
//Image:
linePanel = new JPanel();
linePanel.add(imageLabel);
panel.add(linePanel);
mainPanel.add(panel,BorderLayout.NORTH);
//Bottom:
@@ -90,13 +127,12 @@ public class NewWorldPanel extends JFrame {
});
panel.add(button);
mainPanel.add(panel,BorderLayout.SOUTH);
add(mainPanel);
//Finishing off
pack();
setSize(300,350);
setSize(290,330);
setLocationRelativeTo(null);
setVisible(true);
}
+2 -1
View File
@@ -12,6 +12,7 @@ import Agenda.Event;
import Objects.DrawObject;
import Objects.Path;
public class Visitor
{
@@ -50,7 +51,6 @@ public class Visitor
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;
}
@@ -66,6 +66,7 @@ public class Visitor
}
}
moveToTarget(target, objects, visitors, paths);
}
+11
View File
@@ -5,7 +5,9 @@ import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.geom.Point2D;
import Applicatie.NewWorldPanel;
import Applicatie.Panel;
import Applicatie.SaveLoad;
public class Keyboard implements KeyListener {
@@ -54,6 +56,15 @@ public class Keyboard implements KeyListener {
else if(e.getKeyCode() == e.VK_P) {
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();
}
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB