1 package org.simantics.jfreechart;
\r
3 import java.util.Collection;
\r
4 import java.util.List;
\r
6 import org.simantics.db.ReadGraph;
\r
7 import org.simantics.db.Resource;
\r
8 import org.simantics.db.common.request.ObjectsWithType;
\r
9 import org.simantics.db.exception.DatabaseException;
\r
10 import org.simantics.jfreechart.chart.properties.ChartTab;
\r
11 import org.simantics.jfreechart.chart.properties.bar.BarAxisTab;
\r
12 import org.simantics.jfreechart.chart.properties.bar.BarGeneralPropertiesTab;
\r
13 import org.simantics.jfreechart.chart.properties.bar.BarSeriesTab;
\r
14 import org.simantics.jfreechart.chart.properties.bar.BarSeriesTab2;
\r
15 import org.simantics.jfreechart.chart.properties.pie.PieGeneralPropertiesTab;
\r
16 import org.simantics.jfreechart.chart.properties.pie.PieSeriesTab;
\r
17 import org.simantics.jfreechart.chart.properties.pie.PieSeriesTab2;
\r
18 import org.simantics.jfreechart.chart.properties.xyline.XYLineAxisAndVariablesTab;
\r
19 import org.simantics.jfreechart.chart.properties.xyline.XYLineGeneralPropertiesTab;
\r
20 import org.simantics.layer0.Layer0;
\r
21 import org.simantics.selectionview.ComparableTabContributor;
\r
22 import org.simantics.sysdyn.JFreeChartResource;
\r
24 public class ChartSelectionTabContributor {
\r
27 public static boolean contibuteTabs(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException {
\r
28 JFreeChartResource jfree = JFreeChartResource.getInstance(backend);
\r
29 if(backend.isInstanceOf(r, jfree.ChartElement)) {
\r
30 if(backend.hasStatement(r, jfree.ChartElement_component))
\r
31 r = backend.getSingleObject(r, jfree.ChartElement_component);
\r
34 if (backend.isInstanceOf(r, jfree.Chart)) {
\r
36 Collection<Resource> plots = backend.syncRequest(new ObjectsWithType(r, Layer0.getInstance(backend).ConsistsOf, jfree.Plot));
\r
37 if(!plots.isEmpty()) {
\r
38 Resource plot = plots.iterator().next();
\r
40 if(backend.isInstanceOf(plot, jfree.XYPlot)) {
\r
41 tabs.add(new ComparableTabContributor(
\r
42 new XYLineGeneralPropertiesTab(),
\r
46 tabs.add(new ComparableTabContributor(
\r
47 new XYLineAxisAndVariablesTab(),
\r
50 "Axis and Variables"));
\r
51 } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {
\r
52 tabs.add(new ComparableTabContributor(
\r
53 new BarGeneralPropertiesTab(),
\r
57 tabs.add(new ComparableTabContributor(
\r
62 tabs.add(new ComparableTabContributor(
\r
67 } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {
\r
68 tabs.add(new ComparableTabContributor(
\r
69 new PieGeneralPropertiesTab(),
\r
73 tabs.add(new ComparableTabContributor(
\r
80 tabs.add(new ComparableTabContributor(
\r
92 public static boolean contibuteTabs2(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException {
\r
93 JFreeChartResource jfree = JFreeChartResource.getInstance(backend);
\r
94 if(backend.isInstanceOf(r, jfree.ChartElement)) {
\r
95 if(backend.hasStatement(r, jfree.ChartElement_component))
\r
96 r = backend.getSingleObject(r, jfree.ChartElement_component);
\r
99 if (backend.isInstanceOf(r, jfree.Chart)) {
\r
101 Collection<Resource> plots = backend.syncRequest(new ObjectsWithType(r, Layer0.getInstance(backend).ConsistsOf, jfree.Plot));
\r
102 if(!plots.isEmpty()) {
\r
103 Resource plot = plots.iterator().next();
\r
105 if(backend.isInstanceOf(plot, jfree.XYPlot)) {
\r
106 tabs.add(new ComparableTabContributor(
\r
107 new XYLineGeneralPropertiesTab(),
\r
111 tabs.add(new ComparableTabContributor(
\r
112 new XYLineAxisAndVariablesTab(),
\r
115 "Axis and Variables"));
\r
116 } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {
\r
117 tabs.add(new ComparableTabContributor(
\r
118 new BarGeneralPropertiesTab(),
\r
122 tabs.add(new ComparableTabContributor(
\r
123 new BarSeriesTab2(),
\r
127 tabs.add(new ComparableTabContributor(
\r
132 } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {
\r
133 tabs.add(new ComparableTabContributor(
\r
134 new PieGeneralPropertiesTab(),
\r
138 tabs.add(new ComparableTabContributor(
\r
139 new PieSeriesTab2(),
\r
145 tabs.add(new ComparableTabContributor(
\r