Browse Source

CHART-19720 图表缩放控件面板

feature/10.0
白岳 3 years ago
parent
commit
8b0619f9dc
  1. 17
      designer-chart/src/main/java/com/fr/van/chart/designer/TableLayout4VanChartHelper.java
  2. 190
      designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java
  3. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java
  4. 2
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java

17
designer-chart/src/main/java/com/fr/van/chart/designer/TableLayout4VanChartHelper.java

@ -12,8 +12,8 @@ import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import java.awt.Component;
import java.util.Arrays;
import java.awt.Component;
/**
* 布局 标题+组件
@ -54,13 +54,23 @@ public class TableLayout4VanChartHelper {
return createGapTableLayoutPane(title, component, EDIT_AREA_WIDTH);
}
public static JPanel createGapTableLayoutPaneWithoutTop(String title, Component component) {
return createGapTableLayoutPane(title, component, EDIT_AREA_WIDTH, false);
}
public static JPanel createGapTableLayoutPane(String title, Component component, double componentWidth) {
return createGapTableLayoutPane(title, component, componentWidth, true);
}
public static JPanel createGapTableLayoutPane(String title, Component component, double componentWidth, boolean topLabel) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f, componentWidth};
double[] rowSize = {p, p};
UILabel label = FRWidgetFactory.createLineWrapLabel(title);
if (topLabel) {
label.setVerticalAlignment(SwingConstants.TOP);
}
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{label, UIComponentUtils.wrapWithBorderLayoutPane(component)},
@ -93,6 +103,7 @@ public class TableLayout4VanChartHelper {
/**
* 标题布局(二级菜单距左边框46)
*
* @param title 标题
* @param component 组件
* @return 布局好的组件
@ -103,6 +114,7 @@ public class TableLayout4VanChartHelper {
/**
* 标题布局(二级菜单距左边框46)
*
* @param label 标题label
* @param component 组件
* @return 布局好的组件
@ -113,6 +125,7 @@ public class TableLayout4VanChartHelper {
/**
* 标题布局(三级菜单距二级左侧20)
*
* @param title 标题
* @param component 组件
* @return 布局好的组件
@ -123,6 +136,7 @@ public class TableLayout4VanChartHelper {
/**
* 标题布局指定gap
*
* @param title 标题
* @param component 组件
* @param gap 距左侧距离
@ -134,6 +148,7 @@ public class TableLayout4VanChartHelper {
/**
* 标题布局指定gap
*
* @param label 标题label
* @param component 组件
* @param gap 距左侧距离

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

@ -8,15 +8,19 @@ import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.ConditionCollection;
import com.fr.chartx.attr.LargeDataModeType;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.frpane.UINumberDragPaneWithPercent;
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.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.ispinner.UnsignedIntUISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
@ -32,6 +36,8 @@ import com.fr.plugin.chart.base.VanChartZoom;
import com.fr.plugin.chart.gantt.attr.AttrGanttLabel;
import com.fr.plugin.chart.map.line.condition.AttrLineEffect;
import com.fr.plugin.chart.scatter.attr.ScatterAttrLabel;
import com.fr.plugin.chart.type.AxisType;
import com.fr.plugin.chart.type.ControlType;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.StableUtils;
import com.fr.van.chart.custom.component.VanChartHyperLinkPane;
@ -45,14 +51,15 @@ 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.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Dimension;
public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
private static final long serialVersionUID = 8135452818502145597L;
private static final int AUTO_REFRESH_LEFT_GAP = 18;
private static final double PERCENT = 100.0;
protected UICheckBox isSort;
protected UICheckBox exportImages;
@ -72,15 +79,20 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
private AutoRefreshPane autoRefreshPane;
//图表缩放新设计 恢复用注释。删除下面八行代码。
private UIButtonGroup zoomWidget;
private UICheckBox zoomWidget;
protected UIButtonGroup zoomGesture;//地图手势缩放
private UIButtonGroup zoomResize;
private TinyFormulaPane from;
private TinyFormulaPane to;
private UIButtonGroup<String> zoomType;
private JPanel changeEnablePane;
private JPanel zoomTypePane;
private UIButtonGroup<ControlType> controlType;
protected JPanel centerPane;
private UISpinner categoryNum;
private UINumberDragPane scaling;
private UIButtonGroup zoomResize;
private TinyFormulaPane from;
private TinyFormulaPane to;
//图表缩放新设计 恢复用注释。取消注释。
//private ZoomPane zoomPane;
@ -126,7 +138,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
//new Component[]{createLargeDataModePane(), null},
new Component[]{createAnimationPane(), null},
new Component[]{createAxisRotationPane(new double[]{p, p}, columnSize, plot), null},
new Component[]{createZoomPane(new double[]{p, p, p}, columnSize, plot), null},
new Component[]{createZoomPane(plot), null},
new Component[]{createAutoRefreshPane(plot), null},
new Component[]{createHyperlinkPane(), null}
};
@ -172,7 +184,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
return false;
}
protected JPanel createZoomPane(double[] row, double[] col, VanChartPlot plot) {
protected JPanel createZoomPane(VanChartPlot plot) {
//图表缩放新设计 恢复用注释。取消注释。
// zoomPane = createZoomPane();
// if (zoomPane == null) {
@ -184,47 +196,118 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
if (!plot.isSupportZoomDirection()) {
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();
zoomWidget = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Open_Zoom_Control"));
zoomGesture = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")});
JPanel zoomWidgetPane = TableLayout4VanChartHelper.createGapTableLayoutPaneWithoutTop(Toolkit.i18nText("Fine-Design_Chart_Zoom_Widget"), zoomWidget);
JPanel zoomGesturePane = TableLayout4VanChartHelper.createGapTableLayoutPaneWithoutTop(Toolkit.i18nText("Fine-Design_Chart_ZoomGesture"), zoomGesture);
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")});
zoomTypePane = getZoomTypePane(zoomType);
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);
JPanel panel = createZoomPaneContent(zoomWidgetPane, zoomGesturePane, plot);
zoomWidget.addActionListener((event) -> checkZoomPane());
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Use_Zoom"), panel);
}
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},
private void createChangeEnablePane(VanChartRectanglePlot plot) {
String scroll = Toolkit.i18nText("Fine-Design_Chart_Scroll");
String scaleAxis = Toolkit.i18nText("Fine-Design_Chart_Scale_Axis");
controlType = new UIButtonGroup<>(new String[]{scroll, scaleAxis}, ControlType.values());
JPanel scaleAxisPane = createScaleAxisPane();
JPanel scrollPane = createScrollPane(plot);
centerPane = new JPanel(new CardLayout()) {
@Override
public Dimension getPreferredSize() {
if (controlType.getSelectedItem() == ControlType.ZOOM) {
return scaleAxisPane.getPreferredSize();
} else {
return scrollPane.getPreferredSize();
}
}
};
centerPane.add(scaleAxisPane, scroll);
centerPane.add(scrollPane, scaleAxis);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] row = {p, p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Control_Type")), controlType},
new Component[]{centerPane, null}
};
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();
changeEnablePane.setBorder(BorderFactory.createEmptyBorder(5, 12, 0, 0));
controlType.addActionListener((event) -> checkCardPane());
}
private JPanel createScaleAxisPane() {
zoomResize = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Change"), Toolkit.i18nText("Fine-Design_Chart_Non_Adjustment")});
from = new TinyFormulaPane();
to = new TinyFormulaPane();
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Widget_Boundary")), zoomResize},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_From")), from},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_To")), to},
};
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] row = {p, p, p};
JPanel resizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, columnSize);
return resizePane;
}
private JPanel createScrollPane(VanChartRectanglePlot plot) {
VanChartAxis vanChartAxis = plot.getCategoryAxisList().get(0);
AxisType axisType = vanChartAxis.getAxisType();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] row = {p};
Component[][] components;
if (axisType == AxisType.AXIS_CATEGORY) {
categoryNum = new UnsignedIntUISpinner(1, Double.MAX_VALUE, 1);
components = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Initial_Cate_Num")), categoryNum},
};
} else {
scaling = new UINumberDragPaneWithPercent(1, 100, 1);
components = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Scaling")), scaling},
};
}
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, columnSize);
}
protected void checkCardPane() {
if (centerPane != null && controlType != null) {
CardLayout cardLayout = (CardLayout) centerPane.getLayout();
if (controlType.getSelectedItem() == ControlType.ZOOM) {
cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Scroll"));
} else {
cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Scale_Axis"));
}
}
});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Zoom"), panel);
}
//图表缩放新设计 恢复用注释。删除下面八个方法getzoomTypePane createZoomPaneContent
// checkZoomEnabled getNameArray getValueArray checkZoomPane populateChartZoom updateChartZoom。
protected JPanel getzoomTypePane(UIButtonGroup zoomType) {
return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Direction"), zoomType);
protected JPanel getZoomTypePane(UIButtonGroup zoomType) {
return TableLayout4VanChartHelper.createGapTableLayoutPaneWithoutTop(Toolkit.i18nText("Fine-Design_Chart_Zoom_Direction"), zoomType);
}
protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) {
protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, VanChartPlot plot) {
JPanel panel = new JPanel(new BorderLayout(0, 4));
if (plot.isSupportZoomCategoryAxis()) {//支持缩放控件
createChangeEnablePane((VanChartRectanglePlot) plot);
panel.add(zoomWidgetPane, BorderLayout.NORTH);
panel.add(changeEnablePane, BorderLayout.CENTER);
}
@ -236,17 +319,18 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
if (zoomWidget != null && axisRotation != null) {
if (axisRotation.getSelectedIndex() == 0) {
//只有开启坐标轴翻转,才需要将缩放控件强制关闭。
zoomWidget.setSelectedIndex(1);
zoomWidget.setSelected(false);
}
checkZoomPane();
zoomWidget.setEnabled(axisRotation.getSelectedIndex() == 1);
}
checkCardPane();
}
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")};
return new String[]{Toolkit.i18nText("Fine-Design_Chart_X_Axis"), Toolkit.i18nText("Fine-Design_Chart_Y_Axis")
, Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), Toolkit.i18nText("Fine-Design_Chart_Use_None")};
}
protected String[] getValueArray() {
@ -256,9 +340,11 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
}
private void checkZoomPane() {
boolean zoomWidgetEnabled = zoomWidget.getSelectedIndex() == 0;
boolean zoomWidgetEnabled = zoomWidget.isSelected();
if (changeEnablePane != null) {
changeEnablePane.setVisible(zoomWidgetEnabled);
zoomType.setEnabled(!zoomWidgetEnabled);
}
zoomTypePane.setVisible(!zoomWidgetEnabled);
}
private void populateChartZoom(VanChart chart) {
@ -266,8 +352,13 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
if (zoom == null) {
zoom = new VanChartZoom();
}
zoomWidget.setSelectedIndex(zoom.isZoomVisible() ? 0 : 1);
zoomWidget.setSelected(zoom.isZoomVisible());
zoomGesture.setSelectedIndex(zoom.isZoomGesture() ? 0 : 1);
zoomType.setSelectedItem(zoom.getZoomType());
if (changeEnablePane != null) {
controlType.setSelectedItem(zoom.getControlType());
zoomResize.setSelectedIndex(zoom.isZoomResize() ? 0 : 1);
if (zoom.getFrom() instanceof BaseFormula) {
from.populateBean(((BaseFormula) zoom.getFrom()).getContent());
@ -279,7 +370,13 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
} else {
to.populateBean(Utils.objectToString(zoom.getTo()));
}
zoomType.setSelectedItem(zoom.getZoomType());
if (categoryNum != null) {
categoryNum.setValue(zoom.getCategoryNum());
}
if (scaling != null) {
scaling.populateBean(zoom.getScaling() * PERCENT);
}
}
}
private void updateChartZoom(VanChart chart) {
@ -288,8 +385,12 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
zoom = new VanChartZoom();
chart.setVanChartZoom(zoom);
}
zoom.setZoomVisible(zoomWidget.getSelectedIndex() == 0);
zoom.setZoomVisible(zoomWidget.isSelected());
zoom.setZoomGesture(zoomGesture.getSelectedIndex() == 0);
zoom.setZoomType(zoomType.getSelectedItem());
if (changeEnablePane != null) {
zoom.setControlType(controlType.getSelectedItem());
if (zoom.getControlType() == ControlType.ZOOM) {
zoom.setZoomResize(zoomResize.getSelectedIndex() == 0);
String fromString = from.updateBean();
Object fromObject;
@ -307,7 +408,15 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
toObject = toString;
}
zoom.setTo(toObject);
zoom.setZoomType(zoomType.getSelectedItem());
} else {
if (categoryNum != null) {
zoom.setCategoryNum((int) categoryNum.getValue());
}
if (scaling != null) {
zoom.setScaling(scaling.updateBean() / PERCENT);
}
}
}
}
protected ZoomPane createZoomPane() {
@ -467,7 +576,6 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
//图表缩放新设计 恢复用注释。删除下面三行代码。
if (plot.isSupportZoomDirection()) {//支持缩放方向=方向+控件
populateChartZoom((VanChart) chart);
checkZoomPane();
}
if (plot.getAxisPlotType() == AxisPlotType.RECTANGLE) {

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

@ -12,7 +12,7 @@ public class VanChartInteractivePaneWithMapZoom extends VanChartInteractivePaneW
//图表缩放新设计 恢复用注释。删除下面方法 createZoomPaneContent。
@Override
protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) {
protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, VanChartPlot plot) {
JPanel panel = new JPanel(new BorderLayout(0, 4));
panel.add(zoomWidgetPane, BorderLayout.NORTH);
panel.add(zoomGesturePane, BorderLayout.CENTER);

2
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java

@ -42,7 +42,7 @@ public class VanChartDrillMapInteractivePane extends VanChartInteractivePaneWith
Component[][] components = new Component[][]{
new Component[]{createToolBarPane(new double[]{p, p, p}, columnSize), null},
new Component[]{createAnimationPane(), null},
new Component[]{createZoomPane(new double[]{p, p, p}, columnSize, plot), null},
new Component[]{createZoomPane(plot), null},
new Component[]{createDrillToolsPane(), null},
new Component[]{createAutoRefreshPane(plot), null},
new Component[]{createHyperlinkPane(), null}

Loading…
Cancel
Save