Browse Source
Merge in DESIGN/design from release/10.0 to feature/10.0 * commit '0b28fbee04131a98ba0ba1b5cd1c44daf3a24506': (163 commits) REPORT-35253 切换远程到本地设计器的问题 REPORT-34780 && CHART-14441 CHART-14624 调整面积图系列面板不透明的enable属性的check REPORT-35381 && REPORT-35379 CHART-14541 轴标题增加缩进 REPORT-34020 【国际化】非简中设计器-界面右侧面板选择超链接或悬浮元素后下拉框溢出 CHART-14120 英文设计器地图数据面板截断 REPORT-33236 REPORT-31546 公式面板的说明切换偶尔会失效 REPORT-34351 ""改为StringUtils.EMPTY REPORT-33500 日志面板清除日志后同时清除设计器右上角日志提示信息 REPORT-35016【组件生成】目前生成的组件,从组件库拖入模板中会变大 [场景] 从组件库拖入时,不会保持原有的大小。 [解决方案] 将原来的大小,在创建时一并初始化 CHART-14346 CHART-14346 悬浮窗图表组合图不允许选择单元格数据源 REPORT-34954 富文本上标下标不应该可以同时设置 REPORT-34954 富文本上标下标可以同时设置 CHART-14180 优化代码 CHART-14346 && CHART-14180 悬浮图表配置组合图不能选择单元格数据源 && 轴标题隐藏优化 REPORT-34385 修改联网搜索的enable条件 REPORT-34351 修正FineJOptionPane组件showInputDialog()方法点击弹出框的取消键后的行为;在组件重命名后将与自己的原来的名字进行对比的情况去除 ...research/11.0
ju.ju
4 years ago
159 changed files with 5169 additions and 2419 deletions
@ -0,0 +1,14 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-06-12 |
||||
*/ |
||||
public interface ChartWidgetOptionProvider extends ParameterWidgetOptionProvider { |
||||
|
||||
String XML_TAG = "ChartWidgetOptionProvider"; |
||||
|
||||
//在图表区域的开头还是结尾插入
|
||||
boolean isBefore(); |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.ChartWidgetOptionProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-06-12 |
||||
*/ |
||||
@API(level = ChartWidgetOptionProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractChartWidgetOptionProvider extends AbstractProvider implements ChartWidgetOptionProvider { |
||||
|
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isBefore() { |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,68 @@
|
||||
package com.fr.design.ui; |
||||
|
||||
import com.fr.stable.StringUtils; |
||||
import com.teamdev.jxbrowser.chromium.Browser; |
||||
import com.teamdev.jxbrowser.chromium.BrowserContext; |
||||
import com.teamdev.jxbrowser.chromium.ProtocolService; |
||||
import com.teamdev.jxbrowser.chromium.URLResponse; |
||||
|
||||
import javax.activation.MimetypesFileTypeMap; |
||||
import java.io.DataInputStream; |
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.nio.file.Files; |
||||
import java.nio.file.Path; |
||||
import java.nio.file.Paths; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-03-07 |
||||
*/ |
||||
public class Assistant { |
||||
|
||||
public static URLResponse inputStream2Response(InputStream inputStream, String filePath) throws Exception { |
||||
URLResponse response = new URLResponse(); |
||||
DataInputStream stream = new DataInputStream(inputStream); |
||||
byte[] data = new byte[stream.available()]; |
||||
stream.readFully(data); |
||||
response.setData(data); |
||||
String mimeType = getMimeType(filePath); |
||||
response.getHeaders().setHeader("Content-Type", mimeType); |
||||
return response; |
||||
} |
||||
|
||||
|
||||
private static String getMimeType(String path) { |
||||
if (StringUtils.isBlank(path)) { |
||||
return "text/html"; |
||||
} |
||||
if (path.endsWith(".html")) { |
||||
return "text/html"; |
||||
} |
||||
if (path.endsWith(".css")) { |
||||
return "text/css"; |
||||
} |
||||
if (path.endsWith(".js")) { |
||||
return "text/javascript"; |
||||
} |
||||
if (path.endsWith(".svg")) { |
||||
return "image/svg+xml"; |
||||
} |
||||
Path file = new File(path).toPath(); |
||||
try { |
||||
return Files.probeContentType(file); |
||||
} catch (IOException e) { |
||||
return "text/html"; |
||||
} |
||||
} |
||||
|
||||
public static void setEmbProtocolHandler(Browser browser, EmbProtocolHandler handler) { |
||||
BrowserContext browserContext = browser.getContext(); |
||||
ProtocolService protocolService = browserContext.getProtocolService(); |
||||
// 支持读取jar包中文件的自定义协议————emb:/com/fr/design/images/bbs.png
|
||||
protocolService.setProtocolHandler("emb", handler); |
||||
protocolService.setProtocolHandler("file", handler); |
||||
} |
||||
} |
@ -0,0 +1,130 @@
|
||||
package com.fr.design.ui; |
||||
|
||||
import com.fr.base.TemplateUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.EncodeConstants; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.org.apache.commons.codec.net.URLCodec; |
||||
import com.fr.third.org.apache.commons.io.FileUtils; |
||||
import com.fr.third.org.apache.commons.io.FilenameUtils; |
||||
import com.fr.web.struct.AssembleComponent; |
||||
import com.fr.web.struct.AtomBuilder; |
||||
import com.fr.web.struct.PathGroup; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
import com.teamdev.jxbrowser.chromium.ProtocolHandler; |
||||
import com.teamdev.jxbrowser.chromium.URLRequest; |
||||
import com.teamdev.jxbrowser.chromium.URLResponse; |
||||
|
||||
import java.io.ByteArrayInputStream; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.io.StringReader; |
||||
import java.net.URI; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-03-07 |
||||
*/ |
||||
public class EmbProtocolHandler implements ProtocolHandler { |
||||
|
||||
private AssembleComponent component; |
||||
private Map<String, String> map; |
||||
|
||||
public EmbProtocolHandler() { |
||||
|
||||
} |
||||
|
||||
public EmbProtocolHandler(AssembleComponent component) { |
||||
this.component = component; |
||||
} |
||||
|
||||
public EmbProtocolHandler(AssembleComponent component, Map<String, String> map) { |
||||
this.component = component; |
||||
this.map = map; |
||||
} |
||||
|
||||
public EmbProtocolHandler(Map<String, String> map) { |
||||
this.map = map; |
||||
} |
||||
|
||||
@Override |
||||
public URLResponse onRequest(URLRequest req) { |
||||
InputStream inputStream = null; |
||||
try { |
||||
String path = req.getURL(); |
||||
if (path.startsWith("file:")) { |
||||
String url = new URLCodec().decode(path); |
||||
String filePath = TemplateUtils.renderParameter4Tpl(url, map); |
||||
File file = new File(URI.create(filePath).getPath()); |
||||
inputStream = IOUtils.readResource(file.getAbsolutePath()); |
||||
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); |
||||
text = TemplateUtils.renderParameter4Tpl(text, map); |
||||
return Assistant.inputStream2Response(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), path); |
||||
} else if (path.startsWith("emb:dynamic")) { |
||||
URLResponse response = new URLResponse(); |
||||
response.setData(htmlText(map).getBytes()); |
||||
response.getHeaders().setHeader("Content-Type", "text/html"); |
||||
return response; |
||||
} else { |
||||
int index = path.indexOf("="); |
||||
if (index > 0) { |
||||
path = path.substring(index + 1); |
||||
} else { |
||||
path = path.substring(4); |
||||
} |
||||
inputStream = IOUtils.readResource(path); |
||||
return Assistant.inputStream2Response(inputStream, path); |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||
} finally { |
||||
if (inputStream != null) { |
||||
try { |
||||
inputStream.close(); |
||||
} catch (IOException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private String htmlText(Map<String, String> map) { |
||||
PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component); |
||||
StylePath[] stylePaths = pathGroup.toStylePathGroup(); |
||||
StringBuilder styleText = new StringBuilder(); |
||||
for (StylePath path : stylePaths) { |
||||
if (StringUtils.isNotBlank(path.toFilePath())) { |
||||
styleText.append("<link rel=\"stylesheet\" href=\"emb:"); |
||||
styleText.append(path.toFilePath()); |
||||
styleText.append("\"/>"); |
||||
} |
||||
} |
||||
String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString()); |
||||
ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup(); |
||||
StringBuilder scriptText = new StringBuilder(); |
||||
for (ScriptPath path : scriptPaths) { |
||||
if (StringUtils.isNotBlank(path.toFilePath())) { |
||||
scriptText.append("<script src=\"emb:"); |
||||
scriptText.append(path.toFilePath()); |
||||
scriptText.append("\"></script>"); |
||||
} |
||||
} |
||||
result = result.replaceAll("##script##", scriptText.toString()); |
||||
if (map != null) { |
||||
for (Map.Entry<String, String> entry : map.entrySet()) { |
||||
String key = entry.getKey(); |
||||
String value = entry.getValue(); |
||||
result = result.replaceAll("\\$\\{" + key + "}", value); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
} |
@ -1,85 +0,0 @@
|
||||
package com.fr.design.ui; |
||||
|
||||
import com.fr.general.IOUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.web.struct.AssembleComponent; |
||||
import com.fr.web.struct.AtomBuilder; |
||||
import com.fr.web.struct.PathGroup; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
import com.teamdev.jxbrowser.net.Network; |
||||
import com.teamdev.jxbrowser.net.UrlRequest; |
||||
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; |
||||
|
||||
import java.io.InputStream; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2020/3/25 |
||||
*/ |
||||
public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallback { |
||||
|
||||
private AssembleComponent component; |
||||
|
||||
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component) { |
||||
super(network); |
||||
this.component = component; |
||||
} |
||||
|
||||
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component, Map<String, String> map) { |
||||
super(network, map); |
||||
this.component = component; |
||||
} |
||||
|
||||
@Override |
||||
protected Response next(UrlRequest urlRequest, String path) { |
||||
if (path.startsWith("emb:dynamic")) { |
||||
String text = htmlText(map); |
||||
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, "text/html", text.getBytes(StandardCharsets.UTF_8))); |
||||
} else { |
||||
int index = path.indexOf("="); |
||||
if (index > 0) { |
||||
path = path.substring(index + 1); |
||||
} else { |
||||
path = path.substring(4); |
||||
} |
||||
InputStream inputStream = IOUtils.readResource(path); |
||||
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); |
||||
} |
||||
} |
||||
|
||||
private String htmlText(Map<String, String> map) { |
||||
PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component); |
||||
StylePath[] stylePaths = pathGroup.toStylePathGroup(); |
||||
StringBuilder styleText = new StringBuilder(); |
||||
for (StylePath path : stylePaths) { |
||||
if (StringUtils.isNotBlank(path.toFilePath())) { |
||||
styleText.append("<link rel=\"stylesheet\" href=\"emb:"); |
||||
styleText.append(path.toFilePath()); |
||||
styleText.append("\"/>"); |
||||
} |
||||
} |
||||
String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString()); |
||||
ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup(); |
||||
StringBuilder scriptText = new StringBuilder(); |
||||
for (ScriptPath path : scriptPaths) { |
||||
if (StringUtils.isNotBlank(path.toFilePath())) { |
||||
scriptText.append("<script src=\"emb:"); |
||||
scriptText.append(path.toFilePath()); |
||||
scriptText.append("\"></script>"); |
||||
} |
||||
} |
||||
result = result.replaceAll("##script##", scriptText.toString()); |
||||
if (map != null) { |
||||
for (Map.Entry<String, String> entry : map.entrySet()) { |
||||
String key = entry.getKey(); |
||||
String value = entry.getValue(); |
||||
result = result.replaceAll("\\$\\{" + key + "}", value); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
} |
@ -1,134 +0,0 @@
|
||||
package com.fr.design.ui; |
||||
|
||||
import com.fr.base.TemplateUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.EncodeConstants; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.org.apache.commons.codec.net.URLCodec; |
||||
import com.teamdev.jxbrowser.net.HttpHeader; |
||||
import com.teamdev.jxbrowser.net.HttpStatus; |
||||
import com.teamdev.jxbrowser.net.Network; |
||||
import com.teamdev.jxbrowser.net.UrlRequest; |
||||
import com.teamdev.jxbrowser.net.UrlRequestJob; |
||||
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.net.URI; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.nio.file.Files; |
||||
import java.nio.file.Path; |
||||
import java.util.Map; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2020/3/25 |
||||
*/ |
||||
public class NxInterceptRequestCallback implements InterceptRequestCallback { |
||||
|
||||
Network network; |
||||
Map<String, String> map; |
||||
|
||||
public NxInterceptRequestCallback(Network network) { |
||||
this.network = network; |
||||
} |
||||
|
||||
public NxInterceptRequestCallback(Network network, Map<String, String> map) { |
||||
this.network = network; |
||||
this.map = map; |
||||
} |
||||
|
||||
@Override |
||||
public Response on(Params params) { |
||||
UrlRequest urlRequest = params.urlRequest(); |
||||
String path = urlRequest.url(); |
||||
if (path.startsWith("file:")) { |
||||
Optional<UrlRequestJob> optional = generateFileProtocolUrlRequestJob(urlRequest, path); |
||||
if (optional.isPresent()) { |
||||
return InterceptRequestCallback.Response.intercept(optional.get()); |
||||
} |
||||
} else { |
||||
return next(urlRequest, path); |
||||
} |
||||
return Response.proceed(); |
||||
} |
||||
|
||||
Response next(UrlRequest urlRequest, String path) { |
||||
return Response.proceed(); |
||||
} |
||||
|
||||
private Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(UrlRequest urlRequest, String path) { |
||||
try { |
||||
String url = new URLCodec().decode(path); |
||||
String filePath = TemplateUtils.renderParameter4Tpl(url, map); |
||||
File file = new File(URI.create(filePath).getPath()); |
||||
InputStream inputStream = IOUtils.readResource(file.getAbsolutePath()); |
||||
String mimeType = getMimeType(path); |
||||
byte[] bytes; |
||||
if (isPlainText(mimeType)) { |
||||
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); |
||||
text = TemplateUtils.renderParameter4Tpl(text, map); |
||||
bytes = text.getBytes(StandardCharsets.UTF_8); |
||||
} else { |
||||
bytes = IOUtils.inputStream2Bytes(inputStream); |
||||
} |
||||
return Optional.of(generateBasicUrlRequestJob(urlRequest, mimeType, bytes)); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return Optional.empty(); |
||||
} |
||||
|
||||
private boolean isPlainText(String mimeType) { |
||||
return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType); |
||||
} |
||||
|
||||
UrlRequestJob generateBasicUrlRequestJob(UrlRequest urlRequest, String mimeType, byte[] bytes) { |
||||
UrlRequestJob.Options options = UrlRequestJob.Options |
||||
.newBuilder(urlRequest.id(), HttpStatus.OK) |
||||
.addHttpHeader(HttpHeader.of("Content-Type", mimeType)) |
||||
.build(); |
||||
UrlRequestJob urlRequestJob = network.newUrlRequestJob(options); |
||||
urlRequestJob.write(bytes); |
||||
urlRequestJob.complete(); |
||||
return urlRequestJob; |
||||
} |
||||
|
||||
String getMimeType(String path) { |
||||
if (StringUtils.isBlank(path)) { |
||||
return "text/html"; |
||||
} |
||||
if (path.endsWith(".html")) { |
||||
return "text/html"; |
||||
} |
||||
if (path.endsWith(".css")) { |
||||
return "text/css"; |
||||
} |
||||
if (path.endsWith(".js")) { |
||||
return "text/javascript"; |
||||
} |
||||
if (path.endsWith(".svg")) { |
||||
return "image/svg+xml"; |
||||
} |
||||
if (path.endsWith(".png")) { |
||||
return "image/png"; |
||||
} |
||||
if (path.endsWith(".jpeg")) { |
||||
return "image/jpeg"; |
||||
} |
||||
if (path.endsWith(".gif")) { |
||||
return "image/gif"; |
||||
} |
||||
Path file = new File(path).toPath(); |
||||
try { |
||||
return Files.probeContentType(file); |
||||
} catch (IOException e) { |
||||
return "text/html"; |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 423 B |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.env; |
||||
|
||||
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
||||
import junit.framework.TestCase; |
||||
import org.junit.Assert; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/7/15 |
||||
*/ |
||||
public class RemoteDesignerWorkspaceInfoTest extends TestCase { |
||||
|
||||
public void testCheckValid() { |
||||
RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true)); |
||||
RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); |
||||
RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); |
||||
RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true)); |
||||
Assert.assertFalse(workspaceInfo0.checkValid()); |
||||
Assert.assertFalse(workspaceInfo1.checkValid()); |
||||
Assert.assertFalse(workspaceInfo2.checkValid()); |
||||
Assert.assertFalse(workspaceInfo3.checkValid()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.cardtag.mobile.UniteStyle; |
||||
import com.fr.invoke.Reflect; |
||||
import junit.framework.TestCase; |
||||
import org.junit.Test; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public class UniteStyleDefinePaneTest extends TestCase { |
||||
|
||||
@Test |
||||
public void testDefaultConfig() { |
||||
UniteStyleDefinePane definePane = new UniteStyleDefinePane(new WCardTagLayout()); |
||||
Reflect.on(definePane).call("initDefaultConfig"); |
||||
|
||||
double paddingTop = Reflect.on(definePane).field("paddingTopSpinner").call("getValue").get(); |
||||
assertEquals((int)paddingTop, UniteStyle.DEFAULT_PADDING_TOP); |
||||
double paddingBottom = Reflect.on(definePane).field("paddingBottomSpinner").call("getValue").get(); |
||||
assertEquals((int)paddingBottom, UniteStyle.DEFAULT_PADDING_BOTTOM); |
||||
double paddingLeft = Reflect.on(definePane).field("paddingLeftSpinner").call("getValue").get(); |
||||
assertEquals((int)paddingLeft, UniteStyle.DEFAULT_PADDING_LEFT); |
||||
double paddingRight = Reflect.on(definePane).field("paddingRightSpinner").call("getValue").get(); |
||||
assertEquals((int)paddingRight, UniteStyle.DEFAULT_PADDING_RIGHT); |
||||
|
||||
Color initialBackgroundColor = Reflect.on(definePane).field("initialBackgroundColorBox").call("getSelectObject").get(); |
||||
assertEquals(initialBackgroundColor, UniteStyle.DEFAULT_INITIAL_BACKGROUND_COLOR); |
||||
Color selectedBackgroundColor = Reflect.on(definePane).field("selectedBackgroundColorBox").call("getSelectObject").get(); |
||||
assertEquals(selectedBackgroundColor, UniteStyle.DEFAULT_SELECTED_BACKGROUND_COLOR); |
||||
|
||||
int lineStyle = Reflect.on(definePane).field("borderWidthComboBox").call("getSelectedLineStyle").get(); |
||||
assertEquals(lineStyle, UniteStyle.DEFAULT_BORDER_LINE.lineStyle); |
||||
Color borderColor = Reflect.on(definePane).field("borderColorBox").call("getSelectObject").get(); |
||||
assertEquals(borderColor, UniteStyle.DEFAULT_BORDER_LINE.color); |
||||
double borderRadius = Reflect.on(definePane).field("borderRadiusSpinner").call("getValue").get(); |
||||
assertEquals((int)borderRadius, UniteStyle.DEFAULT_BORDER_RADIUS); |
||||
} |
||||
} |
@ -0,0 +1,90 @@
|
||||
package com.fr.design.chart; |
||||
|
||||
import com.fr.base.chart.BaseChartCollection; |
||||
import com.fr.base.chart.chartdata.TopDefinitionProvider; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.chartx.TwoTuple; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.plugin.chart.vanchart.VanChart; |
||||
|
||||
import javax.swing.JList; |
||||
import javax.swing.event.ListSelectionEvent; |
||||
import javax.swing.event.ListSelectionListener; |
||||
import java.awt.Component; |
||||
import java.awt.Dialog; |
||||
import java.awt.Frame; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-28 |
||||
*/ |
||||
public class AutoChartDialog extends ChartDialog { |
||||
|
||||
private AutoChartTypePane autoChartTypePane; |
||||
|
||||
public AutoChartDialog(Frame owner) { |
||||
super(owner); |
||||
} |
||||
|
||||
public AutoChartDialog(Dialog owner) { |
||||
super(owner); |
||||
} |
||||
|
||||
protected Component initCenterPane() { |
||||
autoChartTypePane = new AutoChartTypePane(); |
||||
|
||||
getOk().setEnabled(false); |
||||
|
||||
autoChartTypePane.registsListAction(new ListSelectionListener() { |
||||
@Override |
||||
public void valueChanged(ListSelectionEvent e) { |
||||
getOk().setEnabled(((JList) e.getSource()).getSelectedIndex() >= 0); |
||||
} |
||||
}); |
||||
return autoChartTypePane; |
||||
} |
||||
|
||||
protected ActionListener getActionListener(final String createTime) { |
||||
return new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
ChartCollection chartCollection = (ChartCollection) getChartCollection(); |
||||
autoChartTypePane.update(chartCollection, createTime); |
||||
if (chartCollection.getChartCount() > 0) { |
||||
doOK(); |
||||
} else { |
||||
doCancel(); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
protected String getDialogTitle() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Auto_Recommended_Chart"); |
||||
} |
||||
|
||||
/** |
||||
* 更新新建的图表 ChartCollection |
||||
*/ |
||||
public void populate(BaseChartCollection cc) { |
||||
super.populate(cc); |
||||
ChartCollection chartCollection = (ChartCollection) getChartCollection(); |
||||
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class); |
||||
if (vanChart == null) { |
||||
return; |
||||
} |
||||
TopDefinitionProvider filterDefinition = vanChart.getFilterDefinition(); |
||||
if (filterDefinition == null) { |
||||
return; |
||||
} |
||||
TwoTuple<String, String[]> tableNameAndDataFields = filterDefinition.getTableNameAndDataFields(); |
||||
if (tableNameAndDataFields == null) { |
||||
return; |
||||
} |
||||
String tableName = tableNameAndDataFields.getFirst(); |
||||
String[] dataFields = tableNameAndDataFields.getSecond(); |
||||
autoChartTypePane.populate(tableName, dataFields); |
||||
} |
||||
} |
@ -0,0 +1,104 @@
|
||||
package com.fr.design.chart; |
||||
|
||||
import com.fr.base.chart.BaseChartPainter; |
||||
import com.fr.base.chart.chartdata.CallbackEvent; |
||||
import com.fr.base.chart.result.WebChartIDInfo; |
||||
import com.fr.chart.chartattr.Chart; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.design.ChartTypeInterfaceManager; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.script.Calculator; |
||||
|
||||
import javax.swing.Icon; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Paint; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-29 |
||||
*/ |
||||
public class AutoChartIcon implements Icon { |
||||
|
||||
private static final int WIDTH = 500; |
||||
private static final int HEIGHT = 281; |
||||
|
||||
private ChartCollection chartCollection; |
||||
private CallbackEvent callbackEvent; |
||||
|
||||
private String chartName; |
||||
|
||||
public AutoChartIcon(ChartCollection chartCollection) { |
||||
this.chartCollection = chartCollection; |
||||
initChartName(); |
||||
} |
||||
|
||||
public ChartCollection getChartCollection() { |
||||
return chartCollection; |
||||
} |
||||
|
||||
public String getChartName() { |
||||
return chartName; |
||||
} |
||||
|
||||
private void initChartName() { |
||||
Chart chart = chartCollection.getSelectedChart(Chart.class); |
||||
String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID()); |
||||
chartName = subName[0]; |
||||
} |
||||
|
||||
public void registerCallBackEvent(CallbackEvent callbackEvent) { |
||||
this.callbackEvent = callbackEvent; |
||||
} |
||||
|
||||
/** |
||||
* 画出缩略图Icon |
||||
* |
||||
* @param g 图形的上下文 |
||||
* @param c 所在的Component |
||||
* @param x 缩略图的起始坐标x |
||||
* @param y 缩略图的起始坐标y |
||||
*/ |
||||
@Override |
||||
public void paintIcon(Component c, Graphics g, int x, int y) { |
||||
|
||||
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), |
||||
WebChartIDInfo.createAutoTypeInfo(), getIconWidth(), getIconHeight()); |
||||
|
||||
int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); |
||||
|
||||
Graphics2D g2d = (Graphics2D) g; |
||||
Paint oldPaint = g2d.getPaint(); |
||||
g.translate(x, y); |
||||
g2d.setPaint(Color.white); |
||||
g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); |
||||
|
||||
painter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent); |
||||
|
||||
g.translate(-x, -y); |
||||
g2d.setPaint(oldPaint); |
||||
} |
||||
|
||||
/** |
||||
* 返回缩略图的宽度 |
||||
* |
||||
* @return int 缩略图宽度 |
||||
*/ |
||||
@Override |
||||
public int getIconWidth() { |
||||
return WIDTH; |
||||
} |
||||
|
||||
/** |
||||
* 返回缩略图的高度 |
||||
* |
||||
* @return int 缩略图高度 |
||||
*/ |
||||
@Override |
||||
public int getIconHeight() { |
||||
return HEIGHT; |
||||
} |
||||
} |
@ -0,0 +1,291 @@
|
||||
package com.fr.design.chart; |
||||
|
||||
import com.fr.base.chart.chartdata.CallbackEvent; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.design.chart.auto.AutoTypeCalculate; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.data.datapane.TableDataComboBox; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.iprogressbar.AutoProgressBar; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.chart.info.ChartInfoCollector; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.vanchart.VanChart; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.DefaultListCellRenderer; |
||||
import javax.swing.DefaultListModel; |
||||
import javax.swing.JList; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JSplitPane; |
||||
import javax.swing.ListCellRenderer; |
||||
import javax.swing.SwingWorker; |
||||
import javax.swing.UIManager; |
||||
import javax.swing.event.ListSelectionListener; |
||||
import javax.swing.plaf.SplitPaneUI; |
||||
import javax.swing.plaf.basic.BasicSplitPaneUI; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.concurrent.CancellationException; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-29 |
||||
*/ |
||||
public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent { |
||||
|
||||
private JList chartViewList; |
||||
private DefaultListModel chartResultModel; |
||||
private UIButton refreshButton; |
||||
|
||||
private TableDataComboBox tableNameComboBox; |
||||
private UIComboCheckBox dataFieldBox; |
||||
|
||||
private AutoProgressBar connectionBar; |
||||
private SwingWorker worker; |
||||
|
||||
public AutoChartTypePane() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
initButtonGroup(); |
||||
initRefreshLabel(); |
||||
initDataFiledBox(); |
||||
JPanel contentPane = createContentPane(); |
||||
|
||||
chartViewList = new JList(); |
||||
|
||||
chartResultModel = new DefaultListModel(); |
||||
chartViewList.setModel(chartResultModel); |
||||
chartViewList.setVisibleRowCount(0); |
||||
chartViewList.setLayoutOrientation(JList.HORIZONTAL_WRAP); |
||||
chartViewList.setCellRenderer(iconCellRenderer); |
||||
|
||||
JScrollPane subListPane = new JScrollPane(chartViewList); |
||||
subListPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Recommended_Chart"))); |
||||
|
||||
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, contentPane, subListPane); |
||||
|
||||
SplitPaneUI ui = splitPane.getUI(); |
||||
if (ui instanceof BasicSplitPaneUI) { |
||||
((BasicSplitPaneUI) ui).getDivider().setBorder(null); |
||||
} |
||||
splitPane.setDividerLocation(60); |
||||
this.add(splitPane); |
||||
} |
||||
|
||||
ListCellRenderer iconCellRenderer = new DefaultListCellRenderer() { |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
this.setText(""); |
||||
|
||||
AutoChartIcon chartIcon = (AutoChartIcon) value; |
||||
this.setIcon(chartIcon); |
||||
setHorizontalAlignment(UILabel.CENTER); |
||||
if (isSelected) { |
||||
// 深蓝色.
|
||||
this.setBackground(new Color(57, 107, 181)); |
||||
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName(), Color.WHITE)); |
||||
} else { |
||||
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName())); |
||||
} |
||||
return this; |
||||
} |
||||
}; |
||||
|
||||
private JPanel createContentPane() { |
||||
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
|
||||
JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
panel.add(tableDataPane); |
||||
tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":")); |
||||
tableNameComboBox.setPreferredSize(new Dimension(126, 20)); |
||||
tableDataPane.add(tableNameComboBox); |
||||
|
||||
JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
panel.add(areaNamePane); |
||||
areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Field") + ":")); |
||||
areaNamePane.add(dataFieldBox); |
||||
panel.add(refreshButton); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||
return panel; |
||||
} |
||||
|
||||
private void initButtonGroup() { |
||||
dataFieldBox = new UIComboCheckBox(new Object[0]); |
||||
dataFieldBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkButtonState(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void initDataFiledBox() { |
||||
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
||||
tableNameComboBox.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
refreshBox(); |
||||
checkButtonState(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkButtonState() { |
||||
if (tableNameComboBox.getSelectedItem() != null && dataFieldBox.getSelectedValues().length > 0) { |
||||
refreshButton.setEnabled(true); |
||||
} else { |
||||
refreshButton.setEnabled(false); |
||||
} |
||||
} |
||||
|
||||
public void registsListAction(ListSelectionListener listSelectionListener) { |
||||
chartViewList.addListSelectionListener(listSelectionListener); |
||||
} |
||||
|
||||
private void refreshBox() { |
||||
TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem(); |
||||
|
||||
if (dataWrap == null) { |
||||
return; |
||||
} |
||||
dataFieldBox.clearText(); |
||||
|
||||
List<String> columnNameList = dataWrap.calculateColumnNameList(); |
||||
|
||||
dataFieldBox.refreshCombo(columnNameList.toArray()); |
||||
} |
||||
|
||||
private void initRefreshLabel() { |
||||
refreshButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Recommend")); |
||||
refreshButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
refreshButton.setEnabled(false); |
||||
calculateAutoChart(); |
||||
} |
||||
}); |
||||
refreshButton.setEnabled(false); |
||||
} |
||||
|
||||
private void calculateAutoChart() { |
||||
connectionBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Chart_Generate_Recommended_Chart"), "", 0, 100) { |
||||
public void doMonitorCanceled() { |
||||
refreshButton.setEnabled(true); |
||||
worker.cancel(true); |
||||
} |
||||
}; |
||||
setWorker(); |
||||
worker.execute(); |
||||
} |
||||
|
||||
private void setWorker() { |
||||
|
||||
worker = new SwingWorker<List<VanChart>, Void>() { |
||||
protected List<VanChart> doInBackground() { |
||||
connectionBar.start(); |
||||
chartResultModel.clear(); |
||||
List<String> columnList = new ArrayList<>(); |
||||
Object[] selectedValues = dataFieldBox.getSelectedValues(); |
||||
for (Object value : selectedValues) { |
||||
columnList.add(GeneralUtils.objectToString(value)); |
||||
} |
||||
List<VanChart> vanChartList = AutoTypeCalculate.calculateType(tableNameComboBox.getSelectedItem().getTableDataName(), columnList); |
||||
connectionBar.close(); |
||||
return vanChartList; |
||||
} |
||||
|
||||
public void done() { |
||||
try { |
||||
List<VanChart> vanChartList = get(); |
||||
if (vanChartList != null && !vanChartList.isEmpty()) { |
||||
for (VanChart vanChart : vanChartList) { |
||||
ChartCollection chartCollection = new ChartCollection(vanChart); |
||||
AutoChartIcon autoChartIcon = new AutoChartIcon(chartCollection); |
||||
autoChartIcon.registerCallBackEvent(AutoChartTypePane.this); |
||||
chartResultModel.addElement(autoChartIcon); |
||||
} |
||||
chartViewList.setSelectedIndex(0); |
||||
} |
||||
} catch (Exception e) { |
||||
if (!(e instanceof CancellationException)) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
FineJOptionPane.showMessageDialog(AutoChartTypePane.this, e.getMessage(), |
||||
Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); |
||||
} |
||||
} finally { |
||||
connectionBar.close(); |
||||
refreshButton.setEnabled(true); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void populate(ChartCollection cc) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void update(ChartCollection cc) { |
||||
update(cc, null); |
||||
} |
||||
|
||||
public void populate(String tableName, String[] dataFields) { |
||||
tableNameComboBox.setSelectedTableDataByName(tableName); |
||||
Map<Object, Boolean> map = new HashMap(); |
||||
for (String dataField : dataFields) { |
||||
map.put(dataField, true); |
||||
} |
||||
dataFieldBox.setSelectedValues(map); |
||||
if (refreshButton.isEnabled()) { |
||||
refreshButton.setEnabled(false); |
||||
calculateAutoChart(); |
||||
} |
||||
} |
||||
|
||||
public void update(ChartCollection cc, String createTime) { |
||||
if (chartViewList.getSelectedIndex() < 0) { |
||||
return; |
||||
} |
||||
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue(); |
||||
VanChart vanChart = chartIcon.getChartCollection().getSelectedChartProvider(VanChart.class); |
||||
if (cc.getChartCount() > 0) { |
||||
VanChart selectedChartProvider = cc.getSelectedChartProvider(VanChart.class); |
||||
if (selectedChartProvider.getChartUuid() != null) { |
||||
vanChart.setUuid(selectedChartProvider.getChartUuid()); |
||||
} |
||||
cc.setSelectChart(vanChart); |
||||
ChartInfoCollector.getInstance().updateChartTypeTime(vanChart, null, true); |
||||
} else { |
||||
cc.addChart(vanChart); |
||||
//记录埋点
|
||||
ChartInfoCollector.getInstance().collection(vanChart, createTime, false, true); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void callback() { |
||||
this.repaint(); |
||||
} |
||||
} |
@ -0,0 +1,143 @@
|
||||
package com.fr.design.chart.auto; |
||||
|
||||
import com.fr.chart.auto.ColumnInfo; |
||||
import com.fr.chart.auto.strategy.AutoTypeStrategy; |
||||
import com.fr.chart.auto.strategy.imp.AvaStrategy; |
||||
import com.fr.chart.auto.strategy.imp.BubbleChartStrategy; |
||||
import com.fr.chart.auto.strategy.imp.SingleDimensionStrategy; |
||||
import com.fr.chart.auto.strategy.imp.SingleTargetStrategy; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.data.TableDataSourceTailor; |
||||
import com.fr.data.impl.EmbeddedTableData; |
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.vanchart.VanChart; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-08 |
||||
*/ |
||||
public class AutoTypeCalculate { |
||||
|
||||
public static List<VanChart> calculateType(String tableName, List<String> columns) { |
||||
List<ColumnInfo> columnValue = calculateField(tableName, columns); |
||||
if (columnValue.isEmpty()) { |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
List<ColumnInfo> dimensions = new ArrayList<>(); |
||||
List<ColumnInfo> targets = new ArrayList<>(); |
||||
for (ColumnInfo field : columnValue) { |
||||
if (isTarget(field.getValues())) { |
||||
targets.add(field); |
||||
} else { |
||||
dimensions.add(field); |
||||
} |
||||
} |
||||
AutoTypeStrategy autoTypeStrategy = chooseStrategy(dimensions.size(), targets.size()); |
||||
return autoTypeStrategy.rankChart(tableName, dimensions, targets); |
||||
} |
||||
|
||||
private static AutoTypeStrategy chooseStrategy(int dimensionSize, int targetSize) { |
||||
if (dimensionSize == 0) { |
||||
//没有维度,并且只有一个指标,使用单指标匹配逻辑,大于1个指标,使用气泡图(散点图)匹配逻辑
|
||||
if (targetSize == 1) { |
||||
return new SingleTargetStrategy(); |
||||
} else { |
||||
return new BubbleChartStrategy(); |
||||
} |
||||
} else if (dimensionSize == 1) { |
||||
//1个维度,并且没有指标,使用单维度匹配,2~3个指标,使用气泡图(散点图)匹配逻辑,其余使用ava匹配
|
||||
if (targetSize == 0) { |
||||
return new SingleDimensionStrategy(); |
||||
} else if (targetSize == 2 || targetSize == 3) { |
||||
return new BubbleChartStrategy(); |
||||
} else { |
||||
return new AvaStrategy(); |
||||
} |
||||
} else { |
||||
//大与1个维度,并且没有指标,使用单维度匹配(循环),否则使用ava匹配
|
||||
if (targetSize == 0) { |
||||
return new SingleDimensionStrategy(); |
||||
} else { |
||||
return new AvaStrategy(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static boolean isTarget(List<String> values) { |
||||
for (String value : values) { |
||||
if (StringUtils.isEmpty(value)) { |
||||
continue; |
||||
} |
||||
Number number = GeneralUtils.string2Number(value); |
||||
if (number == null) { |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
private static List<ColumnInfo> calculateField(String tableName, List<String> columns) { |
||||
NameTableData nameTableData = new NameTableData(tableName); |
||||
TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); |
||||
Calculator calculator = Calculator.createCalculator(); |
||||
calculator.setAttribute(TableDataSource.KEY, dataSource); |
||||
nameTableData.createTableData(calculator); |
||||
|
||||
EmbeddedTableData tableData; |
||||
try { |
||||
tableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, nameTableData, Integer.MAX_VALUE, false); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
List<ColumnInfo> originalData = new ArrayList<>(); |
||||
for (String column : columns) { |
||||
List<String> columnData = getColumnData(tableData, column); |
||||
if (columnData != null && !columnData.isEmpty()) { |
||||
originalData.add(new ColumnInfo(column, columnData)); |
||||
} |
||||
} |
||||
return originalData; |
||||
} |
||||
|
||||
private static List<String> getColumnData(EmbeddedTableData tableData, String columnName) { |
||||
List<String> columnData = new ArrayList<>(); |
||||
|
||||
int colIndex = getColIndex(tableData, columnName); |
||||
if (colIndex == DataModel.COLUMN_NAME_NOT_FOUND) { |
||||
return columnData; |
||||
} |
||||
|
||||
int size = tableData.getRowCount(); |
||||
for (int i = 0; i < size; i++) { |
||||
Object valueAt = tableData.getValueAt(i, colIndex); |
||||
columnData.add(GeneralUtils.objectToString(valueAt)); |
||||
} |
||||
return columnData; |
||||
} |
||||
|
||||
private static int getColIndex(EmbeddedTableData tableData, String columnName) { |
||||
int colIndex = 0; |
||||
|
||||
for (int count = tableData.getColumnCount(); colIndex < count; ++colIndex) { |
||||
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(colIndex), columnName)) { |
||||
return colIndex; |
||||
} |
||||
} |
||||
return DataModel.COLUMN_NAME_NOT_FOUND; |
||||
} |
||||
} |
@ -0,0 +1,113 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.chart.base.GradientStyle; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.style.background.gradient.FixedGradientBar; |
||||
import com.fr.plugin.chart.type.GradientType; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class VanChartBeautyPaneWithGradientBar extends VanChartBeautyPane { |
||||
|
||||
private FixedGradientBar colorGradient; |
||||
private JPanel gradientBarPane; |
||||
|
||||
public VanChartBeautyPaneWithGradientBar() { |
||||
super(); |
||||
|
||||
this.add(initGradientBarPane(), BorderLayout.SOUTH); |
||||
|
||||
initListener(); |
||||
} |
||||
|
||||
private JPanel initGradientBarPane() { |
||||
colorGradient = new FixedGradientBar(4, 140); |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{null, colorGradient}, |
||||
}; |
||||
|
||||
gradientBarPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
|
||||
return gradientBarPane; |
||||
} |
||||
|
||||
private void initListener() { |
||||
getGradientTypeBox().addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkGradientBarVisible(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkGradientBarVisible() { |
||||
if (colorGradient != null && gradientBarPane != null) { |
||||
gradientBarPane.setVisible(getGradientTypeBox().getSelectedIndex() == 1); |
||||
} |
||||
} |
||||
|
||||
protected String[] getNameArray() { |
||||
return new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Auto"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Custom"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Off") |
||||
}; |
||||
} |
||||
|
||||
public void populateBean(GradientStyle gradientStyle) { |
||||
super.populateBean(gradientStyle); |
||||
|
||||
if (colorGradient != null) { |
||||
colorGradient.updateColor(gradientStyle.getStartColor(), gradientStyle.getEndColor()); |
||||
} |
||||
|
||||
checkGradientBarVisible(); |
||||
} |
||||
|
||||
@Override |
||||
public GradientStyle updateBean() { |
||||
GradientStyle gradientStyle = super.updateBean(); |
||||
|
||||
if (this.colorGradient != null && this.gradientBarPane != null) { |
||||
gradientStyle.setStartColor(colorGradient.getSelectColorPointBtnP1().getColorInner()); |
||||
gradientStyle.setEndColor(colorGradient.getSelectColorPointBtnP2().getColorInner()); |
||||
} |
||||
|
||||
return gradientStyle; |
||||
} |
||||
|
||||
protected int convertGradientTypeToIndex(GradientType gradientType) { |
||||
switch (gradientType) { |
||||
case CUSTOM: |
||||
return 1; |
||||
case NONE: |
||||
return 2; |
||||
default: |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
protected GradientType convertIndexToGradientType(int index) { |
||||
switch (index) { |
||||
case 1: |
||||
return GradientType.CUSTOM; |
||||
case 2: |
||||
return GradientType.NONE; |
||||
default: |
||||
return GradientType.AUTO; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,153 @@
|
||||
package com.fr.van.chart.designer.other.condition.item; |
||||
|
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.chart.base.AttrBackground; |
||||
import com.fr.chart.base.DataSeriesCondition; |
||||
import com.fr.design.condition.ConditionAttributesPane; |
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.style.background.gradient.FixedGradientBar; |
||||
import com.fr.design.style.color.ColorSelectBox; |
||||
import com.fr.plugin.chart.type.GradientType; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class VanChartColumnSeriesColorConditionPane extends AbstractNormalMultiLineConditionPane { |
||||
|
||||
private UIButtonGroup matchColorTypeBox; |
||||
|
||||
private ColorSelectBox colorSelectionBox; |
||||
private FixedGradientBar colorGradient; |
||||
|
||||
private JPanel colorSelectPane; |
||||
private JPanel colorGradientPane; |
||||
|
||||
public VanChartColumnSeriesColorConditionPane(ConditionAttributesPane conditionAttributesPane) { |
||||
super(conditionAttributesPane, null); |
||||
} |
||||
|
||||
protected String getItemLabelString() { |
||||
return nameForPopupMenuItem(); |
||||
} |
||||
|
||||
protected JPanel initContentPane() { |
||||
colorSelectionBox = new ColorSelectBox(80); |
||||
colorGradient = new FixedGradientBar(4, 150); |
||||
|
||||
colorSelectPane = createJPanelWithComponent(colorSelectionBox); |
||||
colorGradientPane = createJPanelWithComponent(colorGradient); |
||||
|
||||
JPanel panel = new JPanel(); |
||||
|
||||
panel.setLayout(new BorderLayout()); |
||||
|
||||
panel.add(initColorButtonPane(), BorderLayout.NORTH); |
||||
panel.add(colorSelectPane, BorderLayout.CENTER); |
||||
panel.add(colorGradientPane, BorderLayout.SOUTH); |
||||
|
||||
initListener(); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
private JPanel initColorButtonPane() { |
||||
String[] names = new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Solid_Color"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade") |
||||
}; |
||||
|
||||
matchColorTypeBox = new UIButtonGroup(names); |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
Component[][] components = new Component[][]{new Component[]{matchColorTypeBox}}; |
||||
|
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p}, new double[]{e}); |
||||
} |
||||
|
||||
private void initListener() { |
||||
matchColorTypeBox.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkColorPaneVisible(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkColorPaneVisible() { |
||||
if (colorSelectPane != null) { |
||||
colorSelectPane.setVisible(matchColorTypeBox.getSelectedIndex() == 0); |
||||
} |
||||
if (colorGradientPane != null) { |
||||
colorGradientPane.setVisible(matchColorTypeBox.getSelectedIndex() == 1); |
||||
} |
||||
} |
||||
|
||||
public String nameForPopupMenuItem() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Match_Color"); |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Match_Color"); |
||||
} |
||||
|
||||
public void populate(DataSeriesCondition condition) { |
||||
if (condition instanceof AttrBackground) { |
||||
AttrBackground matchColor = (AttrBackground) condition; |
||||
|
||||
if (matchColor.getGradient() == GradientType.NONE) { |
||||
this.matchColorTypeBox.setSelectedIndex(0); |
||||
} else { |
||||
this.matchColorTypeBox.setSelectedIndex(1); |
||||
} |
||||
|
||||
ColorBackground seriesColor = (ColorBackground) matchColor.getSeriesBackground(); |
||||
|
||||
if (seriesColor != null) { |
||||
this.colorSelectionBox.setSelectObject(seriesColor.getColor()); |
||||
} |
||||
|
||||
this.colorGradient.updateColor(matchColor.getGradientStartColor(), matchColor.getGradientEndColor()); |
||||
} |
||||
|
||||
checkColorPaneVisible(); |
||||
} |
||||
|
||||
public DataSeriesCondition update() { |
||||
AttrBackground matchColor = new AttrBackground(); |
||||
|
||||
if (this.matchColorTypeBox.getSelectedIndex() == 0) { |
||||
matchColor.setGradient(GradientType.NONE); |
||||
} else { |
||||
matchColor.setGradient(GradientType.CUSTOM); |
||||
} |
||||
|
||||
matchColor.setSeriesBackground(ColorBackground.getInstance(this.colorSelectionBox.getSelectObject())); |
||||
matchColor.setGradientStartColor(this.colorGradient.getSelectColorPointBtnP1().getColorInner()); |
||||
matchColor.setGradientEndColor(this.colorGradient.getSelectColorPointBtnP2().getColorInner()); |
||||
|
||||
return matchColor; |
||||
} |
||||
|
||||
public void setDefault() { |
||||
this.populate(new AttrBackground()); |
||||
} |
||||
|
||||
private JPanel createJPanelWithComponent(Component component) { |
||||
double p = TableLayout.PREFERRED; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null}, |
||||
new Component[]{component} |
||||
}; |
||||
|
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{e}); |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue