Search in sources :

Example 1 with ChartNotSetupedException

use of com.ramussoft.chart.exception.ChartNotSetupedException in project ramus by Vitaliy-Yakovchuk.

the class PieChartDataPlugin method createChart.

@Override
public JFreeChart createChart(Element element, ChartSource source) {
    Attribute key = source.getAttributeProperty(PIE_ATTRIBUTE_KEY);
    Attribute value = source.getAttributeProperty(PIE_ATTRIBUTE_VALUE);
    if ((key == null) || (value == null))
        throw new ChartNotSetupedException();
    DefaultPieDataset dataset = new DefaultPieDataset();
    for (Element element2 : source.getElements()) {
        Object v1 = engine.getAttribute(element2, key);
        Object v2 = engine.getAttribute(element2, value);
        if ((v1 != null) && (v2 != null))
            dataset.setValue(toString(v1), toDouble(v2));
    }
    return ChartFactory.createPieChart(element.getName(), dataset, true, true, false);
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ChartNotSetupedException(com.ramussoft.chart.exception.ChartNotSetupedException)

Example 2 with ChartNotSetupedException

use of com.ramussoft.chart.exception.ChartNotSetupedException in project ramus by Vitaliy-Yakovchuk.

the class ChartView method createComponent.

@Override
public JComponent createComponent() {
    ChartDataPlugin plugin = chartDataFramework.getChartDataPlugin(chartSource.getChartType());
    try {
        chartPanel = new ChartPanel(plugin.createChart(element));
        chartPanel.setPopupMenu(null);
    } catch (ChartNotSetupedException e) {
        JOptionPane.showMessageDialog(framework.getMainFrame(), ChartResourceManager.getString("Error.chartNotSetuped"));
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                close();
            }
        });
        return new JPanel();
    }
    return chartPanel;
}
Also used : ChartDataPlugin(com.ramussoft.chart.ChartDataPlugin) JPanel(javax.swing.JPanel) ChartPanel(org.jfree.chart.ChartPanel) ChartNotSetupedException(com.ramussoft.chart.exception.ChartNotSetupedException)

Example 3 with ChartNotSetupedException

use of com.ramussoft.chart.exception.ChartNotSetupedException in project ramus by Vitaliy-Yakovchuk.

the class ChartView method reload.

protected void reload() {
    try {
        ChartDataPlugin plugin = chartDataFramework.getChartDataPlugin(chartSource.getChartType());
        chartPanel.setChart(plugin.createChart(element));
    } catch (ChartNotSetupedException e) {
        close();
        JOptionPane.showMessageDialog(framework.getMainFrame(), ChartResourceManager.getString("Error.chartNotSetuped"));
    }
}
Also used : ChartDataPlugin(com.ramussoft.chart.ChartDataPlugin) ChartNotSetupedException(com.ramussoft.chart.exception.ChartNotSetupedException)

Aggregations

ChartNotSetupedException (com.ramussoft.chart.exception.ChartNotSetupedException)3 ChartDataPlugin (com.ramussoft.chart.ChartDataPlugin)2 Attribute (com.ramussoft.common.Attribute)1 Element (com.ramussoft.common.Element)1 JPanel (javax.swing.JPanel)1 ChartPanel (org.jfree.chart.ChartPanel)1 DefaultPieDataset (org.jfree.data.general.DefaultPieDataset)1