Browse Source

CHART-10225 图表缩放 兼容

persist/11.0
zheng 5 years ago
parent
commit
5114201a35
  1. 15
      designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java
  2. 9
      designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java
  3. 29
      designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleInteractivePane.java
  4. 6
      designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java
  5. 173
      designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java
  6. 14
      designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java
  7. 47
      designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/MapZoomPane.java
  8. 224
      designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java
  9. 17
      designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPaneWithOutMode.java
  10. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java
  11. 8
      designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java
  12. 15
      designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java
  13. 26
      designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java
  14. 13
      designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java

15
designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java

@ -1,5 +1,6 @@
package com.fr.van.chart.bar;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.condition.ConditionAttributesPane;
@ -9,7 +10,9 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.van.chart.column.VanChartColumnConditionPane;
import com.fr.van.chart.column.VanChartColumnSeriesPane;
import com.fr.van.chart.designer.other.VanChartInteractivePane;
import com.fr.van.chart.designer.other.VanChartOtherPane;
import com.fr.van.chart.designer.other.zoom.ZoomPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI;
@ -41,7 +44,17 @@ public class BarIndependentVanChartInterface extends AbstractMultiCategoryVanCha
*/
public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){
VanChartStylePane stylePane = new VanChartBarStylePane(listener);
VanChartOtherPane otherPane = new VanChartOtherPane();
VanChartOtherPane otherPane = new VanChartOtherPane() {
@Override
protected BasicBeanPane<Chart> createInteractivePane() {
return new VanChartInteractivePane() {
@Override
protected ZoomPane createZoomPane() {
return new ZoomPane();
}
};
}
};
return new AbstractChartAttrPane[]{stylePane, otherPane};
}

9
designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java

@ -14,7 +14,9 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.plugin.chart.bubble.VanChartBubblePlot;
import com.fr.van.chart.bubble.data.VanChartBubblePlotTableDataContentPane;
import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort;
import com.fr.van.chart.designer.other.VanChartOtherPane;
import com.fr.van.chart.designer.other.zoom.ZoomPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI;
@ -70,7 +72,12 @@ public class BubbleIndependentVanChartInterface extends AbstractIndependentVanCh
VanChartStylePane stylePane = new VanChartBubbleStylePane(listener);
VanChartOtherPane otherPane = new VanChartOtherPane(){
protected BasicBeanPane<Chart> createInteractivePane() {
return new VanChartBubbleInteractivePane();
return new VanChartInteractivePaneWithOutSort() {
@Override
protected ZoomPane createZoomPane() {
return new ZoomPane();
}
};
}
};
return new AbstractChartAttrPane[]{stylePane, otherPane};

29
designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleInteractivePane.java

@ -1,29 +0,0 @@
package com.fr.van.chart.bubble;
import com.fr.chart.chartattr.Plot;
import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.plugin.chart.bubble.VanChartBubblePlot;
import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort;
/**
* Created by Mitisky on 16/3/31.
*/
public class VanChartBubbleInteractivePane extends VanChartInteractivePaneWithOutSort {
protected String[] getNameArray() {
Plot plot = chart.getPlot();
if(plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) {
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")};
}
return super.getNameArray();
}
protected String[] getValueArray() {
Plot plot = chart.getPlot();
if(plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) {
return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE};
}
return super.getValueArray();
}
}

6
designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java

