scaling to Endtime added
This commit is contained in:
+40
-18
@@ -1,35 +1,57 @@
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Stage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private String name;
|
||||
public class Stage
|
||||
{
|
||||
private ArrayList<Event> performances;
|
||||
private int expectedPopularity;
|
||||
private String description;
|
||||
private int length;
|
||||
private int startTime,endTime;
|
||||
|
||||
public Stage(String name, String description)
|
||||
public Stage(ArrayList<Event> performances, int expectedPopularity, String description, int startTime, int endTime)
|
||||
{
|
||||
this.name = name;
|
||||
this.performances = performances;
|
||||
this.expectedPopularity = expectedPopularity;
|
||||
this.description = description;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.length = endTime - startTime;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
public void setStartTime(int startTime)
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
public void setEndTime(int endTime)
|
||||
{
|
||||
this.description = description;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
public ArrayList<Event> getPerformances()
|
||||
{
|
||||
this.name = name;
|
||||
return performances;
|
||||
}
|
||||
|
||||
// public int getID()
|
||||
// {
|
||||
// return id + 100;
|
||||
// }
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
|
||||
public int getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public int getEndTime()
|
||||
{
|
||||
return endTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +67,11 @@ public class StagePanel extends JPanel
|
||||
stage.setStartTime(startTime);
|
||||
}
|
||||
|
||||
public void setStageEndTime(int endTime)
|
||||
{
|
||||
stage.setEndTime(endTime);
|
||||
}
|
||||
|
||||
public int getStageStartTime()
|
||||
{
|
||||
return stage.getStartTime();
|
||||
|
||||
+33
-3
@@ -27,7 +27,7 @@ public class Timeline extends JPanel
|
||||
private ArrayList<Stage> stages = new ArrayList<Stage>();
|
||||
private JFrame frame;
|
||||
|
||||
//Geef dit object je JFrame mee, en zet in je JFrame de volgende code:
|
||||
// Geef dit object je JFrame mee, en zet in je JFrame de volgende code:
|
||||
// this.setContentPane(timeline.getTimeline());
|
||||
// this.getRootPane().addComponentListener(new ComponentAdapter()
|
||||
// {
|
||||
@@ -132,9 +132,10 @@ public class Timeline extends JPanel
|
||||
{
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
System.out.println(stagepanel.getStageStartTime());
|
||||
System.out.println(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||
// System.out.println(stagepanel.getStageStartTime());
|
||||
// System.out.println(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||
stagepanel.setStageStartTime(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||
stagepanel.setStageEndTime(calcEndTimeOfStagePanel(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
||||
refresh();
|
||||
|
||||
|
||||
@@ -153,6 +154,21 @@ public class Timeline extends JPanel
|
||||
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 = frame.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;
|
||||
@@ -187,6 +203,20 @@ public class Timeline extends JPanel
|
||||
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 = frame.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);
|
||||
|
||||
Reference in New Issue
Block a user