From 9f6f5e32faece952652d422af20d925a556ed26d Mon Sep 17 00:00:00 2001 From: Yyming Date: Fri, 17 Jul 2020 10:02:42 +0800 Subject: [PATCH 01/16] =?UTF-8?q?REPORT-32116=20=E7=94=B1=E4=BA=8Efr=5Fema?= =?UTF-8?q?il=E7=9A=84http=E8=AF=B7=E6=B1=82=E9=87=8C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=88=B7=E6=96=B0sessionMap=E7=BC=93=E5=AD=98,=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=9A=84=E5=AF=B9=E8=B1=A1=E6=98=AF=E4=B8=8A?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E9=80=89=E6=8B=A9=E7=9A=84=E5=8F=91=E9=80=81?= =?UTF-8?q?=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-realize/src/main/java/com/fr/start/MainDesigner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index 2cdc83230..0020514f2 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -144,7 +144,7 @@ public class MainDesigner extends BaseDesigner { } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - return shortCuts.toArray(new ShortCut[shortCuts.size()]); + return shortCuts.toArray(new ShortCut[0]); } @Override From aa8b671b35b0b44be56b9438cb9e8380b6c5eaa5 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 11 Aug 2020 13:51:45 +0800 Subject: [PATCH 02/16] =?UTF-8?q?REPORT-37235=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E8=A7=84=E8=8C=83-=E6=9B=B4=E6=96=B0=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=8F=90=E7=A4=BA=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E4=B8=8D=E7=AC=A6=E5=90=88=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/update/push/DesignerUpdateInfo.java | 8 +++++++- .../resources/com/fr/design/ui/update/push/pushUpdate.css | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java index a136f279b..3f7c23cd3 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java @@ -24,6 +24,7 @@ class DesignerUpdateInfo { private final String currentVersion; // 当前版本 private final String latestVersion; // 最新版本 + private final String latestFullVersion; // 最新版本的完整信息 private final String lastIgnoredVersion; // 最近一次跳过的版本 private final String pushVersion; // 推送版本 @@ -34,6 +35,7 @@ class DesignerUpdateInfo { DesignerUpdateInfo(String currentVersion, String latestVersion, String lastIgnoredVersion, JSONObject pushData) { this.currentVersion = currentVersion; this.latestVersion = latestVersion; + this.latestFullVersion = initLatestFullVersion(); this.lastIgnoredVersion = lastIgnoredVersion; this.pushVersion = pushData.optString(KEY_VERSION); @@ -65,7 +67,7 @@ class DesignerUpdateInfo { return latestVersion; } - String getLatestFullVersion() { + String initLatestFullVersion() { try { String url = CloudCenter.getInstance().acquireUrlByKind("jar10.new.update"); if (StringUtils.isBlank(url)) { @@ -85,6 +87,10 @@ class DesignerUpdateInfo { return StringUtils.EMPTY; } + String getLatestFullVersion() { + return latestFullVersion; + } + String getLastIgnoredVersion() { return lastIgnoredVersion; } diff --git a/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css b/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css index 58c03ecba..f8a9eb713 100644 --- a/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css +++ b/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css @@ -1,6 +1,6 @@ body { padding-left: 30px; - padding-top: 30px; + padding-top: 25px; color: white; background-size: 100% 100% !important; -moz-background-size: 100% 100% !important; From f6840df7613b1a46c7d4e914396396aace75b68f Mon Sep 17 00:00:00 2001 From: Yyming Date: Tue, 11 Aug 2020 14:53:15 +0800 Subject: [PATCH 03/16] =?UTF-8?q?REPORT-37100=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86-=E5=88=B7=E6=96=B0=E5=8F=82=E6=95=B0=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=90=8E=EF=BC=8C=E5=A4=8D=E5=88=B6=E7=9A=84=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=95=B0=E6=8D=AE=E9=9B=86=E7=9A=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=9A=E5=BD=B1=E5=93=8D=E5=8E=9F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tabledatapane/MultiTDTableDataPane.java | 107 ++++++++---------- .../itableeditorpane/UITableModelAdapter.java | 7 +- 2 files changed, 52 insertions(+), 62 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java index 2cf170c55..d9377da6b 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java @@ -19,6 +19,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itextfield.UITextField; import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; import com.fr.script.Calculator; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; @@ -95,9 +96,8 @@ public class MultiTDTableDataPane extends AbstractTableDataPane> entryIt = resMap.entrySet().iterator(); - while (entryIt.hasNext()) { - TableDataWrapper tableDataWrappe = entryIt.next().getValue(); + for (Entry stringTableDataWrapperEntry : resMap.entrySet()) { + TableDataWrapper tableDataWrappe = stringTableDataWrapperEntry.getValue(); String tmp = tableDataWrappe.getTableDataName(); if (!ComparatorUtils.equals(tableDataWrappe.getTableDataName(), multiName)) { centerPanel.add(new BarPanel(tmp, tableDataWrappe.getIcon())); @@ -111,13 +111,10 @@ public class MultiTDTableDataPane extends AbstractTableDataPane { + MultiTDTableData td = MultiTDTableDataPane.this.updateBean(); + td.setTableDataSource(DesignTableDataManager.getEditingTableDataSource()); + new TemplateTableDataWrapper(td).previewData(); }; } @@ -126,12 +123,12 @@ public class MultiTDTableDataPane extends AbstractTableDataPane(new ParameterTableModel() { + editorPane = new UITableEditorPane<>(new ParameterTableModel() { @Override public UITableEditAction[] createAction() { return new UITableEditAction[]{new RefreshAction()}; } - }, " " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Default_Parameter")); + }, StringUtils.BLANK + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Default_Parameter")); jpanel.add(editorPane, BorderLayout.CENTER); @@ -162,29 +159,31 @@ public class MultiTDTableDataPane extends AbstractTableDataPane existParameterList = new ArrayList(); - Iterator> dataItera = choosenTableData.entrySet().iterator(); - List parameterName = new ArrayList(); - while (dataItera.hasNext()) { - Entry entry = dataItera.next(); - TableData td = resMap.get(entry.getKey()).getTableData(); - ParameterProvider[] currentparameters = td.getParameters(Calculator.createCalculator()); - for (int i=0; i existParameterList = new ArrayList<>(); + List parameterName = new ArrayList<>(); + for (Entry entry : choosenTableData.entrySet()) { + TableData td = resMap.get(entry.getKey()).getTableData(); + ParameterProvider[] currentParameters = td.getParameters(Calculator.createCalculator()); + for (ParameterProvider currentParameter : currentParameters) { + if (parameterName.contains(currentParameter.getName())) { + continue; + } + parameterName.add(currentParameter.getName()); + try { + existParameterList.add((ParameterProvider) currentParameter.clone()); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } } ParameterProvider[] texts = ParameterHelper.analyze4Parameters(paramTexts, true); - for (int i=0; i> it = choosenTableData.entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); + for (Entry entry : choosenTableData.entrySet()) { td.addTableData(entry.getKey(), entry.getValue()); } List paramList = editorPane.update(); if (paramList != null) { - td.setDefineParameters(paramList.toArray(new Parameter[paramList.size()])); + td.setDefineParameters(paramList.toArray(new Parameter[0])); } return td; @@ -348,9 +345,7 @@ public class MultiTDTableDataPane extends AbstractTableDataPane { + final UIFormula formulaPane = FormulaFactory.createFormulaPane(); + formulaPane.populate(BaseFormula.createFormulaBuilder().build(formulaContentTextField.getText())); + formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(MultiTDTableDataPane.this), new DialogActionAdapter() { + public void doOk() { + BaseFormula formula = formulaPane.update(); + if (formula == null) { + formulaContentTextField.setText(StringUtils.EMPTY); + } else { + formulaContentTextField.setText(formula.getContent().substring(1)); } - }).setVisible(true); - } + MultiTDTableDataPane.this.refresh(); + } + }).setVisible(true); }; } } diff --git a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java index 7d0411307..4506bb9a6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java @@ -23,7 +23,7 @@ import java.util.List; * @editor zhou * @since 2012-3-28下午3:07:44 */ -public abstract class UITableModelAdapter extends AbstractTableModel implements UITableEditorLoader { +public abstract class UITableModelAdapter extends AbstractTableModel implements UITableEditorLoader { /** * @@ -37,7 +37,6 @@ public abstract class UITableModelAdapter extends AbstractTabl // list里放的是一行数据 private List list = new ArrayList(); - @SuppressWarnings({ "unchecked", "rawtypes" }) protected UITableModelAdapter(String[] columnNames) { this.columnNames = columnNames; table = new JTable(this); @@ -101,8 +100,8 @@ public abstract class UITableModelAdapter extends AbstractTabl } } - public void setRowAt(T value, int rowIndwx) { - this.list.set(rowIndwx, value); + public void setRowAt(T value, int rowIndex) { + this.list.set(rowIndex, value); } /** From bcb58283ffcdce649bd3d570f8bf3635e958253b Mon Sep 17 00:00:00 2001 From: Yyming Date: Tue, 11 Aug 2020 15:04:45 +0800 Subject: [PATCH 04/16] =?UTF-8?q?REPORT-37100=20=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/tabledata/tabledatapane/MultiTDTableDataPane.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java index d9377da6b..571e13d44 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java @@ -170,6 +170,7 @@ public class MultiTDTableDataPane extends AbstractTableDataPane Date: Tue, 11 Aug 2020 15:21:49 +0800 Subject: [PATCH 05/16] =?UTF-8?q?CHART-15033=20linux=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=A0=87=E9=A2=98=E5=9B=BE=E4=BE=8B=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E8=AE=BE=E7=BD=AE=E6=A1=86=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/frpane/UIBubbleFloatPane.java | 554 +++++++++--------- .../style/VanChartPlotLegendPane.java | 89 +-- .../designer/style/VanChartTitlePane.java | 75 +-- 3 files changed, 368 insertions(+), 350 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java index 0297353ee..03927ca46 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java @@ -9,14 +9,17 @@ import com.fr.stable.Constants; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingUtilities; +import javax.swing.border.Border; import java.awt.AWTEvent; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dialog; import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Insets; import java.awt.Point; import java.awt.Polygon; import java.awt.Rectangle; @@ -29,303 +32,312 @@ import java.awt.event.MouseEvent; /** * @author Jerry - * 非模态悬浮对话框,气泡形状 + * 非模态悬浮对话框,气泡形状 */ public abstract class UIBubbleFloatPane extends BasicBeanPane { - private static final long serialVersionUID = -6386018511442190959L; - private static int OFF_LEFT = 10; + private static final long serialVersionUID = -6386018511442190959L; + private static int OFF_LEFT = 10; private static final int ARROR_PARALLEL = 30; private static final int ARROR_VERTICAL = 20; private static final int TITLE_HEIGHT = 60; private static final double TIME_DEFAULT = 0.5; private static final double TIME_GAP = 0.1; - private BasicBeanPane contentPane; - private Rectangle bounds; - private int arrowPosition; - private double time = 0.5; - - private UIDialog showDialog; - - /** - * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO - * @param arrowPoint 箭头的坐标点 - * @param contentPane 对话框中的Panel - */ - public UIBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane) { - this(arrowPosition, arrowPoint, contentPane, contentPane.getPreferredSize().width, contentPane.getPreferredSize().height); - } - - /** - * 这个方法主要用于那些宽度和高度有变化的面板,因为显然外面的气泡要固定大小,不然忽大忽小,体验太差了 - * - * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO - * @param arrowPoint 箭头的坐标点 - * @param contentPane 对话框中的Panel - * @param width 对话框中的Panel的宽度,写死了 - * @param height 对话框中的Panel的高度,写死了 - */ - public UIBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane, int width, int height) { - this.contentPane = contentPane; - this.arrowPosition = arrowPosition; - this.time = initBoundsTime(arrowPosition, arrowPoint, width, height); - if (arrowPosition == Constants.LEFT) { - this.bounds = new Rectangle(arrowPoint.x - width, (int) (arrowPoint.y - height * time), width, height); - } else if (arrowPosition == Constants.TOP) { - this.bounds = new Rectangle((int) (arrowPoint.x - width * time), arrowPoint.y , width, height); - } else if (arrowPosition == Constants.RIGHT) { - this.bounds = new Rectangle(arrowPoint.x - OFF_LEFT * 2 - width, (int) (arrowPoint.y - height * time), width, height); - } - - initComponents(); - } + private BasicBeanPane contentPane; + private Rectangle bounds; + private int arrowPosition; + private double time = 0.5; + + private UIDialog showDialog; + + /** + * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO + * @param arrowPoint 箭头的坐标点 + * @param contentPane 对话框中的Panel + */ + public UIBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane) { + this(arrowPosition, arrowPoint, contentPane, contentPane.getPreferredSize().width, contentPane.getPreferredSize().height); + } + + /** + * 这个方法主要用于那些宽度和高度有变化的面板,因为显然外面的气泡要固定大小,不然忽大忽小,体验太差了 + * + * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO + * @param arrowPoint 箭头的坐标点 + * @param contentPane 对话框中的Panel + * @param width 对话框中的Panel的宽度,写死了 + * @param height 对话框中的Panel的高度,写死了 + */ + public UIBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane, int width, int height) { + this.contentPane = contentPane; + this.arrowPosition = arrowPosition; + this.time = initBoundsTime(arrowPosition, arrowPoint, width, height); + if (arrowPosition == Constants.LEFT) { + this.bounds = new Rectangle(arrowPoint.x - width, (int) (arrowPoint.y - height * time), width, height); + } else if (arrowPosition == Constants.TOP) { + this.bounds = new Rectangle((int) (arrowPoint.x - width * time), arrowPoint.y, width, height); + } else if (arrowPosition == Constants.RIGHT) { + this.bounds = new Rectangle(arrowPoint.x - OFF_LEFT * 2 - width, (int) (arrowPoint.y - height * time), width, height); + } + + initComponents(); + } /** * show对话框 + * * @param fatherPane 上一层界面 parentPane - * @param ob 传入的内容,在show之前populate + * @param ob 传入的内容,在show之前populate */ - public void show(JComponent fatherPane, T ob) { - populateBean(ob); - UIDialog dialog = showUnsizedWindow(SwingUtilities.getWindowAncestor(fatherPane)); - showDialog = dialog; - Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); - dialog.setVisible(true); - } - - /** - * 数据展现 - */ - public void populateBean(T ob) { - contentPane.populateBean(ob); - } - - /** - * 停止编辑, 更新至最新的面板到属性保存 - */ - public T updateBean() { - updateContentPane(); - return contentPane.updateBean(); - } - - /** - * 需要实现更新内容,将updateBean传值给对象即可,在窗口消失的时候会被调用 - */ - protected abstract void updateContentPane(); - - /** - * 以对话框的形式弹出 - * - * @param window 窗口 - * @return 对话框 - */ - public UIDialog showUnsizedWindow(Window window) { - CustomShapedDialog dg = null; - if (window instanceof Frame) { - dg = new CustomShapedDialog((Frame) window); - } else { - dg = new CustomShapedDialog((Dialog) window); - } - if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { - dg.setSize(bounds.width + ARROR_PARALLEL, bounds.height + ARROR_VERTICAL); - } else { - dg.setSize(bounds.width + ARROR_VERTICAL, bounds.height + ARROR_PARALLEL); - } - - dg.setLocation(bounds.x, bounds.y); - dg.setBackground(Color.blue); - dg.setResizable(false); - return dg; - } - - @Override - protected String title4PopupWindow() { - return null; - } - - private double initBoundsTime(int arrowPosition, Point arrowPoint, int width, int height) { - int x = arrowPoint.x; - int y = arrowPoint.y; - int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; - int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height - TITLE_HEIGHT; - double time = TIME_DEFAULT; - - if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { - while (y + time * height > screenHeight && time > 0) { - time -= TIME_GAP; - } - - while (y - (1 - time) * height < 0 && time < 1) { - time += TIME_GAP; - } - } else if (arrowPosition == Constants.TOP) { - while (x + time * width > screenWidth && time > 0) { - time -= TIME_GAP; - } - - while (x - (1 - time) * width < 0 && time < 1) { - time += TIME_GAP; - } - } - return 1 - time; - } - - private AWTEventListener awt = new AWTEventListener() { - public void eventDispatched(AWTEvent event) { - doSomeInAll(event); - } - }; - - private void doSomeInAll(AWTEvent event) { - if (event instanceof MouseEvent) { - MouseEvent mv = (MouseEvent) event; - if (mv.getClickCount() > 0) { - Point point = new Point((int) (mv.getLocationOnScreen().getX()) - 2 * OFF_LEFT, (int) mv.getLocationOnScreen().getY()); - // 判断鼠标点击是否在边界内 - if (!containsPoint(point) && showDialog != null) { - updateContentPane(); - showDialog.setVisible(false); - Toolkit.getDefaultToolkit().removeAWTEventListener(awt); - } - } - } - } + public void show(JComponent fatherPane, T ob) { + populateBean(ob); + if (showDialog == null) { + showDialog = showUnsizedWindow(SwingUtilities.getWindowAncestor(fatherPane)); + } + Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + showDialog.setVisible(true); + } + + /** + * 数据展现 + */ + public void populateBean(T ob) { + contentPane.populateBean(ob); + } + + /** + * 停止编辑, 更新至最新的面板到属性保存 + */ + public T updateBean() { + updateContentPane(); + return contentPane.updateBean(); + } + + /** + * 需要实现更新内容,将updateBean传值给对象即可,在窗口消失的时候会被调用 + */ + protected abstract void updateContentPane(); + + /** + * 以对话框的形式弹出 + * + * @param window 窗口 + * @return 对话框 + */ + public UIDialog showUnsizedWindow(Window window) { + CustomShapedDialog dg = null; + if (window instanceof Frame) { + dg = new CustomShapedDialog((Frame) window); + } else { + dg = new CustomShapedDialog((Dialog) window); + } + if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { + dg.setSize(bounds.width + ARROR_PARALLEL, bounds.height + ARROR_VERTICAL); + } else { + dg.setSize(bounds.width + ARROR_VERTICAL, bounds.height + ARROR_PARALLEL); + } + + dg.setLocation(bounds.x, bounds.y); + dg.setBackground(Color.blue); + dg.setResizable(false); + return dg; + } + + @Override + protected String title4PopupWindow() { + return null; + } + + private double initBoundsTime(int arrowPosition, Point arrowPoint, int width, int height) { + int x = arrowPoint.x; + int y = arrowPoint.y; + int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; + int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height - TITLE_HEIGHT; + double time = TIME_DEFAULT; + + if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { + while (y + time * height > screenHeight && time > 0) { + time -= TIME_GAP; + } + + while (y - (1 - time) * height < 0 && time < 1) { + time += TIME_GAP; + } + } else if (arrowPosition == Constants.TOP) { + while (x + time * width > screenWidth && time > 0) { + time -= TIME_GAP; + } + + while (x - (1 - time) * width < 0 && time < 1) { + time += TIME_GAP; + } + } + return 1 - time; + } + + private AWTEventListener awt = new AWTEventListener() { + public void eventDispatched(AWTEvent event) { + doSomeInAll(event); + } + }; + + private void doSomeInAll(AWTEvent event) { + if (event instanceof MouseEvent) { + MouseEvent mv = (MouseEvent) event; + if (mv.getClickCount() > 0) { + Point point = new Point((int) (mv.getLocationOnScreen().getX()) - 2 * OFF_LEFT, (int) mv.getLocationOnScreen().getY()); + // 判断鼠标点击是否在边界内 + if (!containsPoint(point) && showDialog != null) { + updateContentPane(); + showDialog.setVisible(false); + Toolkit.getDefaultToolkit().removeAWTEventListener(awt); + } + } + } + } private boolean containsPoint(Point point) { - if(arrowPosition == Constants.TOP){ + if (arrowPosition == Constants.TOP) { //箭头和按钮也算在pane内 Rectangle judgedBounds = new Rectangle(bounds.x, bounds.y - OFF_LEFT * 2, bounds.width, bounds.height + OFF_LEFT * 2 + OFF_LEFT); - return judgedBounds.contains(point); + return judgedBounds.contains(point); } return bounds.contains(point); } - private void initComponents() { - if(arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { - this.setBounds(20, 10, bounds.width, bounds.height); - } else { - this.setBounds(10, 10, bounds.width, bounds.height); - } - - this.setLayout(new BorderLayout()); - this.add(contentPane, BorderLayout.CENTER); - } + private void initComponents() { + if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { + this.setBounds(20, 10, bounds.width, bounds.height); + } else { + this.setBounds(10, 10, bounds.width, bounds.height); + } + + this.setLayout(new BorderLayout()); + this.add(contentPane, BorderLayout.CENTER); + } - private class CustomShapedDialog extends UIDialog { + private class CustomShapedDialog extends UIDialog { private static final int GAP_SMALL = 10; private static final int GAP = 20; private static final int GAP_BIG = 30; - public CustomShapedDialog(Frame parent) { - super(parent); - this.initComponents(); - } - - public CustomShapedDialog(Dialog parent) { - super(parent); - this.initComponents(); - } - - - private Shape getCustomShap() { - Polygon polygon = new Polygon(); - if (arrowPosition == Constants.LEFT) { - polygon.addPoint(GAP_SMALL, 0); - polygon.addPoint(bounds.width + GAP_BIG, 0); - polygon.addPoint(bounds.width + GAP_BIG, bounds.height + GAP); - polygon.addPoint(GAP_SMALL, bounds.height + GAP); - polygon.addPoint(GAP_SMALL, (int) ((bounds.height + GAP) * time) - GAP_SMALL); - polygon.addPoint(0, (int) ((bounds.height + GAP) * time - GAP)); - polygon.addPoint(GAP_SMALL, (int) ((bounds.height + GAP) * time - GAP_BIG)); - polygon.addPoint(GAP_SMALL, 0); - } else if (arrowPosition == Constants.TOP) { - polygon.addPoint(0, GAP_SMALL); - polygon.addPoint((int) (bounds.width * time + GAP_SMALL), GAP_SMALL); - polygon.addPoint((int) (bounds.width * time + GAP), 0); - polygon.addPoint((int) (bounds.getWidth() * time + GAP_BIG), GAP_SMALL); - polygon.addPoint(bounds.width + GAP, GAP_SMALL); - polygon.addPoint(bounds.width + GAP, bounds.height + GAP_BIG); - polygon.addPoint(0, bounds.height + GAP_BIG); - polygon.addPoint(0, GAP_SMALL); - } else if (arrowPosition == Constants.RIGHT) { - polygon.addPoint(0, 0); - polygon.addPoint(bounds.width + GAP, 0); - polygon.addPoint(bounds.width + GAP, (int) ((bounds.height + GAP) * time) - GAP_BIG); - polygon.addPoint(bounds.width + GAP_BIG, (int) ((bounds.height + GAP) * time) - GAP); - polygon.addPoint(bounds.width + GAP, (int) ((bounds.height + GAP) * time) - GAP_SMALL); - polygon.addPoint(bounds.width + GAP, bounds.height + GAP); - polygon.addPoint(0, bounds.height + GAP); - polygon.addPoint(0, 0); - } - - return polygon; - } - - private Shape getShape4Board() { - Polygon polygon = new Polygon(); - if (arrowPosition == Constants.LEFT) { - polygon.addPoint(GAP_SMALL, 1); - polygon.addPoint(bounds.width + GAP_BIG - 1, 1); - polygon.addPoint(bounds.width + GAP_BIG - 1, bounds.height + GAP - 1); - polygon.addPoint(GAP_SMALL + 1, bounds.height + GAP - 1); - polygon.addPoint(GAP_SMALL + 1, (int) ((bounds.height + GAP) * time) - GAP_SMALL); - polygon.addPoint(1, (int) ((bounds.height + GAP) * time - GAP)); - polygon.addPoint(GAP_SMALL + 1, (int) ((bounds.height + GAP) * time - GAP_BIG)); - polygon.addPoint(GAP_SMALL + 1, 1); - } else if (arrowPosition == Constants.TOP) { - polygon.addPoint(1, GAP_SMALL + 1); - polygon.addPoint((int) (bounds.width * time + GAP_SMALL), GAP_SMALL + 1); - polygon.addPoint((int) (bounds.width * time + GAP), 1); - polygon.addPoint((int) (bounds.getWidth() * time + GAP_BIG), GAP_SMALL + 1); - polygon.addPoint(bounds.width + GAP - 1, GAP_SMALL + 1); - polygon.addPoint(bounds.width + GAP - 1, bounds.height + GAP_BIG - 1); - polygon.addPoint(1, bounds.height + GAP_BIG - 1); - polygon.addPoint(1, GAP_SMALL + 1); - } else if(arrowPosition == Constants.RIGHT) { - polygon.addPoint(1, 1); - polygon.addPoint(bounds.width + GAP - 1, 1); - polygon.addPoint(bounds.width + GAP - 1, (int) ((bounds.height + GAP) * time) - GAP_BIG); - polygon.addPoint(bounds.width + GAP_BIG - 1, (int) ((bounds.height + GAP) * time) - GAP); - polygon.addPoint(bounds.width + GAP - 1, (int) ((bounds.height + GAP) * time) - GAP_SMALL); - polygon.addPoint(bounds.width + GAP - 1, bounds.height + GAP - 1); - polygon.addPoint(1, bounds.height + GAP - 1); - polygon.addPoint(1, 0); - } - return polygon; - } - - /** - * 画出界面的样式, 边框等. - */ - public void paint(Graphics g) { - super.paint(g); - Graphics2D g2d = (Graphics2D) g; - Stroke oldStroke = g2d.getStroke(); - g2d.setStroke(new BasicStroke(2, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND)); - g2d.setColor(new Color(51, 51, 51)); - g2d.drawPolygon((Polygon) getShape4Board()); - g2d.setStroke(oldStroke); - } - - protected void initComponents() { - setUndecorated(true); - try { - AWTUtilities.setWindowShape(CustomShapedDialog.this, this.getCustomShap()); - } catch (UnsupportedOperationException e) { + public CustomShapedDialog(Frame parent) { + super(parent); + this.initComponents(); + } + + public CustomShapedDialog(Dialog parent) { + super(parent); + this.initComponents(); + } + + + private Shape getCustomShap() { + Polygon polygon = new Polygon(); + if (arrowPosition == Constants.LEFT) { + polygon.addPoint(GAP_SMALL, 0); + polygon.addPoint(bounds.width + GAP_BIG, 0); + polygon.addPoint(bounds.width + GAP_BIG, bounds.height + GAP); + polygon.addPoint(GAP_SMALL, bounds.height + GAP); + polygon.addPoint(GAP_SMALL, (int) ((bounds.height + GAP) * time) - GAP_SMALL); + polygon.addPoint(0, (int) ((bounds.height + GAP) * time - GAP)); + polygon.addPoint(GAP_SMALL, (int) ((bounds.height + GAP) * time - GAP_BIG)); + polygon.addPoint(GAP_SMALL, 0); + } else if (arrowPosition == Constants.TOP) { + polygon.addPoint(0, GAP_SMALL - 2); + polygon.addPoint((int) (bounds.width * time + GAP_SMALL), GAP_SMALL - 2); + polygon.addPoint((int) (bounds.width * time + GAP), 0); + polygon.addPoint((int) (bounds.getWidth() * time + GAP_BIG), GAP_SMALL - 2); + polygon.addPoint(bounds.width + GAP, GAP_SMALL - 2); + polygon.addPoint(bounds.width + GAP, bounds.height + GAP_BIG); + polygon.addPoint(0, bounds.height + GAP_BIG); + polygon.addPoint(0, GAP_SMALL - 2); + } else if (arrowPosition == Constants.RIGHT) { + polygon.addPoint(0, 0); + polygon.addPoint(bounds.width + GAP, 0); + polygon.addPoint(bounds.width + GAP, (int) ((bounds.height + GAP) * time) - GAP_BIG); + polygon.addPoint(bounds.width + GAP_BIG, (int) ((bounds.height + GAP) * time) - GAP); + polygon.addPoint(bounds.width + GAP, (int) ((bounds.height + GAP) * time) - GAP_SMALL); + polygon.addPoint(bounds.width + GAP, bounds.height + GAP); + polygon.addPoint(0, bounds.height + GAP); + polygon.addPoint(0, 0); + } + + return polygon; + } + + private Shape getShape4Board() { + Polygon polygon = new Polygon(); + if (arrowPosition == Constants.LEFT) { + polygon.addPoint(GAP_SMALL, 1); + polygon.addPoint(bounds.width + GAP_BIG - 1, 1); + polygon.addPoint(bounds.width + GAP_BIG - 1, bounds.height + GAP - 1); + polygon.addPoint(GAP_SMALL + 1, bounds.height + GAP - 1); + polygon.addPoint(GAP_SMALL + 1, (int) ((bounds.height + GAP) * time) - GAP_SMALL); + polygon.addPoint(1, (int) ((bounds.height + GAP) * time - GAP)); + polygon.addPoint(GAP_SMALL + 1, (int) ((bounds.height + GAP) * time - GAP_BIG)); + polygon.addPoint(GAP_SMALL + 1, 1); + } else if (arrowPosition == Constants.TOP) { + polygon.addPoint(1, GAP_SMALL - 1); + polygon.addPoint((int) (bounds.width * time + GAP_SMALL), GAP_SMALL - 1); + polygon.addPoint((int) (bounds.width * time + GAP), 1); + polygon.addPoint((int) (bounds.getWidth() * time + GAP_BIG), GAP_SMALL - 1); + polygon.addPoint(bounds.width + GAP - 1, GAP_SMALL - 1); + polygon.addPoint(bounds.width + GAP - 1, bounds.height + GAP_BIG - 1); + polygon.addPoint(1, bounds.height + GAP_BIG - 1); + polygon.addPoint(1, GAP_SMALL - 1); + } else if (arrowPosition == Constants.RIGHT) { + polygon.addPoint(1, 1); + polygon.addPoint(bounds.width + GAP - 1, 1); + polygon.addPoint(bounds.width + GAP - 1, (int) ((bounds.height + GAP) * time) - GAP_BIG); + polygon.addPoint(bounds.width + GAP_BIG - 1, (int) ((bounds.height + GAP) * time) - GAP); + polygon.addPoint(bounds.width + GAP - 1, (int) ((bounds.height + GAP) * time) - GAP_SMALL); + polygon.addPoint(bounds.width + GAP - 1, bounds.height + GAP - 1); + polygon.addPoint(1, bounds.height + GAP - 1); + polygon.addPoint(1, 0); + } + return polygon; + } + + protected void initComponents() { + setUndecorated(true); + try { + AWTUtilities.setWindowShape(CustomShapedDialog.this, this.getCustomShap()); + } catch (UnsupportedOperationException e) { FineLoggerFactory.getLogger().info("Not support"); - } - final JPanel contentPane = (JPanel) this.getContentPane(); - this.setLayout(null); - contentPane.add(UIBubbleFloatPane.this); - setVisible(true); - } - - /** - * 检查 - */ - public void checkValid() throws Exception { - - } - } + } + final JPanel contentPane = (JPanel) this.getContentPane(); + this.setLayout(null); + contentPane.add(UIBubbleFloatPane.this); + contentPane.setBorder(new Border() { + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Graphics2D g2d = (Graphics2D) g; + Stroke oldStroke = g2d.getStroke(); + g2d.setStroke(new BasicStroke(2, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND)); + g2d.setColor(new Color(51, 51, 51)); + g2d.drawPolygon((Polygon) getShape4Board()); + g2d.setStroke(oldStroke); + } + + @Override + public Insets getBorderInsets(Component c) { + return null; + } + + @Override + public boolean isBorderOpaque() { + return false; + } + }); + } + + /** + * 检查 + */ + public void checkValid() throws Exception { + + } + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java index 3c5e992b9..241a93ea0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.designer.style; import com.fr.base.BaseUtils; -import com.fr.base.Style; import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UIBubbleFloatPane; @@ -61,6 +60,7 @@ public class VanChartPlotLegendPane extends BasicPane { private UIButtonGroup layoutButton; private JPanel layoutPane; private VanChartFloatPositionPane customFloatPositionPane; + private UIBubbleFloatPane uiBubbleFloatPane; //区域显示策略 恢复用注释。下面4行删除。 private UIButtonGroup customSize; @@ -80,7 +80,7 @@ public class VanChartPlotLegendPane extends BasicPane { initComponents(); } - public VanChartPlotLegendPane(VanChartStylePane parent){ + public VanChartPlotLegendPane(VanChartStylePane parent) { this.parent = parent; initComponents(); } @@ -118,9 +118,9 @@ public class VanChartPlotLegendPane extends BasicPane { new Component[]{legendPane}, }; - JPanel panel = TableLayoutHelper.createTableLayoutPane(components,row,col); + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); this.setLayout(new BorderLayout()); - this.add(panel,BorderLayout.CENTER); + this.add(panel, BorderLayout.CENTER); addLegendListener(); } @@ -133,7 +133,7 @@ public class VanChartPlotLegendPane extends BasicPane { }); } - protected JPanel createLegendPaneWithoutHighlight(){ + protected JPanel createLegendPaneWithoutHighlight() { borderPane = new VanChartBorderWithRadiusPane(); backgroundPane = new VanChartBackgroundWithOutImagePane(); @@ -141,19 +141,19 @@ public class VanChartPlotLegendPane extends BasicPane { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; - double[] rowSize = { p,p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createTitlePositionPane(new double[]{p,p,p},columnSize),null}, - new Component[]{createTitleStylePane(),null} , - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), createDisplayStrategy()),null} + new Component[]{createTitlePositionPane(new double[]{p, p, p}, columnSize), null}, + new Component[]{createTitleStylePane(), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), createDisplayStrategy()), null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } - protected JPanel createLegendPane(){ + protected JPanel createLegendPane() { borderPane = new VanChartBorderWithRadiusPane(); backgroundPane = new VanChartBackgroundWithOutImagePane(); highlightPane = createHighlightPane(); @@ -166,14 +166,14 @@ public class VanChartPlotLegendPane extends BasicPane { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; - double[] rowSize = { p,p,p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createTitlePositionPane(new double[]{p,p,p},columnSize),null}, - new Component[]{createTitleStylePane(),null} , - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel),null}, + new Component[]{createTitlePositionPane(new double[]{p, p, p}, columnSize), null}, + new Component[]{createTitleStylePane(), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel), null}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } @@ -205,12 +205,12 @@ public class VanChartPlotLegendPane extends BasicPane { customFloatPositionButton.setEventBannded(true); Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),location}, - new Component[]{null,customFloatPositionButton} + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), location}, + new Component[]{null, customFloatPositionButton} }; - customFloatPositionPane = new VanChartFloatPositionPane(); + customFloatPositionPane = new VanChartFloatPositionPane(); layoutPane = createLayoutPane(); initPositionListener(); @@ -241,7 +241,7 @@ public class VanChartPlotLegendPane extends BasicPane { return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{f, e}); } - private void initPositionListener(){ + private void initPositionListener() { location.addChangeListener(new ChangeListener() { @Override @@ -262,18 +262,20 @@ public class VanChartPlotLegendPane extends BasicPane { checkLayoutPaneVisible(); checkDisplayStrategyUse(); - if(customFloatPositionPane == null) { - customFloatPositionPane = new VanChartFloatPositionPane(); + if (customFloatPositionPane == null) { + customFloatPositionPane = new VanChartFloatPositionPane(); + } + if (uiBubbleFloatPane == null) { + Point comPoint = customFloatPositionButton.getLocationOnScreen(); + Point arrowPoint = new Point(comPoint.x + customFloatPositionButton.getWidth() / 2 - GAP, comPoint.y + customFloatPositionButton.getHeight()); + uiBubbleFloatPane = new UIBubbleFloatPane(Constants.TOP, arrowPoint, customFloatPositionPane, WIDTH, HEIGHT) { + @Override + public void updateContentPane() { + parent.attributeChanged(); + } + }; } - Point comPoint = customFloatPositionButton.getLocationOnScreen(); - Point arrowPoint = new Point(comPoint.x + customFloatPositionButton.getWidth()/2 - GAP, comPoint.y + customFloatPositionButton.getHeight()); - UIBubbleFloatPane