Browse Source
* commit 'd0274db42bf56339956f20499b32b0459d4f2e3c': update update update 图表切换 图表切换 update 图表切换master
superman
8 years ago
6 changed files with 383 additions and 18 deletions
@ -0,0 +1,209 @@
|
||||
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.chartglyph.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.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* 图表切换设置面板 |
||||
*/ |
||||
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; |
||||
//配置界面
|
||||
private JPanel configPane; |
||||
//按钮切换方式配置界面
|
||||
private JPanel buttonConfigPane; |
||||
private ChartTextAttrPane styleAttrPane; |
||||
private ColorSelectBoxWithOutTransparent colorSelectBox4button; |
||||
|
||||
//轮播切换方式配置接界面
|
||||
private JPanel carouselConfigPane; |
||||
protected UISpinner timeInterval; |
||||
private ColorSelectBoxWithOutTransparent colorSelectBox4carousel; |
||||
|
||||
public ChangeConfigPane(){ |
||||
initButtonGroup(); |
||||
configPane = createConfigPane(); |
||||
contentPane = createContentPane(); |
||||
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 30, 10, 30)); |
||||
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,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}, |
||||
}; |
||||
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 buttonConfigPane.getPreferredSize(); |
||||
} else{ |
||||
return carouselConfigPane.getPreferredSize(); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
panel.add(buttonConfigPane, "button"); |
||||
panel.add(carouselConfigPane, "carousel"); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
private JPanel createCarouseConfigPane() { |
||||
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(){ |
||||
styleAttrPane = new ChartTextAttrPane(); |
||||
styleAttrPane.setPreferredSize(new Dimension(WIDTH, (int) styleAttrPane.getPreferredSize().getHeight())); |
||||
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("FR-Designer-Widget_Style")+":", styleAttrPane); |
||||
} |
||||
|
||||
|
||||
private JPanel createButtonBackgroundColorPane(){ |
||||
colorSelectBox4button = new ColorSelectBoxWithOutTransparent(WIDTH); |
||||
return TableLayoutHelper.createTableLayoutPaneWithTitle(Inter.getLocText("Background") + ":", colorSelectBox4button); |
||||
} |
||||
|
||||
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[]{createButtonBackgroundColorPane(),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.setPreferredSize(new Dimension(WIDTH * 2, (int) configStyleButton.getPreferredSize().getHeight())); |
||||
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(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 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 Inter.getLocText("Chart-Change_Config_Attributes"); |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
@ -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…
Reference in new issue