Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into release/10.0

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
86609179a8
  1. 21
      designer-base/src/main/java/com/fr/common/report/ReportState.java
  2. 29
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 11
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 6
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  5. 10
      designer-base/src/main/java/com/fr/design/dialog/TipDialog.java
  6. 73
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java
  7. 25
      designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java
  8. 25
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java
  9. 7
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  10. 7
      designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java
  11. 3
      designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java
  12. 0
      designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java
  13. 43
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java
  14. 33
      designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java
  15. 4
      designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java
  16. 111
      designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java
  17. 7
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java
  18. 15
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java
  19. 8
      designer-base/src/main/java/com/fr/exit/DesignerExiter.java
  20. 174
      designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java
  21. 245
      designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java
  22. 238
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java
  23. 19
      designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java
  24. 7
      designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java
  25. 3
      designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java
  26. 1
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java
  27. 5
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java
  28. 16
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java
  29. 218
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java
  30. 27
      designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java
  31. 1
      designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java
  32. 6
      designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java
  33. 9
      designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java
  34. 5
      designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java
  35. 6
      designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java
  36. 51
      designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java
  37. 7
      designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java
  38. 1
      designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java
  39. 5
      designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java
  40. 1
      designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java
  41. 7
      designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java
  42. 7
      designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java
  43. 2
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  44. 2
      designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java
  45. 9
      designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java
  46. 12
      designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java
  47. 30
      designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java

21
designer-base/src/main/java/com/fr/common/report/ReportState.java

@ -0,0 +1,21 @@
package com.fr.common.report;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/27
*/
public enum ReportState {
STOP("stop"), ACTIVE("active");
private String value;
ReportState(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
}

29
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -8,18 +8,21 @@ import com.fr.base.Utils;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.ErrorDialog;
import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.locale.impl.ProductImproveMark;
import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.update.push.DesignerPushUpdateConfigManager;
import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.style.color.ColorSelectConfigManager;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.DesignerPort; import com.fr.design.utils.DesignerPort;
import com.fr.exit.DesignerExiter;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter; import com.fr.general.FRLogFormatter;
@ -199,6 +202,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile()); XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
XmlHandler.Self.handle(e);
} }
// james:如果没有env定义,要设置一个默认的 // james:如果没有env定义,要设置一个默认的
@ -345,6 +349,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} catch (IOException e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
XmlHandler.Self.handle(e);
} finally { } finally {
if (null != fileWriter) { if (null != fileWriter) {
try { try {
@ -2039,4 +2044,28 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
public void setVcsConfigManager(VcsConfigManager vcsConfigManager) { public void setVcsConfigManager(VcsConfigManager vcsConfigManager) {
this.vcsConfigManager = vcsConfigManager; this.vcsConfigManager = vcsConfigManager;
} }
enum XmlHandler {
Self;
public void handle(Throwable throwable) {
ErrorDialog dialog = new ErrorDialog(null,
Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"),
Toolkit.i18nText("Fine-Design_Error_Start_Report"),
throwable.getMessage()) {
@Override
protected void okEvent() {
dispose();
DesignerExiter.getInstance().execute();
}
@Override
protected void restartEvent() {
dispose();
RestartHelper.restart();
}
};
dialog.setVisible(true);
DesignerExiter.getInstance().execute();
}
};
} }

11
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -1,5 +1,6 @@
package com.fr.design; package com.fr.design;
import com.fr.common.report.ReportState;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -24,6 +25,9 @@ import com.fr.json.JSONArray;
import com.fr.license.exception.RegistEditionException; import com.fr.license.exception.RegistEditionException;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.process.ProcessEventPipe;
import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.rpc.Result; import com.fr.rpc.Result;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
@ -407,6 +411,10 @@ public class EnvChangeEntrance {
@Override @Override
public void doOk() { public void doOk() {
ProcessEventPipe pipe = FineProcessContext.getParentPipe();
if (FineProcessContext.getParentPipe() != null) {
pipe.fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
}
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} }
@ -414,7 +422,8 @@ public class EnvChangeEntrance {
@Override @Override
public void doCancel() { public void doCancel() {
DesignerExiter.getInstance().execute(); } DesignerExiter.getInstance().execute();
}
}); });
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }

6
designer-base/src/main/java/com/fr/design/RestartHelper.java

@ -202,7 +202,11 @@ public class RestartHelper {
} catch (IOException e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
DesignerContext.getDesignerFrame().exit(); if (DesignerContext.getDesignerFrame() != null) {
DesignerContext.getDesignerFrame().exit();
} else {
DesignerExiter.getInstance().execute();
}
} }
} }
} }

10
designer-base/src/main/java/com/fr/design/dialog/TipDialog.java

