Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c6b2b44e4 | ||
|
|
18726278a5 | ||
|
|
7195152f7f | ||
|
|
81b49bc905 | ||
|
|
be35fd46e4 | ||
|
|
4e844bcd3b | ||
|
|
9a09338818 | ||
|
|
e8490956dd | ||
|
|
e0b9c991c8 | ||
|
|
056a8b36d1 | ||
|
|
677e9a7c43 | ||
|
|
a0d37e1039 | ||
|
|
9de7409bac | ||
|
|
c225c23d66 | ||
|
|
08b63eb2ec | ||
|
|
172b9a3470 | ||
|
|
26e31ed1c6 | ||
|
|
e8079862f4 |
+11
@@ -42,6 +42,14 @@ public class Agenda implements Serializable {
|
|||||||
{
|
{
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
public ArrayList<Artist> getArtists()
|
||||||
|
{
|
||||||
|
return artists;
|
||||||
|
}
|
||||||
|
public ArrayList<Stage> getStages()
|
||||||
|
{
|
||||||
|
return stages;
|
||||||
|
}
|
||||||
|
|
||||||
public void saveAgenda()
|
public void saveAgenda()
|
||||||
{
|
{
|
||||||
@@ -118,7 +126,9 @@ public class Agenda implements Serializable {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
clearAgenda();
|
||||||
fillAgenda(file);
|
fillAgenda(file);
|
||||||
|
JOptionPane.showMessageDialog(null, "Loaded succesfully");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,6 +202,7 @@ public class Agenda implements Serializable {
|
|||||||
oos.writeObject(event);
|
oos.writeObject(event);
|
||||||
}
|
}
|
||||||
oos.close();
|
oos.close();
|
||||||
|
JOptionPane.showMessageDialog(null, "Saved succesfully");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-1
@@ -11,12 +11,14 @@ public class Artist implements Serializable{
|
|||||||
private String genre;
|
private String genre;
|
||||||
private ImageIcon image;
|
private ImageIcon image;
|
||||||
private String description;
|
private String description;
|
||||||
|
private String background;
|
||||||
|
|
||||||
public Artist(String name, String genre, String image, String description)
|
public Artist(String name, String genre, String image, String description, String background)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.genre = genre;
|
this.genre = genre;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.background = background;
|
||||||
|
|
||||||
if ( !image.equals("null")) {
|
if ( !image.equals("null")) {
|
||||||
this.image = new ImageIcon(image);
|
this.image = new ImageIcon(image);
|
||||||
@@ -43,6 +45,11 @@ public class Artist implements Serializable{
|
|||||||
return this.description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBackground()
|
||||||
|
{
|
||||||
|
return this.background;
|
||||||
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -67,4 +74,14 @@ public class Artist implements Serializable{
|
|||||||
{
|
{
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBackground(String background)
|
||||||
|
{
|
||||||
|
this.background = background;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+66
@@ -1,6 +1,8 @@
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.text.Format;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
public class Event implements Serializable {
|
public class Event implements Serializable {
|
||||||
@@ -112,6 +114,70 @@ public class Event implements Serializable {
|
|||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLength()
|
||||||
|
{
|
||||||
|
return getEndTime() - getStartTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStartTime()
|
||||||
|
{
|
||||||
|
DateFormat format = new SimpleDateFormat("kkmm");
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
DateFormat format = new SimpleDateFormat("kkmm");
|
||||||
|
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() {
|
public String toString() {
|
||||||
DateFormat format = new SimpleDateFormat("dd-MM-yyyy");
|
DateFormat format = new SimpleDateFormat("dd-MM-yyyy");
|
||||||
format.setLenient(false);
|
format.setLenient(false);
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,9 +9,9 @@ public class Main {
|
|||||||
Window w = new Window();
|
Window w = new Window();
|
||||||
Agenda agn = w.getAgenda();
|
Agenda agn = w.getAgenda();
|
||||||
|
|
||||||
Artist a1 = new Artist("Coldplay", "Alternative Rock", "null", "A band");
|
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");
|
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");
|
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 s1 = new Stage("Rock Stage", "Stage for Rock and Alternative Rock concerts");
|
||||||
Stage s2 = new Stage("Rap Stage", "Stage for Rap concerts");
|
Stage s2 = new Stage("Rap Stage", "Stage for Rap concerts");
|
||||||
|
|
||||||
@@ -19,14 +19,23 @@ public class Main {
|
|||||||
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 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 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 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(e1);
|
||||||
agn.addEvent(e2);
|
agn.addEvent(e2);
|
||||||
agn.addEvent(e3);
|
agn.addEvent(e3);
|
||||||
agn.addEvent(e4);
|
agn.addEvent(e4);
|
||||||
|
agn.addEvent(e5);
|
||||||
|
agn.addEvent(e6);
|
||||||
|
agn.addEvent(e7);
|
||||||
|
agn.addEvent(e8);
|
||||||
|
|
||||||
agn.fillArtists();
|
agn.fillArtists();
|
||||||
agn.fillStages();
|
agn.fillStages();
|
||||||
|
w.updatePanel("timeline");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-1
@@ -5,6 +5,7 @@ import java.awt.event.KeyEvent;
|
|||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuBar;
|
import javax.swing.JMenuBar;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
|
|
||||||
@@ -30,11 +31,35 @@ public class MenuBar extends JMenuBar {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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");
|
JMenuItem open = new JMenuItem("Open");
|
||||||
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
w.getAgenda().loadAgenda();
|
w.getAgenda().loadAgenda();
|
||||||
|
Window.updatePanel("table");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -43,17 +68,25 @@ public class MenuBar extends JMenuBar {
|
|||||||
save.addActionListener(new ActionListener() {
|
save.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
w.getAgenda().saveAgenda();
|
w.getAgenda().saveAgenda();
|
||||||
|
Window.updatePanel("table");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JMenuItem exit = new JMenuItem("Exit");
|
JMenuItem exit = new JMenuItem("Exit");
|
||||||
exit.addActionListener(new ActionListener() {
|
exit.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
System.exit(0);
|
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(newEvent);
|
||||||
|
file.add(newArtist);
|
||||||
|
file.add(newStage);
|
||||||
|
file.addSeparator();
|
||||||
|
file.add(newAgenda);
|
||||||
file.addSeparator();
|
file.addSeparator();
|
||||||
file.add(open);
|
file.add(open);
|
||||||
file.add(save);
|
file.add(save);
|
||||||
@@ -82,8 +115,16 @@ public class MenuBar extends JMenuBar {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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(timeline);
|
||||||
view.add(table);
|
view.add(table);
|
||||||
|
view.add(art_sta);
|
||||||
add(view);
|
add(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-13
@@ -138,13 +138,8 @@ public class PanelTable extends JPanel implements Panel{
|
|||||||
* @param row
|
* @param row
|
||||||
*/
|
*/
|
||||||
private void openEventDialog(int row) {
|
private void openEventDialog(int row) {
|
||||||
JFrame frame = new JFrame();
|
|
||||||
Event event = events.get(row);
|
Event event = events.get(row);
|
||||||
//the dialog
|
new TabbedPane(event, true);
|
||||||
frame.pack();
|
|
||||||
frame.setSize(300, 200);
|
|
||||||
frame.setLocationRelativeTo(this);
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,13 +147,8 @@ public class PanelTable extends JPanel implements Panel{
|
|||||||
* @param row
|
* @param row
|
||||||
*/
|
*/
|
||||||
private void openArtistDialog(int row) {
|
private void openArtistDialog(int row) {
|
||||||
JFrame frame = new JFrame();
|
Event event = events.get(row);
|
||||||
Artist artist = events.get(row).getArtist();
|
new TabbedPane(event, false);
|
||||||
//the dialog
|
|
||||||
frame.pack();
|
|
||||||
frame.setSize(300, 200);
|
|
||||||
frame.setLocationRelativeTo(this);
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,4 +32,9 @@ public class Stage implements Serializable {
|
|||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
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 double widthD, posXD;
|
||||||
|
private Event event;
|
||||||
|
public StagePanel(int width, int height, int posX, Event event, double widthD, double posXD)
|
||||||
|
{
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.posX = posX;
|
||||||
|
this.event = event;
|
||||||
|
this.widthD = widthD;
|
||||||
|
this.posXD = posXD;
|
||||||
|
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, double posXD)
|
||||||
|
{
|
||||||
|
this.posX = posx;
|
||||||
|
this.posXD = posXD;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StagePanel(LayoutManager arg0, boolean arg1)
|
||||||
|
{
|
||||||
|
super(arg0, arg1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPosX()
|
||||||
|
{
|
||||||
|
return this.posXD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(int length, double widthD)
|
||||||
|
{
|
||||||
|
this.width = length;
|
||||||
|
this.widthD = widthD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStageStartTime(int hours, int minutes)
|
||||||
|
{
|
||||||
|
event.setStartTime(hours, minutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStageEndTime(int hours, int minutes)
|
||||||
|
{
|
||||||
|
event.setEndTime(hours, minutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStageStartTime()
|
||||||
|
{
|
||||||
|
return event.getStartTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getImageWidth()
|
||||||
|
{
|
||||||
|
return this.widthD;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
//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"
|
||||||
+455
@@ -0,0 +1,455 @@
|
|||||||
|
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 java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
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<Event> events = new ArrayList<Event>();
|
||||||
|
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 setEvents(ArrayList<Event> events)
|
||||||
|
{
|
||||||
|
this.events = events;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh()
|
||||||
|
{
|
||||||
|
this.removeAll();
|
||||||
|
createMainPanel();
|
||||||
|
this.revalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel createMainPanel()
|
||||||
|
{
|
||||||
|
// this.setSize(frame.getWidth(), frame.getHeight());
|
||||||
|
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(), this.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);
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
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(Event event : events)
|
||||||
|
{
|
||||||
|
StagePanel stagepanel = new StagePanel((int)calcLengthOfStage(event.getLength()), 30, (int)calcPositionOfStage(event.getStartTime()), event,calcLengthOfStage(event.getLength()),calcPositionOfStage(event.getStartTime()));
|
||||||
|
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) {
|
||||||
|
int value = (int)(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(Box.createRigidArea(new Dimension(0,15)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// this.add(centerPanel, BorderLayout.CENTER);
|
||||||
|
return centerPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resizeTimeline(StagePanel stagepanel)
|
||||||
|
{
|
||||||
|
// System.out.println(stagepanel.getStageStartTime());
|
||||||
|
// System.out.println(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||||
|
stagepanel.setStageStartTime(calcStartTimeOfStagePanelHours(stagepanel.getPosX()),calcStartTimeOfStagePanelMinutes(stagepanel.getPosX()));
|
||||||
|
stagepanel.setStageEndTime(calcEndTimeOfStagePanelHours(stagepanel.getPosX(), stagepanel.getImageWidth()),calcEndTimeOfStagePanelMinutes(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
||||||
|
// stagepanel.setLength(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
||||||
|
// System.out.println("HOURS: " + calcEndTimeOfStagePanelHours(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
||||||
|
// System.out.println("MINUTES: " + calcEndTimeOfStagePanelMinutes(stagepanel.getPosX(), stagepanel.getImageWidth()) );
|
||||||
|
// TimelinePanel tempPanel = (TimelinePanel) frame;
|
||||||
|
// tempPanel.refresh();
|
||||||
|
refresh();
|
||||||
|
// System.out.println(stagepanel.getPosX());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double calcLengthOfStage(double length)
|
||||||
|
{
|
||||||
|
double lengthOfStage = 0;
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
|
||||||
|
double frameWidth = this.getWidth();
|
||||||
|
double minmax = max-min;
|
||||||
|
double pixelsPerLength = frameWidth / minmax;
|
||||||
|
lengthOfStage = pixelsPerLength * (double)length;
|
||||||
|
// System.out.println("LengthOfStage: " + 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)
|
||||||
|
{
|
||||||
|
double lengthOfStagePanel = 0;
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
// System.out.println(length);
|
||||||
|
double frameWidth = this.getWidth();
|
||||||
|
double minmax = max-min;
|
||||||
|
double pixelsPerLength = frameWidth / minmax;
|
||||||
|
// System.out.println(pixelsPerLength);
|
||||||
|
lengthOfStagePanel = (double)length / pixelsPerLength;
|
||||||
|
// System.out.println(lengthOfStagePanel);
|
||||||
|
|
||||||
|
|
||||||
|
// System.out.println("LengthOfStagePane: " + (int)lengthOfStagePanel);
|
||||||
|
|
||||||
|
return lengthOfStagePanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double calcPositionOfStage(int startTime)
|
||||||
|
{
|
||||||
|
double posx;
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
double minmax = max-min;
|
||||||
|
posx = startTime - min;
|
||||||
|
posx = posx * this.getWidth() / minmax;
|
||||||
|
// 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 calcStartTimeOfStagePanelHours(double 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 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("STPM: " + this.getWidth());
|
||||||
|
|
||||||
|
return ((int)startTime % 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calcEndTimeOfStagePanelHours(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("ETPH: " + this.getWidth());
|
||||||
|
return (int)endTime / 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// Event oldevent = new Event(0, 0, null, "Base", 0);
|
||||||
|
// ArrayList<Event> oldevents = new ArrayList<Event>();
|
||||||
|
// oldevents.add(oldevent);
|
||||||
|
// Steage oldstage = new Stage(oldevents,0,null, 0, 0);
|
||||||
|
ArrayList<Event> eventscopy = (ArrayList<Event>) events.clone();
|
||||||
|
|
||||||
|
Integer earliestStartTime = null;
|
||||||
|
Integer lastEndTime = null;
|
||||||
|
|
||||||
|
for(Event event : eventscopy)
|
||||||
|
{
|
||||||
|
if(i == 1)
|
||||||
|
{
|
||||||
|
if(earliestStartTime == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
earliestStartTime = event.getStartTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(event.getStartTime() < earliestStartTime)
|
||||||
|
{
|
||||||
|
earliestStartTime = event.getStartTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( i == 2)
|
||||||
|
{
|
||||||
|
if(lastEndTime == null)
|
||||||
|
{
|
||||||
|
lastEndTime = event.getEndTime();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(event.getEndTime() > lastEndTime)
|
||||||
|
{
|
||||||
|
lastEndTime = event.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/sprites/block.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(toHours(findMinMax(1)))));
|
||||||
|
panel.add(Box.createHorizontalGlue());
|
||||||
|
panel.add(new JLabel(Integer.toString(toHours(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()
|
||||||
|
{
|
||||||
|
this.setSize(frame.getWidth(), frame.getHeight());
|
||||||
|
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 < events.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() + ": " + " ");
|
||||||
|
|
||||||
|
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);
|
||||||
|
// events.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);
|
||||||
|
// events.add(stage3);
|
||||||
|
// events.add(stage2);
|
||||||
|
//// stages.add(stage4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createNull()
|
||||||
|
{
|
||||||
|
this.removeAll();
|
||||||
|
this.add(new JLabel("No events for this day"));
|
||||||
|
this.revalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel getTimeline()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
|
||||||
|
public class TimelinePanel extends JPanel implements Panel {
|
||||||
|
|
||||||
|
private Timeline timeline;
|
||||||
|
// private WestPanel westPanel;
|
||||||
|
|
||||||
|
public TimelinePanel()
|
||||||
|
{
|
||||||
|
super(new BorderLayout());
|
||||||
|
|
||||||
|
this.setSize(600, 600);
|
||||||
|
this.setVisible(true);
|
||||||
|
timeline = new Timeline(this);
|
||||||
|
// westPanel = new WestPanel();
|
||||||
|
// this.add(timeline.createMainPanel(),BorderLayout.CENTER);
|
||||||
|
// this.add(new JButton());
|
||||||
|
// this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh()
|
||||||
|
{
|
||||||
|
this.removeAll();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+23
-4
@@ -7,6 +7,8 @@ import java.awt.FlowLayout;
|
|||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -72,6 +74,12 @@ public class Window extends JFrame {
|
|||||||
Panel tablePanel = new PanelTable();
|
Panel tablePanel = new PanelTable();
|
||||||
panels.put("table", tablePanel);
|
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
|
//Main Panels
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
centerPanel = new JPanel(new BorderLayout());
|
centerPanel = new JPanel(new BorderLayout());
|
||||||
@@ -160,6 +168,14 @@ public class Window extends JFrame {
|
|||||||
|
|
||||||
//Show window
|
//Show window
|
||||||
setVisible(true);
|
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)
|
public static void updatePanel(String panel)
|
||||||
@@ -170,15 +186,13 @@ public class Window extends JFrame {
|
|||||||
|
|
||||||
private static void changePanel()
|
private static void changePanel()
|
||||||
{
|
{
|
||||||
if(centerPanel.getComponents().length > 0)
|
centerPanel.removeAll();
|
||||||
{
|
|
||||||
centerPanel.remove(0);
|
|
||||||
}
|
|
||||||
Panel p = panels.get(currentPanel);
|
Panel p = panels.get(currentPanel);
|
||||||
p.update(getEvents());
|
p.update(getEvents());
|
||||||
JPanel p1 = (JPanel) p;
|
JPanel p1 = (JPanel) p;
|
||||||
p1.setPreferredSize(centerPanel.getSize());
|
p1.setPreferredSize(centerPanel.getSize());
|
||||||
centerPanel.add(p1, BorderLayout.CENTER);
|
centerPanel.add(p1, BorderLayout.CENTER);
|
||||||
|
centerPanel.revalidate();
|
||||||
centerPanel.repaint();
|
centerPanel.repaint();
|
||||||
p1.repaint();
|
p1.repaint();
|
||||||
}
|
}
|
||||||
@@ -209,5 +223,10 @@ public class Window extends JFrame {
|
|||||||
return agenda;
|
return agenda;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAgenda(Agenda a)
|
||||||
|
{
|
||||||
|
agenda = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 155 B |
Reference in New Issue
Block a user