@ -6,10 +6,9 @@ import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.ConditionCollection;
import com.fr.chartx.attr.ZoomAttribute;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.base.VanChartZoom;
import com.fr.plugin.chart.bubble.BubbleIndependentVanChart;
import com.fr.plugin.chart.bubble.VanChartBubblePlot;
import com.fr.plugin.chart.scatter.attr.ScatterAttrLabel;
@ -145,8 +144,7 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane {
*/
@Override
protected void resetChartAttr4SamePlot(Chart chart){
VanChartZoom vanChartZoom = new VanChartZoom();
((VanChart)chart).setVanChartZoom(vanChartZoom);
((VanChart) chart).setZoomAttribute(new ZoomAttribute());
//重置监控刷新选项
resetRefreshMoreLabelAttr((VanChart)chart);
}

173
designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java

@ -1,40 +1,28 @@
package com.fr.van.chart.designer.other;
import com.fr.base.BaseFormula;
import com.fr.base.Utils;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import com.fr.plugin.chart.axis.type.AxisPlotType;
import com.fr.plugin.chart.base.RefreshMoreLabel;
import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.base.VanChartZoom;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.StableUtils;
import com.fr.van.chart.custom.component.VanChartHyperLinkPane;
import com.fr.van.chart.designer.AbstractVanChartScrollPane;
import com.fr.van.chart.designer.PlotFactory;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.other.zoom.ZoomPane;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
@ -53,14 +41,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
private AutoRefreshPane autoRefreshPane;
private UIButtonGroup zoomWidget;
protected UIButtonGroup zoomGesture;//地图手势缩放
private UIButtonGroup zoomResize;
private TinyFormulaPane from;
private TinyFormulaPane to;
private UIButtonGroup<String> zoomType;
private JPanel changeEnablePane;
private JPanel zoomTypePane;
private ZoomPane zoomPane;
protected VanChartHyperLinkPane superLink;
@ -111,54 +92,15 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
}
protected JPanel createZoomPane(double[] row, double[] col, VanChartPlot plot) {
if (!plot.isSupportZoomDirection()) {
zoomPane = createZoomPane();
if (zoomPane == null) {
return null;
}
zoomWidget = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")});
zoomResize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Non_Adjustment")});
from = new TinyFormulaPane();
to = new TinyFormulaPane();
zoomType = new UIButtonGroup(getNameArray(), getValueArray());
zoomGesture = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")});
JPanel zoomWidgetPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Widget"), zoomWidget);
JPanel zoomGesturePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_ZoomGesture"), zoomGesture);
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Boundary")), zoomResize},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_From")), from},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_To")), to},
};
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
changeEnablePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, columnSize);
changeEnablePane.setBorder(BorderFactory.createEmptyBorder(10,12,0,0));
zoomTypePane = getzoomTypePane(zoomType);
JPanel panel = createZoomPaneContent(zoomWidgetPane, zoomGesturePane, changeEnablePane, zoomTypePane, plot);
zoomWidget.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkZoomPane();
}
});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Zoom"), panel);
}
protected JPanel getzoomTypePane(UIButtonGroup zoomType) {
return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Direction"), zoomType);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Zoom"), zoomPane);
}
protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) {
JPanel panel = new JPanel(new BorderLayout(0, 4));
if (plot.isSupportZoomCategoryAxis()) {//支持缩放控件
panel.add(zoomWidgetPane, BorderLayout.NORTH);
panel.add(changeEnablePane, BorderLayout.CENTER);
}
panel.add(zoomTypePane, BorderLayout.SOUTH);
return panel;
protected ZoomPane createZoomPane() {
return null;
}
private JPanel createAxisRotationPane(double[] row, double[] col, VanChartPlot plot){
@ -167,12 +109,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
}
axisRotation = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")});
axisRotation.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
checkZoomEnabled();
}
});
Component[][] components = new Component[][]{
new Component[]{null,null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Reversal")),axisRotation}
@ -181,28 +118,6 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis"), panel);
}
private void checkZoomEnabled() {
if (zoomWidget != null && axisRotation != null) {
if (axisRotation.getSelectedIndex() == 0) {
//只有开启坐标轴翻转,才需要将缩放控件强制关闭。
zoomWidget.setSelectedIndex(1);
}
checkZoomPane();
zoomWidget.setEnabled(axisRotation.getSelectedIndex() == 1);
}
}
protected String[] getNameArray() {
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_X_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Y_Axis")
,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")};
}
protected String[] getValueArray() {
return new String[]{VanChartConstants.ZOOM_TYPE_X, VanChartConstants.ZOOM_TYPE_Y
,VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE};
}
protected JPanel createToolBarPane(double[] row, double[] col){
isSort = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Sort"));
@ -263,27 +178,21 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
}
private void checkZoomPane() {
boolean zoomWidgetEnabled = zoomWidget.getSelectedIndex() == 0;
changeEnablePane.setVisible(zoomWidgetEnabled);
zoomType.setEnabled(!zoomWidgetEnabled);
}
@Override
public void populateBean(Chart chart) {
if (chart == null || chart.getPlot() == null) {
return;
}
this.chart = chart;
VanChartPlot plot = (VanChartPlot)chart.getPlot();
VanChartPlot plot = chart.getPlot();
if(interactivePane == null){
this.remove(leftcontentPane);
reLayoutContentPane(plot);
}
if(plot.isSupportZoomDirection()){//支持缩放方向=方向+控件
populateChartZoom((VanChart)chart);
checkZoomPane();
if (zoomPane != null) {
zoomPane.populateBean(((VanChart) chart).getZoomAttribute());
}
if (plot.getAxisPlotType() == AxisPlotType.RECTANGLE){
@ -295,8 +204,6 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
populateAutoRefresh((VanChart)chart);
populateHyperlink(plot);
checkZoomEnabled();
}
@ -312,27 +219,6 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
collapse.setSelected(vanChartTools.isHidden());
}
private void populateChartZoom(VanChart chart) {
VanChartZoom zoom = chart.getVanChartZoom();
if(zoom == null){
zoom = new VanChartZoom();
}
zoomWidget.setSelectedIndex(zoom.isZoomVisible() ? 0 : 1);
zoomGesture.setSelectedIndex(zoom.isZoomGesture() ? 0 : 1);
zoomResize.setSelectedIndex(zoom.isZoomResize() ? 0 : 1);
if (zoom.getFrom() instanceof BaseFormula) {
from.populateBean(((BaseFormula) zoom.getFrom()).getContent());
} else {
from.populateBean(Utils.objectToString(zoom.getFrom()));
}
if (zoom.getTo() instanceof BaseFormula) {
to.populateBean(((BaseFormula) zoom.getTo()).getContent());
} else {
to.populateBean(Utils.objectToString(zoom.getTo()));
}
zoomType.setSelectedItem(zoom.getZoomType());
}
private void populateChartAxisRotation(VanChartPlot plot) {
axisRotation.setSelectedIndex(plot.isAxisRotation() ? 0 : 1);
}
@ -366,11 +252,12 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
return;
}
VanChartPlot plot = (VanChartPlot)chart.getPlot();
VanChartPlot plot = chart.getPlot();
if(plot.isSupportZoomDirection()){
updateChartZoom((VanChart)chart);
if (zoomPane != null) {
((VanChart) chart).setZoomAttribute(zoomPane.updateBean());
}
if(plot.getAxisPlotType() == AxisPlotType.RECTANGLE){
updateChartAxisRotation((VanChart)chart);
}
@ -393,34 +280,6 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
chart.setVanChartTools(vanChartTools);
}
private void updateChartZoom(VanChart chart) {
VanChartZoom zoom = chart.getVanChartZoom();
if(zoom == null){
zoom = new VanChartZoom();
chart.setVanChartZoom(zoom);
}
zoom.setZoomVisible(zoomWidget.getSelectedIndex() == 0);
zoom.setZoomGesture(zoomGesture.getSelectedIndex() == 0);
zoom.setZoomResize(zoomResize.getSelectedIndex() == 0);
String fromString = from.updateBean();
Object fromObject;
if (StableUtils.maybeFormula(fromString)) {
fromObject = BaseFormula.createFormulaBuilder().build(fromString);
} else {
fromObject = fromString;
}
zoom.setFrom(fromObject);
String toString = to.updateBean();
Object toObject;
if (StableUtils.maybeFormula(toString)) {
toObject = BaseFormula.createFormulaBuilder().build(toString);
} else {
toObject = toString;
}
zoom.setTo(toObject);
zoom.setZoomType(zoomType.getSelectedItem());
}
private void updateChartAxisRotation(VanChart chart) {
//坐标轴和plot都需要这个属性,因为坐标轴和plot是分开画的
VanChartPlot plot = (VanChartPlot) chart.getPlot();

14
designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java

@ -1,19 +1,15 @@
package com.fr.van.chart.designer.other;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import com.fr.van.chart.designer.other.zoom.MapZoomPane;
import com.fr.van.chart.designer.other.zoom.ZoomPane;
/**
* Created by mengao on 2017/4/7.
*/
public class VanChartInteractivePaneWithMapZoom extends VanChartInteractivePaneWithOutSort {
@Override
protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) {
JPanel panel = new JPanel(new BorderLayout(0, 4));
panel.add(zoomWidgetPane, BorderLayout.NORTH);
panel.add(zoomGesturePane, BorderLayout.CENTER);
return panel;
protected ZoomPane createZoomPane() {
return new MapZoomPane();
}
}

47
designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/MapZoomPane.java

@ -0,0 +1,47 @@
package com.fr.van.chart.designer.other.zoom;
import com.fr.chartx.attr.ZoomAttribute;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import java.awt.Component;
/**
* Created by shine on 2019/08/28.
*/
public class MapZoomPane extends ZoomPane {
private UIButtonGroup<Boolean> mapZoomWidget;//地图缩放控件
private UIButtonGroup<Boolean> gestureZoomGroup;//地图手势缩放
@Override
protected Component[][] getSouthComps() {
mapZoomWidget = new UIButtonGroup<Boolean>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open")
, Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false});
gestureZoomGroup = new UIButtonGroup<Boolean>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open")
, Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false});
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Widget")), mapZoomWidget},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_ZoomGesture")), gestureZoomGroup}
};
}
@Override
public void populateBean(ZoomAttribute ob) {
super.populateBean(ob);
mapZoomWidget.setSelectedItem(ob.isMapZoomWidget());
gestureZoomGroup.setSelectedItem(ob.isGestureZoom());
}
@Override
public ZoomAttribute updateBean() {
ZoomAttribute zoomAttribute = super.updateBean();
zoomAttribute.setMapZoomWidget(mapZoomWidget.getSelectedItem());
zoomAttribute.setGestureZoom(gestureZoomGroup.getSelectedItem());
return zoomAttribute;
}
}

