Browse Source

提交开源任务材料

10.0
LAPTOP-SB56SG4Q\86185 3 years ago
parent
commit
110a6063b9
  1. 7
      README.md
  2. BIN
      lib/finekit-10.0.jar
  3. 19
      plugin.xml
  4. 396
      src/main/java/com/fr/plugin/third/party/jsdggac/CustomChartConfig.java
  5. 60
      src/main/java/com/fr/plugin/third/party/jsdggac/CustomChartType.java
  6. 63
      src/main/java/com/fr/plugin/third/party/jsdggac/CustomChartUI.java
  7. 198
      src/main/java/com/fr/plugin/third/party/jsdggac/CustomGanttDataFactory.java
  8. 39
      src/main/java/com/fr/plugin/third/party/jsdggac/UIComboBoxWithNone.java
  9. 197
      src/main/java/com/fr/plugin/third/party/jsdggac/color/ColorUtils.java
  10. 37
      src/main/java/com/fr/plugin/third/party/jsdggac/data/CustomGanttColumnFieldCollection.java
  11. 55
      src/main/java/com/fr/plugin/third/party/jsdggac/data/CustomGanttDataCellFieldsPane.java
  12. 57
      src/main/java/com/fr/plugin/third/party/jsdggac/data/CustomGanttDataSetFieldsPane.java
  13. 59
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/ColorSectionPane.java
  14. 251
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/ColorSeriesConfPane.java
  15. 46
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/ColorSettingPane.java
  16. 461
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomFRFontPane.java
  17. 49
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomGanttTypePane.java
  18. 72
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomMultiTabPane.java
  19. 47
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomStyleContentPane.java
  20. 33
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomStylePane.java
  21. 75
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/CylinderWidthConfPane.java
  22. 51
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/DisplayScaleConfPane.java
  23. 45
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/spinner/CustomUIBoundSpinner.java
  24. 399
      src/main/java/com/fr/plugin/third/party/jsdggac/ui/spinner/CustomUISpinner.java
  25. BIN
      src/main/resources/com/fr/plugin/third/party/jsdggac/images/bbb.png
  26. BIN
      src/main/resources/com/fr/plugin/third/party/jsdggac/images/ccc.png
  27. BIN
      src/main/resources/com/fr/plugin/third/party/jsdggac/images/chart_icon.png
  28. BIN
      src/main/resources/com/fr/plugin/third/party/jsdggac/images/chart_type.png
  29. BIN
      src/main/resources/com/fr/plugin/third/party/jsdggac/images/chart_type_demo.png
  30. 0
      src/main/resources/com/fr/plugin/third/party/jsdggac/web/common.css
  31. 65
      src/main/resources/com/fr/plugin/third/party/jsdggac/web/customGanttPlusWrapper.js
  32. 65
      src/main/resources/com/fr/plugin/third/party/jsdggac/web/custom_map.js
  33. 7
      src/main/resources/com/fr/plugin/third/party/jsdggac/web/echarts-adapter.js
  34. 1
      src/main/resources/com/fr/plugin/third/party/jsdggac/web/echarts-gl.min.js
  35. 45
      src/main/resources/com/fr/plugin/third/party/jsdggac/web/echarts.min.js
  36. 1
      实现方案.txt

7
README.md

@ -1,3 +1,6 @@
# open-JSD-6602 # open-JSD-6602 热力图
JSD-6602 热力图 JSD-6602 热力图\
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
仅作为开发者学习参考使用!禁止用于任何商业用途!\
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。

BIN
lib/finekit-10.0.jar

Binary file not shown.

19
plugin.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugin>
<id>com.fr.plugin.third.party.jsdggac</id>
<name><![CDATA[矿场人员位置图]]></name>
<active>yes</active>
<version>0.6</version>
<env-version>10.0</env-version>
<jartime>2019-01-01</jartime>
<vendor>fr.open</vendor>
<description><![CDATA[]]></description>
<change-notes><![CDATA[]]></change-notes>
<extra-chart>
<ChartTypeProvider class="com.fr.plugin.third.party.jsdggac.CustomChartType" chartID="CUSTOM_HEAT_MAP_CHART_JSDGGAC"/>
</extra-chart>
<extra-chart-designer>
<IndependentChartUIProvider class="com.fr.plugin.third.party.jsdggac.CustomChartUI" chartID="CUSTOM_HEAT_MAP_CHART_JSDGGAC"/>
</extra-chart-designer>
<function-recorder class="com.fr.plugin.third.party.jsdggac.CustomChartType"/>
</plugin>

396
src/main/java/com/fr/plugin/third/party/jsdggac/CustomChartConfig.java

