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.
223 lines
8.8 KiB
223 lines
8.8 KiB
package com.fr.plugin.heatpointmapbox.ui; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
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.gui.itextfield.UITextField; |
|
import com.fr.design.i18n.Toolkit; |
|
import com.fr.design.layout.TableLayout; |
|
import com.fr.design.layout.TableLayoutHelper; |
|
import com.fr.json.JSONObject; |
|
import com.fr.plugin.heatpointmapbox.vo.CustomJsonObject; |
|
import com.fr.plugin.heatpointmapbox.vo.PointMapStyleJson; |
|
import com.fr.van.chart.designer.AbstractVanChartScrollPane; |
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
|
|
|
import javax.swing.*; |
|
import java.awt.*; |
|
import java.awt.event.ActionEvent; |
|
import java.awt.event.ActionListener; |
|
|
|
/** |
|
* @author xx |
|
*/ |
|
public class HeatPointMapPointStyleCreator extends AbstractVanChartScrollPane<CustomJsonObject> { |
|
|
|
private UITextArea condition; |
|
|
|
private UITextField legendName; |
|
private UISpinner pointSize; |
|
private ImageChooserPane pointPane; |
|
|
|
|
|
@Override |
|
protected JPanel createContentPane() { |
|
return new ContentPane(); |
|
} |
|
|
|
@Override |
|
public void populateBean(CustomJsonObject json) { |
|
JSONObject chartConf = null; |
|
if (null != json) { |
|
chartConf = json.get(); |
|
} |
|
if (null != chartConf) { |
|
this.legendName.setText(chartConf.getString("legendName")); |
|
this.pointSize.setValue(chartConf.getDouble("pointSize")); |
|
this.condition.setText(chartConf.getString("condition")); |
|
|
|
ImageEntity imgEnt = new ImageEntity(); |
|
imgEnt.setImagestr(chartConf.getString("pointimg")); |
|
imgEnt.setImagetype(chartConf.getString("pointimgtype")); |
|
imgEnt.setWidth(chartConf.getInt("pointimgw")); |
|
imgEnt.setHeight(chartConf.getInt("pointimgh")); |
|
this.pointPane.populateBean(imgEnt); |
|
} |
|
} |
|
|
|
@Override |
|
public CustomJsonObject updateBean() { |
|
JSONObject chartConf = JSONObject.create(); |
|
|
|
chartConf.put("legendName", this.legendName.getText()); |
|
chartConf.put("pointSize", this.pointSize.getValue()); |
|
chartConf.put("condition", this.condition.getText()); |
|
|
|
ImageEntity imgEnt = this.pointPane.updateBean(); |
|
if (null != imgEnt) { |
|
chartConf.put("pointimg", imgEnt.getImagestr()); |
|
chartConf.put("pointimgtype", imgEnt.getImagetype()); |
|
chartConf.put("pointimgw", imgEnt.getWidth()); |
|
chartConf.put("pointimgh", imgEnt.getHeight()); |
|
} |
|
|
|
PointMapStyleJson json = new PointMapStyleJson(); |
|
chartConf.put("title", json.getTilte()); |
|
json.put(chartConf); |
|
return json; |
|
} |
|
|
|
@Override |
|
protected String title4PopupWindow() { |
|
return Toolkit.i18nText("Plugin-HeatPointMap-Cond-pointMapTitle"); |
|
} |
|
|
|
protected class ContentPane extends JPanel { |
|
public ContentPane() { |
|
initComponents(); |
|
} |
|
|
|
private void initComponents() { |
|
this.setLayout(new BorderLayout()); |
|
|
|
JPanel condPane = createConditionPane(); |
|
JPanel stylePane = createStylePane(); |
|
|
|
double p = TableLayout.PREFERRED; |
|
double f = TableLayout.FILL; |
|
double[] columnSize = {f}; |
|
double[] rowSize = {p, p, p}; |
|
Component[][] acomponents = new Component[][]{ |
|
new Component[]{condPane}, |
|
new Component[]{stylePane} |
|
}; |
|
|
|
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents, rowSize, columnSize); |
|
this.add(panel, BorderLayout.CENTER); |
|
this.setVisible(true); |
|
} |
|
} |
|
|
|
private JPanel createStylePane() { |
|
|
|
this.legendName = new UITextField(); |
|
this.pointSize = new UISpinner(0, 1000, 1, 32); |
|
this.pointPane = new ImageChooserPane(); |
|
|
|
Component[][] components = new Component[][]{ |
|
{null, null}, |
|
//new Component[]{new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-Cond-legendName")), this.legendName}, |
|
new Component[]{new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-Cond-pointSize")), this.pointSize} |
|
}; |
|
|
|
double p = TableLayout.PREFERRED; |
|
double[] columnSize = {TableLayout.PREFERRED, TableLayout.FILL}; |
|
double[] rowSize = {p, p, p}; |
|
JPanel sizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
|
|
|
Component[][] comp1 = new Component[][]{ |
|
new Component[]{sizePane}, |
|
new Component[]{pointPane} |
|
}; |
|
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(comp1, new double[]{p, p, p}, new double[]{TableLayout.FILL}); |
|
|
|
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-HeatPointMap-Cond-PointMapStyleExpand"), panel); |
|
} |
|
|
|
private JPanel createConditionPane() { |
|
condition = new UITextArea(3, 6); |
|
|
|
final UITextField typevalue = new UITextField(); |
|
final UIComboBox typecond = new UIComboBox(new String[]{"=="}); |
|
UILabel type = new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-Cond-typeNameLabel")); |
|
UIButton addType = new UIButton(Toolkit.i18nText("Plugin-HeatPointMap-Cond-addButton")); |
|
|
|
final UITextField datavalue = new UITextField(); |
|
final UIComboBox datacond = new UIComboBox(new String[]{"=="}); |
|
UILabel data = new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-Cond-dataTypeLabel")); |
|
UIButton addData = new UIButton(Toolkit.i18nText("Plugin-HeatPointMap-Cond-addButton")); |
|
|
|
final UITextField value = new UITextField(); |
|
final UIComboBox cond = new UIComboBox(new String[]{"==", ">", "<"}); |
|
UILabel name = new UILabel(Toolkit.i18nText("Plugin-HeatPointMap-Cond-valueNameLabel")); |
|
UIButton add = new UIButton(Toolkit.i18nText("Plugin-HeatPointMap-Cond-addButton")); |
|
|
|
UIButton clear = new UIButton(Toolkit.i18nText("Plugin-HeatPointMap-Cond-clearButton")); |
|
|
|
double p = TableLayout.PREFERRED; |
|
double f = TableLayout.FILL; |
|
Component[][] components = new Component[][]{ |
|
new Component[]{type, typecond, typevalue, addType, null}, |
|
new Component[]{data, datacond, datavalue, addData, null}, |
|
new Component[]{name, cond, value, add, clear} |
|
}; |
|
JPanel condPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p, p, p}, new double[]{p, p, f, p, p}); |
|
|
|
Component[][] comp1 = new Component[][]{ |
|
new Component[]{condition} |
|
}; |
|
JPanel areaPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comp1, new double[]{p}, new double[]{f}); |
|
|
|
Component[][] comp = new Component[][]{ |
|
new Component[]{condPane}, |
|
new Component[]{areaPane} |
|
}; |
|
JPanel sumPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comp, new double[]{p, p}, new double[]{f}); |
|
|
|
condition.setEnabled(false); |
|
add.addActionListener(new ActionListener() { |
|
@Override |
|
public void actionPerformed(ActionEvent e) { |
|
String srcStr = condition.getText(); |
|
if (null != srcStr && !"".equals(srcStr)) { |
|
srcStr += " && "; |
|
} |
|
String condstr = "{数值} " + cond.getSelectedItem() + " " + value.getText(); |
|
condition.setText(srcStr + condstr); |
|
} |
|
}); |
|
addData.addActionListener(new ActionListener() { |
|
@Override |
|
public void actionPerformed(ActionEvent e) { |
|
String srcStr = condition.getText(); |
|
if (null != srcStr && !"".equals(srcStr)) { |
|
srcStr += " && "; |
|
} |
|
String condstr = "'{数据类型}' " + datacond.getSelectedItem() + " '" + datavalue.getText() + "'"; |
|
condition.setText(srcStr + condstr); |
|
} |
|
}); |
|
addType.addActionListener(new ActionListener() { |
|
@Override |
|
public void actionPerformed(ActionEvent e) { |
|
String srcStr = condition.getText(); |
|
if (null != srcStr && !"".equals(srcStr)) { |
|
srcStr += " && "; |
|
} |
|
String condstr = "'{数据分类}' " + typecond.getSelectedItem() + " '" + typevalue.getText() + "'"; |
|
condition.setText(srcStr + condstr); |
|
} |
|
}); |
|
|
|
clear.addActionListener(new ActionListener() { |
|
@Override |
|
public void actionPerformed(ActionEvent e) { |
|
condition.setText(""); |
|
} |
|
}); |
|
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-HeatPointMap-Cond-condTaskStyleTitle"), sumPane); |
|
} |
|
|
|
}
|
|
|