@ -6,6 +6,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -39,7 +40,14 @@ public abstract class TipDialog extends JDialog implements ActionListener {
northPane.add(iconPane, BorderLayout.WEST); northPane.add(iconPane, BorderLayout.WEST);
northPane.add(tipPane, BorderLayout.CENTER); northPane.add(tipPane, BorderLayout.CENTER);
JTextArea area = new JTextArea(type); JTextPane area = new JTextPane();
UILabel typeLabel = new UILabel(type);
area.insertComponent(typeLabel);
if (StringUtils.isNotEmpty(type)) {
UILabel logoIconLabel = new UILabel();
logoIconLabel.setIcon(IOUtils.readIcon("com/fr/base/images/oem/logo.png"));
area.insertComponent(logoIconLabel);
}
area.setPreferredSize(new Dimension(400, 100)); area.setPreferredSize(new Dimension(400, 100));
area.setEnabled(true); area.setEnabled(true);
area.setEditable(false); area.setEditable(false);

73
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java vendored

@ -1,15 +1,40 @@
package com.fr.design.env; package com.fr.design.env;
import com.fr.common.report.ReportState;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector;
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.process.ProcessEventPipe;
import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceClient;
import javax.swing.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/** /**
* 根据配置生成运行环境 * 根据配置生成运行环境
*/ */
public class DesignerWorkspaceGenerator { public class DesignerWorkspaceGenerator {
public static Workspace generate(DesignerWorkspaceInfo config) throws Exception { private static final int WAIT_FREQ = 60;
private static ExecutorService service = Executors.newCachedThreadPool(
new NamedThreadFactory("DesignerWorkspaceGenerator"));
public static Workspace generate(final DesignerWorkspaceInfo config) throws Exception {
if (config == null || config.getType() == null) { if (config == null || config.getType() == null) {
return null; return null;
@ -22,7 +47,19 @@ public class DesignerWorkspaceGenerator {
break; break;
} }
case Remote: { case Remote: {
WorkspaceClient client = WorkContext.getConnector().connect(config.getConnection()); Future<WorkspaceClient> future = service.submit(new Callable<WorkspaceClient>() {
@Override
public WorkspaceClient call() throws Exception {
return WorkContext.getConnector().connect(config.getConnection());
}
});
WorkspaceClient client = null;
try {
client = future.get(WAIT_FREQ, TimeUnit.SECONDS);
} catch (TimeoutException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
RemoteHandler.handle(config);
}
if (client != null) { if (client != null) {
workspace = new RemoteWorkspace(client, config.getConnection()); workspace = new RemoteWorkspace(client, config.getConnection());
} }
@ -31,4 +68,36 @@ public class DesignerWorkspaceGenerator {
} }
return workspace; return workspace;
} }
enum RemoteHandler {
SELF;
public static void handle(DesignerWorkspaceInfo config) {
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe();
if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(),
DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(),
StringUtils.EMPTY);
int result = FineJOptionPane.showOptionDialog(null,
Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Error_Tittle"),
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
IOUtils.readIcon("com/fr/design/images/error/error2.png"),
new Object[] {Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Wait"), Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Switch")},
null);
if (result == JOptionPane.YES_OPTION) {
try {
generate(config);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
}
public static void stop() {
service.shutdown();
}
} }

25
designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java

@ -0,0 +1,25 @@
package com.fr.design.fun;
import com.fr.design.beans.BasicBeanPane;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.stable.fun.mark.Mutable;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
public interface MobileTemplateStyleProvider extends Mutable {
String XML_TAG = "MobileTemplateStyleProvider";
int CURRENT_LEVEL = 1;
Class<? extends MobileTemplateStyle> classFroMobileTemplateStyle();
Class<? extends BasicBeanPane<MobileTemplateStyle>> classFroMobileTemplateStyleAppearance();
String displayName();
}

25
designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java

@ -0,0 +1,25 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.MobileTemplateStyleProvider;
import com.fr.design.fun.MobileWidgetStyleProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
@API(level = MobileWidgetStyleProvider.CURRENT_LEVEL)
public abstract class AbstractMobileTemplateStyleProvider extends AbstractProvider implements MobileTemplateStyleProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
}

7
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -1104,8 +1104,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (tplFile != null) { if (tplFile != null) {
int index = HistoryTemplateListCache.getInstance().contains(tplFile); int index = HistoryTemplateListCache.getInstance().contains(tplFile);
if (index != -1) { if (index != -1) {
HistoryTemplateListCache.getInstance().getHistoryList().get(index).activeOldJTemplate(); JTemplate jt = HistoryTemplateListCache.getInstance().getHistoryList().get(index);
return; if (!(jt instanceof JVirtualTemplate)) {
jt.activeOldJTemplate();
return;
}
} }
} }

7
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java → designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java

@ -21,6 +21,9 @@ import java.util.Date;
*/ */
public class ErrorInfo { public class ErrorInfo {
private static final String SUFFIX = ".json";
private static final String FOLDER_NAME = "errorInfo";
private String username; private String username;
private String uuid; private String uuid;
private String activekey; private String activekey;
@ -128,8 +131,8 @@ public class ErrorInfo {
public void saveFileToCache(JSONObject jo) { public void saveFileToCache(JSONObject jo) {
String content = jo.toString(); String content = jo.toString();
String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX; String fileName = UUID.randomUUID() + SUFFIX;
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName)); File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FOLDER_NAME, fileName));
FileOutputStream out = null; FileOutputStream out = null;
try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) { try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) {
StableUtils.makesureFileExist(file); StableUtils.makesureFileExist(file);

3
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java → designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java

@ -1,8 +1,8 @@
package com.fr.design.mainframe.messagecollect; package com.fr.design.mainframe.messagecollect;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.errorinfo.ErrorInfo; import com.fr.design.mainframe.errorinfo.ErrorInfo;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
/** /**
@ -30,6 +30,7 @@ public class StartErrorMessageCollector {
} }
public void record(String id, String msg, String detail) { public void record(String id, String msg, String detail) {
FineLoggerFactory.getLogger().error(id + ": " + msg + ", detail: " + detail);
ErrorInfo errorInfo = new ErrorInfo(StringUtils.EMPTY, uuid, activeKey); ErrorInfo errorInfo = new ErrorInfo(StringUtils.EMPTY, uuid, activeKey);
errorInfo.setLogid(id); errorInfo.setLogid(id);
errorInfo.setLog(msg); errorInfo.setLog(msg);

0
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java → designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java

43
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java

@ -1,11 +1,14 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.MobileTemplateStyleProvider;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.mobile.ui.TemplateStyleDefinePaneFactory; import com.fr.design.mainframe.mobile.ui.TemplateStyleDefinePaneFactory;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.MobileTemplateStyle; import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.MobileTemplateStyleType; import com.fr.general.cardtag.mobile.MobileTemplateStyleType;
import com.fr.invoke.Reflect;
import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.JList; import javax.swing.JList;
@ -18,9 +21,12 @@ import java.awt.Dimension;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTemplateStyle> { public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTemplateStyle> {
private static final List<MobileTemplateStyleType> STYLE_LIST = new ArrayList<MobileTemplateStyleType>(); private static final List<MobileTemplateStyleType> STYLE_LIST = new ArrayList<MobileTemplateStyleType>();
@ -36,6 +42,7 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTem
private Map<String, BasicBeanPane<MobileTemplateStyle>> map = new HashMap<>(); private Map<String, BasicBeanPane<MobileTemplateStyle>> map = new HashMap<>();
private JPanel right; private JPanel right;
private CardLayout card; private CardLayout card;
private Set<Class<? extends MobileTemplateStyle>> extraStyle = new HashSet<>();
public MobileTemplateStylePane(WCardTagLayout tagLayout){ public MobileTemplateStylePane(WCardTagLayout tagLayout){
init(tagLayout); init(tagLayout);
} }
@ -52,6 +59,7 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTem
map.put(style.getDisplayName(), styleBasicBeanPane); map.put(style.getDisplayName(), styleBasicBeanPane);
right.add(style.getDisplayName(), styleBasicBeanPane); right.add(style.getDisplayName(), styleBasicBeanPane);
} }
initExtra();
styleList = new JList(listModel); styleList = new JList(listModel);
styleList.setCellRenderer(render); styleList.setCellRenderer(render);
@ -74,6 +82,20 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTem
this.add(westPane, BorderLayout.WEST); this.add(westPane, BorderLayout.WEST);
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
} }
private void initExtra() {
List<MobileTemplateStyleProvider> list = getMobileTemplateStyleProvider();
for (MobileTemplateStyleProvider provider : list) {
String displayName = provider.displayName();
Class<? extends BasicBeanPane<MobileTemplateStyle>> clazz = provider.classFroMobileTemplateStyleAppearance();
BasicBeanPane<MobileTemplateStyle> styleBasicBeanPane = Reflect.on(clazz).create().get();
listModel.addElement(displayName);
map.put(displayName, styleBasicBeanPane);
right.add(displayName, styleBasicBeanPane);
extraStyle.add(provider.classFroMobileTemplateStyle());
}
}
public static ListCellRenderer render = new DefaultListCellRenderer() { public static ListCellRenderer render = new DefaultListCellRenderer() {
@Override @Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
@ -97,16 +119,31 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTem
String style = templateStyle.getStyle(); String style = templateStyle.getStyle();
MobileTemplateStyleType templateStyleType = MobileTemplateStyleType.parse(style); MobileTemplateStyleType templateStyleType = MobileTemplateStyleType.parse(style);
if((listModel.getElementAt(i)).equals(templateStyleType.getDisplayName())){ if((listModel.getElementAt(i)).equals(templateStyleType.getDisplayName())){
styleList.setSelectedIndex(i); populateStyle(templateStyle, i);
map.get(templateStyle.toString()).populateBean(templateStyle); return;
card.show(right, templateStyle.toString()); }
if (extraStyle.contains(templateStyle.getClass())) {
populateStyle(templateStyle, i);
return; return;
} }
} }
styleList.setSelectedIndex(0); styleList.setSelectedIndex(0);
} }
private void populateStyle(MobileTemplateStyle templateStyle, int index) {
styleList.setSelectedIndex(index);
map.get(templateStyle.toString()).populateBean(templateStyle);
card.show(right, templateStyle.toString());
}
public MobileTemplateStyle update() { public MobileTemplateStyle update() {
return map.get(styleList.getSelectedValue()).updateBean(); return map.get(styleList.getSelectedValue()).updateBean();
} }
private List<MobileTemplateStyleProvider> getMobileTemplateStyleProvider() {
List<MobileTemplateStyleProvider> list = new ArrayList<>();
Set<MobileTemplateStyleProvider> sets = ExtraDesignClassManager.getInstance().getArray(MobileTemplateStyleProvider.XML_TAG);
list.addAll(sets);
return Collections.unmodifiableList(list);
}
} }

33
designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java

@ -5,15 +5,22 @@ import com.fr.design.style.background.BackgroundJComponent;
import com.fr.design.style.background.gradient.GradientBackgroundPane; import com.fr.design.style.background.gradient.GradientBackgroundPane;
import com.fr.general.Background; import com.fr.general.Background;
import javax.swing.*; import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.util.ArrayList;
import java.util.List;
import java.awt.AWTEvent;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.AWTEventListener; import java.awt.event.AWTEventListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
@ -50,7 +57,7 @@ public abstract class AbstractPopBox extends JPanel {
} }
}; };
private void showPopupMenu() { protected void showPopupMenu() {
if (selectPopupWindow != null && selectPopupWindow.isVisible()) { if (selectPopupWindow != null && selectPopupWindow.isVisible()) {
hidePopupMenu(); hidePopupMenu();
return; return;
@ -98,12 +105,16 @@ public abstract class AbstractPopBox extends JPanel {
private void mouseClick(MouseEvent evt) { private void mouseClick(MouseEvent evt) {
Point point = new Point((int) (evt.getLocationOnScreen().getX()), (int) evt.getLocationOnScreen().getY()); Point point = new Point((int) (evt.getLocationOnScreen().getX()), (int) evt.getLocationOnScreen().getY());
Dimension popBoxD = AbstractPopBox.this.getSize(); Dimension popBoxD = AbstractPopBox.this.getSize();
Point popBoxP = AbstractPopBox.this.getLocationOnScreen(); try {
Dimension popMenuD = this.getControlWindow().getSize(); Point popBoxP = AbstractPopBox.this.getLocationOnScreen();
Point popMenuP = this.getControlWindow().getLocation(); Dimension popMenuD = this.getControlWindow().getSize();
Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD); Point popMenuP = this.getControlWindow().getLocation();
Rectangle popMenuRect = new Rectangle(popMenuP, popMenuD); Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD);
if (!popBoxRect.contains(point) && !popMenuRect.contains(point)) { Rectangle popMenuRect = new Rectangle(popMenuP, popMenuD);
if (!popBoxRect.contains(point) && !popMenuRect.contains(point)) {
this.hidePopupMenu();
}
} catch (Exception ignore){
this.hidePopupMenu(); this.hidePopupMenu();
} }
} }

4
designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java

@ -1,6 +1,6 @@
package com.fr.design.style.background.gradient; package com.fr.design.style.background.gradient;
import com.fr.design.style.background.gradient.GradientBar; import java.awt.Color;
/** /**
* 这个bar不能拖拽滑动 * 这个bar不能拖拽滑动
@ -8,6 +8,8 @@ import com.fr.design.style.background.gradient.GradientBar;
public class FixedGradientBar extends GradientBar { public class FixedGradientBar extends GradientBar {
private static final long serialVersionUID = 2787525421995954889L; private static final long serialVersionUID = 2787525421995954889L;
public static final Color NEW_CHARACTER = new Color(99, 178, 238);
public FixedGradientBar(int minvalue, int maxvalue) { public FixedGradientBar(int minvalue, int maxvalue) {
super(minvalue, maxvalue); super(minvalue, maxvalue);
} }

111
designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java

@ -1,40 +1,38 @@
package com.fr.design.style.background.gradient; package com.fr.design.style.background.gradient;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LinearGradientPaint;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorCell;
import com.fr.design.style.color.ColorSelectConfigManager;
import com.fr.design.style.color.ColorSelectDetailPane; import com.fr.design.style.color.ColorSelectDetailPane;
import com.fr.design.style.color.ColorSelectDialog; import com.fr.design.style.color.ColorSelectDialog;
import com.fr.design.style.color.ColorSelectable; import com.fr.design.style.color.ColorSelectable;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import javax.swing.JComponent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LinearGradientPaint;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
/** /**
* TODO:面板缩放的功能没有考虑就是尾值过大导致超过界面显示的情况原来的那个实现完全是个BUG要缩放的情况也比较少就干脆以后弄吧 * TODO:面板缩放的功能没有考虑就是尾值过大导致超过界面显示的情况原来的那个实现完全是个BUG要缩放的情况也比较少就干脆以后弄吧
*/ */
public class GradientBar extends JComponent implements UIObserver,ColorSelectable{ public class GradientBar extends JComponent implements UIObserver, ColorSelectable {
/** /**
* *
@ -54,12 +52,12 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
private UINumberField endLabel; private UINumberField endLabel;
private ChangeListener changeListener = null; private ChangeListener changeListener = null;
private UIObserverListener uiObserverListener; private List<UIObserverListener> uiObserverListener;
private static final int MOUSE_OFFSET = 4; private static final int MOUSE_OFFSET = 4;
private static final int MAX_VERTICAL = 45; private static final int MAX_VERTICAL = 45;
// 选中的颜色 // 选中的颜色
private Color color; private Color color;
@ -89,6 +87,11 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
iniListener(); iniListener();
} }
public void updateColor(Color begin, Color end) {
p1.setColorInner(begin);
p2.setColorInner(end);
}
protected void addMouseClickListener() { protected void addMouseClickListener() {
this.addMouseListener(new MouseAdapter() { this.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -142,14 +145,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
} }
private void iniListener() { private void iniListener() {
uiObserverListener = new ArrayList<>();
if (shouldResponseChangeListener()) { if (shouldResponseChangeListener()) {
this.addChangeListener(new ChangeListener() { this.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) { for (UIObserverListener observerListener : uiObserverListener) {
return; observerListener.doChange();
} }
uiObserverListener.doChange();
} }
}); });
} }
@ -199,14 +202,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
* 状态改变 * 状态改变
*/ */
public void stateChanged() { public void stateChanged() {
if (changeListener != null) { if (changeListener != null) {
changeListener.stateChanged(null); changeListener.stateChanged(null);
} }
} }
/** /**
* 增加监听 * 增加监听
* *
* @param changeListener 监听 * @param changeListener 监听
*/ */
public void addChangeListener(ChangeListener changeListener) { public void addChangeListener(ChangeListener changeListener) {
@ -215,14 +218,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
/** /**
* 如果左右两个按钮还在初始位置就为true * 如果左右两个按钮还在初始位置就为true
* @return 同上 *
* @return 同上
*/ */
public boolean isOriginalPlace() { public boolean isOriginalPlace() {
return AssistUtils.equals(startLabel.getValue(), min) && AssistUtils.equals(endLabel.getValue(), max); return AssistUtils.equals(startLabel.getValue(), min) && AssistUtils.equals(endLabel.getValue(), max);
} }
/** /**
*
* @return * @return
*/ */
public double getStartValue() { public double getStartValue() {
@ -230,7 +233,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
} }
/** /**
*
* @return * @return
*/ */
public double getEndValue() { public double getEndValue() {
@ -238,7 +240,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
} }
/** /**
*
* @param startValue * @param startValue
*/ */
public void setStartValue(double startValue) { public void setStartValue(double startValue) {
@ -246,7 +247,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
} }
/** /**
*
* @param endValue * @param endValue
*/ */
public void setEndValue(double endValue) { public void setEndValue(double endValue) {
@ -254,7 +254,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
} }
/** /**
*
* @return * @return
*/ */
public SelectColorPointBtn getSelectColorPointBtnP1() { public SelectColorPointBtn getSelectColorPointBtnP1() {
@ -262,7 +261,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
} }
/** /**
*
* @return * @return
*/ */
public SelectColorPointBtn getSelectColorPointBtnP2() { public SelectColorPointBtn getSelectColorPointBtnP2() {
@ -276,7 +274,7 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
* *
*/ */
public void registerChangeListener(UIObserverListener listener) { public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener; uiObserverListener.add(listener);
} }
@Override @Override
@ -288,22 +286,23 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
return true; return true;
} }
@Override @Override
public void setColor(Color color) { public void setColor(Color color) {
this.color = color; this.color = color;
} }
@Override @Override
public Color getColor() { public Color getColor() {
return this.color; return this.color;
} }
/** /**
* 选中颜色 * 选中颜色
* @param ColorCell 颜色单元格 *
*/ * @param ColorCell 颜色单元格
@Override */
public void colorSetted(ColorCell colorCell) { @Override
public void colorSetted(ColorCell colorCell) {
}
}
} }

7
designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java

@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.io.Serializable;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dialog; import java.awt.Dialog;
@ -13,7 +14,6 @@ import java.awt.FlowLayout;
import java.awt.Frame; import java.awt.Frame;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.Serializable;
/** /**
@ -136,8 +136,13 @@ public class ColorSelectDialog extends MiddleChartDialog{
* void * void
*/ */
public static void showDialog(Frame owner,ColorSelectDetailPane pane,Color initialColor,ColorSelectable selectePane){ public static void showDialog(Frame owner,ColorSelectDetailPane pane,Color initialColor,ColorSelectable selectePane){
showDialog(owner,pane,initialColor,selectePane,false);
}
public static void showDialog(Frame owner,ColorSelectDetailPane pane,Color initialColor,ColorSelectable selectePane, boolean alwaysOnTop){
ColorTracker okListener = new ColorTracker(pane); ColorTracker okListener = new ColorTracker(pane);
ColorSelectDialog dialog = new ColorSelectDialog(owner,pane,initialColor,okListener,selectePane); ColorSelectDialog dialog = new ColorSelectDialog(owner,pane,initialColor,okListener,selectePane);
dialog.setAlwaysOnTop(alwaysOnTop);
dialog.setModal(true); dialog.setModal(true);
dialog.show(); dialog.show();
} }

15
designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java

@ -11,16 +11,21 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.*; import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.util.ArrayList;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
/** /**
* The pane used to select color * The pane used to select color
@ -196,6 +201,6 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
@Override @Override
public void customButtonPressed() { public void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE); pane = new ColorSelectDetailPane(Color.WHITE);
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this, true);
} }
} }

8
designer-base/src/main/java/com/fr/exit/DesignerExiter.java

@ -1,5 +1,6 @@
package com.fr.exit; package com.fr.exit;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessContext;
import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.process.engine.core.FineProcessEngineEvent;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -19,9 +20,14 @@ public class DesignerExiter {
} }
public void execute() { public void execute() {
beforeExit();
if (FineProcessContext.getParentPipe() != null) { if (FineProcessContext.getParentPipe() != null) {
FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); FineProcessContext.getParentPipe().syncFire(FineProcessEngineEvent.DESTROY);
} }
System.exit(0); System.exit(0);
} }
private void beforeExit() {
DesignerWorkspaceGenerator.stop();
}
} }

174
designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java

@ -0,0 +1,174 @@
package com.fr.design.chartx.component.button;
import com.fr.base.BaseUtils;
import com.fr.base.background.ColorBackground;
import com.fr.design.style.AbstractSelectBox;
import com.fr.design.style.color.ColorSelectPane;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-03-06
*/
public class ColorButton extends AbstractSelectBox<Color> {
private static final double DEL_WIDTH = 7;
public static final int WIDTH = 18;
private BufferedImage closeIcon = BaseUtils.readImageWithCache("com/fr/design/images/toolbarbtn/chartChangeClose.png");
private Color color;
private boolean isMoveOn = false;
private ColorSelectPane colorPane;
private boolean lastButton;
private ChangeListener changeListener;
public ColorButton(Color color) {
this.color = color;
addMouseListener(getMouseListener());
}
public Dimension getPreferredSize() {
return new Dimension(WIDTH, WIDTH);
}
private void paintDeleteButton(Graphics g2d) {
Rectangle2D bounds = this.getBounds();
int x = (int) (bounds.getWidth() - DEL_WIDTH);
int y = 1;
g2d.drawImage(closeIcon, x, y, closeIcon.getWidth(), closeIcon.getHeight(), null);
}
public void setLastButton(boolean lastButton) {
this.lastButton = lastButton;
}
@Override
public void paint(Graphics g) {
this.setSize(WIDTH, WIDTH);
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(color);
Rectangle2D rec = new Rectangle2D.Double(0, 0, WIDTH + 1, WIDTH + 1);
g2d.fill(rec);
if (isMoveOn && !lastButton) {
paintDeleteButton(g);
}
}
protected void deleteButton() {
}
private void checkMoveOn(boolean moveOn) {
this.isMoveOn = moveOn;
repaint();
}
protected MouseListener getMouseListener() {
return new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
mouseClick(e);
}
public void mouseEntered(MouseEvent e) {
checkMoveOn(true);
}
public void mouseExited(MouseEvent e) {
checkMoveOn(false);
}
};
}
public void mouseClick(MouseEvent e) {
if (!lastButton) {
Rectangle2D bounds = this.getBounds();
if (bounds == null) {
return;
}
if (e.getX() >= bounds.getWidth() - DEL_WIDTH && e.getY() <= DEL_WIDTH) {
deleteButton();
hidePopupMenu();
return;
}
}
//打开颜色选择面板
showPopupMenu();
}
public JPanel initWindowPane(double preferredWidth) {
// 下拉的时候重新生成面板,刷新最近使用颜色
colorPane = new ColorSelectPane(false) {
@Override
public void setVisible(boolean b) {
super.setVisible(b);
}
};
colorPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
hidePopupMenu();
color = ((ColorSelectPane) e.getSource()).getColor();
fireDisplayComponent(ColorBackground.getInstance(color));
ColorButton.this.stateChanged();
}
});
return colorPane;
}
public void stateChanged() {
if (changeListener != null) {
changeListener.stateChanged(null);
}
}
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
/**
* 获取当前选中的颜色
*
* @return 当前选中的颜色
*/
public Color getSelectObject() {
return this.color;
}
/**
* 设置选中的颜色
*
* @param color 颜色
*/
public void setSelectObject(Color color) {
this.color = color;
colorPane.setColor(color);
fireDisplayComponent(ColorBackground.getInstance(color));
}
}

