Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70b1dba047 | ||
|
|
80a934ebb3 | ||
|
|
b94c913472 | ||
|
|
e985dbe537 | ||
|
|
0a2c7ed67c | ||
|
|
5aaf23e346 | ||
|
|
558cf0ea5c |
@@ -0,0 +1,113 @@
|
|||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
|
||||||
|
public class AddArtistPanel extends JFrame{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
public AddArtistPanel(Agenda agenda)
|
||||||
|
{
|
||||||
|
super("Artist addscreen!");
|
||||||
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
|
JPanel content = new JPanel(new BorderLayout());
|
||||||
|
JPanel south = new JPanel(new FlowLayout());
|
||||||
|
JPanel center = new JPanel(new GridLayout(4,2));
|
||||||
|
content.add(south, BorderLayout.SOUTH);
|
||||||
|
content.add(center, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
JPanel panel1 = new JPanel();
|
||||||
|
JLabel name = new JLabel("Artist name: ");
|
||||||
|
panel1.add(name);
|
||||||
|
center.add(panel1);
|
||||||
|
|
||||||
|
JPanel panel2 = new JPanel();
|
||||||
|
JTextField nameTF = new JTextField("",15);
|
||||||
|
panel2.add(nameTF);
|
||||||
|
center.add(panel2);
|
||||||
|
|
||||||
|
JLabel genre = new JLabel("Genre: ");
|
||||||
|
JPanel panel3 = new JPanel();
|
||||||
|
panel3.add(genre);
|
||||||
|
center.add(panel3);
|
||||||
|
|
||||||
|
JTextField genreTF = new JTextField("",15);
|
||||||
|
JPanel panel4 = new JPanel();
|
||||||
|
panel4.add(genreTF);
|
||||||
|
center.add(panel4);
|
||||||
|
|
||||||
|
JPanel panel5 = new JPanel();
|
||||||
|
JLabel image = new JLabel("Image: ");
|
||||||
|
panel5.add(image);
|
||||||
|
center.add(panel5);
|
||||||
|
|
||||||
|
JPanel panel6 = new JPanel();
|
||||||
|
JTextField imageTF = new JTextField("", 15);
|
||||||
|
panel6.add(imageTF);
|
||||||
|
center.add(panel6);
|
||||||
|
|
||||||
|
JPanel panel7 = new JPanel();
|
||||||
|
JLabel description = new JLabel("Description: ");
|
||||||
|
panel7.add(description);
|
||||||
|
center.add(panel7);
|
||||||
|
|
||||||
|
JPanel panel8 = new JPanel();
|
||||||
|
JTextField descriptionTF = new JTextField("", 15);
|
||||||
|
panel8.add(descriptionTF);
|
||||||
|
center.add(panel8);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JButton add = new JButton("Add artist!");
|
||||||
|
south.add(add);
|
||||||
|
|
||||||
|
add.addActionListener(new ActionListener()
|
||||||
|
{
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
String name = nameTF.getText();
|
||||||
|
String genre = genreTF.getText();
|
||||||
|
String image = imageTF.getText();
|
||||||
|
String description = descriptionTF.getText();
|
||||||
|
|
||||||
|
boolean alreadyExists = false;
|
||||||
|
for (Artist artist : agenda.artists)
|
||||||
|
{
|
||||||
|
if (artist.getName().equals(name))
|
||||||
|
{
|
||||||
|
alreadyExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.isEmpty() == true){
|
||||||
|
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||||
|
}
|
||||||
|
else if (alreadyExists == false)
|
||||||
|
{
|
||||||
|
Artist a = new Artist(name,genre,image,description);
|
||||||
|
agenda.addArtist(a);
|
||||||
|
JOptionPane.showMessageDialog(null, "Artist added!");
|
||||||
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Choose a different artist name!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
setContentPane(content);
|
||||||
|
setVisible(true);
|
||||||
|
setSize(500,320);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
|
||||||
|
public class AddEventPanel extends JFrame{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
public AddEventPanel(Agenda agenda)
|
||||||
|
{
|
||||||
|
super("Event addscreen!");
|
||||||
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
|
JPanel content = new JPanel(new BorderLayout());
|
||||||
|
JPanel south = new JPanel(new FlowLayout());
|
||||||
|
JPanel center = new JPanel(new GridLayout(7,2));
|
||||||
|
content.add(south, BorderLayout.SOUTH);
|
||||||
|
content.add(center, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
JPanel panel1 = new JPanel();
|
||||||
|
JLabel name = new JLabel("Event name: ");
|
||||||
|
panel1.add(name);
|
||||||
|
center.add(panel1);
|
||||||
|
|
||||||
|
JPanel panel2 = new JPanel();
|
||||||
|
JTextField nameTF = new JTextField("",15);
|
||||||
|
panel2.add(nameTF);
|
||||||
|
center.add(panel2);
|
||||||
|
|
||||||
|
JLabel starttime = new JLabel("Starttime: ");
|
||||||
|
JPanel panel3 = new JPanel();
|
||||||
|
panel3.add(starttime);
|
||||||
|
center.add(panel3);
|
||||||
|
|
||||||
|
Integer[] hours = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 };
|
||||||
|
JComboBox<Integer> hour = new JComboBox<Integer>(hours);
|
||||||
|
JPanel panel4 = new JPanel();
|
||||||
|
panel4.add(hour);
|
||||||
|
center.add(panel4);
|
||||||
|
|
||||||
|
Integer[] minutes = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59};
|
||||||
|
JComboBox<Integer> minute = new JComboBox<Integer>(minutes);
|
||||||
|
panel4.add(minute);
|
||||||
|
|
||||||
|
|
||||||
|
Integer[] days = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
|
||||||
|
JComboBox<Integer> day = new JComboBox<Integer>(days);
|
||||||
|
panel4.add(day);
|
||||||
|
|
||||||
|
String[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
|
||||||
|
JComboBox<String> month = new JComboBox<String>(months);
|
||||||
|
panel4.add(month);
|
||||||
|
|
||||||
|
|
||||||
|
Integer[] years = { 2015,2016,2017};
|
||||||
|
JComboBox<Integer> year = new JComboBox<Integer>(years);
|
||||||
|
panel4.add(year);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JPanel panel5 = new JPanel();
|
||||||
|
JLabel endtime = new JLabel("Endtime: ");
|
||||||
|
panel5.add(endtime);
|
||||||
|
center.add(panel5);
|
||||||
|
|
||||||
|
JComboBox<Integer> hourE = new JComboBox<Integer>(hours);
|
||||||
|
JPanel panel6 = new JPanel();
|
||||||
|
panel6.add(hourE);
|
||||||
|
center.add(panel6);
|
||||||
|
|
||||||
|
JComboBox<Integer> minuteE = new JComboBox<Integer>(minutes);
|
||||||
|
panel6.add(minuteE);
|
||||||
|
|
||||||
|
|
||||||
|
JComboBox<Integer> dayE = new JComboBox<Integer>(days);
|
||||||
|
panel6.add(dayE);
|
||||||
|
|
||||||
|
JComboBox<String> monthE = new JComboBox<String>(months);
|
||||||
|
panel6.add(monthE);
|
||||||
|
|
||||||
|
|
||||||
|
JComboBox<Integer> yearE = new JComboBox<Integer>(years);
|
||||||
|
panel6.add(yearE);
|
||||||
|
|
||||||
|
|
||||||
|
JPanel panel7 = new JPanel();
|
||||||
|
JLabel artist2 = new JLabel("Artist: ");
|
||||||
|
panel7.add(artist2);
|
||||||
|
center.add(panel7);
|
||||||
|
|
||||||
|
JPanel panel8 = new JPanel();
|
||||||
|
String[] artists = new String[agenda.artists.size()];
|
||||||
|
|
||||||
|
for ( int idx = 0; idx < agenda.artists.size(); idx ++)
|
||||||
|
{
|
||||||
|
artists[idx] = agenda.artists.get(idx).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
JComboBox<String> artist = new JComboBox<String>(artists);
|
||||||
|
panel8.add(artist);
|
||||||
|
center.add(panel8);
|
||||||
|
|
||||||
|
JPanel panel9 = new JPanel();
|
||||||
|
JLabel stage = new JLabel("Stage: ");
|
||||||
|
panel9.add(stage);
|
||||||
|
center.add(panel9);
|
||||||
|
|
||||||
|
JPanel panel10 = new JPanel();
|
||||||
|
String[] stages = new String[agenda.stages.size()];
|
||||||
|
|
||||||
|
for ( int idx = 0; idx < agenda.stages.size(); idx ++)
|
||||||
|
{
|
||||||
|
artists[idx] = agenda.stages.get(idx).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
JComboBox<String> stage2 = new JComboBox<String>(stages);
|
||||||
|
panel10.add(stage2);
|
||||||
|
center.add(panel10);
|
||||||
|
|
||||||
|
JPanel panel11 = new JPanel();
|
||||||
|
JLabel description = new JLabel("Description: ");
|
||||||
|
panel11.add(description);
|
||||||
|
center.add(panel11);
|
||||||
|
|
||||||
|
JPanel panel12 = new JPanel();
|
||||||
|
JTextField descriptionTF = new JTextField("",15);
|
||||||
|
panel12.add(descriptionTF);
|
||||||
|
center.add(panel12);
|
||||||
|
|
||||||
|
JPanel panel13 = new JPanel();
|
||||||
|
JLabel expectedPopularity = new JLabel("Expected Popularity: ");
|
||||||
|
panel13.add(expectedPopularity);
|
||||||
|
center.add(panel13);
|
||||||
|
|
||||||
|
JPanel panel14 = new JPanel();
|
||||||
|
Integer[] eps= { 1,2,3,4,5,6,7,8,9,10};
|
||||||
|
JComboBox<Integer> ep = new JComboBox<Integer>(eps);
|
||||||
|
panel14.add(ep);
|
||||||
|
center.add(panel14);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JButton add = new JButton("Add event!");
|
||||||
|
south.add(add);
|
||||||
|
|
||||||
|
add.addActionListener(new ActionListener()
|
||||||
|
{
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
boolean everythingCorrect = true;
|
||||||
|
String name = nameTF.getText();
|
||||||
|
|
||||||
|
int hourS = hour.getSelectedIndex();
|
||||||
|
int minuteS = minute.getSelectedIndex();
|
||||||
|
int dayS = day.getSelectedIndex();
|
||||||
|
String monthS = (String) month.getSelectedItem();
|
||||||
|
int yearS = year.getSelectedIndex();
|
||||||
|
|
||||||
|
int hourEnd = hourE.getSelectedIndex();
|
||||||
|
int minuteEnd = minuteE.getSelectedIndex();
|
||||||
|
int dayEnd = dayE.getSelectedIndex();
|
||||||
|
String monthEnd = (String) monthE.getSelectedItem();
|
||||||
|
int yearEnd = yearE.getSelectedIndex();
|
||||||
|
|
||||||
|
String artistName = (String)artist.getSelectedItem();
|
||||||
|
|
||||||
|
Artist artist = null;
|
||||||
|
|
||||||
|
for(Artist a : agenda.artists)
|
||||||
|
{
|
||||||
|
if (a.getName().equals(artistName))
|
||||||
|
{
|
||||||
|
artist = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String stageName = (String)stage2.getSelectedItem();
|
||||||
|
|
||||||
|
Stage stage = null;
|
||||||
|
|
||||||
|
for(Stage s : agenda.stages)
|
||||||
|
{
|
||||||
|
if (s.getName().equals(stageName))
|
||||||
|
{
|
||||||
|
stage = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String description = descriptionTF.getText();
|
||||||
|
|
||||||
|
int popularity = ep.getSelectedIndex();
|
||||||
|
|
||||||
|
if (dayS > monthDays(monthS)){
|
||||||
|
everythingCorrect = false;
|
||||||
|
JOptionPane.showMessageDialog(null, "Invalid Date!");
|
||||||
|
}
|
||||||
|
else if (yearS > yearEnd || monthToInt(monthS) > monthToInt(monthEnd) || dayS > dayEnd || hourS > hourEnd || minuteS > minuteEnd){
|
||||||
|
everythingCorrect = false;
|
||||||
|
JOptionPane.showMessageDialog(null, "End time is earlier then start time!");
|
||||||
|
}
|
||||||
|
else if (dayS != dayEnd || monthS.equals(monthEnd) == false || yearS != yearEnd){
|
||||||
|
everythingCorrect = false;
|
||||||
|
JOptionPane.showMessageDialog(null, "Event is too long!");
|
||||||
|
} else if (name.isEmpty()){
|
||||||
|
everythingCorrect = false;
|
||||||
|
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||||
|
} else if (stage == null){
|
||||||
|
everythingCorrect = false;
|
||||||
|
JOptionPane.showMessageDialog(null, "Missing a stage!");
|
||||||
|
} else if (artist == null){
|
||||||
|
JOptionPane.showMessageDialog(null, "Missing a artist!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (everythingCorrect == true)
|
||||||
|
{
|
||||||
|
Event event = new Event(name,yearS,monthToInt(monthS),dayS,hourS,minuteS,yearEnd,monthToInt(monthEnd),dayEnd,hourEnd, minuteEnd, artist, stage,description, popularity);
|
||||||
|
agenda.addEvent(event);
|
||||||
|
everythingCorrect = false;
|
||||||
|
JOptionPane.showMessageDialog(null, "Event added!");
|
||||||
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
setContentPane(content);
|
||||||
|
setVisible(true);
|
||||||
|
setSize(640,320);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int monthToInt(String month)
|
||||||
|
{
|
||||||
|
int number = 0;
|
||||||
|
switch (month)
|
||||||
|
{
|
||||||
|
case "January": number = 0; break;
|
||||||
|
case "February": number = 1; break;
|
||||||
|
case "March": number = 2; break;
|
||||||
|
case "April": number = 3; break;
|
||||||
|
case "May": number = 4; break;
|
||||||
|
case "June":number = 5; break;
|
||||||
|
case "July": number = 6; break;
|
||||||
|
case "August": number = 7; break;
|
||||||
|
case "September":number = 8; break;
|
||||||
|
case "October": number = 9; break;
|
||||||
|
case "November": number = 10; break;
|
||||||
|
case "December": number = 11; break;
|
||||||
|
}
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int monthDays(String month)
|
||||||
|
{
|
||||||
|
int number = 0;
|
||||||
|
switch (month)
|
||||||
|
{
|
||||||
|
case "January": number = 31; break;
|
||||||
|
case "February": number = 28; break;
|
||||||
|
case "March": number = 31; break;
|
||||||
|
case "April": number = 30; break;
|
||||||
|
case "May": number = 31; break;
|
||||||
|
case "June":number = 30; break;
|
||||||
|
case "July": number = 31; break;
|
||||||
|
case "August": number = 31; break;
|
||||||
|
case "September":number = 30; break;
|
||||||
|
case "October": number = 31; break;
|
||||||
|
case "November": number = 30; break;
|
||||||
|
case "December": number = 31; break;
|
||||||
|
}
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
|
||||||
|
public class AddStagePanel extends JFrame{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
public AddStagePanel(Agenda agenda)
|
||||||
|
{
|
||||||
|
super("Stage addscreen!");
|
||||||
|
agenda.addStage(new Stage("mainstage", "niks"));
|
||||||
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
|
JPanel content = new JPanel(new BorderLayout());
|
||||||
|
JPanel south = new JPanel(new FlowLayout());
|
||||||
|
JPanel center = new JPanel(new GridLayout(2,2));
|
||||||
|
content.add(south, BorderLayout.SOUTH);
|
||||||
|
content.add(center, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
JPanel panel1 = new JPanel();
|
||||||
|
JLabel name = new JLabel("Stage name: ");
|
||||||
|
panel1.add(name);
|
||||||
|
center.add(panel1);
|
||||||
|
|
||||||
|
JPanel panel2 = new JPanel();
|
||||||
|
JTextField nameTF = new JTextField("",15);
|
||||||
|
panel2.add(nameTF);
|
||||||
|
center.add(panel2);
|
||||||
|
|
||||||
|
JLabel description = new JLabel("Stage Description: ");
|
||||||
|
JPanel panel3 = new JPanel();
|
||||||
|
panel3.add(description);
|
||||||
|
center.add(panel3);
|
||||||
|
|
||||||
|
JTextField descriptionTF = new JTextField("",15);
|
||||||
|
JPanel panel4 = new JPanel();
|
||||||
|
panel4.add(descriptionTF);
|
||||||
|
center.add(panel4);
|
||||||
|
|
||||||
|
|
||||||
|
JButton add = new JButton("Add stage!");
|
||||||
|
south.add(add);
|
||||||
|
|
||||||
|
add.addActionListener(new ActionListener()
|
||||||
|
{
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
String name = nameTF.getText();
|
||||||
|
String description = descriptionTF.getText();
|
||||||
|
|
||||||
|
boolean alreadyExists = false;
|
||||||
|
for (Stage stage : agenda.stages)
|
||||||
|
{
|
||||||
|
if (stage.getName().equals(name))
|
||||||
|
{
|
||||||
|
alreadyExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.isEmpty()){
|
||||||
|
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||||
|
}
|
||||||
|
else if ( alreadyExists == false )
|
||||||
|
{
|
||||||
|
Stage s = new Stage(name,description);
|
||||||
|
agenda.addStage(s);
|
||||||
|
JOptionPane.showMessageDialog(null, "Stage added!");
|
||||||
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Choose a different stage name!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
setContentPane(content);
|
||||||
|
setVisible(true);
|
||||||
|
setSize(400,180);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
|
public class Agenda implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
private ArrayList<Stage> stages;
|
||||||
|
private ArrayList<Event> events;
|
||||||
|
private ArrayList<Artist> artists;
|
||||||
|
|
||||||
|
public Agenda() {
|
||||||
|
stages = new ArrayList<Stage>();
|
||||||
|
events = new ArrayList<Event>();
|
||||||
|
artists = new ArrayList<Artist>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addStage(Stage stage){
|
||||||
|
stages.add(stage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEvent(Event event) {
|
||||||
|
events.add(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addArtist(Artist artist) {
|
||||||
|
artists.add(artist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAgenda()
|
||||||
|
{
|
||||||
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
|
|
||||||
|
fileChooser.setFileFilter(new FileFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File pathname) {
|
||||||
|
if(pathname.isFile() && pathname.getName().endsWith(".dat"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}else if(pathname.isDirectory()){return true;}else{return false;}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return ".dat";
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
fileChooser.setDialogTitle("Choose save location");
|
||||||
|
int userSelection = fileChooser.showSaveDialog(null);
|
||||||
|
|
||||||
|
if(userSelection == JFileChooser.APPROVE_OPTION)
|
||||||
|
{
|
||||||
|
File file = fileChooser.getSelectedFile();
|
||||||
|
if(!file.getName().endsWith(".dat"))
|
||||||
|
{
|
||||||
|
file = new File(file.getAbsolutePath() + ".dat");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to overwrite: " + file.getName(), "Overwrite", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||||
|
{
|
||||||
|
saveAgenda(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
saveAgenda(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadAgenda()
|
||||||
|
{
|
||||||
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
|
fileChooser.setFileFilter(new FileFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File pathname) {
|
||||||
|
if(pathname.isFile() && pathname.getName().endsWith(".dat"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}else if(pathname.isDirectory()){return true;}else{return false;}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return ".dat";
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
fileChooser.setDialogTitle("Choose file");
|
||||||
|
int userSelection = fileChooser.showOpenDialog(null);
|
||||||
|
|
||||||
|
if(userSelection == JFileChooser.APPROVE_OPTION)
|
||||||
|
{
|
||||||
|
File file = fileChooser.getSelectedFile();
|
||||||
|
if(!file.exists())
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog(null, "This file does not exist: " + file.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fillAgenda(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillAgenda(File file) {
|
||||||
|
FileInputStream fis = null;
|
||||||
|
ObjectInputStream ois = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
ois = new ObjectInputStream(fis);
|
||||||
|
|
||||||
|
Object object;
|
||||||
|
object = ois.readObject();
|
||||||
|
try {
|
||||||
|
while (object != null) {
|
||||||
|
events.add((Event) object);
|
||||||
|
object = ois.readObject();
|
||||||
|
}
|
||||||
|
} catch (EOFException e) {
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillArtists()
|
||||||
|
{
|
||||||
|
for (Event e : events)
|
||||||
|
{
|
||||||
|
boolean exists = false;
|
||||||
|
String name = e.getArtist().getName();
|
||||||
|
for (Artist a : artists)
|
||||||
|
{
|
||||||
|
if ( a.getName().equals(name) ) {
|
||||||
|
exists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( exists == false) {
|
||||||
|
addArtist(e.getArtist());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillStages()
|
||||||
|
{
|
||||||
|
for (Event e : events)
|
||||||
|
{
|
||||||
|
boolean exists = false;
|
||||||
|
String name = e.getStage().getName();
|
||||||
|
for (Stage s : stages)
|
||||||
|
{
|
||||||
|
if ( s.getName().equals(name) ) {
|
||||||
|
exists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( exists == false) {
|
||||||
|
addStage(e.getStage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAgenda(File file) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
|
for (Event event : events) {
|
||||||
|
oos.writeObject(event);
|
||||||
|
}
|
||||||
|
oos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearAgenda()
|
||||||
|
{
|
||||||
|
events.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillAllLists()
|
||||||
|
{
|
||||||
|
loadAgenda();
|
||||||
|
fillStages();
|
||||||
|
fillArtists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
Agenda a = new Agenda();
|
||||||
|
a.fillAllLists();
|
||||||
|
|
||||||
|
System.out.println(a.events.get(0).getEventName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
|
||||||
|
public class Artist implements Serializable{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String genre;
|
||||||
|
private ImageIcon image;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public Artist(String name, String genre, String image, String description)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.genre = genre;
|
||||||
|
this.description = description;
|
||||||
|
|
||||||
|
if ( !image.equals("null")) {
|
||||||
|
this.image = new ImageIcon(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGenre()
|
||||||
|
{
|
||||||
|
return this.genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageIcon getImage()
|
||||||
|
{
|
||||||
|
return this.image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription()
|
||||||
|
{
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGenre(String genre)
|
||||||
|
{
|
||||||
|
this.genre = genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageIconString(String image)
|
||||||
|
{
|
||||||
|
this.image = new ImageIcon(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageIcon(ImageIcon image)
|
||||||
|
{
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description)
|
||||||
|
{
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
}
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
|
|
||||||
public class Artist
|
|
||||||
{
|
|
||||||
private String genre;
|
|
||||||
private String name;
|
|
||||||
private String description;
|
|
||||||
private ImageIcon image;
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
public Artist(String genre, String name, String description, ImageIcon image, int id)
|
|
||||||
{
|
|
||||||
this.genre = genre;
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
this.image = image;
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getID()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
import java.io.Serializable;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
public class Event implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
private String eventName;
|
||||||
|
private GregorianCalendar startDate;
|
||||||
|
private GregorianCalendar endDate;
|
||||||
|
private Artist artist;
|
||||||
|
private Stage stage;
|
||||||
|
private String description;
|
||||||
|
private int expectedPopularity;
|
||||||
|
|
||||||
|
public Event(String eventName, int startYear, int startMonth, int startDay,
|
||||||
|
int startHour, int startMinute, int endYear, int endMonth,
|
||||||
|
int endDay, int endHour, int endMinute, Artist artist, Stage stage,
|
||||||
|
String description, int expectedPopularity) {
|
||||||
|
this.eventName = eventName;
|
||||||
|
this.startDate = new GregorianCalendar(startYear, startMonth - 1,
|
||||||
|
startDay, startHour, startMinute);
|
||||||
|
this.endDate = new GregorianCalendar(endYear, endMonth - 1, endDay,
|
||||||
|
endHour, endMinute);
|
||||||
|
this.stage = stage;
|
||||||
|
this.artist = artist;
|
||||||
|
this.description = description;
|
||||||
|
this.expectedPopularity = expectedPopularity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Event(String eventName, GregorianCalendar startDate,
|
||||||
|
GregorianCalendar endDate, Artist artist, Stage stage,
|
||||||
|
String description, int expectedPopularity) {
|
||||||
|
this.eventName = eventName;
|
||||||
|
this.startDate = startDate;
|
||||||
|
this.endDate = endDate;
|
||||||
|
this.artist = artist;
|
||||||
|
this.stage = stage;
|
||||||
|
this.description = description;
|
||||||
|
this.expectedPopularity = expectedPopularity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventName() {
|
||||||
|
return this.eventName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GregorianCalendar getStartDate() {
|
||||||
|
return this.startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GregorianCalendar getEndDate() {
|
||||||
|
return this.endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artist getArtist() {
|
||||||
|
return this.artist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stage getStage() {
|
||||||
|
return this.stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExpectedPopularity() {
|
||||||
|
return this.expectedPopularity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventName(String name) {
|
||||||
|
this.eventName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(int startYear, int startMonth, int startDay,
|
||||||
|
int startHour, int startMinute) {
|
||||||
|
startDate.set(startYear, startMonth - 1, startDay, startHour,
|
||||||
|
startMinute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(GregorianCalendar startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(int endYear, int endMonth, int endDay, int endHour,
|
||||||
|
int endMinute) {
|
||||||
|
endDate.set(endYear, endMonth - 1, endDay, endHour, endMinute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(GregorianCalendar endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArtist(Artist artist) {
|
||||||
|
this.artist.setName(artist.getName());
|
||||||
|
this.artist.setGenre(artist.getGenre());
|
||||||
|
this.artist.setImageIcon(artist.getImage());
|
||||||
|
this.artist.setDescription(artist.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpectedPopularity(int popularity) {
|
||||||
|
this.expectedPopularity = popularity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStage(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
DateFormat format = new SimpleDateFormat("dd-MM-yyyy");
|
||||||
|
format.setLenient(false);
|
||||||
|
|
||||||
|
return artist.getName() + " plays from "
|
||||||
|
+ format.format(startDate.getTime()) + " to "
|
||||||
|
+ format.format(endDate.getTime()) + ".";
|
||||||
|
}
|
||||||
|
}
|
||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
|
|
||||||
public class Event
|
|
||||||
{
|
|
||||||
private int startTime;
|
|
||||||
private int endTime;
|
|
||||||
private Artist artist;
|
|
||||||
private String description;
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
public Event(int startTime, int endTime, Artist artist, String description, int id)
|
|
||||||
{
|
|
||||||
this.startTime = startTime;
|
|
||||||
this.endTime = endTime;
|
|
||||||
this.artist = artist;
|
|
||||||
this.description = description;
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Artist getArtist()
|
|
||||||
{
|
|
||||||
return artist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStartTime()
|
|
||||||
{
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getID()
|
|
||||||
{
|
|
||||||
return id + 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
|
|
||||||
public class GUI extends JFrame
|
|
||||||
{
|
|
||||||
private Timeline timeline;
|
|
||||||
|
|
||||||
public GUI()
|
|
||||||
{
|
|
||||||
super("Gui");
|
|
||||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
|
||||||
|
|
||||||
// JPanel contentPane = new JPanel(new BorderLayout());
|
|
||||||
// this.setContentPane(contentPane);
|
|
||||||
// this.setSize(600, 600);
|
|
||||||
// this.setVisible(true);
|
|
||||||
// System.out.println(contentPane.getWidth());
|
|
||||||
// timeline = new Timeline(contentPane);
|
|
||||||
// contentPane.add(timeline,BorderLayout.CENTER);
|
|
||||||
// contentPane.add(timeline.createWestPanel(), BorderLayout.WEST);
|
|
||||||
// timeline.refresh();
|
|
||||||
TimelinePanel panel = new TimelinePanel();
|
|
||||||
this.setContentPane(panel);
|
|
||||||
this.setSize(600, 600);
|
|
||||||
this.setVisible(true);
|
|
||||||
|
|
||||||
this.getRootPane().addComponentListener(new ComponentAdapter()
|
|
||||||
{
|
|
||||||
public void componentResized(ComponentEvent e) {
|
|
||||||
panel.refresh();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
new GUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# BELANGRIJK
|
|
||||||
De .jar file moet als externe Library toegevoegd worden.
|
|
||||||
De sprites folder moet in de root van het project.
|
|
||||||
|
|
||||||
BRANCH VAN YORICK
|
|
||||||
Ja, codemess please.
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Stage implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public Stage(String name, String description)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription()
|
||||||
|
{
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description)
|
||||||
|
{
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
-57
@@ -1,57 +0,0 @@
|
|||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
|
|
||||||
public class Stage
|
|
||||||
{
|
|
||||||
private ArrayList<Event> performances;
|
|
||||||
private int expectedPopularity;
|
|
||||||
private String description;
|
|
||||||
private int length;
|
|
||||||
private int startTime,endTime;
|
|
||||||
|
|
||||||
public Stage(ArrayList<Event> performances, int expectedPopularity, String description, int startTime, int endTime)
|
|
||||||
{
|
|
||||||
this.performances = performances;
|
|
||||||
this.expectedPopularity = expectedPopularity;
|
|
||||||
this.description = description;
|
|
||||||
this.startTime = startTime;
|
|
||||||
this.endTime = endTime;
|
|
||||||
this.length = endTime - startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartTime(int startTime)
|
|
||||||
{
|
|
||||||
this.startTime = startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndTime(int endTime)
|
|
||||||
{
|
|
||||||
this.endTime = endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Event> getPerformances()
|
|
||||||
{
|
|
||||||
return performances;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public int getID()
|
|
||||||
// {
|
|
||||||
// return id + 100;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public int getLength()
|
|
||||||
{
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStartTime()
|
|
||||||
{
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEndTime()
|
|
||||||
{
|
|
||||||
return endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.LayoutManager;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
|
|
||||||
public class StagePanel extends JPanel
|
|
||||||
{
|
|
||||||
private BufferedImage image;
|
|
||||||
private int width, height, posX;
|
|
||||||
private Stage stage;
|
|
||||||
public StagePanel(int width, int height, int posX, Stage stage)
|
|
||||||
{
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
this.posX = posX;
|
|
||||||
this.stage = stage;
|
|
||||||
image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB);
|
|
||||||
Graphics2D g2 = image.createGraphics();
|
|
||||||
g2.setColor(Color.blue);
|
|
||||||
g2.fillRect(0, 0, image.getWidth(), image.getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void paint(Graphics g)
|
|
||||||
{
|
|
||||||
super.paint(g);
|
|
||||||
((Graphics2D)g).drawImage(image, this.posX, 0, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public StagePanel(LayoutManager arg0)
|
|
||||||
{
|
|
||||||
super(arg0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public StagePanel(boolean arg0)
|
|
||||||
{
|
|
||||||
super(arg0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(int posx)
|
|
||||||
{
|
|
||||||
this.posX = posx;
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public StagePanel(LayoutManager arg0, boolean arg1)
|
|
||||||
{
|
|
||||||
super(arg0, arg1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPosX()
|
|
||||||
{
|
|
||||||
return this.posX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLength(int length)
|
|
||||||
{
|
|
||||||
this.width = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStageStartTime(int startTime)
|
|
||||||
{
|
|
||||||
stage.setStartTime(startTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStageEndTime(int endTime)
|
|
||||||
{
|
|
||||||
stage.setEndTime(endTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStageStartTime()
|
|
||||||
{
|
|
||||||
return stage.getStartTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getImageWidth()
|
|
||||||
{
|
|
||||||
return this.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-358
@@ -1,358 +0,0 @@
|
|||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Container;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
import java.awt.event.ComponentListener;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.awt.event.MouseMotionAdapter;
|
|
||||||
import java.awt.event.MouseMotionListener;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.Box;
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({ "serial" })
|
|
||||||
public class Timeline extends JPanel
|
|
||||||
{
|
|
||||||
private ArrayList<Stage> stages = new ArrayList<Stage>();
|
|
||||||
private JPanel frame;
|
|
||||||
|
|
||||||
// Geef dit object je JFrame mee, en zet in je JFrame de volgende code:
|
|
||||||
// this.setContentPane(timeline.getTimeline());
|
|
||||||
// this.getRootPane().addComponentListener(new ComponentAdapter()
|
|
||||||
// {
|
|
||||||
// public void componentResized(ComponentEvent e) {
|
|
||||||
// timeline.refresh();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
public Timeline(JPanel frame)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.frame = frame;
|
|
||||||
|
|
||||||
genStages();
|
|
||||||
this.setSize(frame.getWidth(), frame.getHeight());
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh()
|
|
||||||
{
|
|
||||||
this.removeAll();
|
|
||||||
// createWestPanel();
|
|
||||||
createMainPanel();
|
|
||||||
this.revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createMainPanel()
|
|
||||||
{
|
|
||||||
JPanel mainPanel = new JPanel();
|
|
||||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
|
||||||
Container topContainer = createTopPanel();
|
|
||||||
Dimension dim = new Dimension(this.getWidth(), 60);
|
|
||||||
topContainer.setMaximumSize(dim);
|
|
||||||
mainPanel.add(topContainer);
|
|
||||||
|
|
||||||
Dimension centerDim = new Dimension(this.getWidth(), frame.getHeight());
|
|
||||||
|
|
||||||
// Container centerContainer = createCenterPanel();
|
|
||||||
JPanel centerContainer = createCenterPanel();
|
|
||||||
centerContainer.setPreferredSize(centerDim);
|
|
||||||
|
|
||||||
centerContainer.setMaximumSize(centerDim);
|
|
||||||
System.out.println(centerDim);
|
|
||||||
mainPanel.add(centerContainer);
|
|
||||||
this.add(mainPanel, BorderLayout.CENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel createCenterPanel()
|
|
||||||
{
|
|
||||||
|
|
||||||
JPanel centerPanel = new JPanel();
|
|
||||||
centerPanel.setBackground(Color.lightGray);
|
|
||||||
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
|
|
||||||
centerPanel.add(Box.createRigidArea(new Dimension(0, 30)));
|
|
||||||
|
|
||||||
for(Stage stage : stages)
|
|
||||||
{
|
|
||||||
StagePanel stagepanel = new StagePanel(calcLengthOfStage(stage.getLength()), 30, calcPositionOfStage(stage.getStartTime()), stage);
|
|
||||||
Container content = stagepanel;
|
|
||||||
content.setMaximumSize(new Dimension(this.getWidth(),30));
|
|
||||||
content.addMouseListener(new MouseListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
|
||||||
resizeTimeline(stagepanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
content.addMouseMotionListener(new MouseMotionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDragged(MouseEvent e) {
|
|
||||||
stagepanel.update(e.getX() - stagepanel.getImageWidth() / 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
centerPanel.add(content);
|
|
||||||
centerPanel.add(Box.createRigidArea(new Dimension(0,15)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// this.add(centerPanel, BorderLayout.CENTER);
|
|
||||||
return centerPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resizeTimeline(StagePanel stagepanel)
|
|
||||||
{
|
|
||||||
int min = findMinMax(1);
|
|
||||||
int max = findMinMax(2);
|
|
||||||
// System.out.println(stagepanel.getStageStartTime());
|
|
||||||
// System.out.println(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
|
||||||
stagepanel.setStageStartTime(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
|
||||||
stagepanel.setStageEndTime(calcEndTimeOfStagePanel(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
|
||||||
// stagepanel.setLength(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
|
||||||
// System.out.println(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calcLengthOfStage(int length)
|
|
||||||
{
|
|
||||||
double lengthOfStage = 0;
|
|
||||||
int min = findMinMax(1);
|
|
||||||
int max = findMinMax(2);
|
|
||||||
|
|
||||||
double frameWidth = this.getWidth();
|
|
||||||
double pixelsPerLength = frameWidth / (max - min);
|
|
||||||
lengthOfStage = pixelsPerLength * (double)length;
|
|
||||||
// System.out.println((int)lengthOfStage);
|
|
||||||
return (int)lengthOfStage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calcLengthOfStagePanel(int length)
|
|
||||||
{
|
|
||||||
double lengthOfStagePanel = 0;
|
|
||||||
int min = findMinMax(1);
|
|
||||||
int max = findMinMax(2);
|
|
||||||
// System.out.println(length);
|
|
||||||
double frameWidth = this.getWidth();
|
|
||||||
double pixelsPerLength = frameWidth / (max - min);
|
|
||||||
// System.out.println(pixelsPerLength);
|
|
||||||
lengthOfStagePanel = (double)length / pixelsPerLength;
|
|
||||||
// System.out.println(lengthOfStagePanel);
|
|
||||||
|
|
||||||
return (int)lengthOfStagePanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calcPositionOfStage(int startTime)
|
|
||||||
{
|
|
||||||
int posx = 0;
|
|
||||||
int min = findMinMax(1);
|
|
||||||
int max = findMinMax(2);
|
|
||||||
posx = startTime - min;
|
|
||||||
posx = posx * this.getWidth() / (max-min);
|
|
||||||
// System.out.println("Frame: " + this.getWidth());
|
|
||||||
// System.out.println("startTime: " + startTime);
|
|
||||||
// System.out.println("Max: " + max + " min: " + min);
|
|
||||||
// System.out.println("Posx: " + posx);
|
|
||||||
return posx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calcStartTimeOfStagePanel(int posx)
|
|
||||||
{
|
|
||||||
int min = findMinMax(1);
|
|
||||||
int max = findMinMax(2);
|
|
||||||
// double startTime = (posx / (this.getWidth() / (max - min )) ) + min;
|
|
||||||
//Omdat het anders onnodig afgerond wordt, alles apart in doubles.
|
|
||||||
double minmax = max-min;
|
|
||||||
double bottom = this.getWidth() / minmax;
|
|
||||||
double all = posx / bottom;
|
|
||||||
double startTime = all + min;
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("starttime----------------");
|
|
||||||
// System.out.println("Frame: " + this.getWidth());
|
|
||||||
// System.out.println("startTime: " + startTime);
|
|
||||||
// System.out.println("Max: " + max + " min: " + min);
|
|
||||||
// System.out.println("Posx: " + posx);
|
|
||||||
return (int)startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calcEndTimeOfStagePanel(int posx, int imageWidth)
|
|
||||||
{
|
|
||||||
int min = findMinMax(1);
|
|
||||||
int max = findMinMax(2);
|
|
||||||
//Omdat het anders onnodig afgerond wordt, alles apart in doubles.
|
|
||||||
double minmax = max-min;
|
|
||||||
double bottom = this.getWidth() / minmax;
|
|
||||||
double all = posx / bottom;
|
|
||||||
double endTime = all + min + calcLengthOfStagePanel(imageWidth);
|
|
||||||
// System.out.println(calcLengthOfStagePanel(imageWidth));
|
|
||||||
// System.out.println(endTime);
|
|
||||||
return (int)endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int findMinMax(int i)
|
|
||||||
{
|
|
||||||
// Event oldevent = new Event(0, 0, null, "Base", 0);
|
|
||||||
// ArrayList<Event> oldevents = new ArrayList<Event>();
|
|
||||||
// oldevents.add(oldevent);
|
|
||||||
// Stage oldstage = new Stage(oldevents,0,null, 0, 0);
|
|
||||||
ArrayList<Stage> stagescopy = (ArrayList<Stage>) stages.clone();
|
|
||||||
|
|
||||||
Integer earliestStartTime = null;
|
|
||||||
Integer lastEndTime = null;
|
|
||||||
|
|
||||||
for(Stage stage : stagescopy)
|
|
||||||
{
|
|
||||||
if(i == 1)
|
|
||||||
{
|
|
||||||
if(earliestStartTime == null)
|
|
||||||
{
|
|
||||||
|
|
||||||
earliestStartTime = stage.getStartTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(stage.getStartTime() < earliestStartTime)
|
|
||||||
{
|
|
||||||
earliestStartTime = stage.getStartTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( i == 2)
|
|
||||||
{
|
|
||||||
if(lastEndTime == null)
|
|
||||||
{
|
|
||||||
lastEndTime = stage.getEndTime();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(stage.getEndTime() > lastEndTime)
|
|
||||||
{
|
|
||||||
lastEndTime = stage.getEndTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(i == 1)
|
|
||||||
{
|
|
||||||
return earliestStartTime;
|
|
||||||
}
|
|
||||||
else if(i == 2)
|
|
||||||
{
|
|
||||||
return lastEndTime;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println("Return -1");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel createTopPanel()
|
|
||||||
{
|
|
||||||
JPanel topPane = new JPanel();
|
|
||||||
topPane.setLayout(new BoxLayout(topPane, BoxLayout.Y_AXIS));
|
|
||||||
JPanel topPanel = new JPanel(new FlowLayout());
|
|
||||||
for(int i = 0; i <= this.getWidth() / 10; i++)
|
|
||||||
{
|
|
||||||
ImageIcon topImageIcon = new ImageIcon("src/test2.png");
|
|
||||||
JLabel topImage = new JLabel(topImageIcon);
|
|
||||||
topPanel.add(topImage);
|
|
||||||
}
|
|
||||||
topPane.add(Box.createRigidArea(new Dimension(0,20)));
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
|
||||||
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
|
||||||
panel.add(new JLabel(Integer.toString(findMinMax(1))));
|
|
||||||
panel.add(Box.createHorizontalGlue());
|
|
||||||
panel.add(new JLabel(Integer.toString(findMinMax(2))));
|
|
||||||
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
|
||||||
topPane.add(panel);
|
|
||||||
topPane.add(topPanel);
|
|
||||||
// this.add(topPane, BorderLayout.NORTH);
|
|
||||||
return topPane;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JPanel createWestPanel()
|
|
||||||
{
|
|
||||||
JPanel westPanel = new JPanel();
|
|
||||||
westPanel.setLayout(new BoxLayout(westPanel, BoxLayout.Y_AXIS));
|
|
||||||
westPanel.add(Box.createRigidArea(new Dimension(0, 100)));
|
|
||||||
for(int i = 0; i < stages.size(); i++)
|
|
||||||
{
|
|
||||||
JLabel stageText = new JLabel("Stage: " + (i+1) + " ");
|
|
||||||
westPanel.add(stageText);
|
|
||||||
westPanel.add(Box.createRigidArea(new Dimension(0, 30 )));
|
|
||||||
}
|
|
||||||
// this.add(westPanel, BorderLayout.WEST);
|
|
||||||
return westPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void genStages()
|
|
||||||
{
|
|
||||||
ImageIcon image = new ImageIcon();
|
|
||||||
Artist artist2 = new Artist("Henk", "paul2", "kaas", image, 2);
|
|
||||||
Artist artist1 = new Artist("Kaas", "Paul", "Lala", image, 1);
|
|
||||||
Event event2 = new Event(1900, 2000, artist2, "hi2", 2);
|
|
||||||
Event event1 = new Event(600, 1800, artist1, "hi", 1);
|
|
||||||
ArrayList<Event> performances = new ArrayList<Event>();
|
|
||||||
performances.add(event1);
|
|
||||||
performances.add(event2);
|
|
||||||
Stage stage1 = new Stage(performances, 100, null, 1800, 2100);
|
|
||||||
stages.add(stage1);
|
|
||||||
Stage stage2 = new Stage(performances, 100, null, 1700, 1900);
|
|
||||||
Stage stage3 = new Stage(performances, 100, null, 1600, 1800);
|
|
||||||
Stage stage4 = new Stage(performances, 100, null, 1600, 2100);
|
|
||||||
stages.add(stage3);
|
|
||||||
stages.add(stage2);
|
|
||||||
// stages.add(stage4);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public JPanel getTimeline()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import java.awt.BorderLayout;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
|
|
||||||
public class TimelinePanel extends JPanel {
|
|
||||||
|
|
||||||
private Timeline timeline;
|
|
||||||
|
|
||||||
public TimelinePanel()
|
|
||||||
{
|
|
||||||
super(new BorderLayout());
|
|
||||||
|
|
||||||
this.setSize(600, 600);
|
|
||||||
this.setVisible(true);
|
|
||||||
timeline = new Timeline(this);
|
|
||||||
this.add(timeline,BorderLayout.CENTER);
|
|
||||||
this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh()
|
|
||||||
{
|
|
||||||
timeline.refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
Eventuele methode om de Arraylisten mee te vullen.
|
||||||
|
|
||||||
|
public void test()
|
||||||
|
{
|
||||||
|
Artist artist = new Artist("Paul", "Rock", "null", "description");
|
||||||
|
Event e = new Event(2015,2,13,15,0,2015,2,13,16,0,artist,"Description",7, 1);
|
||||||
|
Stage s = new Stage("Main Stage", 1);
|
||||||
|
|
||||||
|
addArtist(artist);
|
||||||
|
addEvent(e);
|
||||||
|
addStage(s);
|
||||||
|
|
||||||
|
saveAll();
|
||||||
|
fillAll();
|
||||||
|
System.out.println("Saved All Data!");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user