- static final private Color gridline_color = new Color(0, 0, 0);
- static final private Color border_color = new Color(255, 255, 255);
- static final private Color background_color = new Color(255, 255, 255);
-
- MicroData data;
-
- public JPanel panel() {
- return panel;
- }
-
- private MicroSeries addSeries(int index, String label, String units, Color color) {
- MicroSeries series = new MicroSeries(label, units, color);
- XYSeriesCollection dataset = new XYSeriesCollection(series);
-
- series.renderer.setPlot(plot);
- plot.setRangeAxis(index, series.axis);
- plot.setDataset(index, dataset);
- plot.setRenderer(index, series.renderer);
- plot.mapDatasetToRangeAxis(index, index);
- return series;
- }
-
- public void resetData() {
- heightSeries.clear();
- speedSeries.clear();
- accelSeries.clear();
- if (data != null) {
- for (MicroDataPoint point : data.points()) {
- heightSeries.add(point.time, AltosConvert.height.value(point.height));
- speedSeries.add(point.time, AltosConvert.speed.value(point.speed));
- accelSeries.add(point.time, AltosConvert.accel.value(point.accel));
- }
- }
- }
-
- public void setName (String name) {
- chart.setTitle(name);
- }
-
- public void setData (MicroData data) {
- this.data = data;
- if (data != null)
- setName(data.name);
- resetData();
- }
-
- public void units_changed(boolean imperial_units) {
- heightSeries.set_units(AltosConvert.height.show_units());
- speedSeries.set_units(AltosConvert.speed.show_units());
- accelSeries.set_units(AltosConvert.accel.show_units());
- resetData();
- }
-
- public MicroGraph() {
-
- xAxis = new NumberAxis("Time (s)");
-
- xAxis.setAutoRangeIncludesZero(true);
-
- plot = new XYPlot();
- plot.setDomainAxis(xAxis);
- plot.setOrientation(PlotOrientation.VERTICAL);
- plot.setDomainPannable(true);
- plot.setRangePannable(true);
-
- chart = new JFreeChart("Flight", JFreeChart.DEFAULT_TITLE_FONT,
- plot, true);
-
- ChartUtilities.applyCurrentTheme(chart);
-
- heightSeries = addSeries(0, "Height", AltosConvert.height.show_units(), height_color);
- speedSeries = addSeries(1, "Speed", AltosConvert.speed.show_units(), speed_color);
- accelSeries = addSeries(2, "Acceleration", AltosConvert.accel.show_units(), accel_color);
-
- plot.setDomainGridlinePaint(gridline_color);
- plot.setRangeGridlinePaint(gridline_color);
- plot.setBackgroundPaint(background_color);
- plot.setBackgroundAlpha((float) 1);