Merge banaan dev
This commit is contained in:
+64
-35
@@ -6,6 +6,7 @@ import java.awt.event.ActionListener;
|
|||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuBar;
|
import javax.swing.JMenuBar;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
public class MenuBar extends JMenuBar
|
public class MenuBar extends JMenuBar
|
||||||
{
|
{
|
||||||
@@ -17,8 +18,40 @@ public class MenuBar extends JMenuBar
|
|||||||
|
|
||||||
JMenu file = new JMenu("File");
|
JMenu file = new JMenu("File");
|
||||||
|
|
||||||
JMenuItem exit = new JMenuItem("Exit");
|
JMenuItem item = new JMenuItem("New");
|
||||||
exit.addActionListener(new ActionListener()
|
item.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
NewWorldPanel world = new NewWorldPanel(w.getPanel());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
file.add(item);
|
||||||
|
|
||||||
|
item = new JMenuItem("Open");
|
||||||
|
item.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
file.add(item);
|
||||||
|
|
||||||
|
item = new JMenuItem("Save");
|
||||||
|
item.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
file.add(item);
|
||||||
|
|
||||||
|
file.addSeparator();
|
||||||
|
|
||||||
|
item = new JMenuItem("Exit");
|
||||||
|
item.addActionListener(new ActionListener()
|
||||||
{
|
{
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
@@ -26,39 +59,35 @@ public class MenuBar extends JMenuBar
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JMenuItem save = new JMenuItem("Save");
|
file.add(item);
|
||||||
save.addActionListener(new ActionListener()
|
|
||||||
{
|
|
||||||
public void actionPerformed(ActionEvent e)
|
|
||||||
{
|
|
||||||
SaveLoad.save(w.getPanel());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem load = new JMenuItem("Load terrain");
|
|
||||||
load.addActionListener(new ActionListener()
|
|
||||||
{
|
|
||||||
public void actionPerformed(ActionEvent e)
|
|
||||||
{
|
|
||||||
SaveLoad.load(w.getPanel());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem loadagenda = new JMenuItem("Load agenda");
|
|
||||||
loadagenda.addActionListener(new ActionListener()
|
|
||||||
{
|
|
||||||
public void actionPerformed(ActionEvent e)
|
|
||||||
{
|
|
||||||
w.getPanel().getAgenda().loadAgenda();
|
|
||||||
w.getPanel().addVisitors();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
file.add(load);
|
|
||||||
file.add(loadagenda);
|
|
||||||
file.add(save);
|
|
||||||
file.add(exit);
|
|
||||||
|
|
||||||
add(file);
|
add(file);
|
||||||
|
|
||||||
|
file = new JMenu("Path");
|
||||||
|
|
||||||
|
item = new JMenuItem("New Path");
|
||||||
|
item.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
w.getPanel().startPath();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
file.add(item);
|
||||||
|
add(file);
|
||||||
|
|
||||||
|
file = new JMenu("Help");
|
||||||
|
|
||||||
|
item = new JMenuItem("About");
|
||||||
|
item.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
JOptionPane.showMessageDialog(w.getFrames()[0],"Festivalplanner\nMade by: Wesley de Hek, Kenneth van Ewijk, Remco Sannen, Yorick Rommers & Guus van Dongen ");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
file.add(item);
|
||||||
|
add(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package Applicatie;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
public class NewWorldPanel extends JFrame {
|
||||||
|
|
||||||
|
public NewWorldPanel(Panel topPanel) {
|
||||||
|
super("New World");
|
||||||
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
|
|
||||||
|
String[] terrains = {"Grass", "Sand"};
|
||||||
|
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
|
JButton button;
|
||||||
|
JLabel label;
|
||||||
|
JTextField heightTextField;
|
||||||
|
JTextField widthTextField;
|
||||||
|
JComboBox terrainBox;
|
||||||
|
|
||||||
|
//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)));
|
||||||
|
//Width:
|
||||||
|
JPanel linePanel = new JPanel();
|
||||||
|
label = new JLabel("Width: ");
|
||||||
|
widthTextField = new JTextField("1920");
|
||||||
|
widthTextField.setPreferredSize(new Dimension(100,20));
|
||||||
|
linePanel.add(label);
|
||||||
|
linePanel.add(widthTextField);
|
||||||
|
panel.add(linePanel);
|
||||||
|
//Height:
|
||||||
|
linePanel = new JPanel();
|
||||||
|
label = new JLabel("Height: ");
|
||||||
|
heightTextField = new JTextField("1080");
|
||||||
|
heightTextField.setPreferredSize(new Dimension(100,20));
|
||||||
|
linePanel.add(label);
|
||||||
|
linePanel.add(heightTextField);
|
||||||
|
panel.add(linePanel);
|
||||||
|
//Terrain:
|
||||||
|
linePanel = new JPanel();
|
||||||
|
label = new JLabel("Terrain: ");
|
||||||
|
terrainBox = new JComboBox(terrains);
|
||||||
|
terrainBox.setPreferredSize(new Dimension(100,20));
|
||||||
|
linePanel.add(label);
|
||||||
|
linePanel.add(terrainBox);
|
||||||
|
panel.add(linePanel);
|
||||||
|
//Image:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mainPanel.add(panel,BorderLayout.NORTH);
|
||||||
|
//Bottom:
|
||||||
|
panel = new JPanel();
|
||||||
|
//Cancel:
|
||||||
|
button = new JButton("Cancel");
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
NewWorldPanel.this.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
button = new JButton("Apply");
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
topPanel.newWorld(Integer.parseInt(widthTextField.getText()),Integer.parseInt(heightTextField.getText()),terrainBox.getSelectedIndex());
|
||||||
|
NewWorldPanel.this.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
|
||||||
|
mainPanel.add(panel,BorderLayout.SOUTH);
|
||||||
|
add(mainPanel);
|
||||||
|
|
||||||
|
//Finishing off
|
||||||
|
pack();
|
||||||
|
setSize(300,350);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
+46
-18
@@ -38,9 +38,10 @@ import Objects.Toilet;
|
|||||||
import Objects.Wall;
|
import Objects.Wall;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class Panel extends JPanel implements ActionListener
|
public class Panel extends JPanel implements ActionListener
|
||||||
{
|
{
|
||||||
|
|
||||||
|
BufferedImage grass, sand;
|
||||||
BufferedImage background;
|
BufferedImage background;
|
||||||
BufferedImage podiumImage, toiletImage, entranceImage, pathImage, wallImage, foodImage;
|
BufferedImage podiumImage, toiletImage, entranceImage, pathImage, wallImage, foodImage;
|
||||||
|
|
||||||
@@ -56,6 +57,8 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
private DrawObject selectedObject;
|
private DrawObject selectedObject;
|
||||||
private String clickedOption = "drag";
|
private String clickedOption = "drag";
|
||||||
private Path currentPath;
|
private Path currentPath;
|
||||||
|
private int width = 1920;
|
||||||
|
private int height = 1080;
|
||||||
|
|
||||||
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
|
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
|
||||||
float cameraScale = 1;
|
float cameraScale = 1;
|
||||||
@@ -66,9 +69,10 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
Point2D selectionPosition = new Point(0, 0);
|
Point2D selectionPosition = new Point(0, 0);
|
||||||
Images images = new Images();
|
Images images = new Images();
|
||||||
javax.swing.Timer t;
|
javax.swing.Timer t;
|
||||||
|
|
||||||
int currentTime = 540;
|
int currentTime = 540;
|
||||||
int tick = 0;
|
int tick = 0;
|
||||||
|
|
||||||
// how to nieuwe dingen aan het panel toe te voegen:
|
// how to nieuwe dingen aan het panel toe te voegen:
|
||||||
// maak bufferedimage global aan, voeg er een image aan toe, en voeg de
|
// maak bufferedimage global aan, voeg er een image aan toe, en voeg de
|
||||||
// image aan panelInfo toe en het object aan panelTypes.
|
// image aan panelInfo toe en het object aan panelTypes.
|
||||||
@@ -91,13 +95,15 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
pp.setPanel(this);
|
pp.setPanel(this);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
background = ImageIO.read(new File("images/grass.jpg"));
|
grass = ImageIO.read(new File("images/grass.jpg"));
|
||||||
|
sand = ImageIO.read(new File("images/sand.jpg"));
|
||||||
podiumImage = ImageIO.read(new File("images/stageIcon.png"));
|
podiumImage = ImageIO.read(new File("images/stageIcon.png"));
|
||||||
toiletImage = ImageIO.read(new File("images/wcIcon.png"));
|
toiletImage = ImageIO.read(new File("images/wcIcon.png"));
|
||||||
entranceImage = ImageIO.read(new File("images/entranceIcon.png"));
|
entranceImage = ImageIO.read(new File("images/entranceIcon.png"));
|
||||||
pathImage = ImageIO.read(new File("images/pathIcon.png"));
|
pathImage = ImageIO.read(new File("images/pathIcon.png"));
|
||||||
wallImage = ImageIO.read(new File("images/wallIcon.png"));
|
wallImage = ImageIO.read(new File("images/wallIcon.png"));
|
||||||
foodImage = ImageIO.read(new File("images/foodIcon.png"));
|
foodImage = ImageIO.read(new File("images/foodIcon.png"));
|
||||||
|
background = grass;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -109,7 +115,7 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
panelInfo.add(pathImage);
|
panelInfo.add(pathImage);
|
||||||
panelInfo.add(wallImage);
|
panelInfo.add(wallImage);
|
||||||
panelInfo.add(foodImage);
|
panelInfo.add(foodImage);
|
||||||
|
|
||||||
agenda = new Agenda();
|
agenda = new Agenda();
|
||||||
|
|
||||||
panelInfox = 0;
|
panelInfox = 0;
|
||||||
@@ -125,11 +131,9 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
addMouseMotionListener(new MouseMotion(this));
|
addMouseMotionListener(new MouseMotion(this));
|
||||||
|
|
||||||
addMouseWheelListener(new MouseWheel(this));
|
addMouseWheelListener(new MouseWheel(this));
|
||||||
t = new Timer(1000/100, this);
|
t = new Timer(1000 / 100, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getPanelInfoLength()
|
public int getPanelInfoLength()
|
||||||
{
|
{
|
||||||
int panelInfoLength = 0;
|
int panelInfoLength = 0;
|
||||||
@@ -171,10 +175,10 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
{
|
{
|
||||||
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects));
|
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addVisitors(int count)
|
public void addVisitors(int count)
|
||||||
{
|
{
|
||||||
for(int i = 0 ; i < count ; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects));
|
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects));
|
||||||
}
|
}
|
||||||
@@ -202,7 +206,8 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
|
|
||||||
TexturePaint p = new TexturePaint(background, new Rectangle2D.Double(0, 0, 100, 100));
|
TexturePaint p = new TexturePaint(background, new Rectangle2D.Double(0, 0, 100, 100));
|
||||||
g2.setPaint(p);
|
g2.setPaint(p);
|
||||||
g2.fill(new Rectangle2D.Double(-1920, -1080, 3840, 2160));
|
|
||||||
|
g2.fill(new Rectangle2D.Double(-width / 2, -height / 2, width, height));
|
||||||
|
|
||||||
BasicStroke stroke = new BasicStroke(10);
|
BasicStroke stroke = new BasicStroke(10);
|
||||||
g2.setStroke(stroke);
|
g2.setStroke(stroke);
|
||||||
@@ -215,11 +220,12 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
{
|
{
|
||||||
o.draw(g2);
|
o.draw(g2);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Visitor v : visitors){
|
for (Visitor v : visitors)
|
||||||
|
{
|
||||||
v.draw(g2);
|
v.draw(g2);
|
||||||
}
|
}
|
||||||
|
|
||||||
g2.setTransform(oldTransform);
|
g2.setTransform(oldTransform);
|
||||||
if (currentPath != null)
|
if (currentPath != null)
|
||||||
{ // Display text while in path making modes.
|
{ // Display text while in path making modes.
|
||||||
@@ -524,19 +530,22 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
tick++;
|
tick++;
|
||||||
if ( tick >= 10 && visitors.size() > 0){
|
if (tick >= 10 && visitors.size() > 0)
|
||||||
|
{
|
||||||
tick = 0;
|
tick = 0;
|
||||||
currentTime++;
|
currentTime++;
|
||||||
System.out.println(currentTime);
|
System.out.println(currentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Visitor v: visitors){
|
for (Visitor v : visitors)
|
||||||
|
{
|
||||||
v.update(objects, currentTime, visitors);
|
v.update(objects, currentTime, visitors);
|
||||||
}
|
}
|
||||||
repaint();
|
repaint();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public javax.swing.Timer getT()
|
public javax.swing.Timer getT()
|
||||||
@@ -548,4 +557,23 @@ public class Panel extends JPanel implements ActionListener
|
|||||||
{
|
{
|
||||||
this.t = t;
|
this.t = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void newWorld(int width, int height, int terrainIndex)
|
||||||
|
{
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
paths.clear();
|
||||||
|
objects.clear();
|
||||||
|
cameraScale = 1;
|
||||||
|
switch (terrainIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
background = grass;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
background = sand;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,19 +23,17 @@ import javax.swing.JTextField;
|
|||||||
import Objects.DrawObject;
|
import Objects.DrawObject;
|
||||||
import Objects.Path;
|
import Objects.Path;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class PropertiesPanel extends JPanel
|
public class PropertiesPanel extends JPanel
|
||||||
{
|
{
|
||||||
|
|
||||||
DrawObject selectedObject = null;
|
DrawObject selectedObject = null;
|
||||||
Path selectedPath = null;
|
Path selectedPath = null;
|
||||||
|
|
||||||
Panel p = null;
|
Panel p = null;
|
||||||
|
|
||||||
Dimension spacerDimension = new Dimension(200, 10);
|
Dimension spacerDimension = new Dimension(200, 10);
|
||||||
|
|
||||||
|
|
||||||
JLabel nameLabel;
|
JLabel nameLabel;
|
||||||
JPanel areaPanel;
|
JPanel areaPanel;
|
||||||
Component rigidArea;
|
Component rigidArea;
|
||||||
@@ -88,10 +86,11 @@ public class PropertiesPanel extends JPanel
|
|||||||
buttonPanel.setMaximumSize(new Dimension(200, 40));
|
buttonPanel.setMaximumSize(new Dimension(200, 40));
|
||||||
buttonPanel.add(buttonLabel);
|
buttonPanel.add(buttonLabel);
|
||||||
add(buttonPanel);
|
add(buttonPanel);
|
||||||
|
|
||||||
//AREA PANEL: AVAILABLE FOR ACTIONLISTENER
|
// AREA PANEL: AVAILABLE FOR ACTIONLISTENER
|
||||||
areaPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
areaPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
areaPanel.setVisible(false);
|
areaPanel.setVisible(false);
|
||||||
|
|
||||||
rigidArea = Box.createRigidArea(spacerDimension);
|
rigidArea = Box.createRigidArea(spacerDimension);
|
||||||
rigidArea.setVisible(false);
|
rigidArea.setVisible(false);
|
||||||
|
|
||||||
@@ -103,9 +102,10 @@ public class PropertiesPanel extends JPanel
|
|||||||
{
|
{
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
if(selectedObject != null)
|
if (selectedObject != null)
|
||||||
p.removeObject(selectedObject);
|
p.removeObject(selectedObject);
|
||||||
else if(selectedPath != null) {
|
else if (selectedPath != null)
|
||||||
|
{
|
||||||
p.removePath(selectedPath);
|
p.removePath(selectedPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,6 +118,7 @@ public class PropertiesPanel extends JPanel
|
|||||||
{
|
{
|
||||||
areaPanel.setVisible(!areaPanel.isVisible());
|
areaPanel.setVisible(!areaPanel.isVisible());
|
||||||
rigidArea.setVisible(!rigidArea.isVisible());
|
rigidArea.setVisible(!rigidArea.isVisible());
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
row1ButtonPanel.setPreferredSize(new Dimension(200, 50));
|
row1ButtonPanel.setPreferredSize(new Dimension(200, 50));
|
||||||
@@ -125,30 +126,33 @@ public class PropertiesPanel extends JPanel
|
|||||||
row1ButtonPanel.add(deleteButton);
|
row1ButtonPanel.add(deleteButton);
|
||||||
row1ButtonPanel.add(areaButton);
|
row1ButtonPanel.add(areaButton);
|
||||||
add(row1ButtonPanel);
|
add(row1ButtonPanel);
|
||||||
|
|
||||||
add(rigidArea);
|
add(rigidArea);
|
||||||
|
|
||||||
//AREA PANEL
|
// AREA PANEL
|
||||||
JLabel areaLabel = new JLabel("Area size");
|
JLabel areaLabel = new JLabel("Area size");
|
||||||
areaLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
areaLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
||||||
areaPanel.setPreferredSize(new Dimension(200, 180));
|
areaPanel.setPreferredSize(new Dimension(200, 150));
|
||||||
areaPanel.setMaximumSize(new Dimension(200, 180));
|
areaPanel.setMaximumSize(new Dimension(200, 250));
|
||||||
areaPanel.add(areaLabel);
|
areaPanel.add(areaLabel);
|
||||||
add(areaPanel);
|
add(areaPanel);
|
||||||
{
|
{
|
||||||
JPanel areaTopPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel areaTopPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
areaTopPanel.setPreferredSize(new Dimension(200, 30));
|
areaTopPanel.setPreferredSize(new Dimension(200, 50));
|
||||||
areaPanel.add(areaTopPanel);
|
areaPanel.add(areaTopPanel);
|
||||||
|
|
||||||
JLabel areaTopLabel = new JLabel("Top ");
|
JLabel areaTopLabel = new JLabel("Top");
|
||||||
areaTopPanel.add(areaTopLabel);
|
areaTopPanel.add(areaTopLabel);
|
||||||
areaTopField = new JTextField();
|
areaTopField = new JTextField();
|
||||||
areaTopField.setPreferredSize(new Dimension(120, 25));
|
areaTopField.setPreferredSize(new Dimension(140, 25));
|
||||||
|
|
||||||
{
|
{
|
||||||
areaTopField.addKeyListener(new KeyListener()
|
areaTopField.addKeyListener(new KeyListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
public void keyTyped(KeyEvent e){}
|
public void keyTyped(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e)
|
public void keyReleased(KeyEvent e)
|
||||||
{
|
{
|
||||||
@@ -158,20 +162,24 @@ public class PropertiesPanel extends JPanel
|
|||||||
int top = Integer.parseInt(areaTopField.getText());
|
int top = Integer.parseInt(areaTopField.getText());
|
||||||
selectedObject.setAreaTop(top);
|
selectedObject.setAreaTop(top);
|
||||||
p.update();
|
p.update();
|
||||||
} catch (NumberFormatException nfe)
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
areaTopField.setBackground(Color.RED);
|
areaTopField.setBackground(Color.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyPressed(KeyEvent e){}
|
public void keyPressed(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
areaTopPanel.add(areaTopField);
|
areaTopPanel.add(areaTopField);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JPanel areaBottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel areaBottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
areaBottomPanel.setPreferredSize(new Dimension(200, 30));
|
areaBottomPanel.setPreferredSize(new Dimension(200, 50));
|
||||||
|
|
||||||
areaPanel.add(areaBottomPanel);
|
areaPanel.add(areaBottomPanel);
|
||||||
|
|
||||||
JLabel areaBottomLabel = new JLabel("Bottom");
|
JLabel areaBottomLabel = new JLabel("Bottom");
|
||||||
@@ -182,7 +190,9 @@ public class PropertiesPanel extends JPanel
|
|||||||
areaBottomField.addKeyListener(new KeyListener()
|
areaBottomField.addKeyListener(new KeyListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
public void keyTyped(KeyEvent e){}
|
public void keyTyped(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e)
|
public void keyReleased(KeyEvent e)
|
||||||
{
|
{
|
||||||
@@ -192,31 +202,36 @@ public class PropertiesPanel extends JPanel
|
|||||||
int bottom = Integer.parseInt(areaBottomField.getText());
|
int bottom = Integer.parseInt(areaBottomField.getText());
|
||||||
selectedObject.setAreaBottom(bottom);
|
selectedObject.setAreaBottom(bottom);
|
||||||
p.update();
|
p.update();
|
||||||
} catch (NumberFormatException nfe)
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
areaBottomField.setBackground(Color.RED);
|
areaBottomField.setBackground(Color.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyPressed(KeyEvent e){}
|
public void keyPressed(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
areaBottomPanel.add(areaBottomField);
|
areaBottomPanel.add(areaBottomField);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JPanel areaLeftPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel areaLeftPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
areaLeftPanel.setPreferredSize(new Dimension(200, 30));
|
areaLeftPanel.setPreferredSize(new Dimension(200, 50));
|
||||||
areaPanel.add(areaLeftPanel);
|
areaPanel.add(areaLeftPanel);
|
||||||
|
|
||||||
JLabel areaLeftLabel = new JLabel("Left ");
|
JLabel areaLeftLabel = new JLabel("Left");
|
||||||
areaLeftPanel.add(areaLeftLabel);
|
areaLeftPanel.add(areaLeftLabel);
|
||||||
areaLeftField = new JTextField();
|
areaLeftField = new JTextField();
|
||||||
areaLeftField.setPreferredSize(new Dimension(120, 25));
|
areaLeftField.setPreferredSize(new Dimension(138, 25));
|
||||||
{
|
{
|
||||||
areaLeftField.addKeyListener(new KeyListener()
|
areaLeftField.addKeyListener(new KeyListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
public void keyTyped(KeyEvent e){}
|
public void keyTyped(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e)
|
public void keyReleased(KeyEvent e)
|
||||||
{
|
{
|
||||||
@@ -226,31 +241,37 @@ public class PropertiesPanel extends JPanel
|
|||||||
int left = Integer.parseInt(areaLeftField.getText());
|
int left = Integer.parseInt(areaLeftField.getText());
|
||||||
selectedObject.setAreaLeft(left);
|
selectedObject.setAreaLeft(left);
|
||||||
p.update();
|
p.update();
|
||||||
} catch (NumberFormatException nfe)
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
areaLeftField.setBackground(Color.RED);
|
areaLeftField.setBackground(Color.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyPressed(KeyEvent e){}
|
public void keyPressed(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
areaLeftPanel.add(areaLeftField);
|
areaLeftPanel.add(areaLeftField);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JPanel areaRightPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel areaRightPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
areaRightPanel.setPreferredSize(new Dimension(200, 30));
|
|
||||||
|
areaRightPanel.setPreferredSize(new Dimension(200, 50));
|
||||||
areaPanel.add(areaRightPanel);
|
areaPanel.add(areaRightPanel);
|
||||||
|
|
||||||
JLabel areaRightLabel = new JLabel("Right ");
|
JLabel areaRightLabel = new JLabel("Right");
|
||||||
areaRightPanel.add(areaRightLabel);
|
areaRightPanel.add(areaRightLabel);
|
||||||
areaRightField = new JTextField();
|
areaRightField = new JTextField();
|
||||||
areaRightField.setPreferredSize(new Dimension(120, 25));
|
areaRightField.setPreferredSize(new Dimension(130, 25));
|
||||||
{
|
{
|
||||||
areaRightField.addKeyListener(new KeyListener()
|
areaRightField.addKeyListener(new KeyListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
public void keyTyped(KeyEvent e){}
|
public void keyTyped(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e)
|
public void keyReleased(KeyEvent e)
|
||||||
{
|
{
|
||||||
@@ -260,13 +281,16 @@ public class PropertiesPanel extends JPanel
|
|||||||
int right = Integer.parseInt(areaRightField.getText());
|
int right = Integer.parseInt(areaRightField.getText());
|
||||||
selectedObject.setAreaRight(right);
|
selectedObject.setAreaRight(right);
|
||||||
p.update();
|
p.update();
|
||||||
} catch (NumberFormatException nfe)
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
areaRightField.setBackground(Color.RED);
|
areaRightField.setBackground(Color.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyPressed(KeyEvent e){}
|
public void keyPressed(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
areaRightPanel.add(areaRightField);
|
areaRightPanel.add(areaRightField);
|
||||||
@@ -308,7 +332,8 @@ public class PropertiesPanel extends JPanel
|
|||||||
double xpos = Double.parseDouble(locationXField.getText());
|
double xpos = Double.parseDouble(locationXField.getText());
|
||||||
selectedObject.setPosition(new Point2D.Double(xpos, selectedObject.getPosition().getY()));
|
selectedObject.setPosition(new Point2D.Double(xpos, selectedObject.getPosition().getY()));
|
||||||
p.update();
|
p.update();
|
||||||
} catch (NumberFormatException nfe)
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
locationXField.setBackground(Color.RED);
|
locationXField.setBackground(Color.RED);
|
||||||
}
|
}
|
||||||
@@ -347,7 +372,8 @@ public class PropertiesPanel extends JPanel
|
|||||||
selectedObject.setPosition(new Point2D.Double(selectedObject.getPosition().getX(), ypos));
|
selectedObject.setPosition(new Point2D.Double(selectedObject.getPosition().getX(), ypos));
|
||||||
;
|
;
|
||||||
p.update();
|
p.update();
|
||||||
} catch (NumberFormatException nfe)
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
|
|
||||||
locationYField.setBackground(Color.RED);
|
locationYField.setBackground(Color.RED);
|
||||||
@@ -396,7 +422,8 @@ public class PropertiesPanel extends JPanel
|
|||||||
double scale = Double.parseDouble(scaleField.getText());
|
double scale = Double.parseDouble(scaleField.getText());
|
||||||
selectedObject.setScale(scale);
|
selectedObject.setScale(scale);
|
||||||
p.update();
|
p.update();
|
||||||
} catch (NumberFormatException nfe)
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
scaleField.setBackground(Color.RED);
|
scaleField.setBackground(Color.RED);
|
||||||
}
|
}
|
||||||
@@ -444,7 +471,8 @@ public class PropertiesPanel extends JPanel
|
|||||||
rotationField.setText(rotation + "");
|
rotationField.setText(rotation + "");
|
||||||
selectedObject.setRotation(rotation);
|
selectedObject.setRotation(rotation);
|
||||||
p.update();
|
p.update();
|
||||||
} catch (NumberFormatException nfe)
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
rotationField.setBackground(Color.RED);
|
rotationField.setBackground(Color.RED);
|
||||||
}
|
}
|
||||||
@@ -491,8 +519,8 @@ public class PropertiesPanel extends JPanel
|
|||||||
|
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
if(selectedObject != null)
|
if (selectedObject != null)
|
||||||
fillFields();
|
fillFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableComponents(Container container, boolean enable)
|
private void enableComponents(Container container, boolean enable)
|
||||||
@@ -532,18 +560,18 @@ public class PropertiesPanel extends JPanel
|
|||||||
|
|
||||||
private void fillFields()
|
private void fillFields()
|
||||||
{
|
{
|
||||||
|
|
||||||
nameLabel.setText(selectedObject.getName());
|
|
||||||
|
|
||||||
locationXField.setText(Math.round(selectedObject.getPosition().getX()) + "");
|
nameLabel.setText(selectedObject.getName());
|
||||||
locationYField.setText(Math.round(selectedObject.getPosition().getY()) + "");
|
|
||||||
scaleField.setText((double) Math.round(selectedObject.getScale() * 10) / 10 + "");
|
locationXField.setText(Math.round(selectedObject.getPosition().getX()) + "");
|
||||||
rotationField.setText(Math.round(selectedObject.getRotation() % 360) + "");
|
locationYField.setText(Math.round(selectedObject.getPosition().getY()) + "");
|
||||||
|
scaleField.setText((double) Math.round(selectedObject.getScale() * 10) / 10 + "");
|
||||||
areaTopField.setText(selectedObject.getAreaTop() + "");
|
rotationField.setText(Math.round(selectedObject.getRotation() % 360) + "");
|
||||||
areaBottomField.setText(selectedObject.getAreaBottom() + "");
|
|
||||||
areaLeftField.setText(selectedObject.getAreaLeft() + "");
|
areaTopField.setText(selectedObject.getAreaTop() + "");
|
||||||
areaRightField.setText(selectedObject.getAreaRight() + "");
|
areaBottomField.setText(selectedObject.getAreaBottom() + "");
|
||||||
|
areaLeftField.setText(selectedObject.getAreaLeft() + "");
|
||||||
|
areaRightField.setText(selectedObject.getAreaRight() + "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,14 +579,16 @@ public class PropertiesPanel extends JPanel
|
|||||||
{
|
{
|
||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedPath(Path path) {
|
public void setSelectedPath(Path path)
|
||||||
|
{
|
||||||
selectedObject = null;
|
selectedObject = null;
|
||||||
selectedPath = path;
|
selectedPath = path;
|
||||||
fillPathFields();
|
fillPathFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillPathFields() {
|
private void fillPathFields()
|
||||||
|
{
|
||||||
nameLabel.setText("Path");
|
nameLabel.setText("Path");
|
||||||
enableComponents(this, true);
|
enableComponents(this, true);
|
||||||
locationXField.setEnabled(false);
|
locationXField.setEnabled(false);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.awt.event.MouseWheelListener;
|
|||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
import Applicatie.Panel;
|
import Applicatie.Panel;
|
||||||
|
import Objects.DrawObject;
|
||||||
|
|
||||||
public class MouseWheel implements MouseWheelListener
|
public class MouseWheel implements MouseWheelListener
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
Reference in New Issue
Block a user