Solved with the Second class. Here is an example:
Code: Select all
import java.util.*;
import java.text.*;
import java.io.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.filechooser.*;
import org.jfree.chart.*;
import org.jfree.chart.block.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.renderer.*;
import org.jfree.chart.renderer.xy.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.labels.*;
import org.jfree.chart.servlet.*;
import org.jfree.chart.annotations.*;
import org.jfree.chart.needle.*;
import org.jfree.chart.event.*;
import org.jfree.chart.imagemap.*;
import org.jfree.chart.encoders.*;
import org.jfree.chart.urls.*;
import org.jfree.chart.entity.*;
import org.jfree.chart.title.*;
import org.jfree.chart.util.*;
import org.jfree.chart.resources.*;
import org.jfree.chart.panel.*;
import org.jfree.chart.editor.*;
import org.jfree.chart.demo.*;
import org.jfree.data.*;
import org.jfree.data.time.*;
import org.jfree.chart.plot.*;
import org.jfree.data.xy.*;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class SecondDemo extends ApplicationFrame
{
public SecondDemo(final String title)
{
super(title);
NumberAxis xAxis = new NumberAxis("time");
XYItemRenderer renderer;
TimeSeriesCollection tSeriesDataSet;
JFreeChart chart;
TimeSeries series;
final XYPlot xyplot;
tSeriesDataSet = new TimeSeriesCollection();
series = new TimeSeries(title);
// Second(int second, int minute, int hour, int day, int month, int year))
series.add(new Second(0, 1, 10, 4, 6, 2016), 1);
series.add(new Second(1, 1, 10, 4, 6, 2016), 1.1);
series.add(new Second(2, 1, 10, 4, 6, 2016), null);
series.add(new Second(3, 1, 10, 4, 6, 2016), 1.3);
series.add(new Second(4, 1, 10, 4, 6, 2016), 1.4);
series.add(new Second(5, 1, 10, 4, 6, 2016), 1.5);
series.add(new Second(6, 1, 10, 4, 6, 2016), 1.6);
series.add(new Second(7, 1, 10, 4, 6, 2016), 1.7);
series.add(new Second(8, 1, 10, 4, 6, 2016), 1.8);
tSeriesDataSet.addSeries(series);
chart = ChartFactory.createXYLineChart("Plot view", "A", "Time ", tSeriesDataSet, PlotOrientation.VERTICAL, true, true, false);
xyplot = (XYPlot) chart.getXYPlot();
xyplot.setBackgroundPaint(new Color(211,210,235));
xyplot.setRangeGridlinePaint(Color.black);
xyplot.setDomainCrosshairVisible(true);
xyplot.setRangeCrosshairVisible(true);
renderer = xyplot.getRenderer();
renderer.setSeriesPaint(0, Color.green);
renderer.setSeriesPaint(1, Color.blue);
renderer.setSeriesPaint(2, Color.red);
xyplot.setDomainAxis(new DateAxis());
DateAxis axis = (DateAxis) xyplot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));
/*range = (NumberAxis) xyplot.getRangeAxis();
range.setRange(-1.2, 1.2);
range.setTickUnit(new NumberTickUnit(0.1));*/
final ChartPanel chartPanel = new ChartPanel(chart);
setContentPane(chartPanel);
}
public static void main(String args[])
{
SecondDemo secondDemo = new SecondDemo("Second Demo");
secondDemo.pack();
secondDemo.setVisible(true);
}
}
Of course the arguments of the Second class will be from the file, for which I can retrieve the year, month and day from the filename.