245
designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java

@ -0,0 +1,245 @@
package com.fr.design.chartx.component.combobox;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LinearGradientPaint;
import java.awt.geom.Rectangle2D;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-03-05
* 一个带颜色展示的配色选择下拉框
*/
public class ColorSchemeComboBox extends UIComboBox {
private Map<String, ColorInfo> colorSchemes;
public ColorSchemeComboBox() {
this(null);
}
public ColorSchemeComboBox(Map<String, ColorInfo> colorSchemes) {
//通过配色方案的集合初始化下拉控件,如果参数为null,从配置中读取配色方案。
if (colorSchemes == null) {
colorSchemes = getColorSchemesFromConfig();
}
this.colorSchemes = colorSchemes;
this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray()));
this.setRenderer(new ColorSchemeCellRenderer());
}
private Map<String, ColorInfo> getColorSchemesFromConfig() {
Map<String, ColorInfo> colorSchemes = new LinkedHashMap<>();
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance();
//所有的样式名称
Iterator names = config.names();
//添加默认的方案和第一个方案
String defaultName = config.getCurrentStyle();
ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName);
Object firstName = names.next();
ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName);
if (defaultStyle == null) {
defaultStyle = firstStyle;
}
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle));
colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle));
//添加其他的配色方案
while (names.hasNext()) {
Object key = names.next();
ChartColorMatching colorMatching = (ChartColorMatching) config.getPreStyle(key);
colorSchemes.put(colorMatching.getId(), colorMatchingToColorInfo(colorMatching));
}
//添加自定义组合色和自定义渐变色
colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Custom_Combination_Color"), null);
colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Custom_Gradient"), null);
return colorSchemes;
}
public ColorInfo getSelectColorInfo() {
String selectedItem = (String) getSelectedItem();
return colorSchemes.get(selectedItem);
}
private ColorInfo colorMatchingToColorInfo(ChartColorMatching colorMatching) {
ColorInfo colorInfo = new ColorInfo();
colorInfo.setGradient(colorMatching.getGradient());
colorInfo.setColors(colorMatching.getColorList());
return colorInfo;
}
public SelectType getSelectType() {
int selectedIndex = this.getSelectedIndex();
int itemCount = this.getItemCount();
if (selectedIndex == itemCount - 1) {
return SelectType.GRADATION_COLOR;
}
if (selectedIndex == itemCount - 2) {
return SelectType.COMBINATION_COLOR;
}
if (selectedIndex == 0) {
return SelectType.DEFAULT;
}
return SelectType.NORMAL;
}
public void setSelectType(SelectType selectType) {
int itemCount = this.getItemCount();
switch (selectType) {
case DEFAULT:
setSelectedIndex(0);
break;
case GRADATION_COLOR:
setSelectedIndex(itemCount - 1);
break;
case COMBINATION_COLOR:
setSelectedIndex(itemCount - 2);
break;
}
}
public enum SelectType {
DEFAULT,
COMBINATION_COLOR,
GRADATION_COLOR,
NORMAL
}
public class ColorInfo {
private List<Color> colors;
private boolean gradient;
public List<Color> getColors() {
return colors;
}
public void setColors(List<Color> colors) {
this.colors = colors;
}
public boolean isGradient() {
return gradient;
}
public void setGradient(boolean gradient) {
this.gradient = gradient;
}
}
/**
* CellRenderer.
*/
class ColorSchemeCellRenderer extends UIComboBoxRenderer {
private String schemeName = Toolkit.i18nText("Fine-Design_Report_Default");
//左边距
private static final double X = 4d;
//上边距
private static final double Y = 4d;
private static final String BLANK_SPACE = " ";
private static final int HEIGHT = 20;
private static final int MAX_COUNT = 5;
@Override
public Dimension getPreferredSize() {
Dimension preferredSize = super.getPreferredSize();
preferredSize.setSize(super.getPreferredSize().getWidth(), HEIGHT);
return preferredSize;
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
public Component getListCellRendererComponent(
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.schemeName = GeneralUtils.objectToString(value);
ColorInfo colorInfo = colorSchemes.get(schemeName);
if (colorInfo == null) {
comp.setText(BLANK_SPACE + schemeName);
} else {
FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont());
double width = (HEIGHT - 2 * Y) * MAX_COUNT;
String fill = BLANK_SPACE;
//图形和文字之间留的宽度大于3倍的X
while (fontMetrics.stringWidth(fill) < width + 3 * X) {
fill += BLANK_SPACE;
}
comp.setText(fill + schemeName);
}
comp.setToolTipText(schemeName);
return comp;
}
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
ColorInfo colorInfo = colorSchemes.get(schemeName);
if (colorInfo != null) {
if (colorInfo.isGradient()) {
drawGradient(g2d, colorInfo.getColors());
} else {
drawCombineColor(g2d, colorInfo.getColors());
}
}
}
private void drawGradient(Graphics2D g2d, List<Color> colors) {
//上下留4px,宽度等于5倍高
double height = HEIGHT - 2 * Y;
double width = height * MAX_COUNT;
LinearGradientPaint linearGradientPaint = new LinearGradientPaint((float) X, (float) Y, (float) (X + width), (float) Y, new float[]{0f, 1f}, colors.toArray(new Color[colors.size()]));
g2d.setPaint(linearGradientPaint);
Rectangle2D rec = new Rectangle2D.Double(X, Y, width, height);
g2d.fill(rec);
}
private void drawCombineColor(Graphics2D g2d, List<Color> colors) {
int size = Math.min(colors.size(), MAX_COUNT);
double height = HEIGHT - 2 * Y;
double width = height * MAX_COUNT / size;
for (int i = 0; i < size; i++) {
g2d.setPaint(colors.get(i));
Rectangle2D rec = new Rectangle2D.Double(X + width * i, Y, width, height);
g2d.fill(rec);
}
}
}
}

