diff --git a/designer-base/src/main/java/com/fr/common/report/ReportState.java b/designer-base/src/main/java/com/fr/common/report/ReportState.java new file mode 100644 index 0000000000..cc32e439cf --- /dev/null +++ b/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; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 81211cc579..77c779ce3e 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/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.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.ErrorDialog; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.i18n.Toolkit; import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignerPort; +import com.fr.exit.DesignerExiter; import com.fr.file.FILEFactory; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogFormatter; @@ -199,6 +202,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + XmlHandler.Self.handle(e); } // james:如果没有env定义,要设置一个默认的 @@ -345,6 +349,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + XmlHandler.Self.handle(e); } finally { if (null != fileWriter) { try { @@ -2039,4 +2044,28 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void setVcsConfigManager(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(); + } + }; } diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 43c829822d..81e62239b4 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -1,5 +1,6 @@ package com.fr.design; +import com.fr.common.report.ReportState; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -24,6 +25,9 @@ import com.fr.json.JSONArray; import com.fr.license.exception.RegistEditionException; import com.fr.locale.InterProviderFactory; 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.stable.AssistUtils; import com.fr.stable.EnvChangedListener; @@ -407,6 +411,10 @@ public class EnvChangeEntrance { @Override public void doOk() { + ProcessEventPipe pipe = FineProcessContext.getParentPipe(); + if (FineProcessContext.getParentPipe() != null) { + pipe.fire(new CarryMessageEvent(ReportState.ACTIVE.getValue())); + } if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { DesignerExiter.getInstance().execute(); } @@ -414,7 +422,8 @@ public class EnvChangeEntrance { @Override public void doCancel() { - DesignerExiter.getInstance().execute(); } + DesignerExiter.getInstance().execute(); + } }); envListDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index b5f1b6b815..64fdda7baa 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -202,7 +202,11 @@ public class RestartHelper { } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - DesignerContext.getDesignerFrame().exit(); + if (DesignerContext.getDesignerFrame() != null) { + DesignerContext.getDesignerFrame().exit(); + } else { + DesignerExiter.getInstance().execute(); + } } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java b/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java index e4cf0c8e71..35f9c3c0fb 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java +++ b/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.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.BorderLayout; @@ -39,7 +40,14 @@ public abstract class TipDialog extends JDialog implements ActionListener { northPane.add(iconPane, BorderLayout.WEST); 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.setEnabled(true); area.setEditable(false); diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java index 1174a8a73b..288f6baa30 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java @@ -1,15 +1,40 @@ 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.Workspace; 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 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) { return null; @@ -22,7 +47,19 @@ public class DesignerWorkspaceGenerator { break; } case Remote: { - WorkspaceClient client = WorkContext.getConnector().connect(config.getConnection()); + Future future = service.submit(new Callable() { + @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) { workspace = new RemoteWorkspace(client, config.getConnection()); } @@ -31,4 +68,36 @@ public class DesignerWorkspaceGenerator { } 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(); + } } diff --git a/designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java new file mode 100644 index 0000000000..770e65a9ee --- /dev/null +++ b/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 classFroMobileTemplateStyle(); + + + Class> classFroMobileTemplateStyleAppearance(); + + String displayName(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java new file mode 100644 index 0000000000..54c947c57a --- /dev/null +++ b/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(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 6d9dc3b619..2cf8d8c350 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/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) { int index = HistoryTemplateListCache.getInstance().contains(tplFile); if (index != -1) { - HistoryTemplateListCache.getInstance().getHistoryList().get(index).activeOldJTemplate(); - return; + JTemplate jt = HistoryTemplateListCache.getInstance().getHistoryList().get(index); + if (!(jt instanceof JVirtualTemplate)) { + jt.activeOldJTemplate(); + return; + } } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java similarity index 94% rename from designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java rename to designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java index 9bfd729dd4..99950edae7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java @@ -21,6 +21,9 @@ import java.util.Date; */ public class ErrorInfo { + private static final String SUFFIX = ".json"; + private static final String FOLDER_NAME = "errorInfo"; + private String username; private String uuid; private String activekey; @@ -128,8 +131,8 @@ public class ErrorInfo { public void saveFileToCache(JSONObject jo) { String content = jo.toString(); - String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX; - File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName)); + String fileName = UUID.randomUUID() + SUFFIX; + File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FOLDER_NAME, fileName)); FileOutputStream out = null; try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) { StableUtils.makesureFileExist(file); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java similarity index 90% rename from designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java rename to designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java index 0b6a6b0e4c..ca3fd13ccc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java @@ -1,8 +1,8 @@ package com.fr.design.mainframe.messagecollect; -import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.errorinfo.ErrorInfo; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; /** @@ -30,6 +30,7 @@ public class StartErrorMessageCollector { } 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.setLogid(id); errorInfo.setLog(msg); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java similarity index 100% rename from designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java rename to designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java index 76434545ed..9c52673d7f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java @@ -1,11 +1,14 @@ package com.fr.design.mainframe.widget.accessibles; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.MobileTemplateStyleProvider; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.mobile.ui.TemplateStyleDefinePaneFactory; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.general.cardtag.mobile.MobileTemplateStyle; import com.fr.general.cardtag.mobile.MobileTemplateStyleType; +import com.fr.invoke.Reflect; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.JList; @@ -18,9 +21,12 @@ import java.awt.Dimension; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; public class MobileTemplateStylePane extends AbstractTemplateStylePane { private static final List STYLE_LIST = new ArrayList(); @@ -36,6 +42,7 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane> map = new HashMap<>(); private JPanel right; private CardLayout card; + private Set> extraStyle = new HashSet<>(); public MobileTemplateStylePane(WCardTagLayout tagLayout){ init(tagLayout); } @@ -52,6 +59,7 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane list = getMobileTemplateStyleProvider(); + for (MobileTemplateStyleProvider provider : list) { + String displayName = provider.displayName(); + Class> clazz = provider.classFroMobileTemplateStyleAppearance(); + BasicBeanPane 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() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -97,16 +119,31 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane getMobileTemplateStyleProvider() { + List list = new ArrayList<>(); + Set sets = ExtraDesignClassManager.getInstance().getArray(MobileTemplateStyleProvider.XML_TAG); + list.addAll(sets); + return Collections.unmodifiableList(list); + } } diff --git a/designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java b/designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java index 83768079ce..4df9b75144 100644 --- a/designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java +++ b/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.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.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.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; /** * @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()) { hidePopupMenu(); return; @@ -98,12 +105,16 @@ public abstract class AbstractPopBox extends JPanel { private void mouseClick(MouseEvent evt) { Point point = new Point((int) (evt.getLocationOnScreen().getX()), (int) evt.getLocationOnScreen().getY()); Dimension popBoxD = AbstractPopBox.this.getSize(); - Point popBoxP = AbstractPopBox.this.getLocationOnScreen(); - Dimension popMenuD = this.getControlWindow().getSize(); - Point popMenuP = this.getControlWindow().getLocation(); - Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD); - Rectangle popMenuRect = new Rectangle(popMenuP, popMenuD); - if (!popBoxRect.contains(point) && !popMenuRect.contains(point)) { + try { + Point popBoxP = AbstractPopBox.this.getLocationOnScreen(); + Dimension popMenuD = this.getControlWindow().getSize(); + Point popMenuP = this.getControlWindow().getLocation(); + Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD); + Rectangle popMenuRect = new Rectangle(popMenuP, popMenuD); + if (!popBoxRect.contains(point) && !popMenuRect.contains(point)) { + this.hidePopupMenu(); + } + } catch (Exception ignore){ this.hidePopupMenu(); } } diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java index 33df00bc59..8c502114bf 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java @@ -1,6 +1,6 @@ package com.fr.design.style.background.gradient; -import com.fr.design.style.background.gradient.GradientBar; +import java.awt.Color; /** * 这个bar不能拖拽滑动 @@ -8,6 +8,8 @@ import com.fr.design.style.background.gradient.GradientBar; public class FixedGradientBar extends GradientBar { private static final long serialVersionUID = 2787525421995954889L; + public static final Color NEW_CHARACTER = new Color(99, 178, 238); + public FixedGradientBar(int minvalue, int maxvalue) { super(minvalue, maxvalue); } diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index b197a3d396..dcb381e819 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -1,40 +1,38 @@ 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.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.mainframe.DesignerContext; 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.ColorSelectDialog; import com.fr.design.style.color.ColorSelectable; 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。要缩放的情况也比较少,就干脆以后弄吧 */ -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 ChangeListener changeListener = null; - private UIObserverListener uiObserverListener; - + private List uiObserverListener; + private static final int MOUSE_OFFSET = 4; - + private static final int MAX_VERTICAL = 45; - + // 选中的颜色 private Color color; @@ -89,6 +87,11 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl iniListener(); } + public void updateColor(Color begin, Color end) { + p1.setColorInner(begin); + p2.setColorInner(end); + } + protected void addMouseClickListener() { this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { @@ -142,14 +145,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } private void iniListener() { + uiObserverListener = new ArrayList<>(); if (shouldResponseChangeListener()) { this.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - if (uiObserverListener == null) { - return; + for (UIObserverListener observerListener : uiObserverListener) { + observerListener.doChange(); } - uiObserverListener.doChange(); } }); } @@ -199,14 +202,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl * 状态改变 */ public void stateChanged() { - if (changeListener != null) { + if (changeListener != null) { changeListener.stateChanged(null); } } /** * 增加监听 - * + * * @param changeListener 监听 */ public void addChangeListener(ChangeListener changeListener) { @@ -215,14 +218,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl /** * 如果左右两个按钮还在初始位置,就为true - * @return 同上 + * + * @return 同上 */ public boolean isOriginalPlace() { return AssistUtils.equals(startLabel.getValue(), min) && AssistUtils.equals(endLabel.getValue(), max); } /** - * * @return */ public double getStartValue() { @@ -230,7 +233,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } /** - * * @return */ public double getEndValue() { @@ -238,7 +240,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } /** - * * @param startValue */ public void setStartValue(double startValue) { @@ -246,7 +247,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } /** - * * @param endValue */ public void setEndValue(double endValue) { @@ -254,7 +254,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } /** - * * @return */ public SelectColorPointBtn getSelectColorPointBtnP1() { @@ -262,7 +261,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } /** - * * @return */ public SelectColorPointBtn getSelectColorPointBtnP2() { @@ -276,7 +274,7 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl * */ public void registerChangeListener(UIObserverListener listener) { - uiObserverListener = listener; + uiObserverListener.add(listener); } @Override @@ -288,22 +286,23 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl return true; } - @Override - public void setColor(Color color) { - this.color = color; - } - - @Override - public Color getColor() { - return this.color; - } - - /** - * 选中颜色 - * @param ColorCell 颜色单元格 - */ - @Override - public void colorSetted(ColorCell colorCell) { - - } + @Override + public void setColor(Color color) { + this.color = color; + } + + @Override + public Color getColor() { + return this.color; + } + + /** + * 选中颜色 + * + * @param ColorCell 颜色单元格 + */ + @Override + public void colorSetted(ColorCell colorCell) { + + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java index b717ea67e7..33eb6dbf15 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java +++ b/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 javax.swing.JPanel; +import java.io.Serializable; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dialog; @@ -13,7 +14,6 @@ import java.awt.FlowLayout; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.Serializable; /** @@ -136,8 +136,13 @@ public class ColorSelectDialog extends MiddleChartDialog{ * void */ 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); ColorSelectDialog dialog = new ColorSelectDialog(owner,pane,initialColor,okListener,selectePane); + dialog.setAlwaysOnTop(alwaysOnTop); dialog.setModal(true); dialog.show(); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java index bb902fa930..c82eac0c0d 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java +++ b/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.utils.gui.GUICoreUtils; - -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; 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.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.ArrayList; /** * The pane used to select color @@ -196,6 +201,6 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable @Override public void customButtonPressed() { pane = new ColorSelectDetailPane(Color.WHITE); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this, true); } } diff --git a/designer-base/src/main/java/com/fr/exit/DesignerExiter.java b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java index 06260894e5..b9067a22ee 100644 --- a/designer-base/src/main/java/com/fr/exit/DesignerExiter.java +++ b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java @@ -1,5 +1,6 @@ package com.fr.exit; +import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.StableUtils; @@ -19,9 +20,14 @@ public class DesignerExiter { } public void execute() { + beforeExit(); if (FineProcessContext.getParentPipe() != null) { - FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); + FineProcessContext.getParentPipe().syncFire(FineProcessEngineEvent.DESTROY); } System.exit(0); } + + private void beforeExit() { + DesignerWorkspaceGenerator.stop(); + } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java b/designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java new file mode 100644 index 0000000000..dd908505db --- /dev/null +++ b/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 { + + 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)); + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java new file mode 100644 index 0000000000..ae076b8f37 --- /dev/null +++ b/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 colorSchemes; + + public ColorSchemeComboBox() { + this(null); + } + + public ColorSchemeComboBox(Map colorSchemes) { + //通过配色方案的集合初始化下拉控件,如果参数为null,从配置中读取配色方案。 + if (colorSchemes == null) { + colorSchemes = getColorSchemesFromConfig(); + } + this.colorSchemes = colorSchemes; + + this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray())); + + this.setRenderer(new ColorSchemeCellRenderer()); + } + + private Map getColorSchemesFromConfig() { + Map 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 colors; + + private boolean gradient; + + public List getColors() { + return colors; + } + + public void setColors(List 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 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 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); + } + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java new file mode 100644 index 0000000000..52bde97a6d --- /dev/null +++ b/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 colorButtons = new ArrayList<>(); + + private List 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 { + + 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) { + + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java index 66a103e657..de85cfcdba 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java +++ b/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.TableLayout; 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 javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -20,8 +21,6 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; /** @@ -37,7 +36,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { private UIButton accButton; private UIButton gradientButton; - private ChartAccColorPane colorAcc; + private ChartColorAdjustPane colorAdjustPane; private FixedGradientBar colorGradient; public ChartPreFillStylePane() { @@ -53,13 +52,13 @@ public class ChartPreFillStylePane extends BasicBeanPane { JPanel buttonPane = new JPanel(); 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"))); customPane.add(buttonPane, BorderLayout.NORTH); changeColorSetPane = new JPanel(cardLayout = new CardLayout()); changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); - changeColorSetPane.add(colorAcc = new ChartAccColorPane(), "acc"); + changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc"); cardLayout.show(changeColorSetPane, "acc"); customPane.add(changeColorSetPane, BorderLayout.CENTER); @@ -68,7 +67,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { customPane.setPreferredSize(new Dimension(200, 200)); colorGradient.setPreferredSize(new Dimension(120, 30)); colorGradient.getSelectColorPointBtnP1().setColorInner(Color.WHITE); - colorGradient.getSelectColorPointBtnP2().setColorInner(Color.black); + colorGradient.getSelectColorPointBtnP2().setColorInner(FixedGradientBar.NEW_CHARACTER); double p = TableLayout.PREFERRED; double[] columnSize = {p, p}; @@ -131,7 +130,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { cardLayout.show(changeColorSetPane, "acc"); 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 { } else { chartColorMatching.setGradient(false); - Color[] colors = colorAcc.updateBean(); + Color[] colors = colorAdjustPane.getColors(); for(Color color : colors) { colorList.add(color); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java index 45beccc7ef..d3b511b1f2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java +++ b/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.mainframe.chart.gui.ChartStylePane; import com.fr.van.chart.column.VanChartCustomStackAndAxisConditionPane; +import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.line.VanChartLineSeriesPane; import javax.swing.JPanel; @@ -27,7 +28,6 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { double[] col = {f}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createLineTypePane()}, new Component[]{createMarkerPane()}, new Component[]{createAreaFillColorPane()}, @@ -44,4 +44,9 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { protected Class getStackAndAxisPaneClass() { return VanChartCustomStackAndAxisConditionPane.class; } + + //风格 + protected VanChartBeautyPane createStylePane() { + return new VanChartBeautyPane(); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java index 44077c0ba7..0bb6ede075 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java @@ -37,14 +37,13 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { double[] col = {f}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createBubblePane()}, new Component[]{createStackedAndAxisPane()}, new Component[]{null} }; if (!((VanChartBubblePlot) plot).isForceBubble()) { - components[3] = new Component[]{createLargeDataModelPane()}; + components[2] = new Component[]{createLargeDataModelPane()}; } contentPane = TableLayoutHelper.createTableLayoutPane(components, row, col); diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java index 12c42408f1..fd870048cb 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java +++ b/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[] rowSize = {p,p,p,p,p,p,p,p,p,p}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createSeriesStylePane(new double[]{p,p}, new double[]{f,e})}, new Component[]{createBorderPane()}, new Component[]{createStackedAndAxisPane()}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java index 425258a5bf..2cd3d74e1f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java +++ b/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.TableLayoutHelper; 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.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot; @@ -24,7 +23,7 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane { private JPanel seriesPane; protected VanChartCustomPlotSeriesTabPane plotSeriesPane; - private ChartFillStylePane fillStylePane;//配色 + private VanChartFillStylePane fillStylePane;//配色 private VanChartBeautyPane stylePane;//风格 @@ -81,7 +80,7 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane { }; 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; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java index f6642bd710..db41e8a480 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java @@ -29,7 +29,7 @@ public class VanChartBeautyPane extends BasicBeanPane { double[] columnSize = {f, e}; double[] rowSize = {p}; 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); this.setLayout(new BorderLayout()); @@ -37,17 +37,17 @@ public class VanChartBeautyPane extends BasicBeanPane { } protected String[] getNameArray(){ - return new String[]{Toolkit.i18nText("Fine-Design_Chart_Default_Name"), - Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade") + return new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), + Toolkit.i18nText("Fine-Design_Chart_Off") }; } @Override public void populateBean(Integer ob) { int finalIndex; switch (ob){ - case ChartConstants.STYLE_NONE: finalIndex = 0; break; - case ChartConstants.STYLE_SHADE: finalIndex = 1; break; - default: finalIndex = 0; + case ChartConstants.STYLE_NONE: finalIndex = 1; break; + case ChartConstants.STYLE_SHADE: finalIndex = 0; break; + default: finalIndex = 1; } styleBox.setSelectedIndex(finalIndex); } @@ -57,8 +57,8 @@ public class VanChartBeautyPane extends BasicBeanPane { int index = styleBox.getSelectedIndex(); int style; switch (index){ - case 0: style = ChartConstants.STYLE_NONE; break; - case 1: style = ChartConstants.STYLE_SHADE; break; + case 0: style = ChartConstants.STYLE_SHADE; break; + case 1: style = ChartConstants.STYLE_NONE; break; default: style = ChartConstants.STYLE_NONE; } return style; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java index e395f26e94..154ed5557e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java @@ -1,42 +1,236 @@ 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.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; 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 javax.swing.BorderFactory; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Created by mengao on 2017/8/17. */ -public class VanChartFillStylePane extends ChartFillStylePane { +public class VanChartFillStylePane extends BasicBeanPane { + + + 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 - protected JPanel getContentPane () { + public Dimension getPreferredSize() { + if (gradientSelect) { + return new Dimension(225, 80); + } + return super.getPreferredSize(); + } + + protected JPanel getContentPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; double[] rowSize = {p, p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color_Match")),styleSelectBox}, - new Component[]{null,customPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), styleSelectBox}, + new Component[]{null, customPane}, }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); - panel.setBorder(BorderFactory.createEmptyBorder(5,5,0,0)); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); return panel; } + @Override - public Dimension getPreferredSize() { - if(styleSelectBox.getSelectedIndex() != styleSelectBox.getItemCount() - 1) { - return new Dimension(styleSelectBox.getPreferredSize().width, 30); + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color"); + } + + @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(); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java index 9b912ee9f7..2bcdda7895 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java +++ b/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.design.gui.frpane.UINumberDragPane; 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.style.ChartFillStylePane; import com.fr.design.mainframe.chart.gui.style.series.AbstractPlotSeriesPane; import com.fr.plugin.chart.VanChartAttrHelper; 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.VanChartAttrTrendLine; 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.component.VanChartAreaSeriesFillColorPane; import com.fr.van.chart.designer.component.VanChartBeautyPane; @@ -62,6 +61,8 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP private VanChartBorderPane borderPane;//边框 + protected VanChartFillStylePane vanChartFillStylePane;//配色 + private UINumberDragPane transparent;//不透明度 protected VanChartStackedAndAxisListControlPane stackAndAxisEditPane;//堆積和坐標軸 @@ -86,18 +87,18 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); } JPanel panel = new JPanel(new BorderLayout()); - if (fillStylePane != null) { - panel.add(fillStylePane, BorderLayout.NORTH); + JPanel colorPane = getColorPane(); + if(colorPane != null) { + panel.add(colorPane, BorderLayout.NORTH); } panel.add(getContentInPlotType(), BorderLayout.CENTER); return panel; } - @Override /** * 返回 填充界面. */ - protected ChartFillStylePane getFillStylePane() { + protected VanChartFillStylePane getVanChartFillStylePane() { //如果是自定義組合圖,則不創建填充界面 return parentPane instanceof VanChartCustomStylePane ? null : new VanChartFillStylePane(); } @@ -111,9 +112,13 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP protected JPanel getColorPane() { JPanel panel = new JPanel(new BorderLayout()); stylePane = createStylePane(); + vanChartFillStylePane = getVanChartFillStylePane(); + if (vanChartFillStylePane != null) { + panel.add(vanChartFillStylePane, BorderLayout.NORTH); + } setColorPaneContent(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; } @@ -266,7 +271,9 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkoutMapType(plot); - super.populateBean(plot);//配色 + if(vanChartFillStylePane != null) { //配色 + vanChartFillStylePane.populateBean(plot.getPlotFillStyle()); + } if (stylePane != null) {//风格 stylePane.populateBean(plot.getPlotStyle()); @@ -323,7 +330,9 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //更新之前先更新界面的map类型属性 checkoutMapType(plot); - super.updateBean(plot);//配色 + if(vanChartFillStylePane != null) {//配色 + plot.setPlotFillStyle(vanChartFillStylePane.updateBean()); + } if (stylePane != null) {//风格 plot.setPlotStyle(stylePane.updateBean()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java index 8a02cd5f44..9df55249ad 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java +++ b/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[] rowSize = {p,p,p,p,p,p,p,p,p,p}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createFunnelStylePane()}, new Component[]{createBorderPane()}, }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java index 8b96c36940..c17d97692c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java +++ b/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.stable.CoreConstants; 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.marker.VanChartCommonMarkerPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; @@ -121,4 +122,9 @@ public class VanChartGanttSeriesPane extends VanChartAbstractPlotSeriesPane { } } + + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java index c4ce90edc7..858fb0ae72 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java +++ b/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.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.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.style.color.ColorSelectBox; import com.fr.general.ComparatorUtils; -import com.fr.design.i18n.Toolkit; - import com.fr.plugin.chart.attr.GaugeDetailStyle; import com.fr.plugin.chart.base.AttrLabel; 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.stable.Constants; 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 javax.swing.JPanel; @@ -306,4 +306,9 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { colorPickerPane.updateBean(detailStyle.getHotAreaColor()); } } + + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java index f4c7bd4769..7c4fa4ad4a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java +++ b/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.TableLayoutHelper; 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.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.VanChartFillStylePane; import com.fr.van.chart.map.VanChartMapSeriesPane; import javax.swing.JPanel; @@ -41,7 +40,7 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { /** * 返回 填充界面. */ - protected ChartFillStylePane getFillStylePane() { + protected VanChartFillStylePane getVanChartFillStylePane() { return null; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java index aea7ace9e5..8300cac6ba 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java +++ b/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.TableLayoutHelper; 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 javax.swing.JPanel; @@ -38,4 +39,9 @@ public class VanChartLineSeriesPane extends VanChartAbstractPlotSeriesPane { return contentPane; } + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } + } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index fd00a87c87..b24e8fc33d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/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.ibutton.UIButtonGroup; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; 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.VanChartLineMapEffectPane; +import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; 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, 得到不同类型的属性. 比如: 柱形的风格, 折线的线型曲线. */ @@ -176,10 +207,17 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { } //设置色彩面板内容 - protected void setColorPaneContent(JPanel panel) { - panel.add(createNullValueColorPane(), BorderLayout.CENTER); - panel.add(createAlphaPane(), BorderLayout.SOUTH); - + protected void setColorPaneContent(JPanel panel, MapType paneType) { + switch (paneType) { + 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}; 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)}, }; @@ -213,7 +251,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { double[] col = {f}; 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()}, //大数据模式 恢复用注释。下面1行删除。 new Component[]{createLargeDataModelPane()}, @@ -232,6 +270,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { curvePane = new VanChartCurvePane(); Component[][] components = new Component[][]{ + new Component[]{getColorPane(MapType.LINE)}, new Component[]{createCurvePane()}, //大数据模式 恢复用注释。下面1行删除。 new Component[]{createLineMapLargeDataModelPane()}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java index df967518b7..4fa61802de 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java +++ b/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.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; - import com.fr.plugin.chart.multilayer.VanChartMultiPiePlot; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.pie.VanChartPieSeriesPane; import javax.swing.JPanel; @@ -90,4 +90,9 @@ public class VanChartMultiPieSeriesPane extends VanChartPieSeriesPane { multiPiePlot.setSupportRotation(supportRotation.getSelectedIndex() == 0); } } + + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java index 2169c4a20c..a6a1a5e28a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java +++ b/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[] rowSize = {p,p,p,p,p,p}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createSeriesStylePane(rowSize, new double[]{f, e})}, new Component[]{createBorderPane()}, }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java index 6838969229..5500cf9a32 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java @@ -43,7 +43,6 @@ public class VanChartRadarSeriesPane extends VanChartAbstractPlotSeriesPane { private Component[][] getPaneComponents() { if(plot instanceof VanChartRadarPlot && ((VanChartRadarPlot)plot).isStackChart()) { return new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createRadarTypePane()}, new Component[]{createBorderPane()}, }; @@ -59,7 +58,9 @@ public class VanChartRadarSeriesPane extends VanChartAbstractPlotSeriesPane { //设置色彩面板内容 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() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java index a85725a8e7..c6d7f8af6c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java @@ -35,7 +35,6 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane { double[] col = {f}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createLineTypePane()}, new Component[]{createMarkerPane()}, new Component[]{createStackedAndAxisPane()}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java index b9e5427112..ee2cda46a6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java +++ b/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.mainframe.chart.gui.ChartStylePane; import com.fr.design.style.color.ColorSelectBox; - import com.fr.plugin.chart.base.AttrNode; import com.fr.plugin.chart.structure.VanChartStructurePlot; 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 javax.swing.JPanel; @@ -142,4 +142,9 @@ public class VanChartStructureSeriesPane extends VanChartAbstractPlotSeriesPane } } } + + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java index d5ab61b950..884e96b330 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java +++ b/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.general.FRFont; import com.fr.general.IOUtils; - import com.fr.plugin.chart.wordcloud.CloudShapeType; import com.fr.plugin.chart.wordcloud.VanChartWordCloudPlot; 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 javax.swing.JPanel; @@ -228,4 +228,9 @@ public class VanChartWordCloudSeriesPane extends VanChartAbstractPlotSeriesPane } } } + + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 756a89f564..f61eb2f8a4 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -93,7 +93,7 @@ public class FormCreatorDropTarget extends DropTarget { //SetSelection时要确保选中的是最顶层的布局 //tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout 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); if (addingXCreator.isShared()) { diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java index e97a92b4d1..f3cea39410 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java +++ b/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); this.biasTextPainterPane = new BiasTextPainterPane(); 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); return this.biasTextPainterPane.showWindowWithCustomSize(parentWindow, new DialogActionAdapter() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java b/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java index eec7773282..85266b7cd8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java +++ b/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.report.cellcase.CellCase; import com.fr.report.poly.PolyWorkSheet; +import com.fr.report.report.Report; import com.fr.report.worksheet.WorkSheet; import java.util.Iterator; @@ -61,8 +62,12 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo { int blockCount = 0; if (!template.isElementCaseBook()) { // 如果是聚合报表 for (int i = 0; i < template.getReportCount(); i++) { - PolyWorkSheet r = (PolyWorkSheet) template.getReport(i); - blockCount += r.getBlockCount(); + Report report = template.getReport(i); + // 考虑多个sheet下 包含WorkSheet的情况 需要判断下 + if (report instanceof PolyWorkSheet) { + PolyWorkSheet r = (PolyWorkSheet) report; + blockCount += r.getBlockCount(); + } } } return blockCount; diff --git a/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java b/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java index 6b0c45eab1..5f4f62210e 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java +++ b/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.os.OperatingSystem; -import javax.imageio.ImageIO; import java.io.File; 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 LOGO_PATH = StableUtils.pathJoin(BIN_HOME, "logo.png"); 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"}; static { - if (SupportOSImpl.DOCK_ICON.support()) { - try { - ImageIO.write(IOUtils.readImage("com/fr/design/icon/logo.png"), "png", new File(LOGO_PATH)); - } catch (IOException ignore) { - } + try { + IOUtils.copy(DesignerJavaRuntime.class.getResourceAsStream("/com/fr/design/icon/logo.png"), "logo.png", new File(BIN_HOME)); + } catch (IOException ignore) { } } @@ -99,7 +97,7 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime { if (isInstallVersion()) { String[] options = super.getJvmOptions(); if (SupportOSImpl.DOCK_ICON.support()) { - options = ArrayUtils.add(options, DOCK_OPTIONS); + options = ArrayUtils.addAll(options, DOCK_OPTIONS, DOCK_NAME_OPTIONS); } return options; } else { diff --git a/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java b/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java index db8e532dcf..f6fa3c9376 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java @@ -1,5 +1,6 @@ package com.fr.start; +import com.fr.common.report.ReportState; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.dialog.ErrorDialog; 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.Listener; import com.fr.event.Null; +import com.fr.general.ComparatorUtils; import com.fr.process.FineProcess; import com.fr.process.ProcessEventPipe; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.StringUtils; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -33,10 +36,12 @@ public class DesignerSuperListener { private static final int FIXED_FREQ = 2; private final ScheduledExecutorService service = Executors.newScheduledThreadPool(2, new NamedThreadFactory("DesignerListener")); + private final ExecutorService helpService = Executors.newSingleThreadExecutor( new NamedThreadFactory("DesignerSuperListener-Help")); private FineProcess process; private ScheduledFuture fixedFuture; private ScheduledFuture onceFuture; + private volatile boolean cancel = false; private DesignerSuperListener() { @@ -49,6 +54,7 @@ public class DesignerSuperListener { public void start() { process = FineProcessContext.getProcess(DesignerProcessType.INSTANCE); startExitListener(); + startHelpLister(); startFrameListener(); 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() { onceFuture = service.schedule(new Runnable() { @Override public void run() { + cancel = true; ProcessEventPipe pipe = process.getPipe(); pipe.fire(FineProcessEngineEvent.READY); if (StringUtils.isNotEmpty(pipe.info())) { @@ -138,10 +166,12 @@ public class DesignerSuperListener { public void stopTask() { onceFuture.cancel(false); fixedFuture.cancel(false); + cancel = true; } public void stop() { stopTask(); service.shutdown(); + helpService.shutdown(); } }