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.
160 lines
6.0 KiB
160 lines
6.0 KiB
3 years ago
|
package com.fr.plugin.lzljgdmap.ui;
|
||
|
|
||
|
import com.fr.design.gui.frpane.UINumberDragPane;
|
||
|
import com.fr.design.gui.ilable.UILabel;
|
||
|
import com.fr.design.gui.ispinner.UISpinner;
|
||
|
import com.fr.design.i18n.Toolkit;
|
||
|
import com.fr.design.layout.TableLayout;
|
||
|
import com.fr.design.layout.TableLayoutHelper;
|
||
|
import com.fr.extended.chart.ExtendedScrollPane;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.plugin.chart.range.GradualIntervalConfig;
|
||
|
import com.fr.plugin.chart.range.glyph.GradualColorDist;
|
||
|
import com.fr.plugin.lzljgdmap.LzljMapChart;
|
||
|
import com.fr.stable.StringUtils;
|
||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
|
||
|
import com.fr.van.chart.range.component.LegendGradientBar;
|
||
|
|
||
|
import javax.swing.*;
|
||
|
import javax.swing.event.ChangeEvent;
|
||
|
import javax.swing.event.ChangeListener;
|
||
|
import java.awt.*;
|
||
|
import java.util.ArrayList;
|
||
|
|
||
|
/**
|
||
|
* @author fr.open
|
||
|
*/
|
||
|
public class LzljMapStyleHeatMapPane extends ExtendedScrollPane<LzljMapChart> {
|
||
|
|
||
|
private UISpinner radius;
|
||
|
private UISpinner maxValue;
|
||
|
private UINumberDragPane bgOpacity;
|
||
|
|
||
|
private UINumberDragPane interval;
|
||
|
|
||
|
private LegendGradientBar intervalLegend;
|
||
|
|
||
|
|
||
|
@Override
|
||
|
protected JPanel createContentPane() {
|
||
|
return new ContentPane();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void populateBean(LzljMapChart chart) {
|
||
|
JSONObject heatConf = chart.getHeatConf();
|
||
|
this.radius.setValue(heatConf.getDouble("radius"));
|
||
|
this.maxValue.setValue(heatConf.getDouble("maxValue"));
|
||
|
this.bgOpacity.populateBean(heatConf.getDouble("bgOpacity"));
|
||
|
this.interval.populateBean(heatConf.getDouble("interval"));
|
||
|
|
||
|
GradualIntervalConfig intervalConfig = new GradualIntervalConfig();
|
||
|
String intervalColors = heatConf.getString("intervalColors");
|
||
|
String intervalPos = heatConf.getString("intervalPos");
|
||
|
if (StringUtils.isNotEmpty(intervalColors)
|
||
|
&& StringUtils.isNotEmpty(intervalPos)) {
|
||
|
String[] intervalArr = intervalColors.split("\\|");
|
||
|
String[] intervalPosArr = intervalPos.split("\\|");
|
||
|
ArrayList<GradualColorDist> colorsList = new ArrayList();
|
||
|
for (int i = 0; i < intervalArr.length; i++) {
|
||
|
colorsList.add(new GradualColorDist(Float.parseFloat(intervalPosArr[i]), MapUtil.toColor(intervalArr[i])));
|
||
|
}
|
||
|
intervalConfig.setDivStage(intervalArr.length - 1);
|
||
|
intervalConfig.setGradualColorDistList(colorsList);
|
||
|
}
|
||
|
intervalLegend.populate(intervalConfig);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void updateBean(LzljMapChart chart) {
|
||
|
JSONObject heatConf = JSONObject.create();
|
||
|
heatConf.put("radius", this.radius.getValue());
|
||
|
heatConf.put("maxValue", this.maxValue.getValue());
|
||
|
heatConf.put("bgOpacity", this.bgOpacity.updateBean());
|
||
|
heatConf.put("interval", this.interval.updateBean());
|
||
|
|
||
|
GradualIntervalConfig intervalConfig = new GradualIntervalConfig();
|
||
|
intervalLegend.update(intervalConfig);
|
||
|
ArrayList<GradualColorDist> colorsList = intervalConfig.getGradualColorDistList();
|
||
|
String intervalColors = "";
|
||
|
String intervalPos = "";
|
||
|
if (null != colorsList && colorsList.size() > 0) {
|
||
|
for (int i = 0; i < colorsList.size(); i++) {
|
||
|
if (i > 0) {
|
||
|
intervalColors += "|";
|
||
|
intervalPos += "|";
|
||
|
}
|
||
|
intervalColors += MapUtil.toHex(colorsList.get(i).getColor());
|
||
|
intervalPos += colorsList.get(i).getPosition();
|
||
|
}
|
||
|
}
|
||
|
heatConf.put("intervalColors", intervalColors);
|
||
|
heatConf.put("intervalPos", intervalPos);
|
||
|
|
||
|
chart.setHeatConf(heatConf);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String title4PopupWindow() {
|
||
|
return Toolkit.i18nText("Plugin-LzljMap-heattitle");
|
||
|
}
|
||
|
|
||
|
private class ContentPane extends JPanel {
|
||
|
public ContentPane() {
|
||
|
initComponents();
|
||
|
}
|
||
|
|
||
|
private void initComponents() {
|
||
|
this.setLayout(new BorderLayout());
|
||
|
|
||
|
JPanel regionContentPane = createHeatContentPane();
|
||
|
|
||
|
double p = TableLayout.PREFERRED;
|
||
|
double f = TableLayout.FILL;
|
||
|
double[] columnSize = {f};
|
||
|
double[] rowSize = {p, p};
|
||
|
Component[][] acomponents = new Component[][]{
|
||
|
new Component[]{regionContentPane}
|
||
|
};
|
||
|
|
||
|
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents, rowSize, columnSize);
|
||
|
this.add(panel, BorderLayout.CENTER);
|
||
|
this.setVisible(true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private JPanel createHeatContentPane() {
|
||
|
|
||
|
radius = new UISpinner(1, 10000, 1, 30);
|
||
|
maxValue = new UISpinner(1, 10000000, 1, 1);
|
||
|
bgOpacity = new UINumberDragPane(0, 100);
|
||
|
interval = new UINumberDragPane(1, 6);
|
||
|
intervalLegend = new LegendGradientBar();
|
||
|
|
||
|
interval.addChangeListener(new ChangeListener() {
|
||
|
@Override
|
||
|
public void stateChanged(ChangeEvent e) {
|
||
|
Double num = interval.updateBean();
|
||
|
intervalLegend.refreshColorSelectionBtnNum(num.intValue());
|
||
|
}
|
||
|
});
|
||
|
|
||
|
double p = TableLayout.PREFERRED;
|
||
|
double f = TableLayout.FILL;
|
||
|
Component[][] components = new Component[][]{
|
||
|
{null, null},
|
||
|
new Component[]{new UILabel(Toolkit.i18nText("Plugin-LzljMap-heatradius")), this.radius},
|
||
|
new Component[]{new UILabel(Toolkit.i18nText("Plugin-LzljMap-heatmaxValue")), this.maxValue},
|
||
|
new Component[]{new UILabel(Toolkit.i18nText("Plugin-LzljMap-heatbgOpacity")), this.bgOpacity},
|
||
|
new Component[]{new UILabel(Toolkit.i18nText("Plugin-LzljMap-heatinterval")), this.interval},
|
||
|
new Component[]{null, this.intervalLegend}
|
||
|
};
|
||
|
JPanel sizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p, p, p, p, p}, new double[]{p, f});
|
||
|
|
||
|
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-LzljMap-heatMapExpand"), sizePane);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|