238
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java

@ -0,0 +1,238 @@
package com.fr.design.mainframe.chart.gui.style;
import com.fr.base.BaseUtils;
import com.fr.base.background.ColorBackground;
import com.fr.design.chartx.component.button.ColorButton;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.style.AbstractSelectBox;
import com.fr.design.style.color.ColorSelectPane;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.util.ArrayList;
import java.util.List;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
/**
* 配色方案选择组合色之后可以调整颜色的组件
*
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-03-25
*/
public class ChartColorAdjustPane extends JPanel implements UIObserver {
public static final Color[] DEFAULT_COLORS = {
new Color(99, 178, 238),
new Color(118, 218, 145),
new Color(248, 203, 127),
new Color(248, 149, 136),
new Color(124, 214, 207),
new Color(145, 146, 171),
new Color(120, 152, 225),
new Color(239, 166, 102),
new Color(237, 221, 134),
new Color(153, 135, 206),
};
private static final int COUNT_OF_ROW = 8;
private static final int MAX_BUTTON = 40;
private List<ColorButton> colorButtons = new ArrayList<>();
private List<UIObserverListener> uiObserverListener;
private ChangeListener changeListener;
public ChartColorAdjustPane() {
this(DEFAULT_COLORS);
}
public ChartColorAdjustPane(Color[] colors) {
iniListener();
createColorButton(colors);
createContentPane();
}
public void updateColor() {
updateColor(DEFAULT_COLORS);
}
public void updateColor(Color[] colors) {
createColorButton(colors);
relayout();
}
public Color[] getColors() {
int size = colorButtons.size();
Color[] colors = new Color[size];
for (int i = 0; i < size; i++) {
colors[i] = colorButtons.get(i).getSelectObject();
}
return colors;
}
private void relayout() {
this.removeAll();
createContentPane();
this.validate();
this.repaint();
}
private void createContentPane() {
VerticalFlowLayout layout = new VerticalFlowLayout(0, 0, 0);
layout.setAlignLeft(true);
this.setLayout(layout);
for (int i = 0, size = colorButtons.size(); i < size; i += COUNT_OF_ROW) {
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
int count = i + COUNT_OF_ROW > colorButtons.size() ? colorButtons.size() : i + COUNT_OF_ROW;
for (int j = i; j < count; j++) {
colorButtons.get(j).setLastButton(false);
panel.add(colorButtons.get(j));
}
if (i + COUNT_OF_ROW > colorButtons.size()) {
panel.add(new AddColorButton());
this.add(panel);
} else if (i + COUNT_OF_ROW == colorButtons.size() && colorButtons.size() != MAX_BUTTON) {
this.add(panel);
this.add(new AddColorButton());
} else {
this.add(panel);
}
}
if (colorButtons.size() == 1) {
colorButtons.get(0).setLastButton(true);
}
}
private void createColorButton(Color[] colors) {
colorButtons.clear();
for (Color color : colors) {
colorButtons.add(createColorButton(color));
}
}
private ColorButton createColorButton(Color color) {
ColorButton colorButton = new ColorButton(color) {
@Override
protected void deleteButton() {
colorButtons.remove(this);
stateChanged();
relayout();
}
};
colorButton.addChangeListener(changeListener);
return colorButton;
}
private void iniListener() {
uiObserverListener = new ArrayList<>();
if (shouldResponseChangeListener()) {
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
for (UIObserverListener observerListener : uiObserverListener) {
observerListener.doChange();
}
}
});
}
}
public void stateChanged() {
if (changeListener != null) {
changeListener.stateChanged(null);
}
}
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener.add(listener);
}
public boolean shouldResponseChangeListener() {
return true;
}
private class AddColorButton extends AbstractSelectBox<Color> {
BufferedImage image = BaseUtils.readImageWithCache("/com/fr/design/images/buttonicon/add.png");
public AddColorButton() {
addMouseListener(getMouseListener());
}
@Override
public void paint(Graphics g) {
this.setSize(ColorButton.WIDTH, ColorButton.WIDTH);
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(Color.WHITE);
Rectangle2D rec = new Rectangle2D.Double(0, 0, ColorButton.WIDTH + 1, ColorButton.WIDTH + 1);
g2d.fill(rec);
g2d.drawImage(image, 0, 0, ColorButton.WIDTH + 1, ColorButton.WIDTH + 1, null);
}
public Dimension getPreferredSize() {
return new Dimension(ColorButton.WIDTH, ColorButton.WIDTH);
}
protected MouseListener getMouseListener() {
return new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
showPopupMenu();
}
};
}
public JPanel initWindowPane(double preferredWidth) {
// 下拉的时候重新生成面板,刷新最近使用颜色
ColorSelectPane colorPane = new ColorSelectPane(false) {
public void setVisible(boolean b) {
super.setVisible(b);
}
};
colorPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
hidePopupMenu();
Color color = ((ColorSelectPane) e.getSource()).getColor();
fireDisplayComponent(ColorBackground.getInstance(color));
colorButtons.add(createColorButton(color));
ChartColorAdjustPane.this.stateChanged();
relayout();
}
});
return colorPane;
}
public Color getSelectObject() {
return null;
}
public void setSelectObject(Color color) {
}
}
}

