Left to do: fix time in timeline
This commit is contained in:
+12
-6
@@ -123,7 +123,7 @@ public class Event implements Serializable {
|
||||
{
|
||||
DateFormat format = new SimpleDateFormat("kkmm");
|
||||
format.setLenient(false);
|
||||
System.out.println(format.format(startDate.getTime()));
|
||||
// System.out.println(format.format(startDate.getTime()));
|
||||
|
||||
// System.out.println(date.get(Calendar.HOUR_OF_DAY));
|
||||
|
||||
@@ -134,18 +134,24 @@ public class Event implements Serializable {
|
||||
{
|
||||
DateFormat format = new SimpleDateFormat("kkmm");
|
||||
format.setLenient(false);
|
||||
System.out.println(format.format(endDate.getTime()));
|
||||
// System.out.println(format.format(endDate.getTime()));
|
||||
return Integer.valueOf(format.format(endDate.getTime()));
|
||||
}
|
||||
|
||||
public void setStartTime(int time)
|
||||
public void setStartTime(int hours, int minutes)
|
||||
{
|
||||
startDate.set(Calendar.HOUR, 6);
|
||||
// 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 time)
|
||||
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() {
|
||||
|
||||
+4
-4
@@ -67,14 +67,14 @@ public class StagePanel extends JPanel
|
||||
this.width = length;
|
||||
}
|
||||
|
||||
public void setStageStartTime(int startTime)
|
||||
public void setStageStartTime(int hours, int minutes)
|
||||
{
|
||||
event.setStartTime(startTime);
|
||||
event.setStartTime(hours, minutes);
|
||||
}
|
||||
|
||||
public void setStageEndTime(int endTime)
|
||||
public void setStageEndTime(int hours, int minutes)
|
||||
{
|
||||
event.setEndTime(endTime);
|
||||
event.setEndTime(hours, minutes);
|
||||
}
|
||||
|
||||
public int getStageStartTime()
|
||||
|
||||
+50
-19
@@ -63,12 +63,11 @@ public class Timeline extends JPanel
|
||||
public void refresh()
|
||||
{
|
||||
this.removeAll();
|
||||
// createWestPanel();
|
||||
createMainPanel();
|
||||
this.revalidate();
|
||||
}
|
||||
|
||||
private void createMainPanel()
|
||||
public JPanel createMainPanel()
|
||||
{
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
||||
@@ -86,7 +85,8 @@ public class Timeline extends JPanel
|
||||
centerContainer.setMaximumSize(centerDim);
|
||||
// System.out.println(centerDim);
|
||||
mainPanel.add(centerContainer);
|
||||
this.add(mainPanel, BorderLayout.CENTER);
|
||||
// this.add(mainPanel, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
private JPanel createCenterPanel()
|
||||
@@ -155,8 +155,8 @@ public class Timeline extends JPanel
|
||||
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.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(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
||||
refresh();
|
||||
@@ -206,7 +206,7 @@ public class Timeline extends JPanel
|
||||
return posx;
|
||||
}
|
||||
|
||||
public int calcStartTimeOfStagePanel(int posx)
|
||||
public int calcStartTimeOfStagePanelHours(int posx)
|
||||
{
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
@@ -216,17 +216,23 @@ public class Timeline extends JPanel
|
||||
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;
|
||||
return (int)startTime / 100;
|
||||
}
|
||||
|
||||
public int calcStartTimeOfStagePanelMinutes(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;
|
||||
return (int)startTime % 100;
|
||||
}
|
||||
|
||||
public int calcEndTimeOfStagePanel(int posx, int imageWidth)
|
||||
public int calcEndTimeOfStagePanelHours(int posx, int imageWidth)
|
||||
{
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
@@ -235,9 +241,33 @@ public class Timeline extends JPanel
|
||||
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;
|
||||
return (int)endTime / 100;
|
||||
}
|
||||
|
||||
public int calcEndTimeOfStagePanelMinutes(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);
|
||||
return (int)endTime % 100;
|
||||
}
|
||||
|
||||
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 findMinMax(int i)
|
||||
@@ -306,7 +336,7 @@ public class Timeline extends JPanel
|
||||
JPanel topPanel = new JPanel(new FlowLayout());
|
||||
for(int i = 0; i <= this.getWidth() / 10; i++)
|
||||
{
|
||||
ImageIcon topImageIcon = new ImageIcon("src/test2.png");
|
||||
ImageIcon topImageIcon = new ImageIcon("src/sprites/block.png");
|
||||
JLabel topImage = new JLabel(topImageIcon);
|
||||
topPanel.add(topImage);
|
||||
}
|
||||
@@ -365,4 +395,5 @@ public class Timeline extends JPanel
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+23
-5
@@ -1,6 +1,7 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
|
||||
@@ -12,7 +13,7 @@ public class TimelinePanel extends JPanel implements Panel {
|
||||
{
|
||||
super(new BorderLayout());
|
||||
|
||||
this.setSize(600, 600);
|
||||
this.setSize(1920, 1080);
|
||||
this.setVisible(true);
|
||||
timeline = new Timeline(this);
|
||||
this.add(timeline,BorderLayout.CENTER);
|
||||
@@ -21,14 +22,31 @@ public class TimelinePanel extends JPanel implements Panel {
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
timeline.refresh();
|
||||
this.removeAll();
|
||||
this.add(timeline.createMainPanel(),BorderLayout.CENTER);
|
||||
this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
||||
this.revalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ArrayList<Event> event)
|
||||
public void update(ArrayList<Event> events)
|
||||
{
|
||||
timeline.setEvents(event);
|
||||
timeline.refresh();
|
||||
timeline.setEvents(events);
|
||||
System.out.println(events.size());
|
||||
|
||||
//dit fixt het half
|
||||
// if(events.size() == 0)
|
||||
// {
|
||||
// this.removeAll();
|
||||
// this.add(timeline.createWestPanel(),BorderLayout.WEST);
|
||||
// this.add(timeline, BorderLayout.CENTER);
|
||||
// this.revalidate();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// refresh();
|
||||
// }
|
||||
refresh();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user