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;
}
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);
}
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;
}
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);
}
};
}
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);
}
Aggregations