日期:2014-05-20 浏览次数:20783 次
private IntervalCategoryDataset createDataset() {
this.flags = modelfocus.getListflag();// 为了匹配每个命令,我在写入一个命令时,也写入一个标记用来找相应的命令
commands = modelfocus.getListCommand();//获得所有命令
DateFormat formatedate = new SimpleDateFormat("yyyy/MM/ww/dd HH:mm:ss");
cal = Calendar.getInstance();
nextDate = modelfocus.getNextDate();//获得一条命令的结束、(即下一命令的开始)
//初始化命令个数 个线条 用来绘图
for (int i = 0; i < countCom; i++) {
this.series[i] = new TaskSeries(commands.get(i));
}
int flag = 0;
Task task; //任务,用于 new task(命令,开始时间,结束时间)
//遍历日志文件list
for (Focus listTxt : modelfocus.getList()) {
try {
d1 = formatedate.parse(listTxt.date2String());
// postcal.setTime();
} catch (ParseException e) {
System.out.println("Can't change this date");
e.printStackTrace();
}
d1 = modelfocus.getDate().get(flag);
cal.setTime(d1);
System.out.println(cal);
if (flag < nextDate.size() - 1) {
d2 = nextDate.get(flag);
System.out.println("start:......" + d1);
System.out.println("e n d:......" + d2);
}
String eachCmd = listTxt.getCommand();//获取当前日志行的命令段
//问题的地方(我觉得是这里)
//我循环所有命令,判断是否和当前命令匹配,如果匹配的话就加入相应命令的 线条
for (int i = 0; i < countCom; i++) {
String currentCmd = listTxt.getCommand();
if (eachCmd==currentCmd && currentCmd !=" ") {
if (d1.compareTo(d2) < 0)
task = new Task(currentCmd, d1, d2);
else {
System.out.println(cal);
task = new Task(currentCmd, d1, d1);
}
//任务加入线条
series[i].add(task);
}
}
flag++;
}
TaskSeriesCollection dataset = new TaskSeriesCollection();
//任务集合
for (int i = 0; i < countCom; i++) {
dataset.add(this.series[i]);
}
return dataset;
}