]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Extend chart property options to select property tab visibility.
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 24 Oct 2014 13:13:02 +0000 (13:13 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 24 Oct 2014 13:13:02 +0000 (13:13 +0000)
fixes #5437

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30480 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java
org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java

index 4b6314ed606b3c6b35d06454b6da4fd1dce0bce4..7fc2b604c57246208eaadb2eb3f7cc0fea8d2247 100644 (file)
@@ -2,7 +2,10 @@ package org.simantics.jfreechart;
 \r
 public class ChartPropertyOptions {\r
        \r
-       public static final int SHOW_TIME   = 1 << 0;\r
-       public static final int SHOW_FILTER = 1 << 1;\r
+       public static final int SHOW_TIME      = 1 << 0;\r
+       public static final int SHOW_FILTER    = 1 << 1;\r
+       public static final int SHOW_VARIABLES = 1 << 2;\r
+       public static final int SHOW_AXIS      = 1 << 3;\r
+       public static final int SHOW_CHART     = 1 << 4;\r
 \r
 }\r
index df95e7144a3e43bacf2771df66f9da31582b96b9..48033d846c50d5b1d298879138f11dd0f7a5dd77 100644 (file)
@@ -24,7 +24,7 @@ import org.simantics.sysdyn.JFreeChartResource;
 public class ChartSelectionTabContributor {\r
 \r
        public static boolean contibuteTabs(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException{\r
-               return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME);\r
+               return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME|ChartPropertyOptions.SHOW_AXIS|ChartPropertyOptions.SHOW_VARIABLES|ChartPropertyOptions.SHOW_CHART);\r
        }\r
        public static boolean contibuteTabs(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs, int options) throws DatabaseException {\r
                JFreeChartResource jfree = JFreeChartResource.getInstance(backend);\r
@@ -45,45 +45,49 @@ public class ChartSelectionTabContributor {
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new XYLineAxisAndVariablesTab(r),\r
-                             9,\r
-                             r,\r
-                             "Axis and Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_AXIS )>0 ||(options&ChartPropertyOptions.SHOW_VARIABLES)>0 )\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new XYLineAxisAndVariablesTab(r),\r
+                                    9,\r
+                                    r,\r
+                                    "Axis and Variables"));\r
                  } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
                              new BarGeneralPropertiesTab(r, options),\r
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new BarSeriesTab(r, options),\r
-                             9,\r
-                             r,\r
-                             "Variables"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new BarAxisTab(r),\r
-                             8,\r
-                             r,\r
-                             "Axis"));                        \r
+                     if ((options&ChartPropertyOptions.SHOW_VARIABLES )>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new BarSeriesTab(r, options),\r
+                                    9,\r
+                                    r,\r
+                                    "Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_AXIS )>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new BarAxisTab(r),\r
+                                    8,\r
+                                    r,\r
+                                    "Axis"));                        \r
                  } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
                              new PieGeneralPropertiesTab(r, options),\r
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new PieSeriesTab(r, options),\r
-                             9,\r
-                             r,\r
-                             "Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_VARIABLES )>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new PieSeriesTab(r, options),\r
+                                    9,\r
+                                    r,\r
+                                    "Variables"));\r
                  }\r
-\r
-                 tabs.add(new ComparableTabContributor(\r
-                         new ChartTab(r),\r
-                         1,\r
-                         r,\r
-                         "Chart"));\r
+                 if ((options&ChartPropertyOptions.SHOW_CHART )>0)\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new ChartTab(r),\r
+                                1,\r
+                                r,\r
+                                "Chart"));\r
                 \r
                  return true;\r
              } \r
@@ -92,7 +96,7 @@ public class ChartSelectionTabContributor {
        }\r
        \r
        public static boolean contibuteTabs2(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs) throws DatabaseException{\r
-               return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME);\r
+               return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME|ChartPropertyOptions.SHOW_AXIS|ChartPropertyOptions.SHOW_VARIABLES|ChartPropertyOptions.SHOW_CHART);\r
        }\r
        \r
        public static boolean contibuteTabs2(ReadGraph backend, Resource r, List<ComparableTabContributor> tabs, int options) throws DatabaseException {\r
@@ -114,45 +118,49 @@ public class ChartSelectionTabContributor {
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new XYLineAxisAndVariablesTab(r),\r
-                             9,\r
-                             r,\r
-                             "Axis and Variables"));\r
-                 } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
-                     tabs.add(new ComparableTabContributor(\r
+                     if ((options&ChartPropertyOptions.SHOW_AXIS )>0 ||(options&ChartPropertyOptions.SHOW_VARIABLES)>0 )\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new XYLineAxisAndVariablesTab(r),\r
+                                    9,\r
+                                    r,\r
+                                    "Axis and Variables"));\r
+                               } else if (backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
+                                       tabs.add(new ComparableTabContributor(\r
                              new BarGeneralPropertiesTab(r, options),\r
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new BarSeriesTab2(r, options),\r
-                             9,\r
-                             r,\r
-                             "Variables"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new BarAxisTab(r),\r
-                             8,\r
-                             r,\r
-                             "Axis"));                        \r
+                     if ((options&ChartPropertyOptions.SHOW_VARIABLES)>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new BarSeriesTab2(r, options),\r
+                                    9,\r
+                                    r,\r
+                                    "Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_AXIS )>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new BarAxisTab(r),\r
+                                    8,\r
+                                    r,\r
+                                    "Axis"));                        \r
                  } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
                      tabs.add(new ComparableTabContributor(\r
                              new PieGeneralPropertiesTab(r, options),\r
                              10,\r
                              r,\r
                              "General"));\r
-                     tabs.add(new ComparableTabContributor(\r
-                             new PieSeriesTab2(r, options),\r
-                             9,\r
-                             r,\r
-                             "Variables"));\r
+                     if ((options&ChartPropertyOptions.SHOW_VARIABLES)>0)\r
+                            tabs.add(new ComparableTabContributor(\r
+                                    new PieSeriesTab2(r, options),\r
+                                    9,\r
+                                    r,\r
+                                    "Variables"));\r
                  }\r
-\r
-                 tabs.add(new ComparableTabContributor(\r
-                         new ChartTab(r),\r
-                         1,\r
-                         r,\r
-                         "Chart"));\r
+                 if ((options&ChartPropertyOptions.SHOW_CHART )>0)\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new ChartTab(r),\r
+                                1,\r
+                                r,\r
+                                "Chart"));\r
                 \r
                  return true;\r
              } \r