List of usage examples for org.jfree.chart.plot XYPlot setDomainAxes
public void setDomainAxes(ValueAxis[] axes)
From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java
/** * some jFreeChart Axis settings for TimeValueDiagram * @param plot jFreeChart plot instance * @param rangeAxisLabel Label of rangeAxis *//*from ww w . j av a 2 s . c o m*/ private void buildTimeValueDiagramAxisFormat(XYPlot plot, String rangeAxisLabel) { System.out.println("StatisticGrafic.buildTimeValueDiagramAxisFormat"); ValueAxis rangeAxis = (ValueAxis) plot.getRangeAxis(); double a = 0.1 * Math.max(Math.abs(statistic.getValueLow()), Math.abs(statistic.getValueHigh())); rangeAxis.setLowerBound(statistic.getValueLow() - a); rangeAxis.setUpperBound(statistic.getValueHigh() + a); rangeAxis.setLabel(rangeAxisLabel); rangeAxis.setLabelFont(FONT_DEFAULT); DateAxis dateAxis = new DateAxis(); DateAxis[] domainAxisArray = new DateAxis[1]; domainAxisArray[0] = dateAxis; plot.setDomainAxes(domainAxisArray); dateAxis.setLowerBound(statistic.getTimeLow()); dateAxis.setUpperBound(statistic.getTimeHigh()); long diff = statistic.getTimeHigh() - statistic.getTimeLow(); String format, unit; if (diff > 24 * 60 * 60 * 1000) { format = "d.MM.yyyy"; unit = "[day]"; } else if (diff > 60 * 60 * 1000) { format = "H:mm"; unit = "[h]"; } else if (diff > 60 * 1000) { format = "m:ss"; unit = "[min]"; } else if (diff > 1000) { format = "s.S"; unit = "[sec]"; } else { format = "S"; unit = "[millisec]"; } SimpleDateFormat sdf = new SimpleDateFormat(format); dateAxis.setDateFormatOverride(sdf); SimpleDateFormat sdf1 = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SSS"); String von = sdf1.format(dateAxis.getMinimumDate()); String bis = sdf1.format(dateAxis.getMaximumDate()); dateAxis.setLabel(von + " Time " + unit + " " + bis); dateAxis.setLabelFont(FONT_DEFAULT); }