19
designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java

@ -7,11 +7,12 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.style.ChartAccColorPane; import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane;
import com.fr.design.style.background.gradient.FixedGradientBar; import com.fr.design.style.background.gradient.FixedGradientBar;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
@ -20,8 +21,6 @@ import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/** /**
@ -37,7 +36,7 @@ public class ChartPreFillStylePane extends BasicBeanPane<ChartColorMatching> {
private UIButton accButton; private UIButton accButton;
private UIButton gradientButton; private UIButton gradientButton;
private ChartAccColorPane colorAcc; private ChartColorAdjustPane colorAdjustPane;
private FixedGradientBar colorGradient; private FixedGradientBar colorGradient;
public ChartPreFillStylePane() { public ChartPreFillStylePane() {
@ -53,13 +52,13 @@ public class ChartPreFillStylePane extends BasicBeanPane<ChartColorMatching> {
JPanel buttonPane = new JPanel(); JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT)); buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT));
buttonPane.add(accButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Acc_Set"))); buttonPane.add(accButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Color")));
buttonPane.add(gradientButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Color"))); buttonPane.add(gradientButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Color")));
customPane.add(buttonPane, BorderLayout.NORTH); customPane.add(buttonPane, BorderLayout.NORTH);
changeColorSetPane = new JPanel(cardLayout = new CardLayout()); changeColorSetPane = new JPanel(cardLayout = new CardLayout());
changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient");
changeColorSetPane.add(colorAcc = new ChartAccColorPane(), "acc"); changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc");
cardLayout.show(changeColorSetPane, "acc"); cardLayout.show(changeColorSetPane, "acc");
customPane.add(changeColorSetPane, BorderLayout.CENTER); customPane.add(changeColorSetPane, BorderLayout.CENTER);
@ -68,7 +67,7 @@ public class ChartPreFillStylePane extends BasicBeanPane<ChartColorMatching> {
customPane.setPreferredSize(new Dimension(200, 200)); customPane.setPreferredSize(new Dimension(200, 200));
colorGradient.setPreferredSize(new Dimension(120, 30)); colorGradient.setPreferredSize(new Dimension(120, 30));
colorGradient.getSelectColorPointBtnP1().setColorInner(Color.WHITE); colorGradient.getSelectColorPointBtnP1().setColorInner(Color.WHITE);
colorGradient.getSelectColorPointBtnP2().setColorInner(Color.black); colorGradient.getSelectColorPointBtnP2().setColorInner(FixedGradientBar.NEW_CHARACTER);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double[] columnSize = {p, p}; double[] columnSize = {p, p};
@ -131,7 +130,7 @@ public class ChartPreFillStylePane extends BasicBeanPane<ChartColorMatching> {
cardLayout.show(changeColorSetPane, "acc"); cardLayout.show(changeColorSetPane, "acc");
if (colorList.size() > 0) { if (colorList.size() > 0) {
colorAcc.populateBean(colorList.toArray(new Color[colorList.size()])); colorAdjustPane.updateColor(colorList.toArray(new Color[colorList.size()]));
} }
} }
} }
@ -152,7 +151,7 @@ public class ChartPreFillStylePane extends BasicBeanPane<ChartColorMatching> {
} else { } else {
chartColorMatching.setGradient(false); chartColorMatching.setGradient(false);
Color[] colors = colorAcc.updateBean(); Color[] colors = colorAdjustPane.getColors();
for(Color color : colors) { for(Color color : colors) {
colorList.add(color); colorList.add(color);
} }

7
designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java

@ -6,6 +6,7 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.van.chart.column.VanChartCustomStackAndAxisConditionPane; import com.fr.van.chart.column.VanChartCustomStackAndAxisConditionPane;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.line.VanChartLineSeriesPane; import com.fr.van.chart.line.VanChartLineSeriesPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -27,7 +28,6 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane {
double[] col = {f}; double[] col = {f};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{getColorPane()},
new Component[]{createLineTypePane()}, new Component[]{createLineTypePane()},
new Component[]{createMarkerPane()}, new Component[]{createMarkerPane()},
new Component[]{createAreaFillColorPane()}, new Component[]{createAreaFillColorPane()},
@ -44,4 +44,9 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane {
protected Class<? extends BasicBeanPane> getStackAndAxisPaneClass() { protected Class<? extends BasicBeanPane> getStackAndAxisPaneClass() {
return VanChartCustomStackAndAxisConditionPane.class; return VanChartCustomStackAndAxisConditionPane.class;
} }
//风格
protected VanChartBeautyPane createStylePane() {
return new VanChartBeautyPane();
}
} }

3
designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java

@ -37,14 +37,13 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane {
double[] col = {f}; double[] col = {f};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{getColorPane()},
new Component[]{createBubblePane()}, new Component[]{createBubblePane()},
new Component[]{createStackedAndAxisPane()}, new Component[]{createStackedAndAxisPane()},
new Component[]{null} new Component[]{null}
}; };
if (!((VanChartBubblePlot) plot).isForceBubble()) { if (!((VanChartBubblePlot) plot).isForceBubble()) {
components[3] = new Component[]{createLargeDataModelPane()}; components[2] = new Component[]{createLargeDataModelPane()};
} }
contentPane = TableLayoutHelper.createTableLayoutPane(components, row, col); contentPane = TableLayoutHelper.createTableLayoutPane(components, row, col);

1
designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java

@ -53,7 +53,6 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
double[] columnSize = {f}; double[] columnSize = {f};
double[] rowSize = {p,p,p,p,p,p,p,p,p,p}; double[] rowSize = {p,p,p,p,p,p,p,p,p,p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{getColorPane()},
new Component[]{createSeriesStylePane(new double[]{p,p}, new double[]{f,e})}, new Component[]{createSeriesStylePane(new double[]{p,p}, new double[]{f,e})},
new Component[]{createBorderPane()}, new Component[]{createBorderPane()},
new Component[]{createStackedAndAxisPane()}, new Component[]{createStackedAndAxisPane()},

5
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java

@ -4,7 +4,6 @@ import com.fr.chart.chartattr.Chart;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane;
import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane;
import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot;
@ -24,7 +23,7 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
private JPanel seriesPane; private JPanel seriesPane;
protected VanChartCustomPlotSeriesTabPane plotSeriesPane; protected VanChartCustomPlotSeriesTabPane plotSeriesPane;
private ChartFillStylePane fillStylePane;//配色 private VanChartFillStylePane fillStylePane;//配色
private VanChartBeautyPane stylePane;//风格 private VanChartBeautyPane stylePane;//风格
@ -81,7 +80,7 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
}; };
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col);
panel.setBorder(BorderFactory.createEmptyBorder(10,10,0,15)); panel.setBorder(BorderFactory.createEmptyBorder(5,5,0,5));
return panel; return panel;
} }

16
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java

@ -29,7 +29,7 @@ public class VanChartBeautyPane extends BasicBeanPane<Integer> {
double[] columnSize = {f, e}; double[] columnSize = {f, e};
double[] rowSize = {p}; double[] rowSize = {p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style")), styleBox}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), styleBox},
} ; } ;
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
@ -37,17 +37,17 @@ public class VanChartBeautyPane extends BasicBeanPane<Integer> {
} }
protected String[] getNameArray(){ protected String[] getNameArray(){
return new String[]{Toolkit.i18nText("Fine-Design_Chart_Default_Name"), return new String[]{Toolkit.i18nText("Fine-Design_Chart_On"),
Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade") Toolkit.i18nText("Fine-Design_Chart_Off")
}; };
} }
@Override @Override
public void populateBean(Integer ob) { public void populateBean(Integer ob) {
int finalIndex; int finalIndex;
switch (ob){ switch (ob){
case ChartConstants.STYLE_NONE: finalIndex = 0; break; case ChartConstants.STYLE_NONE: finalIndex = 1; break;
case ChartConstants.STYLE_SHADE: finalIndex = 1; break; case ChartConstants.STYLE_SHADE: finalIndex = 0; break;
default: finalIndex = 0; default: finalIndex = 1;
} }
styleBox.setSelectedIndex(finalIndex); styleBox.setSelectedIndex(finalIndex);
} }
@ -57,8 +57,8 @@ public class VanChartBeautyPane extends BasicBeanPane<Integer> {
int index = styleBox.getSelectedIndex(); int index = styleBox.getSelectedIndex();
int style; int style;
switch (index){ switch (index){
case 0: style = ChartConstants.STYLE_NONE; break; case 0: style = ChartConstants.STYLE_SHADE; break;
case 1: style = ChartConstants.STYLE_SHADE; break; case 1: style = ChartConstants.STYLE_NONE; break;
default: style = ChartConstants.STYLE_NONE; default: style = ChartConstants.STYLE_NONE;
} }
return style; return style;

218
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java

@ -1,42 +1,236 @@
package com.fr.van.chart.designer.component; package com.fr.van.chart.designer.component;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.base.Utils;
import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartUtils;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chartx.component.combobox.ColorSchemeComboBox;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane; import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/** /**
* Created by mengao on 2017/8/17. * Created by mengao on 2017/8/17.
*/ */
public class VanChartFillStylePane extends ChartFillStylePane { public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> {
protected ColorSchemeComboBox styleSelectBox;
protected JPanel customPane;
protected JPanel changeColorSetPane;
protected FixedGradientBar colorGradient;
protected CardLayout cardLayout;
protected ChartColorAdjustPane colorAdjustPane;
private Color[] gradientColors;
private Color[] accColors;
private boolean gradientSelect = false;
public VanChartFillStylePane() {
this.setLayout(new BorderLayout());
styleSelectBox = new ColorSchemeComboBox();
customPane = new JPanel(FRGUIPaneFactory.createBorderLayout());
changeColorSetPane = new JPanel(cardLayout = new CardLayout());
changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient");
gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER};
changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc");
accColors = ChartColorAdjustPane.DEFAULT_COLORS;
cardLayout.show(changeColorSetPane, "acc");
customPane.add(changeColorSetPane, BorderLayout.CENTER);
initListener();
initLayout();
}
private void initListener() {
colorAdjustPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
accColors = colorAdjustPane.getColors();
if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.COMBINATION_COLOR) {
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR);
}
VanChartFillStylePane.this.revalidate();
}
});
colorGradient.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
gradientColors[0] = colorGradient.getSelectColorPointBtnP1().getColorInner();
gradientColors[1] = colorGradient.getSelectColorPointBtnP2().getColorInner();
if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.GRADATION_COLOR) {
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR);
}
}
});
styleSelectBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
switch (styleSelectBox.getSelectType()) {
case COMBINATION_COLOR:
colorAdjustPane.updateColor(accColors);
cardLayout.show(changeColorSetPane, "acc");
gradientSelect = false;
break;
case GRADATION_COLOR:
colorGradient.updateColor(gradientColors[0], gradientColors[1]);
cardLayout.show(changeColorSetPane, "gradient");
gradientSelect = true;
break;
default:
ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo();
if (selectColorInfo.isGradient()) {
colorGradient.updateColor(selectColorInfo.getColors().get(0), selectColorInfo.getColors().get(1));
cardLayout.show(changeColorSetPane, "gradient");
gradientSelect = true;
} else {
colorAdjustPane.updateColor(selectColorInfo.getColors().toArray(new Color[]{}));
cardLayout.show(changeColorSetPane, "acc");
gradientSelect = false;
}
break;
}
VanChartFillStylePane.this.revalidate();
}
});
}
protected void initLayout() {
this.setLayout(new BorderLayout());
this.add(getContentPane(), BorderLayout.CENTER);
}
@Override @Override
protected JPanel getContentPane () { public Dimension getPreferredSize() {
if (gradientSelect) {
return new Dimension(225, 80);
}
return super.getPreferredSize();
}
protected JPanel getContentPane() {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e}; double[] columnSize = {f, e};
double[] rowSize = {p, p}; double[] rowSize = {p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color_Match")),styleSelectBox}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), styleSelectBox},
new Component[]{null,customPane}, new Component[]{null, customPane},
}; };
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
panel.setBorder(BorderFactory.createEmptyBorder(5,5,0,0)); panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
return panel; return panel;
} }
@Override @Override
public Dimension getPreferredSize() { protected String title4PopupWindow() {
if(styleSelectBox.getSelectedIndex() != styleSelectBox.getItemCount() - 1) { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color");
return new Dimension(styleSelectBox.getPreferredSize().width, 30); }
@Override
public void populateBean(AttrFillStyle condition) {
String fillStyleName = condition == null ? "" : condition.getFillStyleName();
if (StringUtils.isBlank(fillStyleName)) {//兼容处理
if (condition == null || condition.getColorStyle() == ChartConstants.COLOR_DEFAULT) {
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.DEFAULT);//默认
} else {
int colorStyle = condition.getColorStyle();
if (colorStyle == ChartConstants.COLOR_GRADIENT) {
gradientColors[0] = condition.getColorIndex(0);
gradientColors[1] = condition.getColorIndex(1);
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR);
} else {
int colorSize = condition.getColorSize();
accColors = new Color[colorSize];
for (int i = 0; i < colorSize; i++) {
accColors[i] = condition.getColorIndex(i);
}
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR);
}
}
} else {
styleSelectBox.setSelectedItem(fillStyleName);
}
}
@Override
public AttrFillStyle updateBean() {
switch (styleSelectBox.getSelectType()) {
case COMBINATION_COLOR:
return updateCombinationColor();
case GRADATION_COLOR:
return updateGradationColor();
case DEFAULT:
return updateDefaultColor();
default:
return updateNormalColor();
}
}
private AttrFillStyle updateCombinationColor() {
AttrFillStyle condition = new AttrFillStyle();
condition.clearColors();
condition.setColorStyle(ChartConstants.COLOR_ACC);
for (int i = 0, length = accColors.length; i < length; i++) {
condition.addFillColor(accColors[i]);
}
condition.setCustomFillStyle(true);
return condition;
}
private AttrFillStyle updateGradationColor() {
AttrFillStyle condition = new AttrFillStyle();
condition.clearColors();
condition.setColorStyle(ChartConstants.COLOR_GRADIENT);
Color start = gradientColors[0];
Color end = gradientColors[1];
condition.addFillColor(start);
condition.addFillColor(end);
condition.setCustomFillStyle(true);
return condition;
}
private AttrFillStyle updateDefaultColor() {
AttrFillStyle condition = new AttrFillStyle();
condition.clearColors();
condition.setColorStyle(ChartConstants.COLOR_DEFAULT);
return condition;
}
private AttrFillStyle updateNormalColor() {
ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance();
Object preStyle = manager.getPreStyle(styleSelectBox.getSelectedItem());
if (preStyle instanceof ChartColorMatching) {
AttrFillStyle def = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle);
def.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem()));
return def;
} else {
return updateDefaultColor();
} }
return super.getPreferredSize();
} }
} }

