/*
* Copyright 2013 Serdar.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.fub.maps.gpx.analysis.ui.charts;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.geom.Ellipse2D;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.openide.util.NbBundle;
/**
*
* @author Serdar
*/
public class LineChart extends javax.swing.JPanel {
private static final String CHART_NAME = "BaseSeries";
private static final long serialVersionUID = 1L;
private final XYSeriesCollection dataset = new XYSeriesCollection(new XYSeries(CHART_NAME));
private final JFreeChart chart;
private final XYPlot plot;
private final ChartPanel chartPanel;
/**
* Creates new form LineChart
*/
public LineChart() {
initComponents();
chart = ChartFactory.createXYLineChart(
null,
NbBundle.getMessage(LineChart.class, "LineChart.Domain.Name"),
NbBundle.getMessage(LineChart.class, "LineCHart.Value.Name"),
dataset,
PlotOrientation.VERTICAL,
false,
true,
true);
plot = chart.getXYPlot();
plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
plot.setBackgroundPaint(Color.white);
plot.getRenderer(0).setSeriesPaint(0, Color.BLUE);
plot.getRenderer(0).setSeriesShape(0, new Ellipse2D.Double(0, 0, 2, 2));
plot.getRenderer(0).setBaseShape(new Ellipse2D.Double(0, 0, 2, 2));
chartPanel = new ChartPanel(chart, false);
add(chartPanel, BorderLayout.CENTER);
}
public XYSeries getDataset() {
return dataset.getSeries(CHART_NAME);
}
public JFreeChart getChart() {
return chart;
}
public XYPlot getPlot() {
return plot;
}
public ChartPanel getChartPanel() {
return chartPanel;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setLayout(new java.awt.BorderLayout());
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}