Merge remote-tracking branch 'origin/kenneth' into develop
This commit is contained in:
+19
-3
@@ -51,7 +51,20 @@ public class Agenda implements Serializable {
|
||||
{
|
||||
return stages;
|
||||
}
|
||||
public ArrayList<Event> eventsForStage(AgendaStage st)
|
||||
{
|
||||
ArrayList<Event> stageEvents = new ArrayList<Event>();
|
||||
for(Event e: events)
|
||||
{
|
||||
if(e.getStage() == st)
|
||||
{
|
||||
stageEvents.add(e);
|
||||
}
|
||||
}
|
||||
return stageEvents;
|
||||
}
|
||||
|
||||
/*
|
||||
public void saveAgenda()
|
||||
{
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
@@ -179,7 +192,7 @@ public class Agenda implements Serializable {
|
||||
{
|
||||
boolean exists = false;
|
||||
String name = e.getStage().getName();
|
||||
for (AgendaStage s : stages)
|
||||
for (Stage s : stages)
|
||||
{
|
||||
if ( s.getName().equals(name) ) {
|
||||
exists = true;
|
||||
@@ -202,7 +215,8 @@ public class Agenda implements Serializable {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public void clearAgenda()
|
||||
{
|
||||
@@ -211,10 +225,12 @@ public class Agenda implements Serializable {
|
||||
artists.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
public void fillAllLists()
|
||||
{
|
||||
loadAgenda();
|
||||
fillStages();
|
||||
fillArtists();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
+4
-3
@@ -63,7 +63,8 @@ public class MenuBar extends JMenuBar {
|
||||
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
||||
open.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
w.getAgenda().loadAgenda();
|
||||
Applicatie.SaveLoad.load(w.getPanel());
|
||||
w.setAgenda(w.getPanel().getAgenda());
|
||||
Window.updatePanel();
|
||||
}
|
||||
});
|
||||
@@ -72,7 +73,7 @@ public class MenuBar extends JMenuBar {
|
||||
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
|
||||
save.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
w.getAgenda().saveAgenda();
|
||||
Applicatie.SaveLoad.save(w.getPanel());
|
||||
Window.updatePanel();
|
||||
}
|
||||
});
|
||||
@@ -133,4 +134,4 @@ public class MenuBar extends JMenuBar {
|
||||
view.add(art_sta);
|
||||
add(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-5
@@ -1,6 +1,5 @@
|
||||
package Agenda;
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
@@ -36,14 +35,16 @@ public class Window extends JFrame {
|
||||
private static GregorianCalendar date;
|
||||
private static Agenda agenda;
|
||||
private static String currentPanel = "table";
|
||||
private Applicatie.Panel ap;
|
||||
|
||||
public Window()
|
||||
public Window(Applicatie.Panel ap)
|
||||
{
|
||||
/*
|
||||
* Initialize window
|
||||
*/
|
||||
super("Agenda");
|
||||
agenda = new Agenda();
|
||||
this.ap = ap;
|
||||
agenda = ap.getAgenda();
|
||||
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@@ -181,7 +182,7 @@ public class Window extends JFrame {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static void changePanel(String panel)
|
||||
{
|
||||
currentPanel = panel;
|
||||
@@ -231,7 +232,13 @@ public class Window extends JFrame {
|
||||
public void setAgenda(Agenda a)
|
||||
{
|
||||
agenda = a;
|
||||
ap.setAgenda(a);
|
||||
}
|
||||
|
||||
public Applicatie.Panel getPanel()
|
||||
{
|
||||
return ap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+4
-12
@@ -33,11 +33,13 @@ public class MenuBar extends JMenuBar
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
new Agenda.Window();
|
||||
new Agenda.Window(w.getPanel());
|
||||
}
|
||||
});
|
||||
file.add(agenda);
|
||||
|
||||
file.addSeparator();
|
||||
|
||||
item = new JMenuItem("Open");
|
||||
item.addActionListener(new ActionListener() {
|
||||
|
||||
@@ -60,22 +62,12 @@ public class MenuBar extends JMenuBar
|
||||
|
||||
file.addSeparator();
|
||||
|
||||
item = new JMenuItem("Load agenda");
|
||||
item.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
w.getPanel().agenda.loadAgenda();
|
||||
}
|
||||
});
|
||||
file.add(item);
|
||||
|
||||
item = new JMenuItem("Agenda");
|
||||
item.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
new Agenda.Window();
|
||||
new Agenda.Window(w.getPanel());
|
||||
}
|
||||
});
|
||||
file.add(item);
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import Agenda.Agenda;
|
||||
import Objects.DrawObject;
|
||||
|
||||
public class SaveLoad {
|
||||
@@ -66,6 +67,7 @@ public class SaveLoad {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
oos.writeObject(panel.getAgenda());
|
||||
for (DrawObject object : panel.objects) {
|
||||
oos.writeObject(object);
|
||||
}
|
||||
@@ -124,8 +126,10 @@ public class SaveLoad {
|
||||
ois = new ObjectInputStream(fis);
|
||||
|
||||
Object object;
|
||||
object = ois.readObject();
|
||||
Agenda a = (Agenda) ois.readObject();
|
||||
panel.setAgenda(a);
|
||||
try {
|
||||
object = ois.readObject();
|
||||
panel.clearObjects();
|
||||
while (object != null) {
|
||||
panel.objects.add((DrawObject) object);
|
||||
@@ -141,4 +145,4 @@ public class SaveLoad {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+19
-1
@@ -15,6 +15,7 @@ import java.io.Serializable;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import Applicatie.Images;
|
||||
import Applicatie.Panel;
|
||||
|
||||
public abstract class DrawObject implements Serializable
|
||||
{
|
||||
@@ -232,13 +233,30 @@ public abstract class DrawObject implements Serializable
|
||||
|
||||
public void setPosition(Point2D position)
|
||||
{
|
||||
if(position.getX() < -Panel.getFieldWidth()/2)
|
||||
{
|
||||
position.setLocation(-Panel.getFieldWidth()/2, position.getY());
|
||||
}
|
||||
if(position.getY() < -Panel.getFieldHeight()/2)
|
||||
{
|
||||
position.setLocation(position.getX(), -Panel.getFieldHeight()/2);
|
||||
}
|
||||
if(position.getX() > Panel.getFieldWidth()/2 - width)
|
||||
{
|
||||
position.setLocation(Panel.getFieldWidth()/2-width, position.getY());
|
||||
}
|
||||
if(position.getY() > Panel.getFieldHeight()/2 - height)
|
||||
{
|
||||
position.setLocation(position.getX(), Panel.getFieldHeight()/2-height);
|
||||
}
|
||||
this.position = position;
|
||||
}
|
||||
public void setPosition(Point2D position, boolean b)
|
||||
{
|
||||
this.position = position;
|
||||
setPosition(position);
|
||||
}
|
||||
|
||||
|
||||
public double getRotation()
|
||||
{
|
||||
return rotation;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 8.0 KiB |
Reference in New Issue
Block a user