27
designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java

@ -10,8 +10,8 @@ import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane;
import com.fr.design.mainframe.chart.gui.style.series.AbstractPlotSeriesPane; import com.fr.design.mainframe.chart.gui.style.series.AbstractPlotSeriesPane;
import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.VanChartAttrHelper;
import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartPlot;
@ -23,7 +23,6 @@ import com.fr.plugin.chart.base.VanChartAttrLine;
import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.plugin.chart.base.VanChartAttrMarker;
import com.fr.plugin.chart.base.VanChartAttrTrendLine; import com.fr.plugin.chart.base.VanChartAttrTrendLine;
import com.fr.van.chart.custom.style.VanChartCustomStylePane; import com.fr.van.chart.custom.style.VanChartCustomStylePane;
import com.fr.design.i18n.Toolkit;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartAreaSeriesFillColorPane; import com.fr.van.chart.designer.component.VanChartAreaSeriesFillColorPane;
import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.designer.component.VanChartBeautyPane;
@ -62,6 +61,8 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
private VanChartBorderPane borderPane;//边框 private VanChartBorderPane borderPane;//边框
protected VanChartFillStylePane vanChartFillStylePane;//配色
private UINumberDragPane transparent;//不透明度 private UINumberDragPane transparent;//不透明度
protected VanChartStackedAndAxisListControlPane stackAndAxisEditPane;//堆積和坐標軸 protected VanChartStackedAndAxisListControlPane stackAndAxisEditPane;//堆積和坐標軸
@ -86,18 +87,18 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
} }
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
if (fillStylePane != null) { JPanel colorPane = getColorPane();
panel.add(fillStylePane, BorderLayout.NORTH); if(colorPane != null) {
panel.add(colorPane, BorderLayout.NORTH);
} }
panel.add(getContentInPlotType(), BorderLayout.CENTER); panel.add(getContentInPlotType(), BorderLayout.CENTER);
return panel; return panel;
} }
@Override
/** /**
* 返回 填充界面. * 返回 填充界面.
*/ */
protected ChartFillStylePane getFillStylePane() { protected VanChartFillStylePane getVanChartFillStylePane() {
//如果是自定義組合圖,則不創建填充界面 //如果是自定義組合圖,則不創建填充界面
return parentPane instanceof VanChartCustomStylePane ? null : new VanChartFillStylePane(); return parentPane instanceof VanChartCustomStylePane ? null : new VanChartFillStylePane();
} }
@ -111,9 +112,13 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
protected JPanel getColorPane() { protected JPanel getColorPane() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
stylePane = createStylePane(); stylePane = createStylePane();
vanChartFillStylePane = getVanChartFillStylePane();
if (vanChartFillStylePane != null) {
panel.add(vanChartFillStylePane, BorderLayout.NORTH);
}
setColorPaneContent(panel); setColorPaneContent(panel);
JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel); JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel);
panel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
return panel.getComponentCount() == 0 ? null : colorPane; return panel.getComponentCount() == 0 ? null : colorPane;
} }
@ -266,7 +271,9 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
checkoutMapType(plot); checkoutMapType(plot);
super.populateBean(plot);//配色 if(vanChartFillStylePane != null) { //配色
vanChartFillStylePane.populateBean(plot.getPlotFillStyle());
}
if (stylePane != null) {//风格 if (stylePane != null) {//风格
stylePane.populateBean(plot.getPlotStyle()); stylePane.populateBean(plot.getPlotStyle());
@ -323,7 +330,9 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
//更新之前先更新界面的map类型属性 //更新之前先更新界面的map类型属性
checkoutMapType(plot); checkoutMapType(plot);
super.updateBean(plot);//配色 if(vanChartFillStylePane != null) {//配色
plot.setPlotFillStyle(vanChartFillStylePane.updateBean());
}
if (stylePane != null) {//风格 if (stylePane != null) {//风格
plot.setPlotStyle(stylePane.updateBean()); plot.setPlotStyle(stylePane.updateBean());

1
designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java

@ -31,7 +31,6 @@ public class VanChartFunnelSeriesPane extends VanChartAbstractPlotSeriesPane {
double[] columnSize = {f}; double[] columnSize = {f};
double[] rowSize = {p,p,p,p,p,p,p,p,p,p}; double[] rowSize = {p,p,p,p,p,p,p,p,p,p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{getColorPane()},
new Component[]{createFunnelStylePane()}, new Component[]{createFunnelStylePane()},
new Component[]{createBorderPane()}, new Component[]{createBorderPane()},
}; };

6
designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java

@ -13,6 +13,7 @@ import com.fr.plugin.chart.base.VanChartAttrMarker;
import com.fr.plugin.chart.gantt.VanChartGanttPlot; import com.fr.plugin.chart.gantt.VanChartGanttPlot;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartMarkerPane; import com.fr.van.chart.designer.component.VanChartMarkerPane;
import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane; import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
@ -121,4 +122,9 @@ public class VanChartGanttSeriesPane extends VanChartAbstractPlotSeriesPane {
} }
} }
@Override
protected VanChartBeautyPane createStylePane() {
return null;
}
} }