224
designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java

@ -0,0 +1,224 @@
package com.fr.van.chart.designer.other.zoom;
import com.fr.chartx.attr.ZoomAttribute;
import com.fr.chartx.attr.ZoomInitialDisplayType;
import com.fr.chartx.attr.ZoomModeType;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.extended.chart.StringFormula;
import com.fr.general.ComparatorUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
/**
* Created by shine on 2019/08/28.
*/
public class ZoomPane extends BasicBeanPane<ZoomAttribute> {
private UIButtonGroup<ZoomModeType> modeTypeButtonGroup;
private JPanel customModePane;
private UIComboBox initialDisplayTypeComboBox;
private JPanel initialDisplayCardPane;
private UISpinner topCategorySpinner;
private TinyFormulaPane leftFormulaPane;
private TinyFormulaPane rightFormulaPane;
private UIButtonGroup<Boolean> selectionZoomGroup;
public ZoomPane() {
initComponent();
}
private void initComponent() {
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double p = TableLayout.PREFERRED;
double[] columnSize = {f, e};
JPanel northPane = createNorthPane(f, p);
initCustomModePane(columnSize, p);
JPanel southPane = createSouthPane(f, p);
this.setLayout(new BorderLayout(0, 6));
if (northPane != null) {
this.add(northPane, BorderLayout.NORTH);
}
if (customModePane != null) {
this.add(customModePane, BorderLayout.CENTER);
}
if (southPane != null) {
this.add(southPane, BorderLayout.SOUTH);
}
}
protected JPanel createNorthPane(double f, double p) {
modeTypeButtonGroup = new UIButtonGroup<ZoomModeType>(new String[]{
Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"),
Toolkit.i18nText("Fine-Design_Chart_Mode_Custom"),
Toolkit.i18nText("Fine-Design_Chart_Close")
}, new ZoomModeType[]{ZoomModeType.AUTO, ZoomModeType.CUSTOM, ZoomModeType.CLOSE});
modeTypeButtonGroup.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
checkCustomModePane();
}
});
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Mode_type")), modeTypeButtonGroup}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p}
, new double[]{f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH});
}
private JPanel createSouthPane(double f, double p) {
Component[][] components = getSouthComps();
double[] rows = new double[components.length];
Arrays.fill(rows, p);
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rows
, new double[]{f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH});
}
protected Component[][] getSouthComps() {
selectionZoomGroup = new UIButtonGroup<Boolean>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open")
, Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false});
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Selection_Zoom")), selectionZoomGroup}
};
}
protected void initCustomModePane(double[] columnSize, double p) {
initialDisplayTypeComboBox = new UIComboBox(new ZoomInitialDisplayType[]{
ZoomInitialDisplayType.TOP_CATEGORY,
ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY});
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_InitialDisplay")), initialDisplayTypeComboBox}
};
JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p}, columnSize);
initInitialDisplayCardPane(columnSize, p);
customModePane = new JPanel(new BorderLayout(0, 6));
customModePane.add(northPane, BorderLayout.NORTH);
customModePane.add(initialDisplayCardPane, BorderLayout.CENTER);
customModePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
}
private void initInitialDisplayCardPane(double[] columnSize, double p) {
topCategorySpinner = new UISpinner(1, Integer.MAX_VALUE, 1);
Component[][] components1 = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Category_Number")), topCategorySpinner}
};
final JPanel topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components1, new double[]{p}, columnSize);
leftFormulaPane = new TinyFormulaPane();
rightFormulaPane = new TinyFormulaPane();
Component[][] components2 = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Left_Boundary")), leftFormulaPane},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Right_Boundary")), rightFormulaPane}
};
final JPanel leftRightPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, new double[]{p, p}, columnSize);
initialDisplayCardPane = new JPanel(new CardLayout()) {
@Override
public Dimension getPreferredSize() {
return initialDisplayTypeComboBox.getSelectedIndex() == 0 ? topPane.getPreferredSize() : leftRightPane.getPreferredSize();
}
};
initialDisplayCardPane.add(topPane, ZoomInitialDisplayType.TOP_CATEGORY.toString());
initialDisplayCardPane.add(leftRightPane, ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY.toString());
initialDisplayTypeComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkInitialDisplayCardPane();
}
});
}
private void checkCustomModePane() {
customModePane.setVisible(modeTypeButtonGroup.getSelectedItem() == ZoomModeType.CUSTOM);
}
private void checkInitialDisplayCardPane() {
CardLayout cardLayout = (CardLayout) initialDisplayCardPane.getLayout();
if (ComparatorUtils.equals(initialDisplayTypeComboBox.getSelectedItem(), ZoomInitialDisplayType.TOP_CATEGORY)) {
cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.TOP_CATEGORY.toString());
} else {
cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY.toString());
}
}
@Override
public void populateBean(ZoomAttribute ob) {
modeTypeButtonGroup.setSelectedItem(ob.getModeType());
initialDisplayTypeComboBox.setSelectedItem(ob.getInitialDisplayType());
topCategorySpinner.setValue(ob.getTopCategory());
if (ob.getLeft() != null) {
leftFormulaPane.populateBean(ob.getLeft().getContent());
}
if (ob.getRight() != null) {
rightFormulaPane.populateBean(ob.getRight().getContent());
}
selectionZoomGroup.setSelectedItem(ob.isSelectionZoom());
checkInitialDisplayCardPane();
checkCustomModePane();
}
@Override
public ZoomAttribute updateBean() {
ZoomAttribute zoomAttribute = new ZoomAttribute();
zoomAttribute.setModeType(modeTypeButtonGroup.getSelectedItem());
zoomAttribute.setInitialDisplayType((ZoomInitialDisplayType) initialDisplayTypeComboBox.getSelectedItem());
zoomAttribute.setTopCategory((int) topCategorySpinner.getValue());
zoomAttribute.setLeft(new StringFormula(leftFormulaPane.updateBean()));
zoomAttribute.setRight(new StringFormula(rightFormulaPane.updateBean()));
zoomAttribute.setSelectionZoom(selectionZoomGroup.getSelectedItem());
return zoomAttribute;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

17
designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPaneWithOutMode.java

@ -0,0 +1,17 @@
package com.fr.van.chart.designer.other.zoom;
import javax.swing.JPanel;
/**
* Created by shine on 2019/08/28.
*/
public class ZoomPaneWithOutMode extends ZoomPane {
@Override
protected JPanel createNorthPane(double f, double p) {
return null;
}
@Override
protected void initCustomModePane(double[] columnSize, double p) {
}
}

4
designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java

@ -7,6 +7,7 @@ import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.ConditionCollection;
import com.fr.chart.chartglyph.DataSheet;
import com.fr.chartx.attr.ZoomAttribute;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.MultilineLabel;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
@ -16,7 +17,6 @@ import com.fr.js.NameJavaScriptGroup;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.base.VanChartZoom;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.JPanel;
@ -100,7 +100,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
protected void resetChartAttr(Chart chart, Plot newPlot){
chart.setPlot(newPlot);
if(newPlot.isSupportZoomDirection() && !newPlot.isSupportZoomCategoryAxis()){
((VanChart)chart).setVanChartZoom(new VanChartZoom());
((VanChart) chart).setZoomAttribute(new ZoomAttribute());
}
//重置工具栏选项
((VanChart)chart).setVanChartTools(createVanChartTools());

8
designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java

@ -15,6 +15,7 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort;
import com.fr.van.chart.designer.other.VanChartOtherPane;
import com.fr.van.chart.designer.other.zoom.ZoomPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.scatter.component.VanChartScatterStylePane;
import com.fr.van.chart.scatter.data.VanChartScatterPlotTableDataContentPane;
@ -68,7 +69,12 @@ public class ScatterIndependentVanChartInterface extends AbstractIndependentVanC
VanChartOtherPane otherPane = new VanChartOtherPane(){
@Override
protected BasicBeanPane<Chart> createInteractivePane() {
return new VanChartInteractivePaneWithOutSort();
return new VanChartInteractivePaneWithOutSort() {
@Override
protected ZoomPane createZoomPane() {
return new ZoomPane();
}
};
}
};

15
designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java

@ -11,10 +11,10 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort;
import com.fr.van.chart.designer.other.VanChartOtherPane;
import com.fr.van.chart.designer.other.zoom.ZoomPane;
import com.fr.van.chart.designer.other.zoom.ZoomPaneWithOutMode;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.structure.desinger.data.StructurePlotReportDataContentPane;
import com.fr.van.chart.structure.desinger.data.StructurePlotTableDataContentPane;
@ -61,16 +61,9 @@ public class StructureIndependentVanChartInterface extends AbstractIndependentVa
return new VanChartInteractivePaneWithOutSort(){
@Override
protected String[] getNameArray() {
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")};
}
@Override
protected String[] getValueArray() {
return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE};
protected ZoomPane createZoomPane() {
return new ZoomPaneWithOutMode();
}
};
}
};