@ -0,0 +1,396 @@
package com.fr.plugin.third.party.jsdggac;
import com.fanruan.api.report.chart.BaseChartWithData;
import com.fanruan.api.util.AssistKit;
import com.fanruan.api.util.IOKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.chart.cross.FormulaProcessor;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.ChartWebPara;
import com.fr.chart.ChartWebParaProvider;
import com.fr.chartx.data.field.ColumnField;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.plugin.context.PluginContexts;
import com.fr.plugin.third.party.jsdggac.data.CustomGanttColumnFieldCollection;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.web.core.SessionPoolManager;
import com.fr.web.core.TemplateSessionIDInfo;
import java.awt.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
public class CustomChartConfig extends BaseChartWithData {
private static final String ID = "CUSTOM_HEAT_MAP_CHART_JSDGGAC";
private double originX = 0;
private double originY = 0;
private double originDiagonalX = 0;
private double originDiagonalY = 0;
public double getOriginX() {
return originX;
}
public void setOriginX(double originX) {
this.originX = originX;
}
public double getOriginY() {
return originY;
}
public void setOriginY(double originY) {
this.originY = originY;
}
public double getOriginDiagonalX() {
return originDiagonalX;
}
public void setOriginDiagonalX(double originDiagonalX) {
this.originDiagonalX = originDiagonalX;
}
public double getOriginDiagonalY() {
return originDiagonalY;
}
public void setOriginDiagonalY(double originDiagonalY) {
this.originDiagonalY = originDiagonalY;
}
@Override
protected Image designImage(int width, int height, int resolution, ChartWebParaProvider chartWebPara) {
return IOKit.readImageWithCache("com/fr/plugin/third/party/jsdggac/images/chart_type_demo.png");
}
@Override
protected Image exportImage(int width, int height, int resolution, ChartWebParaProvider chartWebPara) {
return null;
}
@Override
public CustomChartConfig clone() throws CloneNotSupportedException {
CustomChartConfig result = (CustomChartConfig) super.clone();
result.setOriginX(this.getOriginX());
result.setOriginY(this.getOriginY());
result.setOriginDiagonalX(this.getOriginDiagonalX());
result.setOriginDiagonalY(this.getOriginDiagonalY());
return result;
}
@Override
public int hashCode() {
return super.hashCode() + AssistKit.hashCode(this.getOriginX()) + AssistKit.hashCode(this.getOriginY()) + AssistKit.hashCode(this.getOriginDiagonalX())
+ AssistKit.hashCode(this.getOriginDiagonalY())
;
}
@Override
public boolean equals(Object ob) {
return super.equals(ob)
&& ob instanceof CustomChartConfig
&& AssistKit.equals(this.getOriginX(), ((CustomChartConfig) ob).getOriginX())
&& AssistKit.equals(this.getOriginY(), ((CustomChartConfig) ob).getOriginY())
&& AssistKit.equals(this.getOriginDiagonalX(), ((CustomChartConfig) ob).getOriginDiagonalX())
&& AssistKit.equals(this.getOriginDiagonalY(), ((CustomChartConfig) ob).getOriginDiagonalY())
;
}
@Override
public JSONObject createAttributeConfig(ChartWebParaProvider chartWebPara) {
JSONObject jsonObject = super.createAttributeConfig(chartWebPara);
jsonObject.put("dataStatus", false);
if (!PluginContexts.currentContext().isAvailable()) {
return jsonObject;
}
if (isDatasEmpty()) {
return jsonObject;
}
JSONObject mapConfigJson = new JSONObject();
mapConfigJson.put("originX", getOriginX());
mapConfigJson.put("originY", getOriginY());
mapConfigJson.put("originDiagonalX", getOriginDiagonalX());
mapConfigJson.put("originDiagonalY", getOriginDiagonalY());
jsonObject.put("mapConfig", mapConfigJson);
//jsonObject.put("coordinates", createCoordinatesContent());
jsonObject.put("datas", createDatas());
jsonObject.put("dataStatus", true);
return jsonObject;
}
@Override
public void dealFormula(FormulaProcessor formulaProcessor) {
super.dealFormula(formulaProcessor);
}
@Override
public String getID() {
return ID;
}
@Override
public void readAttr(XMLableReader xmLableReader) {
super.readAttr(xmLableReader);
setOriginX(xmLableReader.getAttrAsDouble("originX", 10));
if (getOriginX() <= 0) {
setOriginX(10);
}
setOriginY(xmLableReader.getAttrAsDouble("originY", 0));
setOriginDiagonalX(xmLableReader.getAttrAsDouble("originDiagonalX", 0));
setOriginDiagonalY(xmLableReader.getAttrAsDouble("originDiagonalY", 0));
}
@Override
public void writeAttr(XMLPrintWriter xmlPrintWriter) {
super.writeAttr(xmlPrintWriter);
xmlPrintWriter.attr("originX", getOriginX());
xmlPrintWriter.attr("originY", getOriginY());
xmlPrintWriter.attr("originDiagonalX", getOriginDiagonalX());
xmlPrintWriter.attr("originDiagonalY", getOriginDiagonalY());
}
private String createCoordinatesContent() {
/*
[[[[0, 0],[1200, 0],[1200, 800],[0, 800]]]]
*/
String content = "[[[[" + getOriginX() + ", " + getOriginY() + "],[" + getOriginDiagonalX() + "," + getOriginY() + "],[" + getOriginDiagonalX() + ", " + getOriginDiagonalY() + "],[" + getOriginX() + ", " + getOriginDiagonalY() + "]]]]";
return content;
}
private JSONArray createDatas() {
JSONArray datasJson = new JSONArray();
if (isDatasEmpty()) {
return datasJson;
}
CustomGanttColumnFieldCollection columnFieldCollection = getFieldCollection(CustomGanttColumnFieldCollection.class);
if (columnFieldCollection == null) {
return datasJson;
}
List<Object> dataXValues = columnFieldCollection.getDataX().getValues();
List<Object> dataYValues = columnFieldCollection.getDataY().getValues();
double x, y;
for (int i = 0, max = dataXValues.size() - 1; i <= max; i++) {
x = Double.valueOf(String.valueOf(dataXValues.get(i)));
y = Double.valueOf(String.valueOf(dataYValues.get(i)));
datasJson.put(createDataValue(x, y));
}
return datasJson;
}
private JSONArray createDataValue(double x, double y) {
//double xValue = (4220315.5 - y) / 21000 * 4232;
//double yValue = (19513890.5 - x) / 6150 * 1240;
//xValue = (4220315.5 - 1736 / 10040 * 21000 - y) / (21000 * 5992 / 10040) * 5992;
//yValue = (19513890.5 - 120 / 2952 * 6150 - x) / (6150 * 2104 / 2952) * 2104;
//xValue = (4220315.5 - 1697 / 10040 * 21000 - y) / (21000 * 6075 / 10040) * 6075;
//yValue = (19513890.5 - 105 / 2952 * 6150 - x) / (6150 * 2153 / 2952) * 2153;
double xValue = (4220315.5 - y) / 21000 * 10040;
double yValue = (19513890.5 - x) / 6150 * 2952;
xValue = xValue - 1705;
yValue = yValue - 129;
xValue = toValue(xValue);
yValue = toValue(yValue);
JSONArray valueJson = new JSONArray();
valueJson.put(xValue);
valueJson.put(yValue);
return valueJson;
}
private double toValue(double value) {
BigDecimal b = new BigDecimal(value);
double f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
return f1;
}
private String getOwnerChartName(ChartWebPara chartWebPara) {
if (chartWebPara == null) {
return "";
}
WebChartIDInfo chartIDInfo = chartWebPara.getChartIDInfo();
String ownerChartName = chartIDInfo.getName();
if (StringKit.isNotEmpty(ownerChartName)) {
ownerChartName = ownerChartName.toUpperCase();
}
return ownerChartName;
}
private String getBookPath(ChartWebPara chartWebPara) {
if (chartWebPara == null) {
return "";
}
String sessionID = chartWebPara.getSessionID();
TemplateSessionIDInfo templateSessionIDInfo = (TemplateSessionIDInfo) SessionPoolManager.getSessionIDInfor(sessionID, TemplateSessionIDInfo.class);
if (templateSessionIDInfo == null) {
return "";
}
String path = templateSessionIDInfo.getRelativePath();
return path;
}
private String trim(String value) {
String tempValue = StringKit.trim(value);
if (StringKit.isEmpty(tempValue)) {
return "";
}
return tempValue;
}
private List<Integer> toColorList(String content) {
List<Integer> tempColors = new ArrayList<>();
if (StringKit.isEmpty(content)) {
return tempColors;
}
content = content.trim();
if (StringKit.isEmpty(content)) {
return tempColors;
}
String[] tempArray = content.split(",");
if ((tempArray == null) || (tempArray.length <= 0)) {
return tempColors;
}
String tempValue;
int tempColorValue;
for (int i = 0, max = tempArray.length - 1; i <= max; i++) {
tempValue = tempArray[i];
tempColorValue = Integer.valueOf(tempValue);
tempColors.add(tempColorValue);
}
return tempColors;
}
private int getObjectValue(List<Object> objs) {
double tempValue = getObjectDoubleValue(objs);
Double doubleValue = new Double(tempValue);
int value = doubleValue.intValue();
return value;
}
private double getObjectDoubleValue(List<Object> objs) {
double value = 0;
if ((objs == null) || (objs.size() <= 0)) {
return -1;
}
try {
value = Double.valueOf(String.valueOf(objs.get(0)));
} catch (Exception e) {
value = -1;
}
return value;
}
private double getFinishRate(double monthFinishValue, double maxValue) {
double f = monthFinishValue * 1.00 / maxValue;
BigDecimal b = new BigDecimal(f);
double f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
return f1;
}
private double toDouble(Object obj) {
if (obj == null) {
return 0;
}
String tempStr = String.valueOf(obj);
if (StringKit.isEmpty(tempStr)) {
return 0;
}
double value = Double.valueOf(tempStr);
return value;
}
private JSONObject createSymbolJson(int index, List<Object> values) {
JSONObject circleJson = new JSONObject();
circleJson.put("type", "circle");
circleJson.put("path", "");
if (isListEmpty(values) || (index >= values.size())) {
return circleJson;
}
String path = GeneralUtils.objectToString(values.get(index));
if (StringKit.isEmpty(path)) {
return circleJson;
}
JSONObject itemJson = new JSONObject();
itemJson.put("type", "image");
itemJson.put("path", path);
return itemJson;
}
private boolean isListEmpty(List list) {
if ((list == null) || (list.size() <= 0)) {
return true;
}
return false;
}
private boolean isDatasEmpty() {
if (isDataXsEmpty() || isDataYsEmpty()) {
return true;
}
return false;
}
private boolean isDataXsEmpty() {
CustomGanttColumnFieldCollection columnFieldCollection = getFieldCollection(CustomGanttColumnFieldCollection.class);
if (columnFieldCollection == null) {
return true;
}
ColumnField dataXColumnField = columnFieldCollection.getDataX();
if (dataXColumnField == null) {
return true;
}
List<Object> values = dataXColumnField.getValues();
if ((values == null) || (values.size() <= 0)) {
return true;
}
return false;
}
private boolean isDataYsEmpty() {
CustomGanttColumnFieldCollection columnFieldCollection = getFieldCollection(CustomGanttColumnFieldCollection.class);
if (columnFieldCollection == null) {
return true;
}
ColumnField dataXColumnField = columnFieldCollection.getDataY();
if (dataXColumnField == null) {
return true;
}
List<Object> values = dataXColumnField.getValues();
if ((values == null) || (values.size() <= 0)) {
return true;
}
return false;
}
}

60
src/main/java/com/fr/plugin/third/party/jsdggac/CustomChartType.java

@ -0,0 +1,60 @@
package com.fr.plugin.third.party.jsdggac;
import com.fanruan.api.report.chart.BaseChartType;
import com.fanruan.api.report.chart.BaseChartWithData;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.fun.Authorize;
@EnableMetrics
@Authorize(callSignKey = "com.fr.plugin.third.party.jsdggac")
public class CustomChartType extends BaseChartType {
/**
* 该种图表所有的图表对象实例比如柱形图就有堆积柱形图百分比堆积柱形图等等
*
* @return 所有的图表对象实例
*/
@Focus(id = "com.fr.plugin.third.party.jsdggac", text = "plugin-jsd-ggac", source = Original.PLUGIN)
public BaseChartWithData[] getChartTypes() {
return new BaseChartWithData[]{
new CustomChartConfig()
};
}
/**
* 图表在web端展现时需要的JS文件
*
* @return JS文件数组
*/
public String[] getRequiredJS() {
return new String[]{
"com/fr/plugin/third/party/jsdggac/web/echarts.min.js",
"com/fr/plugin/third/party/jsdggac/web/echarts-gl.min.js",
"com/fr/plugin/third/party/jsdggac/web/custom_map.js",
"com/fr/plugin/third/party/jsdggac/web/customGanttPlusWrapper.js",
};
}
/**
* 图表在web端展现时需要的CSS文件
*
* @return CSS文件数组
*/
public String[] getRequiredCss() {
return new String[]{
"com/fr/plugin/third/party/jsdggac/web/common.css"
};
}
/**
* JS对象名该对象一般是一个函数执行后会在给定的dom中绘制图表
*
* @return JS对象名
*/
public String getWrapperName() {
return "customChartJsdggacWrapper";
}
}

63
src/main/java/com/fr/plugin/third/party/jsdggac/CustomChartUI.java

@ -0,0 +1,63 @@
package com.fr.plugin.third.party.jsdggac;
import com.fanruan.api.design.chart.*;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.plugin.third.party.jsdggac.data.CustomGanttDataCellFieldsPane;
import com.fr.plugin.third.party.jsdggac.data.CustomGanttDataSetFieldsPane;
import com.fr.plugin.third.party.jsdggac.ui.CustomGanttTypePane;
import com.fr.plugin.third.party.jsdggac.ui.CustomStylePane;
public class CustomChartUI extends BaseChartTypeUI {
public String CHART_NAME = "矿场热力图";
@Override
public DefaultTypePane getPlotTypePane() {
return new CustomGanttTypePane();
}
@Override
public BaseDataPane getChartDataPane(AttributeChangeListener listener) {
return new BaseDataPane(listener) {
@Override
protected SingleDataPane createSingleDataPane() {
return new SingleDataPane(new CustomGanttDataSetFieldsPane(),
new CustomGanttDataCellFieldsPane()
);
}
};
}
@Override
public BaseOtherPane[] getAttrPaneArray(AttributeChangeListener listener) {
return new BaseOtherPane[]{
//new CustomGanttTitlePane(),
new CustomStylePane(),
// new CustomGanttShowSettingsPane(),
// new VanChartStylePane(listener),
new DefaultOtherPane()};
}
@Override
public String getIconPath() {
return "com/fr/plugin/third/party/jsdggac/images/chart_icon.png";
}
@Override
public String getName() {
return CHART_NAME;
}
@Override
public String[] getSubName() {
return new String[]{
CHART_NAME
};
}
@Override
public String[] getDemoImagePath() {
return new String[]{
"com/fr/plugin/third/party/jsdggac/images/chart_type_demo.png"
};
}
}

198
src/main/java/com/fr/plugin/third/party/jsdggac/CustomGanttDataFactory.java