9
designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java

@ -6,6 +6,7 @@ import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
@ -13,8 +14,6 @@ import com.fr.design.mainframe.chart.gui.style.series.ColorPickerPaneWithFormula
import com.fr.design.mainframe.chart.gui.style.series.UIColorPickerPane; import com.fr.design.mainframe.chart.gui.style.series.UIColorPickerPane;
import com.fr.design.style.color.ColorSelectBox; import com.fr.design.style.color.ColorSelectBox;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.chart.attr.GaugeDetailStyle; import com.fr.plugin.chart.attr.GaugeDetailStyle;
import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.AttrLabel;
import com.fr.plugin.chart.base.AttrLabelDetail; import com.fr.plugin.chart.base.AttrLabelDetail;
@ -22,6 +21,7 @@ import com.fr.plugin.chart.gauge.VanChartGaugePlot;
import com.fr.plugin.chart.type.GaugeStyle; import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -306,4 +306,9 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
colorPickerPane.updateBean(detailStyle.getHotAreaColor()); colorPickerPane.updateBean(detailStyle.getHotAreaColor());
} }
} }
@Override
protected VanChartBeautyPane createStylePane() {
return null;
}
} }

5
designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java

@ -9,10 +9,9 @@ import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane;
import com.fr.plugin.chart.heatmap.VanChartHeatMapPlot; import com.fr.plugin.chart.heatmap.VanChartHeatMapPlot;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartFillStylePane;
import com.fr.van.chart.map.VanChartMapSeriesPane; import com.fr.van.chart.map.VanChartMapSeriesPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -41,7 +40,7 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane {
/** /**
* 返回 填充界面. * 返回 填充界面.
*/ */
protected ChartFillStylePane getFillStylePane() { protected VanChartFillStylePane getVanChartFillStylePane() {
return null; return null;
} }

6
designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java

@ -4,6 +4,7 @@ import com.fr.chart.chartattr.Plot;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -38,4 +39,9 @@ public class VanChartLineSeriesPane extends VanChartAbstractPlotSeriesPane {
return contentPane; return contentPane;
} }
@Override
protected VanChartBeautyPane createStylePane() {
return null;
}
} }

51
designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java

@ -6,6 +6,7 @@ import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
@ -36,6 +37,7 @@ import com.fr.van.chart.map.designer.style.series.VanChartMapScatterMarkerPane;
import com.fr.van.chart.map.line.VanChartCurvePane; import com.fr.van.chart.map.line.VanChartCurvePane;
import com.fr.van.chart.map.line.VanChartLineMapEffectPane; import com.fr.van.chart.map.line.VanChartLineMapEffectPane;
import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
@ -157,6 +159,35 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane {
} }
} }
@Override
protected JPanel getContentPane(boolean custom) {
JPanel panel = new JPanel(new BorderLayout());
mapType = ((VanChartMapPlot) plot).getAllLayersMapType();
if(mapType == MapType.CUSTOM || mapType == MapType.DRILL_CUSTOM) {
vanChartFillStylePane = getVanChartFillStylePane();
panel.add(vanChartFillStylePane, BorderLayout.NORTH);
}
panel.add(getContentInPlotType(), BorderLayout.CENTER);
return panel;
}
//获取颜色面板
private JPanel getColorPane(MapType paneType) {
JPanel panel = new JPanel(new BorderLayout());
stylePane = createStylePane();
mapType = ((VanChartMapPlot) plot).getAllLayersMapType();
if(mapType != MapType.CUSTOM && mapType != MapType.DRILL_CUSTOM) {
vanChartFillStylePane = getVanChartFillStylePane();
if (vanChartFillStylePane != null) {
panel.add(vanChartFillStylePane, BorderLayout.NORTH);
}
}
setColorPaneContent(panel, paneType);
JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel);
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
return panel.getComponentCount() == 0 ? null : colorPane;
}
/** /**
* 在每个不同类型Plot, 得到不同类型的属性. 比如: 柱形的风格, 折线的线型曲线. * 在每个不同类型Plot, 得到不同类型的属性. 比如: 柱形的风格, 折线的线型曲线.
*/ */
@ -176,10 +207,17 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane {
} }
//设置色彩面板内容 //设置色彩面板内容
protected void setColorPaneContent(JPanel panel) { protected void setColorPaneContent(JPanel panel, MapType paneType) {
panel.add(createNullValueColorPane(), BorderLayout.CENTER); switch (paneType) {
panel.add(createAlphaPane(), BorderLayout.SOUTH); case AREA:
panel.add(createNullValueColorPane(), BorderLayout.CENTER);
panel.add(createAlphaPane(), BorderLayout.SOUTH);
break;
case POINT:
panel.add(createPointAlphaPane(), BorderLayout.CENTER);
default:
return;
}
} }
@ -192,7 +230,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane {
double[] col = {f}; double[] col = {f};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{getColorPane()}, new Component[]{getColorPane(MapType.AREA)},
new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"), borderWithAlphaPane)}, new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"), borderWithAlphaPane)},
}; };
@ -213,7 +251,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane {
double[] col = {f}; double[] col = {f};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle((com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), createPointAlphaPane())}, new Component[]{getColorPane(MapType.POINT)},
new Component[]{createMarkerComPane()}, new Component[]{createMarkerComPane()},
//大数据模式 恢复用注释。下面1行删除。 //大数据模式 恢复用注释。下面1行删除。
new Component[]{createLargeDataModelPane()}, new Component[]{createLargeDataModelPane()},
@ -232,6 +270,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane {
curvePane = new VanChartCurvePane(); curvePane = new VanChartCurvePane();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{getColorPane(MapType.LINE)},
new Component[]{createCurvePane()}, new Component[]{createCurvePane()},
//大数据模式 恢复用注释。下面1行删除。 //大数据模式 恢复用注释。下面1行删除。
new Component[]{createLineMapLargeDataModelPane()}, new Component[]{createLineMapLargeDataModelPane()},

7
designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java

@ -7,9 +7,9 @@ import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.plugin.chart.multilayer.VanChartMultiPiePlot; import com.fr.plugin.chart.multilayer.VanChartMultiPiePlot;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.pie.VanChartPieSeriesPane; import com.fr.van.chart.pie.VanChartPieSeriesPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -90,4 +90,9 @@ public class VanChartMultiPieSeriesPane extends VanChartPieSeriesPane {
multiPiePlot.setSupportRotation(supportRotation.getSelectedIndex() == 0); multiPiePlot.setSupportRotation(supportRotation.getSelectedIndex() == 0);
} }
} }
@Override
protected VanChartBeautyPane createStylePane() {
return null;
}
} }

1
designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java

@ -41,7 +41,6 @@ public class VanChartPieSeriesPane extends VanChartAbstractPlotSeriesPane {
double[] columnSize = {f}; double[] columnSize = {f};
double[] rowSize = {p,p,p,p,p,p}; double[] rowSize = {p,p,p,p,p,p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{getColorPane()},
new Component[]{createSeriesStylePane(rowSize, new double[]{f, e})}, new Component[]{createSeriesStylePane(rowSize, new double[]{f, e})},
new Component[]{createBorderPane()}, new Component[]{createBorderPane()},
}; };

5
designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java

@ -43,7 +43,6 @@ public class VanChartRadarSeriesPane extends VanChartAbstractPlotSeriesPane {
private Component[][] getPaneComponents() { private Component[][] getPaneComponents() {
if(plot instanceof VanChartRadarPlot && ((VanChartRadarPlot)plot).isStackChart()) { if(plot instanceof VanChartRadarPlot && ((VanChartRadarPlot)plot).isStackChart()) {
return new Component[][]{ return new Component[][]{
new Component[]{getColorPane()},
new Component[]{createRadarTypePane()}, new Component[]{createRadarTypePane()},
new Component[]{createBorderPane()}, new Component[]{createBorderPane()},
}; };
@ -59,7 +58,9 @@ public class VanChartRadarSeriesPane extends VanChartAbstractPlotSeriesPane {
//设置色彩面板内容 //设置色彩面板内容
protected void setColorPaneContent (JPanel panel) { protected void setColorPaneContent (JPanel panel) {
panel.add(createAlphaPane(), BorderLayout.CENTER); if(plot instanceof VanChartRadarPlot && ((VanChartRadarPlot)plot).isStackChart()) {
panel.add(createAlphaPane(), BorderLayout.CENTER);
}
} }
private JPanel createRadarTypePane() { private JPanel createRadarTypePane() {

1
designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java

@ -35,7 +35,6 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane {
double[] col = {f}; double[] col = {f};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{getColorPane()},
new Component[]{createLineTypePane()}, new Component[]{createLineTypePane()},
new Component[]{createMarkerPane()}, new Component[]{createMarkerPane()},
new Component[]{createStackedAndAxisPane()}, new Component[]{createStackedAndAxisPane()},

7
designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java

@ -10,10 +10,10 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.style.color.ColorSelectBox; import com.fr.design.style.color.ColorSelectBox;
import com.fr.plugin.chart.base.AttrNode; import com.fr.plugin.chart.base.AttrNode;
import com.fr.plugin.chart.structure.VanChartStructurePlot; import com.fr.plugin.chart.structure.VanChartStructurePlot;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -142,4 +142,9 @@ public class VanChartStructureSeriesPane extends VanChartAbstractPlotSeriesPane
} }
} }
} }
@Override
protected VanChartBeautyPane createStylePane() {
return null;
}
} }

7
designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java

@ -15,10 +15,10 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.plugin.chart.wordcloud.CloudShapeType; import com.fr.plugin.chart.wordcloud.CloudShapeType;
import com.fr.plugin.chart.wordcloud.VanChartWordCloudPlot; import com.fr.plugin.chart.wordcloud.VanChartWordCloudPlot;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -228,4 +228,9 @@ public class VanChartWordCloudSeriesPane extends VanChartAbstractPlotSeriesPane
} }
} }
} }
@Override
protected VanChartBeautyPane createStylePane() {
return null;
}
} }

