From 6dfb8710f53ebe0b999f1b474d5223e31cca8fe0 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Fri, 24 Oct 2014 13:13:02 +0000 Subject: [PATCH] Extend chart property options to select property tab visibility. fixes #5437 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30480 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../jfreechart/ChartPropertyOptions.java | 7 +- .../ChartSelectionTabContributor.java | 120 ++++++++++-------- 2 files changed, 69 insertions(+), 58 deletions(-) diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java index 4b6314ed..7fc2b604 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartPropertyOptions.java @@ -2,7 +2,10 @@ package org.simantics.jfreechart; public class ChartPropertyOptions { - public static final int SHOW_TIME = 1 << 0; - public static final int SHOW_FILTER = 1 << 1; + public static final int SHOW_TIME = 1 << 0; + public static final int SHOW_FILTER = 1 << 1; + public static final int SHOW_VARIABLES = 1 << 2; + public static final int SHOW_AXIS = 1 << 3; + public static final int SHOW_CHART = 1 << 4; } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java index df95e714..48033d84 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/ChartSelectionTabContributor.java @@ -24,7 +24,7 @@ import org.simantics.sysdyn.JFreeChartResource; public class ChartSelectionTabContributor { public static boolean contibuteTabs(ReadGraph backend, Resource r, List tabs) throws DatabaseException{ - return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME); + return contibuteTabs(backend, r, tabs, ChartPropertyOptions.SHOW_TIME|ChartPropertyOptions.SHOW_AXIS|ChartPropertyOptions.SHOW_VARIABLES|ChartPropertyOptions.SHOW_CHART); } public static boolean contibuteTabs(ReadGraph backend, Resource r, List tabs, int options) throws DatabaseException { JFreeChartResource jfree = JFreeChartResource.getInstance(backend); @@ -45,45 +45,49 @@ public class ChartSelectionTabContributor { 10, r, "General")); - tabs.add(new ComparableTabContributor( - new XYLineAxisAndVariablesTab(r), - 9, - r, - "Axis and Variables")); + if ((options&ChartPropertyOptions.SHOW_AXIS )>0 ||(options&ChartPropertyOptions.SHOW_VARIABLES)>0 ) + tabs.add(new ComparableTabContributor( + new XYLineAxisAndVariablesTab(r), + 9, + r, + "Axis and Variables")); } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) { tabs.add(new ComparableTabContributor( new BarGeneralPropertiesTab(r, options), 10, r, "General")); - tabs.add(new ComparableTabContributor( - new BarSeriesTab(r, options), - 9, - r, - "Variables")); - tabs.add(new ComparableTabContributor( - new BarAxisTab(r), - 8, - r, - "Axis")); + if ((options&ChartPropertyOptions.SHOW_VARIABLES )>0) + tabs.add(new ComparableTabContributor( + new BarSeriesTab(r, options), + 9, + r, + "Variables")); + if ((options&ChartPropertyOptions.SHOW_AXIS )>0) + tabs.add(new ComparableTabContributor( + new BarAxisTab(r), + 8, + r, + "Axis")); } else if(backend.isInstanceOf(plot, jfree.PiePlot)) { tabs.add(new ComparableTabContributor( new PieGeneralPropertiesTab(r, options), 10, r, "General")); - tabs.add(new ComparableTabContributor( - new PieSeriesTab(r, options), - 9, - r, - "Variables")); + if ((options&ChartPropertyOptions.SHOW_VARIABLES )>0) + tabs.add(new ComparableTabContributor( + new PieSeriesTab(r, options), + 9, + r, + "Variables")); } - - tabs.add(new ComparableTabContributor( - new ChartTab(r), - 1, - r, - "Chart")); + if ((options&ChartPropertyOptions.SHOW_CHART )>0) + tabs.add(new ComparableTabContributor( + new ChartTab(r), + 1, + r, + "Chart")); return true; } @@ -92,7 +96,7 @@ public class ChartSelectionTabContributor { } public static boolean contibuteTabs2(ReadGraph backend, Resource r, List tabs) throws DatabaseException{ - return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME); + return contibuteTabs2(backend, r, tabs, ChartPropertyOptions.SHOW_TIME|ChartPropertyOptions.SHOW_AXIS|ChartPropertyOptions.SHOW_VARIABLES|ChartPropertyOptions.SHOW_CHART); } public static boolean contibuteTabs2(ReadGraph backend, Resource r, List tabs, int options) throws DatabaseException { @@ -114,45 +118,49 @@ public class ChartSelectionTabContributor { 10, r, "General")); - tabs.add(new ComparableTabContributor( - new XYLineAxisAndVariablesTab(r), - 9, - r, - "Axis and Variables")); - } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) { - tabs.add(new ComparableTabContributor( + if ((options&ChartPropertyOptions.SHOW_AXIS )>0 ||(options&ChartPropertyOptions.SHOW_VARIABLES)>0 ) + tabs.add(new ComparableTabContributor( + new XYLineAxisAndVariablesTab(r), + 9, + r, + "Axis and Variables")); + } else if (backend.isInstanceOf(plot, jfree.CategoryPlot)) { + tabs.add(new ComparableTabContributor( new BarGeneralPropertiesTab(r, options), 10, r, "General")); - tabs.add(new ComparableTabContributor( - new BarSeriesTab2(r, options), - 9, - r, - "Variables")); - tabs.add(new ComparableTabContributor( - new BarAxisTab(r), - 8, - r, - "Axis")); + if ((options&ChartPropertyOptions.SHOW_VARIABLES)>0) + tabs.add(new ComparableTabContributor( + new BarSeriesTab2(r, options), + 9, + r, + "Variables")); + if ((options&ChartPropertyOptions.SHOW_AXIS )>0) + tabs.add(new ComparableTabContributor( + new BarAxisTab(r), + 8, + r, + "Axis")); } else if(backend.isInstanceOf(plot, jfree.PiePlot)) { tabs.add(new ComparableTabContributor( new PieGeneralPropertiesTab(r, options), 10, r, "General")); - tabs.add(new ComparableTabContributor( - new PieSeriesTab2(r, options), - 9, - r, - "Variables")); + if ((options&ChartPropertyOptions.SHOW_VARIABLES)>0) + tabs.add(new ComparableTabContributor( + new PieSeriesTab2(r, options), + 9, + r, + "Variables")); } - - tabs.add(new ComparableTabContributor( - new ChartTab(r), - 1, - r, - "Chart")); + if ((options&ChartPropertyOptions.SHOW_CHART )>0) + tabs.add(new ComparableTabContributor( + new ChartTab(r), + 1, + r, + "Chart")); return true; } -- 2.47.1