@ -0,0 +1,198 @@
package com.fr.plugin.third.party.jsdggac;
import com.fanruan.api.util.StringKit;
import com.fr.general.GeneralUtils;
import com.fr.plugin.third.party.jsdggac.data.CustomGanttColumnFieldCollection;
import java.awt.*;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
public class CustomGanttDataFactory {
public static synchronized List<String> createProjectNames(CustomGanttColumnFieldCollection dataSource) {
List<String> projectList = new ArrayList<>();
if (dataSource == null) {
return projectList;
}
//List<Object> projectNames = dataSource.getProjectName().getValues();
List<Object> projectNames = null;
int size = projectNames.size();
if (size <= 0) {
return projectList;
}
String tempValue;
Object tempObj;
for (int i = 0, max = size - 1; i <= max; i++) {
tempObj = projectNames.get(i);
if (tempObj == null) {
tempValue = "";
addNotRepeatingObj(tempValue, projectList);
continue;
}
tempValue = GeneralUtils.objectToString(tempObj);
addNotRepeatingObj(tempValue, projectList);
}
Collections.reverse(projectList);
return projectList;
}
/**
* 针对echarts的bug处理,若系列名称有数字有中文,会默认按数字处理,有中文会显示NaN,故在前面加中文处理
*
* @param name
* @return
*/
private static String createSeriesName(String name) {
String tempName = name;
if (StringKit.isEmpty(name)) {
tempName = "";
}
return "甘特图" + tempName;
}
private static synchronized String objectToString(Object obj) {
String tempValue = GeneralUtils.objectToString(obj);
return tempValue;
}
private static ThreadLocal<SimpleDateFormat> threadLocalFormat = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
}
};
private static ThreadLocal<SimpleDateFormat> threadLocalFormat1 = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
};
/**
* 转为时间戳
*
* @param obj
* @return
*/
private static synchronized long objectToTimestamp(Object obj) {
if (obj == null) {
return 0;
}
Date tempDate = null;
if (obj instanceof Date) {
tempDate = (Date) obj;
return tempDate.getTime();
}
String tempValue = GeneralUtils.objectToString(obj);
if (StringKit.isEmpty(tempValue)) {
return 0;
}
int length = tempValue.length();
try {
if (length == 10) {
tempDate = threadLocalFormat.get().parse(tempValue);
} else if (length == 19) {
tempDate = threadLocalFormat1.get().parse(tempValue);
}
} catch (Exception e) {
return 0;
}
if (tempDate != null) {
return tempDate.getTime();
}
return 0;
}
/**
* 转为0-1的四位小数
*
* @param obj
* @return
*/
private static synchronized double objectToRate(Object obj) {
if (obj == null) {
return 0;
}
double tempValue = 0;
if (obj instanceof Double) {
tempValue = (Double) obj;
} else {
String tempContent = objectToString(obj);
if (StringKit.isEmpty(tempContent)) {
return 0;
}
tempContent = tempContent.trim();
if (StringKit.isEmpty(tempContent)) {
return 0;
}
tempValue = Double.valueOf(tempContent);
}
if (tempValue <= 0) {
return 0;
}
if (tempValue >= 1) {
return 1;
}
BigDecimal bigDecimal = new BigDecimal(String.valueOf(tempValue));
tempValue = bigDecimal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
return tempValue;
}
private static synchronized String objectToRateShow(double value) {
BigDecimal bigDecimal = new BigDecimal(String.valueOf(value));
BigDecimal bigDecimal1 = new BigDecimal("100");
String tempValue = bigDecimal.multiply(bigDecimal1).doubleValue() + "%";
return tempValue;
}
private static synchronized void addNotRepeatingObj(String value, List<String> values) {
String tempValue = value;
if (StringKit.isEmpty(tempValue)) {
tempValue = "";
}
if (values.contains(tempValue)) {
return;
}
values.add(tempValue);
}
private static synchronized int getIndex(String value, List<String> values) {
int index = values.indexOf(value);
return index;
}
public static String rgbToHex(Color color) {
if (color == null) {
return "#000000";
}
String value = "#" + String.format("%02X", color.getRed()) + String.format("%02X", color.getGreen()) + String.format("%02X", color.getBlue());
return value;
}
public static Color colorToGray(Color color) {
if (color == null) {
return new Color(0);
}
int gray = (int) ((color.getRed() * 30 + color.getGreen() * 59 + color.getBlue() * 11 + 50) * 0.01);
return new Color(gray);
}
}

39
src/main/java/com/fr/plugin/third/party/jsdggac/UIComboBoxWithNone.java

@ -0,0 +1,39 @@
package com.fr.plugin.third.party.jsdggac;
import com.fanruan.api.design.ui.component.UIComboBox;
import com.fr.design.i18n.Toolkit;
import java.util.List;
public class UIComboBoxWithNone extends UIComboBox {
protected String getDefaultLocaleString() {
return Toolkit.i18nText("Fine-Design_Chart_Use_None");
}
public UIComboBoxWithNone() {
this.addDefaultItem();
}
public void refreshBoxItems(List var1) {
super.refreshBoxItems(var1);
this.addDefaultItem();
}
public void clearBoxItems() {
super.clearBoxItems();
this.addDefaultItem();
}
private void addDefaultItem() {
this.addItem(this.getDefaultLocaleString());
}
public void setSelectedItem(Object var1) {
super.setSelectedItem(var1);
if (this.getSelectedIndex() == -1) {
super.setSelectedItem(this.getDefaultLocaleString());
}
}
}

197
src/main/java/com/fr/plugin/third/party/jsdggac/color/ColorUtils.java

@ -0,0 +1,197 @@
package com.fr.plugin.third.party.jsdggac.color;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ColorUtils {
/**
* 颜色变暗
*
* @param color
* @return
*/
public static Color toDark(Color color) {
if (color == null) {
return Color.black;
}
float[] hsb = rgb2hsb(color.getRed(), color.getGreen(), color.getBlue());
float h = hsb[0];
float s = hsb[1];
float b = hsb[2];
if (s >= 0.5) {
s = (float) (s - 0.5);
} else {
s = 0;
}
int[] rgb = hsb2rgb(h, s, b);
Color tempColor = new Color(rgb[0], rgb[2], rgb[2]);
return tempColor;
}
public static float[] rgb2hsb(int rgbR, int rgbG, int rgbB) {
assert 0 <= rgbR && rgbR <= 255;
assert 0 <= rgbG && rgbG <= 255;
assert 0 <= rgbB && rgbB <= 255;
int[] rgb = new int[]{rgbR, rgbG, rgbB};
Arrays.sort(rgb);
int max = rgb[2];
int min = rgb[0];
float hsbB = max / 255.0f;
float hsbS = max == 0 ? 0 : (max - min) / (float) max;
float hsbH = 0;
if (max == rgbR && rgbG >= rgbB) {
hsbH = (rgbG - rgbB) * 60f / (max - min) + 0;
} else if (max == rgbR && rgbG < rgbB) {
hsbH = (rgbG - rgbB) * 60f / (max - min) + 360;
} else if (max == rgbG) {
hsbH = (rgbB - rgbR) * 60f / (max - min) + 120;
} else if (max == rgbB) {
hsbH = (rgbR - rgbG) * 60f / (max - min) + 240;
}
return new float[]{hsbH, hsbS, hsbB};
}
public static int[] hsb2rgb(float h, float s, float v) {
assert Float.compare(h, 0.0f) >= 0 && Float.compare(h, 360.0f) <= 0;
assert Float.compare(s, 0.0f) >= 0 && Float.compare(s, 1.0f) <= 0;
assert Float.compare(v, 0.0f) >= 0 && Float.compare(v, 1.0f) <= 0;
float r = 0, g = 0, b = 0;
int i = (int) ((h / 60) % 6);
float f = (h / 60) - i;
float p = v * (1 - s);
float q = v * (1 - f * s);
float t = v * (1 - (1 - f) * s);
switch (i) {
case 0:
r = v;
g = t;
b = p;
break;
case 1:
r = q;
g = v;
b = p;
break;
case 2:
r = p;
g = v;
b = t;
break;
case 3:
r = p;
g = q;
b = v;
break;
case 4:
r = t;
g = p;
b = v;
break;
case 5:
r = v;
g = p;
b = q;
break;
default:
break;
}
return new int[]{(int) (r * 255.0), (int) (g * 255.0),
(int) (b * 255.0)};
}
/**
* 获取渐变颜色 当前颜色到 红绿蓝 渐变
*
* @param color
* @param count
* @return
*/
public static List<Color> getGradientColors(Color color, int count) {
List<Color> colors = new ArrayList<>();
if (count <= 0) {
return colors;
}
if (count <= 1) {
count = 1;
}
int max = count - 1;
if (color == null) {
for (int i = 0; i <= max; i++) {
colors.add(Color.black);
}
return colors;
}
if (count == 1) {
colors.add(color);
return colors;
}
Color endColor = new Color(220, 220, 220);
endColor = Color.RED;
int maxStep = Math.abs(Math.abs(color.getRGB()) - Math.abs(endColor.getRGB()));
int tempStep = Math.abs(Math.abs(color.getRGB()) - Math.abs(Color.GREEN.getRGB()));
if (tempStep >= maxStep) {
maxStep = tempStep;
endColor = Color.GREEN;
}
tempStep = Math.abs(Math.abs(color.getRGB()) - Math.abs(Color.BLUE.getRGB()));
if (tempStep >= maxStep) {
maxStep = tempStep;
endColor = Color.BLUE;
}
endColor = new Color(220, 220, 220);
double redStep = (endColor.getRed() - color.getRed()) / (count + 1);
double greenStep = (endColor.getGreen() - color.getGreen()) / (count + 1);
double blueStep = (endColor.getBlue() - color.getBlue()) / (count + 1);
int redValue = color.getRed();
int greenValue = color.getGreen();
int blueValue = color.getBlue();
double redTempValue = color.getRed();
double greenTempValue = color.getGreen();
double blueTempValue = color.getBlue();
Color tempColor = null;
for (int i = 0; i <= max; i++) {
if (redValue >= 255) {
redValue = 255;
}
if (greenValue >= 255) {
greenValue = 255;
}
if (blueValue >= 255) {
blueValue = 255;
}
tempColor = new Color(redValue, greenValue, blueValue);
colors.add(tempColor);
redTempValue = (redTempValue + redStep);
greenTempValue = (greenTempValue + greenStep);
blueTempValue = (blueTempValue + blueStep);
redValue = (int) redTempValue;
greenValue = (int) greenTempValue;
blueValue = (int) blueTempValue;
}
return colors;
}
public static String rgbToHex(Color color) {
if (color == null) {
return "#000000";
}
String value = "#" + String.format("%02X", color.getRed()) + String.format("%02X", color.getGreen()) + String.format("%02X", color.getBlue());
return value;
}
}