2
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -93,7 +93,7 @@ public class FormCreatorDropTarget extends DropTarget {
//SetSelection时要确保选中的是最顶层的布局 //SetSelection时要确保选中的是最顶层的布局
//tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout //tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout
XCreator addingXCreator = addingModel.getXCreator(); XCreator addingXCreator = addingModel.getXCreator();
Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData(); Widget widget = (addingXCreator.getBackupParent() != null && addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();
//图表埋点 //图表埋点
dealChartBuryingPoint(widget); dealChartBuryingPoint(widget);
if (addingXCreator.isShared()) { if (addingXCreator.isShared()) {

2
designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java

@ -88,7 +88,7 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor {
Window parentWindow = SwingUtilities.getWindowAncestor(grid); Window parentWindow = SwingUtilities.getWindowAncestor(grid);
this.biasTextPainterPane = new BiasTextPainterPane(); this.biasTextPainterPane = new BiasTextPainterPane();
Dimension dimension = this.biasTextPainterPane.getPreferredSize(); Dimension dimension = this.biasTextPainterPane.getPreferredSize();
Dimension wrapDimension = new Dimension((int) (dimension.width * MULTIPLE), (int) (dimension.height * MULTIPLE)); Dimension wrapDimension = new Dimension((int) (dimension.width * MULTIPLE), (int) (dimension.height * Math.pow(MULTIPLE, 2)));
this.biasTextPainterPane.populate(biasTextPainter); this.biasTextPainterPane.populate(biasTextPainter);
return this.biasTextPainterPane.showWindowWithCustomSize(parentWindow, new DialogActionAdapter() { return this.biasTextPainterPane.showWindowWithCustomSize(parentWindow, new DialogActionAdapter() {

9
designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java

@ -5,6 +5,7 @@ import com.fr.main.impl.WorkBook;
import com.fr.main.parameter.ReportParameterAttr; import com.fr.main.parameter.ReportParameterAttr;
import com.fr.report.cellcase.CellCase; import com.fr.report.cellcase.CellCase;
import com.fr.report.poly.PolyWorkSheet; import com.fr.report.poly.PolyWorkSheet;
import com.fr.report.report.Report;
import com.fr.report.worksheet.WorkSheet; import com.fr.report.worksheet.WorkSheet;
import java.util.Iterator; import java.util.Iterator;
@ -61,8 +62,12 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> {
int blockCount = 0; int blockCount = 0;
if (!template.isElementCaseBook()) { // 如果是聚合报表 if (!template.isElementCaseBook()) { // 如果是聚合报表
for (int i = 0; i < template.getReportCount(); i++) { for (int i = 0; i < template.getReportCount(); i++) {
PolyWorkSheet r = (PolyWorkSheet) template.getReport(i); Report report = template.getReport(i);
blockCount += r.getBlockCount(); // 考虑多个sheet下 包含WorkSheet的情况 需要判断下
if (report instanceof PolyWorkSheet) {
PolyWorkSheet r = (PolyWorkSheet) report;
blockCount += r.getBlockCount();
}
} }
} }
return blockCount; return blockCount;

12
designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java

@ -9,7 +9,6 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import javax.imageio.ImageIO;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -32,14 +31,13 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime {
private static final String BIN_HOME = StableUtils.pathJoin(StableUtils.getInstallHome(), "bin"); private static final String BIN_HOME = StableUtils.pathJoin(StableUtils.getInstallHome(), "bin");
private static final String LOGO_PATH = StableUtils.pathJoin(BIN_HOME, "logo.png"); private static final String LOGO_PATH = StableUtils.pathJoin(BIN_HOME, "logo.png");
private static final String DOCK_OPTIONS = "-Xdock:icon=" + LOGO_PATH; private static final String DOCK_OPTIONS = "-Xdock:icon=" + LOGO_PATH;
private static final String DOCK_NAME_OPTIONS = "-Xdock:name=" + FineDesigner.class.getSimpleName();
private static final String[] DEBUG_OPTIONS = new String[]{"-Dfile.encoding=UTF-8", "-Xmx2048m"}; private static final String[] DEBUG_OPTIONS = new String[]{"-Dfile.encoding=UTF-8", "-Xmx2048m"};
static { static {
if (SupportOSImpl.DOCK_ICON.support()) { try {
try { IOUtils.copy(DesignerJavaRuntime.class.getResourceAsStream("/com/fr/design/icon/logo.png"), "logo.png", new File(BIN_HOME));
ImageIO.write(IOUtils.readImage("com/fr/design/icon/logo.png"), "png", new File(LOGO_PATH)); } catch (IOException ignore) {
} catch (IOException ignore) {
}
} }
} }
@ -99,7 +97,7 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime {
if (isInstallVersion()) { if (isInstallVersion()) {
String[] options = super.getJvmOptions(); String[] options = super.getJvmOptions();
if (SupportOSImpl.DOCK_ICON.support()) { if (SupportOSImpl.DOCK_ICON.support()) {
options = ArrayUtils.add(options, DOCK_OPTIONS); options = ArrayUtils.addAll(options, DOCK_OPTIONS, DOCK_NAME_OPTIONS);
} }
return options; return options;
} else { } else {

30
designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java

@ -1,5 +1,6 @@
package com.fr.start; package com.fr.start;
import com.fr.common.report.ReportState;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.dialog.ErrorDialog; import com.fr.design.dialog.ErrorDialog;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -9,12 +10,14 @@ import com.fr.design.utils.DesignUtils;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.event.Null; import com.fr.event.Null;
import com.fr.general.ComparatorUtils;
import com.fr.process.FineProcess; import com.fr.process.FineProcess;
import com.fr.process.ProcessEventPipe; import com.fr.process.ProcessEventPipe;
import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessContext;
import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.process.engine.core.FineProcessEngineEvent;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
@ -33,10 +36,12 @@ public class DesignerSuperListener {
private static final int FIXED_FREQ = 2; private static final int FIXED_FREQ = 2;
private final ScheduledExecutorService service = Executors.newScheduledThreadPool(2, new NamedThreadFactory("DesignerListener")); private final ScheduledExecutorService service = Executors.newScheduledThreadPool(2, new NamedThreadFactory("DesignerListener"));
private final ExecutorService helpService = Executors.newSingleThreadExecutor( new NamedThreadFactory("DesignerSuperListener-Help"));
private FineProcess process; private FineProcess process;
private ScheduledFuture fixedFuture; private ScheduledFuture fixedFuture;
private ScheduledFuture onceFuture; private ScheduledFuture onceFuture;
private volatile boolean cancel = false;
private DesignerSuperListener() { private DesignerSuperListener() {
@ -49,6 +54,7 @@ public class DesignerSuperListener {
public void start() { public void start() {
process = FineProcessContext.getProcess(DesignerProcessType.INSTANCE); process = FineProcessContext.getProcess(DesignerProcessType.INSTANCE);
startExitListener(); startExitListener();
startHelpLister();
startFrameListener(); startFrameListener();
startFallBackListener(); startFallBackListener();
} }
@ -62,10 +68,32 @@ public class DesignerSuperListener {
}); });
} }
private void startHelpLister() {
helpService.submit(new Runnable() {
@Override
public void run() {
while (!cancel) {
ProcessEventPipe pipe = process.getPipe();
String msg = pipe.info();
if (ComparatorUtils.equals(ReportState.STOP.getValue(), msg)) {
onceFuture.cancel(false);
}
if (ComparatorUtils.equals(ReportState.ACTIVE.getValue(), msg)) {
startFrameListener();
}
if (ComparatorUtils.equals(DesignerProcessType.INSTANCE.obtain(), msg)) {
frameReport();
}
}
}
});
}
private void startFrameListener() { private void startFrameListener() {
onceFuture = service.schedule(new Runnable() { onceFuture = service.schedule(new Runnable() {
@Override @Override
public void run() { public void run() {
cancel = true;
ProcessEventPipe pipe = process.getPipe(); ProcessEventPipe pipe = process.getPipe();
pipe.fire(FineProcessEngineEvent.READY); pipe.fire(FineProcessEngineEvent.READY);
if (StringUtils.isNotEmpty(pipe.info())) { if (StringUtils.isNotEmpty(pipe.info())) {
@ -138,10 +166,12 @@ public class DesignerSuperListener {
public void stopTask() { public void stopTask() {
onceFuture.cancel(false); onceFuture.cancel(false);
fixedFuture.cancel(false); fixedFuture.cancel(false);
cancel = true;
} }
public void stop() { public void stop() {
stopTask(); stopTask();
service.shutdown(); service.shutdown();
helpService.shutdown();
} }
} }

Loading…
Cancel
Save