Search in sources :

Example 1 with ChartSource

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

the class BarChartSetupEditor method createComponent.

@Override
public JComponent createComponent(GUIFramework framework, Element element) {
    JComponent component = super.createComponent(framework, element);
    initAttributes(framework.getEngine());
    ChartSource source = getChartSource();
    key.setSelectedItem(source.getAttributeProperty(BAR_ATTRIBUTE_KEY));
    double[][] size = { { 5, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL, 5 }, { 5, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, 5 } };
    TableLayout layout = new TableLayout(size);
    layout.setHGap(5);
    layout.setVGap(5);
    JPanel panel = new JPanel(layout);
    panel.add(new JLabel(ChartResourceManager.getString("Label.categoryAxis")), "1,1");
    panel.add(categoryAxis, "2,1");
    panel.add(new JLabel(ChartResourceManager.getString("Label.valueAxis")), "3,1");
    panel.add(valueAxis, "4,1");
    panel.add(new JLabel(ChartResourceManager.getString("Chart.key")), "1,2");
    panel.add(key, "2,2");
    panel.add(new JLabel(ChartResourceManager.getString("Orientation")), "3,2");
    panel.add(orientation, "4,2");
    panel.add(new JLabel(ChartResourceManager.getString("Chart.values")), "1,3,3,3");
    attributesSelectPanel = new AttributesSelectPanel(framework, source.getPropertyAttributes(BAR_ATTRIBUTE_VALUE_PREFIX));
    attributesSelectPanel.setPreferredSize(new Dimension(300, 150));
    JPanel panel3 = new JPanel(new BorderLayout());
    panel3.add(panel, BorderLayout.CENTER);
    panel3.add(attributesSelectPanel, BorderLayout.SOUTH);
    categoryAxis.setText(source.getProperty(BAR_CATEGORY_AXIS_LABEL));
    valueAxis.setText(source.getProperty(BAR_VALUE_AXIS_LABEL));
    String o = source.getProperty(BAR_ORIENTATION);
    if (BAR_ORIENTATION_HORIZONTAL.equals(o))
        orientation.setSelectedIndex(1);
    JPanel panel2 = new JPanel(new BorderLayout());
    panel2.add(component, BorderLayout.CENTER);
    panel2.add(panel3, BorderLayout.SOUTH);
    return panel2;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) ChartSource(com.ramussoft.chart.ChartSource) AttributesSelectPanel(com.ramussoft.gui.attribute.AttributesSelectPanel) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) TableLayout(info.clearthought.layout.TableLayout)

Example 2 with ChartSource

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

the class PieChartSetupEditor method save.

@Override
public void save(Element element) {
    ChartSource source = getChartSource();
    source.setAttributeProperty(PIE_ATTRIBUTE_KEY, ((Attribute) key.getSelectedItem()));
    source.setAttributeProperty(PIE_ATTRIBUTE_VALUE, ((Attribute) value.getSelectedItem()));
    super.save(element);
}
Also used : ChartSource(com.ramussoft.chart.ChartSource) Attribute(com.ramussoft.common.Attribute)

Example 3 with ChartSource

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

the class AbstractChartSetupEditor method createComponent.

@Override
public JComponent createComponent(GUIFramework framework, Element element) {
    this.framework = framework;
    ChartSource chartSource = new ChartSource(framework.getEngine());
    if (element != null) {
        Engine engine = framework.getEngine();
        chartSource.load(engine.getInputStream(getPreferencesPath(element, StandardAttributesPlugin.getAttributeNameAttribute(engine))));
    }
    component = new ChartSourceSelectPanel(framework, chartSource);
    return component;
}
Also used : ChartSource(com.ramussoft.chart.ChartSource) Engine(com.ramussoft.common.Engine)

Example 4 with ChartSource

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