37
src/main/java/com/fr/plugin/third/party/jsdggac/data/CustomGanttColumnFieldCollection.java

@ -0,0 +1,37 @@
package com.fr.plugin.third.party.jsdggac.data;
import com.fanruan.api.report.chart.field.BaseColumnFieldCollection;
import com.fr.chartx.data.field.ColumnField;
public class CustomGanttColumnFieldCollection extends BaseColumnFieldCollection {
/**
* x轴数据
*/
private ColumnField dataX = new ColumnField();
/**
* y轴数据
*/
private ColumnField dataY = new ColumnField();
public ColumnField getDataX() {
return dataX;
}
public void setDataX(ColumnField dataX) {
this.dataX = dataX;
}
public ColumnField getDataY() {
return dataY;
}
public void setDataY(ColumnField dataY) {
this.dataY = dataY;
}
}

55
src/main/java/com/fr/plugin/third/party/jsdggac/data/CustomGanttDataCellFieldsPane.java

@ -0,0 +1,55 @@
package com.fr.plugin.third.party.jsdggac.data;
import com.fanruan.api.design.chart.field.BaseCellDataFieldsPane;
import com.fanruan.api.design.ui.component.formula.UIFormulaTextField;
import java.awt.*;
public class CustomGanttDataCellFieldsPane extends BaseCellDataFieldsPane<CustomGanttColumnFieldCollection> {
private UIFormulaTextField dataXPane;
private UIFormulaTextField dataYPane;
public void initComponents() {
dataXPane = new UIFormulaTextField();
dataYPane = new UIFormulaTextField();
super.initComponents();
}
@Override
protected String[] fieldLabels() {
return new String[]{
"X轴",
"Y轴"
};
}
@Override
protected Component[] fieldComponents() {
return new Component[]{
this.dataXPane,
this.dataYPane,
};
}
@Override
protected UIFormulaTextField[] formulaPanes() {
return new UIFormulaTextField[]{
this.dataXPane,
this.dataYPane,
};
}
@Override
public void populateBean(CustomGanttColumnFieldCollection dataConf) {
populateField(dataXPane, dataConf.getDataX());
populateField(dataYPane, dataConf.getDataY());
}
@Override
public CustomGanttColumnFieldCollection updateBean() {
CustomGanttColumnFieldCollection dataConf = new CustomGanttColumnFieldCollection();
updateField(dataXPane, dataConf.getDataX());
updateField(dataYPane, dataConf.getDataY());
return dataConf;
}
}

57
src/main/java/com/fr/plugin/third/party/jsdggac/data/CustomGanttDataSetFieldsPane.java

@ -0,0 +1,57 @@
package com.fr.plugin.third.party.jsdggac.data;
import com.fanruan.api.design.chart.field.BaseDataSetFieldsPane;
import com.fanruan.api.design.ui.component.UIComboBox;
import com.fr.plugin.third.party.jsdggac.UIComboBoxWithNone;
import java.awt.*;
public class CustomGanttDataSetFieldsPane extends BaseDataSetFieldsPane<CustomGanttColumnFieldCollection> {
private UIComboBoxWithNone dataXPane;
private UIComboBoxWithNone dataYPane;
public void initComponents() {
dataXPane = new UIComboBoxWithNone();
dataYPane = new UIComboBoxWithNone();
super.initComponents();
}
@Override
protected String[] fieldLabels() {
return new String[]{
"X轴",
"Y轴"
};
}
@Override
protected Component[] fieldComponents() {
return new Component[]{
this.dataXPane,
this.dataYPane,
};
}
@Override
protected UIComboBox[] filedComboBoxes() {
return new UIComboBox[]{
this.dataXPane,
this.dataYPane,
};
}
@Override
public void populateBean(CustomGanttColumnFieldCollection dataConf) {
populateField(dataXPane, dataConf.getDataX());
populateField(dataYPane, dataConf.getDataY());
}
@Override
public CustomGanttColumnFieldCollection updateBean() {
CustomGanttColumnFieldCollection dataConf = new CustomGanttColumnFieldCollection();
updateField(dataXPane, dataConf.getDataX());
updateField(dataYPane, dataConf.getDataY());
return dataConf;
}
}

59
src/main/java/com/fr/plugin/third/party/jsdggac/ui/ColorSectionPane.java

@ -0,0 +1,59 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fr.chart.chartglyph.MapHotAreaColor;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.van.chart.range.component.SectionIntervalConfigPaneWithOutNum;
import javax.swing.*;
public class ColorSectionPane extends AbstractAttrNoScrollPane implements UIObserver {
private SectionIntervalConfigPaneWithOutNum sectionIntervalConfigPaneWithOutNum;
protected UIObserverListener uiObserverListener;
public ColorSectionPane() {
if (this.shouldResponseChangeListener()) {
addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
if (ColorSectionPane.this.uiObserverListener != null) {
ColorSectionPane.this.uiObserverListener.doChange();
}
}
});
}
}
@Override
protected JPanel createContentPane() {
sectionIntervalConfigPaneWithOutNum = new SectionIntervalConfigPaneWithOutNum(this);
return sectionIntervalConfigPaneWithOutNum;
}
public void updateBean(MapHotAreaColor mapHotAreaColor) {
sectionIntervalConfigPaneWithOutNum.updateBean(mapHotAreaColor);
}
public void populateBean(MapHotAreaColor mapHotAreaColor) {
sectionIntervalConfigPaneWithOutNum.populateBean(mapHotAreaColor);
}
public String title4PopupWindow() {
return "区域颜色设置";
}
@Override
public void registerChangeListener(UIObserverListener uiObserverListener) {
this.uiObserverListener = uiObserverListener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
}

251
src/main/java/com/fr/plugin/third/party/jsdggac/ui/ColorSeriesConfPane.java

