diff --git a/designer_base/src/com/fr/design/layout/TableLayoutHelper.java b/designer_base/src/com/fr/design/layout/TableLayoutHelper.java index 97dcf816b..b15aa99ba 100644 --- a/designer_base/src/com/fr/design/layout/TableLayoutHelper.java +++ b/designer_base/src/com/fr/design/layout/TableLayoutHelper.java @@ -47,6 +47,40 @@ public class TableLayoutHelper { return createCommonTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM); } + /** + * 标题布局(二级菜单距左边框46) + * @param title 标题 + * @param component 组件 + * @return 布局好的组件 + */ + public static JPanel createTableLayoutPaneWithTitle(String title, Component component){ + return createTitlePane(title, component, LayoutConstants.CHART_ATTR_TOMARGIN); + } + + public static JPanel createTitlePane(String title, Component component, int gap){ + return createTitlePaneWithUILabel(new UILabel(title), component, gap); + } + + /** + * 标题布局(指定gap) + * @param label 标题label + * @param component 组件 + * @param gap 距左侧距离 + * @return 布局好的组件 + */ + public static JPanel createTitlePaneWithUILabel(UILabel label, Component component, int gap){ + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {gap, f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + new Component[]{label,null}, + new Component[]{null,component}, + }; + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + + public static JPanel createCommonTableLayoutPane(Component[][] components, double[] rowSize, double[] columnSize, double gap) { return createGapTableLayoutPane(components, rowSize, columnSize, gap, gap); diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index 866d03966..1909c947c 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -284,7 +284,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); String chartID = (String) entry.getKey(); - return getChartDataPane(chartID, plotID, listener); + if (plotInChart(plotID, chartID)) { + return getChartDataPane(chartID, plotID, listener); + } } return getChartDataPane(DEFAULT_CHART_ID, plotID, listener); } @@ -310,7 +312,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); String chartID = (String) entry.getKey(); - return getAttrPaneArray(chartID, plotID, listener); + if (plotInChart(plotID, chartID)) { + return getAttrPaneArray(chartID, plotID, listener); + } } return getAttrPaneArray(DEFAULT_CHART_ID, plotID, listener); } @@ -324,7 +328,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); String chartID = (String) entry.getKey(); - return getTableDataSourcePane(chartID, plot, parent); + if (plotInChart(plot.getPlotID(), chartID)) { + return getTableDataSourcePane(chartID, plot, parent); + } } return getTableDataSourcePane(DEFAULT_CHART_ID, plot, parent); } @@ -339,11 +345,20 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); String chartID = (String) entry.getKey(); - return getReportDataSourcePane(chartID, plot, parent); + String plotID = plot.getPlotID(); + if (plotInChart(plotID, chartID)) { + return getReportDataSourcePane(chartID, plot, parent); + } } return getReportDataSourcePane(DEFAULT_CHART_ID, plot, parent); } + private boolean plotInChart(String plotID, String chartID) { + return chartTypeInterfaces != null + && chartTypeInterfaces.containsKey(chartID) + && chartTypeInterfaces.get(chartID).containsKey(plotID); + } + private AbstractReportDataContentPane getReportDataSourcePane(String chartID, Plot plot, ChartDataPane parent) { return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getReportDataSourcePane(plot, parent); } @@ -354,7 +369,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); String chartID = (String) entry.getKey(); - return getPlotConditionPane(chartID, plot); + if (plotInChart(plot.getPlotID(), chartID)) { + return getPlotConditionPane(chartID, plot); + } } return getPlotConditionPane(DEFAULT_CHART_ID, plot); } @@ -369,7 +386,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); String chartID = (String) entry.getKey(); - return getPlotSeriesPane(chartID, parent, plot); + if (plotInChart(plot.getPlotID(), chartID)) { + return getPlotSeriesPane(chartID, parent, plot); + } } return getPlotSeriesPane(DEFAULT_CHART_ID, parent, plot); } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java new file mode 100644 index 000000000..89e5e5719 --- /dev/null +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java @@ -0,0 +1,209 @@ +package com.fr.design.mainframe.chart.gui; + +/** + * Created by hufan on 2016/10/20. + */ + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.change.ChangeConfigAttr; +import com.fr.chart.chartglyph.ChangeType; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.general.Inter; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 图表切换设置面板 + */ +public class ChangeConfigPane extends BasicBeanPane { + private static final int WIDTH = 100; + private static final int MIN_TIME = 0; + private static final int MAX_TIME = Integer.MAX_VALUE; + private JPanel contentPane; + //配置方式按钮 + private UIButtonGroup configStyleButton; + //配置界面 + private JPanel configPane; + //按钮切换方式配置界面 + private JPanel buttonConfigPane; + private ChartTextAttrPane styleAttrPane; + private ColorSelectBoxWithOutTransparent colorSelectBox4button; + + //轮播切换方式配置接界面 + private JPanel carouselConfigPane; + protected UISpinner timeInterval; + private ColorSelectBoxWithOutTransparent colorSelectBox4carousel; + + public ChangeConfigPane(){ + initButtonGroup(); + configPane = createConfigPane(); + contentPane = createContentPane(); + contentPane.setBorder(BorderFactory.createEmptyBorder(10, 30, 10, 30)); + this.add(contentPane, BorderLayout.CENTER); + } + + private JPanel createContentPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p,p,p,p}; + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("Plugin-ChartF_Change_Style") + ":"),configStyleButton}, + new Component[]{null, null}, + new Component[]{new JSeparator(), null}, + new Component[]{configPane, null}, + }; + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + + private JPanel createConfigPane() { + + buttonConfigPane = createButtonConfigPane(); + carouselConfigPane = createCarouseConfigPane(); + + JPanel panel = new JPanel(new CardLayout()){ + @Override + public Dimension getPreferredSize() { + if(configStyleButton.getSelectedIndex() == 0){ + return buttonConfigPane.getPreferredSize(); + } else{ + return carouselConfigPane.getPreferredSize(); + } + } + }; + + panel.add(buttonConfigPane, "button"); + panel.add(carouselConfigPane, "carousel"); + + return panel; + } + + private JPanel createCarouseConfigPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p,p,p}; + Component[][] components = new Component[][]{ + new Component[]{createTimeIntervalPane(),null}, + new Component[]{new JSeparator(),null}, + new Component[]{createCarouseBackgroundColorPane(),null}, + }; + + return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + } + + private Component createTimeIntervalPane() { + timeInterval = new UISpinner(MIN_TIME, MAX_TIME, 1, 0); + return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("Plugin-ChartF_Time_Interval") + ":", timeInterval); + } + + private JPanel createCarouseBackgroundColorPane() { + colorSelectBox4carousel = new ColorSelectBoxWithOutTransparent(WIDTH); + return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("Background") + ":", colorSelectBox4carousel); + } + + private JPanel createTitleStylePane(){ + styleAttrPane = new ChartTextAttrPane(); + styleAttrPane.setPreferredSize(new Dimension(WIDTH, (int) styleAttrPane.getPreferredSize().getHeight())); + return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style")+":", styleAttrPane); + } + + + private JPanel createButtonBackgroundColorPane(){ + colorSelectBox4button = new ColorSelectBoxWithOutTransparent(WIDTH); + return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("Background") + ":", colorSelectBox4button); + } + + private JPanel createButtonConfigPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p,p,p}; + Component[][] components = new Component[][]{ + new Component[]{createTitleStylePane(),null}, + new Component[]{new JSeparator(),null}, + new Component[]{createButtonBackgroundColorPane(),null}, + }; + + return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + } + + private void initButtonGroup() { + configStyleButton = new UIButtonGroup(new String[]{Inter.getLocText("Plugin-ChartF_Button_Style"), + Inter.getLocText("Plugin-ChartF_Carousel_Style")}); + configStyleButton.setPreferredSize(new Dimension(WIDTH * 2, (int) configStyleButton.getPreferredSize().getHeight())); + configStyleButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkCardPane(); + } + }); + } + + private void checkCardPane() { + CardLayout cardLayout = (CardLayout) configPane.getLayout(); + if (configStyleButton.getSelectedIndex() == 0) { + cardLayout.show(configPane, "button"); + } else { + cardLayout.show(configPane, "carousel"); + } + } + + @Override + public void populateBean(ChartCollection ob) { + if (ob == null){ + return; + } + ChangeConfigAttr changeConfigAttr = ob.getChangeConfigAttr(); + if (changeConfigAttr == null){ + return; + } + configStyleButton.setSelectedIndex(changeConfigAttr.getChangeType() == ChangeType.BUTTON ? 0 : 1); + + //按钮切换界面 + styleAttrPane.populate(changeConfigAttr.getStyleAttr()); + colorSelectBox4button.setSelectObject(changeConfigAttr.getButtonColor()); + + //轮播切换界面 + timeInterval.setValue(changeConfigAttr.getTimeInterval()); + colorSelectBox4carousel.setSelectObject(changeConfigAttr.getCarouselColor()); + + checkCardPane(); + + } + + @Override + public ChartCollection updateBean() { + return null; + } + + public void updateBean(ChartCollection ob) { + if (ob == null){ + return; + } + ChangeConfigAttr changeConfigAttr = ob.getChangeConfigAttr(); + if (changeConfigAttr == null){ + return; + } + + changeConfigAttr.setChangeType(configStyleButton.getSelectedIndex() == 0 ? ChangeType.BUTTON : ChangeType.CAROUSEL); + changeConfigAttr.setStyleAttr(styleAttrPane.update()); + changeConfigAttr.setButtonColor(colorSelectBox4button.getSelectObject()); + changeConfigAttr.setTimeInterval(timeInterval.getValue()); + changeConfigAttr.setCarouselColor(colorSelectBox4carousel.getSelectObject()); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("Chart-Change_Config_Attributes"); + } +} diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index aeb9cb0d9..fceb0500f 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -4,13 +4,16 @@ import com.fr.base.BaseUtils; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.SwitchState; -import com.fr.chart.charttypes.ColumnIndependentChart; +import com.fr.chart.chartattr.change.ChangeConfigAttr; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.DialogActionListener; +import com.fr.design.dialog.UIDialog; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.imenutable.UIMenuNameableCreator; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane; import com.fr.general.ComparatorUtils; @@ -34,6 +37,8 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private static final int B_W = 52; private static final int B_H = 20; private static final int COL_COUNT = 3; + private static final int P_W = 300; + private static final int P_H = 400; private UIButton addButton; private UIButton configButton; @@ -47,8 +52,12 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private ChartTypePane parent = null; + //记录鼠标当前是否在操作添加按钮 private boolean mouseOnChartTypeButtonPane = false; + //配置窗口属性 + private UIMenuNameableCreator configCreator; + /** * 鼠标事件是否在这个面板 * @return 返回是否 @@ -98,10 +107,26 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen button.add(configButton); eastPane.add(button, BorderLayout.NORTH); + initAddButton(); + initConfigButton(); + initConfigCreator(); + + Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + } + + private void initConfigCreator() { + configCreator = new UIMenuNameableCreator(Inter.getLocText("Chart-Change_Config_Attributes"), new ChangeConfigAttr(), ChangeConfigPane.class); + } + + private void initAddButton() { addButton.setPreferredSize(new Dimension(20, 20)); addButton.addActionListener(addListener); addButton.addMouseListener(mouseListener); - Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + } + + private void initConfigButton() { + configButton.setPreferredSize(new Dimension(20, 20)); + configButton.addActionListener(configListener); } ActionListener addListener = new ActionListener() { @@ -125,17 +150,43 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } catch (CloneNotSupportedException e1) { FRLogger.getLogger().error("Error in Clone"); } - //获取图表收集器的状态 - SwitchState state = editingCollection.calculateMultiChartMode(); - if (state.isDynamicState() && parent != null){ - parent.reactorChartTypePane(editingCollection); - } - + checkoutChange(); } layoutPane(buttonPane); } }; + //获取图表收集器的状态 + private void checkoutChange(){ + SwitchState state = editingCollection.calculateMultiChartMode(); + if (state.isDynamicState() && parent != null){ + parent.reactorChartTypePane(editingCollection); + } + } + + ActionListener configListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + UIMenuNameableCreator ui = configCreator.clone(); + final BasicBeanPane pane = ui.getPane(); + pane.populateBean(editingCollection); + UIDialog dialog = pane.showUnsizedWindow(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionListener() { + @Override + public void doOk() { + pane.updateBean(editingCollection); + } + + @Override + public void doCancel() { + + } + }); + dialog.setSize(P_W, P_H); + dialog.setVisible(true); + } + }; + + MouseListener mouseListener = new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { @@ -268,6 +319,8 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen layoutPane(buttonPane); checkConfigButtonVisible(); + //更新切换面板 + checkoutChange(); } private void checkConfigButtonVisible() { @@ -396,10 +449,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } //获取图表收集器的状态 - SwitchState state = editingCollection.calculateMultiChartMode(); - if (state.isDynamicState() && parent != null){ - parent.reactorChartTypePane(editingCollection); - } + checkoutChange(); relayoutPane(); } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java new file mode 100644 index 000000000..ba0b03241 --- /dev/null +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java @@ -0,0 +1,20 @@ +package com.fr.design.mainframe.chart.gui; + +import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.style.color.ColorSelectPane; + +/** + * Created by Fangjie on 2016/4/8. + * 没有透明度的颜色选择器 + */ +public class ColorSelectBoxWithOutTransparent extends ColorSelectBox { + public ColorSelectBoxWithOutTransparent(int preferredWidth){ + super(preferredWidth); + } + + + @Override + protected ColorSelectPane getColorSelectPane(){ + return new ColorSelectPaneWithOutTransparent(); + } +} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java new file mode 100644 index 000000000..a32d5d929 --- /dev/null +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java @@ -0,0 +1,33 @@ +package com.fr.design.mainframe.chart.gui; + +import com.fr.chart.base.ChartConstants; +import com.fr.design.style.color.ColorCell; +import com.fr.design.style.color.ColorSelectPane; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by Fangjie on 2016/4/8. + */ +public class ColorSelectPaneWithOutTransparent extends ColorSelectPane { + + public ColorSelectPaneWithOutTransparent(){ + super(false); + } + + public void initCenterPaneChildren(JPanel centerPane) { + JPanel menuColorPane1 = new JPanel(); + centerPane.add(menuColorPane1); + menuColorPane1.setLayout(new GridLayout(5, 8, 5, 5)); + for (int i = 0; i < ChartConstants.MAP_COLOR_ARRAY.length; i++) { + menuColorPane1.add(new ColorCell(ChartConstants.MAP_COLOR_ARRAY[i], this)); + } + centerPane.add(Box.createVerticalStrut(5)); + centerPane.add(new JSeparator()); + } + + protected Color[] getColorArray(){ + return ChartConstants.MAP_COLOR_ARRAY; + } +}