You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

139 lines
5.3 KiB

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 HeatPointMapStyleLegendPane extends ExtendedScrollPane<HeatPointMapChart> {
private UICheckBox isLegendVisable;
private UIButtonGroup<Integer> legendPosition;
private ChartTextAttrPane textAttrPane;
@Override
protected JPanel createContentPane() {
return new ContentPane();
}
@Override
public void populateBean(HeatPointMapChart chart) {
JSONObject legendConf = chart.getLegendConf();
this.isLegendVisable.setSelected(legendConf.getBoolean("isLegendVisable"));
this.legendPosition.setSelectedItem(legendConf.getInt("legendPosition"));
FRFont titleFont = FRFont.getInstance(legendConf.getString("legendfamily"),
legendConf.getInt("legendstyle"),
legendConf.getInt("legendsize"),
MapUtil.toColor(legendConf.getString("legendcolor")));
this.textAttrPane.populate(titleFont);
}
@Override
public void updateBean(HeatPointMapChart chart) {
JSONObject legendConf = JSONObject.create();
legendConf.put("isLegendVisable", this.isLegendVisable.isSelected());
legendConf.put("legendPosition", legendPosition.getSelectedItem());
TextAttr titleAttr = this.textAttrPane.update();
legendConf.put("legendsize", titleAttr.getFRFont().getSize());
legendConf.put("legendstyle", titleAttr.getFRFont().getStyle());
legendConf.put("legendfamily", titleAttr.getFRFont().getFamily());
legendConf.put("legendcolor", MapUtil.toHex(titleAttr.getFRFont().getForeground()));
chart.setLegendConf(legendConf);
}
@Override
protected String title4PopupWindow() {
return PaneTitleConstants.CHART_STYLE_LEGNED_TITLE;
}
private class ContentPane extends JPanel {
public ContentPane() {
initComponents();
}
private void initComponents() {
this.setLayout(new BorderLayout());
// 内容
JPanel titleContentPane = createLegendContentPane();
// 样式
JPanel stylePane = createLegendStylePane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p, p, p, p};
Component[][] acomponents = new Component[][]{
new Component[]{isLegendVisable},
new Component[]{titleContentPane},
new Component[]{stylePane}
} ;
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents,rowSize,columnSize);
this.add(panel,BorderLayout.CENTER);
this.setVisible(true);
}
}
private JPanel createLegendContentPane(){
// 内容
this.isLegendVisable = new UICheckBox(Toolkit.i18nText("Plugin-HeatPointMap-isLegendVisable"));
String[] tips = new String[]{
Toolkit.i18nText("Plugin-HeatPointMap-Alignment-LeftTop"),
Toolkit.i18nText("Plugin-HeatPointMap-Alignment-RightTop"),
Toolkit.i18nText("Plugin-HeatPointMap-Alignment-RightBottom"),
Toolkit.i18nText("Plugin-HeatPointMap-Alignment-LeftBottom")
};
Integer[] vals = new Integer[]{1, 2, 3, 4};
Icon[] icons = new Icon[]{
BaseUtils.readIcon("/com/fr/plugin/heatpointmapbox/images/layout_top_left.png"),
BaseUtils.readIcon("/com/fr/plugin/heatpointmapbox/images/layout_top_right.png"),
BaseUtils.readIcon("/com/fr/plugin/heatpointmapbox/images/layout_bottom_right.png"),
BaseUtils.readIcon("/com/fr/plugin/heatpointmapbox/images/layout_bottom_left.png")
};
this.legendPosition = new UIButtonGroup(icons, vals);
this.legendPosition.setAllToolTips(tips);
Component[][] components = new Component[][]{
{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-legendPosition"), 2), this.legendPosition}
} ;
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-HeatPointMap-legendPositionExpand"), components);
}
private JPanel createLegendStylePane() {
this.textAttrPane = new ChartTextAttrPane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-HeatPointMap-LegendStyle"), this.textAttrPane);
}
}