Compare commits
56
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
604fc9491a | ||
|
|
9ff8c50309 | ||
|
|
53195bfc7f | ||
|
|
fb224081cc | ||
|
|
21d17eadd2 | ||
|
|
d769129415 | ||
|
|
285de27ba9 | ||
|
|
0ce2e7e6e9 | ||
|
|
2a10e0846d | ||
|
|
0e5a2ccb61 | ||
|
|
692e63f25c | ||
|
|
ddd9435e4f | ||
|
|
2e4e763ef7 | ||
|
|
3dafa12ba8 | ||
|
|
a15ecc78c0 | ||
|
|
d0b6bcdd74 | ||
|
|
29063703f6 | ||
|
|
4fe2761ab1 | ||
|
|
46be84245b | ||
|
|
755941598e | ||
|
|
54fe904cad | ||
|
|
b530a47a95 | ||
|
|
dc4a87a4b3 | ||
|
|
8f5ef939f6 | ||
|
|
e2b140f780 | ||
|
|
302703f6ea | ||
|
|
7fcab5a2a6 | ||
|
|
3764de4a8f | ||
|
|
8d4ffa48f1 | ||
|
|
70ac0560b1 | ||
|
|
a35af42dcf | ||
|
|
46829eff10 | ||
|
|
73493d1faa | ||
|
|
7ab04656b6 | ||
|
|
68c7392f2d | ||
|
|
b566007b77 | ||
|
|
a1520cf55c | ||
|
|
1ed16ab22f | ||
|
|
b5dbb8e058 | ||
|
|
ea3d16c533 | ||
|
|
f69ac37ea8 | ||
|
|
d065860c4b | ||
|
|
4e6abc1551 | ||
|
|
6d6c5cd153 | ||
|
|
63e6138e83 | ||
|
|
a0cdeb1794 | ||
|
|
c10341c403 | ||
|
|
0e78c56ad7 | ||
|
|
c232d6a01c | ||
|
|
451ae58a77 | ||
|
|
4e81a4aa30 | ||
|
|
ff5daf1da8 | ||
|
|
26d0fa1ff3 | ||
|
|
fc0539c6ab | ||
|
|
91f113e8e3 | ||
|
|
c27d44a559 |
-55
@@ -1,55 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
import nl.kennyboy.EventSorter.Mode;
|
|
||||||
|
|
||||||
public class Agenda implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -383023632433640516L;
|
|
||||||
|
|
||||||
ArrayList<Event> afspraken;
|
|
||||||
EventSorter sort;
|
|
||||||
|
|
||||||
public Agenda()
|
|
||||||
{
|
|
||||||
afspraken = new ArrayList<Event>();
|
|
||||||
sort = new EventSorter(Mode.SORT_ASC);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Event afspraak)
|
|
||||||
{
|
|
||||||
afspraken.add(afspraak);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(GregorianCalendar startDate, GregorianCalendar endDate, String name, String desc)
|
|
||||||
{
|
|
||||||
new Event(startDate, endDate, name, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, String name, String desc)
|
|
||||||
{
|
|
||||||
new Event(startYear, startMonth,startDay, endYear, endMonth, endDay, name, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sort(EventSorter.Mode mode)
|
|
||||||
{
|
|
||||||
sort.changeMode(mode);
|
|
||||||
Collections.sort(afspraken, sort);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
String str = "";
|
|
||||||
str += "All event sorted " + sort.getModeDesc() + ":\n";
|
|
||||||
for(Event asp : afspraken)
|
|
||||||
{
|
|
||||||
str += "\t" + asp + "\n";
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
|
||||||
|
public class Artist
|
||||||
|
{
|
||||||
|
private String genre;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private ImageIcon image;
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
public Artist(String genre, String name, String description, ImageIcon image, int id)
|
||||||
|
{
|
||||||
|
this.genre = genre;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.image = image;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+20
-67
@@ -1,81 +1,34 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
public class Event
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
public class Event implements Serializable, Comparable<Event>
|
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = -8412700922907201793L;
|
private int startTime;
|
||||||
|
private int endTime;
|
||||||
|
private Artist artist;
|
||||||
|
private String description;
|
||||||
|
private int id;
|
||||||
|
|
||||||
GregorianCalendar startDate;
|
public Event(int startTime, int endTime, Artist artist, String description, int id)
|
||||||
GregorianCalendar endDate;
|
|
||||||
String name;
|
|
||||||
String desc;
|
|
||||||
|
|
||||||
public Event(GregorianCalendar startDate, GregorianCalendar endDate, String name, String desc)
|
|
||||||
{
|
{
|
||||||
this.startDate = startDate;
|
this.startTime = startTime;
|
||||||
this.endDate = endDate;
|
this.endTime = endTime;
|
||||||
this.name = name;
|
this.artist = artist;
|
||||||
this.desc = desc;
|
this.description = description;
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
public Event(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, String name, String desc)
|
|
||||||
|
public Artist getArtist()
|
||||||
{
|
{
|
||||||
this(new GregorianCalendar(startYear, startMonth-1, startDay), new GregorianCalendar(endYear, endMonth-1, endDay),name, desc);
|
return artist;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Getters and Setters
|
public int getStartTime()
|
||||||
public GregorianCalendar getStartDate() {
|
|
||||||
return startDate;
|
|
||||||
}
|
|
||||||
public void setStartDate(GregorianCalendar startDate) {
|
|
||||||
this.startDate = startDate;
|
|
||||||
}
|
|
||||||
public GregorianCalendar getEndDate() {
|
|
||||||
return endDate;
|
|
||||||
}
|
|
||||||
public void setEndDate(GregorianCalendar endDate) {
|
|
||||||
this.endDate = endDate;
|
|
||||||
}
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
public String getDesc() {
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
public void setDesc(String desc) {
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo(Event o) {
|
|
||||||
if(startDate.before(o.getStartDate()))
|
|
||||||
{
|
{
|
||||||
return -1;
|
return startTime;
|
||||||
}
|
}
|
||||||
if(startDate.after(o.getStartDate()))
|
|
||||||
|
public int getID()
|
||||||
{
|
{
|
||||||
return 1;
|
return id + 10;
|
||||||
}
|
|
||||||
if(startDate.equals(o.getStartDate()))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
formatter.setLenient(false);
|
|
||||||
|
|
||||||
return name + " from " + formatter.format(startDate.getTime()) + " to " + formatter.format(endDate.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,135 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
|
|
||||||
public class EventSorter implements Serializable, Comparator<Event> {
|
|
||||||
|
|
||||||
public enum Mode {
|
|
||||||
SORT_ASC,
|
|
||||||
SORT_DESC,
|
|
||||||
SORT_LENGTH_ASC,
|
|
||||||
SORT_LENGTH_DESC
|
|
||||||
}
|
|
||||||
|
|
||||||
Mode mode;
|
|
||||||
|
|
||||||
public EventSorter(Mode mode)
|
|
||||||
{
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changeMode(Mode mode)
|
|
||||||
{
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModeDesc()
|
|
||||||
{
|
|
||||||
switch(mode)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case SORT_ASC:
|
|
||||||
return "alphabetically";
|
|
||||||
case SORT_DESC:
|
|
||||||
return "reverse alphabetically";
|
|
||||||
case SORT_LENGTH_ASC:
|
|
||||||
return "shortest first";
|
|
||||||
case SORT_LENGTH_DESC:
|
|
||||||
return "longstest first";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Event asp1, Event asp2) {
|
|
||||||
|
|
||||||
switch(mode)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case SORT_ASC:
|
|
||||||
return sortAsc(asp1, asp2);
|
|
||||||
case SORT_DESC:
|
|
||||||
return sortDesc(asp1, asp2);
|
|
||||||
case SORT_LENGTH_ASC:
|
|
||||||
return sortLenAsc(asp1, asp2);
|
|
||||||
case SORT_LENGTH_DESC:
|
|
||||||
return sortLenDesc(asp1, asp2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sortAsc(Event asp1, Event asp2)
|
|
||||||
{
|
|
||||||
if(asp1.getStartDate().before(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(asp1.getStartDate().after(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(asp1.getStartDate().equals(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sortDesc(Event asp1, Event asp2)
|
|
||||||
{
|
|
||||||
if(asp1.getStartDate().after(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(asp1.getStartDate().before(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(asp1.getStartDate().equals(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sortLenAsc(Event asp1, Event asp2)
|
|
||||||
{
|
|
||||||
long len1 = asp1.getEndDate().getTimeInMillis() - asp1.getStartDate().getTimeInMillis();
|
|
||||||
long len2 = asp2.getEndDate().getTimeInMillis() - asp2.getStartDate().getTimeInMillis();
|
|
||||||
|
|
||||||
if(len1 < len2)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(len2 < len1)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(len1 == len2)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sortLenDesc(Event asp1, Event asp2)
|
|
||||||
{
|
|
||||||
long len1 = asp1.getEndDate().getTimeInMillis() - asp1.getStartDate().getTimeInMillis();
|
|
||||||
long len2 = asp2.getEndDate().getTimeInMillis() - asp2.getStartDate().getTimeInMillis();
|
|
||||||
|
|
||||||
if(len1 > len2)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(len2 > len1)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(len1 == len2)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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,37 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import nl.kennyboy.EventSorter.Mode;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new Main();
|
|
||||||
}
|
|
||||||
|
|
||||||
Agenda agenda;
|
|
||||||
Window window;
|
|
||||||
|
|
||||||
public Main()
|
|
||||||
{
|
|
||||||
agenda = new Agenda();
|
|
||||||
window = new Window();
|
|
||||||
|
|
||||||
test();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void test()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
agenda.add(new Event(2014, 12, 1, 2014, 12, 2, "School", "Doe iets op school"));
|
|
||||||
agenda.add(new Event(2014, 11, 2, 2014, 11, 4, "School2", "Doe nog iets op school"));
|
|
||||||
agenda.sort(Mode.SORT_LENGTH_DESC);
|
|
||||||
window.setText(agenda + "");
|
|
||||||
SaveLoad.saveFile(agenda);
|
|
||||||
*/
|
|
||||||
|
|
||||||
agenda = (Agenda) SaveLoad.loadFile();
|
|
||||||
window.setText(agenda + "");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
# FestivalPlanner
|
# BELANGRIJK
|
||||||
Avans - Technische Informatica - Periode 3 - Project Festival Planner
|
De .jar file moet als externe Library toegevoegd worden.
|
||||||
|
De sprites folder moet in de root van het project.
|
||||||
|
|
||||||
##Project Leden
|
BRANCH VAN YORICK
|
||||||
* Kenneth van Ewijk
|
Ja, codemess please.
|
||||||
|
|
||||||
##Branch
|
|
||||||
Deze branch is van Kenneth van Ewijk
|
|
||||||
|
|||||||
-127
@@ -1,127 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
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 SaveLoad() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
public class Stage
|
||||||
|
{
|
||||||
|
private ArrayList<Event> performances;
|
||||||
|
private int expectedPopularity;
|
||||||
|
private String description;
|
||||||
|
private int length;
|
||||||
|
private int startTime,endTime;
|
||||||
|
|
||||||
|
public Stage(ArrayList<Event> performances, int expectedPopularity, String description, int startTime, int endTime)
|
||||||
|
{
|
||||||
|
this.performances = performances;
|
||||||
|
this.expectedPopularity = expectedPopularity;
|
||||||
|
this.description = description;
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.endTime = endTime;
|
||||||
|
this.length = endTime - startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(int startTime)
|
||||||
|
{
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(int endTime)
|
||||||
|
{
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Event> getPerformances()
|
||||||
|
{
|
||||||
|
return performances;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public int getID()
|
||||||
|
// {
|
||||||
|
// return id + 100;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public int getLength()
|
||||||
|
{
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStartTime()
|
||||||
|
{
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEndTime()
|
||||||
|
{
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.LayoutManager;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
|
||||||
|
public class StagePanel extends JPanel
|
||||||
|
{
|
||||||
|
private BufferedImage image;
|
||||||
|
private int width, height, posX;
|
||||||
|
private Stage stage;
|
||||||
|
public StagePanel(int width, int height, int posX, Stage stage)
|
||||||
|
{
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.posX = posX;
|
||||||
|
this.stage = stage;
|
||||||
|
image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
Graphics2D g2 = image.createGraphics();
|
||||||
|
g2.setColor(Color.blue);
|
||||||
|
g2.fillRect(0, 0, image.getWidth(), image.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics g)
|
||||||
|
{
|
||||||
|
super.paint(g);
|
||||||
|
((Graphics2D)g).drawImage(image, this.posX, 0, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StagePanel(LayoutManager arg0)
|
||||||
|
{
|
||||||
|
super(arg0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public StagePanel(boolean arg0)
|
||||||
|
{
|
||||||
|
super(arg0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(int posx)
|
||||||
|
{
|
||||||
|
this.posX = posx;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StagePanel(LayoutManager arg0, boolean arg1)
|
||||||
|
{
|
||||||
|
super(arg0, arg1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosX()
|
||||||
|
{
|
||||||
|
return this.posX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(int length)
|
||||||
|
{
|
||||||
|
this.width = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStageStartTime(int startTime)
|
||||||
|
{
|
||||||
|
stage.setStartTime(startTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStageEndTime(int endTime)
|
||||||
|
{
|
||||||
|
stage.setEndTime(endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStageStartTime()
|
||||||
|
{
|
||||||
|
return stage.getStartTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getImageWidth()
|
||||||
|
{
|
||||||
|
return this.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+358
@@ -0,0 +1,358 @@
|
|||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.awt.event.ComponentListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseMotionAdapter;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings({ "serial" })
|
||||||
|
public class Timeline extends JPanel
|
||||||
|
{
|
||||||
|
private ArrayList<Stage> stages = new ArrayList<Stage>();
|
||||||
|
private JPanel frame;
|
||||||
|
|
||||||
|
// Geef dit object je JFrame mee, en zet in je JFrame de volgende code:
|
||||||
|
// this.setContentPane(timeline.getTimeline());
|
||||||
|
// this.getRootPane().addComponentListener(new ComponentAdapter()
|
||||||
|
// {
|
||||||
|
// public void componentResized(ComponentEvent e) {
|
||||||
|
// timeline.refresh();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
public Timeline(JPanel frame)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.frame = frame;
|
||||||
|
|
||||||
|
genStages();
|
||||||
|
this.setSize(frame.getWidth(), frame.getHeight());
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh()
|
||||||
|
{
|
||||||
|
this.removeAll();
|
||||||
|
// createWestPanel();
|
||||||
|
createMainPanel();
|
||||||
|
this.revalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createMainPanel()
|
||||||
|
{
|
||||||
|
JPanel mainPanel = new JPanel();
|
||||||
|
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
||||||
|
Container topContainer = createTopPanel();
|
||||||
|
Dimension dim = new Dimension(this.getWidth(), 60);
|
||||||
|
topContainer.setMaximumSize(dim);
|
||||||
|
mainPanel.add(topContainer);
|
||||||
|
|
||||||
|
Dimension centerDim = new Dimension(this.getWidth(), frame.getHeight());
|
||||||
|
|
||||||
|
// Container centerContainer = createCenterPanel();
|
||||||
|
JPanel centerContainer = createCenterPanel();
|
||||||
|
centerContainer.setPreferredSize(centerDim);
|
||||||
|
|
||||||
|
centerContainer.setMaximumSize(centerDim);
|
||||||
|
System.out.println(centerDim);
|
||||||
|
mainPanel.add(centerContainer);
|
||||||
|
this.add(mainPanel, BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JPanel createCenterPanel()
|
||||||
|
{
|
||||||
|
|
||||||
|
JPanel centerPanel = new JPanel();
|
||||||
|
centerPanel.setBackground(Color.lightGray);
|
||||||
|
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
|
||||||
|
centerPanel.add(Box.createRigidArea(new Dimension(0, 30)));
|
||||||
|
|
||||||
|
for(Stage stage : stages)
|
||||||
|
{
|
||||||
|
StagePanel stagepanel = new StagePanel(calcLengthOfStage(stage.getLength()), 30, calcPositionOfStage(stage.getStartTime()), stage);
|
||||||
|
Container content = stagepanel;
|
||||||
|
content.setMaximumSize(new Dimension(this.getWidth(),30));
|
||||||
|
content.addMouseListener(new MouseListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
resizeTimeline(stagepanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
content.addMouseMotionListener(new MouseMotionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent e) {
|
||||||
|
stagepanel.update(e.getX() - stagepanel.getImageWidth() / 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
centerPanel.add(content);
|
||||||
|
centerPanel.add(Box.createRigidArea(new Dimension(0,15)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// this.add(centerPanel, BorderLayout.CENTER);
|
||||||
|
return centerPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resizeTimeline(StagePanel stagepanel)
|
||||||
|
{
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
// System.out.println(stagepanel.getStageStartTime());
|
||||||
|
// System.out.println(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||||
|
stagepanel.setStageStartTime(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||||
|
stagepanel.setStageEndTime(calcEndTimeOfStagePanel(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
||||||
|
// stagepanel.setLength(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
||||||
|
// System.out.println(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calcLengthOfStage(int length)
|
||||||
|
{
|
||||||
|
double lengthOfStage = 0;
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
|
||||||
|
double frameWidth = this.getWidth();
|
||||||
|
double pixelsPerLength = frameWidth / (max - min);
|
||||||
|
lengthOfStage = pixelsPerLength * (double)length;
|
||||||
|
// System.out.println((int)lengthOfStage);
|
||||||
|
return (int)lengthOfStage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calcLengthOfStagePanel(int length)
|
||||||
|
{
|
||||||
|
double lengthOfStagePanel = 0;
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
// System.out.println(length);
|
||||||
|
double frameWidth = this.getWidth();
|
||||||
|
double pixelsPerLength = frameWidth / (max - min);
|
||||||
|
// System.out.println(pixelsPerLength);
|
||||||
|
lengthOfStagePanel = (double)length / pixelsPerLength;
|
||||||
|
// System.out.println(lengthOfStagePanel);
|
||||||
|
|
||||||
|
return (int)lengthOfStagePanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calcPositionOfStage(int startTime)
|
||||||
|
{
|
||||||
|
int posx = 0;
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
posx = startTime - min;
|
||||||
|
posx = posx * this.getWidth() / (max-min);
|
||||||
|
// System.out.println("Frame: " + this.getWidth());
|
||||||
|
// System.out.println("startTime: " + startTime);
|
||||||
|
// System.out.println("Max: " + max + " min: " + min);
|
||||||
|
// System.out.println("Posx: " + posx);
|
||||||
|
return posx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calcStartTimeOfStagePanel(int posx)
|
||||||
|
{
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
// double startTime = (posx / (this.getWidth() / (max - min )) ) + min;
|
||||||
|
//Omdat het anders onnodig afgerond wordt, alles apart in doubles.
|
||||||
|
double minmax = max-min;
|
||||||
|
double bottom = this.getWidth() / minmax;
|
||||||
|
double all = posx / bottom;
|
||||||
|
double startTime = all + min;
|
||||||
|
|
||||||
|
|
||||||
|
// System.out.println("starttime----------------");
|
||||||
|
// System.out.println("Frame: " + this.getWidth());
|
||||||
|
// System.out.println("startTime: " + startTime);
|
||||||
|
// System.out.println("Max: " + max + " min: " + min);
|
||||||
|
// System.out.println("Posx: " + posx);
|
||||||
|
return (int)startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calcEndTimeOfStagePanel(int posx, int imageWidth)
|
||||||
|
{
|
||||||
|
int min = findMinMax(1);
|
||||||
|
int max = findMinMax(2);
|
||||||
|
//Omdat het anders onnodig afgerond wordt, alles apart in doubles.
|
||||||
|
double minmax = max-min;
|
||||||
|
double bottom = this.getWidth() / minmax;
|
||||||
|
double all = posx / bottom;
|
||||||
|
double endTime = all + min + calcLengthOfStagePanel(imageWidth);
|
||||||
|
// System.out.println(calcLengthOfStagePanel(imageWidth));
|
||||||
|
// System.out.println(endTime);
|
||||||
|
return (int)endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int findMinMax(int i)
|
||||||
|
{
|
||||||
|
// Event oldevent = new Event(0, 0, null, "Base", 0);
|
||||||
|
// ArrayList<Event> oldevents = new ArrayList<Event>();
|
||||||
|
// oldevents.add(oldevent);
|
||||||
|
// Stage oldstage = new Stage(oldevents,0,null, 0, 0);
|
||||||
|
ArrayList<Stage> stagescopy = (ArrayList<Stage>) stages.clone();
|
||||||
|
|
||||||
|
Integer earliestStartTime = null;
|
||||||
|
Integer lastEndTime = null;
|
||||||
|
|
||||||
|
for(Stage stage : stagescopy)
|
||||||
|
{
|
||||||
|
if(i == 1)
|
||||||
|
{
|
||||||
|
if(earliestStartTime == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
earliestStartTime = stage.getStartTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(stage.getStartTime() < earliestStartTime)
|
||||||
|
{
|
||||||
|
earliestStartTime = stage.getStartTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( i == 2)
|
||||||
|
{
|
||||||
|
if(lastEndTime == null)
|
||||||
|
{
|
||||||
|
lastEndTime = stage.getEndTime();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(stage.getEndTime() > lastEndTime)
|
||||||
|
{
|
||||||
|
lastEndTime = stage.getEndTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(i == 1)
|
||||||
|
{
|
||||||
|
return earliestStartTime;
|
||||||
|
}
|
||||||
|
else if(i == 2)
|
||||||
|
{
|
||||||
|
return lastEndTime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("Return -1");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JPanel createTopPanel()
|
||||||
|
{
|
||||||
|
JPanel topPane = new JPanel();
|
||||||
|
topPane.setLayout(new BoxLayout(topPane, BoxLayout.Y_AXIS));
|
||||||
|
JPanel topPanel = new JPanel(new FlowLayout());
|
||||||
|
for(int i = 0; i <= this.getWidth() / 10; i++)
|
||||||
|
{
|
||||||
|
ImageIcon topImageIcon = new ImageIcon("src/test2.png");
|
||||||
|
JLabel topImage = new JLabel(topImageIcon);
|
||||||
|
topPanel.add(topImage);
|
||||||
|
}
|
||||||
|
topPane.add(Box.createRigidArea(new Dimension(0,20)));
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||||
|
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
||||||
|
panel.add(new JLabel(Integer.toString(findMinMax(1))));
|
||||||
|
panel.add(Box.createHorizontalGlue());
|
||||||
|
panel.add(new JLabel(Integer.toString(findMinMax(2))));
|
||||||
|
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
||||||
|
topPane.add(panel);
|
||||||
|
topPane.add(topPanel);
|
||||||
|
// this.add(topPane, BorderLayout.NORTH);
|
||||||
|
return topPane;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel createWestPanel()
|
||||||
|
{
|
||||||
|
JPanel westPanel = new JPanel();
|
||||||
|
westPanel.setLayout(new BoxLayout(westPanel, BoxLayout.Y_AXIS));
|
||||||
|
westPanel.add(Box.createRigidArea(new Dimension(0, 100)));
|
||||||
|
for(int i = 0; i < stages.size(); i++)
|
||||||
|
{
|
||||||
|
JLabel stageText = new JLabel("Stage: " + (i+1) + " ");
|
||||||
|
westPanel.add(stageText);
|
||||||
|
westPanel.add(Box.createRigidArea(new Dimension(0, 30 )));
|
||||||
|
}
|
||||||
|
// this.add(westPanel, BorderLayout.WEST);
|
||||||
|
return westPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void genStages()
|
||||||
|
{
|
||||||
|
ImageIcon image = new ImageIcon();
|
||||||
|
Artist artist2 = new Artist("Henk", "paul2", "kaas", image, 2);
|
||||||
|
Artist artist1 = new Artist("Kaas", "Paul", "Lala", image, 1);
|
||||||
|
Event event2 = new Event(1900, 2000, artist2, "hi2", 2);
|
||||||
|
Event event1 = new Event(600, 1800, artist1, "hi", 1);
|
||||||
|
ArrayList<Event> performances = new ArrayList<Event>();
|
||||||
|
performances.add(event1);
|
||||||
|
performances.add(event2);
|
||||||
|
Stage stage1 = new Stage(performances, 100, null, 1800, 2100);
|
||||||
|
stages.add(stage1);
|
||||||
|
Stage stage2 = new Stage(performances, 100, null, 1700, 1900);
|
||||||
|
Stage stage3 = new Stage(performances, 100, null, 1600, 1800);
|
||||||
|
Stage stage4 = new Stage(performances, 100, null, 1600, 2100);
|
||||||
|
stages.add(stage3);
|
||||||
|
stages.add(stage2);
|
||||||
|
// stages.add(stage4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel getTimeline()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import java.awt.BorderLayout;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
|
||||||
|
public class TimelinePanel extends JPanel {
|
||||||
|
|
||||||
|
private Timeline timeline;
|
||||||
|
|
||||||
|
public TimelinePanel()
|
||||||
|
{
|
||||||
|
super(new BorderLayout());
|
||||||
|
|
||||||
|
this.setSize(600, 600);
|
||||||
|
this.setVisible(true);
|
||||||
|
timeline = new Timeline(this);
|
||||||
|
this.add(timeline,BorderLayout.CENTER);
|
||||||
|
this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh()
|
||||||
|
{
|
||||||
|
timeline.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
|
|
||||||
public class Window extends JFrame {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 4468821981332661759L;
|
|
||||||
|
|
||||||
JTextArea tarea;
|
|
||||||
|
|
||||||
public Window()
|
|
||||||
{
|
|
||||||
super("Agenda");
|
|
||||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
|
||||||
setSize(500,600);
|
|
||||||
JPanel contentPanel = new JPanel();
|
|
||||||
|
|
||||||
tarea = new JTextArea(10,20);
|
|
||||||
tarea.setEditable(false);
|
|
||||||
|
|
||||||
contentPanel.add(tarea);
|
|
||||||
setContentPane(contentPanel);
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(String str)
|
|
||||||
{
|
|
||||||
tarea.setText(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user