我正在使用 jfreechart 绘制关于计算机中操作记录器的图表。
例如:1:2012/09/39/28 06:55:37 8 S 0x1c0c762 终端--geometry=134x35 --display :0.0 --role=Terminal-0x10591b0-16869-1343137248 --show-menubar --show-边界 --hide-toolbars --working-directory /home/termier “终端”,“终端” “终端 - termier@akagi: ~” 2: 2012/09/39/28 06:55:41 8 S 0x1600313 /usr /lib/xfce4/notifyd/xfce4-notifyd "xfce4-notifyd", "Xfce4-notifyd" "xfce4-notifyd"
现在,我可以像 (2012/09/39/28 06:55:37,Terminal) 一样绘制每个点,scilicet: x 轴是 2012/09/39/28 06:55:37,Y 轴是:终端(我使用 1 表示终端,至于其他命令,就像终端... 2:/usr/lib/xfce4/notifyd/xfce4-notifyd 等...)
但我需要的是画一个块,比如:
终端 1: _ __ _ __ _ _ _S||||||
/usr/lib/xfce4/notifyd/xfce4-notifyd2: _ __ _ __ _ __ _ ___ _S||||||
com 3: _ __ _ _S||||| (S:start ,eg: 2000/12/12 09:22:10 start) .....(当第一个命令结束时,另一个将开始,我只是可以开始,这意味着 post 命令是上一条命令的结束时间)
但不是: 1:S 2:S 3:S
这里有一些代码给你。
private XYDataset createDataset() {
Calendar precal;
Calendar postcal;
this.flags = modelfocus.getListflag();
commands = modelfocus.getListCommand();
DateFormat formatedate = new SimpleDateFormat("yyyy/MM/ww/dd HH:mm:ss");
precal = Calendar.getInstance();
postcal = Calendar.getInstance();
for (int i = 0; i < countCom; i++) {
this.series[i] = new TimeSeries(commands.get(i));
}
for (Focus listTxt : modelfocus.getList()) {
try {
Date d = new Date();
d = formatedate.parse(listTxt.date2String());
System.out.println(d);
precal.setTime(d);
//postcal.setTime();
} catch (ParseException e) {
System.out.println("Can't change this date");
e.printStackTrace();
}
String eachCmd = listTxt.getCommand();
for (int i = 0; i < countCom; i++) {
if (eachCmd == commands.get(i)) {
series[i].addOrUpdate(new Second(precal.getTime()),
flags.get(i));
}
}
}
TimeSeriesCollection dataset = new TimeSeriesCollection();
for (int i = 0; i < countCom; i++) {
dataset.addSeries(this.series[i]);
}
return dataset;
}
请有人帮忙解决这个问题,非常感谢。