@ -0,0 +1,251 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fanruan.api.design.DesignKit;
import com.fr.base.BaseUtils;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
public class ColorSeriesConfPane extends BasicPane {
private JList colorList;
private UIButton addButton;
private UIButton editButton;
private UIButton removeButton;
private UIButton moveUpButton;
private UIButton moveDownButton;
ActionListener addActionListener = new ActionListener() {
public void actionPerformed(ActionEvent var1) {
final ColorSettingPane var2 = new ColorSettingPane();
BasicDialog var3 = var2.showSmallWindow(SwingUtilities.getWindowAncestor(ColorSeriesConfPane.this), new DialogActionAdapter() {
public void doOk() {
Color var1 = var2.update();
if (var1 != null) {
DefaultListModel var2x = (DefaultListModel) ColorSeriesConfPane.this.colorList.getModel();
var2x.addElement(var1);
ColorSeriesConfPane.this.colorList.setSelectedIndex(var2x.size() - 1);
}
}
});
var3.setTitle("增加颜色...");
var3.setVisible(true);
}
};
ActionListener editActionListener = new ActionListener() {
public void actionPerformed(ActionEvent var1) {
ColorSeriesConfPane.this.editPrinterList();
}
};
ActionListener removeActionListener = new ActionListener() {
public void actionPerformed(ActionEvent var1) {
int var2 = ColorSeriesConfPane.this.colorList.getSelectedIndex();
if (var2 != -1) {
int var3 = FineJOptionPane.showConfirmDialog(ColorSeriesConfPane.this, "你确实想删除选中的颜色吗?", DesignKit.i18nText("Fine-Design_Basic_Remove"), 2, 3);
if (var3 == 0) {
((DefaultListModel) ColorSeriesConfPane.this.colorList.getModel()).remove(var2);
if (ColorSeriesConfPane.this.colorList.getModel().getSize() > 0) {
if (var2 < ColorSeriesConfPane.this.colorList.getModel().getSize()) {
ColorSeriesConfPane.this.colorList.setSelectedIndex(var2);
} else {
ColorSeriesConfPane.this.colorList.setSelectedIndex(ColorSeriesConfPane.this.colorList.getModel().getSize() - 1);
}
}
ColorSeriesConfPane.this.checkButtonEnabled();
}
}
}
};
ActionListener moveUpActionListener = new ActionListener() {
public void actionPerformed(ActionEvent var1) {
int var2 = ColorSeriesConfPane.this.colorList.getSelectedIndex();
if (var2 > 0) {
DefaultListModel var3 = (DefaultListModel) ColorSeriesConfPane.this.colorList.getModel();
Object var4 = var3.get(var2 - 1);
var3.set(var2 - 1, var3.get(var2));
var3.set(var2, var4);
ColorSeriesConfPane.this.colorList.setSelectedIndex(var2 - 1);
ColorSeriesConfPane.this.checkButtonEnabled();
}
}
};
ActionListener moveDownActionListener = new ActionListener() {
public void actionPerformed(ActionEvent var1) {
int var2 = ColorSeriesConfPane.this.colorList.getSelectedIndex();
if (var2 != -1) {
if (var2 < ColorSeriesConfPane.this.colorList.getModel().getSize() - 1) {
DefaultListModel var3 = (DefaultListModel) ColorSeriesConfPane.this.colorList.getModel();
Object var4 = var3.get(var2 + 1);
var3.set(var2 + 1, var3.get(var2));
var3.set(var2, var4);
ColorSeriesConfPane.this.colorList.setSelectedIndex(var2 + 1);
ColorSeriesConfPane.this.checkButtonEnabled();
}
}
}
};
ListSelectionListener printerSelectionListener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent var1) {
ColorSeriesConfPane.this.checkButtonEnabled();
}
};
MouseAdapter mouseClickedListener = new MouseAdapter() {
public void mouseClicked(MouseEvent var1) {
int var2 = var1.getClickCount();
if (var2 >= 2) {
ColorSeriesConfPane.this.editPrinterList();
}
}
};
public class ColorRenderer extends JLabel implements ListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
if ((value != null) && (value instanceof Color)) {
Color color = (Color) value;
this.setOpaque(true); //此句是重点,设置背景颜色必须先将它设置为不透明的,因为默认是透明的。。。
this.setText(" ");
this.setBackground(color);
}
return this;
}
}
public ColorSeriesConfPane() {
this.initComponents();
}
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(6, 2, 4, 2));
JToolBar var1 = new JToolBar();
this.add(var1, "North");
Dimension var2 = new Dimension(24, 24);
this.addButton = new UIButton(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"));
this.addButton.addActionListener(this.addActionListener);
this.addButton.setToolTipText(DesignKit.i18nText("Fine-Design_Basic_Add"));
this.addButton.setPreferredSize(var2);
this.editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/edit.png"));
this.editButton.addActionListener(this.editActionListener);
this.editButton.setToolTipText(DesignKit.i18nText("Fine-Design_Report_Edit"));
this.editButton.setPreferredSize(var2);
this.removeButton = new UIButton(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png"));
this.removeButton.addActionListener(this.removeActionListener);
this.removeButton.setToolTipText(DesignKit.i18nText("Fine-Design_Basic_Remove"));
this.removeButton.setPreferredSize(var2);
this.moveUpButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/up.png"));
this.moveUpButton.addActionListener(this.moveUpActionListener);
this.moveUpButton.setToolTipText(DesignKit.i18nText("Fine-Design_Basic_Utils_Move_Up"));
this.moveUpButton.setPreferredSize(var2);
this.moveDownButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/down.png"));
this.moveDownButton.addActionListener(this.moveDownActionListener);
this.moveDownButton.setToolTipText(DesignKit.i18nText("Fine-Design_Basic_Utils_Move_Down"));
this.moveDownButton.setPreferredSize(var2);
var1.add(this.addButton);
var1.add(this.editButton);
var1.add(this.removeButton);
var1.add(this.moveUpButton);
var1.add(this.moveDownButton);
this.colorList = new JList(new DefaultListModel());
this.colorList.addListSelectionListener(this.printerSelectionListener);
this.colorList.addMouseListener(this.mouseClickedListener);
this.colorList.setCellRenderer(new ColorRenderer());
this.add(new JScrollPane(this.colorList), "Center");
this.checkButtonEnabled();
}
protected String title4PopupWindow() {
return "完成颜色设置";
}
private void checkButtonEnabled() {
this.editButton.setEnabled(false);
this.removeButton.setEnabled(false);
this.moveUpButton.setEnabled(false);
this.moveDownButton.setEnabled(false);
int var1 = this.colorList.getSelectedIndex();
if (var1 >= 0) {
this.editButton.setEnabled(true);
this.removeButton.setEnabled(true);
if (var1 > 0) {
this.moveUpButton.setEnabled(true);
}
if (var1 < this.colorList.getModel().getSize() - 1) {
this.moveDownButton.setEnabled(true);
}
}
}
public void editPrinterList() {
final int var1 = this.colorList.getSelectedIndex();
final ColorSettingPane var2 = new ColorSettingPane();
BasicDialog var3 = var2.showSmallWindow(SwingUtilities.getWindowAncestor(this), new DialogActionAdapter() {
public void doOk() {
Color var1x = var2.update();
if (var1x != null) {
DefaultListModel var2x = (DefaultListModel) ColorSeriesConfPane.this.colorList.getModel();
var2x.remove(var1);
var2x.add(var1, var1x);
ColorSeriesConfPane.this.colorList.setSelectedIndex(var1);
}
}
});
var2.populate((Color) this.colorList.getSelectedValue());
var3.setTitle( "编辑颜色...");
var3.setVisible(true);
}
public void populate(List<Integer> colors) {
DefaultListModel var3 = (DefaultListModel) this.colorList.getModel();
var3.removeAllElements();
if ((colors == null) || (colors.size() <= 0)) {
return;
}
int size = colors.size();
for (int i = 0, max = size - 1; i <= max; i++) {
var3.addElement(new Color(colors.get(i)));
}
if (size >= 1) {
this.colorList.setSelectedIndex(0);
}
}
public List update() {
List<Integer> var2 = new ArrayList();
DefaultListModel var3 = (DefaultListModel) this.colorList.getModel();
Color color;
for (int i = 0, max = var3.size() - 1; i <= max; i++) {
color = (Color) var3.get(i);
var2.add(color.getRGB());
}
return var2;
}
}

46
src/main/java/com/fr/plugin/third/party/jsdggac/ui/ColorSettingPane.java

@ -0,0 +1,46 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.color.NewColorSelectBox;
import java.awt.*;
public class ColorSettingPane extends BasicPane {
//private ColorBackgroundQuickPane colorBackgroundQuickPane;
private NewColorSelectBox colorBackgroundQuickPane;
public ColorSettingPane() {
this.initComponents();
}
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
colorBackgroundQuickPane = new NewColorSelectBox(100);
this.add(new UILabel("设置颜色"), BorderLayout.NORTH);
this.add(colorBackgroundQuickPane, BorderLayout.CENTER);
}
public void checkValid() throws Exception {
}
protected boolean isShowHelpButton() {
return false;
}
protected String title4PopupWindow() {
return "设置颜色";
}
public void populate(Color var1) {
//this.colorBackgroundQuickPane.populateColor(var1);
this.colorBackgroundQuickPane.setSelectObject(var1);
}
public Color update() {
//return this.colorBackgroundQuickPane.updateColor();
return this.colorBackgroundQuickPane.getSelectObject();
}
}

461
src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomFRFontPane.java