the class TableChartAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor oldAttributeEditor) {
    return new AbstractAttributeEditor() {

        @Override
        public Object setValue(Object value) {
            return null;
        }

        @Override
        public Object getValue() {
            return null;
        }

        @Override
        public JComponent getComponent() {
            ChartDataFramework chartDataFramework = ChartDataFramework.getChartDataFramework(engine);
            ChartSource source = new ChartSource(engine) {

                @Override
                public List<Element> getElements() {
                    List<Element> res = new ArrayList<Element>();
                    for (QualifierSource source : qualifierSources) {
                        if (QualifierSource.ELEMENTS_LOAD_TYPE_ALL.equals(source.getElementsLoadType())) {
                            FilterSource filterSource = source.getFilterSources().get(0);
                            Qualifier qualifier = source.getQualifier();
                            if (StandardAttributesPlugin.isTableQualifier(qualifier) && filterSource.getAttribute().equals(StandardAttributesPlugin.getTableElementIdAttribute(engine))) {
                                res.addAll(StandardAttributesPlugin.getOrderedTableElements(engine, StandardAttributesPlugin.getAttributeForTable(engine, qualifier), element));
                            } else
                                res.addAll(engine.findElements(qualifier.getId(), filterSource.getAttribute(), Long.parseLong(filterSource.getValue())));
                        } else
                            for (ElementSource elementSource : source.getElementSources()) res.add(elementSource.getElement());
                    }
                    return res;
                }
            };
            TableChartPersistent tcp = (TableChartPersistent) engine.getAttribute(null, attribute);
            Element chartElement = engine.getElement(tcp.getOtherElementId());
            source.load(chartElement);
            ChartDataPlugin chartDataPlugin = chartDataFramework.getChartDataPlugin(source.getChartType());
            JFreeChart freeChart = chartDataPlugin.createChart(element, source);
            return new ChartPanel(freeChart);
        }
    };
}
Also used : FilterSource(com.ramussoft.chart.FilterSource) ChartPanel(org.jfree.chart.ChartPanel) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) ChartDataFramework(com.ramussoft.chart.ChartDataFramework) JFreeChart(org.jfree.chart.JFreeChart) QualifierSource(com.ramussoft.chart.QualifierSource) ChartDataPlugin(com.ramussoft.chart.ChartDataPlugin) AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) ChartSource(com.ramussoft.chart.ChartSource) TableChartPersistent(com.ramussoft.chart.core.TableChartPersistent) Qualifier(com.ramussoft.common.Qualifier) ElementSource(com.ramussoft.chart.ElementSource)

Example 5 with ChartSource

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

the class BarChartSetupEditor method save.

@Override
public void save(Element element) {
    ChartSource source = getChartSource();
    source.setAttributeProperty(BAR_ATTRIBUTE_KEY, ((Attribute) key.getSelectedItem()));
    source.setPropertyAttributes(BAR_ATTRIBUTE_VALUE_PREFIX, attributesSelectPanel.getAttributes());
    source.setProperty(BAR_CATEGORY_AXIS_LABEL, categoryAxis.getText());
    source.setProperty(BAR_VALUE_AXIS_LABEL, valueAxis.getText());
    source.setProperty(BAR_ORIENTATION, (orientation.getSelectedIndex() == 0) ? BAR_ORIENTATION_VERTICAL : BAR_ORIENTATION_HORIZONTAL);
    super.save(element);
}
Also used : ChartSource(com.ramussoft.chart.ChartSource) Attribute(com.ramussoft.common.Attribute)

Aggregations

ChartSource (com.ramussoft.chart.ChartSource)7 Attribute (com.ramussoft.common.Attribute)2 TableLayout (info.clearthought.layout.TableLayout)2 BorderLayout (java.awt.BorderLayout)2 JComponent (javax.swing.JComponent)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 ChartDataFramework (com.ramussoft.chart.ChartDataFramework)1 ChartDataPlugin (com.ramussoft.chart.ChartDataPlugin)1 ElementSource (com.ramussoft.chart.ElementSource)1 FilterSource (com.ramussoft.chart.FilterSource)1 QualifierSource (com.ramussoft.chart.QualifierSource)1 TableChartPersistent (com.ramussoft.chart.core.TableChartPersistent)1 Element (com.ramussoft.common.Element)1 Engine (com.ramussoft.common.Engine)1 Qualifier (com.ramussoft.common.Qualifier)1 AttributesSelectPanel (com.ramussoft.gui.attribute.AttributesSelectPanel)1 AbstractAttributeEditor (com.ramussoft.gui.common.AbstractAttributeEditor)1 Dimension (java.awt.Dimension)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1