Browse Source

图表切换

master
Fangjie Hu 8 years ago
parent
commit
bf8b5b1958
  1. 103
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java
  2. 15
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

103
designer_chart/src/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java

@ -4,12 +4,18 @@ package com.fr.design.mainframe.chart.gui;
* Created by hufan on 2016/10/20. * Created by hufan on 2016/10/20.
*/ */
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.change.ChangeConfigAttr;
import com.fr.chart.chartattr.change.ChangeType;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; 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.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.function.MAX;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.third.org.hsqldb.lib.Collection; import com.fr.third.org.hsqldb.lib.Collection;
@ -23,7 +29,10 @@ import java.awt.event.ActionListener;
/** /**
* 图表切换设置面板 * 图表切换设置面板
*/ */
public class ChangeConfigPane extends BasicBeanPane<Collection> { public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
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 JPanel contentPane;
//配置方式按钮 //配置方式按钮
private UIButtonGroup<Integer> configStyleButton; private UIButtonGroup<Integer> configStyleButton;
@ -31,15 +40,19 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
private JPanel configPane; private JPanel configPane;
//按钮切换方式配置界面 //按钮切换方式配置界面
private JPanel buttonConfigPane; private JPanel buttonConfigPane;
private ChartTextAttrPane textAttrPane; private ChartTextAttrPane styleAttrPane;
private ColorSelectBoxWithOutTransparent colorSelectBox; private ColorSelectBoxWithOutTransparent colorSelectBox4button;
//轮播切换方式配置接界面 //轮播切换方式配置接界面
private JPanel carouselConfigPane; private JPanel carouselConfigPane;
protected UISpinner timeInterval;
private ColorSelectBoxWithOutTransparent colorSelectBox4carousel;
public ChangeConfigPane(){ public ChangeConfigPane(){
initButtonGroup(); initButtonGroup();
contentPane = createContentPane();
configPane = createConfigPane(); configPane = createConfigPane();
contentPane = createContentPane();
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 30, 10, 30));
this.add(contentPane, BorderLayout.CENTER); this.add(contentPane, BorderLayout.CENTER);
} }
@ -47,9 +60,10 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {p, f}; double[] columnSize = {p, f};
double[] rowSize = {p,p,p}; double[] rowSize = {p,p,p,p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("Plugin-ChartF_Change_Style") + ":"),configStyleButton}, new Component[]{new UILabel(Inter.getLocText("Plugin-ChartF_Change_Style") + ":"),configStyleButton},
new Component[]{null, null},
new Component[]{new JSeparator(), null}, new Component[]{new JSeparator(), null},
new Component[]{configPane, null}, new Component[]{configPane, null},
}; };
@ -65,7 +79,7 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
if(configStyleButton.getSelectedIndex() == 0){ if(configStyleButton.getSelectedIndex() == 0){
return new Dimension(buttonConfigPane.getWidth(), 0); return buttonConfigPane.getPreferredSize();
} else{ } else{
return carouselConfigPane.getPreferredSize(); return carouselConfigPane.getPreferredSize();
} }
@ -79,18 +93,39 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
} }
private JPanel createCarouseConfigPane() { private JPanel createCarouseConfigPane() {
return new JPanel(); 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(){ private JPanel createTitleStylePane(){
textAttrPane = new ChartTextAttrPane(); styleAttrPane = new ChartTextAttrPane();
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style"), textAttrPane); styleAttrPane.setPreferredSize(new Dimension(WIDTH, (int) styleAttrPane.getPreferredSize().getHeight()));
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style")+":", styleAttrPane);
} }
private JPanel createBackgroundColorPane(){ private JPanel createButtonBackgroundColorPane(){
colorSelectBox = new ColorSelectBoxWithOutTransparent(100); colorSelectBox4button = new ColorSelectBoxWithOutTransparent(WIDTH);
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style"), textAttrPane); return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("Background") + ":", colorSelectBox4button);
} }
private JPanel createButtonConfigPane() { private JPanel createButtonConfigPane() {
@ -101,7 +136,7 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createTitleStylePane(),null}, new Component[]{createTitleStylePane(),null},
new Component[]{new JSeparator(),null}, new Component[]{new JSeparator(),null},
new Component[]{createBackgroundColorPane(),null}, new Component[]{createButtonBackgroundColorPane(),null},
}; };
return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
@ -110,7 +145,7 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
private void initButtonGroup() { private void initButtonGroup() {
configStyleButton = new UIButtonGroup<Integer>(new String[]{Inter.getLocText("Plugin-ChartF_Button_Style"), configStyleButton = new UIButtonGroup<Integer>(new String[]{Inter.getLocText("Plugin-ChartF_Button_Style"),
Inter.getLocText("Plugin-ChartF_Carousel_Style")}); Inter.getLocText("Plugin-ChartF_Carousel_Style")});
configStyleButton.setSelectedIndex(0); configStyleButton.setPreferredSize(new Dimension(WIDTH * 2, (int) configStyleButton.getPreferredSize().getHeight()));
configStyleButton.addActionListener(new ActionListener() { configStyleButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -129,17 +164,51 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
} }
@Override @Override
public void populateBean(Collection ob) { 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 @Override
public Collection updateBean() { public ChartCollection updateBean() {
return null; 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 @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return null; return Inter.getLocText("Chart-Change_Config_Attributes");
} }
} }

15
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -4,7 +4,7 @@ import com.fr.base.BaseUtils;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.SwitchState; import com.fr.chart.chartattr.SwitchState;
import com.fr.chart.chartglyph.ChangeConfigAttr; import com.fr.chart.chartattr.change.ChangeConfigAttr;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
@ -21,8 +21,6 @@ import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
@ -39,6 +37,8 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private static final int B_W = 52; private static final int B_W = 52;
private static final int B_H = 20; private static final int B_H = 20;
private static final int COL_COUNT = 3; 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 addButton;
private UIButton configButton; private UIButton configButton;
@ -165,21 +165,20 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
UIMenuNameableCreator ui = configCreator.clone(); UIMenuNameableCreator ui = configCreator.clone();
final Object obj = ui.getObj();
final BasicBeanPane pane = ui.getPane(); final BasicBeanPane pane = ui.getPane();
pane.populateBean(editingCollection);
UIDialog dialog = pane.showUnsizedWindow(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionListener() { UIDialog dialog = pane.showUnsizedWindow(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionListener() {
@Override @Override
public void doOk() { public void doOk() {
pane.updateBean(editingCollection);
} }
@Override @Override
public void doCancel() { public void doCancel() {
} }
}); });
dialog.setSize(500, 500); dialog.setSize(P_W, P_H);
dialog.setVisible(true); dialog.setVisible(true);
} }
}; };

Loading…
Cancel
Save