Search in sources :

Example 1 with ElementSource

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

the class ChartSourceSelectPanel method changeSourceForTable.

private void changeSourceForTable() {
    Engine engine = framework.getEngine();
    QualifierSource source = chartSource.getQualifierSources().get(0);
    FilterSource source2 = source.getFilterSources().get(0);
    Element element = engine.getElement(Long.parseLong(source2.getValue()));
    source.setQualifier(engine.getQualifier(element.getQualifierId()));
    source.getElementSources().clear();
    ElementSource source3 = chartSource.createElementSource();
    source3.setElement(element);
    source.getElementSources().add(source3);
    source.getFilterSources().clear();
}
Also used : QualifierSource(com.ramussoft.chart.QualifierSource) FilterSource(com.ramussoft.chart.FilterSource) Element(com.ramussoft.common.Element) ElementSource(com.ramussoft.chart.ElementSource) Engine(com.ramussoft.common.Engine)

Example 2 with ElementSource

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

the class ChartSourceSelectPanel method save.

public void save() {
    if (qualifierSelectPanel != null)
        saveSelectedElements();
    chartSource.setProperty(SOURCE_TYPE, (sourceType.getSelectedItem().equals(sourceTypeElements)) ? SOURCE_TYPE_ELEMENTS : SOURCE_TYPE_TABLE);
    if (sourceType.getSelectedItem().equals(sourceTypeTable)) {
        if (chartSource.getQualifierSources().size() > 0) {
            QualifierSource source = chartSource.getQualifierSources().get(0);
            if (source.getElementSources().size() > 0) {
                ElementSource source2 = source.getElementSources().get(0);
                source.getFilterSources().clear();
                FilterSource filterSource = chartSource.createFilterSource();
                Attribute selectedItem = (Attribute) tableAttribute.getSelectedItem();
                if (selectedItem != null) {
                    filterSource.setAttribute(StandardAttributesPlugin.getTableElementIdAttribute(framework.getEngine()));
                    filterSource.setValue(Long.toString(source2.getElement().getId()));
                    source.getFilterSources().add(filterSource);
                    source.setQualifier(StandardAttributesPlugin.getTableQualifierForAttribute(framework.getEngine(), selectedItem));
                    source.setElementsLoadType(QualifierSource.ELEMENTS_LOAD_TYPE_ALL);
                }
            }
        }
    } else {
        for (QualifierSource source : chartSource.getQualifierSources()) source.setElementsLoadType(QualifierSource.ELEMENTS_LOAD_TYPE_SELECTED);
    }
}
Also used : QualifierSource(com.ramussoft.chart.QualifierSource) FilterSource(com.ramussoft.chart.FilterSource) Attribute(com.ramussoft.common.Attribute) ElementSource(com.ramussoft.chart.ElementSource)

Example 3 with ElementSource

use of com.ramussoft.chart.ElementSource 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 4 with ElementSource

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

the class QualifierSourceSelectPanel method save.

public void save() {
    List<ElementSource> elementSources = qualifierSource.getElementSources();
    elementSources.clear();
    for (Row row : view.getSelectedRows()) {
        ElementSource e = qualifierSource.getChartSource().createElementSource();
        e.setElement(row.getElement());
        elementSources.add(e);
    }
    qualifierSource.getChartSource().fireAttributeListChanged();
}
Also used : Row(com.ramussoft.database.common.Row) ElementSource(com.ramussoft.chart.ElementSource)

Aggregations

ElementSource (com.ramussoft.chart.ElementSource)4 FilterSource (com.ramussoft.chart.FilterSource)3 QualifierSource (com.ramussoft.chart.QualifierSource)3 Element (com.ramussoft.common.Element)2 ChartDataFramework (com.ramussoft.chart.ChartDataFramework)1 ChartDataPlugin (com.ramussoft.chart.ChartDataPlugin)1 ChartSource (com.ramussoft.chart.ChartSource)1 TableChartPersistent (com.ramussoft.chart.core.TableChartPersistent)1 Attribute (com.ramussoft.common.Attribute)1 Engine (com.ramussoft.common.Engine)1 Qualifier (com.ramussoft.common.Qualifier)1 Row (com.ramussoft.database.common.Row)1 AbstractAttributeEditor (com.ramussoft.gui.common.AbstractAttributeEditor)1 ArrayList (java.util.ArrayList)1 ChartPanel (org.jfree.chart.ChartPanel)1 JFreeChart (org.jfree.chart.JFreeChart)1