package com.fr.plugin.heatpointmapbox.ui; import com.fr.base.BaseUtils; import com.fr.chart.base.TextAttr; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.style.color.ColorSelectBox; import com.fr.extended.chart.ExtendedScrollPane; import com.fr.general.FRFont; import com.fr.json.JSONObject; import com.fr.plugin.heatpointmapbox.HeatPointMapChart; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.*; import java.awt.*; public class HeatPointMapStyleTitlePane extends ExtendedScrollPane { private UICheckBox isTitleVisable; private ColorSelectBox titleBgColor; private UINumberDragPane titleBgOpacity; private TinyFormulaPane titleName; private UIButtonGroup titleAlignment; private ChartTextAttrPane textAttrPane; @Override protected JPanel createContentPane() { return new ContentPane(); } @Override public void populateBean(HeatPointMapChart chart) { JSONObject titleConf = chart.getTitleConf(); this.isTitleVisable.setSelected(titleConf.getBoolean("titlevisiable")); this.titleBgColor.setSelectObject(MapUtil.toColor(titleConf.getString("titlebgcolor"))); this.titleBgOpacity.populateBean(titleConf.getDouble("titleBgOpacity")); this.titleName.populateBean(titleConf.getString("titlename")); this.titleAlignment.setSelectedItem(titleConf.getInt("titleposition")); FRFont titleFont = FRFont.getInstance(titleConf.getString("titlefamily"), titleConf.getInt("titlestyle"), titleConf.getInt("titlesize"), MapUtil.toColor(titleConf.getString("titlecolor"))); this.textAttrPane.populate(titleFont); } @Override public void updateBean(HeatPointMapChart chart) { JSONObject titleConf = JSONObject.create(); titleConf.put("titlevisiable", this.isTitleVisable.isSelected()); titleConf.put("titlebgcolor", MapUtil.toHex(this.titleBgColor.getSelectObject())); titleConf.put("titleBgOpacity", this.titleBgOpacity.updateBean()); titleConf.put("titlename", this.titleName.updateBean()); titleConf.put("titleposition", titleAlignment.getSelectedItem()); TextAttr titleAttr = this.textAttrPane.update(); titleConf.put("titlesize", titleAttr.getFRFont().getSize()); titleConf.put("titlestyle", titleAttr.getFRFont().getStyle()); titleConf.put("titlefamily", titleAttr.getFRFont().getFamily()); titleConf.put("titlecolor", MapUtil.toHex(titleAttr.getFRFont().getForeground())); chart.setTitleConf(titleConf); } @Override protected String title4PopupWindow() { return PaneTitleConstants.CHART_STYLE_TITLE_TITLE; } private class ContentPane extends JPanel { public ContentPane() { initComponents(); } private void initComponents() { this.setLayout(new BorderLayout()); // 内容 JPanel titleContentPane = createTitleContentPane(); // 样式 JPanel stylePane = createTitleStylePane(); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {f}; double[] rowSize = {p, p, p, p}; Component[][] acomponents = new Component[][]{ new Component[]{isTitleVisable}, new Component[]{titleContentPane}, new Component[]{stylePane} } ; JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents,rowSize,columnSize); this.add(panel,BorderLayout.CENTER); this.setVisible(true); } } private JPanel createTitleContentPane(){ // 内容 this.isTitleVisable = new UICheckBox(Toolkit.i18nText("Plugin-HeatPointMap-isVisiableTitle")); this.titleBgColor = new ColorSelectBox(100); this.titleBgOpacity = new UINumberDragPane(0, 100); this.titleName = new TinyFormulaPane(); // 位置 Icon[] titlePositonIcons = new Icon[]{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")}; Integer[] titlePositionVal = new Integer[]{2, 0, 4}; this.titleAlignment = new UIButtonGroup(titlePositonIcons, titlePositionVal); Component[][] components = new Component[][]{ {null, null}, new Component[]{new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-titleBgColor")), this.titleBgColor}, new Component[]{new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-titleBgOpacity")), this.titleBgOpacity}, new Component[]{new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-TitleText")), this.titleName}, new Component[]{new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-TitlePosition"), 2), this.titleAlignment} } ; return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-HeatPointMap-TitleExpand"), components); } private JPanel createTitleStylePane() { this.textAttrPane = new ChartTextAttrPane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-HeatPointMap-TitleStyle"), this.textAttrPane); } }