@ -0,0 +1,461 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fanruan.api.design.DesignKit;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Style;
import com.fr.base.Utils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.style.AbstractBasicStylePane;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.DefaultValues;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector;
/**
* Pane to edit Font.
*/
public class CustomFRFontPane extends AbstractBasicStylePane implements GlobalNameObserver {
public static final Integer[] FONT_SIZES = {
6, 8, 9, 10, 11, 12, 13, 14, 16,
18, 20, 22, 24, 26, 28, 30, 32, 34,
36, 38, 40, 48, 64, 72, 128
};
private static final int MAX_FONT_SIZE = 100;
private static final Dimension BUTTON_SIZE = new Dimension(20, 18);
private static final Dimension UNDER_LINE_SIZE = new Dimension(87, 20);
private static final Dimension HIDE_SIZE = new Dimension(0, 0);
private final String[] fontSizeStyles = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Plain"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Bold"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Italic"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Bolditalic")};
private JPanel buttonPane;
private JPanel isSuperOrSubPane;
private UIComboBox fontNameComboBox;
private UIComboBox fontSizeStyleComboBox;
protected UIComboBox fontSizeComboBox;
private UIToggleButton bold;
private UIToggleButton italic;
private UIToggleButton underline;
private GlobalNameListener globalNameListener = null;
// underline
private LineComboBox underlineCombo;
private UIColorButton colorSelectPane;
// effects.
private UIToggleButton isStrikethroughCheckBox;
private UIToggleButton isShadowCheckBox;
private UIToggleButton superPane;
private UIToggleButton subPane;
private JPanel linePane;
private int italic_bold;
private String title = DesignKit.i18nText("Fine-Design_Report_Sytle_FRFont");
;
/**
* LeftPane和RightPane之间的间隙也是fontSizeStyleComboBox与fontSizeComboBox之间的间隙之前的默认值为VGAP_LARGE
*/
private int hGapBetweenLeftPaneAndRightPane = LayoutConstants.VGAP_LARGE;
public CustomFRFontPane(String text) {
this.title = text;
this.initComponents();
}
public CustomFRFontPane() {
this.initComponents();
}
public CustomFRFontPane(int hGapBetweenLeftPaneAndRightPane) {
this.hGapBetweenLeftPaneAndRightPane = hGapBetweenLeftPaneAndRightPane;
this.initComponents();
}
public static void main(String[] args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new CustomFRFontPane(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(290, 400);
jf.setVisible(true);
}
@Override
protected String title4PopupWindow() {
return this.title;
}
/**
* Use font to populate pane.
*/
public void populateBean(FRFont frFont) {
fontNameComboBox.setSelectedItem(frFont.getFamily());
fontSizeStyleComboBox.setSelectedIndex(frFont.getStyle());
fontSizeComboBox.setSelectedItem(Utils.round5(frFont.getSize2D()));
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
// foreground.
this.colorSelectPane.setColor(frFont.getForeground());
this.colorSelectPane.repaint();
// update frFont.
CardLayout cly = (CardLayout) linePane.getLayout();
int line = frFont.getUnderline();
if (line == Constants.LINE_NONE) {
underline.setSelected(false);
cly.show(linePane, "none");
linePane.setPreferredSize(HIDE_SIZE);
} else {
underline.setSelected(true);
cly.show(linePane, "combobox");
linePane.setPreferredSize(UNDER_LINE_SIZE);
this.underlineCombo.setSelectedLineStyle(line);
}
// effects
this.isStrikethroughCheckBox.setSelected(frFont.isStrikethrough());
this.isShadowCheckBox.setSelected(frFont.isShadow());
if (frFont.isSuperscript()) {
this.superPane.setSelected(true);
this.subPane.setSelected(false);
} else if (frFont.isSubscript()) {
this.superPane.setSelected(false);
this.subPane.setSelected(true);
} else {
this.superPane.setSelected(false);
this.subPane.setSelected(false);
}
}
public FRFont updateFRFont() {
FRFont frFont = FRFont.getInstance();
frFont = frFont.applyName((String) fontNameComboBox.getSelectedItem());
frFont = frFont.applyStyle(fontSizeStyleComboBox.getSelectedIndex());
frFont = frFont.applySize(Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()));
frFont = frFont.applyForeground(this.colorSelectPane.getColor());
int line = underline.isSelected() ? this.underlineCombo.getSelectedLineStyle() : Constants.LINE_NONE;
frFont = frFont.applyUnderline(line);
frFont = frFont.applyUnderline(this.underlineCombo.getSelectedLineStyle());
frFont = frFont.applyStrikethrough(isStrikethroughCheckBox.isSelected());
frFont = frFont.applyShadow(isShadowCheckBox.isSelected());
frFont = updateOthers(frFont);
return frFont;
}
/**
* Update pane to get new font.
*/
public FRFont update(FRFont frFont) {
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Name"))) {
frFont = frFont.applyName((String) fontNameComboBox.getSelectedItem());
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Style"))) {
frFont = frFont.applyStyle(fontSizeStyleComboBox.getSelectedIndex());
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size"))) {
frFont = frFont.applySize(Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()));
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Foreground"))) {
frFont = frFont.applyForeground(this.colorSelectPane.getColor());
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Underline"))) {
int line = underline.isSelected() ? this.underlineCombo.getSelectedLineStyle() : Constants.LINE_NONE;
frFont = frFont.applyUnderline(line);
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style"))) {
frFont = frFont.applyUnderline(this.underlineCombo.getSelectedLineStyle());
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Strikethrough"))) {
frFont = frFont.applyStrikethrough(isStrikethroughCheckBox.isSelected());
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Shadow"))) {
frFont = frFont.applyShadow(isShadowCheckBox.isSelected());
}
frFont = updateOthers(frFont);
return frFont;
}
private FRFont updateOthers(FRFont frFont) {
frFont = updateSubSuperscript(frFont);
return frFont;
}
private FRFont updateSubSuperscript(FRFont frFont) {
boolean isSuper = frFont.isSuperscript();
boolean isSub = frFont.isSubscript();
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Superscript"))) {
//如果上标没有选中,点击则选中上标,并且下标一定是不选中状态
//如果上标选中,点击则取消选中上标,字体回复正常
if (superPane.isSelected() && !isSuper) {
frFont = frFont.applySuperscript(true);
frFont = frFont.applySubscript(false);
this.subPane.setSelected(false);
} else if (!superPane.isSelected() && isSuper) {
frFont = frFont.applySuperscript(false);
}
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Subscript"))) {
if (subPane.isSelected() && !isSub) {
frFont = frFont.applySubscript(true);
frFont = frFont.applySuperscript(false);
this.superPane.setSelected(false);
} else if (!subPane.isSelected() && isSub) {
frFont = frFont.applySubscript(false);
}
}
return frFont;
}
@Override
public void populateBean(Style style) {
this.populateBean(style.getFRFont());
}
@Override
public Style update(Style style) {
// TODO Auto-generated method stub
FRFont frFont = style.getFRFont();
frFont = this.update(frFont);
return style.deriveFRFont(frFont);
}
public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>();
for (int i = 1; i < MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i);
}
return FONT_SIZES;
}
protected void initComponents() {
fontSizeStyleComboBox = new UIComboBox(fontSizeStyles);
fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
fontNameComboBox.setPreferredSize(new Dimension(144, 20));
fontSizeComboBox = new UIComboBox(getFontSizes());
fontSizeComboBox.setEditable(true);
this.underlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY);
colorSelectPane = new UIColorButton();
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"));
bold.setPreferredSize(BUTTON_SIZE);
italic.setPreferredSize(BUTTON_SIZE);
underline.setPreferredSize(BUTTON_SIZE);
isStrikethroughCheckBox = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/strikethrough.png"));
isStrikethroughCheckBox.setPreferredSize(BUTTON_SIZE);
isShadowCheckBox = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/shadow.png"));
isShadowCheckBox.setPreferredSize(BUTTON_SIZE);
superPane = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/sup.png"));
superPane.setPreferredSize(BUTTON_SIZE);
subPane = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/sub.png"));
subPane.setPreferredSize(BUTTON_SIZE);
Component[] SuperOrSubComponents = new Component[]{
superPane, subPane
};
isSuperOrSubPane = new JPanel(new BorderLayout());
isSuperOrSubPane.add(GUICoreUtils.createFlowPane(SuperOrSubComponents, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL));
Component[] components_font = new Component[]{
colorSelectPane, underline, isStrikethroughCheckBox, isShadowCheckBox
};
buttonPane = new JPanel(new BorderLayout());
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL));
linePane = new JPanel(new CardLayout());
initAllNames();
setToolTips();
this.setLayout(new BorderLayout());
this.add(createPane(), BorderLayout.CENTER);
DefaultValues defaultValues = FRContext.getDefaultValues();
populateBean(defaultValues.getFRFont());
}
private void initAllNames() {
fontSizeStyleComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Style"));
fontNameComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Name"));
fontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size"));
colorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Foreground"));
italic.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Italic"));
bold.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Bold"));
underline.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Underline"));
underlineCombo.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style"));
isStrikethroughCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Strikethrough"));
isShadowCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Shadow"));
superPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Superscript"));
subPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Subscript"));
}
private void setToolTips() {
colorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Foreground"));
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Italic"));
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Bold"));
underline.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Underline"));
isStrikethroughCheckBox.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Strikethrough"));
isShadowCheckBox.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Shadow"));
superPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Superscript"));
subPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FR_Font_Subscript"));
}
private JPanel createLinePane() {
linePane.add(new JPanel(), "none");
JPanel gap = new JPanel(new GridLayout(0, 1));
gap.add(underlineCombo);
linePane.add(gap, "combobox");
underline.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
CardLayout cly = (CardLayout) linePane.getLayout();
cly.show(linePane, underline.isSelected() ? "combobox" : "none");
if (underline.isSelected()) {
linePane.setPreferredSize(UNDER_LINE_SIZE);
} else {
linePane.setPreferredSize(HIDE_SIZE);
}
}
});
return linePane;
}
private JPanel createLeftPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p};
double[] rowSize = {p, p, p};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{fontSizeStyleComboBox},
new Component[]{buttonPane},
new Component[]{createLinePane()}
};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
protected JPanel createRightPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p, p};
int[][] rowCount = {{1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{fontSizeComboBox},
new Component[]{isSuperOrSubPane}
};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
private JPanel createPane() {
JPanel createPane = new JPanel(new BorderLayout());
Component[] components_font = new Component[]{
fontNameComboBox, fontSizeComboBox, colorSelectPane
};
createPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL));
//createPane.add(fontNameComboBox, BorderLayout.NORTH);
//JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{createLeftPane(), createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, hGapBetweenLeftPaneAndRightPane, LayoutConstants.VGAP_LARGE);
//jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
//createPane.add(jPanel, BorderLayout.CENTER);
return createPane;
}
/**
* @param listener 观察者监听事件
*/
public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener;
}
/**
* @return
*/
public boolean shouldResponseNameListener() {
return false;
}
public void setGlobalName(String name) {
}
private class TwoButtonPane extends JPanel {
public UIToggleButton leftButton;
public UIToggleButton rightButton;
public TwoButtonPane(UIToggleButton leftButton, UIToggleButton rightButton) {
this.leftButton = leftButton;
this.rightButton = rightButton;
this.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 0));
this.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
initButton(leftButton);
initButton(rightButton);
initListener();
}
private void initListener() {
leftButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
rightButton.setSelected(false);
}
});
rightButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
leftButton.setSelected(false);
}
});
}
private void initButton(UIToggleButton button) {
button.setRoundBorder(false);
button.setBorderPainted(false);
this.add(button);
}
protected void paintBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(UIConstants.LINE_COLOR);
int buttonX = getComponent(0).getX();
int buttonY = getComponent(0).getY();
int height = getComponent(0).getHeight();
int width = getComponent(0).getWidth();
g.drawLine(buttonX + width, 0, buttonX + width, height);
width += getComponent(1).getWidth();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect(buttonX - 1, buttonY - 1, width + 2, getHeight() - 1, UIConstants.ARC, UIConstants.ARC);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
}
}

49
src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomGanttTypePane.java

@ -0,0 +1,49 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fanruan.api.design.chart.DefaultTypePane;
import com.fr.plugin.third.party.jsdggac.CustomChartConfig;
import javax.swing.*;
import java.awt.*;
public class CustomGanttTypePane extends DefaultTypePane<CustomChartConfig> {
//private UIButtonGroup buttonGroup = new UIButtonGroup(new String[]{DesignKit.i18nText("Fine-Plugin_Legend_Right"), DesignKit.i18nText("Fine-Plugin_Legend_Left")});
@Override
protected String[] getTypeIconPath() {
return new String[]{
"com/fr/plugin/third/party/jsdggac/images/chart_type.png"
};
}
@Override
protected int getSelectIndexInChart(CustomChartConfig chart) {
return 0;
}
@Override
protected void setSelectIndexInChart(CustomChartConfig chart, int index) {
//chart.setPieType(PieType.parseInt(index));
}
@Override
protected Component[][] getPaneComponents(JPanel typePane) {
return new Component[][]{
new Component[]{typePane},
//new Component[]{buttonGroup}
};
}
@Override
public void populateBean(CustomChartConfig ob) {
super.populateBean(ob);
// buttonGroup.setSelectedIndex(StringKit.equals("left", ob.getLegendPosition()) ? 0 : 1);
}
@Override
public void updateBean(CustomChartConfig ob) {
super.updateBean(ob);
// ob.setLegendPosition(buttonGroup.getSelectedIndex() == 0 ? "left" : "right");
}
}

72
src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomMultiTabPane.java

