Browse Source

Added agenda back.

Gilian Joosen 11 years ago
parent
commit
90a247996f

BIN
res/img/Xicon.png


BIN
res/img/_icon.png


+ 122 - 0
src/GUI/GUI.java

@@ -0,0 +1,122 @@
+package src.GUI;
+
+import src.agenda.*;
+
+import java.awt.Color;
+import java.awt.EventQueue;
+import java.awt.Frame;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+
+public class GUI {
+
+	private JFrame frame;
+
+	int posX=0,posY=0;
+	/**
+	 * Launch the application.
+	 */
+	public static void main(String[] args) {
+		EventQueue.invokeLater(new Runnable() {
+			public void run() {
+				try {
+					GUI window = new GUI();
+					window.frame.setVisible(true);
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+		});
+	}
+
+	/**
+	 * Create the application.
+	 */
+	public GUI() {
+		initialize();
+        
+        //test agenda.
+        Agenda agenda = new Agenda();
+        
+//        agenda.addArtist(new Artist("Iron Maiden", "Heavy metal"));
+//        agenda.addStage(new Stage("Mainstage"));
+//        agenda.addAct(new Act(agenda.getStages().get(0), "Heavy metal", agenda.getArtists().get(0)));
+//
+//        System.out.println(agenda);
+//
+//        //test time
+//        System.out.println(new ActTime(new Time(10, 30), new Time(11, 20)).getLength());
+	}
+
+	/**
+	 * Initialize the contents of the frame.
+	 */
+	private void initialize() {
+		frame = new JFrame();
+		frame.setResizable(false);
+		frame.setBounds(100, 100, 1020, 700);
+		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		frame.setUndecorated(true);
+		frame.getContentPane().setLayout(null);
+		
+		
+		
+		JPanel menuBarPanel = new JPanel();
+		menuBarPanel.setBackground(new Color(0, 128, 128));
+		menuBarPanel.setBounds(0, 0, 1020, 45);
+		frame.getContentPane().add(menuBarPanel);
+		menuBarPanel.addMouseListener(new MouseAdapter()
+		{
+			   public void mousePressed(MouseEvent e)
+			   {
+			      posX=e.getX();
+			      posY=e.getY();
+			   }
+			});
+		menuBarPanel.addMouseMotionListener(new MouseAdapter()
+		{
+		     public void mouseDragged(MouseEvent evt)
+		     {
+				//sets frame position when mouse dragged			
+				setLocation(evt.getXOnScreen()-posX,evt.getYOnScreen()-posY);
+							
+		     }
+		});
+		ImageIcon closeIcon = new ImageIcon("res/img/Xicon.png");
+	    JLabel closeLabel = new JLabel(closeIcon);
+	    closeLabel.setBounds(983, 11, 18, 18);
+	    closeLabel.addMouseListener(new MouseAdapter() {
+	      public void mouseClicked(MouseEvent me) {
+	    	  frame.dispose();
+	      }
+	    });
+	    ImageIcon min = new ImageIcon("res/img/_icon.png");
+	    JLabel minLabel = new JLabel(min);
+	    minLabel.setBounds(948, 11, 18, 18);
+	    minLabel.addMouseListener(new MouseAdapter() {
+	      public void mouseClicked(MouseEvent me) {
+	    	  frame.setState(Frame.ICONIFIED);
+	      }
+	    });
+	    menuBarPanel.setLayout(null);
+	    menuBarPanel.add(closeLabel);
+	    menuBarPanel.add(minLabel);
+	    
+		
+		
+		JPanel contentPanel = new JPanel();
+		contentPanel.setBackground(new Color(51, 160, 160));
+		contentPanel.setBounds(0, 45, 1020, 655);
+		frame.getContentPane().add(contentPanel);
+	}
+
+	protected void setLocation(int i, int j) {
+		frame.setLocation(i,j);
+	}
+}

+ 71 - 0
src/agenda/Act.java

@@ -0,0 +1,71 @@
+package src.agenda;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by gjoosen on 06/02/15.
+ */
+public class Act {
+    
+    private List<Artist> artists;
+    private Stage stage;
+    private String genre;
+    private ActTime actTime;
+
+    public Act(Stage stage, String genre, Time startTime, Time endTime, Artist... artists){
+        this.stage = stage; 
+        this.genre = genre;
+        this.actTime = new ActTime(startTime, endTime);
+
+        this.artists = new ArrayList<Artist>();
+        for(Artist artist: artists) {
+            this.artists.add(artist);
+        }
+    }
+
+    /**
+     * * returns a list with all the artists that are in the act.
+     * @return all artists.
+     */
+    public List<Artist> getArtists() {
+        return artists;
+    }
+
+    /**
+     * * returns the stage the act plays on.
+     * @return stage
+     */
+    public Stage getStage() {
+        return stage;
+    }
+
+    /**
+     * * returns the genre of the act.
+     * @return the genre of the act.
+     */
+    public String getGenre() {
+        return genre;
+    }
+
+    /**
+     * * return the act time.
+     * @return the act time in minutes
+     */
+    public int getActTime() {
+        return this.actTime.getLength();
+    }
+    
+    @Override
+    public String toString(){
+        String string = "";
+        string+="Artists: ";
+        for(Artist artist: this.artists){
+            string += artist.getName() + "\n";
+        }
+        string+= "genre: " + this.genre + "\n";
+        string+= "stage: " + this.stage.getName() + "\n";
+        string+= this.actTime;
+        return string;
+    }
+}

+ 37 - 0
src/agenda/ActTime.java

@@ -0,0 +1,37 @@
+package src.agenda;
+
+/**
+ * Created by gjoosen on 06/02/15.
+ */
+public class ActTime {
+    
+    private Time beginTime, endTime;
+    
+    public ActTime(Time beginTime, Time endTime){
+        this.beginTime = beginTime;
+        this.endTime = endTime;
+    }
+
+    /**
+     * *
+     * @return the length of the act in minutes.
+     */
+    public int getLength(){
+        int difHours = this.endTime.getHours() - this.beginTime.getHours();
+        int difMinutes = this.endTime.getMinutes() - this.beginTime.getMinutes();
+        return difHours  * 60 + difMinutes;
+    }
+
+    public Time getBeginTime() {
+        return beginTime;
+    }
+
+    public Time getEndTime() {
+        return endTime;
+    }
+    
+    @Override
+    public String toString(){
+        return "start time: " + this.beginTime + "\nend time: " + this.endTime;
+    }
+}

+ 73 - 0
src/agenda/Agenda.java

@@ -0,0 +1,73 @@
+package src.agenda;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by gjoosen on 06/02/15.
+ */
+public class Agenda {
+    
+    private List<Stage> stages;
+    private List<Artist> artists;
+    private List<Act> acts;
+    
+    public Agenda() {
+        this.stages = new ArrayList<Stage>();
+        this.artists = new ArrayList<Artist>();
+        this.acts = new ArrayList<Act>();
+        
+        this.testAgenda();
+    }
+
+    private void testAgenda(){
+        //stages
+        this.stages.add(new Stage("Main stage"));
+        this.stages.add(new Stage("Tent stage"));
+        
+        //artiesten
+        this.artists.add(new Artist("Iron Maiden", "Heavy metal"));
+        this.artists.add(new Artist("Slayer", "Tresh metal"));
+        this.artists.add(new Artist("Sabaton", "Power metal"));
+
+        //acts
+        this.acts.add(new Act(this.stages.get(0), "Heavy metal", new Time(21, 00), new Time(23, 00), this.artists.get(0)));
+        this.acts.add(new Act(this.stages.get(1), "Test metal" ,new Time(10, 10), new Time(10, 50), this.artists.get(1)));
+        this.acts.add(new Act(this.stages.get(0), "Power metal" ,new Time(10, 10), new Time(10, 50), this.artists.get(2)));
+        
+        System.out.println(this);
+    }
+    
+    public List<Stage> getStages() {
+        return stages;
+    }
+
+    public void addStage(Stage stage){
+        this.stages.add(stage);
+    }
+    
+    public void addArtist(Artist artist){
+        this.artists.add(artist);
+    }
+    
+    public void addAct(Act act){
+        this.acts.add(act);
+    }
+    
+    public List<Artist> getArtists() {
+        return artists;
+    }
+
+    public List<Act> getActs() {
+        return acts;
+    }
+    
+    @Override
+    public String toString(){
+        String string = "";
+        for(Act act: this.acts){
+            string += act + "\n\n";
+        }
+        return string;
+    }
+}

+ 22 - 0
src/agenda/Artist.java

@@ -0,0 +1,22 @@
+package src.agenda;
+
+/**
+ * Created by gjoosen on 06/02/15.
+ */
+public class Artist {
+    
+    private String name, genre;
+    
+    public Artist(String name, String genre){
+        this.name = name;
+        this.genre = genre;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getGenre() {
+        return genre;
+    }
+}

+ 17 - 0
src/agenda/Stage.java

@@ -0,0 +1,17 @@
+package src.agenda;
+
+/**
+ * Created by gjoosen on 06/02/15.
+ */
+public class Stage {
+    
+    private String name;
+    
+    public Stage(String name){
+        this.name = name;
+    }
+    
+    public String getName(){
+        return this.name;
+    }
+}

+ 37 - 0
src/agenda/Time.java

@@ -0,0 +1,37 @@
+package src.agenda;
+
+/**
+ * Created by gjoosen on 07/02/15.
+ */
+public class Time {
+    
+    private int hours, minutes;
+    
+    public Time(int hours, int minutes){
+        this.hours = hours;
+        this.minutes = minutes;
+    }
+
+    public int getHours() {
+        return hours;
+    }
+
+    public int getMinutes() {
+        return minutes;
+    }
+    
+    @Override
+    public String toString(){
+        return this.numberToTimeDigits(this.hours) + ":" + this.numberToTimeDigits(this.minutes);
+    }
+    
+    private String numberToTimeDigits(int h){
+        String hours;
+        if(h == 0 || h == 1 || h == 2 || h == 3 || h == 4 || h == 5 || h == 6 || h == 7 || h == 8 || h == 9){
+            hours = "0" + h;
+        }else {
+            hours = String.valueOf(h);
+        }
+        return hours;
+    }
+}