26
designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java

@ -1,6 +1,10 @@
package com.fr.van.chart.vanchart;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotReportDataContentPane;
@ -9,6 +13,10 @@ import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContent
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.van.chart.designer.data.VanChartMoreCateReportDataContentPane;
import com.fr.van.chart.designer.data.VanChartMoreCateTableDataContentPane;
import com.fr.van.chart.designer.other.VanChartInteractivePane;
import com.fr.van.chart.designer.other.VanChartOtherPane;
import com.fr.van.chart.designer.other.zoom.ZoomPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
/**
* Created by mengao on 2017/7/6.
@ -28,4 +36,22 @@ public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndepende
}
return new VanChartMoreCateReportDataContentPane(parent);
}
@Override
public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) {
VanChartStylePane stylePane = new VanChartStylePane(listener);
VanChartOtherPane otherPane = new VanChartOtherPane() {
@Override
protected BasicBeanPane<Chart> createInteractivePane() {
return new VanChartInteractivePane() {
@Override
protected ZoomPane createZoomPane() {
return new ZoomPane();
}
};
}
};
return new AbstractChartAttrPane[]{stylePane, otherPane};
}
}

13
designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java

@ -11,9 +11,10 @@ import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort;
import com.fr.van.chart.designer.other.VanChartOtherPane;
import com.fr.van.chart.designer.other.zoom.ZoomPane;
import com.fr.van.chart.designer.other.zoom.ZoomPaneWithOutMode;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI;
import com.fr.van.chart.wordcloud.designer.other.VanChartWordCloudConditionPane;
@ -72,14 +73,8 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa
return new VanChartInteractivePaneWithOutSort(){
@Override
protected String[] getNameArray() {
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")};
}
@Override
protected String[] getValueArray() {
return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE};
protected ZoomPane createZoomPane() {
return new ZoomPaneWithOutMode();
}
};
}

Loading…
Cancel
Save