@ -0,0 +1,72 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UITabGroup;
import javax.swing.*;
import java.awt.*;
import java.util.List;
public abstract class CustomMultiTabPane<T> extends FurtherBasicBeanPane<T> {
private static final long serialVersionUID = 2298609199400393886L;
protected UITabGroup tabPane;
protected String[] NameArray;
protected JPanel centerPane;
protected CardLayout cardLayout = new CardLayout();
protected List<BasicPane> paneList;
protected abstract List<BasicPane> initPaneList();
public abstract void populateBean(T var1);
public abstract void updateBean(T var1);
public int getSelectedIndex() {
return this.tabPane.getSelectedIndex();
}
public CustomMultiTabPane() {
//this.relayoutWhenListChange();
}
public void relayoutWhenListChange() {
this.centerPane = new JPanel(this.cardLayout) {
public Dimension getPreferredSize() {
return getSelectedIndex() == -1 ? super.getPreferredSize() : paneList.get(getSelectedIndex()).getPreferredSize();
}
};
paneList = this.initPaneList();
this.NameArray = new String[this.paneList.size()];
for(int var1 = 0; var1 < this.paneList.size(); ++var1) {
BasicPane var2 = this.paneList.get(var1);
this.NameArray[var1] = var2.getTitle();
this.centerPane.add(var2, this.NameArray[var1]);
}
this.tabPane = new UITabGroup(this.NameArray) {
public void tabChanged(int var1) {
dealWithTabChanged(var1);
}
};
this.tabPane.setSelectedIndex(0);
this.tabPane.tabChanged(0);
this.initLayout();
}
protected void dealWithTabChanged(int var1) {
this.cardLayout.show(this.centerPane, this.NameArray[var1]);
this.tabChanged();
}
protected void tabChanged() {
}
protected void initLayout() {
this.setLayout(new BorderLayout(0, 4));
this.add(this.tabPane, "North");
this.add(this.centerPane, "Center");
}
}

47
src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomStyleContentPane.java

@ -0,0 +1,47 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fr.design.dialog.BasicPane;
import com.fr.plugin.third.party.jsdggac.CustomChartConfig;
import java.util.ArrayList;
import java.util.List;
//import com.fr.design.style.FRFontPane;
public class CustomStyleContentPane extends CustomMultiTabPane<CustomChartConfig> {
private CylinderWidthConfPane cylinderWidthConfPane = new CylinderWidthConfPane();
@Override
protected List<BasicPane> initPaneList() {
List<BasicPane> tempPaneList = new ArrayList<>();
tempPaneList.add(cylinderWidthConfPane);
return tempPaneList;
}
@Override
public void populateBean(CustomChartConfig config) {
cylinderWidthConfPane.populate(config);
}
@Override
public CustomChartConfig updateBean() {
CustomChartConfig config = new CustomChartConfig();
updateBean(config);
return config;
}
@Override
public void updateBean(CustomChartConfig config) {
cylinderWidthConfPane.update(config);
}
@Override
public boolean accept(Object o) {
return true;
}
@Override
public void reset() {
}
}

33
src/main/java/com/fr/plugin/third/party/jsdggac/ui/CustomStylePane.java

@ -0,0 +1,33 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fanruan.api.design.chart.BaseOtherPane;
import com.fr.plugin.third.party.jsdggac.CustomChartConfig;
import javax.swing.*;
public class CustomStylePane extends BaseOtherPane<CustomChartConfig> {
private CustomStyleContentPane contentPane;
@Override
protected JPanel createContentPane() {
contentPane = new CustomStyleContentPane();
contentPane.relayoutWhenListChange();
return contentPane;
}
@Override
protected void populate(CustomChartConfig config) {
contentPane.populateBean(config);
}
@Override
protected void update(CustomChartConfig config) {
contentPane.updateBean(config);
}
@Override
public String title4PopupWindow() {
return "样式";
}
}

75
src/main/java/com/fr/plugin/third/party/jsdggac/ui/CylinderWidthConfPane.java

@ -0,0 +1,75 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fr.design.dialog.BasicPane;
import com.fr.plugin.third.party.jsdggac.CustomChartConfig;
import com.fr.plugin.third.party.jsdggac.ui.spinner.CustomUIBoundSpinner;
import javax.swing.*;
import java.awt.*;
/**
* 柱形宽度配置
*/
public class CylinderWidthConfPane extends BasicPane {
private CustomUIBoundSpinner originXBoundSpinner;
private CustomUIBoundSpinner originYBoundSpinner;
private CustomUIBoundSpinner originDiagonalXBoundSpinner;
private CustomUIBoundSpinner originDiagonalYBoundSpinner;
public CylinderWidthConfPane() {
this.initComponents();
}
protected void initComponents() {
this.setLayout(new BorderLayout());
JPanel panel0 = new JPanel();
panel0.setLayout(new FlowLayout(0, 0, 0));
originXBoundSpinner = new CustomUIBoundSpinner(Integer.MIN_VALUE, Integer.MAX_VALUE, 1, 0);
originYBoundSpinner = new CustomUIBoundSpinner(Integer.MIN_VALUE, Integer.MAX_VALUE, 1, 0);
originDiagonalXBoundSpinner = new CustomUIBoundSpinner(Integer.MIN_VALUE, Integer.MAX_VALUE, 1, 0);
originDiagonalYBoundSpinner = new CustomUIBoundSpinner(Integer.MIN_VALUE, Integer.MAX_VALUE, 1, 0);
Component[][] components = new Component[][]{
{new UILabel("圆点大小:"), originXBoundSpinner},
//{new UILabel("原点坐标Y:"), originYBoundSpinner},
//{new UILabel("原点对角坐标X:"), originDiagonalXBoundSpinner},
// {new UILabel("原点对角坐标Y:"), originDiagonalYBoundSpinner},
};
double p = TableLayoutKit.PREFERRED;
double[] rowSize = new double[]{p, p, p, p};
double[] columnSize = new double[]{p, 100};
JPanel settingsUI = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize);
this.add(settingsUI, BorderLayout.CENTER);
}
protected String title4PopupWindow() {
return "地图设置";
}
public void populate(CustomChartConfig conf) {
originXBoundSpinner.setValue(conf.getOriginX());
originYBoundSpinner.setValue(conf.getOriginY());
originDiagonalXBoundSpinner.setValue(conf.getOriginDiagonalX());
originDiagonalYBoundSpinner.setValue(conf.getOriginDiagonalY());
}
public void update(CustomChartConfig conf) {
conf.setOriginX(originXBoundSpinner.getValue());
conf.setOriginY(originYBoundSpinner.getValue());
conf.setOriginDiagonalX(originDiagonalXBoundSpinner.getValue());
conf.setOriginDiagonalY(originDiagonalYBoundSpinner.getValue());
}
private int getIntegerValue(double value) {
int tempValue = (int) value;
if (tempValue <= 0) {
tempValue = 0;
}
return tempValue;
}
}

51
src/main/java/com/fr/plugin/third/party/jsdggac/ui/DisplayScaleConfPane.java

@ -0,0 +1,51 @@
package com.fr.plugin.third.party.jsdggac.ui;
import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ispinner.UISpinner;
import java.awt.*;
public class DisplayScaleConfPane extends BasicPane {
private UISpinner scaleSpinner;
public DisplayScaleConfPane() {
this.initComponents();
}
protected void initComponents() {
this.setLayout(new FlowLayout(0, 0, 0));
scaleSpinner = new UISpinner(0, 100, 1, 100);
this.add(new UILabel("比例:"));
this.add(scaleSpinner);
}
public void populate(int value) {
if (value <= 0) {
value = 0;
}
if (value >= 100) {
value = 100;
}
scaleSpinner.setValue(value, true);
}
public int update() {
int value = (int) scaleSpinner.getValue();
if (value <= 0) {
value = 0;
}
if (value >= 100) {
value = 100;
}
return value;
}
@Override
protected String title4PopupWindow() {
return "显示比例";
}
}

45
src/main/java/com/fr/plugin/third/party/jsdggac/ui/spinner/CustomUIBoundSpinner.java

@ -0,0 +1,45 @@
package com.fr.plugin.third.party.jsdggac.ui.spinner;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/**
* 定制此组件,是为了修复若组件值和设置值相同时,不显示设置值问题
*/
public class CustomUIBoundSpinner extends CustomUISpinner {
public CustomUIBoundSpinner(double minValue, double maxValue, double dierta) {
super(minValue, maxValue, dierta);
}
public CustomUIBoundSpinner(double minValue, double maxValue, double dierta, double defaultValue) {
super(minValue, maxValue, dierta, defaultValue);
}
@Override
protected void initTextFiledListeners() {
this.getTextField().addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
setTextFieldValue(getTextField().getValue());
setTextField(value);
}
});
this.getTextField().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
setTextFieldValue(getTextField().getValue());
setTextField(value);
}
}
});
}
@Override
protected void setTextField(double value) {
this.getTextField().setValue(value);
}
}

399
src/main/java/com/fr/plugin/third/party/jsdggac/ui/spinner/CustomUISpinner.java

