Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
604fc9491a | ||
|
|
9ff8c50309 | ||
|
|
53195bfc7f | ||
|
|
fb224081cc | ||
|
|
21d17eadd2 | ||
|
|
d769129415 | ||
|
|
285de27ba9 | ||
|
|
0ce2e7e6e9 | ||
|
|
ddd9435e4f |
-222
@@ -1,222 +0,0 @@
|
|||||||
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 ArrayList<Event> getEvents()
|
|
||||||
{
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
public ArrayList<Artist> getArtists()
|
|
||||||
{
|
|
||||||
return artists;
|
|
||||||
}
|
|
||||||
public ArrayList<Stage> getStages()
|
|
||||||
{
|
|
||||||
return stages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveAgenda()
|
|
||||||
{
|
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
|
||||||
|
|
||||||
fileChooser.setFileFilter(new FileFilter() {
|
|
||||||
@Override
|
|
||||||
public boolean accept(File pathname) {
|
|
||||||
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}else if(pathname.isDirectory()){return true;}else{return false;}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return ".agn";
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
fileChooser.setDialogTitle("Choose save location");
|
|
||||||
int userSelection = fileChooser.showSaveDialog(null);
|
|
||||||
|
|
||||||
if(userSelection == JFileChooser.APPROVE_OPTION)
|
|
||||||
{
|
|
||||||
File file = fileChooser.getSelectedFile();
|
|
||||||
if(!file.getName().endsWith(".agn"))
|
|
||||||
{
|
|
||||||
file = new File(file.getAbsolutePath() + ".agn");
|
|
||||||
}
|
|
||||||
|
|
||||||
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(".agn"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}else if(pathname.isDirectory()){return true;}else{return false;}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return ".agn";
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
clearAgenda();
|
|
||||||
fillAgenda(file);
|
|
||||||
JOptionPane.showMessageDialog(null, "Loaded succesfully");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
JOptionPane.showMessageDialog(null, "Saved succesfully");
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearAgenda()
|
|
||||||
{
|
|
||||||
events.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fillAllLists()
|
|
||||||
{
|
|
||||||
loadAgenda();
|
|
||||||
fillStages();
|
|
||||||
fillArtists();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+10
-70
@@ -1,87 +1,27 @@
|
|||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
|
||||||
public class Artist implements Serializable{
|
public class Artist
|
||||||
|
{
|
||||||
private static final long serialVersionUID = 1;
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private String genre;
|
private String genre;
|
||||||
private ImageIcon image;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private String background;
|
private ImageIcon image;
|
||||||
|
private int id;
|
||||||
|
|
||||||
public Artist(String name, String genre, String image, String description, String background)
|
public Artist(String genre, String name, String description, ImageIcon image, int id)
|
||||||
{
|
{
|
||||||
this.name = name;
|
|
||||||
this.genre = genre;
|
this.genre = genre;
|
||||||
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.background = background;
|
|
||||||
|
|
||||||
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 String getBackground()
|
|
||||||
{
|
|
||||||
return this.background;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
this.image = image;
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description)
|
public int getID()
|
||||||
{
|
{
|
||||||
this.description = description;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBackground(String background)
|
|
||||||
{
|
|
||||||
this.background = background;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Font;
|
|
||||||
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
|
|
||||||
public class ArtistPanel extends JPanel{
|
|
||||||
|
|
||||||
public ArtistPanel(Event event)
|
|
||||||
{
|
|
||||||
super(new BorderLayout());
|
|
||||||
JLabel name = new JLabel(event.getArtist().getName());
|
|
||||||
|
|
||||||
name.setFont(new Font("Dialog", Font.BOLD, 20));
|
|
||||||
JLabel description = new JLabel("<html>" + " <b> Genre: </b> " + event.getArtist().getGenre() + "<br> <br> <b> Beschrijving </b> <br> <br>" + event.getArtist().getDescription() + " <br> <br> <b> achtergrondinfo </b> <br> <br>" + event.getArtist().getBackground() + "</html>");
|
|
||||||
description.setFont(new Font("Dialog", Font.PLAIN, 12));
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
|
|
||||||
JLabel photo = new JLabel(event.getArtist().getImage());
|
|
||||||
panel.add(name);
|
|
||||||
panel.add(new JSeparator(SwingConstants.HORIZONTAL));
|
|
||||||
add(photo, BorderLayout.EAST);
|
|
||||||
add(description, BorderLayout.CENTER);
|
|
||||||
add(panel, BorderLayout.NORTH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import javax.swing.AbstractListModel;
|
|
||||||
|
|
||||||
|
|
||||||
public class ContentList extends AbstractListModel {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 9110016552017561529L;
|
|
||||||
|
|
||||||
Object[] data;
|
|
||||||
|
|
||||||
public ContentList(Object[] data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(int arg0) {
|
|
||||||
return data[arg0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize() {
|
|
||||||
return data.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
import javax.swing.table.AbstractTableModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is used to make a temporary abstracttableModel with selected data so later it can be passed to the JTable so it refreshes.
|
|
||||||
* @author Wesley
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class ContentTable extends AbstractTableModel {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private Object[][] data;
|
|
||||||
private String[] columnNames;
|
|
||||||
|
|
||||||
|
|
||||||
public ContentTable(Object[][] data,String[] columnNames) {
|
|
||||||
this.data = data;
|
|
||||||
this.columnNames = columnNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return columnNames.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRowCount() {
|
|
||||||
return data.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
|
||||||
return data[rowIndex][columnIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getColumnName(int col) {
|
|
||||||
return columnNames[col];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+19
-174
@@ -1,189 +1,34 @@
|
|||||||
import java.io.Serializable;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.Format;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
public class Event implements Serializable {
|
public class Event
|
||||||
|
{
|
||||||
private static final long serialVersionUID = 1;
|
private int startTime;
|
||||||
|
private int endTime;
|
||||||
private String eventName;
|
|
||||||
private GregorianCalendar startDate;
|
|
||||||
private GregorianCalendar endDate;
|
|
||||||
private Artist artist;
|
private Artist artist;
|
||||||
private Stage stage;
|
|
||||||
private String description;
|
private String description;
|
||||||
private int expectedPopularity;
|
private int id;
|
||||||
|
|
||||||
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 int getLength()
|
public Event(int startTime, int endTime, Artist artist, String description, int id)
|
||||||
{
|
{
|
||||||
return getEndTime() - getStartTime();
|
this.startTime = startTime;
|
||||||
|
this.endTime = endTime;
|
||||||
|
this.artist = artist;
|
||||||
|
this.description = description;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artist getArtist()
|
||||||
|
{
|
||||||
|
return artist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStartTime()
|
public int getStartTime()
|
||||||
{
|
{
|
||||||
DateFormat format = new SimpleDateFormat("kkmm");
|
return startTime;
|
||||||
format.setLenient(false);
|
|
||||||
// System.out.println(format.format(startDate.getTime()));
|
|
||||||
|
|
||||||
// System.out.println(date.get(Calendar.HOUR_OF_DAY));
|
|
||||||
int time = Integer.valueOf(format.format(startDate.getTime()));
|
|
||||||
int hours = time/100;
|
|
||||||
int minutes = time%100;
|
|
||||||
int finaltime;
|
|
||||||
if(minutes != 0)
|
|
||||||
{
|
|
||||||
finaltime = hours*60 + minutes;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
finaltime = hours*60;
|
|
||||||
}
|
|
||||||
return finaltime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEndTime()
|
public int getID()
|
||||||
{
|
{
|
||||||
DateFormat format = new SimpleDateFormat("kkmm");
|
return id + 10;
|
||||||
format.setLenient(false);
|
|
||||||
// System.out.println(format.format(endDate.getTime()));
|
|
||||||
int time = Integer.valueOf(format.format(endDate.getTime()));
|
|
||||||
int hours = time/100;
|
|
||||||
int minutes = time%100;
|
|
||||||
int finaltime;
|
|
||||||
if(minutes != 0)
|
|
||||||
{
|
|
||||||
finaltime = hours*60 + minutes;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
finaltime = hours*60;
|
|
||||||
}
|
|
||||||
|
|
||||||
return finaltime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartTime(int hours, int minutes)
|
|
||||||
{
|
|
||||||
// System.out.println("Start:" + hours + ":" + minutes);
|
|
||||||
startDate.set(Calendar.HOUR_OF_DAY, hours);
|
|
||||||
startDate.set(Calendar.MINUTE, minutes);
|
|
||||||
// System.out.println(startDate.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndTime(int hours, int minutes)
|
|
||||||
{
|
|
||||||
// System.out.println("End:" + hours + ":" + minutes);
|
|
||||||
endDate.set(Calendar.HOUR_OF_DAY, hours);
|
|
||||||
endDate.set(Calendar.MINUTE, minutes);
|
|
||||||
// System.out.println(endDate.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
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()) + ".";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
|
|
||||||
public class EventPanel extends JPanel{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 504733981352439417L;
|
|
||||||
|
|
||||||
public EventPanel(Event event)
|
|
||||||
{
|
|
||||||
super(new BorderLayout());
|
|
||||||
SimpleDateFormat dateformatter = new SimpleDateFormat("dd-MM-yyyy");
|
|
||||||
SimpleDateFormat timeformatter = new SimpleDateFormat("HH:mm");
|
|
||||||
JPanel box1 = new JPanel();
|
|
||||||
box1.setLayout(new BoxLayout(box1, BoxLayout.PAGE_AXIS));
|
|
||||||
JPanel box2 = new JPanel();
|
|
||||||
box2.setLayout(new BoxLayout(box2, BoxLayout.LINE_AXIS));
|
|
||||||
JPanel box3 = new JPanel();
|
|
||||||
box3.setLayout(new BoxLayout(box3, BoxLayout.PAGE_AXIS));
|
|
||||||
JPanel row = new JPanel();
|
|
||||||
row.setLayout(new BoxLayout(row, BoxLayout.LINE_AXIS));
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
|
|
||||||
JLabel title = new JLabel("<html>" + event.getEventName() + "</html>");
|
|
||||||
JLabel date = new JLabel("<html>" + dateformatter.format(event.getEndDate().getTime()) + "</html>");
|
|
||||||
JLabel data = new JLabel("<html> " + event.getStage().getName() + "<br> <br>" + event.getArtist().getName() + "<br> <br>" + event.getExpectedPopularity() + "<br> <br>" + timeformatter.format(event.getStartDate().getTime()) + " - " + timeformatter.format(event.getEndDate().getTime()) + "<br> <br> </html>");
|
|
||||||
JLabel text = new JLabel("<html> Podium: <br> <br> Artiest: <br> <br> Populariteit: <br> <br> Tijd: <br> <br> </html>");
|
|
||||||
box2.setAlignmentX(LEFT_ALIGNMENT);
|
|
||||||
date.setFont(new Font("Dialog", Font.BOLD, 15));
|
|
||||||
row.setAlignmentX(LEFT_ALIGNMENT);
|
|
||||||
date.setAlignmentX(RIGHT_ALIGNMENT);
|
|
||||||
title.setFont(new Font("Dialog", Font.BOLD, 20));
|
|
||||||
text.setFont(new Font("Dialog", Font.BOLD, 15));
|
|
||||||
data.setFont(new Font("Dialog", Font.PLAIN, 15));
|
|
||||||
JLabel description = new JLabel("<html> <b> Beschrijving </b> <br> <br>" + event.getDescription() + "</html>");
|
|
||||||
description.setFont(new Font("Dialog", Font.PLAIN, 12));
|
|
||||||
row.add(title);
|
|
||||||
row.add(date);
|
|
||||||
box1.add(row);
|
|
||||||
box1.add(new JSeparator(SwingConstants.HORIZONTAL));
|
|
||||||
box2.add(text);
|
|
||||||
box2.add(data);
|
|
||||||
box3.add(new JSeparator(SwingConstants.HORIZONTAL));
|
|
||||||
box3.add(description);
|
|
||||||
panel.add(box1);
|
|
||||||
panel.add(box2);
|
|
||||||
panel.add(box3);
|
|
||||||
add(panel, BorderLayout.CENTER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
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,41 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
//new Window();
|
|
||||||
|
|
||||||
Window w = new Window();
|
|
||||||
Agenda agn = w.getAgenda();
|
|
||||||
|
|
||||||
Artist a1 = new Artist("Coldplay", "Alternative Rock", "null", "A band", "more important information");
|
|
||||||
Artist a2 = new Artist("Nirvana", "Alternative Rock", "null", "A band whose lead singer is dead", "more important information");
|
|
||||||
Artist a3 = new Artist("Eminem", "Rap", "null", "A very famous rapper", "more important information");
|
|
||||||
Stage s1 = new Stage("Rock Stage", "Stage for Rock and Alternative Rock concerts");
|
|
||||||
Stage s2 = new Stage("Rap Stage", "Stage for Rap concerts");
|
|
||||||
|
|
||||||
Event e1 = new Event("Coldplay Live", 2015, 2, 24, 21, 00, 2015, 2, 24, 23, 00, a1, s1, "A concert from a very famous band", 2);
|
|
||||||
Event e2 = new Event("Coldplay Live", 2015, 2, 25, 20, 00, 2015, 2, 25, 22, 00, a1, s1, "A concert from a very famous band", 1);
|
|
||||||
Event e3 = new Event("Nirvana in memory", 2015, 2, 24, 16, 30, 2015, 2, 24, 20, 45, a2, s1, "A concert in memory of a once very famous band", 4);
|
|
||||||
Event e4 = new Event("Epic Rap Battles of History", 2015, 3, 3, 12, 30, 2015, 3, 12, 18, 45, a3, s2, "Rap battle with Eminem and ERP", 3);
|
|
||||||
Event e5 = new Event("Coldplay Live", 2015, 2, 26, 21, 00, 2015, 2, 24, 23, 00, a1, s1, "A concert from a very famous band", 2);
|
|
||||||
Event e6 = new Event("Coldplay Live", 2015, 2, 27, 20, 00, 2015, 2, 25, 22, 00, a1, s1, "A concert from a very famous band", 1);
|
|
||||||
Event e7 = new Event("Nirvana in memory", 2015, 2, 28, 16, 30, 2015, 2, 24, 20, 45, a2, s1, "A concert in memory of a once very famous band", 4);
|
|
||||||
Event e8 = new Event("Epic Rap Battles of History", 2015, 3, 2, 12, 30, 2015, 3, 12, 18, 45, a3, s2, "Rap battle with Eminem and ERP", 3);
|
|
||||||
|
|
||||||
agn.addEvent(e1);
|
|
||||||
agn.addEvent(e2);
|
|
||||||
agn.addEvent(e3);
|
|
||||||
agn.addEvent(e4);
|
|
||||||
agn.addEvent(e5);
|
|
||||||
agn.addEvent(e6);
|
|
||||||
agn.addEvent(e7);
|
|
||||||
agn.addEvent(e8);
|
|
||||||
|
|
||||||
agn.fillArtists();
|
|
||||||
agn.fillStages();
|
|
||||||
w.updatePanel("timeline");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-130
@@ -1,130 +0,0 @@
|
|||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
|
|
||||||
import javax.swing.JMenu;
|
|
||||||
import javax.swing.JMenuBar;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.KeyStroke;
|
|
||||||
|
|
||||||
|
|
||||||
public class MenuBar extends JMenuBar {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -2095136277753179215L;
|
|
||||||
|
|
||||||
|
|
||||||
public MenuBar(Window w)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FILE
|
|
||||||
*/
|
|
||||||
JMenu file = new JMenu("File");
|
|
||||||
|
|
||||||
JMenuItem newEvent = new JMenuItem("New Event");
|
|
||||||
newEvent.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
|
|
||||||
newEvent.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem newArtist = new JMenuItem("New Artist");
|
|
||||||
newArtist.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem newStage = new JMenuItem("New Stage");
|
|
||||||
newStage.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem newAgenda = new JMenuItem("New Agenda");
|
|
||||||
newAgenda.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Agenda a = new Agenda();
|
|
||||||
w.setAgenda(a);
|
|
||||||
Window.updatePanel("table");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem open = new JMenuItem("Open");
|
|
||||||
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
|
||||||
open.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
w.getAgenda().loadAgenda();
|
|
||||||
Window.updatePanel("table");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem save = new JMenuItem("Save");
|
|
||||||
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
|
|
||||||
save.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
w.getAgenda().saveAgenda();
|
|
||||||
Window.updatePanel("table");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem exit = new JMenuItem("Exit");
|
|
||||||
exit.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to close this program?", "Close Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
|
||||||
{
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
file.add(newEvent);
|
|
||||||
file.add(newArtist);
|
|
||||||
file.add(newStage);
|
|
||||||
file.addSeparator();
|
|
||||||
file.add(newAgenda);
|
|
||||||
file.addSeparator();
|
|
||||||
file.add(open);
|
|
||||||
file.add(save);
|
|
||||||
file.addSeparator();
|
|
||||||
file.add(exit);
|
|
||||||
add(file);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* VIEW
|
|
||||||
*/
|
|
||||||
|
|
||||||
JMenu view = new JMenu("View");
|
|
||||||
|
|
||||||
JMenuItem timeline = new JMenuItem("Timeline");
|
|
||||||
timeline.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Window.updatePanel("timeline");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem table = new JMenuItem("Table");
|
|
||||||
table.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Window.updatePanel("table");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem art_sta = new JMenuItem("Artists and Stages");
|
|
||||||
art_sta.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Window.updatePanel("art_sta");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view.add(timeline);
|
|
||||||
view.add(table);
|
|
||||||
view.add(art_sta);
|
|
||||||
add(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public interface Panel{
|
|
||||||
public void update(ArrayList<Event> event);
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
import java.awt.Dimension;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.AbstractListModel;
|
|
||||||
import javax.swing.JList;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.ListSelectionModel;
|
|
||||||
import javax.swing.event.ListSelectionEvent;
|
|
||||||
import javax.swing.event.ListSelectionListener;
|
|
||||||
|
|
||||||
public class PanelArtSta extends JPanel implements Panel{
|
|
||||||
|
|
||||||
private Agenda a;
|
|
||||||
JList artists;
|
|
||||||
JList stages;
|
|
||||||
Object[] dataArtist;
|
|
||||||
Object[] dataStage;
|
|
||||||
|
|
||||||
public PanelArtSta(Window w)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
a = w.getAgenda();
|
|
||||||
|
|
||||||
artists = new JList();
|
|
||||||
artists.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
|
||||||
artists.setLayoutOrientation(JList.VERTICAL_WRAP);
|
|
||||||
artists.setVisibleRowCount(-1);
|
|
||||||
artists.addListSelectionListener(new ListSelectionListener() {
|
|
||||||
@Override
|
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
|
||||||
if (e.getValueIsAdjusting() == false) {
|
|
||||||
|
|
||||||
if (artists.getSelectedIndex() == -1) {
|
|
||||||
} else {
|
|
||||||
JOptionPane.showMessageDialog(null, "Artist Selected: " + a.getArtists().get(artists.getSelectedIndex()));
|
|
||||||
artists.clearSelection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
JScrollPane artistScroller = new JScrollPane(artists);
|
|
||||||
artistScroller.setPreferredSize(new Dimension(250, 80));
|
|
||||||
|
|
||||||
stages = new JList();
|
|
||||||
stages.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
|
||||||
stages.setLayoutOrientation(JList.VERTICAL_WRAP);
|
|
||||||
stages.setVisibleRowCount(-1);
|
|
||||||
stages.addListSelectionListener(new ListSelectionListener() {
|
|
||||||
@Override
|
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
|
||||||
if (e.getValueIsAdjusting() == false) {
|
|
||||||
|
|
||||||
if (stages.getSelectedIndex() == -1) {
|
|
||||||
} else {
|
|
||||||
JOptionPane.showMessageDialog(null, "Stage Selected: " + a.getStages().get(stages.getSelectedIndex()));
|
|
||||||
stages.clearSelection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
JScrollPane stageScroller = new JScrollPane(stages);
|
|
||||||
stageScroller.setPreferredSize(new Dimension(250, 80));
|
|
||||||
|
|
||||||
add(artistScroller);
|
|
||||||
add(stageScroller);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void compileData()
|
|
||||||
{
|
|
||||||
int artists = a.getArtists().size();
|
|
||||||
int stages = a.getStages().size();
|
|
||||||
dataArtist = new Object[artists];
|
|
||||||
dataStage = new Object[stages];
|
|
||||||
|
|
||||||
for(int i = 0; i < artists; i++)
|
|
||||||
{
|
|
||||||
dataArtist[i] = a.getArtists().get(i);
|
|
||||||
}
|
|
||||||
for(int i = 0; i < stages; i++)
|
|
||||||
{
|
|
||||||
dataStage[i] = a.getStages().get(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
public void update(ArrayList<Event> event) {
|
|
||||||
compileData();
|
|
||||||
AbstractListModel artistsList = new ContentList(dataArtist);
|
|
||||||
AbstractListModel stagesList = new ContentList(dataStage);
|
|
||||||
artists.setModel(artistsList);
|
|
||||||
stages.setModel(stagesList);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-196
@@ -1,196 +0,0 @@
|
|||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a JTable in a ScrolPane.
|
|
||||||
* @author Wesley
|
|
||||||
* @version 1.2
|
|
||||||
*/
|
|
||||||
public class PanelTable extends JPanel implements Panel{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private JScrollPane scrollPane;
|
|
||||||
private Object[][] data;
|
|
||||||
private String[] columnNames = {"Stage",
|
|
||||||
"Event",
|
|
||||||
"Artist",
|
|
||||||
"Begin Time",
|
|
||||||
"End Time"};
|
|
||||||
private ArrayList<Event> events;
|
|
||||||
private ArrayList<Event> fullEvents;
|
|
||||||
private JTable table;
|
|
||||||
private JTable selectedCell;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor makes the table and adds it to a scrollPane.
|
|
||||||
* @param events
|
|
||||||
*/
|
|
||||||
public PanelTable() {
|
|
||||||
super.setLayout(new BorderLayout());
|
|
||||||
table= new JTable();
|
|
||||||
table.setAutoCreateRowSorter(true);
|
|
||||||
table.setAutoResizeMode(table.AUTO_RESIZE_ALL_COLUMNS);
|
|
||||||
table.addMouseListener(new MouseAdapter() {
|
|
||||||
public void mouseClicked(MouseEvent e) { if(e.getClickCount() > 1 ) cellClicked(e); else selectedCell = (JTable) e.getSource(); }
|
|
||||||
});
|
|
||||||
scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
|
||||||
add(scrollPane,BorderLayout.SOUTH);
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
||||||
JButton button;
|
|
||||||
button = new JButton("Filter");
|
|
||||||
button.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) { filter(); }
|
|
||||||
});
|
|
||||||
buttonPanel.add(button);
|
|
||||||
button = new JButton(new ImageIcon("sprites/sprite0.png"));
|
|
||||||
button.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) { update(fullEvents, true); }
|
|
||||||
});
|
|
||||||
buttonPanel.add(button);
|
|
||||||
add(buttonPanel,BorderLayout.NORTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the size of the scrollPane, in which the table is placed to fill out its container panel (not sure if this is needed?)
|
|
||||||
*/
|
|
||||||
public void paintComponent(Graphics g) {
|
|
||||||
scrollPane.setPreferredSize(new Dimension(getWidth(),getHeight()-35));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the data from the events arrayList and makes a 2D-array of it.
|
|
||||||
* @param columnes
|
|
||||||
* @param rows
|
|
||||||
*/
|
|
||||||
public void compileData(int columnes, int rows) {
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm");
|
|
||||||
data = new Object[rows][columnes];
|
|
||||||
for(int x = 0; x < rows; x++) {
|
|
||||||
Object[] tempData = new Object[columnes];
|
|
||||||
tempData[0] = "Stage 1";
|
|
||||||
tempData[1] = events.get(x).getEventName();
|
|
||||||
tempData[2] = events.get(x).getArtist().getName();
|
|
||||||
tempData[3] = formatter.format(events.get(x).getStartDate().getTime());
|
|
||||||
tempData[4] = formatter.format(events.get(x).getEndDate().getTime());
|
|
||||||
data[x] = tempData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refreshes the content on the table with a fresh ArrayList of events, useful when things are removed and added and should be called every time you update the list.
|
|
||||||
* @param events
|
|
||||||
*/
|
|
||||||
public void update(ArrayList<Event> events)
|
|
||||||
{
|
|
||||||
update(events, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(ArrayList<Event> events, boolean newList) {
|
|
||||||
this.events = events;
|
|
||||||
if(newList)
|
|
||||||
this.fullEvents = events;
|
|
||||||
compileData(columnNames.length,events.size());
|
|
||||||
AbstractTableModel tableModel = new ContentTable(data,columnNames);
|
|
||||||
table.setModel(tableModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method for the action listener when a cell is clicked, opens dialog of the clicked cell.
|
|
||||||
* @param e
|
|
||||||
*/
|
|
||||||
private void cellClicked(MouseEvent e) {
|
|
||||||
JTable target = (JTable) e.getSource();
|
|
||||||
switch(target.getSelectedColumn()) {
|
|
||||||
case 0:
|
|
||||||
//A dialog for podia?
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
openEventDialog(target.getSelectedRow());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
openArtistDialog(target.getSelectedRow());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens a dialog with information of the selected event.
|
|
||||||
* @param row
|
|
||||||
*/
|
|
||||||
private void openEventDialog(int row) {
|
|
||||||
Event event = events.get(row);
|
|
||||||
new TabbedPane(event, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens a dialog with information of the selected artist
|
|
||||||
* @param row
|
|
||||||
*/
|
|
||||||
private void openArtistDialog(int row) {
|
|
||||||
Event event = events.get(row);
|
|
||||||
new TabbedPane(event, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter method which filters on the currently selected cell.
|
|
||||||
* Needs to be under a button action, also a reset button is needed so list can be restored.
|
|
||||||
*/
|
|
||||||
public void filter() {
|
|
||||||
if(selectedCell != null) {
|
|
||||||
if(fullEvents.isEmpty()) {
|
|
||||||
fullEvents = events;
|
|
||||||
}
|
|
||||||
ArrayList<Event> filteredList = new ArrayList<>();
|
|
||||||
switch(selectedCell.getSelectedColumn()) {
|
|
||||||
case 0:
|
|
||||||
for(Event event : fullEvents) {
|
|
||||||
if(event.getStage().equals(events.get(selectedCell.getSelectedRow()).getStage())) {
|
|
||||||
filteredList.add(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
for(Event event : fullEvents) {
|
|
||||||
if(event.equals(events.get(selectedCell.getSelectedRow()))) {
|
|
||||||
filteredList.add(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
for(Event event : fullEvents) {
|
|
||||||
if(event.getArtist().equals(events.get(selectedCell.getSelectedRow()).getArtist())) {
|
|
||||||
filteredList.add(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
update(filteredList,false);
|
|
||||||
selectedCell = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JOptionPane.showMessageDialog(this, "Select a cell with the value u want to filter on","No cell selected",JOptionPane.WARNING_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
# BELANGRIJK
|
# BELANGRIJK
|
||||||
De .jar file moet als externe Library toegevoegd worden.
|
De .jar file moet als externe Library toegevoegd worden.
|
||||||
De sprites folder moet in de root van het project.
|
De sprites folder moet in de root van het project.
|
||||||
|
|
||||||
|
BRANCH VAN YORICK
|
||||||
|
Ja, codemess please.
|
||||||
|
|||||||
-123
@@ -1,123 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
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 javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.filechooser.FileFilter;
|
|
||||||
|
|
||||||
public class SaveLoad {
|
|
||||||
|
|
||||||
public static void saveFile(Object obj)
|
|
||||||
{
|
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
|
||||||
|
|
||||||
fileChooser.setFileFilter(new FileFilter() {
|
|
||||||
@Override
|
|
||||||
public boolean accept(File pathname) {
|
|
||||||
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}else if(pathname.isDirectory()){return true;}else{return false;}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return "Agenda (.agn)";
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
fileChooser.setDialogTitle("Choose save location");
|
|
||||||
int userSelection = fileChooser.showSaveDialog(null);
|
|
||||||
|
|
||||||
if(userSelection == JFileChooser.APPROVE_OPTION)
|
|
||||||
{
|
|
||||||
File file = fileChooser.getSelectedFile();
|
|
||||||
if(!file.getName().endsWith(".agn"))
|
|
||||||
{
|
|
||||||
file = new File(file.getAbsolutePath() + ".agn");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(file.exists())
|
|
||||||
{
|
|
||||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to overwrite: " + file.getName(), "Overwrite", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
|
||||||
{
|
|
||||||
save(obj, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
save(obj, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object loadFile()
|
|
||||||
{
|
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
|
||||||
fileChooser.setFileFilter(new FileFilter() {
|
|
||||||
@Override
|
|
||||||
public boolean accept(File pathname) {
|
|
||||||
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}else if(pathname.isDirectory()){return true;}else{return false;}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return "Agenda (.agn)";
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
return load(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void save(Object obj, File file)
|
|
||||||
{
|
|
||||||
ObjectOutputStream oostr = null;
|
|
||||||
try {
|
|
||||||
oostr = new ObjectOutputStream(new FileOutputStream(file));
|
|
||||||
oostr.writeObject(obj);
|
|
||||||
oostr.flush();
|
|
||||||
oostr.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Object load(File file)
|
|
||||||
{
|
|
||||||
ObjectInputStream oistr = null;
|
|
||||||
try {
|
|
||||||
oistr = new ObjectInputStream(new FileInputStream(file));
|
|
||||||
Object obj = oistr.readObject();
|
|
||||||
oistr.close();
|
|
||||||
return obj;
|
|
||||||
} catch (IOException | ClassNotFoundException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+37
-20
@@ -1,40 +1,57 @@
|
|||||||
import java.io.Serializable;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Stage implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1;
|
public class Stage
|
||||||
|
{
|
||||||
private String name;
|
private ArrayList<Event> performances;
|
||||||
|
private int expectedPopularity;
|
||||||
private String description;
|
private String description;
|
||||||
|
private int length;
|
||||||
|
private int startTime,endTime;
|
||||||
|
|
||||||
public Stage(String name, String description)
|
public Stage(ArrayList<Event> performances, int expectedPopularity, String description, int startTime, int endTime)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.performances = performances;
|
||||||
|
this.expectedPopularity = expectedPopularity;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.endTime = endTime;
|
||||||
|
this.length = endTime - startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public void setStartTime(int startTime)
|
||||||
{
|
{
|
||||||
return this.name;
|
this.startTime = startTime;
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription()
|
|
||||||
{
|
|
||||||
return this.description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description)
|
public void setEndTime(int endTime)
|
||||||
{
|
{
|
||||||
this.description = description;
|
this.endTime = endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public ArrayList<Event> getPerformances()
|
||||||
{
|
{
|
||||||
this.name = name;
|
return performances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
// public int getID()
|
||||||
|
// {
|
||||||
|
// return id + 100;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public int getLength()
|
||||||
{
|
{
|
||||||
return name;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStartTime()
|
||||||
|
{
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEndTime()
|
||||||
|
{
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-19
@@ -13,16 +13,13 @@ public class StagePanel extends JPanel
|
|||||||
{
|
{
|
||||||
private BufferedImage image;
|
private BufferedImage image;
|
||||||
private int width, height, posX;
|
private int width, height, posX;
|
||||||
private double widthD, posXD;
|
private Stage stage;
|
||||||
private Event event;
|
public StagePanel(int width, int height, int posX, Stage stage)
|
||||||
public StagePanel(int width, int height, int posX, Event event, double widthD, double posXD)
|
|
||||||
{
|
{
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.posX = posX;
|
this.posX = posX;
|
||||||
this.event = event;
|
this.stage = stage;
|
||||||
this.widthD = widthD;
|
|
||||||
this.posXD = posXD;
|
|
||||||
image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB);
|
image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB);
|
||||||
Graphics2D g2 = image.createGraphics();
|
Graphics2D g2 = image.createGraphics();
|
||||||
g2.setColor(Color.blue);
|
g2.setColor(Color.blue);
|
||||||
@@ -47,10 +44,9 @@ public class StagePanel extends JPanel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(int posx, double posXD)
|
public void update(int posx)
|
||||||
{
|
{
|
||||||
this.posX = posx;
|
this.posX = posx;
|
||||||
this.posXD = posXD;
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,35 +57,34 @@ public class StagePanel extends JPanel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPosX()
|
public int getPosX()
|
||||||
{
|
{
|
||||||
return this.posXD;
|
return this.posX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLength(int length, double widthD)
|
public void setLength(int length)
|
||||||
{
|
{
|
||||||
this.width = length;
|
this.width = length;
|
||||||
this.widthD = widthD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStageStartTime(int hours, int minutes)
|
public void setStageStartTime(int startTime)
|
||||||
{
|
{
|
||||||
event.setStartTime(hours, minutes);
|
stage.setStartTime(startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStageEndTime(int hours, int minutes)
|
public void setStageEndTime(int endTime)
|
||||||
{
|
{
|
||||||
event.setEndTime(hours, minutes);
|
stage.setEndTime(endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStageStartTime()
|
public int getStageStartTime()
|
||||||
{
|
{
|
||||||
return event.getStartTime();
|
return stage.getStartTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getImageWidth()
|
public int getImageWidth()
|
||||||
{
|
{
|
||||||
return this.widthD;
|
return this.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
//een jframe met info, heeft alleen een event object (het desbetreffende event) en een boolean met daarin true of false (slaande op je wel of niet met het event wilt starten) nodig.
|
|
||||||
//Voorderest heeft dit niks nodig en is het een apart openend JFrame wat gewoon weer afgesloten kan worden.
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JTabbedPane;
|
|
||||||
|
|
||||||
public class TabbedPane extends JFrame{
|
|
||||||
|
|
||||||
public TabbedPane(Event event, boolean eventSelected)
|
|
||||||
{
|
|
||||||
super("info GUI");
|
|
||||||
JTabbedPane tab = new JTabbedPane();
|
|
||||||
tab.add("Event", new EventPanel(event));
|
|
||||||
tab.add("Artist", new ArtistPanel(event));
|
|
||||||
if(eventSelected)
|
|
||||||
{
|
|
||||||
tab.setSelectedIndex(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tab.setSelectedIndex(1);
|
|
||||||
}
|
|
||||||
setContentPane(tab);
|
|
||||||
setSize(480, 410);
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//"Event", new EventPanel("Introductie", "Hoofdpodium", "14:00-15:00", "Populair", "Paul Lindelauf", "25-02-2015", "Het begin van het festival, wordt gepresenteerd door Paul Lindelauf. En ik moet nog een hele hoop onzin toevoegen om dit goed te kunnen testen, dus daarom doe ik dat nu ook maar even. En nog een hele hoop informatie vanwege REDENEN. En waarom de fuck hij nu wel ineens normaal kan doen weet ik niet, maar zal dus maar voor de volgende keer onthouden minder onzin te typen."
|
|
||||||
//"Artist", new ArtistPanel("Paul Lindelauf", "Paultje Lindelauf <br> <br> Paultje is de ster van de show en opent de voorstelling. Hierna komen de geweldige artiesten.<br> <br>", "Achtergrondinformatie<br> <br> Paul staat bekend als de man die zijn leerlingen treiterde met zijn diagrammen, leiderschap en Excel.", "src/content/Paul.jpg"
|
|
||||||
+68
-165
@@ -13,7 +13,6 @@ import java.awt.event.MouseListener;
|
|||||||
import java.awt.event.MouseMotionAdapter;
|
import java.awt.event.MouseMotionAdapter;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
@@ -27,7 +26,7 @@ import javax.swing.JPanel;
|
|||||||
@SuppressWarnings({ "serial" })
|
@SuppressWarnings({ "serial" })
|
||||||
public class Timeline extends JPanel
|
public class Timeline extends JPanel
|
||||||
{
|
{
|
||||||
private ArrayList<Event> events = new ArrayList<Event>();
|
private ArrayList<Stage> stages = new ArrayList<Stage>();
|
||||||
private JPanel frame;
|
private JPanel frame;
|
||||||
|
|
||||||
// Geef dit object je JFrame mee, en zet in je JFrame de volgende code:
|
// Geef dit object je JFrame mee, en zet in je JFrame de volgende code:
|
||||||
@@ -47,25 +46,20 @@ public class Timeline extends JPanel
|
|||||||
|
|
||||||
genStages();
|
genStages();
|
||||||
this.setSize(frame.getWidth(), frame.getHeight());
|
this.setSize(frame.getWidth(), frame.getHeight());
|
||||||
// refresh();
|
refresh();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEvents(ArrayList<Event> events)
|
|
||||||
{
|
|
||||||
this.events = events;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh()
|
public void refresh()
|
||||||
{
|
{
|
||||||
this.removeAll();
|
this.removeAll();
|
||||||
|
// createWestPanel();
|
||||||
createMainPanel();
|
createMainPanel();
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel createMainPanel()
|
private void createMainPanel()
|
||||||
{
|
{
|
||||||
// this.setSize(frame.getWidth(), frame.getHeight());
|
|
||||||
JPanel mainPanel = new JPanel();
|
JPanel mainPanel = new JPanel();
|
||||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
||||||
Container topContainer = createTopPanel();
|
Container topContainer = createTopPanel();
|
||||||
@@ -73,17 +67,16 @@ public class Timeline extends JPanel
|
|||||||
topContainer.setMaximumSize(dim);
|
topContainer.setMaximumSize(dim);
|
||||||
mainPanel.add(topContainer);
|
mainPanel.add(topContainer);
|
||||||
|
|
||||||
Dimension centerDim = new Dimension(this.getWidth(), this.getHeight());
|
Dimension centerDim = new Dimension(this.getWidth(), frame.getHeight());
|
||||||
|
|
||||||
// Container centerContainer = createCenterPanel();
|
// Container centerContainer = createCenterPanel();
|
||||||
JPanel centerContainer = createCenterPanel();
|
JPanel centerContainer = createCenterPanel();
|
||||||
centerContainer.setPreferredSize(centerDim);
|
centerContainer.setPreferredSize(centerDim);
|
||||||
|
|
||||||
centerContainer.setMaximumSize(centerDim);
|
centerContainer.setMaximumSize(centerDim);
|
||||||
// System.out.println(centerDim);
|
System.out.println(centerDim);
|
||||||
mainPanel.add(centerContainer);
|
mainPanel.add(centerContainer);
|
||||||
this.add(mainPanel, BorderLayout.CENTER);
|
this.add(mainPanel, BorderLayout.CENTER);
|
||||||
return mainPanel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel createCenterPanel()
|
private JPanel createCenterPanel()
|
||||||
@@ -94,9 +87,9 @@ public class Timeline extends JPanel
|
|||||||
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
|
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
|
||||||
centerPanel.add(Box.createRigidArea(new Dimension(0, 30)));
|
centerPanel.add(Box.createRigidArea(new Dimension(0, 30)));
|
||||||
|
|
||||||
for(Event event : events)
|
for(Stage stage : stages)
|
||||||
{
|
{
|
||||||
StagePanel stagepanel = new StagePanel((int)calcLengthOfStage(event.getLength()), 30, (int)calcPositionOfStage(event.getStartTime()), event,calcLengthOfStage(event.getLength()),calcPositionOfStage(event.getStartTime()));
|
StagePanel stagepanel = new StagePanel(calcLengthOfStage(stage.getLength()), 30, calcPositionOfStage(stage.getStartTime()), stage);
|
||||||
Container content = stagepanel;
|
Container content = stagepanel;
|
||||||
content.setMaximumSize(new Dimension(this.getWidth(),30));
|
content.setMaximumSize(new Dimension(this.getWidth(),30));
|
||||||
content.addMouseListener(new MouseListener() {
|
content.addMouseListener(new MouseListener() {
|
||||||
@@ -135,11 +128,7 @@ public class Timeline extends JPanel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseDragged(MouseEvent e) {
|
public void mouseDragged(MouseEvent e) {
|
||||||
int value = (int)(e.getX() - stagepanel.getImageWidth() / 2);
|
stagepanel.update(e.getX() - stagepanel.getImageWidth() / 2);
|
||||||
double value2 = (e.getX() - stagepanel.getImageWidth() / 2);
|
|
||||||
// System.out.println("Value1: " + value);
|
|
||||||
// System.out.println("Value2: " + value2);
|
|
||||||
stagepanel.update(value, value2);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
centerPanel.add(content);
|
centerPanel.add(content);
|
||||||
@@ -152,67 +141,54 @@ public class Timeline extends JPanel
|
|||||||
|
|
||||||
public void resizeTimeline(StagePanel stagepanel)
|
public void resizeTimeline(StagePanel stagepanel)
|
||||||
{
|
{
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
// System.out.println(stagepanel.getStageStartTime());
|
// System.out.println(stagepanel.getStageStartTime());
|
||||||
// System.out.println(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
// System.out.println(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||||
stagepanel.setStageStartTime(calcStartTimeOfStagePanelHours(stagepanel.getPosX()),calcStartTimeOfStagePanelMinutes(stagepanel.getPosX()));
|
stagepanel.setStageStartTime(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||||
stagepanel.setStageEndTime(calcEndTimeOfStagePanelHours(stagepanel.getPosX(), stagepanel.getImageWidth()),calcEndTimeOfStagePanelMinutes(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
stagepanel.setStageEndTime(calcEndTimeOfStagePanel(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
||||||
// stagepanel.setLength(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
// stagepanel.setLength(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
||||||
// System.out.println("HOURS: " + calcEndTimeOfStagePanelHours(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
// System.out.println(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
||||||
// System.out.println("MINUTES: " + calcEndTimeOfStagePanelMinutes(stagepanel.getPosX(), stagepanel.getImageWidth()) );
|
|
||||||
// TimelinePanel tempPanel = (TimelinePanel) frame;
|
|
||||||
// tempPanel.refresh();
|
|
||||||
refresh();
|
refresh();
|
||||||
// System.out.println(stagepanel.getPosX());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calcLengthOfStage(double length)
|
public int calcLengthOfStage(int length)
|
||||||
{
|
{
|
||||||
double lengthOfStage = 0;
|
double lengthOfStage = 0;
|
||||||
int min = findMinMax(1);
|
int min = findMinMax(1);
|
||||||
int max = findMinMax(2);
|
int max = findMinMax(2);
|
||||||
|
|
||||||
double frameWidth = this.getWidth();
|
double frameWidth = this.getWidth();
|
||||||
double minmax = max-min;
|
double pixelsPerLength = frameWidth / (max - min);
|
||||||
double pixelsPerLength = frameWidth / minmax;
|
|
||||||
lengthOfStage = pixelsPerLength * (double)length;
|
lengthOfStage = pixelsPerLength * (double)length;
|
||||||
// System.out.println("LengthOfStage: " + lengthOfStage);
|
// System.out.println((int)lengthOfStage);
|
||||||
//
|
return (int)lengthOfStage;
|
||||||
// System.out.println("MAX: " + max);
|
|
||||||
// System.out.println("MIN: " + min);
|
|
||||||
// System.out.println("LENGTH: " + length);
|
|
||||||
// System.out.println("FRAME: " + frameWidth);
|
|
||||||
// System.out.println("PixelsPerLEngth: " + pixelsPerLength);
|
|
||||||
|
|
||||||
return lengthOfStage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calcLengthOfStagePanel(double length)
|
public int calcLengthOfStagePanel(int length)
|
||||||
{
|
{
|
||||||
double lengthOfStagePanel = 0;
|
double lengthOfStagePanel = 0;
|
||||||
int min = findMinMax(1);
|
int min = findMinMax(1);
|
||||||
int max = findMinMax(2);
|
int max = findMinMax(2);
|
||||||
// System.out.println(length);
|
// System.out.println(length);
|
||||||
double frameWidth = this.getWidth();
|
double frameWidth = this.getWidth();
|
||||||
double minmax = max-min;
|
double pixelsPerLength = frameWidth / (max - min);
|
||||||
double pixelsPerLength = frameWidth / minmax;
|
|
||||||
// System.out.println(pixelsPerLength);
|
// System.out.println(pixelsPerLength);
|
||||||
lengthOfStagePanel = (double)length / pixelsPerLength;
|
lengthOfStagePanel = (double)length / pixelsPerLength;
|
||||||
// System.out.println(lengthOfStagePanel);
|
// System.out.println(lengthOfStagePanel);
|
||||||
|
|
||||||
|
return (int)lengthOfStagePanel;
|
||||||
// System.out.println("LengthOfStagePane: " + (int)lengthOfStagePanel);
|
|
||||||
|
|
||||||
return lengthOfStagePanel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calcPositionOfStage(int startTime)
|
public int calcPositionOfStage(int startTime)
|
||||||
{
|
{
|
||||||
double posx;
|
int posx = 0;
|
||||||
int min = findMinMax(1);
|
int min = findMinMax(1);
|
||||||
int max = findMinMax(2);
|
int max = findMinMax(2);
|
||||||
double minmax = max-min;
|
|
||||||
posx = startTime - min;
|
posx = startTime - min;
|
||||||
posx = posx * this.getWidth() / minmax;
|
posx = posx * this.getWidth() / (max-min);
|
||||||
// System.out.println("Frame: " + this.getWidth());
|
// System.out.println("Frame: " + this.getWidth());
|
||||||
// System.out.println("startTime: " + startTime);
|
// System.out.println("startTime: " + startTime);
|
||||||
// System.out.println("Max: " + max + " min: " + min);
|
// System.out.println("Max: " + max + " min: " + min);
|
||||||
@@ -220,27 +196,7 @@ public class Timeline extends JPanel
|
|||||||
return posx;
|
return posx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int calcStartTimeOfStagePanelHours(double posx)
|
public int calcStartTimeOfStagePanel(int posx)
|
||||||
{
|
|
||||||
int min = findMinMax(1);
|
|
||||||
int max = findMinMax(2);
|
|
||||||
// System.out.println("MIN: " + min);
|
|
||||||
// System.out.println("max: " + max);
|
|
||||||
// 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("STPH: " + this.getWidth());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ((int)startTime / 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calcStartTimeOfStagePanelMinutes(double posx)
|
|
||||||
{
|
{
|
||||||
int min = findMinMax(1);
|
int min = findMinMax(1);
|
||||||
int max = findMinMax(2);
|
int max = findMinMax(2);
|
||||||
@@ -250,12 +206,17 @@ public class Timeline extends JPanel
|
|||||||
double bottom = this.getWidth() / minmax;
|
double bottom = this.getWidth() / minmax;
|
||||||
double all = posx / bottom;
|
double all = posx / bottom;
|
||||||
double startTime = all + min;
|
double startTime = all + min;
|
||||||
// System.out.println("STPM: " + this.getWidth());
|
|
||||||
|
|
||||||
return ((int)startTime % 60);
|
|
||||||
|
// 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 calcEndTimeOfStagePanelHours(double posx, double imageWidth)
|
public int calcEndTimeOfStagePanel(int posx, int imageWidth)
|
||||||
{
|
{
|
||||||
int min = findMinMax(1);
|
int min = findMinMax(1);
|
||||||
int max = findMinMax(2);
|
int max = findMinMax(2);
|
||||||
@@ -264,51 +225,9 @@ public class Timeline extends JPanel
|
|||||||
double bottom = this.getWidth() / minmax;
|
double bottom = this.getWidth() / minmax;
|
||||||
double all = posx / bottom;
|
double all = posx / bottom;
|
||||||
double endTime = all + min + calcLengthOfStagePanel(imageWidth);
|
double endTime = all + min + calcLengthOfStagePanel(imageWidth);
|
||||||
// System.out.println("ETPH: " + this.getWidth());
|
// System.out.println(calcLengthOfStagePanel(imageWidth));
|
||||||
return (int)endTime / 60;
|
// System.out.println(endTime);
|
||||||
}
|
return (int)endTime;
|
||||||
|
|
||||||
public int calcEndTimeOfStagePanelMinutes(double posx, double 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("ETPM: " + this.getWidth());
|
|
||||||
return (int)endTime % 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int minutesToHours(int minutes)
|
|
||||||
{
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int intToTime(int time, String option)
|
|
||||||
{
|
|
||||||
if(option == "hours")
|
|
||||||
{
|
|
||||||
time = time % 24;
|
|
||||||
}
|
|
||||||
else if(option == "minutes")
|
|
||||||
{
|
|
||||||
time = time % 60;
|
|
||||||
}
|
|
||||||
// System.out.println(time);
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int toHours(int minutesTot)
|
|
||||||
{
|
|
||||||
int hours = minutesTot / 60;
|
|
||||||
int minutes = minutesTot % 60;
|
|
||||||
int finaltime;
|
|
||||||
|
|
||||||
finaltime = hours * 100 + minutes;
|
|
||||||
|
|
||||||
return finaltime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findMinMax(int i)
|
public int findMinMax(int i)
|
||||||
@@ -316,27 +235,27 @@ public class Timeline extends JPanel
|
|||||||
// Event oldevent = new Event(0, 0, null, "Base", 0);
|
// Event oldevent = new Event(0, 0, null, "Base", 0);
|
||||||
// ArrayList<Event> oldevents = new ArrayList<Event>();
|
// ArrayList<Event> oldevents = new ArrayList<Event>();
|
||||||
// oldevents.add(oldevent);
|
// oldevents.add(oldevent);
|
||||||
// Steage oldstage = new Stage(oldevents,0,null, 0, 0);
|
// Stage oldstage = new Stage(oldevents,0,null, 0, 0);
|
||||||
ArrayList<Event> eventscopy = (ArrayList<Event>) events.clone();
|
ArrayList<Stage> stagescopy = (ArrayList<Stage>) stages.clone();
|
||||||
|
|
||||||
Integer earliestStartTime = null;
|
Integer earliestStartTime = null;
|
||||||
Integer lastEndTime = null;
|
Integer lastEndTime = null;
|
||||||
|
|
||||||
for(Event event : eventscopy)
|
for(Stage stage : stagescopy)
|
||||||
{
|
{
|
||||||
if(i == 1)
|
if(i == 1)
|
||||||
{
|
{
|
||||||
if(earliestStartTime == null)
|
if(earliestStartTime == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
earliestStartTime = event.getStartTime();
|
earliestStartTime = stage.getStartTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(event.getStartTime() < earliestStartTime)
|
if(stage.getStartTime() < earliestStartTime)
|
||||||
{
|
{
|
||||||
earliestStartTime = event.getStartTime();
|
earliestStartTime = stage.getStartTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -344,13 +263,13 @@ public class Timeline extends JPanel
|
|||||||
{
|
{
|
||||||
if(lastEndTime == null)
|
if(lastEndTime == null)
|
||||||
{
|
{
|
||||||
lastEndTime = event.getEndTime();
|
lastEndTime = stage.getEndTime();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(event.getEndTime() > lastEndTime)
|
if(stage.getEndTime() > lastEndTime)
|
||||||
{
|
{
|
||||||
lastEndTime = event.getEndTime();
|
lastEndTime = stage.getEndTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -377,7 +296,7 @@ public class Timeline extends JPanel
|
|||||||
JPanel topPanel = new JPanel(new FlowLayout());
|
JPanel topPanel = new JPanel(new FlowLayout());
|
||||||
for(int i = 0; i <= this.getWidth() / 10; i++)
|
for(int i = 0; i <= this.getWidth() / 10; i++)
|
||||||
{
|
{
|
||||||
ImageIcon topImageIcon = new ImageIcon("src/sprites/block.png");
|
ImageIcon topImageIcon = new ImageIcon("src/test2.png");
|
||||||
JLabel topImage = new JLabel(topImageIcon);
|
JLabel topImage = new JLabel(topImageIcon);
|
||||||
topPanel.add(topImage);
|
topPanel.add(topImage);
|
||||||
}
|
}
|
||||||
@@ -385,9 +304,9 @@ public class Timeline extends JPanel
|
|||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||||
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
||||||
panel.add(new JLabel(Integer.toString(toHours(findMinMax(1)))));
|
panel.add(new JLabel(Integer.toString(findMinMax(1))));
|
||||||
panel.add(Box.createHorizontalGlue());
|
panel.add(Box.createHorizontalGlue());
|
||||||
panel.add(new JLabel(Integer.toString(toHours(findMinMax(2)))));
|
panel.add(new JLabel(Integer.toString(findMinMax(2))));
|
||||||
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
||||||
topPane.add(panel);
|
topPane.add(panel);
|
||||||
topPane.add(topPanel);
|
topPane.add(topPanel);
|
||||||
@@ -397,20 +316,12 @@ public class Timeline extends JPanel
|
|||||||
|
|
||||||
public JPanel createWestPanel()
|
public JPanel createWestPanel()
|
||||||
{
|
{
|
||||||
this.setSize(frame.getWidth(), frame.getHeight());
|
|
||||||
JPanel westPanel = new JPanel();
|
JPanel westPanel = new JPanel();
|
||||||
westPanel.setLayout(new BoxLayout(westPanel, BoxLayout.Y_AXIS));
|
westPanel.setLayout(new BoxLayout(westPanel, BoxLayout.Y_AXIS));
|
||||||
westPanel.add(Box.createRigidArea(new Dimension(0, 100)));
|
westPanel.add(Box.createRigidArea(new Dimension(0, 100)));
|
||||||
// for(int i = 0; i < events.size(); i++)
|
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 )));
|
|
||||||
// }
|
|
||||||
for(Event event : events)
|
|
||||||
{
|
{
|
||||||
JLabel stageText = new JLabel(event.getStage().getName() + ": " + " ");
|
JLabel stageText = new JLabel("Stage: " + (i+1) + " ");
|
||||||
|
|
||||||
westPanel.add(stageText);
|
westPanel.add(stageText);
|
||||||
westPanel.add(Box.createRigidArea(new Dimension(0, 30 )));
|
westPanel.add(Box.createRigidArea(new Dimension(0, 30 )));
|
||||||
}
|
}
|
||||||
@@ -420,36 +331,28 @@ public class Timeline extends JPanel
|
|||||||
|
|
||||||
private void genStages()
|
private void genStages()
|
||||||
{
|
{
|
||||||
// ImageIcon image = new ImageIcon();
|
ImageIcon image = new ImageIcon();
|
||||||
// Artist artist2 = new Artist("Henk", "paul2", "kaas", image, 2);
|
Artist artist2 = new Artist("Henk", "paul2", "kaas", image, 2);
|
||||||
// Artist artist1 = new Artist("Kaas", "Paul", "Lala", image, 1);
|
Artist artist1 = new Artist("Kaas", "Paul", "Lala", image, 1);
|
||||||
// Event event2 = new Event(1900, 2000, artist2, "hi2", 2);
|
Event event2 = new Event(1900, 2000, artist2, "hi2", 2);
|
||||||
// Event event1 = new Event(600, 1800, artist1, "hi", 1);
|
Event event1 = new Event(600, 1800, artist1, "hi", 1);
|
||||||
// ArrayList<Event> performances = new ArrayList<Event>();
|
ArrayList<Event> performances = new ArrayList<Event>();
|
||||||
// performances.add(event1);
|
performances.add(event1);
|
||||||
// performances.add(event2);
|
performances.add(event2);
|
||||||
// Stage stage1 = new Stage(performances, 100, null, 1800, 2100);
|
Stage stage1 = new Stage(performances, 100, null, 1800, 2100);
|
||||||
// events.add(stage1);
|
stages.add(stage1);
|
||||||
// Stage stage2 = new Stage(performances, 100, null, 1700, 1900);
|
Stage stage2 = new Stage(performances, 100, null, 1700, 1900);
|
||||||
// Stage stage3 = new Stage(performances, 100, null, 1600, 1800);
|
Stage stage3 = new Stage(performances, 100, null, 1600, 1800);
|
||||||
// Stage stage4 = new Stage(performances, 100, null, 1600, 2100);
|
Stage stage4 = new Stage(performances, 100, null, 1600, 2100);
|
||||||
// events.add(stage3);
|
stages.add(stage3);
|
||||||
// events.add(stage2);
|
stages.add(stage2);
|
||||||
//// stages.add(stage4);
|
// stages.add(stage4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createNull()
|
|
||||||
{
|
|
||||||
this.removeAll();
|
|
||||||
this.add(new JLabel("No events for this day"));
|
|
||||||
this.revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public JPanel getTimeline()
|
public JPanel getTimeline()
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-50
@@ -1,14 +1,11 @@
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
|
||||||
public class TimelinePanel extends JPanel implements Panel {
|
public class TimelinePanel extends JPanel {
|
||||||
|
|
||||||
private Timeline timeline;
|
private Timeline timeline;
|
||||||
// private WestPanel westPanel;
|
|
||||||
|
|
||||||
public TimelinePanel()
|
public TimelinePanel()
|
||||||
{
|
{
|
||||||
@@ -17,57 +14,13 @@ public class TimelinePanel extends JPanel implements Panel {
|
|||||||
this.setSize(600, 600);
|
this.setSize(600, 600);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
timeline = new Timeline(this);
|
timeline = new Timeline(this);
|
||||||
// westPanel = new WestPanel();
|
this.add(timeline,BorderLayout.CENTER);
|
||||||
// this.add(timeline.createMainPanel(),BorderLayout.CENTER);
|
this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
||||||
// this.add(new JButton());
|
|
||||||
// this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh()
|
public void refresh()
|
||||||
{
|
{
|
||||||
this.removeAll();
|
|
||||||
timeline.refresh();
|
timeline.refresh();
|
||||||
// westPanel.refresh();
|
|
||||||
this.add(timeline,BorderLayout.CENTER);
|
|
||||||
this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
|
||||||
this.revalidate();
|
|
||||||
// timeline.refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(ArrayList<Event> events)
|
|
||||||
{
|
|
||||||
timeline.setEvents(events);
|
|
||||||
// System.out.println(events.size());
|
|
||||||
// westPanel.setEvents(events);
|
|
||||||
// refresh();
|
|
||||||
// this.add(timeline.createMainPanel(),BorderLayout.CENTER);
|
|
||||||
// this.add(new JButton());
|
|
||||||
// this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
|
||||||
|
|
||||||
//dit fixt het half
|
|
||||||
if(events.size() != 0)
|
|
||||||
{
|
|
||||||
this.removeAll();
|
|
||||||
timeline.refresh();
|
|
||||||
this.add(timeline.createWestPanel(),BorderLayout.WEST);
|
|
||||||
this.add(timeline, BorderLayout.CENTER);
|
|
||||||
this.revalidate();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.removeAll();
|
|
||||||
timeline.createNull();
|
|
||||||
this.add(timeline);
|
|
||||||
this.revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public TimelinePanel getTimelinePanel()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-232
@@ -1,232 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
|
||||||
|
|
||||||
public class Window extends JFrame {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 9023061329829975662L;
|
|
||||||
private static HashMap<String, Panel> panels = new HashMap<String, Panel>();
|
|
||||||
private static JPanel centerPanel;
|
|
||||||
private static GregorianCalendar date;
|
|
||||||
private static Agenda agenda;
|
|
||||||
private static String currentPanel = "table";
|
|
||||||
|
|
||||||
public Window()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Initialize window
|
|
||||||
*/
|
|
||||||
super("Agenda");
|
|
||||||
agenda = new Agenda();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
|
||||||
addWindowListener(new WindowAdapter() {
|
|
||||||
public void windowClosing(WindowEvent evt) {
|
|
||||||
onExit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setSize(1200, 800);
|
|
||||||
|
|
||||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
|
||||||
setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
|
|
||||||
|
|
||||||
try {
|
|
||||||
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
|
||||||
} catch (ClassNotFoundException | InstantiationException
|
|
||||||
| IllegalAccessException | UnsupportedLookAndFeelException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
setJMenuBar(new MenuBar(this));
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create Panels
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Agenda Panels
|
|
||||||
Panel tablePanel = new PanelTable();
|
|
||||||
panels.put("table", tablePanel);
|
|
||||||
|
|
||||||
Panel art_staPanel = new PanelArtSta(this);
|
|
||||||
panels.put("art_sta", art_staPanel);
|
|
||||||
|
|
||||||
Panel timeline = new TimelinePanel();
|
|
||||||
panels.put("timeline", timeline);
|
|
||||||
|
|
||||||
//Main Panels
|
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
|
||||||
centerPanel = new JPanel(new BorderLayout());
|
|
||||||
centerPanel.setBackground(Color.WHITE);
|
|
||||||
JPanel bottomPanel = new JPanel();
|
|
||||||
bottomPanel.setBackground(Color.DARK_GRAY);
|
|
||||||
|
|
||||||
date = new GregorianCalendar();
|
|
||||||
SimpleDateFormat formatter=new SimpleDateFormat("dd-MM-yyyy");
|
|
||||||
JLabel dateLabel = new JLabel(formatter.format(date.getTime()));
|
|
||||||
dateLabel.setForeground(Color.WHITE);
|
|
||||||
bottomPanel.add(dateLabel);
|
|
||||||
|
|
||||||
JButton backWeekButton = new JButton("<<");
|
|
||||||
backWeekButton.setToolTipText("Go one week back");
|
|
||||||
backWeekButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
date.set(GregorianCalendar.DAY_OF_MONTH, date.get(GregorianCalendar.DAY_OF_MONTH) - 7);
|
|
||||||
dateLabel.setText(formatter.format(date.getTime()));
|
|
||||||
changePanel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
|
||||||
bottomPanel.add(backWeekButton);
|
|
||||||
|
|
||||||
JButton backDayButton = new JButton("<");
|
|
||||||
backDayButton.setToolTipText("Go one day back");
|
|
||||||
backDayButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
date.set(GregorianCalendar.DAY_OF_MONTH, date.get(GregorianCalendar.DAY_OF_MONTH) - 1);
|
|
||||||
dateLabel.setText(formatter.format(date.getTime()));
|
|
||||||
changePanel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
|
||||||
bottomPanel.add(backDayButton);
|
|
||||||
|
|
||||||
JButton todayButton = new JButton("||");
|
|
||||||
todayButton.setToolTipText("Go to today");
|
|
||||||
todayButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
date = new GregorianCalendar();
|
|
||||||
dateLabel.setText(formatter.format(date.getTime()));
|
|
||||||
changePanel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
|
||||||
bottomPanel.add(todayButton);
|
|
||||||
|
|
||||||
JButton forwardDayButton = new JButton(">");
|
|
||||||
forwardDayButton.setToolTipText("Go one day forward");
|
|
||||||
forwardDayButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
date.set(GregorianCalendar.DAY_OF_MONTH, date.get(GregorianCalendar.DAY_OF_MONTH) + 1);
|
|
||||||
dateLabel.setText(formatter.format(date.getTime()));
|
|
||||||
changePanel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
|
||||||
bottomPanel.add(forwardDayButton);
|
|
||||||
|
|
||||||
JButton forwardWeekButton = new JButton(">>");
|
|
||||||
forwardWeekButton.setToolTipText("Go one week forward");
|
|
||||||
forwardWeekButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
date.set(GregorianCalendar.DAY_OF_MONTH, date.get(GregorianCalendar.DAY_OF_MONTH) + 7);
|
|
||||||
dateLabel.setText(formatter.format(date.getTime()));
|
|
||||||
changePanel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
|
||||||
bottomPanel.add(forwardWeekButton);
|
|
||||||
|
|
||||||
//Add panels
|
|
||||||
mainPanel.add(centerPanel, BorderLayout.CENTER);
|
|
||||||
mainPanel.add(bottomPanel, BorderLayout.SOUTH);
|
|
||||||
|
|
||||||
setContentPane(mainPanel);
|
|
||||||
|
|
||||||
changePanel();
|
|
||||||
|
|
||||||
//Show window
|
|
||||||
setVisible(true);
|
|
||||||
this.getRootPane().addComponentListener(new ComponentAdapter()
|
|
||||||
{
|
|
||||||
public void componentResized(ComponentEvent e) {
|
|
||||||
TimelinePanel tempTimeLine = (TimelinePanel) timeline;
|
|
||||||
tempTimeLine.refresh();
|
|
||||||
// System.out.println("WINDOWS: " + tempframe.getWidth());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updatePanel(String panel)
|
|
||||||
{
|
|
||||||
currentPanel = panel;
|
|
||||||
changePanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void changePanel()
|
|
||||||
{
|
|
||||||
centerPanel.removeAll();
|
|
||||||
Panel p = panels.get(currentPanel);
|
|
||||||
p.update(getEvents());
|
|
||||||
JPanel p1 = (JPanel) p;
|
|
||||||
p1.setPreferredSize(centerPanel.getSize());
|
|
||||||
centerPanel.add(p1, BorderLayout.CENTER);
|
|
||||||
centerPanel.revalidate();
|
|
||||||
centerPanel.repaint();
|
|
||||||
p1.repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onExit() {
|
|
||||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to close this program?", "Close Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
|
||||||
{
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<Event> getEvents()
|
|
||||||
{
|
|
||||||
ArrayList<Event> events = new ArrayList<Event>();
|
|
||||||
for(Event e : agenda.getEvents())
|
|
||||||
{
|
|
||||||
if(DateUtils.isSameDay(e.getStartDate(), date) || DateUtils.isSameDay(e.getEndDate(), date))
|
|
||||||
{
|
|
||||||
events.add(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Agenda getAgenda()
|
|
||||||
{
|
|
||||||
return agenda;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAgenda(Agenda a)
|
|
||||||
{
|
|
||||||
agenda = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 197 B |
|
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 155 B |
Reference in New Issue
Block a user