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.
*/
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.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.function.MAX;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
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 UIButtonGroup<Integer> configStyleButton;
@ -31,15 +40,19 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
private JPanel configPane;
//按钮切换方式配置界面
private JPanel buttonConfigPane;
private ChartTextAttrPane textAttrPane;
private ColorSelectBoxWithOutTransparent colorSelectBox;
private ChartTextAttrPane styleAttrPane;
private ColorSelectBoxWithOutTransparent colorSelectBox4button;
//轮播切换方式配置接界面
private JPanel carouselConfigPane;
protected UISpinner timeInterval;
private ColorSelectBoxWithOutTransparent colorSelectBox4carousel;
public ChangeConfigPane(){
initButtonGroup();
contentPane = createContentPane();
configPane = createConfigPane();
contentPane = createContentPane();
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 30, 10, 30));
this.add(contentPane, BorderLayout.CENTER);
}
@ -47,9 +60,10 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p,p,p};
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},
};
@ -65,7 +79,7 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
@Override
public Dimension getPreferredSize() {
if(configStyleButton.getSelectedIndex() == 0){
return new Dimension(buttonConfigPane.getWidth(), 0);
return buttonConfigPane.getPreferredSize();
} else{
return carouselConfigPane.getPreferredSize();
}
@ -79,18 +93,39 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
}
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(){
textAttrPane = new ChartTextAttrPane();
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style"), textAttrPane);
styleAttrPane = new ChartTextAttrPane();
styleAttrPane.setPreferredSize(new Dimension(WIDTH, (int) styleAttrPane.getPreferredSize().getHeight()));
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style")+":", styleAttrPane);
}
private JPanel createBackgroundColorPane(){
colorSelectBox = new ColorSelectBoxWithOutTransparent(100);
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style"), textAttrPane);
private JPanel createButtonBackgroundColorPane(){
colorSelectBox4button = new ColorSelectBoxWithOutTransparent(WIDTH);
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("Background") + ":", colorSelectBox4button);
}
private JPanel createButtonConfigPane() {
@ -101,7 +136,7 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
Component[][] components = new Component[][]{
new Component[]{createTitleStylePane(),null},
new Component[]{new JSeparator(),null},
new Component[]{createBackgroundColorPane(),null},
new Component[]{createButtonBackgroundColorPane(),null},
};
return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
@ -110,7 +145,7 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
private void initButtonGroup() {
configStyleButton = new UIButtonGroup<Integer>(new String[]{Inter.getLocText("Plugin-ChartF_Button_Style"),
Inter.getLocText("Plugin-ChartF_Carousel_Style")});
configStyleButton.setSelectedIndex(0);
configStyleButton.setPreferredSize(new Dimension(WIDTH * 2, (int) configStyleButton.getPreferredSize().getHeight()));
configStyleButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -129,17 +164,51 @@ public class ChangeConfigPane extends BasicBeanPane<Collection> {
}
@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
public Collection updateBean() {
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 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.ChartCollection;
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.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog;
@ -21,8 +21,6 @@ import com.fr.general.FRLogger;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.*;
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_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;
@ -165,21 +165,20 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
@Override
public void actionPerformed(ActionEvent e) {
UIMenuNameableCreator ui = configCreator.clone();
final Object obj = ui.getObj();
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(500, 500);
dialog.setSize(P_W, P_H);
dialog.setVisible(true);
}
};

Loading…
Cancel
Save