JSD-4334 GIS地图集成
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.

215 lines
8.5 KiB

package com.fr.plugin.shdcmap.ui;
import com.fr.chart.base.TextAttr;
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.gui.ispinner.UISpinner;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
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.shdcmap.CustomChart;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
/**
* @author duan.jingliang
*/
public class CustomChartTipsPane extends ExtendedScrollPane<CustomChart> {
private UICheckBox showtips;
private ColorSelectBox tipbgcolor;
private UINumberDragPane tiptransparent;
private ChartTextAttrPane tipTextAttrPane;
private UISpinner tipbgwidth;
private UICheckBox tipcode;
private UICheckBox tippoint;
private UICheckBox tipother;
private UIButtonGroup<Integer> tiptype;
private UITextArea tipJsPane;
private CardLayout tipCardLayout;
@Override
protected JPanel createContentPane() {
return new ContentPane();
}
@Override
public void populateBean(CustomChart chart) {
JSONObject tipsConf = chart.getTipsConf();
showtips.setSelected(tipsConf.getBoolean("showtips"));
tipbgcolor.setSelectObject(MapUtil.toColor(tipsConf.getString("tipbgcolor")));
tiptransparent.populateBean(tipsConf.getDouble("tiptransparent"));
FRFont tipFont = FRFont.getInstance(tipsConf.getString("tipfamily"),
tipsConf.getInt("tipstyle"),
tipsConf.getInt("tipsize"),
MapUtil.toColor(tipsConf.getString("tipcolor")));
tipTextAttrPane.populate(tipFont);
tipbgwidth.setValue(tipsConf.getDouble("tipbgwidth"));
tipcode.setSelected(tipsConf.getBoolean("tipcode"));
tippoint.setSelected(tipsConf.getBoolean("tippoint"));
tipother.setSelected(tipsConf.getBoolean("tipother"));
tiptype.setSelectedItem(tipsConf.getInt("tiptype"));
tipJsPane.setText(tipsConf.getString("tipJsPane"));
}
@Override
public void updateBean(CustomChart chart) {
JSONObject tipsConf = JSONObject.create();
tipsConf.put("showtips", showtips.isSelected());
tipsConf.put("tipbgcolor", MapUtil.toHex(tipbgcolor.getSelectObject()));
tipsConf.put("tiptransparent", tiptransparent.updateBean());
TextAttr tipText = this.tipTextAttrPane.update();
tipsConf.put("tipsize", tipText.getFRFont().getSize());
tipsConf.put("tipstyle", tipText.getFRFont().getStyle());
tipsConf.put("tipfamily", tipText.getFRFont().getFamily());
tipsConf.put("tipcolor", MapUtil.toHex(tipText.getFRFont().getForeground()));
tipsConf.put("tipbgwidth", tipbgwidth.getValue());
tipsConf.put("tipcode", tipcode.isSelected());
tipsConf.put("tippoint", tippoint.isSelected());
tipsConf.put("tipother", tipother.isSelected());
tipsConf.put("tiptype", tiptype.getSelectedItem());
tipsConf.put("tipJsPane", tipJsPane.getText());
chart.setTipsConf(tipsConf);
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-ShdcMap-tipstitle");
}
private class ContentPane extends JPanel {
public ContentPane() {
initComponents();
}
private void initComponents() {
this.setLayout(new BorderLayout());
JPanel tipPane = createTipStylePane();
JPanel tipContentPane = createTipContentPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p, p, p};
Component[][] acomponents = new Component[][]{
new Component[]{tipPane},
new Component[]{tipContentPane}
};
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents, rowSize, columnSize);
this.add(panel, BorderLayout.CENTER);
this.setVisible(true);
}
}
private JPanel createTipStylePane() {
showtips = new UICheckBox(Toolkit.i18nText("Plugin-ShdcMap-showtips"));
tipbgcolor = new ColorSelectBox(100);
tiptransparent = new UINumberDragPane(0.0, 100.0);
tipTextAttrPane = new ChartTextAttrPane();
tipbgwidth = new UISpinner(0.0, 1000.0, 1.0, 200.0);
Component[][] comp1 = new Component[][]{
{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-ShdcMap-tipbgwidth")), this.tipbgwidth},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-ShdcMap-tipbgcolor")), this.tipbgcolor},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-ShdcMap-tiptransparent")), this.tiptransparent}
};
double p = TableLayout.PREFERRED;
double[] columnSize = {TableLayout.PREFERRED, TableLayout.FILL};
double[] rowSize = {p, p, p, p, p};
JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(comp1, rowSize, columnSize);
Component[][] comp2 = new Component[][]{
new Component[]{this.showtips},
new Component[]{panel1},
new Component[]{tipTextAttrPane}
};
JPanel panel2 = TableLayoutHelper.createTableLayoutPane(comp2, new double[]{p, p, p}, new double[]{TableLayout.FILL});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-ShdcMap-PointTipExpand"), panel2);
}
private JPanel createTipContentPane() {
tiptype = new UIButtonGroup<Integer>(new String[]{Toolkit.i18nText("Plugin-ShdcMap-labelTypeCheck"), Toolkit.i18nText("Plugin-ShdcMap-labelTypeJS")}, new Integer[]{1,2});
//tiptype.setSelectedItem(1);
tipcode = new UICheckBox(Toolkit.i18nText("Plugin-ShdcMap-tipcode"));
tippoint = new UICheckBox(Toolkit.i18nText("Plugin-ShdcMap-tippoint"));
tipother = new UICheckBox(Toolkit.i18nText("Plugin-ShdcMap-tipother"));
tipJsPane = new UITextArea(10, 6);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
Component[][] compCheck = new Component[][]{
new Component[]{null, tipcode},
new Component[]{null, tippoint},
new Component[]{null, tipother}
};
final JPanel checkPane = TableLayout4VanChartHelper.createGapTableLayoutPane(compCheck, new double[]{p, p, p, p, p}, new double[]{p, f});
final JPanel cardPane = new JPanel(this.tipCardLayout = new CardLayout()){
@Override
public Dimension getPreferredSize() {
if (null != tiptype.getSelectedItem() && tiptype.getSelectedItem() == 2) {
return tipJsPane.getPreferredSize();
} else {
return checkPane.getPreferredSize();
}
}
};
cardPane.add(checkPane, "check");
cardPane.add(tipJsPane, "js");
this.tipCardLayout.show(cardPane, "check");
tiptype.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent var1x) {
if (tiptype.getSelectedItem() == 1) {
tipCardLayout.show(cardPane, "check");
} else {
tipCardLayout.show(cardPane, "js");
}
}
});
Component[][] compLabel = new Component[][]{
{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-ShdcMap-tiptype")), this.tiptype}
};
JPanel labelTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(compLabel, new double[]{p, p}, new double[]{p, f});
Component[][] comp1 = new Component[][]{
new Component[]{labelTypePane},
new Component[]{cardPane}
};
JPanel pane = TableLayout4VanChartHelper.createGapTableLayoutPane(comp1, new double[]{p, p, p}, new double[]{f});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-ShdcMap-TipConentExpand"), pane);
}
}