Added several thingz
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
package Applicatie;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class ControlPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 6805244250902524351L;
|
||||
|
||||
private Panel p;
|
||||
|
||||
public ControlPanel(Panel p)
|
||||
{
|
||||
super();
|
||||
BoxLayout box = new BoxLayout(this, BoxLayout.X_AXIS);
|
||||
setLayout(box);
|
||||
this.p = p;
|
||||
setPreferredSize(new Dimension(0,50));
|
||||
setBorder(BorderFactory.createLineBorder(new Color(180, 180, 180)));
|
||||
setBackground(new Color(220, 220, 220));
|
||||
|
||||
|
||||
JPanel simulatorPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
simulatorPanel.setPreferredSize(new Dimension(350,50));
|
||||
simulatorPanel.setMaximumSize(new Dimension(350,50));
|
||||
add(simulatorPanel);
|
||||
{
|
||||
JLabel simulatorLabel = new JLabel("Simulator: ");
|
||||
simulatorLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
||||
simulatorPanel.add(simulatorLabel);
|
||||
|
||||
JButton playButton = new JButton("Play");
|
||||
playButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
playButton.addActionListener(new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
p.getT().start();
|
||||
}
|
||||
});
|
||||
simulatorPanel.add(playButton);
|
||||
|
||||
JButton pauseButton = new JButton("Pause");
|
||||
pauseButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
pauseButton.addActionListener(new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
p.getT().stop();
|
||||
}
|
||||
});
|
||||
simulatorPanel.add(pauseButton);
|
||||
|
||||
JButton stopButton = new JButton("Stop");
|
||||
stopButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
stopButton.addActionListener(new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
p.getT().stop();
|
||||
}
|
||||
});
|
||||
simulatorPanel.add(stopButton);
|
||||
}
|
||||
|
||||
add(Box.createRigidArea(new Dimension(10,50)));
|
||||
|
||||
JPanel timePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
timePanel.setPreferredSize(new Dimension(280,50));
|
||||
timePanel.setMaximumSize(new Dimension(280,50));
|
||||
add(timePanel);
|
||||
{
|
||||
JLabel timeLabel = new JLabel("00:00 00-00-000");
|
||||
timeLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
timePanel.add(timeLabel);
|
||||
|
||||
JButton dateButton = new JButton("Pick Date");
|
||||
dateButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
dateButton.addActionListener(new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
///TODO implement
|
||||
}
|
||||
});
|
||||
timePanel.add(dateButton);
|
||||
}
|
||||
|
||||
add(Box.createRigidArea(new Dimension(10,50)));
|
||||
|
||||
JPanel peoplePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
peoplePanel.setPreferredSize(new Dimension(285,50));
|
||||
peoplePanel.setMaximumSize(new Dimension(285,50));
|
||||
add(peoplePanel);
|
||||
{
|
||||
JLabel peopleLabel = new JLabel("0/0 People");
|
||||
peopleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
peoplePanel.add(peopleLabel);
|
||||
|
||||
JButton peopleButton = new JButton("Set People");
|
||||
peopleButton.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
peopleButton.addActionListener(new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
p.addVisitors(300);
|
||||
}
|
||||
});
|
||||
peoplePanel.add(peopleButton);
|
||||
}
|
||||
|
||||
add(Box.createHorizontalGlue());
|
||||
|
||||
JPanel runningPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
runningPanel.setPreferredSize(new Dimension(195,50));
|
||||
runningPanel.setMaximumSize(new Dimension(195,50));
|
||||
add(runningPanel);
|
||||
{
|
||||
JLabel runningLabel = new JLabel("Simulation stopped");
|
||||
runningLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
runningPanel.add(runningLabel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+23
-3
@@ -19,10 +19,10 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Timer;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import Agenda.Agenda;
|
||||
import Listeners.Mouse;
|
||||
@@ -65,6 +65,7 @@ public class Panel extends JPanel implements ActionListener
|
||||
Point lastMousePosition = new Point(0, 0);
|
||||
Point2D selectionPosition = new Point(0, 0);
|
||||
Images images = new Images();
|
||||
javax.swing.Timer t;
|
||||
|
||||
int currentTime = 540;
|
||||
int tick = 0;
|
||||
@@ -124,9 +125,11 @@ public class Panel extends JPanel implements ActionListener
|
||||
addMouseMotionListener(new MouseMotion(this));
|
||||
|
||||
addMouseWheelListener(new MouseWheel(this));
|
||||
new javax.swing.Timer(1000/20, this).start();;
|
||||
t = new Timer(1000/100, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getPanelInfoLength()
|
||||
{
|
||||
int panelInfoLength = 0;
|
||||
@@ -142,7 +145,6 @@ public class Panel extends JPanel implements ActionListener
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
|
||||
case 0:
|
||||
return new Stage(null);
|
||||
case 1:
|
||||
@@ -169,6 +171,14 @@ public class Panel extends JPanel implements ActionListener
|
||||
{
|
||||
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects));
|
||||
}
|
||||
|
||||
public void addVisitors(int count)
|
||||
{
|
||||
for(int i = 0 ; i < count ; i++)
|
||||
{
|
||||
visitors.add(new Visitor("visitor", new Point(100, 300), agenda, objects));
|
||||
}
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g)
|
||||
{
|
||||
@@ -528,4 +538,14 @@ public class Panel extends JPanel implements ActionListener
|
||||
repaint();
|
||||
|
||||
}
|
||||
|
||||
public javax.swing.Timer getT()
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
public void setT(javax.swing.Timer t)
|
||||
{
|
||||
this.t = t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,12 @@ public class PropertiesPanel extends JPanel
|
||||
|
||||
Panel p = null;
|
||||
|
||||
Dimension spacerDimension = new Dimension(200, 30);
|
||||
Dimension spacerDimension = new Dimension(200, 10);
|
||||
|
||||
|
||||
JLabel nameLabel;
|
||||
JPanel areaPanel;
|
||||
Component rigidArea;
|
||||
|
||||
JTextField locationXField;
|
||||
JTextField locationYField;
|
||||
@@ -91,6 +92,8 @@ public class PropertiesPanel extends JPanel
|
||||
//AREA PANEL: AVAILABLE FOR ACTIONLISTENER
|
||||
areaPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
areaPanel.setVisible(false);
|
||||
rigidArea = Box.createRigidArea(spacerDimension);
|
||||
rigidArea.setVisible(false);
|
||||
|
||||
// BUTTONS ROW 1
|
||||
JPanel row1ButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
@@ -114,6 +117,7 @@ public class PropertiesPanel extends JPanel
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
areaPanel.setVisible(!areaPanel.isVisible());
|
||||
rigidArea.setVisible(!rigidArea.isVisible());
|
||||
}
|
||||
});
|
||||
row1ButtonPanel.setPreferredSize(new Dimension(200, 50));
|
||||
@@ -122,23 +126,24 @@ public class PropertiesPanel extends JPanel
|
||||
row1ButtonPanel.add(areaButton);
|
||||
add(row1ButtonPanel);
|
||||
|
||||
add(rigidArea);
|
||||
|
||||
//AREA PANEL
|
||||
JLabel areaLabel = new JLabel("Area size");
|
||||
areaLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
||||
areaPanel.setPreferredSize(new Dimension(200, 150));
|
||||
areaPanel.setMaximumSize(new Dimension(200, 250));
|
||||
areaPanel.setPreferredSize(new Dimension(200, 180));
|
||||
areaPanel.setMaximumSize(new Dimension(200, 180));
|
||||
areaPanel.add(areaLabel);
|
||||
add(areaPanel);
|
||||
{
|
||||
JPanel areaTopPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
areaTopPanel.setPreferredSize(new Dimension(200, 50));
|
||||
areaTopPanel.setPreferredSize(new Dimension(200, 30));
|
||||
areaPanel.add(areaTopPanel);
|
||||
|
||||
JLabel areaTopLabel = new JLabel("Top");
|
||||
JLabel areaTopLabel = new JLabel("Top ");
|
||||
areaTopPanel.add(areaTopLabel);
|
||||
areaTopField = new JTextField();
|
||||
areaTopField.setPreferredSize(new Dimension(140, 25));
|
||||
areaTopField.setPreferredSize(new Dimension(120, 25));
|
||||
{
|
||||
areaTopField.addKeyListener(new KeyListener()
|
||||
{
|
||||
@@ -166,7 +171,7 @@ public class PropertiesPanel extends JPanel
|
||||
}
|
||||
{
|
||||
JPanel areaBottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
areaBottomPanel.setPreferredSize(new Dimension(200, 50));
|
||||
areaBottomPanel.setPreferredSize(new Dimension(200, 30));
|
||||
areaPanel.add(areaBottomPanel);
|
||||
|
||||
JLabel areaBottomLabel = new JLabel("Bottom");
|
||||
@@ -200,13 +205,13 @@ public class PropertiesPanel extends JPanel
|
||||
}
|
||||
{
|
||||
JPanel areaLeftPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
areaLeftPanel.setPreferredSize(new Dimension(200, 50));
|
||||
areaLeftPanel.setPreferredSize(new Dimension(200, 30));
|
||||
areaPanel.add(areaLeftPanel);
|
||||
|
||||
JLabel areaLeftLabel = new JLabel("Left");
|
||||
JLabel areaLeftLabel = new JLabel("Left ");
|
||||
areaLeftPanel.add(areaLeftLabel);
|
||||
areaLeftField = new JTextField();
|
||||
areaLeftField.setPreferredSize(new Dimension(138, 25));
|
||||
areaLeftField.setPreferredSize(new Dimension(120, 25));
|
||||
{
|
||||
areaLeftField.addKeyListener(new KeyListener()
|
||||
{
|
||||
@@ -234,13 +239,13 @@ public class PropertiesPanel extends JPanel
|
||||
}
|
||||
{
|
||||
JPanel areaRightPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
areaRightPanel.setPreferredSize(new Dimension(200, 50));
|
||||
areaRightPanel.setPreferredSize(new Dimension(200, 30));
|
||||
areaPanel.add(areaRightPanel);
|
||||
|
||||
JLabel areaRightLabel = new JLabel("Right");
|
||||
JLabel areaRightLabel = new JLabel("Right ");
|
||||
areaRightPanel.add(areaRightLabel);
|
||||
areaRightField = new JTextField();
|
||||
areaRightField.setPreferredSize(new Dimension(130, 25));
|
||||
areaRightField.setPreferredSize(new Dimension(120, 25));
|
||||
{
|
||||
areaRightField.addKeyListener(new KeyListener()
|
||||
{
|
||||
@@ -274,13 +279,13 @@ public class PropertiesPanel extends JPanel
|
||||
JPanel locationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
JLabel locationLabel = new JLabel("Location");
|
||||
locationLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
||||
locationPanel.setPreferredSize(new Dimension(200, 150));
|
||||
locationPanel.setMaximumSize(new Dimension(200, 150));
|
||||
locationPanel.setPreferredSize(new Dimension(200, 110));
|
||||
locationPanel.setMaximumSize(new Dimension(200, 110));
|
||||
locationPanel.add(locationLabel);
|
||||
add(locationPanel);
|
||||
{
|
||||
JPanel locationXPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
locationXPanel.setPreferredSize(new Dimension(200, 50));
|
||||
locationXPanel.setPreferredSize(new Dimension(200, 30));
|
||||
locationPanel.add(locationXPanel);
|
||||
|
||||
JLabel locationXLabel = new JLabel("X");
|
||||
@@ -318,7 +323,7 @@ public class PropertiesPanel extends JPanel
|
||||
}
|
||||
{
|
||||
JPanel locationYPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
locationYPanel.setPreferredSize(new Dimension(200, 50));
|
||||
locationYPanel.setPreferredSize(new Dimension(200, 30));
|
||||
locationPanel.add(locationYPanel);
|
||||
|
||||
JLabel locationYLabel = new JLabel("Y");
|
||||
@@ -362,13 +367,13 @@ public class PropertiesPanel extends JPanel
|
||||
JPanel scalePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
JLabel scaleLabel = new JLabel("Scale");
|
||||
scaleLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
||||
scalePanel.setPreferredSize(new Dimension(200, 100));
|
||||
scalePanel.setMaximumSize(new Dimension(200, 100));
|
||||
scalePanel.setPreferredSize(new Dimension(200, 70));
|
||||
scalePanel.setMaximumSize(new Dimension(200, 70));
|
||||
scalePanel.add(scaleLabel);
|
||||
add(scalePanel);
|
||||
{
|
||||
JPanel scalePanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
scalePanel2.setPreferredSize(new Dimension(200, 50));
|
||||
scalePanel2.setPreferredSize(new Dimension(200, 30));
|
||||
scalePanel.add(scalePanel2);
|
||||
|
||||
JLabel scale2Label = new JLabel(" ");
|
||||
@@ -409,13 +414,13 @@ public class PropertiesPanel extends JPanel
|
||||
JPanel rotationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
JLabel rotationLabel = new JLabel("Rotation");
|
||||
rotationLabel.setFont(new Font("Segoe UI", Font.ITALIC, 20));
|
||||
rotationPanel.setPreferredSize(new Dimension(200, 100));
|
||||
rotationPanel.setMaximumSize(new Dimension(200, 100));
|
||||
rotationPanel.setPreferredSize(new Dimension(200, 80));
|
||||
rotationPanel.setMaximumSize(new Dimension(200, 80));
|
||||
rotationPanel.add(rotationLabel);
|
||||
add(rotationPanel);
|
||||
{
|
||||
JPanel rotationPanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
rotationPanel2.setPreferredSize(new Dimension(200, 50));
|
||||
rotationPanel2.setPreferredSize(new Dimension(200, 30));
|
||||
rotationPanel.add(rotationPanel2);
|
||||
|
||||
JLabel rotation2Label = new JLabel(" ");
|
||||
@@ -522,6 +527,7 @@ public class PropertiesPanel extends JPanel
|
||||
|
||||
nameLabel.setText("No Selection");
|
||||
areaPanel.setVisible(false);
|
||||
rigidArea.setVisible(false);
|
||||
}
|
||||
|
||||
private void fillFields()
|
||||
|
||||
+11
-11
@@ -105,13 +105,13 @@ public class Visitor
|
||||
possible = false;
|
||||
}
|
||||
}
|
||||
for (Visitor object : visitors)
|
||||
{
|
||||
if (hitTestVisitor(object) && object != this)
|
||||
{
|
||||
possible = false;
|
||||
}
|
||||
}
|
||||
// for (Visitor object : visitors)
|
||||
// {
|
||||
// if (hitTestVisitor(object) && object != this)
|
||||
// {
|
||||
// possible = false;
|
||||
// }
|
||||
// }
|
||||
if (possible == false)
|
||||
{
|
||||
position = oldPosition;
|
||||
@@ -216,8 +216,8 @@ public class Visitor
|
||||
|
||||
}
|
||||
|
||||
public boolean hitTestVisitor(Visitor v)
|
||||
{
|
||||
return (getEndX() >= v.position.getX() && getEndY() >= v.position.getY() && v.getEndX() >= position.getX() && v.getEndY() >= position.getY());
|
||||
}
|
||||
// public boolean hitTestVisitor(Visitor v)
|
||||
// {
|
||||
// return (getEndX() >= v.position.getX() && getEndY() >= v.position.getY() && v.getEndX() >= position.getX() && v.getEndY() >= position.getY());
|
||||
// }
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package Applicatie;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
@@ -16,7 +17,8 @@ public class Window extends JFrame
|
||||
Window() {
|
||||
super("Festival Plannner");
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setSize(500, 600);
|
||||
//setSize(500, 600);
|
||||
setMinimumSize(new Dimension(1160, 680));
|
||||
setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
|
||||
|
||||
// CONTENT PANELS
|
||||
@@ -24,7 +26,11 @@ public class Window extends JFrame
|
||||
PropertiesPanel pp = new PropertiesPanel();
|
||||
fp = new Panel(pp);
|
||||
contentPanel.add(fp, BorderLayout.CENTER);
|
||||
ControlPanel cp = new ControlPanel(fp);
|
||||
contentPanel.add(cp, BorderLayout.SOUTH);
|
||||
contentPanel.add(pp, BorderLayout.EAST);
|
||||
contentPanel.add(fp, BorderLayout.CENTER);
|
||||
|
||||
|
||||
addKeyListener(new Keyboard(fp));
|
||||
setContentPane(contentPanel);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package Listeners;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import Applicatie.Panel;
|
||||
import Objects.DrawObject;
|
||||
|
||||
public class MouseWheel implements MouseWheelListener
|
||||
{
|
||||
@@ -46,7 +46,13 @@ public class MouseWheel implements MouseWheelListener
|
||||
if (cameraScale >= 0.1 && cameraScale < 4)
|
||||
{
|
||||
panel.setCameraScale((float) cameraScale);
|
||||
}
|
||||
//panel.setCameraPoint(new Point2D.Double(e.getX()-(panel.getWidth()/2)-panel.getCameraPoint().getX(), e.getY()-(panel.getHeight()/2) - panel.getCameraPoint().getY()));
|
||||
//panel.setCameraPoint( new Point2D.Double(
|
||||
// -panel.getClickPoint(new Point(e.getX(), e.getY())).getX(),
|
||||
// -panel.getClickPoint(new Point(e.getX(), e.getY())).getY()
|
||||
// ));
|
||||
//TODO FIX
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user