From 55180c48ff57fd860bc97e0221c29da3bc738c6a Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 26 Sep 2017 19:11:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=85=E9=93=BE=EF=BC=8C?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=B1=9E=E6=80=A7=E7=AD=89=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B1=9E=E6=80=A7=E5=93=8D=E5=BA=94=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E3=80=82=20=E4=BF=AE=E6=94=B9=E6=AD=A3=E5=9C=A8?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=B8=AD=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bubble/VanChartBubbleInteractivePane.java | 11 --- .../component/VanChartUIListControlPane.java | 67 +++++++++++++++++-- .../other/VanChartInteractivePane.java | 7 +- ...StructureIndependentVanChartInterface.java | 10 --- ...WordCloudIndependentVanChartInterface.java | 8 --- 5 files changed, 64 insertions(+), 39 deletions(-) diff --git a/designer_chart/src/com/fr/plugin/chart/bubble/VanChartBubbleInteractivePane.java b/designer_chart/src/com/fr/plugin/chart/bubble/VanChartBubbleInteractivePane.java index 4e4c9edab..706c0f3b0 100644 --- a/designer_chart/src/com/fr/plugin/chart/bubble/VanChartBubbleInteractivePane.java +++ b/designer_chart/src/com/fr/plugin/chart/bubble/VanChartBubbleInteractivePane.java @@ -1,14 +1,10 @@ package com.fr.plugin.chart.bubble; import com.fr.chart.chartattr.Plot; -import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.general.Inter; import com.fr.plugin.chart.base.VanChartConstants; -import com.fr.plugin.chart.designer.TableLayout4VanChartHelper; import com.fr.plugin.chart.designer.other.VanChartInteractivePaneWithOutSort; -import javax.swing.*; - /** * Created by Mitisky on 16/3/31. */ @@ -29,11 +25,4 @@ public class VanChartBubbleInteractivePane extends VanChartInteractivePaneWithOu return super.getValueArray(); } - @Override - protected JPanel getzoomTypePane(UIButtonGroup zoomType) { - if (((VanChartBubblePlot)chart.getPlot()).isForceBubble()) { - return TableLayout4VanChartHelper.createGapTableLayoutPane(Inter.getLocText("Plugin-ChartF_ZoomType"), zoomType); - } - return super.getzoomTypePane(zoomType); - } } diff --git a/designer_chart/src/com/fr/plugin/chart/designer/component/VanChartUIListControlPane.java b/designer_chart/src/com/fr/plugin/chart/designer/component/VanChartUIListControlPane.java index af9e13b35..00bd52a38 100644 --- a/designer_chart/src/com/fr/plugin/chart/designer/component/VanChartUIListControlPane.java +++ b/designer_chart/src/com/fr/plugin/chart/designer/component/VanChartUIListControlPane.java @@ -2,6 +2,8 @@ package com.fr.plugin.chart.designer.component; import com.fr.base.chart.BasePlot; import com.fr.chart.chartattr.Plot; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; import com.fr.design.gui.controlpane.UIListControlPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -16,6 +18,8 @@ import com.fr.plugin.chart.designer.TableLayout4VanChartHelper; import com.fr.stable.Nameable; import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -24,20 +28,71 @@ import java.awt.event.ActionListener; * Created by mengao on 2017/9/8. * 新图表UIListControlPane,基础面板。 */ -public abstract class VanChartUIListControlPane extends UIListControlPane { +public abstract class VanChartUIListControlPane extends UIListControlPane implements UIObserver { + private UIObserverListener uiObserverListener; + public VanChartUIListControlPane() { super(); this.setBorder(null); + iniListener(); } public VanChartUIListControlPane(BasePlot plot) { super(plot); this.setBorder(null); + iniListener(); + } + + /** + * 注册观察者监听事件 + * @param listener 观察者监听事件 + */ + @Override + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + private void iniListener() { + if (shouldResponseChangeListener()) { + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (uiObserverListener == null) { + return; + } + uiObserverListener.doChange(); + } + }); + } + } + + protected void fireChanged() { + Object[] listeners = listenerList.getListenerList(); + + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ChangeListener.class) { + ((ChangeListener) listeners[i + 1]).stateChanged(new ChangeEvent(this)); + } + } + + } + + /** + * 增加监听事件 + * @param l 监听的对象 + */ + public void addChangeListener(ChangeListener l) { + this.listenerList.add(ChangeListener.class, l); } @Override - protected JPanel getLeftTopPane (UIToolbar topToolBar) { + protected JPanel getLeftTopPane(UIToolbar topToolBar) { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; @@ -46,7 +101,7 @@ public abstract class VanChartUIListControlPane extends UIListControlPane { Component[][] components = new Component[][]{ new Component[]{new UILabel(getAddItemText()), topToolBar}, }; - return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } @Override @@ -55,7 +110,7 @@ public abstract class VanChartUIListControlPane extends UIListControlPane { return; } update((Plot) plot); - DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); + fireChanged();//图表属性改变,响应事件 } protected abstract void update(Plot plot); @@ -63,7 +118,7 @@ public abstract class VanChartUIListControlPane extends UIListControlPane { //-------------------连续弹窗问题 start-------------------// - public void populate (Nameable[] nameableArray) { + public void populate(Nameable[] nameableArray) { //特殊处理,使用instanceof判断,弹出不同的面板 if (SwingUtilities.getWindowAncestor(this) instanceof JDialog) { popupEditDialog = new HyperDialog(cardPane); @@ -113,7 +168,7 @@ public abstract class VanChartUIListControlPane extends UIListControlPane { //取消 addCancelButton(buttonsPane); - controlPane.setBorder(BorderFactory.createEmptyBorder(10,0,10,0)); + controlPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); return controlPane; } diff --git a/designer_chart/src/com/fr/plugin/chart/designer/other/VanChartInteractivePane.java b/designer_chart/src/com/fr/plugin/chart/designer/other/VanChartInteractivePane.java index 9c5b07d51..5e2b1fd9b 100644 --- a/designer_chart/src/com/fr/plugin/chart/designer/other/VanChartInteractivePane.java +++ b/designer_chart/src/com/fr/plugin/chart/designer/other/VanChartInteractivePane.java @@ -142,10 +142,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Inter.getLocText("Chart-Use_Zoom"), panel); } + protected JPanel getzoomTypePane(UIButtonGroup zoomType) { - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Inter.getLocText("Plugin-ChartF_ZoomType"), zoomType, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - panel.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); - return panel; + return TableLayout4VanChartHelper.createGapTableLayoutPane(Inter.getLocText("Plugin-ChartF_ZoomType"), zoomType); } protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) { @@ -245,7 +244,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private void checkZoomPane() { boolean zoomWidgetEnabled = zoomWidget.getSelectedIndex() == 0; changeEnablePane.setVisible(zoomWidgetEnabled); - zoomTypePane.setVisible(!zoomWidgetEnabled); + zoomType.setEnabled(!zoomWidgetEnabled); } @Override diff --git a/designer_chart/src/com/fr/plugin/chart/structure/desinger/StructureIndependentVanChartInterface.java b/designer_chart/src/com/fr/plugin/chart/structure/desinger/StructureIndependentVanChartInterface.java index 65725cf53..52eeda2ed 100644 --- a/designer_chart/src/com/fr/plugin/chart/structure/desinger/StructureIndependentVanChartInterface.java +++ b/designer_chart/src/com/fr/plugin/chart/structure/desinger/StructureIndependentVanChartInterface.java @@ -5,7 +5,6 @@ import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; @@ -14,7 +13,6 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.general.Inter; import com.fr.plugin.chart.base.VanChartConstants; -import com.fr.plugin.chart.designer.TableLayout4VanChartHelper; import com.fr.plugin.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.plugin.chart.designer.other.VanChartOtherPane; import com.fr.plugin.chart.designer.style.VanChartStylePane; @@ -25,8 +23,6 @@ import com.fr.plugin.chart.structure.desinger.style.VanChartStructureSeriesPane; import com.fr.plugin.chart.structure.desinger.type.VanChartStructureTypePane; import com.fr.plugin.chart.vanchart.AbstractIndependentVanChartUI; -import javax.swing.*; - /** * Created by shine on 2017/2/15. */ @@ -64,12 +60,6 @@ public class StructureIndependentVanChartInterface extends AbstractIndependentVa protected BasicBeanPane createInteractivePane() { return new VanChartInteractivePaneWithOutSort(){ - @Override - protected JPanel getzoomTypePane(UIButtonGroup zoomType) { - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Inter.getLocText("Plugin-ChartF_ZoomType"), zoomType); - return panel; - } - @Override protected String[] getNameArray() { return new String[]{Inter.getLocText("Plugin-ChartF_XYAxis"), Inter.getLocText("Chart-Use_None")}; diff --git a/designer_chart/src/com/fr/plugin/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java b/designer_chart/src/com/fr/plugin/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java index 5f7566081..2b5ad405a 100644 --- a/designer_chart/src/com/fr/plugin/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java +++ b/designer_chart/src/com/fr/plugin/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java @@ -6,7 +6,6 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; @@ -15,7 +14,6 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.general.Inter; import com.fr.plugin.chart.base.VanChartConstants; -import com.fr.plugin.chart.designer.TableLayout4VanChartHelper; import com.fr.plugin.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.plugin.chart.designer.other.VanChartOtherPane; import com.fr.plugin.chart.designer.style.VanChartStylePane; @@ -26,7 +24,6 @@ import com.fr.plugin.chart.wordcloud.designer.other.VanChartWordCloudConditionPa import com.fr.plugin.chart.wordcloud.designer.style.VanChartWordCloudSeriesPane; import com.fr.plugin.chart.wordcloud.designer.type.VanChartWordCloudTypePane; -import javax.swing.*; import java.util.List; /** @@ -87,11 +84,6 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa @Override protected BasicBeanPane createInteractivePane() { return new VanChartInteractivePaneWithOutSort(){ - @Override - protected JPanel getzoomTypePane(UIButtonGroup zoomType) { - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Inter.getLocText("Plugin-ChartF_ZoomType"), zoomType); - return panel; - } @Override protected String[] getNameArray() {