@ -0,0 +1,399 @@
package com.fr.plugin.third.party.jsdggac.ui.spinner;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.stable.CommonUtils;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.ButtonUI;
import java.awt.*;
import java.awt.event.*;
/**
* 定制此组件,是为了修复若组件值和设置值相同时,不显示设置值问题
*/
public class CustomUISpinner extends JPanel implements UIObserver, GlobalNameObserver {
protected double value;
private static final int SIZE = 20;
private static final int LEN = 13;
private static final int WIDTH = 13;
private static final int HEIGHT = 10;
private static final int DEFAULT_NUMBERFIELD_COLUMNS = 2;
private UINumberField textField;
private UIButton preButton;
private UIButton nextButton;
private double minValue;
private double maxValue;
private double dierta;
private String spinnerName = StringUtils.EMPTY;
private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null;
private boolean lessMinValue = false;
/**
* Spinner内的数字文本框长度
*/
private int numberFieldColumns;
public CustomUISpinner(double minValue, double maxValue, double dierta) {
init(minValue, maxValue, dierta);
}
public CustomUISpinner(double minValue, double maxValue, double dierta, double defaultValue) {
init(minValue, maxValue, dierta);
textField.setValue(defaultValue);
}
private void init(double minValue, double maxValue, double dierta) {
this.minValue = minValue;
this.maxValue = maxValue;
this.dierta = dierta;
initComponents();
iniListener();
}
private void iniListener() {
if (shouldResponseChangeListener()) {
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) {
return;
}
uiObserverListener.doChange();
}
});
}
}
/**
* 给组件分别加上FocusListener
*
* @param focusListener 监听事件
*/
public void addUISpinnerFocusListenner(FocusListener focusListener) {
this.addFocusListener(focusListener);
this.textField.addFocusListener(focusListener);
this.preButton.addFocusListener(focusListener);
this.nextButton.addFocusListener(focusListener);
}
public double getValue() {
return value;
}
@Override
public void setGlobalName(String name) {
spinnerName = name;
}
public UINumberField getTextField() {
return textField;
}
public UIButton getNextButton() {
return nextButton;
}
public boolean isLessMinValue() {
return lessMinValue;
}
public void resetLessMinValue() {
lessMinValue = false;
}
public void setValue(double value) {
setValue(value, true);
}
/**
* 赋值但不触发保存,只是展现,一般是populate的时候用
*
* @param value
*/
public void setValueWithoutEvent(double value) {
setValue(value, false);
}
public void setValue(double value, boolean fireStateChange) {
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(spinnerName);
}
lessMinValue = value < minValue;
value = lessMinValue ? minValue : value;
value = value > maxValue ? maxValue : value;
//if (CommonUtils.equals(value, this.value)) {
//return;
//}
this.value = value;
setTextField(value);
if (fireStateChange) {
fireStateChanged();
}
}
protected void setTextField(double value) {
textField.getDocument().removeDocumentListener(docListener);
textField.setValue(value);
textField.getDocument().addDocumentListener(docListener);
}
public void setTextFieldValue(double value) {
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(spinnerName);
}
lessMinValue = value < minValue;
value = lessMinValue ? minValue : value;
value = value > maxValue ? maxValue : value;
if (CommonUtils.equals(value, this.value)) {
return;
}
this.value = value;
fireStateChanged();
}
/**
* 设置Spinner内的数字输入框列数
*
* @param numberFieldColumns 输入框列数
*/
public void setNumberFieldColumns(int numberFieldColumns) {
textField.setColumns(numberFieldColumns);
}
@Override
public void setEnabled(boolean flag) {
super.setEnabled(flag);
this.textField.setEnabled(flag);
this.preButton.setEnabled(flag);
this.nextButton.setEnabled(flag);
}
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.height = SIZE;
return dim;
}
/**
* 增加 a <code>ChangeListener</code> to the listener list.
*
* @param l 监听事件
*/
public void addChangeListener(ChangeListener l) {
this.listenerList.add(ChangeListener.class, l);
}
/**
* 移除 a <code>ChangeListener</code> from the listener list.
*
* @param l 监听事件
*/
public void removeChangeListener(ChangeListener l) {
this.listenerList.remove(ChangeListener.class, l);
}
// august: Process the listeners last to first
protected void fireStateChanged() {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
((ChangeListener) listeners[i + 1]).stateChanged(new ChangeEvent(this));
}
}
}
private class ButtionUI extends UIButtonUI {
private boolean isNormalPaint = true;
@Override
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
if (isPressed(b) && b.isPressedPainted()) {
isNormalPaint = false;
Color pressColor = UIConstants.COMBOBOX_BTN_PRESS;
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), pressColor);
} else if (isRollOver(b)) {
isNormalPaint = false;
Color hoverColor = UIConstants.COMBOBOX_BTN_ROLLOVER;
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), hoverColor);
} else if (b.isNormalPainted()) {
isNormalPaint = true;
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
}
}
@Override
protected void paintModelIcon(ButtonModel model, Icon icon, Graphics g, JComponent c) {
if (isNormalPaint) {
g.setColor(UIConstants.COMBOBOX_BTN_NORMAL);
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
super.paintModelIcon(model, icon, g, c);
}
}
private void initComponents() {
textField = initNumberField();
textField.setMaxValue(maxValue);
textField.setMinValue(minValue);
setValue(value);
preButton = new UIButton(UIConstants.ARROW_UP_ICON) {
@Override
public boolean shouldResponseChangeListener() {
return false;
}
@Override
public ButtonUI getUI() {
return new ButtionUI();
}
};
preButton.setRoundBorder(true, Constants.LEFT);
nextButton = new UIButton(UIConstants.ARROW_DOWN_ICON) {
@Override
public boolean shouldResponseChangeListener() {
return false;
}
@Override
public ButtonUI getUI() {
return new ButtionUI();
}
};
nextButton.setRoundBorder(true, Constants.LEFT);
setLayout(new BorderLayout());
add(textField, BorderLayout.CENTER);
JPanel arrowPane = new JPanel();
arrowPane.setPreferredSize(new Dimension(LEN, SIZE));
arrowPane.setLayout(new GridLayout(2, 1));
preButton.setBounds(0, 1, WIDTH, HEIGHT);
nextButton.setBounds(0, HEIGHT, WIDTH, HEIGHT);
arrowPane.add(preButton);
arrowPane.add(nextButton);
add(arrowPane, BorderLayout.EAST);
componentInitListeners();
}
private void componentInitListeners() {
preButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setValue(value + dierta);
}
});
nextButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setValue(value - dierta);
}
});
addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
setValue(value - e.getWheelRotation());
}
}
});
initTextFiledListeners();
}
protected void initTextFiledListeners() {
textField.getDocument().removeDocumentListener(docListener);
textField.getDocument().addDocumentListener(docListener);
textField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
textField.getDocument().removeDocumentListener(docListener);
textField.setValue(value);
textField.getDocument().addDocumentListener(docListener);
}
});
}
protected UINumberField initNumberField() {
int columns = this.numberFieldColumns == 0 ? DEFAULT_NUMBERFIELD_COLUMNS : this.numberFieldColumns;
return new UINumberField(columns) {
@Override
public boolean shouldResponseChangeListener() {
return false;
}
};
}
private DocumentListener docListener = new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
setTextFieldValue(textField.getValue());
}
@Override
public void insertUpdate(DocumentEvent e) {
setTextFieldValue(textField.getValue());
}
@Override
public void changedUpdate(DocumentEvent e) {
setTextFieldValue(textField.getValue());
}
};
/**
* 给组件登记一个观察者监听事件
*
* @param listener 观察者监听事件
*/
@Override
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
/**
* 组件是否需要响应添加的观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
@Override
public boolean shouldResponseChangeListener() {
return true;
}
/**
* 给组件登记一个全局名字观察者监听事件
*
* @param listener 观察者监听事件
*/
@Override
public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener;
}
/**
* 组件是否需要响应添加的观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
@Override
public boolean shouldResponseNameListener() {
return true;
}
}

BIN
src/main/resources/com/fr/plugin/third/party/jsdggac/images/bbb.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

BIN
src/main/resources/com/fr/plugin/third/party/jsdggac/images/ccc.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

BIN
src/main/resources/com/fr/plugin/third/party/jsdggac/images/chart_icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

BIN
src/main/resources/com/fr/plugin/third/party/jsdggac/images/chart_type.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

BIN
src/main/resources/com/fr/plugin/third/party/jsdggac/images/chart_type_demo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

0
src/main/resources/com/fr/plugin/third/party/jsdggac/web/common.css

65
src/main/resources/com/fr/plugin/third/party/jsdggac/web/customGanttPlusWrapper.js

@ -0,0 +1,65 @@
!(function () {
Van.FRChartBridge.customChartJsdggacWrapper = Van.FRChartBridge.AbstractChart.extend({
_init: function (dom, option) {
//debugger;
var globeChart = echarts.init(dom);
this._setConfigJsdggac(globeChart,option,false);
//globeChart.setOption(globalOption);
return globeChart;
},
_refresh: function (chart, option) {
this._setConfigJsdggac(chart,option,true);
},
_setConfigJsdggac: function (earthChart, option, refreshOption) {
if (!(option.dataStatus === true)) {
return;
}
var mapConfig = option.mapConfig;
var datas = option.datas;
var globalOption = {
backgroundColor: 'transparent',
geo: {
map: 'custom_map',
//aspectScale: 1, // 宽高比
//layoutCenter: ['50%', '50%'], // 位置
//layoutSize: 100, // 大小
left: 0,
top: 0,
right: 0,
bottom: 0,
silent: false,
roam: false,
//zoom: 0.95, //当前视角的缩放比例
//aspectScale: 0.86,
itemStyle: {
borderWidth: 0,
},
},
series: [{
type: 'scatter',
coordinateSystem: 'geo',
symbolSize: mapConfig.originX,
itemStyle: {
color: 'red'
},
data: datas,
}]
};
if (refreshOption && (refreshOption == true)) {
earthChart.setOption(globalOption, true);
return;
}
earthChart.setOption(globalOption);
},
_resize: function (chart) {
chart.resize();
},
_emptyData: function (options) {
return options.series.data.length === 0;
}
})
})();

65
src/main/resources/com/fr/plugin/third/party/jsdggac/web/custom_map.js

File diff suppressed because one or more lines are too long

7
src/main/resources/com/fr/plugin/third/party/jsdggac/web/echarts-adapter.js

@ -0,0 +1,7 @@
var document = {
createElement: function(element) {
if (element == 'canvas') {
return new Canvas();
}
},
};

1
src/main/resources/com/fr/plugin/third/party/jsdggac/web/echarts-gl.min.js vendored

File diff suppressed because one or more lines are too long

45
src/main/resources/com/fr/plugin/third/party/jsdggac/web/echarts.min.js vendored

File diff suppressed because one or more lines are too long

1
实现方案.txt

@ -0,0 +1 @@
用echarts实现
Loading…
Cancel
Save