Browse Source

图表切换

master
Fangjie Hu 8 years ago
parent
commit
a3a1a1044c
  1. 34
      designer_base/src/com/fr/design/layout/TableLayoutHelper.java
  2. 145
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java
  3. 37
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  4. 20
      designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java
  5. 33
      designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java

34
designer_base/src/com/fr/design/layout/TableLayoutHelper.java

@ -47,6 +47,40 @@ public class TableLayoutHelper {
return createCommonTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM);
}
/**
* 标题布局(二级菜单距左边框46)
* @param title 标题
* @param component 组件
* @return 布局好的组件
*/
public static JPanel createTableLayoutPaneWithTitle(String title, Component component){
return createTitlePane(title, component, LayoutConstants.CHART_ATTR_TOMARGIN);
}
public static JPanel createTitlePane(String title, Component component, int gap){
return createTitlePaneWithUILabel(new UILabel(title), component, gap);
}
/**
* 标题布局指定gap
* @param label 标题label
* @param component 组件
* @param gap 距左侧距离
* @return 布局好的组件
*/
public static JPanel createTitlePaneWithUILabel(UILabel label, Component component, int gap){
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {gap, f};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{label,null},
new Component[]{null,component},
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
public static JPanel createCommonTableLayoutPane(Component[][] components, double[] rowSize, double[] columnSize, double gap) {
return createGapTableLayoutPane(components, rowSize, columnSize, gap, gap);

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

@ -0,0 +1,145 @@
package com.fr.design.mainframe.chart.gui;
/**
* Created by hufan on 2016/10/20.
*/
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.general.Inter;
import com.fr.third.org.hsqldb.lib.Collection;
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;
/**
* 图表切换设置面板
*/
public class ChangeConfigPane extends BasicBeanPane<Collection> {
private JPanel contentPane;
//配置方式按钮
private UIButtonGroup<Integer> configStyleButton;
//配置界面
private JPanel configPane;
//按钮切换方式配置界面
private JPanel buttonConfigPane;
private ChartTextAttrPane textAttrPane;
private ColorSelectBoxWithOutTransparent colorSelectBox;
//轮播切换方式配置接界面
private JPanel carouselConfigPane;
public ChangeConfigPane(){
initButtonGroup();
contentPane = createContentPane();
configPane = createConfigPane();
this.add(contentPane, BorderLayout.CENTER);
}
private JPanel createContentPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p,p,p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("Plugin-ChartF_Change_Style") + ":"),configStyleButton},
new Component[]{new JSeparator(), null},
new Component[]{configPane, null},
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
private JPanel createConfigPane() {
buttonConfigPane = createButtonConfigPane();
carouselConfigPane = createCarouseConfigPane();
JPanel panel = new JPanel(new CardLayout()){
@Override
public Dimension getPreferredSize() {
if(configStyleButton.getSelectedIndex() == 0){
return new Dimension(buttonConfigPane.getWidth(), 0);
} else{
return carouselConfigPane.getPreferredSize();
}
}
};
panel.add(buttonConfigPane, "button");
panel.add(carouselConfigPane, "carousel");
return panel;
}
private JPanel createCarouseConfigPane() {
return new JPanel();
}
private JPanel createTitleStylePane(){
textAttrPane = new ChartTextAttrPane();
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style"), textAttrPane);
}
private JPanel createBackgroundColorPane(){
colorSelectBox = new ColorSelectBoxWithOutTransparent(100);
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style"), textAttrPane);
}
private JPanel createButtonConfigPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p,p,p};
Component[][] components = new Component[][]{
new Component[]{createTitleStylePane(),null},
new Component[]{new JSeparator(),null},
new Component[]{createBackgroundColorPane(),null},
};
return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
}
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.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkCardPane();
}
});
}
private void checkCardPane() {
CardLayout cardLayout = (CardLayout) configPane.getLayout();
if (configStyleButton.getSelectedIndex() == 0) {
cardLayout.show(configPane, "button");
} else {
cardLayout.show(configPane, "carousel");
}
}
@Override
public void populateBean(Collection ob) {
}
@Override
public Collection updateBean() {
return null;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

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

@ -4,6 +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.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog;
@ -114,6 +115,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
}
private void initConfigCreator() {
configCreator = new UIMenuNameableCreator(Inter.getLocText("Chart-Change_Config_Attributes"), new ChangeConfigAttr(), ChangeConfigPane.class);
}
private void initAddButton() {
@ -162,29 +164,26 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
ActionListener configListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
};
UIMenuNameableCreator ui = configCreator.clone();
final Object obj = ui.getObj();
final BasicBeanPane pane = ui.getPane();
/**
* 响应事件
*/
public void fireTargetChanged() {
this.validate();
this.repaint();
this.revalidate();
fireChanged();
}
protected void fireChanged() {
Object[] listeners = listenerList.getListenerList();
UIDialog dialog = pane.showUnsizedWindow(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionListener() {
@Override
public void doOk() {
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
((ChangeListener) listeners[i + 1]).stateChanged(new ChangeEvent(this));
}
}
@Override
public void doCancel() {
}
});
dialog.setSize(500, 500);
dialog.setVisible(true);
}
}
};
MouseListener mouseListener = new MouseAdapter() {
@Override

20
designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java

@ -0,0 +1,20 @@
package com.fr.design.mainframe.chart.gui;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.design.style.color.ColorSelectPane;
/**
* Created by Fangjie on 2016/4/8.
* 没有透明度的颜色选择器
*/
public class ColorSelectBoxWithOutTransparent extends ColorSelectBox {
public ColorSelectBoxWithOutTransparent(int preferredWidth){
super(preferredWidth);
}
@Override
protected ColorSelectPane getColorSelectPane(){
return new ColorSelectPaneWithOutTransparent();
}
}

33
designer_chart/src/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java

@ -0,0 +1,33 @@
package com.fr.design.mainframe.chart.gui;
import com.fr.chart.base.ChartConstants;
import com.fr.design.style.color.ColorCell;
import com.fr.design.style.color.ColorSelectPane;
import javax.swing.*;
import java.awt.*;
/**
* Created by Fangjie on 2016/4/8.
*/
public class ColorSelectPaneWithOutTransparent extends ColorSelectPane {
public ColorSelectPaneWithOutTransparent(){
super(false);
}
public void initCenterPaneChildren(JPanel centerPane) {
JPanel menuColorPane1 = new JPanel();
centerPane.add(menuColorPane1);
menuColorPane1.setLayout(new GridLayout(5, 8, 5, 5));
for (int i = 0; i < ChartConstants.MAP_COLOR_ARRAY.length; i++) {
menuColorPane1.add(new ColorCell(ChartConstants.MAP_COLOR_ARRAY[i], this));
}
centerPane.add(Box.createVerticalStrut(5));
centerPane.add(new JSeparator());
}
protected Color[] getColorArray(){
return ChartConstants.MAP_COLOR_ARRAY;
}
}
Loading…
Cancel
Save