Browse Source

Merge remote-tracking branch 'origin/feature/10.0' into feature/10.0

research/11.0
Bryant 5 years ago
parent
commit
7f519a3447
  1. 2
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  2. 26
      designer-base/src/main/java/com/fr/design/beans/BasicBeanPane.java
  3. 6
      designer-base/src/main/java/com/fr/design/beans/FurtherBasicBeanPane.java
  4. 3
      designer-base/src/main/java/com/fr/design/condition/ConditionAttrSingleConditionPane.java
  5. 2
      designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java
  6. 6
      designer-base/src/main/java/com/fr/design/dialog/BasicDialog.java
  7. 17
      designer-base/src/main/java/com/fr/design/dialog/BasicPane.java
  8. 3
      designer-base/src/main/java/com/fr/design/dialog/DialogActionAdapter.java
  9. 7
      designer-base/src/main/java/com/fr/design/dialog/DialogActionListener.java
  10. 8
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  11. 6
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java
  12. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java
  13. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButton.java
  14. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java
  15. 31
      designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java
  16. 31
      designer-base/src/main/java/com/fr/design/gui/itable/AbstractPropertyTable.java
  17. 2
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java
  18. 3
      designer-base/src/main/java/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
  19. 1
      designer-base/src/main/java/com/fr/design/gui/style/NumberDragBar.java
  20. 2
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxDocument.java
  21. 404
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java
  22. 369
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java
  23. 229
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java
  24. 38
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java
  25. 5
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java
  26. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java
  27. 3
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java
  28. 9
      designer-base/src/main/java/com/fr/design/icon/BorderIcon.java
  29. 2
      designer-base/src/main/java/com/fr/design/icon/LockIcon.java
  30. 2
      designer-base/src/main/java/com/fr/design/icon/WarningIcon.java
  31. 5
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  32. 63
      designer-base/src/main/java/com/fr/design/layout/TableLayout.java
  33. 1
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  34. 23
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  35. 7
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java
  36. 5
      designer-base/src/main/java/com/fr/design/report/WatermarkPane.java
  37. 1
      designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java
  38. 1
      designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java
  39. 1
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  40. 1
      designer-base/src/main/java/com/fr/design/utils/DrawRoutines.java
  41. 1
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  42. 1
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java
  43. 97
      designer-chart/src/main/java/com/fr/design/chart/gui/ActiveGlyphFactory.java
  44. 98
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  45. 161
      designer-chart/src/main/java/com/fr/design/chart/gui/active/ActiveGlyph.java
  46. 38
      designer-chart/src/main/java/com/fr/design/chart/gui/active/AlertValueActiveGlyph.java
  47. 43
      designer-chart/src/main/java/com/fr/design/chart/gui/active/AxisActiveGlyph.java
  48. 19
      designer-chart/src/main/java/com/fr/design/chart/gui/active/CategoryAxisActiveGlyph.java
  49. 39
      designer-chart/src/main/java/com/fr/design/chart/gui/active/ChartActiveGlyph.java
  50. 44
      designer-chart/src/main/java/com/fr/design/chart/gui/active/DataLabelActiveGlyph.java
  51. 53
      designer-chart/src/main/java/com/fr/design/chart/gui/active/DataSeriesActiveGlyph.java
  52. 30
      designer-chart/src/main/java/com/fr/design/chart/gui/active/DataSheetActiveGlyph.java
  53. 18
      designer-chart/src/main/java/com/fr/design/chart/gui/active/DateAxisActiveGlyph.java
  54. 30
      designer-chart/src/main/java/com/fr/design/chart/gui/active/LegendActiveGlyph.java
  55. 34
      designer-chart/src/main/java/com/fr/design/chart/gui/active/PlotActiveGlyph.java
  56. 18
      designer-chart/src/main/java/com/fr/design/chart/gui/active/RadarAxisActiveGlyph.java
  57. 18
      designer-chart/src/main/java/com/fr/design/chart/gui/active/RangeAxisActiveGlyph.java
  58. 35
      designer-chart/src/main/java/com/fr/design/chart/gui/active/TextActiveGlyph.java
  59. 43
      designer-chart/src/main/java/com/fr/design/chart/gui/active/TrendLineActiveGlyph.java
  60. 19
      designer-chart/src/main/java/com/fr/design/chart/gui/active/ValueAxisActiveGlyph.java
  61. 37
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java
  62. 27
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java
  63. 33
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java
  64. 31
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java
  65. 26
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java
  66. 33
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetDataSheetAction.java
  67. 32
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetLegendStyleAction.java
  68. 32
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java
  69. 32
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java
  70. 6
      designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java
  71. 23
      designer-chart/src/main/java/com/fr/design/chartx/StructureChartDataPane.java
  72. 86
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java
  73. 91
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureDataSetFieldsPane.java
  74. 2
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudCellDataFieldsPane.java
  75. 9
      designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java
  76. 5
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java
  77. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java
  78. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BarPlotPane.java
  79. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ColumnPlotPane.java
  80. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java
  81. 2
      designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaPlotPane.java
  82. 5
      designer-chart/src/main/java/com/fr/van/chart/bar/VanChartBarPlotPane.java
  83. 5
      designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java
  84. 8
      designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java
  85. 5
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotPane.java
  86. 2
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java
  87. 3
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java
  88. 8
      designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java
  89. 6
      designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java
  90. 8
      designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java
  91. 18
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  92. 1
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  93. 2
      designer-form/src/main/java/com/fr/design/mainframe/FormToolBar.java
  94. 2
      designer-form/src/main/java/com/fr/design/mainframe/FormToolBarPane.java
  95. 1
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  96. 4
      designer-form/src/main/java/com/fr/design/mainframe/widget/UITreeComboBox.java
  97. 6
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java
  98. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java

2
designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java

@ -5,6 +5,7 @@
package com.fr.design; package com.fr.design;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.common.annotations.Open;
import com.fr.design.data.datapane.TableDataNameObjectCreator; import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.fun.*; import com.fr.design.fun.*;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
@ -34,6 +35,7 @@ import java.util.Set;
* @since : 8.0 * @since : 8.0
* 用于设计器扩展的管理类 * 用于设计器扩展的管理类
*/ */
@Open
public class ExtraDesignClassManager extends AbstractExtraClassManager implements ExtraDesignClassManagerProvider { public class ExtraDesignClassManager extends AbstractExtraClassManager implements ExtraDesignClassManagerProvider {
private static ExtraDesignClassManager classManager = new ExtraDesignClassManager(); private static ExtraDesignClassManager classManager = new ExtraDesignClassManager();

26
designer-base/src/main/java/com/fr/design/beans/BasicBeanPane.java

@ -1,24 +1,27 @@
package com.fr.design.beans; package com.fr.design.beans;
import com.fr.common.annotations.Open;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
/** @Open
* Update Pane
*/
public abstract class BasicBeanPane<T> extends BasicPane { public abstract class BasicBeanPane<T> extends BasicPane {
/** /**
* Populate. * 展示数据
* @param ob 待展示的对象
*/ */
public abstract void populateBean(T ob); public abstract void populateBean(T ob);
/** /**
* Update. * 保存数据
* @return 待保存的对象
*/ */
public abstract T updateBean(); public abstract T updateBean();
/**
* 保存数据
* @param ob 待保存的对象
*/
public void updateBean(T ob) { public void updateBean(T ob) {
} }
@ -29,13 +32,4 @@ public abstract class BasicBeanPane<T> extends BasicPane {
public void populateAuthority() { public void populateAuthority() {
} }
/**
* 仅用来处理图表设计器的地图面板
* @param mapType 地图类型
*/
public void dealWidthMap(String mapType){
}
} }

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

@ -1,11 +1,9 @@
package com.fr.design.beans; package com.fr.design.beans;
import com.fr.common.annotations.Open;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
/** @Open
* @author zhou
* @since 2012-5-30下午12:12:42
*/
public abstract class FurtherBasicBeanPane<T> extends BasicBeanPane<T> { public abstract class FurtherBasicBeanPane<T> extends BasicBeanPane<T> {
/** /**
* 是否是指定类型 * 是否是指定类型

3
designer-base/src/main/java/com/fr/design/condition/ConditionAttrSingleConditionPane.java

@ -1,10 +1,13 @@
package com.fr.design.condition; package com.fr.design.condition;
import com.fr.common.annotations.Open;
/** /**
* @author richie * @author richie
* @date 2015-03-26 * @date 2015-03-26
* @since 8.0 * @since 8.0
*/ */
@Open
public abstract class ConditionAttrSingleConditionPane<T> extends SingleConditionPane<T> { public abstract class ConditionAttrSingleConditionPane<T> extends SingleConditionPane<T> {
protected HighLightConditionAction hightLighAttrUpdateAction = null; protected HighLightConditionAction hightLighAttrUpdateAction = null;
private ConditionAttributesPane conditionAttributesPane; private ConditionAttributesPane conditionAttributesPane;

2
designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java

@ -1,6 +1,7 @@
package com.fr.design.condition; package com.fr.design.condition;
import com.fr.common.annotations.Open;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
@ -17,6 +18,7 @@ import java.awt.Dimension;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@Open
public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> { public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> {
private static final int MIN_HEIGHT = 60; private static final int MIN_HEIGHT = 60;
protected CellHighlightAddMenuDef menuDef; protected CellHighlightAddMenuDef menuDef;

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

@ -1,10 +1,10 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
import java.awt.*; import java.awt.*;
/* @Open
* @author _denny
*/
public abstract class BasicDialog extends UIDialog { public abstract class BasicDialog extends UIDialog {
public static final Dimension SMALL = new Dimension(340, 180); public static final Dimension SMALL = new Dimension(340, 180);
public static final Dimension MEDIUM = new Dimension(600, 400); public static final Dimension MEDIUM = new Dimension(600, 400);

17
designer-base/src/main/java/com/fr/design/dialog/BasicPane.java

@ -1,24 +1,17 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.JPanel; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.Dialog; @Open
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Window;
/*
* _denny: 这里的BasicPane通常会有populate & update方法
* 记得populate 一定要在对应的dialog setVisible之前populate
*/
public abstract class BasicPane extends JPanel { public abstract class BasicPane extends JPanel {
/** /**

3
designer-base/src/main/java/com/fr/design/dialog/DialogActionAdapter.java

@ -1,5 +1,8 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
@Open
public abstract class DialogActionAdapter implements DialogActionListener { public abstract class DialogActionAdapter implements DialogActionListener {
@Override @Override
public void doOk() {} public void doOk() {}

7
designer-base/src/main/java/com/fr/design/dialog/DialogActionListener.java

@ -1,8 +1,11 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
@Open
public interface DialogActionListener { public interface DialogActionListener {
public void doOk(); void doOk();
public void doCancel(); void doCancel();
} }

8
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -25,13 +25,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created with IntelliJ IDEA.
* User: 小灰灰
* Date: 13-7-16
* Time: 下午2:17
* To change this template use File | Settings | File Templates.
*/
public abstract class UIDialog extends JDialog { public abstract class UIDialog extends JDialog {
public static final String OK_BUTTON = "basic_ok"; public static final String OK_BUTTON = "basic_ok";
public static final String CANCEL_BUTTON = "basic_cancel"; public static final String CANCEL_BUTTON = "basic_cancel";

6
designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java

@ -321,9 +321,9 @@ public class UIBasicButtonUI extends MetalButtonUI {
//harry: 画带有高光的按钮。 //harry: 画带有高光的按钮。
private void drawHighLightButton(Graphics2D g2, Color color1, Color color2, int w, int h) { private void drawHighLightButton(Graphics2D g2, Color color1, Color color2, int w, int h) {
GradientPaint buttonPaint = new GradientPaint(0, 0, color1, 0, h - 1, color2); GradientPaint buttonPaint = new GradientPaint(0, 0, color1, 0, h - 1f, color2);
GradientPaint buttonHighLightPaint = new GradientPaint(0, 0, new Color(1.0f, 1.0f, 1.0f, 0.6f), 0, h / 2, new Color(1.0f, 1.0f, 1.0f, 0.2f)); GradientPaint buttonHighLightPaint = new GradientPaint(0, 0, new Color(1.0f, 1.0f, 1.0f, 0.6f), 0, h / 2f, new Color(1.0f, 1.0f, 1.0f, 0.2f));
GradientPaint buttonHighLightLinePaint = new GradientPaint(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.8f), 0, h / 2, new Color(1.0f, 1.0f, 1.0f, 0.4f)); GradientPaint buttonHighLightLinePaint = new GradientPaint(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.8f), 0, h / 2f, new Color(1.0f, 1.0f, 1.0f, 0.4f));
g2.setPaint(buttonPaint); g2.setPaint(buttonPaint);
g2.fillRoundRect(0, 0, w - 1, h - 1, 3, 3); g2.fillRoundRect(0, 0, w - 1, h - 1, 3, 3);
g2.setPaint(buttonHighLightLinePaint);//按钮内侧高光线(内发光,0%阻塞) g2.setPaint(buttonHighLightLinePaint);//按钮内侧高光线(内发光,0%阻塞)

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java

@ -251,7 +251,7 @@ public class UIButton extends JButton implements UIObserver, UITextComponent {
protected void paintOtherBorder(Graphics g) { protected void paintOtherBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(borderStroke); g2d.setStroke(borderStroke);
Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1f, getHeight() - 1f, UIConstants.ARC, UIConstants.ARC);
g2d.setColor(borderColor); g2d.setColor(borderColor);
g2d.draw(shape); g2d.draw(shape);
} }

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButton.java

@ -232,7 +232,7 @@ public class UISliderButton extends JButton implements UIObserver {
protected void paintOtherBorder(Graphics g) { protected void paintOtherBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(borderStroke); g2d.setStroke(borderStroke);
Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1f, getHeight() - 1f, UIConstants.ARC, UIConstants.ARC);
g2d.setColor(borderColor); g2d.setColor(borderColor);
g2d.draw(shape); g2d.draw(shape);
} }

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java

@ -176,7 +176,7 @@ public class UISliderButtonUI extends BasicButtonUI {
private void fillNormal(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) { private void fillNormal(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) {
GradientPaint gp; GradientPaint gp;
if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) { if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) {
gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1, UIConstants.AUTHORITY_DARK_BLUE); gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1f, UIConstants.AUTHORITY_DARK_BLUE);
} else if (isPressedPainted) { } else if (isPressedPainted) {
gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1, UIConstants.SELECT_TAB); gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1, UIConstants.SELECT_TAB);
}else{ }else{

31
designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java

@ -0,0 +1,31 @@
package com.fr.design.gui.ispinner;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
/**
* Created by IntelliJ IDEA.
* Author : Hugh.C
* Date: 19-08-28
* Time: 下午2:19
*/
public class UnsignedIntUISpinner extends UISpinner {
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta) {
super(minValue, maxValue, dierta);
}
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta, double defaultValue) {
super(minValue, maxValue, dierta, defaultValue);
}
@Override
protected UINumberField initNumberField() {
return new UIIntNumberField() {
public boolean shouldResponseChangeListener() {
return false;
}
};
}
}

31
designer-base/src/main/java/com/fr/design/gui/itable/AbstractPropertyTable.java

@ -3,11 +3,15 @@
*/ */
package com.fr.design.gui.itable; package com.fr.design.gui.itable;
import java.awt.*; import com.fr.general.ComparatorUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
@ -16,9 +20,6 @@ import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import com.fr.general.ComparatorUtils;
/** /**
* @author richer * @author richer
* @since 6.5.3 * @since 6.5.3
@ -109,8 +110,8 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public TableCellEditor getCellEditor(int row, int column) { public TableCellEditor getCellEditor(int row, int column) {
if (groups != null) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (groups != null && pIndex != null) {
PropertyGroup group = groups.get(pIndex.x); PropertyGroup group = groups.get(pIndex.x);
if (pIndex.y == 0) { if (pIndex.y == 0) {
return super.getCellEditor(row, column); return super.getCellEditor(row, column);
@ -162,7 +163,7 @@ public abstract class AbstractPropertyTable extends JTable {
int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint()); int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint());
if (row != -1) { if (row != -1) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex.y == 0 && e.getClickCount() > 1) { if (pIndex != null && pIndex.y == 0 && e.getClickCount() > 1) {
toggleCollapse(pIndex.x); toggleCollapse(pIndex.x);
} }
} }
@ -180,7 +181,7 @@ public abstract class AbstractPropertyTable extends JTable {
int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint()); int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint());
if (row != -1) { if (row != -1) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < PROPERTY_ICON_WIDTH) { if (pIndex != null && pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < PROPERTY_ICON_WIDTH) {
toggleCollapse(pIndex.x); toggleCollapse(pIndex.x);
} }
} }
@ -263,6 +264,9 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public void setValueAt(Object aValue, int row, int column) { public void setValueAt(Object aValue, int row, int column) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex == null) {
return;
}
PropertyGroup group = groups.get(pIndex.x); PropertyGroup group = groups.get(pIndex.x);
if (pIndex.y != 0) { if (pIndex.y != 0) {
Object old_value = getValueAt(row, column); Object old_value = getValueAt(row, column);
@ -276,16 +280,11 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public boolean isCellEditable(int row, int column) { public boolean isCellEditable(int row, int column) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
PropertyGroup group = groups.get(pIndex.x); if (pIndex == null) {
if (pIndex.y == 0) {
if (column == 0) {
return false;
} else {
return false; return false;
} }
} else { PropertyGroup group = groups.get(pIndex.x);
return column == 1 && group.getModel().isEditable(pIndex.y - 1); return pIndex.y != 0 && (column == 1 && group.getModel().isEditable(pIndex.y - 1));
}
} }
} }
} }

2
designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java

@ -244,7 +244,7 @@ public abstract class UITableModelAdapter<T extends Object> extends AbstractTabl
FineLoggerFactory.getLogger().error(ee.getMessage(), ee); FineLoggerFactory.getLogger().error(ee.getMessage(), ee);
} }
} }
if (getRowCount() < 1 || selectedRow.length < 0) { if (getRowCount() < 1) {
return; return;
} }

3
designer-base/src/main/java/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java

@ -153,6 +153,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
try { try {
Thread.sleep(3); Thread.sleep(3);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
} }
} }
if (currentPanel != panel) { if (currentPanel != panel) {
@ -202,7 +203,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
} }
@Override @Override
public int getSelectedIndex() { public synchronized int getSelectedIndex() {
return selectedIndex; return selectedIndex;
} }

1
designer-base/src/main/java/com/fr/design/gui/style/NumberDragBar.java

@ -127,6 +127,7 @@ public class NumberDragBar extends JComponent {
revalidate(); revalidate();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.toString()); FineLoggerFactory.getLogger().error(e.toString());
Thread.currentThread().interrupt();
} }
} }
}); });

2
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxDocument.java

@ -366,7 +366,9 @@ public class RSyntaxDocument extends RDocument implements Iterable<Token>,
*/ */
public boolean getShouldIndentNextLine(int line) { public boolean getShouldIndentNextLine(int line) {
Token t = getTokenListForLine(line); Token t = getTokenListForLine(line);
if (t != null) {
t = t.getLastNonCommentNonWhitespaceToken(); t = t.getLastNonCommentNonWhitespaceToken();
}
return tokenMaker.getShouldIndentNextLineAfter(t); return tokenMaker.getShouldIndentNextLineAfter(t);
} }

404
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java

File diff suppressed because it is too large Load Diff

369
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java

@ -9,6 +9,24 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
import com.fr.design.gui.syntax.ui.rtextarea.RTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane;
import javax.swing.JLabel;
import javax.swing.JViewport;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.text.BadLocationException;
import javax.swing.text.Caret;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.Position;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import java.awt.Color; import java.awt.Color;
import java.awt.Container; import java.awt.Container;
import java.awt.Point; import java.awt.Point;
@ -16,23 +34,9 @@ import java.awt.Rectangle;
import java.awt.Shape; import java.awt.Shape;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Caret;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.Position;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
import com.fr.design.gui.syntax.ui.rtextarea.RTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane;
/** /**
@ -122,7 +126,7 @@ public class RSyntaxUtilities implements SwingConstants {
/** /**
* Used internally. * Used internally.
*/ */
private static final char[] JS_KEYWORD_RETURN = { 'r', 'e', 't', 'u', 'r', 'n' }; private static final char[] JS_KEYWORD_RETURN = {'r', 'e', 't', 'u', 'r', 'n'};
/** /**
* Used internally. * Used internally.
@ -146,10 +150,10 @@ public class RSyntaxUtilities implements SwingConstants {
public static final String escapeForHtml(String s, public static final String escapeForHtml(String s,
String newlineReplacement, boolean inPreBlock) { String newlineReplacement, boolean inPreBlock) {
if (s==null) { if (s == null) {
return null; return null;
} }
if (newlineReplacement==null) { if (newlineReplacement == null) {
newlineReplacement = ""; newlineReplacement = "";
} }
final String tabString = " "; final String tabString = " ";
@ -157,14 +161,13 @@ public class RSyntaxUtilities implements SwingConstants {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i=0; i<s.length(); i++) { for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i); char ch = s.charAt(i);
switch (ch) { switch (ch) {
case ' ': case ' ':
if (inPreBlock || !lastWasSpace) { if (inPreBlock || !lastWasSpace) {
sb.append(' '); sb.append(' ');
} } else {
else {
sb.append("&nbsp;"); sb.append("&nbsp;");
} }
lastWasSpace = true; lastWasSpace = true;
@ -208,8 +211,8 @@ public class RSyntaxUtilities implements SwingConstants {
* @return The rendering hints, or <code>null</code> if they cannot be * @return The rendering hints, or <code>null</code> if they cannot be
* determined. * determined.
*/ */
public static Map<?,?> getDesktopAntiAliasHints() { public static Map<?, ?> getDesktopAntiAliasHints() {
return (Map<?,?>)Toolkit.getDefaultToolkit(). return (Map<?, ?>) Toolkit.getDefaultToolkit().
getDesktopProperty("awt.font.desktophints"); getDesktopProperty("awt.font.desktophints");
} }
@ -223,7 +226,7 @@ public class RSyntaxUtilities implements SwingConstants {
public static Color getFoldedLineBottomColor(RSyntaxTextArea textArea) { public static Color getFoldedLineBottomColor(RSyntaxTextArea textArea) {
Color color = Color.gray; Color color = Color.gray;
Gutter gutter = RSyntaxUtilities.getGutter(textArea); Gutter gutter = RSyntaxUtilities.getGutter(textArea);
if (gutter!=null) { if (gutter != null) {
color = gutter.getFoldIndicatorForeground(); color = gutter.getFoldIndicatorForeground();
} }
return color; return color;
@ -245,7 +248,7 @@ public class RSyntaxUtilities implements SwingConstants {
if (parent instanceof JViewport) { if (parent instanceof JViewport) {
parent = parent.getParent(); parent = parent.getParent();
if (parent instanceof RTextScrollPane) { if (parent instanceof RTextScrollPane) {
RTextScrollPane sp = (RTextScrollPane)parent; RTextScrollPane sp = (RTextScrollPane) parent;
gutter = sp.getGutter(); // Should always be non-null gutter = sp.getGutter(); // Should always be non-null
} }
} }
@ -267,7 +270,7 @@ public class RSyntaxUtilities implements SwingConstants {
// This property is defined by all standard LaFs, even Nimbus (!), // This property is defined by all standard LaFs, even Nimbus (!),
// but you never know what crazy LaFs there are... // but you never know what crazy LaFs there are...
Color fg = UIManager.getColor("Label.foreground"); Color fg = UIManager.getColor("Label.foreground");
if (fg==null) { if (fg == null) {
fg = new JLabel().getForeground(); fg = new JLabel().getForeground();
} }
@ -286,7 +289,7 @@ public class RSyntaxUtilities implements SwingConstants {
public static String getLeadingWhitespace(String text) { public static String getLeadingWhitespace(String text) {
int count = 0; int count = 0;
int len = text.length(); int len = text.length();
while (count<len && RSyntaxUtilities.isWhitespace(text.charAt(count))) { while (count < len && RSyntaxUtilities.isWhitespace(text.charAt(count))) {
count++; count++;
} }
return text.substring(0, count); return text.substring(0, count);
@ -310,7 +313,7 @@ public class RSyntaxUtilities implements SwingConstants {
Element elem = root.getElement(line); Element elem = root.getElement(line);
int startOffs = elem.getStartOffset(); int startOffs = elem.getStartOffset();
int endOffs = elem.getEndOffset() - 1; int endOffs = elem.getEndOffset() - 1;
String text = doc.getText(startOffs, endOffs-startOffs); String text = doc.getText(startOffs, endOffs - startOffs);
return getLeadingWhitespace(text); return getLeadingWhitespace(text);
} }
@ -319,7 +322,7 @@ public class RSyntaxUtilities implements SwingConstants {
Element map = d.getDefaultRootElement(); Element map = d.getDefaultRootElement();
int index = map.getElementIndex(offs); int index = map.getElementIndex(offs);
Element elem = map.getElement(index); Element elem = map.getElement(index);
if ((offs>=elem.getStartOffset()) && (offs<elem.getEndOffset())) { if ((offs >= elem.getStartOffset()) && (offs < elem.getEndOffset())) {
return elem; return elem;
} }
return null; return null;
@ -358,13 +361,14 @@ public class RSyntaxUtilities implements SwingConstants {
int x0) int x0)
throws BadLocationException { throws BadLocationException {
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
// Ensure p0 and p1 are valid document positions. // Ensure p0 and p1 are valid document positions.
if (p0<0) if (p0 < 0) {
throw new BadLocationException("Invalid document position", p0); throw new BadLocationException("Invalid document position", p0);
else if (p1>doc.getLength()) } else if (p1 > doc.getLength()) {
throw new BadLocationException("Invalid document position", p1); throw new BadLocationException("Invalid document position", p1);
}
// Ensure p0 and p1 are in the same line, and get the start/end // Ensure p0 and p1 are in the same line, and get the start/end
// offsets for that line. // offsets for that line.
@ -373,9 +377,10 @@ public class RSyntaxUtilities implements SwingConstants {
// We do ">1" because p1 might be the first position on the next line // We do ">1" because p1 might be the first position on the next line
// or the last position on the previous one. // or the last position on the previous one.
// if (lineNum!=map.getElementIndex(p1)) // if (lineNum!=map.getElementIndex(p1))
if (Math.abs(lineNum-map.getElementIndex(p1))>1) if (Math.abs(lineNum - map.getElementIndex(p1)) > 1) {
throw new IllegalArgumentException("p0 and p1 are not on the " + throw new IllegalArgumentException("p0 and p1 are not on the " +
"same line (" + p0 + ", " + p1 + ")."); "same line (" + p0 + ", " + p1 + ").");
}
// Get the token list. // Get the token list.
Token t = doc.getTokenListForLine(lineNum); Token t = doc.getTokenListForLine(lineNum);
@ -410,7 +415,7 @@ public class RSyntaxUtilities implements SwingConstants {
public static Point getMatchingBracketPosition(RSyntaxTextArea textArea, public static Point getMatchingBracketPosition(RSyntaxTextArea textArea,
Point input) { Point input) {
if (input==null) { if (input == null) {
input = new Point(); input = new Point();
} }
input.setLocation(-1, -1); input.setLocation(-1, -1);
@ -419,25 +424,25 @@ public class RSyntaxUtilities implements SwingConstants {
// Actually position just BEFORE caret. // Actually position just BEFORE caret.
int caretPosition = textArea.getCaretPosition() - 1; int caretPosition = textArea.getCaretPosition() - 1;
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
char bracket = 0; char bracket = 0;
// If the caret was at offset 0, we can't check "to its left." // If the caret was at offset 0, we can't check "to its left."
if (caretPosition>=0) { if (caretPosition >= 0) {
bracket = doc.charAt(caretPosition); bracket = doc.charAt(caretPosition);
} }
// Try to match a bracket "to the right" of the caret if one // Try to match a bracket "to the right" of the caret if one
// was not found on the left. // was not found on the left.
int index = BRACKETS.indexOf(bracket); int index = BRACKETS.indexOf(bracket);
if (index==-1 && caretPosition<doc.getLength()-1) { if (index == -1 && caretPosition < doc.getLength() - 1) {
bracket = doc.charAt(++caretPosition); bracket = doc.charAt(++caretPosition);
} }
// First, see if the char was a bracket (one of "{[()]}"). // First, see if the char was a bracket (one of "{[()]}").
if (index==-1) { if (index == -1) {
index = BRACKETS.indexOf(bracket); index = BRACKETS.indexOf(bracket);
if (index==-1) { if (index == -1) {
return input; return input;
} }
} }
@ -455,14 +460,13 @@ public class RSyntaxUtilities implements SwingConstants {
Token token = doc.getTokenListForLine(curLine); Token token = doc.getTokenListForLine(curLine);
token = RSyntaxUtilities.getTokenAtOffset(token, caretPosition); token = RSyntaxUtilities.getTokenAtOffset(token, caretPosition);
// All brackets are always returned as "separators." // All brackets are always returned as "separators."
if (token.getType()!=Token.SEPARATOR) { if (Objects.requireNonNull(token).getType() != Token.SEPARATOR) {
return input; return input;
} }
if (index<3) { // One of "{[(" if (index < 3) { // One of "{[("
goForward = true; goForward = true;
bracketMatch = BRACKETS.charAt(index + 3); bracketMatch = BRACKETS.charAt(index + 3);
} } else { // One of ")]}"
else { // One of ")]}"
goForward = false; goForward = false;
bracketMatch = BRACKETS.charAt(index - 3); bracketMatch = BRACKETS.charAt(index - 3);
} }
@ -479,33 +483,32 @@ public class RSyntaxUtilities implements SwingConstants {
while (true) { while (true) {
doc.getText(start,end-start, charSegment); doc.getText(start, end - start, charSegment);
int segOffset = charSegment.offset; int segOffset = charSegment.offset;
for (int i=segOffset; i<segOffset+charSegment.count; i++) { for (int i = segOffset; i < segOffset + charSegment.count; i++) {
char ch = charSegment.array[i]; char ch = charSegment.array[i];
if (ch==bracket) { if (ch == bracket) {
if (haveTokenList==false) { if (!haveTokenList) {
token = doc.getTokenListForLine(curLine); token = doc.getTokenListForLine(curLine);
haveTokenList = true; haveTokenList = true;
} }
int offset = start + (i-segOffset); int offset = start + (i - segOffset);
token = RSyntaxUtilities.getTokenAtOffset(token, offset); token = RSyntaxUtilities.getTokenAtOffset(token, offset);
if (token.getType()==Token.SEPARATOR) if (Objects.requireNonNull(token).getType() == Token.SEPARATOR) {
numEmbedded++; numEmbedded++;
} }
} else if (ch == bracketMatch) {
else if (ch==bracketMatch) { if (!haveTokenList) {
if (haveTokenList==false) {
token = doc.getTokenListForLine(curLine); token = doc.getTokenListForLine(curLine);
haveTokenList = true; haveTokenList = true;
} }
int offset = start + (i-segOffset); int offset = start + (i - segOffset);
token = RSyntaxUtilities.getTokenAtOffset(token, offset); token = RSyntaxUtilities.getTokenAtOffset(token, offset);
if (token.getType()==Token.SEPARATOR) { if (Objects.requireNonNull(token).getType() == Token.SEPARATOR) {
if (numEmbedded==0) { if (numEmbedded == 0) {
if (textArea.isCodeFoldingEnabled() && if (textArea.isCodeFoldingEnabled() &&
textArea.getFoldManager().isLineHidden(curLine)) { textArea.getFoldManager().isLineHidden(curLine)) {
return input; // Match hidden in a fold return input; // Match hidden in a fold
@ -521,8 +524,9 @@ public class RSyntaxUtilities implements SwingConstants {
// Bail out if we've gone through all lines and // Bail out if we've gone through all lines and
// haven't found the match. // haven't found the match.
if (++curLine==lastLine) if (++curLine == lastLine) {
return input; return input;
}
// Otherwise, go through the next line. // Otherwise, go through the next line.
haveTokenList = false; haveTokenList = false;
@ -548,34 +552,33 @@ public class RSyntaxUtilities implements SwingConstants {
while (true) { while (true) {
doc.getText(start,end-start, charSegment); doc.getText(start, end - start, charSegment);
int segOffset = charSegment.offset; int segOffset = charSegment.offset;
int iStart = segOffset + charSegment.count - 1; int iStart = segOffset + charSegment.count - 1;
for (int i=iStart; i>=segOffset; i--) { for (int i = iStart; i >= segOffset; i--) {
char ch = charSegment.array[i]; char ch = charSegment.array[i];
if (ch==bracket) { if (ch == bracket) {
if (haveTokenList==false) { if (!haveTokenList) {
token = doc.getTokenListForLine(curLine); token = doc.getTokenListForLine(curLine);
haveTokenList = true; haveTokenList = true;
} }
int offset = start + (i-segOffset); int offset = start + (i - segOffset);
t2 = RSyntaxUtilities.getTokenAtOffset(token, offset); t2 = RSyntaxUtilities.getTokenAtOffset(token, offset);
if (t2.getType()==Token.SEPARATOR) if (Objects.requireNonNull(t2).getType() == Token.SEPARATOR) {
numEmbedded++; numEmbedded++;
} }
} else if (ch == bracketMatch) {
else if (ch==bracketMatch) { if (!haveTokenList) {
if (haveTokenList==false) {
token = doc.getTokenListForLine(curLine); token = doc.getTokenListForLine(curLine);
haveTokenList = true; haveTokenList = true;
} }
int offset = start + (i-segOffset); int offset = start + (i - segOffset);
t2 = RSyntaxUtilities.getTokenAtOffset(token, offset); t2 = RSyntaxUtilities.getTokenAtOffset(token, offset);
if (t2.getType()==Token.SEPARATOR) { if (Objects.requireNonNull(t2).getType() == Token.SEPARATOR) {
if (numEmbedded==0) { if (numEmbedded == 0) {
input.setLocation(caretPosition, offset); input.setLocation(caretPosition, offset);
return input; return input;
} }
@ -587,7 +590,7 @@ public class RSyntaxUtilities implements SwingConstants {
// Bail out if we've gone through all lines and // Bail out if we've gone through all lines and
// haven't found the match. // haven't found the match.
if (--curLine==-1) { if (--curLine == -1) {
return input; return input;
} }
@ -625,10 +628,10 @@ public class RSyntaxUtilities implements SwingConstants {
*/ */
public static final Token getNextImportantToken(Token t, public static final Token getNextImportantToken(Token t,
RSyntaxTextArea textArea, int line) { RSyntaxTextArea textArea, int line) {
while (t!=null && t.isPaintable() && t.isCommentOrWhitespace()) { while (t != null && t.isPaintable() && t.isCommentOrWhitespace()) {
t = t.getNextToken(); t = t.getNextToken();
} }
if ((t==null || !t.isPaintable()) && line<textArea.getLineCount()-1) { if ((t == null || !t.isPaintable()) && line < textArea.getLineCount() - 1) {
t = textArea.getTokenListForLine(++line); t = textArea.getTokenListForLine(++line);
return getNextImportantToken(t, textArea, line); return getNextImportantToken(t, textArea, line);
} }
@ -642,7 +645,7 @@ public class RSyntaxUtilities implements SwingConstants {
* Some views may not be visible, * Some views may not be visible,
* they might not be in the same order found in the model, or they just * they might not be in the same order found in the model, or they just
* might not allow access to some of the locations in the model.<p> * might not allow access to some of the locations in the model.<p>
* * <p>
* NOTE: You should only call this method if the passed-in * NOTE: You should only call this method if the passed-in
* <code>javax.swing.text.View</code> is an instance of * <code>javax.swing.text.View</code> is an instance of
* {@link TokenOrientedView} and <code>javax.swing.text.TabExpander</code>; * {@link TokenOrientedView} and <code>javax.swing.text.TabExpander</code>;
@ -661,8 +664,8 @@ public class RSyntaxUtilities implements SwingConstants {
* </ul> * </ul>
* @return the location within the model that best represents the next * @return the location within the model that best represents the next
* location visual position * location visual position
* @exception BadLocationException * @throws BadLocationException
* @exception IllegalArgumentException if <code>direction</code> * @throws IllegalArgumentException if <code>direction</code>
* doesn't have one of the legal values above * doesn't have one of the legal values above
*/ */
public static int getNextVisualPositionFrom(int pos, Position.Bias b, public static int getNextVisualPositionFrom(int pos, Position.Bias b,
@ -670,7 +673,7 @@ public class RSyntaxUtilities implements SwingConstants {
Position.Bias[] biasRet, View view) Position.Bias[] biasRet, View view)
throws BadLocationException { throws BadLocationException {
RSyntaxTextArea target = (RSyntaxTextArea)view.getContainer(); RSyntaxTextArea target = (RSyntaxTextArea) view.getContainer();
biasRet[0] = Position.Bias.Forward; biasRet[0] = Position.Bias.Forward;
// Do we want the "next position" above, below, to the left or right? // Do we want the "next position" above, below, to the left or right?
@ -688,37 +691,39 @@ public class RSyntaxUtilities implements SwingConstants {
// YECK! Ideally, the x location from the magic caret // YECK! Ideally, the x location from the magic caret
// position would be passed in. // position would be passed in.
Point mcp; Point mcp;
if (c != null) if (c != null) {
mcp = c.getMagicCaretPosition(); mcp = c.getMagicCaretPosition();
else } else {
mcp = null; mcp = null;
}
int x; int x;
if (mcp == null) { if (mcp == null) {
Rectangle loc = target.modelToView(pos); Rectangle loc = Objects.requireNonNull(target).modelToView(pos);
x = (loc == null) ? 0 : loc.x; x = (loc == null) ? 0 : loc.x;
} } else {
else {
x = mcp.x; x = mcp.x;
} }
if (direction == NORTH) if (direction == NORTH) {
pos = getPositionAbove(target,pos,x,(TabExpander)view); pos = getPositionAbove(target, pos, x, (TabExpander) view);
else } else {
pos = getPositionBelow(target,pos,x,(TabExpander)view); pos = getPositionBelow(target, pos, x, (TabExpander) view);
}
break; break;
case WEST: case WEST:
if(pos == -1) { if (pos == -1) {
pos = Math.max(0, view.getEndOffset() - 1); pos = Math.max(0, view.getEndOffset() - 1);
} } else {
else {
pos = Math.max(0, pos - 1); pos = Math.max(0, pos - 1);
if (target.isCodeFoldingEnabled()) { if (target.isCodeFoldingEnabled()) {
int last = target.getLineOfOffset(pos+1); int last = target.getLineOfOffset(pos + 1);
int current = target.getLineOfOffset(pos); int current = target.getLineOfOffset(pos);
if (last!=current) { // If moving up a line... if (last != current) { // If moving up a line...
FoldManager fm = target.getFoldManager(); FoldManager fm = target.getFoldManager();
if (fm.isLineHidden(current)) { if (fm.isLineHidden(current)) {
while (--current>0 && fm.isLineHidden(current)); while (--current > 0 && fm.isLineHidden(current)) {
;
}
pos = target.getLineEndOffset(current) - 1; pos = target.getLineEndOffset(current) - 1;
} }
} }
@ -727,21 +732,22 @@ public class RSyntaxUtilities implements SwingConstants {
break; break;
case EAST: case EAST:
if(pos == -1) { if (pos == -1) {
pos = view.getStartOffset(); pos = view.getStartOffset();
} } else {
else {
pos = Math.min(pos + 1, view.getDocument().getLength()); pos = Math.min(pos + 1, view.getDocument().getLength());
if (target.isCodeFoldingEnabled()) { if (target.isCodeFoldingEnabled()) {
int last = target.getLineOfOffset(pos-1); int last = target.getLineOfOffset(pos - 1);
int current = target.getLineOfOffset(pos); int current = target.getLineOfOffset(pos);
if (last!=current) { // If moving down a line... if (last != current) { // If moving down a line...
FoldManager fm = target.getFoldManager(); FoldManager fm = target.getFoldManager();
if (fm.isLineHidden(current)) { if (fm.isLineHidden(current)) {
int lineCount = target.getLineCount(); int lineCount = target.getLineCount();
while (++current<lineCount && fm.isLineHidden(current)); while (++current < lineCount && fm.isLineHidden(current)) {
pos = current==lineCount ? ;
target.getLineEndOffset(last)-1 : // Was the last visible line }
pos = current == lineCount ?
target.getLineEndOffset(last) - 1 : // Was the last visible line
target.getLineStartOffset(current); target.getLineStartOffset(current);
} }
} }
@ -770,23 +776,22 @@ public class RSyntaxUtilities implements SwingConstants {
* @param x the X coordinate >= 0 * @param x the X coordinate >= 0
* @return the position >= 0 if the request can be computed, otherwise * @return the position >= 0 if the request can be computed, otherwise
* a value of -1 will be returned. * a value of -1 will be returned.
* @exception BadLocationException if the offset is out of range * @throws BadLocationException if the offset is out of range
*/ */
public static final int getPositionAbove(RSyntaxTextArea c, int offs, public static final int getPositionAbove(RSyntaxTextArea c, int offs,
float x, TabExpander e) throws BadLocationException { float x, TabExpander e) throws BadLocationException {
TokenOrientedView tov = (TokenOrientedView)e; TokenOrientedView tov = (TokenOrientedView) e;
Token token = tov.getTokenListForPhysicalLineAbove(offs); Token token = tov.getTokenListForPhysicalLineAbove(offs);
if (token==null) if (token == null) {
return -1; return -1;
}
// A line containing only Token.NULL is an empty line. // A line containing only Token.NULL is an empty line.
else if (token.getType()==Token.NULL) { else if (token.getType() == Token.NULL) {
int line = c.getLineOfOffset(offs); // Sure to be >0 ?? int line = c.getLineOfOffset(offs); // Sure to be >0 ??
return c.getLineStartOffset(line-1); return c.getLineStartOffset(line - 1);
} } else {
else {
return token.getListOffset(c, e, 0, x); return token.getListOffset(c, e, 0, x);
} }
@ -804,26 +809,25 @@ public class RSyntaxUtilities implements SwingConstants {
* @param x the X coordinate >= 0 * @param x the X coordinate >= 0
* @return the position >= 0 if the request can be computed, otherwise * @return the position >= 0 if the request can be computed, otherwise
* a value of -1 will be returned. * a value of -1 will be returned.
* @exception BadLocationException if the offset is out of range * @throws BadLocationException if the offset is out of range
*/ */
public static final int getPositionBelow(RSyntaxTextArea c, int offs, public static final int getPositionBelow(RSyntaxTextArea c, int offs,
float x, TabExpander e) throws BadLocationException { float x, TabExpander e) throws BadLocationException {
TokenOrientedView tov = (TokenOrientedView)e; TokenOrientedView tov = (TokenOrientedView) e;
Token token = tov.getTokenListForPhysicalLineBelow(offs); Token token = tov.getTokenListForPhysicalLineBelow(offs);
if (token==null) if (token == null) {
return -1; return -1;
}
// A line containing only Token.NULL is an empty line. // A line containing only Token.NULL is an empty line.
else if (token.getType()==Token.NULL) { else if (token.getType() == Token.NULL) {
int line = c.getLineOfOffset(offs); // Sure to be > c.getLineCount()-1 ?? int line = c.getLineOfOffset(offs); // Sure to be > c.getLineCount()-1 ??
// return c.getLineStartOffset(line+1); // return c.getLineStartOffset(line+1);
FoldManager fm = c.getFoldManager(); FoldManager fm = c.getFoldManager();
line = fm.getVisibleLineBelow(line); line = fm.getVisibleLineBelow(line);
return c.getLineStartOffset(line); return c.getLineStartOffset(line);
} } else {
else {
return token.getListOffset(c, e, 0, x); return token.getListOffset(c, e, 0, x);
} }
@ -841,18 +845,18 @@ return c.getLineStartOffset(line);
* @see #getNextImportantToken(Token, RSyntaxTextArea, int) * @see #getNextImportantToken(Token, RSyntaxTextArea, int)
*/ */
public static final Token getPreviousImportantToken( public static final Token getPreviousImportantToken(
RSyntaxTextArea textArea, int line){ RSyntaxTextArea textArea, int line) {
if (line<0) { if (line < 0) {
return null; return null;
} }
Token t = textArea.getTokenListForLine(line); Token t = textArea.getTokenListForLine(line);
if (t!=null) { if (t != null) {
t = t.getLastNonCommentNonWhitespaceToken(); t = t.getLastNonCommentNonWhitespaceToken();
if (t!=null) { if (t != null) {
return t; return t;
} }
} }
return getPreviousImportantToken(textArea, line-1); return getPreviousImportantToken(textArea, line - 1);
} }
@ -868,10 +872,11 @@ return c.getLineStartOffset(line);
* none of the tokens are at that offset. * none of the tokens are at that offset.
*/ */
public static final Token getTokenAtOffset(Token tokenList, int offset) { public static final Token getTokenAtOffset(Token tokenList, int offset) {
for (Token t=tokenList; t!=null && t.isPaintable(); t=t.getNextToken()){ for (Token t = tokenList; t != null && t.isPaintable(); t = t.getNextToken()) {
if (t.containsPosition(offset)) if (t.containsPosition(offset)) {
return t; return t;
} }
}
return null; return null;
} }
@ -895,18 +900,20 @@ return c.getLineStartOffset(line);
return offs; return offs;
} }
String s = doc.getText(offs, lineEnd-offs-1); String s = doc.getText(offs, lineEnd - offs - 1);
if (s!=null && s.length()>0) { // Should always be true if (s != null && s.length() > 0) { // Should always be true
int i = 0; int i = 0;
int count = s.length(); int count = s.length();
char ch = s.charAt(i); char ch = s.charAt(i);
if (Character.isWhitespace(ch)) { if (Character.isWhitespace(ch)) {
while (i<count && Character.isWhitespace(s.charAt(i++))); while (i < count && Character.isWhitespace(s.charAt(i++))) {
;
} }
else if (Character.isLetterOrDigit(ch)) { } else if (Character.isLetterOrDigit(ch)) {
while (i<count && Character.isLetterOrDigit(s.charAt(i++))); while (i < count && Character.isLetterOrDigit(s.charAt(i++))) {
;
} }
else { } else {
i = 2; i = 2;
} }
offs += i - 1; offs += i - 1;
@ -935,23 +942,22 @@ return c.getLineStartOffset(line);
} }
int lineStart = line.getStartOffset(); int lineStart = line.getStartOffset();
if (offs==lineStart) { // Start of the line. if (offs == lineStart) { // Start of the line.
return offs; return offs;
} }
int endOffs = Math.min(offs+1, doc.getLength()); int endOffs = Math.min(offs + 1, doc.getLength());
String s = doc.getText(lineStart, endOffs-lineStart); String s = doc.getText(lineStart, endOffs - lineStart);
if(s != null && s.length() > 0) { if (s != null && s.length() > 0) {
int i = s.length() - 1; int i = s.length() - 1;
char ch = s.charAt(i); char ch = s.charAt(i);
if (Character.isWhitespace(ch)) { if (Character.isWhitespace(ch)) {
while (i>0 && Character.isWhitespace(s.charAt(i-1))) { while (i > 0 && Character.isWhitespace(s.charAt(i - 1))) {
i--; i--;
} }
offs = lineStart + i; offs = lineStart + i;
} } else if (Character.isLetterOrDigit(ch)) {
else if (Character.isLetterOrDigit(ch)) { while (i > 0 && Character.isLetterOrDigit(s.charAt(i - 1))) {
while (i>0 && Character.isLetterOrDigit(s.charAt(i-1))) {
i--; i--;
} }
offs = lineStart + i; offs = lineStart + i;
@ -968,7 +974,7 @@ return c.getLineStartOffset(line);
* Determines the width of the given token list taking tabs * Determines the width of the given token list taking tabs
* into consideration. This is implemented in a 1.1 style coordinate * into consideration. This is implemented in a 1.1 style coordinate
* system where ints are used and 72dpi is assumed.<p> * system where ints are used and 72dpi is assumed.<p>
* * <p>
* This method also assumes that the passed-in token list begins at * This method also assumes that the passed-in token list begins at
* x-pixel <code>0</code> in the view (for tab purposes). * x-pixel <code>0</code> in the view (for tab purposes).
* *
@ -1000,7 +1006,7 @@ return c.getLineStartOffset(line);
RSyntaxTextArea textArea, RSyntaxTextArea textArea,
TabExpander e, float x0) { TabExpander e, float x0) {
float width = x0; float width = x0;
for (Token t=tokenList; t!=null&&t.isPaintable(); t=t.getNextToken()) { for (Token t = tokenList; t != null && t.isPaintable(); t = t.getNextToken()) {
width += t.getWidth(textArea, e, width); width += t.getWidth(textArea, e, width);
} }
return width - x0; return width - x0;
@ -1029,12 +1035,12 @@ return c.getLineStartOffset(line);
RSyntaxTextArea textArea, TabExpander e, RSyntaxTextArea textArea, TabExpander e,
float x0, int upTo) { float x0, int upTo) {
float width = 0; float width = 0;
for (Token t=tokenList; t!=null&&t.isPaintable(); t=t.getNextToken()) { for (Token t = tokenList; t != null && t.isPaintable(); t = t.getNextToken()) {
if (t.containsPosition(upTo)) { if (t.containsPosition(upTo)) {
return width + t.getWidthUpTo(upTo-t.getOffset(), textArea, e, return width + t.getWidthUpTo(upTo - t.getOffset(), textArea, e,
x0+width); x0 + width);
} }
width += t.getWidth(textArea, e, x0+width); width += t.getWidth(textArea, e, x0 + width);
} }
return width; return width;
} }
@ -1052,7 +1058,7 @@ return c.getLineStartOffset(line);
// We need the first condition as it might be that ch>255, and thus // We need the first condition as it might be that ch>255, and thus
// not in our table. '}' is the highest-valued char in the bracket // not in our table. '}' is the highest-valued char in the bracket
// set. // set.
return ch<='}' && (dataTable[ch]&BRACKET_MASK)>0; return ch <= '}' && (dataTable[ch] & BRACKET_MASK) > 0;
} }
@ -1066,7 +1072,7 @@ return c.getLineStartOffset(line);
// We do it this way as we'd need to do two conditions anyway (first // We do it this way as we'd need to do two conditions anyway (first
// to check that ch<255 so it can index into our table, then whether // to check that ch<255 so it can index into our table, then whether
// that table position has the digit mask). // that table position has the digit mask).
return ch>='0' && ch<='9'; return ch >= '0' && ch <= '9';
} }
@ -1082,7 +1088,7 @@ return c.getLineStartOffset(line);
// We need the first condition as it could be that ch>255 (and thus // We need the first condition as it could be that ch>255 (and thus
// not a valid index into our table). 'f' is the highest-valued // not a valid index into our table). 'f' is the highest-valued
// char that is a valid hex character. // char that is a valid hex character.
return (ch<='f') && (dataTable[ch]&HEX_CHARACTER_MASK)>0; return (ch <= 'f') && (dataTable[ch] & HEX_CHARACTER_MASK) > 0;
} }
@ -1097,7 +1103,7 @@ return c.getLineStartOffset(line);
// We need the first condition as it could be that ch>255 (and thus // We need the first condition as it could be that ch>255 (and thus
// not a valid index into our table). '~' is the highest-valued // not a valid index into our table). '~' is the highest-valued
// char that is a valid Java operator. // char that is a valid Java operator.
return (ch<='~') && (dataTable[ch]&JAVA_OPERATOR_MASK)>0; return (ch <= '~') && (dataTable[ch] & JAVA_OPERATOR_MASK) > 0;
} }
@ -1110,7 +1116,7 @@ return c.getLineStartOffset(line);
public static final boolean isLetter(char ch) { public static final boolean isLetter(char ch) {
// We need the first condition as it could be that ch>255 (and thus // We need the first condition as it could be that ch>255 (and thus
// not a valid index into our table). // not a valid index into our table).
return (ch<='z') && (dataTable[ch]&LETTER_MASK)>0; return (ch <= 'z') && (dataTable[ch] & LETTER_MASK) > 0;
} }
@ -1123,7 +1129,7 @@ return c.getLineStartOffset(line);
public static final boolean isLetterOrDigit(char ch) { public static final boolean isLetterOrDigit(char ch) {
// We need the first condition as it could be that ch>255 (and thus // We need the first condition as it could be that ch>255 (and thus
// not a valid index into our table). // not a valid index into our table).
return (ch<='z') && (dataTable[ch]&LETTER_OR_DIGIT_MASK)>0; return (ch <= 'z') && (dataTable[ch] & LETTER_OR_DIGIT_MASK) > 0;
} }
@ -1137,7 +1143,7 @@ return c.getLineStartOffset(line);
* @see #getHyperlinkForeground() * @see #getHyperlinkForeground()
*/ */
public static final boolean isLightForeground(Color fg) { public static final boolean isLightForeground(Color fg) {
return fg.getRed()>0xa0 && fg.getGreen()>0xa0 && fg.getBlue()>0xa0; return fg.getRed() > 0xa0 && fg.getGreen() > 0xa0 && fg.getBlue() > 0xa0;
} }
@ -1153,7 +1159,7 @@ return c.getLineStartOffset(line);
// We do it this way as we'd need to do two conditions anyway (first // We do it this way as we'd need to do two conditions anyway (first
// to check that ch<255 so it can index into our table, then whether // to check that ch<255 so it can index into our table, then whether
// that table position has the whitespace mask). // that table position has the whitespace mask).
return ch==' ' || ch=='\t'; return ch == ' ' || ch == '\t';
} }
@ -1168,21 +1174,21 @@ return c.getLineStartOffset(line);
public static boolean regexCanFollowInJavaScript(Token t) { public static boolean regexCanFollowInJavaScript(Token t) {
char ch; char ch;
// We basically try to mimic Eclipse's JS editor's behavior here. // We basically try to mimic Eclipse's JS editor's behavior here.
return t==null || return t == null ||
//t.isOperator() || //t.isOperator() ||
(t.length()==1 && ( (t.length() == 1 && (
(ch=t.charAt(0))=='=' || (ch = t.charAt(0)) == '=' ||
ch=='(' || ch == '(' ||
ch==',' || ch == ',' ||
ch=='?' || ch == '?' ||
ch==':' || ch == ':' ||
ch=='[' || ch == '[' ||
ch=='!' || ch == '!' ||
ch=='&' ch == '&'
)) || )) ||
/* Operators "==", "===", "!=", "!==" */ /* Operators "==", "===", "!=", "!==" */
(t.getType()==Token.OPERATOR && (t.getType() == Token.OPERATOR &&
t.charAt(t.length()-1)=='=') || t.charAt(t.length() - 1) == '=') ||
t.is(Token.RESERVED_WORD_2, JS_KEYWORD_RETURN); t.is(Token.RESERVED_WORD_2, JS_KEYWORD_RETURN);
} }
@ -1203,8 +1209,9 @@ return c.getLineStartOffset(line);
// We do it this way as we'd need to do two conditions anyway (first // We do it this way as we'd need to do two conditions anyway (first
// to check that ch<255 so it can index into our table, then whether // to check that ch<255 so it can index into our table, then whether
// that table position has the upper-case mask). // that table position has the upper-case mask).
if (ch>='A' && ch<='Z') if (ch >= 'A' && ch <= 'Z') {
return (char)(ch | 0x20); return (char) (ch | 0x20);
}
return ch; return ch;
} }
@ -1231,17 +1238,18 @@ return c.getLineStartOffset(line);
private static final int getOSImpl() { private static final int getOSImpl() {
int os = OS_OTHER; int os = OS_OTHER;
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
if (osName!=null) { // Should always be true. if (osName != null) { // Should always be true.
osName = osName.toLowerCase(); osName = osName.toLowerCase();
if (osName.indexOf("windows") > -1) if (osName.contains("windows")) {
os = OS_WINDOWS; os = OS_WINDOWS;
else if (osName.indexOf("mac os x") > -1) } else if (osName.contains("mac os x")) {
os = OS_MAC_OSX; os = OS_MAC_OSX;
else if (osName.indexOf("linux") > -1) } else if (osName.contains("linux")) {
os = OS_LINUX; os = OS_LINUX;
else } else {
os = OS_OTHER; os = OS_OTHER;
} }
}
return os; return os;
} }
@ -1260,11 +1268,11 @@ return c.getLineStartOffset(line);
int flags = 0; int flags = 0;
if (!matchCase) { if (!matchCase) {
flags = Pattern.CASE_INSENSITIVE|Pattern.UNICODE_CASE; flags = Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE;
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i=0; i<wildcard.length(); i++) { for (int i = 0; i < wildcard.length(); i++) {
char ch = wildcard.charAt(i); char ch = wildcard.charAt(i);
switch (ch) { switch (ch) {
case '*': case '*':
@ -1274,18 +1282,23 @@ return c.getLineStartOffset(line);
sb.append('.'); sb.append('.');
break; break;
case '^': case '^':
if (i>0 || escapeStartChar) { if (i > 0 || escapeStartChar) {
sb.append('\\'); sb.append('\\');
} }
sb.append('^'); sb.append('^');
break; break;
case '\\': case '\\':
case '.': case '|': case '.':
case '+': case '-': case '|':
case '+':
case '-':
case '$': case '$':
case '[': case ']': case '[':
case '{': case '}': case ']':
case '(': case ')': case '{':
case '}':
case '(':
case ')':
sb.append('\\').append(ch); sb.append('\\').append(ch);
break; break;
default: default:

229
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java

@ -9,24 +9,37 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.text.*;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import javax.swing.event.DocumentEvent;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.PlainDocument;
import javax.swing.text.Position;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
/** /**
* The <code>javax.swing.text.View</code> object used by {@link RSyntaxTextArea} * The <code>javax.swing.text.View</code> object used by {@link RSyntaxTextArea}
* when word wrap is disabled. It implements syntax highlighting for * when word wrap is disabled. It implements syntax highlighting for
* programming languages using the colors and font styles specified by the * programming languages using the colors and font styles specified by the
* <code>RSyntaxTextArea</code>.<p> * <code>RSyntaxTextArea</code>.<p>
* * <p>
* You don't really have to do anything to use this class, as * You don't really have to do anything to use this class, as
* {@link RSyntaxTextAreaUI} automatically sets the text area's view to be * {@link RSyntaxTextAreaUI} automatically sets the text area's view to be
* an instance of this class if word wrap is disabled.<p> * an instance of this class if word wrap is disabled.<p>
* * <p>
* The tokens that specify how to paint the syntax-highlighted text are gleaned * The tokens that specify how to paint the syntax-highlighted text are gleaned
* from the text area's {@link RSyntaxDocument}. * from the text area's {@link RSyntaxDocument}.
* *
@ -105,7 +118,7 @@ public class SyntaxView extends View implements TabExpander,
tabSize = getTabSize() * metrics.charWidth(' '); tabSize = getTabSize() * metrics.charWidth(' ');
Element lines = getElement(); Element lines = getElement();
int n = lines.getElementCount(); int n = lines.getElementCount();
for (int i=0; i<n; i++) { for (int i = 0; i < n; i++) {
Element line = lines.getElement(i); Element line = lines.getElement(i);
float w = getLineWidth(i); float w = getLineWidth(i);
if (w > longLineWidth) { if (w > longLineWidth) {
@ -149,8 +162,7 @@ public class SyntaxView extends View implements TabExpander,
if ((area0 != null) && (area1 != null)) { if ((area0 != null) && (area1 != null)) {
Rectangle dmg = area0.union(area1); // damage. Rectangle dmg = area0.union(area1); // damage.
host.repaint(dmg.x, dmg.y, dmg.width, dmg.height); host.repaint(dmg.x, dmg.y, dmg.width, dmg.height);
} } else
else
host.repaint(); host.repaint();
} }
} }
@ -174,8 +186,8 @@ public class SyntaxView extends View implements TabExpander,
float nextX = x; // The x-value at the end of our text. float nextX = x; // The x-value at the end of our text.
while (token!=null && token.isPaintable() && nextX<clipEnd) { while (token != null && token.isPaintable() && nextX < clipEnd) {
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
token = token.getNextToken(); token = token.getNextToken();
} }
@ -212,15 +224,15 @@ public class SyntaxView extends View implements TabExpander,
float nextX = x; // The x-value at the end of our text. float nextX = x; // The x-value at the end of our text.
while (token!=null && token.isPaintable() && nextX<clipEnd) { while (token != null && token.isPaintable() && nextX < clipEnd) {
// Selection starts in this token // Selection starts in this token
if (token.containsPosition(selStart)) { if (token.containsPosition(selStart)) {
if (selStart>token.getOffset()) { if (selStart > token.getOffset()) {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selStart - tempToken.getOffset(); tempToken.textCount = selStart - tempToken.getOffset();
nextX = painter.paint(tempToken,g,nextX,y,host, this, clipStart); nextX = painter.paint(tempToken, g, nextX, y, host, this, clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(selStart); tempToken.makeStartAt(selStart);
// Clone required since token and tempToken must be // Clone required since token and tempToken must be
@ -229,20 +241,19 @@ public class SyntaxView extends View implements TabExpander,
} }
int tokenLen = token.length(); int tokenLen = token.length();
int selCount = Math.min(tokenLen, selEnd-token.getOffset()); int selCount = Math.min(tokenLen, selEnd - token.getOffset());
if (selCount==tokenLen) { if (selCount == tokenLen) {
nextX = painter.paintSelected(token, g, nextX,y, host, nextX = painter.paintSelected(token, g, nextX, y, host,
this, clipStart); this, clipStart);
} } else {
else {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selCount; tempToken.textCount = selCount;
nextX = painter.paintSelected(tempToken, g, nextX,y, host, nextX = painter.paintSelected(tempToken, g, nextX, y, host,
this, clipStart); this, clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(token.getOffset() + selCount); tempToken.makeStartAt(token.getOffset() + selCount);
token = tempToken; token = tempToken;
nextX = painter.paint(token, g, nextX,y, host, this, nextX = painter.paint(token, g, nextX, y, host, this,
clipStart); clipStart);
} }
@ -252,24 +263,24 @@ public class SyntaxView extends View implements TabExpander,
else if (token.containsPosition(selEnd)) { else if (token.containsPosition(selEnd)) {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selEnd - tempToken.getOffset(); tempToken.textCount = selEnd - tempToken.getOffset();
nextX = painter.paintSelected(tempToken, g, nextX,y, host, this, nextX = painter.paintSelected(tempToken, g, nextX, y, host, this,
clipStart); clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(selEnd); tempToken.makeStartAt(selEnd);
token = tempToken; token = tempToken;
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
} }
// This token is entirely selected // This token is entirely selected
else if (token.getOffset()>=selStart && else if (token.getOffset() >= selStart &&
token.getEndOffset()<=selEnd) { token.getEndOffset() <= selEnd) {
nextX = painter.paintSelected(token, g, nextX,y, host, this, nextX = painter.paintSelected(token, g, nextX, y, host, this,
clipStart); clipStart);
} }
// This token is entirely unselected // This token is entirely unselected
else { else {
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
} }
token = token.getNextToken(); token = token.getNextToken();
@ -298,10 +309,10 @@ public class SyntaxView extends View implements TabExpander,
* @return The width of the line. * @return The width of the line.
*/ */
private float getLineWidth(int lineNumber) { private float getLineWidth(int lineNumber) {
Token tokenList = ((RSyntaxDocument)getDocument()). Token tokenList = ((RSyntaxDocument) getDocument()).
getTokenListForLine(lineNumber); getTokenListForLine(lineNumber);
return RSyntaxUtilities.getTokenListWidth(tokenList, return RSyntaxUtilities.getTokenListWidth(tokenList,
(RSyntaxTextArea)getContainer(), (RSyntaxTextArea) getContainer(),
this); this);
} }
@ -320,8 +331,8 @@ public class SyntaxView extends View implements TabExpander,
* SwingConstants.NORTH, or SwingConstants.SOUTH. * SwingConstants.NORTH, or SwingConstants.SOUTH.
* @return the location within the model that best represents the next * @return the location within the model that best represents the next
* location visual position. * location visual position.
* @exception BadLocationException * @throws BadLocationException
* @exception IllegalArgumentException for an invalid direction * @throws IllegalArgumentException for an invalid direction
*/ */
@Override @Override
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
@ -341,7 +352,7 @@ public class SyntaxView extends View implements TabExpander,
* Typically the view is told to render into the span * Typically the view is told to render into the span
* that is returned, although there is no guarantee. * that is returned, although there is no guarantee.
* The parent may choose to resize or break the view. * The parent may choose to resize or break the view.
* @exception IllegalArgumentException for an invalid axis * @throws IllegalArgumentException for an invalid axis
*/ */
@Override @Override
public float getPreferredSpan(int axis) { public float getPreferredSpan(int axis) {
@ -357,13 +368,13 @@ public class SyntaxView extends View implements TabExpander,
// We update lineHeight here as when this method is first // We update lineHeight here as when this method is first
// called, lineHeight isn't initialized. If we don't do it // called, lineHeight isn't initialized. If we don't do it
// here, we get no vertical scrollbar (as lineHeight==0). // here, we get no vertical scrollbar (as lineHeight==0).
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
// return getElement().getElementCount() * lineHeight; // return getElement().getElementCount() * lineHeight;
int visibleLineCount = getElement().getElementCount(); int visibleLineCount = getElement().getElementCount();
if (host.isCodeFoldingEnabled()) { if (host.isCodeFoldingEnabled()) {
visibleLineCount -= host.getFoldManager().getHiddenLineCount(); visibleLineCount -= host.getFoldManager().getHiddenLineCount();
} }
return visibleLineCount * lineHeight; return visibleLineCount * lineHeight;
default: default:
throw new IllegalArgumentException("Invalid axis: " + axis); throw new IllegalArgumentException("Invalid axis: " + axis);
} }
@ -378,7 +389,7 @@ return visibleLineCount * lineHeight;
*/ */
private final int getRhsCorrection() { private final int getRhsCorrection() {
int rhsCorrection = 10; int rhsCorrection = 10;
if (host!=null) { if (host != null) {
rhsCorrection = host.getRightHandSideCorrection(); rhsCorrection = host.getRightHandSideCorrection();
} }
return rhsCorrection; return rhsCorrection;
@ -391,7 +402,7 @@ return visibleLineCount * lineHeight;
* @return The tab size. * @return The tab size.
*/ */
private int getTabSize() { private int getTabSize() {
Integer i = (Integer)getDocument().getProperty( Integer i = (Integer) getDocument().getProperty(
PlainDocument.tabSizeAttribute); PlainDocument.tabSizeAttribute);
int size = (i != null) ? i.intValue() : 5; int size = (i != null) ? i.intValue() : 5;
return size; return size;
@ -411,22 +422,21 @@ return visibleLineCount * lineHeight;
* the document, <code>null</code> is returned. * the document, <code>null</code> is returned.
*/ */
public Token getTokenListForPhysicalLineAbove(int offset) { public Token getTokenListForPhysicalLineAbove(int offset) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Element map = document.getDefaultRootElement(); Element map = document.getDefaultRootElement();
int line = map.getElementIndex(offset); int line = map.getElementIndex(offset);
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
if (fm==null) { if (fm == null) {
line--; line--;
if (line>=0) { if (line >= 0) {
return document.getTokenListForLine(line); return document.getTokenListForLine(line);
} }
} } else {
else {
line = fm.getVisibleLineAbove(line); line = fm.getVisibleLineAbove(line);
if (line>=0) { if (line >= 0) {
return document.getTokenListForLine(line); return document.getTokenListForLine(line);
} }
} }
// int line = map.getElementIndex(offset) - 1; // int line = map.getElementIndex(offset) - 1;
// if (line>=0) // if (line>=0)
// return document.getTokenListForLine(line); // return document.getTokenListForLine(line);
@ -447,22 +457,21 @@ else {
* line in the document, <code>null</code> is returned. * line in the document, <code>null</code> is returned.
*/ */
public Token getTokenListForPhysicalLineBelow(int offset) { public Token getTokenListForPhysicalLineBelow(int offset) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Element map = document.getDefaultRootElement(); Element map = document.getDefaultRootElement();
int lineCount = map.getElementCount(); int lineCount = map.getElementCount();
int line = map.getElementIndex(offset); int line = map.getElementIndex(offset);
if (!host.isCodeFoldingEnabled()) { if (!host.isCodeFoldingEnabled()) {
if (line<lineCount-1) { if (line < lineCount - 1) {
return document.getTokenListForLine(line+1); return document.getTokenListForLine(line + 1);
} }
} } else {
else {
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
line = fm.getVisibleLineBelow(line); line = fm.getVisibleLineBelow(line);
if (line>=0 && line<lineCount) { if (line >= 0 && line < lineCount) {
return document.getTokenListForLine(line); return document.getTokenListForLine(line);
} }
} }
// int line = map.getElementIndex(offset); // int line = map.getElementIndex(offset);
// int lineCount = map.getElementCount(); // int lineCount = map.getElementCount();
// if (line<lineCount-1) // if (line<lineCount-1)
@ -500,13 +509,13 @@ else {
// NOTE: lineHeight is not initially set here, leading to the // NOTE: lineHeight is not initially set here, leading to the
// current line not being highlighted when a document is first // current line not being highlighted when a document is first
// opened. So, we set it here just in case. // opened. So, we set it here just in case.
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
if (host.isCodeFoldingEnabled()) { if (host != null && host.isCodeFoldingEnabled()) {
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
int hiddenCount = fm.getHiddenLineCountAbove(line); int hiddenCount = fm.getHiddenLineCountAbove(line);
line -= hiddenCount; line -= hiddenCount;
} }
r = new Rectangle(alloc.x, alloc.y + line*lineHeight, r = new Rectangle(alloc.x, alloc.y + line * lineHeight,
alloc.width, lineHeight); alloc.width, lineHeight);
} }
return r; return r;
@ -520,7 +529,7 @@ if (host.isCodeFoldingEnabled()) {
* @param pos the position to convert >= 0 * @param pos the position to convert >= 0
* @param a the allocated region to render into * @param a the allocated region to render into
* @return the bounding box of the given position * @return the bounding box of the given position
* @exception BadLocationException if the given position does not * @throws BadLocationException if the given position does not
* represent a valid location in the associated document * represent a valid location in the associated document
* @see View#modelToView * @see View#modelToView
*/ */
@ -530,7 +539,7 @@ if (host.isCodeFoldingEnabled()) {
// line coordinates // line coordinates
Element map = getElement(); Element map = getElement();
RSyntaxDocument doc = (RSyntaxDocument)getDocument(); RSyntaxDocument doc = (RSyntaxDocument) getDocument();
int lineIndex = map.getElementIndex(pos); int lineIndex = map.getElementIndex(pos);
Token tokenList = doc.getTokenListForLine(lineIndex); Token tokenList = doc.getTokenListForLine(lineIndex);
Rectangle lineArea = lineToRect(a, lineIndex); Rectangle lineArea = lineToRect(a, lineIndex);
@ -542,7 +551,7 @@ if (host.isCodeFoldingEnabled()) {
// We use this method instead as it returns the actual bounding box, // We use this method instead as it returns the actual bounding box,
// not just the x-coordinate. // not just the x-coordinate.
lineArea = tokenList.listOffsetToView( lineArea = tokenList.listOffsetToView(
(RSyntaxTextArea)getContainer(), this, pos, (RSyntaxTextArea) getContainer(), this, pos,
tabBase, lineArea); tabBase, lineArea);
return lineArea; return lineArea;
@ -554,7 +563,7 @@ if (host.isCodeFoldingEnabled()) {
* Provides a mapping, for a given region, from the document model * Provides a mapping, for a given region, from the document model
* coordinate space to the view coordinate space. The specified region is * coordinate space to the view coordinate space. The specified region is
* created as a union of the first and last character positions.<p> * created as a union of the first and last character positions.<p>
* * <p>
* This is implemented to subtract the width of the second character, as * This is implemented to subtract the width of the second character, as
* this view's <code>modelToView</code> actually returns the width of the * this view's <code>modelToView</code> actually returns the width of the
* character instead of "1" or "0" like the View implementations in * character instead of "1" or "0" like the View implementations in
@ -578,9 +587,9 @@ if (host.isCodeFoldingEnabled()) {
* @param a the area of the view, which encompasses the requested region * @param a the area of the view, which encompasses the requested region
* @return the bounding box which is a union of the region specified * @return the bounding box which is a union of the region specified
* by the first and last character positions * by the first and last character positions
* @exception BadLocationException if the given position does * @throws BadLocationException if the given position does
* not represent a valid location in the associated document * not represent a valid location in the associated document
* @exception IllegalArgumentException if <code>b0</code> or * @throws IllegalArgumentException if <code>b0</code> or
* <code>b1</code> are not one of the * <code>b1</code> are not one of the
* legal <code>Position.Bias</code> values listed above * legal <code>Position.Bias</code> values listed above
* @see View#viewToModel * @see View#viewToModel
@ -592,7 +601,7 @@ if (host.isCodeFoldingEnabled()) {
Shape s0 = modelToView(p0, a, b0); Shape s0 = modelToView(p0, a, b0);
Shape s1; Shape s1;
if (p1 ==getEndOffset()) { if (p1 == getEndOffset()) {
try { try {
s1 = modelToView(p1, a, b1); s1 = modelToView(p1, a, b1);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
@ -600,20 +609,19 @@ if (host.isCodeFoldingEnabled()) {
} }
if (s1 == null) { if (s1 == null) {
// Assume extends left to right. // Assume extends left to right.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a :
a.getBounds(); a.getBounds();
s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y, s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y,
1, alloc.height); 1, alloc.height);
} }
} } else {
else {
s1 = modelToView(p1, a, b1); s1 = modelToView(p1, a, b1);
} }
Rectangle r0 = s0 instanceof Rectangle ? (Rectangle)s0 : s0.getBounds(); Rectangle r0 = s0 instanceof Rectangle ? (Rectangle) s0 : s0.getBounds();
Rectangle r1 = s1 instanceof Rectangle ? (Rectangle)s1 : s1.getBounds(); Rectangle r1 = s1 instanceof Rectangle ? (Rectangle) s1 : s1.getBounds();
if (r0.y != r1.y) { if (r0.y != r1.y) {
// If it spans lines, force it to be the width of the view. // If it spans lines, force it to be the width of the view.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a :
a.getBounds(); a.getBounds();
r0.x = alloc.x; r0.x = alloc.x;
r0.width = alloc.width; r0.width = alloc.width;
@ -627,7 +635,7 @@ if (host.isCodeFoldingEnabled()) {
// this, one character too many is highlighted thanks to our // this, one character too many is highlighted thanks to our
// modelToView() implementation returning the actual width of the // modelToView() implementation returning the actual width of the
// character requested! // character requested!
if (p1>p0) r0.width -= r1.width; if (p1 > p0) r0.width -= r1.width;
return r0; return r0;
@ -647,7 +655,7 @@ if (host.isCodeFoldingEnabled()) {
public float nextTabStop(float x, int tabOffset) { public float nextTabStop(float x, int tabOffset) {
if (tabSize == 0) if (tabSize == 0)
return x; return x;
int ntabs = (((int)x) - tabBase) / tabSize; int ntabs = (((int) x) - tabBase) / tabSize;
return tabBase + ((ntabs + 1) * tabSize); return tabBase + ((ntabs + 1) * tabSize);
} }
@ -662,12 +670,12 @@ if (host.isCodeFoldingEnabled()) {
@Override @Override
public void paint(Graphics g, Shape a) { public void paint(Graphics g, Shape a) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Rectangle alloc = a.getBounds(); Rectangle alloc = a.getBounds();
tabBase = alloc.x; tabBase = alloc.x;
host = (RSyntaxTextArea)getContainer(); host = (RSyntaxTextArea) getContainer();
Rectangle clip = g.getClipBounds(); Rectangle clip = g.getClipBounds();
// An attempt to speed things up for files with long lines. Note that // An attempt to speed things up for files with long lines. Note that
@ -695,52 +703,51 @@ if (host.isCodeFoldingEnabled()) {
boolean useSelectedTextColor = host.getUseSelectedTextColor(); boolean useSelectedTextColor = host.getUseSelectedTextColor();
RSyntaxTextAreaHighlighter h = RSyntaxTextAreaHighlighter h =
(RSyntaxTextAreaHighlighter)host.getHighlighter(); (RSyntaxTextAreaHighlighter) host.getHighlighter();
Graphics2D g2d = (Graphics2D)g; Graphics2D g2d = (Graphics2D) g;
Token token; Token token;
//System.err.println("Painting lines: " + linesAbove + " to " + (endLine-1)); //System.err.println("Painting lines: " + linesAbove + " to " + (endLine-1));
TokenPainter painter = host.getTokenPainter(); TokenPainter painter = host.getTokenPainter();
int line = linesAbove; int line = linesAbove;
//int count = 0; //int count = 0;
while (y<clip.y+clip.height+ascent && line<lineCount) { while (y < clip.y + clip.height + ascent && line < lineCount) {
Fold fold = fm.getFoldForLine(line); Fold fold = fm.getFoldForLine(line);
Element lineElement = map.getElement(line); Element lineElement = map.getElement(line);
int startOffset = lineElement.getStartOffset(); int startOffset = lineElement.getStartOffset();
//int endOffset = (line==lineCount ? lineElement.getEndOffset()-1 : //int endOffset = (line==lineCount ? lineElement.getEndOffset()-1 :
// lineElement.getEndOffset()-1); // lineElement.getEndOffset()-1);
int endOffset = lineElement.getEndOffset()-1; // Why always "-1"? int endOffset = lineElement.getEndOffset() - 1; // Why always "-1"?
h.paintLayeredHighlights(g2d, startOffset, endOffset, h.paintLayeredHighlights(g2d, startOffset, endOffset,
a, host, this); a, host, this);
// Paint a line of text. // Paint a line of text.
token = document.getTokenListForLine(line); token = document.getTokenListForLine(line);
if (!useSelectedTextColor || selStart==selEnd || if (!useSelectedTextColor || selStart == selEnd ||
(startOffset>=selEnd || endOffset<selStart)) { (startOffset >= selEnd || endOffset < selStart)) {
drawLine(painter, token, g2d, x,y); drawLine(painter, token, g2d, x, y);
} } else {
else {
//System.out.println("Drawing line with selection: " + line); //System.out.println("Drawing line with selection: " + line);
drawLineWithSelection(painter,token,g2d, x,y, selStart, selEnd); drawLineWithSelection(painter, token, g2d, x, y, selStart, selEnd);
} }
if (fold!=null && fold.isCollapsed()) { if (fold != null && fold.isCollapsed()) {
// Visible indicator of collapsed lines // Visible indicator of collapsed lines
Color c = RSyntaxUtilities.getFoldedLineBottomColor(host); Color c = RSyntaxUtilities.getFoldedLineBottomColor(host);
if (c!=null) { if (c != null) {
g.setColor(c); g.setColor(c);
g.drawLine(x,y+lineHeight-ascent-1, g.drawLine(x, y + lineHeight - ascent - 1,
alloc.width,y+lineHeight-ascent-1); alloc.width, y + lineHeight - ascent - 1);
} }
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"
do { do {
int hiddenLineCount = fold.getLineCount(); int hiddenLineCount = fold.getLineCount();
if (hiddenLineCount==0) { if (hiddenLineCount == 0) {
// Fold parser identified a zero-line fold region. // Fold parser identified a zero-line fold region.
// This is really a bug, but we'll be graceful here // This is really a bug, but we'll be graceful here
// and avoid an infinite loop. // and avoid an infinite loop.
@ -748,7 +755,7 @@ if (host.isCodeFoldingEnabled()) {
} }
line += hiddenLineCount; line += hiddenLineCount;
fold = fm.getFoldForLine(line); fold = fm.getFoldForLine(line);
} while (fold!=null && fold.isCollapsed()); } while (fold != null && fold.isCollapsed());
} }
@ -824,7 +831,7 @@ if (host.isCodeFoldingEnabled()) {
if (added != null) { if (added != null) {
int addedAt = ec.getIndex(); // FIXME: Is this correct????? int addedAt = ec.getIndex(); // FIXME: Is this correct?????
for (int i = 0; i < added.length; i++) for (int i = 0; i < added.length; i++)
possiblyUpdateLongLine(added[i], addedAt+i); possiblyUpdateLongLine(added[i], addedAt + i);
} }
if (removed != null) { if (removed != null) {
for (int i = 0; i < removed.length; i++) { for (int i = 0; i < removed.length; i++) {
@ -841,14 +848,12 @@ if (host.isCodeFoldingEnabled()) {
// This occurs when syntax highlighting only changes on lines // This occurs when syntax highlighting only changes on lines
// (i.e. beginning a multiline comment). // (i.e. beginning a multiline comment).
else if (changes.getType()==DocumentEvent.EventType.CHANGE) { else if (changes.getType() == DocumentEvent.EventType.CHANGE) {
//System.err.println("Updating the damage due to a CHANGE event..."); //System.err.println("Updating the damage due to a CHANGE event...");
int startLine = changes.getOffset(); int startLine = changes.getOffset();
int endLine = changes.getLength(); int endLine = changes.getLength();
damageLineRange(startLine,endLine, a, host); damageLineRange(startLine, endLine, a, host);
} } else {
else {
Element map = getElement(); Element map = getElement();
int line = map.getElementIndex(changes.getOffset()); int line = map.getElementIndex(changes.getOffset());
damageLineRange(line, line, a, host); damageLineRange(line, line, a, host);
@ -861,14 +866,12 @@ if (host.isCodeFoldingEnabled()) {
// because it has gotten longer. // because it has gotten longer.
longLineWidth = getLineWidth(line); longLineWidth = getLineWidth(line);
preferenceChanged(null, true, false); preferenceChanged(null, true, false);
} } else {
else {
// If long line gets updated, update the status bars too. // If long line gets updated, update the status bars too.
if (possiblyUpdateLongLine(e, line)) if (possiblyUpdateLongLine(e, line))
preferenceChanged(null, true, false); preferenceChanged(null, true, false);
} }
} } else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
if (map.getElement(line) == longLine) { if (map.getElement(line) == longLine) {
// removed from longest line... recalc // removed from longest line... recalc
longLineWidth = -1; // Must do this! longLineWidth = -1; // Must do this!
@ -884,7 +887,7 @@ if (host.isCodeFoldingEnabled()) {
* Checks to see if the font metrics and longest line are up-to-date. * Checks to see if the font metrics and longest line are up-to-date.
*/ */
private void updateMetrics() { private void updateMetrics() {
host = (RSyntaxTextArea)getContainer(); host = (RSyntaxTextArea) getContainer();
Font f = host.getFont(); Font f = host.getFont();
if (font != f) { if (font != f) {
// The font changed, we need to recalculate the longest line! // The font changed, we need to recalculate the longest line!
@ -910,7 +913,7 @@ if (host.isCodeFoldingEnabled()) {
bias[0] = Position.Bias.Forward; bias[0] = Position.Bias.Forward;
Rectangle alloc = a.getBounds(); Rectangle alloc = a.getBounds();
RSyntaxDocument doc = (RSyntaxDocument)getDocument(); RSyntaxDocument doc = (RSyntaxDocument) getDocument();
int x = (int) fx; int x = (int) fx;
int y = (int) fy; int y = (int) fy;
@ -936,9 +939,9 @@ if (host.isCodeFoldingEnabled()) {
Element map = doc.getDefaultRootElement(); Element map = doc.getDefaultRootElement();
int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() ); int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() );
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
//System.out.print("--- " + lineIndex); //System.out.print("--- " + lineIndex);
lineIndex += fm.getHiddenLineCountAbove(lineIndex, true); lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
//System.out.println(" => " + lineIndex); //System.out.println(" => " + lineIndex);
if (lineIndex >= map.getElementCount()) { if (lineIndex >= map.getElementCount()) {
return host.getLastVisibleOffset(); return host.getLastVisibleOffset();
@ -960,9 +963,9 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
Token tokenList = doc.getTokenListForLine(lineIndex); Token tokenList = doc.getTokenListForLine(lineIndex);
tabBase = alloc.x; tabBase = alloc.x;
int offs = tokenList.getListOffset( int offs = tokenList.getListOffset(
(RSyntaxTextArea)getContainer(), (RSyntaxTextArea) getContainer(),
this, tabBase, x); this, tabBase, x);
return offs!=-1 ? offs : p0; return offs != -1 ? offs : p0;
} }
} // End of else. } // End of else.
@ -981,11 +984,13 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
// NOTE: lineHeight is not initially set here, leading to the // NOTE: lineHeight is not initially set here, leading to the
// current line not being highlighted when a document is first // current line not being highlighted when a document is first
// opened. So, we set it here just in case. // opened. So, we set it here just in case.
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
if (host != null) {
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
if (!fm.isLineHidden(line)) { if (!fm.isLineHidden(line)) {
line -= fm.getHiddenLineCountAbove(line); line -= fm.getHiddenLineCountAbove(line);
return alloc.y + line*lineHeight; return alloc.y + line * lineHeight;
}
} }
} }

38
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java

@ -9,15 +9,33 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import java.awt.*;
import javax.swing.text.*;
import javax.swing.text.Position.Bias;
import javax.swing.event.*;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter; import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
import com.fr.stable.CommonUtils;
import javax.swing.event.DocumentEvent;
import javax.swing.text.BadLocationException;
import javax.swing.text.BoxView;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.LayeredHighlighter;
import javax.swing.text.PlainDocument;
import javax.swing.text.Position;
import javax.swing.text.Position.Bias;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
/** /**
@ -93,7 +111,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander,
int p = p0; int p = p0;
RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer(); RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer();
float currentWidth = getWidth(); float currentWidth = getWidth();
if (currentWidth==Integer.MAX_VALUE) if (CommonUtils.equals(currentWidth, Integer.MAX_VALUE))
currentWidth = getPreferredSpan(X_AXIS); currentWidth = getPreferredSpan(X_AXIS);
// Make sure width>0; this is a huge hack to fix a bug where // Make sure width>0; this is a huge hack to fix a bug where
// loading text into an RTextArea before it is visible if word wrap // loading text into an RTextArea before it is visible if word wrap
@ -128,7 +146,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander,
//System.err.println("------ ending calculateBreakPosition() --------"); //System.err.println("------ ending calculateBreakPosition() --------");
// return p; // return p;
return p + 1; return p + 1;
} }
//private int getBreakLocation(Token t, FontMetrics fm, int x0, int x, //private int getBreakLocation(Token t, FontMetrics fm, int x0, int x,
@ -1044,8 +1062,8 @@ return p + 1;
// Code folding may have hidden the last line. If so, return the last // Code folding may have hidden the last line. If so, return the last
// visible offset instead of the last offset. // visible offset instead of the last offset.
if (host.isCodeFoldingEnabled() && v==getView(getViewCount()-1) && if (v != null && host.isCodeFoldingEnabled() && v == getView(getViewCount() - 1) &&
offs==v.getEndOffset()-1) { offs == v.getEndOffset() - 1) {
offs = host.getLastVisibleOffset(); offs = host.getLastVisibleOffset();
} }
@ -1170,7 +1188,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
switch (axis) { switch (axis) {
case View.X_AXIS: case View.X_AXIS:
float width = getWidth(); float width = getWidth();
if (width == Integer.MAX_VALUE) { if (CommonUtils.equals(width, Integer.MAX_VALUE)) {
// We have been initially set to MAX_VALUE, but we don't // We have been initially set to MAX_VALUE, but we don't
// want this as our preferred. // want this as our preferred.
return 100f; return 100f;

5
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java

@ -18,6 +18,7 @@ import com.fr.design.gui.syntax.ui.rsyntaxtextarea.ErrorStrip;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxDocument; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxDocument;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token;
import com.fr.stable.StringUtils;
/** /**
@ -60,6 +61,7 @@ public class TaskTagParser extends AbstractParser {
} }
@SuppressWarnings("squid:S2259")
public ParseResult parse(RSyntaxDocument doc, String style) { public ParseResult parse(RSyntaxDocument doc, String style) {
Element root = doc.getDefaultRootElement(); Element root = doc.getDefaultRootElement();
@ -101,6 +103,9 @@ public class TaskTagParser extends AbstractParser {
} }
if (start>-1) { if (start>-1) {
if (StringUtils.isEmpty(text)) {
continue;
}
text = text.substring(start); text = text.substring(start);
// TODO: Strip off end of MLC's if they're there. // TODO: Strip off end of MLC's if they're there.
int len = text.length(); int len = text.length();

8
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java

@ -349,6 +349,10 @@ public class LineNumberList extends AbstractGutterComponent
int width = metrics.stringWidth(number); int width = metrics.stringWidth(number);
g.drawString(number, rhs-width,y); g.drawString(number, rhs-width,y);
y += cellHeight; y += cellHeight;
if (fm == null) {
line++;
continue;
}
Fold fold = fm.getFoldForLine(line-1); Fold fold = fm.getFoldForLine(line-1);
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"
@ -371,6 +375,10 @@ public class LineNumberList extends AbstractGutterComponent
String number = Integer.toString(line + getLineNumberingStartIndex() - 1); String number = Integer.toString(line + getLineNumberingStartIndex() - 1);
g.drawString(number, RHS_BORDER_WIDTH, y); g.drawString(number, RHS_BORDER_WIDTH, y);
y += cellHeight; y += cellHeight;
if (fm == null) {
line++;
continue;
}
Fold fold = fm.getFoldForLine(line-1); Fold fold = fm.getFoldForLine(line-1);
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"

3
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java

@ -635,6 +635,9 @@ public class RTextArea extends RTextAreaBase implements Printable {
parent = parent.getParent(); parent = parent.getParent();
} }
KeyStroke backspace = KeyStroke.getKeyStroke("BACK_SPACE"); KeyStroke backspace = KeyStroke.getKeyStroke("BACK_SPACE");
if (inputMap == null) {
return;
}
inputMap.put(backspace, DefaultEditorKit.deletePrevCharAction); inputMap.put(backspace, DefaultEditorKit.deletePrevCharAction);
} }

9
designer-base/src/main/java/com/fr/design/icon/BorderIcon.java

@ -1,5 +1,6 @@
package com.fr.design.icon; package com.fr.design.icon;
import com.fr.stable.AssistUtils;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Graphics; import java.awt.Graphics;
@ -43,13 +44,13 @@ public class BorderIcon implements Icon {
if (lineStyle == Constants.LINE_MEDIUM if (lineStyle == Constants.LINE_MEDIUM
|| lineStyle == Constants.LINE_THICK) { || lineStyle == Constants.LINE_THICK) {
lineStyle = Constants.LINE_MEDIUM; lineStyle = Constants.LINE_MEDIUM;
if (x1 == x2) { if (AssistUtils.equals(x1, x2)) {
if (x1 == y1) { if (AssistUtils.equals(x1, y1)) {
GraphHelper.drawLine(g, x1, y1 - 1, x2, y2 + 1, lineStyle); GraphHelper.drawLine(g, x1, y1 - 1, x2, y2 + 1, lineStyle);
} else { } else {
GraphHelper.drawLine(g, x1, y1, x2, y2 + 1, lineStyle); GraphHelper.drawLine(g, x1, y1, x2, y2 + 1, lineStyle);
} }
} else if (y1 == y2) { } else if (AssistUtils.equals(y1, y2)) {
GraphHelper.drawLine(g, x1, y1, x2 + 1, y2, lineStyle); GraphHelper.drawLine(g, x1, y1, x2 + 1, y2, lineStyle);
} }
} else if (lineStyle == Constants.LINE_THIN } else if (lineStyle == Constants.LINE_THIN
@ -57,7 +58,7 @@ public class BorderIcon implements Icon {
GraphHelper.drawLine(g, x1, y1, x2, y2, lineStyle); GraphHelper.drawLine(g, x1, y1, x2, y2, lineStyle);
} else { } else {
lineStyle = Constants.LINE_DOT; lineStyle = Constants.LINE_DOT;
if (y1 == x2 && x2 == y2) { if (AssistUtils.equals(y1, x2) && AssistUtils.equals(x2, y2)) {
GraphHelper.drawLine(g, x1, y1, x2 + 1, y2, lineStyle); GraphHelper.drawLine(g, x1, y1, x2 + 1, y2, lineStyle);
} else { } else {
GraphHelper.drawLine(g, x1, y1, x2, y2, lineStyle); GraphHelper.drawLine(g, x1, y1, x2, y2, lineStyle);

2
designer-base/src/main/java/com/fr/design/icon/LockIcon.java

@ -35,7 +35,7 @@ public class LockIcon extends ImageIcon {
} }
@Override @Override
public void paintIcon(Component c, Graphics g, int x, int y) { public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
if (mainImage != null) { if (mainImage != null) {
g.drawImage(mainImage, x, y, c); g.drawImage(mainImage, x, y, c);
} }

2
designer-base/src/main/java/com/fr/design/icon/WarningIcon.java

@ -37,7 +37,7 @@ public class WarningIcon extends ImageIcon {
} }
@Override @Override
public void paintIcon(Component c, Graphics g, int x, int y) { public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
if (mainImage != null) { if (mainImage != null) {
g.drawImage(mainImage, x, y, c); g.drawImage(mainImage, x, y, c);
} }

5
designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

@ -3,6 +3,7 @@ package com.fr.design.layout;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.AssistUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.Icon; import javax.swing.Icon;
@ -562,9 +563,9 @@ public class FRGUIPaneFactory {
float i = Math.abs((((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m); float i = Math.abs((((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m);
float j = Math.abs((((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n); float j = Math.abs((((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n);
float x = i > j ? i : j; float x = i > j ? i : j;
if (x == i) { if (AssistUtils.equals(x, i)) {
w = Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M; w = Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M;
} else if (x == j) { } else if (AssistUtils.equals(x, j)) {
w = Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N; w = Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N;
} }
return w; return w;

63
designer-base/src/main/java/com/fr/design/layout/TableLayout.java

@ -1,6 +1,9 @@
package com.fr.design.layout; package com.fr.design.layout;
import com.fr.stable.AssistUtils;
import com.fr.general.GeneralUtils;
import com.fr.stable.CommonUtils;
import java.awt.Component; import java.awt.Component;
import java.awt.ComponentOrientation; import java.awt.ComponentOrientation;
import java.awt.Container; import java.awt.Container;
@ -12,8 +15,6 @@ import java.lang.reflect.Method;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.ListIterator; import java.util.ListIterator;
import com.fr.general.GeneralUtils;
/** /**
* <p>TableLayout is a layout manager that is more powerful than GridBagLayout * <p>TableLayout is a layout manager that is more powerful than GridBagLayout
@ -399,17 +400,17 @@ public class TableLayout implements LayoutManager2, Serializable {
// Make sure rows and columns are valid // Make sure rows and columns are valid
for (int counter = 0; counter < crSpec[C].length; counter++) for (int counter = 0; counter < crSpec[C].length; counter++)
if ((crSpec[C][counter] < 0.0) && if ((crSpec[C][counter] < 0.0) &&
(crSpec[C][counter] != FILL) && !AssistUtils.equals(crSpec[C][counter], FILL) &&
(crSpec[C][counter] != PREFERRED) && !AssistUtils.equals(crSpec[C][counter], PREFERRED) &&
(crSpec[C][counter] != MINIMUM)) { !AssistUtils.equals(crSpec[C][counter], MINIMUM)) {
crSpec[C][counter] = 0.0; crSpec[C][counter] = 0.0;
} }
for (int counter = 0; counter < crSpec[R].length; counter++) for (int counter = 0; counter < crSpec[R].length; counter++)
if ((crSpec[R][counter] < 0.0) && if ((crSpec[R][counter] < 0.0) &&
(crSpec[R][counter] != FILL) && !AssistUtils.equals(crSpec[R][counter], FILL) &&
(crSpec[R][counter] != PREFERRED) && !AssistUtils.equals(crSpec[R][counter], PREFERRED) &&
(crSpec[R][counter] != MINIMUM)) { !AssistUtils.equals(crSpec[R][counter], MINIMUM)) {
crSpec[R][counter] = 0.0; crSpec[R][counter] = 0.0;
} }
@ -556,9 +557,9 @@ public class TableLayout implements LayoutManager2, Serializable {
// Make sure rows are valid // Make sure rows are valid
for (int counter = 0; counter < crSpec[z].length; counter++) for (int counter = 0; counter < crSpec[z].length; counter++)
if ((crSpec[z][counter] < 0.0) && if ((crSpec[z][counter] < 0.0) &&
(crSpec[z][counter] != FILL) && !AssistUtils.equals(crSpec[z][counter], FILL) &&
(crSpec[z][counter] != PREFERRED) && !AssistUtils.equals(crSpec[z][counter], PREFERRED) &&
(crSpec[z][counter] != MINIMUM)) { !AssistUtils.equals(crSpec[z][counter], MINIMUM)) {
crSpec[z][counter] = 0.0; crSpec[z][counter] = 0.0;
} }
@ -641,9 +642,9 @@ public class TableLayout implements LayoutManager2, Serializable {
protected void setCr(int z, int i, double size) { protected void setCr(int z, int i, double size) {
// Make sure size is valid // Make sure size is valid
if ((size < 0.0) && if ((size < 0.0) &&
(size != FILL) && !AssistUtils.equals(size, FILL) &&
(size != PREFERRED) && !AssistUtils.equals(size, PREFERRED) &&
(size != MINIMUM)) { !AssistUtils.equals(size, MINIMUM)) {
size = 0.0; size = 0.0;
} }
@ -853,9 +854,9 @@ public class TableLayout implements LayoutManager2, Serializable {
// Make sure row size is valid // Make sure row size is valid
if ((size < 0.0) && if ((size < 0.0) &&
(size != FILL) && (!CommonUtils.equals(size, FILL)) &&
(size != PREFERRED) && (!CommonUtils.equals(size, PREFERRED)) &&
(size != MINIMUM)) { (!CommonUtils.equals(size, MINIMUM))) {
size = 0.0; size = 0.0;
} }
@ -1177,7 +1178,7 @@ public class TableLayout implements LayoutManager2, Serializable {
int numCr = crSpec[z].length; int numCr = crSpec[z].length;
for (int counter = 0; counter < numCr; counter++) for (int counter = 0; counter < numCr; counter++)
if ((crSpec[z][counter] >= 1.0) || (crSpec[z][counter] == 0.0)) { if ((crSpec[z][counter] >= 1.0) || CommonUtils.equals(crSpec[z][counter], 0.0)) {
crSize[z][counter] = (int) (crSpec[z][counter] + 0.5); crSize[z][counter] = (int) (crSpec[z][counter] + 0.5);
availableSize -= crSize[z][counter]; availableSize -= crSize[z][counter];
} }
@ -1229,7 +1230,7 @@ public class TableLayout implements LayoutManager2, Serializable {
int numCr = crSpec[z].length; int numCr = crSpec[z].length;
for (int counter = 0; counter < numCr; counter++) for (int counter = 0; counter < numCr; counter++)
if (crSpec[z][counter] == FILL) if (CommonUtils.equals(crSpec[z][counter], FILL))
numFillSize++; numFillSize++;
// If numFillSize is zero, the if statement below will always evaluate to // If numFillSize is zero, the if statement below will always evaluate to
@ -1241,7 +1242,7 @@ public class TableLayout implements LayoutManager2, Serializable {
// Assign "fill" cells equal amounts of the remaining space // Assign "fill" cells equal amounts of the remaining space
for (int counter = 0; counter < numCr; counter++) for (int counter = 0; counter < numCr; counter++)
if (crSpec[z][counter] == FILL) { if (CommonUtils.equals(crSpec[z][counter], FILL)) {
crSize[z][counter] = availableSize / numFillSize; crSize[z][counter] = availableSize / numFillSize;
slackSize -= crSize[z][counter]; slackSize -= crSize[z][counter];
} }
@ -1249,7 +1250,7 @@ public class TableLayout implements LayoutManager2, Serializable {
// Assign one pixel of slack to each FILL cr, starting at the last one, // Assign one pixel of slack to each FILL cr, starting at the last one,
// until all slack has been consumed // until all slack has been consumed
for (int counter = numCr - 1; (counter >= 0) && (slackSize > 0); counter--) { for (int counter = numCr - 1; (counter >= 0) && (slackSize > 0); counter--) {
if (crSpec[z][counter] == FILL) { if (CommonUtils.equals(crSpec[z][counter], FILL)) {
crSize[z][counter]++; crSize[z][counter]++;
slackSize--; slackSize--;
} }
@ -1299,7 +1300,7 @@ public class TableLayout implements LayoutManager2, Serializable {
// Address every cr // Address every cr
for (int counter = 0; counter < numCr; counter++) for (int counter = 0; counter < numCr; counter++)
// Is the current cr a preferred/minimum (based on typeOfSize) size // Is the current cr a preferred/minimum (based on typeOfSize) size
if (crSpec[z][counter] == typeOfSize) { if (CommonUtils.equals(crSpec[z][counter], typeOfSize)) {
// Assume a maximum width of zero // Assume a maximum width of zero
int maxSize = 0; int maxSize = 0;
@ -1319,7 +1320,7 @@ public class TableLayout implements LayoutManager2, Serializable {
// the current component occupies // the current component occupies
if ((entry.cr1[z] <= counter) && (entry.cr2[z] >= counter)) { if ((entry.cr1[z] <= counter) && (entry.cr2[z] >= counter)) {
// Setup size and number of adjustable crs // Setup size and number of adjustable crs
Dimension p = (typeOfSize == PREFERRED) ? Dimension p = CommonUtils.equals(typeOfSize, PREFERRED) ?
entry.component.getPreferredSize() : entry.component.getPreferredSize() :
entry.component.getMinimumSize(); entry.component.getMinimumSize();
@ -1328,23 +1329,23 @@ public class TableLayout implements LayoutManager2, Serializable {
int numAdjustable = 0; int numAdjustable = 0;
// Calculate for preferred size // Calculate for preferred size
if (typeOfSize == PREFERRED) if (CommonUtils.equals(typeOfSize, PREFERRED))
// Consider all crs this component occupies // Consider all crs this component occupies
for (int entryCr = entry.cr1[z]; for (int entryCr = entry.cr1[z];
entryCr <= entry.cr2[z]; entryCr++) { entryCr <= entry.cr2[z]; entryCr++) {
// Subtract absolute, relative, and minumum cr // Subtract absolute, relative, and minumum cr
// sizes, which have already been calculated // sizes, which have already been calculated
if ((crSpec[z][entryCr] >= 0.0) || if ((crSpec[z][entryCr] >= 0.0) ||
(crSpec[z][entryCr] == MINIMUM)) { CommonUtils.equals(crSpec[z][entryCr], MINIMUM)) {
size -= crSize[z][entryCr]; size -= crSize[z][entryCr];
} }
// Count preferred/min width columns // Count preferred/min width columns
else if (crSpec[z][entryCr] == PREFERRED) else if (CommonUtils.equals(crSpec[z][entryCr], PREFERRED))
numAdjustable++; numAdjustable++;
// Skip any component that occupies a fill cr // Skip any component that occupies a fill cr
// because the fill should fulfill the size // because the fill should fulfill the size
// requirements // requirements
else if (crSpec[z][entryCr] == FILL) else if (CommonUtils.equals(crSpec[z][entryCr], FILL))
continue nextComponent; continue nextComponent;
} }
// Calculate for minimum size // Calculate for minimum size
@ -1357,14 +1358,14 @@ public class TableLayout implements LayoutManager2, Serializable {
if (crSpec[z][entryCr] >= 0.0) if (crSpec[z][entryCr] >= 0.0)
size -= crSize[z][entryCr]; size -= crSize[z][entryCr];
// Count preferred/min width columns // Count preferred/min width columns
else if ((crSpec[z][entryCr] == PREFERRED) || else if (CommonUtils.equals(crSpec[z][entryCr], PREFERRED) ||
(crSpec[z][entryCr] == MINIMUM)) { CommonUtils.equals(crSpec[z][entryCr], MINIMUM)) {
numAdjustable++; numAdjustable++;
} }
// Skip any component that occupies a fill cr // Skip any component that occupies a fill cr
// because the fill should fulfill the size // because the fill should fulfill the size
// requirements // requirements
else if (crSpec[z][entryCr] == FILL) else if (CommonUtils.equals(crSpec[z][entryCr], FILL))
continue nextComponent; continue nextComponent;
} }
@ -1692,7 +1693,7 @@ public class TableLayout implements LayoutManager2, Serializable {
Dimension prefMinSize[] = new Dimension[numEntry]; Dimension prefMinSize[] = new Dimension[numEntry];
for (int i = 0; i < numEntry; i++) for (int i = 0; i < numEntry; i++)
prefMinSize[i] = (typeOfSize == PREFERRED) ? prefMinSize[i] = CommonUtils.equals(typeOfSize, PREFERRED) ?
entryList[i].component.getPreferredSize() : entryList[i].component.getPreferredSize() :
entryList[i].component.getMinimumSize(); entryList[i].component.getMinimumSize();

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

@ -1091,6 +1091,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
thread.join(); thread.join();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("Map Thread Error"); FineLoggerFactory.getLogger().error("Map Thread Error");
Thread.currentThread().interrupt();
} }
DesignerEnvManager.getEnvManager().setLastOpenFile( DesignerEnvManager.getEnvManager().setLastOpenFile(

23
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.mobile.ui; package com.fr.design.mainframe.mobile.ui;
import com.fr.base.background.ColorBackground;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -23,6 +24,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private MobileStyleCustomDefinePane customBeanPane; private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz; private Class<? extends MobileStyle> mobileStyleClazz;
private NewColorSelectBox colorSelectBox; private NewColorSelectBox colorSelectBox;
private Color titleColor = new Color(47, 142, 241);
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
Class<? extends MobileStyle> mobileStyleClazz) { Class<? extends MobileStyle> mobileStyleClazz) {
@ -35,7 +37,9 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@Override @Override
public void populateBean(MobileStyle ob) { public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob); this.customBeanPane.populateBean(ob);
colorSelectBox.setSelectObject(ob.getBackground()); if(ob.getBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor());
}
} }
@Override @Override
@ -43,7 +47,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get(); MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle); this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean(); this.customBeanPane.updateBean();
mobileStyle.setBackground(colorSelectBox.getSelectObject()); mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject()));
return mobileStyle; return mobileStyle;
} }
@ -67,8 +71,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
JPanel mobileStylePreviewPane = this.customBeanPane.createPreviewPane(); JPanel mobileStylePreviewPane = this.customBeanPane.createPreviewPane();
if(mobileStylePreviewPane != null) { if(mobileStylePreviewPane != null) {
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Widget_Style_Preview"), null); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Widget_Style_Preview"));
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, new Color(0x2f8ef100)));
previewPane.setBorder(titledBorder); previewPane.setBorder(titledBorder);
previewPane.setPreferredSize(new Dimension(500, 83)); previewPane.setPreferredSize(new Dimension(500, 83));
previewPane.add(mobileStylePreviewPane, BorderLayout.CENTER); previewPane.add(mobileStylePreviewPane, BorderLayout.CENTER);
@ -82,8 +85,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5));
backgroundPane.setPreferredSize(new Dimension(500, 65)); backgroundPane.setPreferredSize(new Dimension(500, 65));
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"), null); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"));
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE));
backgroundPane.setBorder(titledBorder); backgroundPane.setBorder(titledBorder);
UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT);
@ -104,12 +106,17 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private void createCustomPane() { private void createCustomPane() {
JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set"));
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE));
configPane.setBorder(titledBorder); configPane.setBorder(titledBorder);
configPane.add(this.customBeanPane, BorderLayout.CENTER); configPane.add(this.customBeanPane, BorderLayout.CENTER);
this.add(configPane, BorderLayout.CENTER); this.add(configPane, BorderLayout.CENTER);
} }
private TitledBorder createTitledBorder(String title) {
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(title, titleColor);
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12));
return titledBorder;
}
} }

7
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java

@ -19,12 +19,11 @@ public class VcsLabel extends ActionLabel {
} }
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
if (ui != null) { if (ui != null && g != null) {
Graphics scratchGraphics = (g == null) ? null : g.create(); Graphics scratchGraphics = g.create();
try { try {
ui.update(scratchGraphics, this); ui.update(scratchGraphics, this);
} } finally {
finally {
scratchGraphics.dispose(); scratchGraphics.dispose();
} }
} }

5
designer-base/src/main/java/com/fr/design/report/WatermarkPane.java

@ -7,6 +7,7 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.ispinner.UnsignedIntUISpinner;
import com.fr.design.gui.style.FRFontPane; import com.fr.design.gui.style.FRFontPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -112,8 +113,8 @@ public class WatermarkPane extends BasicPane {
formulaPane = new TinyFormulaPane(); formulaPane = new TinyFormulaPane();
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontSizeComboBox.setEditable(true); fontSizeComboBox.setEditable(true);
horizontalGapSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 200); horizontalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 200);
verticalGapSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 100); verticalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 100);
horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION); horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION); verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0)); JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0));

1
designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java

@ -74,6 +74,7 @@ public class ColorPicker extends JDialog implements ActionListener
Thread.sleep(100); // 等待弹窗关闭 Thread.sleep(100); // 等待弹窗关闭
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
colorPickerPanel.captureScreen(); colorPickerPanel.captureScreen();
} }

1
designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java

@ -65,6 +65,7 @@ public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem>
success = get(); success = get();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) { } catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }

1
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -385,6 +385,7 @@ public class UpdateMainDialog extends UIDialog {
showDownLoadInfo(); showDownLoadInfo();
} catch (InterruptedException e) { } catch (InterruptedException e) {
stopLoading(); stopLoading();
Thread.currentThread().interrupt();
} catch (ExecutionException e) { } catch (ExecutionException e) {
stopLoading(); stopLoading();
} finally { } finally {

1
designer-base/src/main/java/com/fr/design/utils/DrawRoutines.java

@ -206,6 +206,7 @@ public class DrawRoutines {
grabber.grabPixels(); grabber.grabPixels();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("PixelGrabber interrupted waiting for pixels"); FineLoggerFactory.getLogger().error("PixelGrabber interrupted waiting for pixels");
Thread.currentThread().interrupt();
} }
if ((grabber.getStatus() & ImageObserver.ABORT) != 0) { if ((grabber.getStatus() & ImageObserver.ABORT) != 0) {

1
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -548,6 +548,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
Thread.currentThread().interrupt();
} }
dialogDownPane.remove(cancelButton); dialogDownPane.remove(cancelButton);
dialogDownPane.revalidate(); dialogDownPane.revalidate();

1
designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java

@ -81,6 +81,7 @@ public class FineEmbedServerMonitor {
try { try {
Thread.sleep(STEP_HEARTBEAT); Thread.sleep(STEP_HEARTBEAT);
} catch (InterruptedException ignore) { } catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
} }
} }
DesignerContext.getDesignerFrame().hideProgressDialog(); DesignerContext.getDesignerFrame().hideProgressDialog();

97
designer-chart/src/main/java/com/fr/design/chart/gui/ActiveGlyphFactory.java

@ -1,97 +0,0 @@
package com.fr.design.chart.gui;
import java.util.HashMap;
import java.util.Map;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.CategoryAxisGlyph;
import com.fr.chart.chartglyph.ChartAlertValueGlyph;
import com.fr.chart.chartglyph.ChartGlyph;
import com.fr.chart.chartglyph.DataSeries;
import com.fr.chart.chartglyph.DataSheetGlyph;
import com.fr.chart.chartglyph.DateAxisGlyph;
import com.fr.chart.chartglyph.LegendGlyph;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.chart.chartglyph.RadarAxisGlyph;
import com.fr.chart.chartglyph.RangeAxisGlyph;
import com.fr.chart.chartglyph.TextGlyph;
import com.fr.chart.chartglyph.TitleGlyph;
import com.fr.chart.chartglyph.TrendLineGlyph;
import com.fr.chart.chartglyph.ValueAxisGlyph;
import com.fr.design.chart.gui.active.ActiveGlyph;
import com.fr.design.chart.gui.active.AlertValueActiveGlyph;
import com.fr.design.chart.gui.active.CategoryAxisActiveGlyph;
import com.fr.design.chart.gui.active.ChartActiveGlyph;
import com.fr.design.chart.gui.active.DataLabelActiveGlyph;
import com.fr.design.chart.gui.active.DataSeriesActiveGlyph;
import com.fr.design.chart.gui.active.DataSheetActiveGlyph;
import com.fr.design.chart.gui.active.DateAxisActiveGlyph;
import com.fr.design.chart.gui.active.LegendActiveGlyph;
import com.fr.design.chart.gui.active.PlotActiveGlyph;
import com.fr.design.chart.gui.active.RadarAxisActiveGlyph;
import com.fr.design.chart.gui.active.RangeAxisActiveGlyph;
import com.fr.design.chart.gui.active.TextActiveGlyph;
import com.fr.design.chart.gui.active.TrendLineActiveGlyph;
import com.fr.design.chart.gui.active.ValueAxisActiveGlyph;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-23
* Time : 上午9:08
*/
public class ActiveGlyphFactory {
private static Map<String, Class> glyphMap = new HashMap<String, Class>();
static {
glyphMap.put(DataSeries.class.getName(), DataSeriesActiveGlyph.class);
glyphMap.put(RadarAxisGlyph.class.getName(), RadarAxisActiveGlyph.class);
glyphMap.put(RangeAxisGlyph.class.getName(), RangeAxisActiveGlyph.class);
glyphMap.put(TitleGlyph.class.getName(), TextActiveGlyph.class);
glyphMap.put(DateAxisGlyph.class.getName(), DateAxisActiveGlyph.class);
glyphMap.put(ValueAxisGlyph.class.getName(), ValueAxisActiveGlyph.class);
glyphMap.put(CategoryAxisGlyph.class.getName(), CategoryAxisActiveGlyph.class);
glyphMap.put(ChartGlyph.class.getName(), ChartActiveGlyph.class);
glyphMap.put(DataSheetGlyph.class.getName(), DataSheetActiveGlyph.class);
glyphMap.put(LegendGlyph.class.getName(), LegendActiveGlyph.class);
glyphMap.put(TextGlyph.class.getName(), DataLabelActiveGlyph.class);
glyphMap.put(TrendLineGlyph.class.getName(), TrendLineActiveGlyph.class);
glyphMap.put(ChartAlertValueGlyph.class.getName(), AlertValueActiveGlyph.class);
}
private ActiveGlyphFactory() {
}
public static ActiveGlyph createActiveGlyph(ChartComponent chartComponent, Object glyph) {
return createActiveGlyph(chartComponent, glyph, null);
}
public static ActiveGlyph createActiveGlyph(ChartComponent chartComponent, Object glyph, Glyph parentGlyph) {
if (glyph == null) {
return null;
}
String clsName = glyph.getClass().getName();
Class cls = glyphMap.get(clsName);
Class parameterCls = glyph.getClass();
if (cls == null) {
if (clsName.endsWith("PlotGlyph")) {
cls = PlotActiveGlyph.class;
parameterCls = PlotGlyph.class;
} else if (clsName.endsWith("DataSeries4Area")) {
cls = DataSeriesActiveGlyph.class;
parameterCls = DataSeries.class;
} else {
cls = ChartActiveGlyph.class;
parameterCls = ChartGlyph.class;
}
}
try {
Class[] argsClass = new Class[]{ChartComponent.class, parameterCls, Glyph.class};
return (ActiveGlyph) cls.getConstructor(argsClass).newInstance(new Object[]{chartComponent, glyph, parentGlyph});
} catch (Exception e) {
return null;
}
}
}

98
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -2,36 +2,26 @@ package com.fr.design.chart.gui;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.ChartWebPara;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.Axis;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartglyph.AxisGlyph;
import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.attr.ChartProvider;
import com.fr.design.chart.gui.active.ActiveGlyph;
import com.fr.design.chart.gui.active.ChartActiveGlyph;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeListener; import com.fr.stable.core.PropertyChangeListener;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Paint; import java.awt.Paint;
import java.awt.Point;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -45,22 +35,12 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
private static final long serialVersionUID = 744164838619052097L; private static final long serialVersionUID = 744164838619052097L;
private final List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>(); private final List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
private ChartCollection chartCollection4Design; private ChartCollection chartCollection4Design;
private Chart editingChart; private ChartProvider editingChart;
private BaseChartGlyph chartGlyph;
private int chartWidth = -1; private int chartWidth = -1;
private int chartHeight = -1; private int chartHeight = -1;
private Point point;
private int resolution = ScreenResolution.getScreenResolution();
private ActiveGlyph activeGlyph;
private boolean supportEdit = true; private boolean supportEdit = true;
private final int[] resizeCursors = new int[]{
Cursor.NW_RESIZE_CURSOR, Cursor.N_RESIZE_CURSOR, Cursor.NE_RESIZE_CURSOR,
Cursor.E_RESIZE_CURSOR, Cursor.W_RESIZE_CURSOR,
Cursor.SE_RESIZE_CURSOR, Cursor.S_RESIZE_CURSOR, Cursor.SW_RESIZE_CURSOR
};
public ChartComponent() { public ChartComponent() {
super(); super();
addMouseListener(this); addMouseListener(this);
@ -112,15 +92,11 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
fireStopEditing(); fireStopEditing();
this.editingChart = null; this.editingChart = null;
this.chartGlyph = null;
this.activeGlyph = null;
this.point = null;
this.chartHeight = this.chartWidth = -1; this.chartHeight = this.chartWidth = -1;
this.editingChart = this.chartCollection4Design.getSelectedChart(); this.editingChart = this.chartCollection4Design.getSelectedChartProvider();
refreshChartGlyph(); refreshChartGlyph();
this.activeGlyph = ActiveGlyphFactory.createActiveGlyph(this, chartGlyph);
repaint(); repaint();
} }
@ -166,9 +142,6 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
return editingChart; return editingChart;
} }
public BaseChartGlyph getChartGlyph() {
return chartGlyph;
}
public void paintComponent(Graphics g) { // public void paintComponent(Graphics g) { //
super.paintComponent(g); super.paintComponent(g);
@ -192,12 +165,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//画图 //画图
drawChartGlyph(g2d); drawChart(g2d);
ActiveGlyph ag = this.getActiveGlyph();
if (ag != null) {
ag.paint4ActiveGlyph(g2d, chartGlyph);
}
g2d.translate(-ChartConstants.PREGAP4BOUNDS/2, -ChartConstants.PREGAP4BOUNDS/2); g2d.translate(-ChartConstants.PREGAP4BOUNDS/2, -ChartConstants.PREGAP4BOUNDS/2);
if (lastHint == null) { if (lastHint == null) {
@ -212,24 +180,11 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
*/ */
private void refreshChartGlyph() { private void refreshChartGlyph() {
Dimension d = getBounds().getSize(); Dimension d = getBounds().getSize();
this.editingChart = this.chartCollection4Design.getSelectedChart();// kunsnat: 切换选中时 同步切换Plot this.editingChart = this.chartCollection4Design.getSelectedChartProvider();// kunsnat: 切换选中时 同步切换Plot
if (editingChart != null) {
this.chartGlyph = editingChart.createGlyph(editingChart.defaultChartData());
this.activeGlyph = ActiveGlyphFactory.createActiveGlyph(this, chartGlyph);
}
this.chartWidth = d.width - ChartConstants.PREGAP4BOUNDS; this.chartWidth = d.width - ChartConstants.PREGAP4BOUNDS;
this.chartHeight = d.height - ChartConstants.PREGAP4BOUNDS; this.chartHeight = d.height - ChartConstants.PREGAP4BOUNDS;
} }
private ActiveGlyph getActiveGlyph() {
if (point == null) {
this.activeGlyph = new ChartActiveGlyph(this, chartGlyph);
} else {
this.activeGlyph = new ChartActiveGlyph(this, chartGlyph).findActionGlyphFromChildren(point.x, point.y);
}
return this.activeGlyph;
}
/** /**
* 鼠标点击 * 鼠标点击
* @param event 鼠标事件 * @param event 鼠标事件
@ -243,16 +198,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
point = new Point(e.getX(),e.getY());
if (!ArrayUtils.contains(resizeCursors, this.getCursor().getType())) {
this.activeGlyph = new ChartActiveGlyph(this, chartGlyph).findActionGlyphFromChildren(point.x, point.y);
}
if (this.activeGlyph == null) {
return;
}
repaint();
} }
@ -291,45 +237,21 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
ActiveGlyph ag = this.getActiveGlyph();
if (ag != null) {
ag.onMouseMove(e);
}
}
public AxisGlyph getActiveAxisGlyph() {
return (AxisGlyph) activeGlyph.getGlyph();
}
public Axis getActiveAxis() {
AxisGlyph axisGlyph = getActiveAxisGlyph();
if (editingChart.getPlot() != null) {
return editingChart.getPlot().getAxis(axisGlyph.getAxisType());
}
return null;
} }
private boolean needRefreshChartGlyph() { private boolean needRefreshChartGlyph() {
return chartGlyph == null || chartWidth != this.getBounds().width || chartHeight != this.getBounds().height; return editingChart == null || chartWidth != this.getBounds().width || chartHeight != this.getBounds().height;
} }
public void drawChartGlyph(Graphics2D g2d) { private void drawChart(Graphics2D g2d) {
if (chartGlyph != null) { if (editingChart != null) {
if (chartGlyph.isRoundBorder()) {
chartGlyph.setBounds(new RoundRectangle2D.Double(0, 0, chartWidth, chartHeight, 10, 10));
} else {
chartGlyph.setBounds(new Rectangle2D.Double(0, 0, chartWidth, chartHeight));
}
//不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单
//其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边
//处理画图事件
resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
if (resolution == 0){ if (resolution == 0){
resolution = ScreenResolution.getScreenResolution(); resolution = ScreenResolution.getScreenResolution();
} }
Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,resolution, this, null); Image chartImage = editingChart.toImage(chartWidth, chartHeight, resolution, new ChartWebPara());
g2d.drawImage(chartImage, 0, 0, null); g2d.drawImage(chartImage, 0, 0, null);
} }

161
designer-chart/src/main/java/com/fr/design/chart/gui/active/ActiveGlyph.java

@ -1,161 +0,0 @@
package com.fr.design.chart.gui.active;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.Glyph;
import com.fr.design.chart.gui.ActiveGlyphFactory;
import com.fr.design.chart.gui.ChartComponent;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午3:51
* 选中的Glyph
*/
public abstract class ActiveGlyph {
protected Glyph parentGlyph;
protected ChartComponent chartComponent;
public ActiveGlyph(ChartComponent chartComponent, Glyph parentGlyph) {
this.chartComponent = chartComponent;
this.parentGlyph = parentGlyph;
}
public abstract Glyph getGlyph();
public void drawAllGlyph(Graphics2D g2d, int resolution){
Point2D offset4Paint = offset4Paint();
g2d.translate(offset4Paint.getX(), offset4Paint.getY());
this.getGlyph().draw(g2d, resolution);
g2d.translate(-offset4Paint.getX(), -offset4Paint.getY());
};
/**
* 属性表中, 通过点击 展开到对应的界面.
*/
public abstract void goRightPane();
/**
* 画的偏移的
* @return 偏移的
*/
public Point2D offset4Paint() {
return new Point2D.Double(
this.parentGlyph.getShape().getBounds().getX(),
this.parentGlyph.getShape().getBounds().getY()
);
}
public void paint4ActiveGlyph(Graphics2D g2d, BaseChartGlyph chartGlyph) {
if(this.parentGlyph == null) {
return;
}
Paint oldPaint = g2d.getPaint();
Composite oldComposite = g2d.getComposite();
g2d.setPaint(Color.WHITE);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
g2d.fill(chartGlyph.getShape());
drawAllGlyph(g2d, ScreenResolution.getScreenResolution());
g2d.setPaint(oldPaint);
g2d.setComposite(oldComposite);
}
protected void drawSelectedBounds4Active(Graphics2D g2d) {
if (this.getGlyph() != null) {
Shape shape = this.getGlyph().getShape();
if (shape != null) {
g2d.draw(shape);
}
}
}
/**
*当前的ActiveGlyph是否包含坐标mouseX, mouseY
* @param mouseX 坐标X
* @param mouseY 坐标Y
* @return 包含则返回true
*/
public boolean contains(int mouseX, int mouseY) {
if (getGlyph() == null || getGlyph().getShape() == null){
return false;
}
Point2D offset = this.offset4Paint();
/*
* alex:因为Line2D.contains(x, y)必然返回false
* 所以用intersect一个区域,这个区域大小用4 * 4的,区域大一些,就灵敏一些
*/
return getGlyph().getShape().intersects(mouseX - offset.getX() - 2, mouseY - offset.getY() - 2, 4, 4);
}
/**
* 在当前选中的ActiveGlyph中,仅仅在其Children中找与mouseX, mouseY匹配的ActiveGlyph
* @param mouseX 坐标X
* @param mouseY 坐标Y
* @return 当前ativeGlyph
*/
public ActiveGlyph findActionGlyphFromChildren(int mouseX, int mouseY) {
Glyph currentGlyph = getGlyph();
// 报错应对.
if (currentGlyph == null) {
return null;
}
java.util.Iterator selectableChildren = currentGlyph.selectableChildren();
ActiveGlyph resAG = null;
while (selectableChildren.hasNext() && resAG == null) {
ActiveGlyph childActiveGlyph = ActiveGlyphFactory.createActiveGlyph(chartComponent, selectableChildren.next(), currentGlyph);
// 如果childActiveGlyph不为null,找一下其子辈有没有符合条件
if (childActiveGlyph != null) {
resAG = childActiveGlyph.findActionGlyphFromChildren(mouseX, mouseY);
}
// 如果childActiveGlyph的子辈没有符合条件的,就看一下这个childGlyph是否符合条件
if (resAG == null && childActiveGlyph != null && childActiveGlyph.contains(mouseX, mouseY)) {
resAG = childActiveGlyph;
}
}
// 如果当前ActiveGlyph的所有子辈都没有与mouseX, mouseY相匹配的,看一下它自己是否匹配
if (resAG == null) {
if (this.contains(mouseX, mouseY)) {
resAG = this;
}
}
return resAG;
}
/**
* 拖拽
* @param e 事件
*/
public void onMouseDragged(MouseEvent e) {
}
/**
* 移动事件
* @param e 事件
*/
public void onMouseMove(MouseEvent e) {
}
}

38
designer-chart/src/main/java/com/fr/design/chart/gui/active/AlertValueActiveGlyph.java

@ -1,38 +0,0 @@
package com.fr.design.chart.gui.active;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.ChartAlertValueGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetAnalysisLineStyleAction;
public class AlertValueActiveGlyph extends ActiveGlyph{
ChartAlertValueGlyph alertValueGlyph;
public AlertValueActiveGlyph(ChartComponent chartComponent,ChartAlertValueGlyph alertLine, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.alertValueGlyph = alertLine;
}
public Point2D offset4Paint() {
Rectangle2D valueAxisBoudns = this.alertValueGlyph.getValueAxisGlyph().getBounds();
return new Point2D.Double(
this.parentGlyph.getShape().getBounds().getX() + valueAxisBoudns.getX(),
this.parentGlyph.getShape().getBounds().getY() + valueAxisBoudns.getY()
);
}
@Override
public Glyph getGlyph() {
return this.alertValueGlyph;
}
@Override
public void goRightPane() {
new SetAnalysisLineStyleAction(chartComponent).showAnalysisLineStylePane();
}
}

43
designer-chart/src/main/java/com/fr/design/chart/gui/active/AxisActiveGlyph.java

@ -1,43 +0,0 @@
package com.fr.design.chart.gui.active;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.AxisGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetAxisStyleAction;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:00
*/
public abstract class AxisActiveGlyph extends ActiveGlyph {
protected AxisGlyph axis;
public AxisActiveGlyph(ChartComponent chartComponent, AxisGlyph axis, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.axis = axis;
}
public void drawAllGlyph(Graphics2D g2d, int resolution){
Point2D offset4Paint = offset4Paint();
g2d.translate(offset4Paint.getX(), offset4Paint.getY());
this.axis.drawWithOutAlert(g2d, resolution);
g2d.translate(-offset4Paint.getX(), -offset4Paint.getY());
};
public void goRightPane() {
new SetAxisStyleAction(chartComponent).showAxisStylePane();
}
/**
* 返回 对应的属性Axis
*/
public Glyph getGlyph() {
return this.axis;
}
}

19
designer-chart/src/main/java/com/fr/design/chart/gui/active/CategoryAxisActiveGlyph.java

@ -1,19 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.CategoryAxisGlyph;
import com.fr.design.chart.gui.ChartComponent;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:01
*/
public class CategoryAxisActiveGlyph extends AxisActiveGlyph {
public CategoryAxisActiveGlyph(ChartComponent chartComponent, CategoryAxisGlyph axis, Glyph parentGlyph) {
super(chartComponent, axis, parentGlyph);
}
}

39
designer-chart/src/main/java/com/fr/design/chart/gui/active/ChartActiveGlyph.java

@ -1,39 +0,0 @@
package com.fr.design.chart.gui.active;
import java.awt.geom.Point2D;
import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.Glyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetChartStyleAciton;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午3:54
*/
public class ChartActiveGlyph extends ActiveGlyph {
private BaseChartGlyph glyphChart;
public ChartActiveGlyph(ChartComponent chartComponent, BaseChartGlyph chart) {
this(chartComponent, chart, null);
}
public ChartActiveGlyph(ChartComponent chartComponent, BaseChartGlyph chart, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.glyphChart = chart;
}
public Glyph getGlyph() {
return this.glyphChart;
}
public Point2D offset4Paint() {
return new java.awt.Point(0, 0);
}
public void goRightPane() {
new SetChartStyleAciton(chartComponent).showChartStylePane();
}
}

44
designer-chart/src/main/java/com/fr/design/chart/gui/active/DataLabelActiveGlyph.java

@ -1,44 +0,0 @@
package com.fr.design.chart.gui.active;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.chart.chartglyph.TextGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetDataLabelStyleAction;
public class DataLabelActiveGlyph extends ActiveGlyph{
private TextGlyph dataLabel;
public DataLabelActiveGlyph(ChartComponent chartComponent, TextGlyph dataLabel, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.dataLabel = dataLabel;
}
public void drawAllGlyph(Graphics2D g2d, int resolution){
Point2D offset4Paint = offset4Paint();
g2d.translate(offset4Paint.getX(), offset4Paint.getY());
ArrayList<TextGlyph> allDataPointLableGlyph = new ArrayList<TextGlyph>();
PlotGlyph plotGlyph = (PlotGlyph)(this.parentGlyph);
plotGlyph.getAllDataPointGlyph(allDataPointLableGlyph);
for(int index = 0; index < allDataPointLableGlyph.size(); index++){
allDataPointLableGlyph.get(index).draw(g2d, resolution);
}
g2d.translate(-offset4Paint.getX(), -offset4Paint.getY());
};
@Override
public Glyph getGlyph() {
return this.dataLabel;
}
@Override
public void goRightPane() {
new SetDataLabelStyleAction(chartComponent).showDataLabelStylePane();
}
}

53
designer-chart/src/main/java/com/fr/design/chart/gui/active/DataSeriesActiveGlyph.java

@ -1,53 +0,0 @@
package com.fr.design.chart.gui.active;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.DataSeries;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午3:59
*/
public class DataSeriesActiveGlyph extends ActiveGlyph {
private DataSeries series;
public DataSeriesActiveGlyph(ChartComponent chartComponent, DataSeries series, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.series = series;
}
public Glyph getGlyph() {
return this.series;
}
/**
* 界面条状
*/
public void goRightPane() {
if(chartComponent.getEditingChart() == null) {
return;
}
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE);
}
@Override
public void drawAllGlyph(Graphics2D g2d, int resolution) {
Point2D offset4Paint = offset4Paint();
g2d.translate(offset4Paint.getX(), offset4Paint.getY());
if(this.parentGlyph != null && this.parentGlyph instanceof PlotGlyph){
PlotGlyph plotGlyph = (PlotGlyph)this.parentGlyph;
plotGlyph.drawShape4Series(g2d, resolution);
}
g2d.translate(-offset4Paint.getX(), -offset4Paint.getY());
}
}

30
designer-chart/src/main/java/com/fr/design/chart/gui/active/DataSheetActiveGlyph.java

@ -1,30 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.DataSheetGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetDataSheetAction;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午3:57
*/
public class DataSheetActiveGlyph extends ActiveGlyph {
private DataSheetGlyph dataSheetGlyph;
public DataSheetActiveGlyph(ChartComponent chartComponent, DataSheetGlyph dataSheetGlyph, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.dataSheetGlyph = dataSheetGlyph;
}
public Glyph getGlyph() {
return this.dataSheetGlyph;
}
public void goRightPane() {
new SetDataSheetAction(chartComponent).showDataSheetStylePane();
}
}

18
designer-chart/src/main/java/com/fr/design/chart/gui/active/DateAxisActiveGlyph.java

@ -1,18 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.DateAxisGlyph;
import com.fr.design.chart.gui.ChartComponent;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:03
*/
public class DateAxisActiveGlyph extends AxisActiveGlyph {
public DateAxisActiveGlyph(ChartComponent chartComponent, DateAxisGlyph axis, Glyph parentGlyph) {
super(chartComponent, axis, parentGlyph);
}
}

30
designer-chart/src/main/java/com/fr/design/chart/gui/active/LegendActiveGlyph.java

@ -1,30 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.LegendGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetLegendStyleAction;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午3:58
*/
public class LegendActiveGlyph extends ActiveGlyph {
private LegendGlyph legendGlyph;
public LegendActiveGlyph(ChartComponent chartComponent, LegendGlyph legendGlyph, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.legendGlyph = legendGlyph;
}
public Glyph getGlyph() {
return this.legendGlyph;
}
public void goRightPane() {
new SetLegendStyleAction(chartComponent).showLegendStylePane();
}
}

34
designer-chart/src/main/java/com/fr/design/chart/gui/active/PlotActiveGlyph.java

@ -1,34 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetPlotStyleAction;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午3:55
*/
public class PlotActiveGlyph extends ActiveGlyph {
private PlotGlyph plotGlyph;
public PlotActiveGlyph(ChartComponent chartComponent, PlotGlyph plotGlyph, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.plotGlyph = plotGlyph;
}
public Glyph getGlyph() {
return this.plotGlyph;
}
public void goRightPane() {
new SetPlotStyleAction(chartComponent).showPlotPane();
}
public java.awt.Point offset4Paint() {
return new java.awt.Point(0, 0);
}
}

18
designer-chart/src/main/java/com/fr/design/chart/gui/active/RadarAxisActiveGlyph.java

@ -1,18 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.RadarAxisGlyph;
import com.fr.design.chart.gui.ChartComponent;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:03
*/
public class RadarAxisActiveGlyph extends AxisActiveGlyph {
public RadarAxisActiveGlyph(ChartComponent chartComponent, RadarAxisGlyph axis, Glyph parentGlyph) {
super(chartComponent, axis, parentGlyph);
}
}

18
designer-chart/src/main/java/com/fr/design/chart/gui/active/RangeAxisActiveGlyph.java

@ -1,18 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.ValueAxisGlyph;
import com.fr.design.chart.gui.ChartComponent;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:02
*/
public class RangeAxisActiveGlyph extends AxisActiveGlyph {
public RangeAxisActiveGlyph(ChartComponent chartComponent, ValueAxisGlyph axis, Glyph parentGlyph) {
super(chartComponent, axis, parentGlyph);
}
}

35
designer-chart/src/main/java/com/fr/design/chart/gui/active/TextActiveGlyph.java

@ -1,35 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.TitleGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetTitleStyleAction;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午3:57
*/
public class TextActiveGlyph extends ActiveGlyph {
private TitleGlyph titleGlyph;
public TextActiveGlyph(ChartComponent chartComponent, TitleGlyph titleGlyph, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.titleGlyph = titleGlyph;
}
public Glyph getGlyph() {
return this.titleGlyph;
}
public java.awt.Point offset4Paint() {
return new java.awt.Point(0, 0);
}
public void goRightPane() {
new SetTitleStyleAction(chartComponent).showTitlePane();
}
}

43
designer-chart/src/main/java/com/fr/design/chart/gui/active/TrendLineActiveGlyph.java

@ -1,43 +0,0 @@
package com.fr.design.chart.gui.active;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.chart.chartglyph.TrendLineGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.chart.gui.active.action.SetAnalysisLineStyleAction;
public class TrendLineActiveGlyph extends ActiveGlyph{
private TrendLineGlyph trendLine;
public TrendLineActiveGlyph(ChartComponent chartComponent,TrendLineGlyph trendLine, Glyph parentGlyph) {
super(chartComponent, parentGlyph);
this.trendLine = trendLine;
}
@Override
public Glyph getGlyph() {
return this.trendLine;
}
public void drawAllGlyph(Graphics2D g2d, int resolution){
Point2D offset4Paint = offset4Paint();
g2d.translate(offset4Paint.getX(), offset4Paint.getY());
PlotGlyph plotGlyph = (PlotGlyph)this.parentGlyph;
List<TrendLineGlyph> list = new ArrayList<TrendLineGlyph>();
plotGlyph.getAllTrendLineGlyph(list);
for(int index = 0; index < list.size(); index++){
list.get(index).draw(g2d, resolution);
}
g2d.translate(-offset4Paint.getX(), -offset4Paint.getY());
};
@Override
public void goRightPane() {
new SetAnalysisLineStyleAction(chartComponent).showAnalysisLineStylePane();
}
}

19
designer-chart/src/main/java/com/fr/design/chart/gui/active/ValueAxisActiveGlyph.java

@ -1,19 +0,0 @@
package com.fr.design.chart.gui.active;
import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.ValueAxisGlyph;
import com.fr.design.chart.gui.ChartComponent;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:02
*/
public class ValueAxisActiveGlyph extends AxisActiveGlyph {
public ValueAxisActiveGlyph(ChartComponent chartComponent, ValueAxisGlyph axis, Glyph parentGlyph) {
super(chartComponent, axis, parentGlyph);
}
}

37
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java

@ -1,37 +0,0 @@
package com.fr.design.chart.gui.active.action;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartglyph.AxisGlyph;
import com.fr.design.actions.UpdateAction;
import com.fr.design.chart.gui.ChartComponent;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午5:05
*/
public abstract class ChartComponentAction extends UpdateAction {
protected ChartComponent chartComponent;
public ChartComponentAction(ChartComponent chartComponent) {
this.chartComponent = chartComponent;
}
public void reset() {
chartComponent.reset();
}
public void repaint() {
chartComponent.repaint();
}
public ChartCollection getChartCollection() {
return chartComponent.getChartCollection();
}
public AxisGlyph getActiveAxisGlyph() {
return chartComponent.getActiveAxisGlyph();
}
}

27
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java

@ -1,27 +0,0 @@
package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
public class SetAnalysisLineStyleAction extends ChartComponentAction{
public SetAnalysisLineStyleAction(ChartComponent chartComponent) {
super(chartComponent);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Analysis_Line"));
}
@Override
public void actionPerformed(ActionEvent e) {
showAnalysisLineStylePane();
}
public void showAnalysisLineStylePane(){
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LINE_TITLE);
}
}

33
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java

@ -1,33 +0,0 @@
package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.stable.StringUtils;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午5:10
*/
public class SetAxisStyleAction extends ChartComponentAction {
public SetAxisStyleAction(ChartComponent chartComponent) {
super(chartComponent);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Axis_Format"));
}
public void actionPerformed(ActionEvent e) {
showAxisStylePane();
}
public void showAxisStylePane() {
String axisType = getActiveAxisGlyph() == null ? StringUtils.EMPTY : getActiveAxisGlyph().getAxisType();
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AXIS_TITLE, axisType);
}
}

31
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java

@ -1,31 +0,0 @@
package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午5:00
*/
public class SetChartStyleAciton extends ChartComponentAction {
public SetChartStyleAciton(ChartComponent chartComponent) {
super(chartComponent);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pattern"));
}
public void actionPerformed(ActionEvent e) {
showChartStylePane();
}
public void showChartStylePane() {
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_AREA_TITLE);
}
}

26
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java

@ -1,26 +0,0 @@
package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
public class SetDataLabelStyleAction extends ChartComponentAction{
public SetDataLabelStyleAction(ChartComponent chartComponent) {
super(chartComponent);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Data_Label"));
}
@Override
public void actionPerformed(ActionEvent e) {
showDataLabelStylePane();
}
public void showDataLabelStylePane() {
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LABEL_TITLE);
}
}

33
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetDataSheetAction.java

@ -1,33 +0,0 @@
package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:49
*/
public class SetDataSheetAction extends ChartComponentAction {
private static final long serialVersionUID = -4763886493273213850L;
public SetDataSheetAction(ChartComponent chartComponent) {
super(chartComponent);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Data_Sheet"));
}
public void actionPerformed(ActionEvent e) {
showDataSheetStylePane();
}
public void showDataSheetStylePane() {
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_DATA_TITLE);
}
}

32
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetLegendStyleAction.java

@ -1,32 +0,0 @@
package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:56
*/
public class SetLegendStyleAction extends ChartComponentAction {
private static final long serialVersionUID = 3253190503195130478L;
public SetLegendStyleAction(ChartComponent chartComponent) {
super(chartComponent);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Legend_Sytle"));
}
public void actionPerformed(ActionEvent e) {
showLegendStylePane();
}
public void showLegendStylePane() {
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LEGNED_TITLE);
}
}

32
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java

@ -1,32 +0,0 @@
package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:58
*/
public class SetPlotStyleAction extends ChartComponentAction {
private static final long serialVersionUID = 2894127568015714372L;
public SetPlotStyleAction(ChartComponent chartComponent) {
super(chartComponent);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Plot"));
}
public void actionPerformed(ActionEvent e) {
showPlotPane();
}
public void showPlotPane() {
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_PLOT_TITLE);
}
}

32
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java

@ -1,32 +0,0 @@
package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
/**
* Created by IntelliJ IDEA.
* Author : Richer
* Version: 6.5.6
* Date : 11-11-22
* Time : 下午4:52
*/
public class SetTitleStyleAction extends ChartComponentAction {
private static final long serialVersionUID = -4763886493273213850L;
public SetTitleStyleAction(ChartComponent chartComponent) {
super(chartComponent);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Set_Title_Style"));
}
public void actionPerformed(ActionEvent e) {
showTitlePane();
}
public void showTitlePane() {
DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_TITLE_TITLE);
}
}

6
designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java

@ -245,7 +245,11 @@ public class MapImageEditPane extends BasicBeanPane<String> {
g2d.translate(moveLeft, moveTop); g2d.translate(moveLeft, moveTop);
g2d.setStroke(new BasicStroke(1)); g2d.setStroke(new BasicStroke(1));
if (resultAreaShape != null && !resultAreaShape.isEmpty()) {
if (resultAreaShape == null) {
throw new IllegalArgumentException("resultAreaShape can not be null!");
}
if (!resultAreaShape.isEmpty()) {
for (String key : resultAreaShape.keySet()) { for (String key : resultAreaShape.keySet()) {
GeneralPath selectShape = getSelectedNodePath(key); GeneralPath selectShape = getSelectedNodePath(key);

23
designer-chart/src/main/java/com/fr/design/chartx/StructureChartDataPane.java

@ -0,0 +1,23 @@
package com.fr.design.chartx;
import com.fr.design.chartx.fields.diff.StructureCellDataFieldsPane;
import com.fr.design.chartx.fields.diff.StructureDataSetFieldsPane;
import com.fr.design.chartx.single.SingleDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-02
*/
public class StructureChartDataPane extends MultiCategoryChartDataPane {
public StructureChartDataPane(AttributeChangeListener listener) {
super(listener);
}
@Override
protected SingleDataPane createSingleDataPane() {
return new SingleDataPane(new StructureDataSetFieldsPane(), new StructureCellDataFieldsPane());
}
}

86
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java

@ -0,0 +1,86 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.StructureColumnFieldCollection;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-02
*/
public class StructureCellDataFieldsPane extends AbstractCellDataFieldsPane<StructureColumnFieldCollection> {
private TinyFormulaPane nodeName;
private TinyFormulaPane nodeId;
private TinyFormulaPane parentId;
private UITextField seriesName;
private TinyFormulaPane nodeValue;
@Override
protected void initComponents() {
seriesName = new UITextField();
nodeName = new TinyFormulaPane();
nodeId = new TinyFormulaPane();
parentId = new TinyFormulaPane();
nodeValue = new TinyFormulaPane();
super.initComponents();
}
@Override
protected String[] fieldLabels() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Node_Name"),
"id",
Toolkit.i18nText("Fine-Design_Chart_Parent_ID"),
Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"),
Toolkit.i18nText("Fine-Design_Chart_Series_Value"),
};
}
@Override
protected TinyFormulaPane[] formulaPanes() {
return new TinyFormulaPane[]{
nodeName,
nodeId,
parentId,
nodeValue
};
}
@Override
protected Component[] fieldComponents() {
return new Component[]{
nodeName,
nodeId,
parentId,
nodeValue,
nodeValue,
};
}
@Override
public void populateBean(StructureColumnFieldCollection ob) {
seriesName.setText(ob.getSeriesName());
populateField(nodeName, ob.getNodeName());
populateField(nodeId, ob.getNodeId());
populateField(parentId, ob.getParentId());
populateField(nodeValue, ob.getNodeValue());
}
@Override
public StructureColumnFieldCollection updateBean() {
StructureColumnFieldCollection result = new StructureColumnFieldCollection();
result.setSeriesName(seriesName.getText());
updateField(nodeName, result.getNodeName());
updateField(nodeId, result.getNodeId());
updateField(parentId, result.getParentId());
updateField(nodeValue, result.getNodeValue());
return result;
}
}

91
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureDataSetFieldsPane.java

@ -0,0 +1,91 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.StructureColumnFieldCollection;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-02
*/
public class StructureDataSetFieldsPane extends AbstractDataSetFieldsPane<StructureColumnFieldCollection> {
private UIComboBox nodeName;
private UIComboBox nodeId;
private UIComboBox parentId;
private UITextField seriesName;
private UIComboBox nodeValue;
private CalculateComboBox calculateCombox;
@Override
protected void initComponents() {
nodeName = new UIComboBox();
nodeId = new UIComboBox();
parentId = new UIComboBox();
seriesName = new UITextField();
nodeValue = new UIComboBox();
calculateCombox = new CalculateComboBox();
super.initComponents();
}
@Override
protected String[] fieldLabels() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Node_Name"),
"id",
Toolkit.i18nText("Fine-Design_Chart_Parent_ID"),
Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"),
Toolkit.i18nText("Fine-Design_Chart_Series_Value"),
Toolkit.i18nText("Fine-Design_Chart_Summary_Method")
};
}
@Override
protected UIComboBox[] filedComboBoxes() {
return new UIComboBox[]{
nodeName,
nodeId,
parentId,
nodeValue
};
}
@Override
protected Component[] fieldComponents() {
return new Component[]{
nodeName,
nodeId,
parentId,
nodeValue,
nodeValue,
calculateCombox
};
}
@Override
public void populateBean(StructureColumnFieldCollection ob) {
seriesName.setText(ob.getSeriesName());
populateField(nodeName, ob.getNodeName());
populateField(nodeId, ob.getNodeId());
populateField(parentId, ob.getParentId());
populateFunctionField(nodeValue, calculateCombox, ob.getNodeValue());
}
@Override
public StructureColumnFieldCollection updateBean() {
StructureColumnFieldCollection result = new StructureColumnFieldCollection();
result.setSeriesName(seriesName.getText());
updateField(nodeName, result.getNodeName());
updateField(nodeId, result.getNodeId());
updateField(parentId, result.getParentId());
updateFunctionField(nodeValue, calculateCombox, result.getNodeValue());
return result;
}
}

2
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudCellDataFieldsPane.java

@ -64,7 +64,7 @@ public class WordCloudCellDataFieldsPane extends AbstractCellDataFieldsPane<Word
WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection(); WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection();
result.setTargetName(name.getText()); result.setTargetName(name.getText());
updateField(wordName, result.getWordName()); updateField(wordName, result.getWordName());
populateField(wordValue, result.getWordValue()); updateField(wordValue, result.getWordValue());
return result; return result;
} }
} }

9
designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java

@ -96,15 +96,6 @@ public class MapEditPane extends BasicBeanPane<MapSvgAttr>{
} }
/**
* 再图片面板设置类型和名字
* @param mapType 地图类型
*/
public void dealWidthMap(String mapType){
areaPane.setTypeNameAndMapName(mapType,currentMapName);
// pointPane.setTypeNameAndMapName(mapType,currentMapName);
}
@Override @Override
public MapSvgAttr updateBean() { public MapSvgAttr updateBean() {
MapSvgAttr currentAttr = editingPane.updateCurrentAttr(); MapSvgAttr currentAttr = editingPane.updateCurrentAttr();

5
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java

@ -56,7 +56,10 @@ public class ChartDataPane extends AbstractChartAttrPane {
} }
this.setLayout(new BorderLayout(0, 0)); this.setLayout(new BorderLayout(0, 0));
if (collection != null && collection.getChartCount() <= 0) { if (collection == null) {
throw new IllegalArgumentException("ChartCollection can not be null!");
}
if (collection.getChartCount() <= 0) {
contentsPane = new NormalChartDataPane(listener, ChartDataPane.this); contentsPane = new NormalChartDataPane(listener, ChartDataPane.this);
} else if (collection.getSelectedChart().getPlot() instanceof MapPlot) { } else if (collection.getSelectedChart().getPlot() instanceof MapPlot) {
contentsPane = new MapDataPane(listener); contentsPane = new MapDataPane(listener);

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java

@ -114,7 +114,9 @@ public class AreaPlotPane extends AbstractDeprecatedChartTypePane {
((Area3DPlot)plot).setStacked(true); ((Area3DPlot)plot).setStacked(true);
((Area3DPlot)plot).getyAxis().setPercentage(true); ((Area3DPlot)plot).getyAxis().setPercentage(true);
} }
if(plot != null) {
createAreaCondition(plot); createAreaCondition(plot);
}
return plot; return plot;
} }

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BarPlotPane.java

@ -97,11 +97,13 @@ public class BarPlotPane extends AbstractBarPane{
} }
Plot cloned = null; Plot cloned = null;
if(newPlot != null) {
try { try {
cloned = (Plot)newPlot.clone(); cloned = (Plot) newPlot.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart"); FineLoggerFactory.getLogger().error("Error In ColumnChart");
} }
}
return cloned; return cloned;
} }

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ColumnPlotPane.java

@ -94,11 +94,13 @@ public class ColumnPlotPane extends AbstractBarPane{
} }
Plot cloned = null; Plot cloned = null;
if(newPlot != null) {
try { try {
cloned = (Plot)newPlot.clone(); cloned = (Plot) newPlot.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart"); FineLoggerFactory.getLogger().error("Error In ColumnChart");
} }
}
return cloned; return cloned;
} }

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java

@ -66,11 +66,13 @@ public class MeterPlotPane extends AbstractDeprecatedChartTypePane {
} }
Plot cloned = null; Plot cloned = null;
if(newPlot != null) {
try { try {
cloned = (Plot)newPlot.clone(); cloned = (Plot) newPlot.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart"); FineLoggerFactory.getLogger().error("Error In ColumnChart");
} }
}
return cloned; return cloned;
} }

2
designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaPlotPane.java

@ -68,11 +68,13 @@ public class VanChartAreaPlotPane extends AbstractVanChartTypePane {
} }
} }
Plot cloned = null; Plot cloned = null;
if(newPlot != null) {
try { try {
cloned = (Plot) newPlot.clone(); cloned = (Plot) newPlot.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In AreaChart"); FineLoggerFactory.getLogger().error("Error In AreaChart");
} }
}
return cloned; return cloned;
} }

5
designer-chart/src/main/java/com/fr/van/chart/bar/VanChartBarPlotPane.java

@ -65,10 +65,11 @@ public class VanChartBarPlotPane extends AbstractVanChartTypePane {
newPlot = (VanChartColumnPlot)barChart[i].getPlot(); newPlot = (VanChartColumnPlot)barChart[i].getPlot();
} }
} }
Plot cloned = null; Plot cloned = null;
try { try {
cloned = (Plot)newPlot.clone(); if(newPlot != null) {
cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart"); FineLoggerFactory.getLogger().error("Error In ColumnChart");
} }

5
designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java

@ -77,10 +77,11 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane {
newPlot = (VanChartBubblePlot)bubbleChart[i].getPlot(); newPlot = (VanChartBubblePlot)bubbleChart[i].getPlot();
} }
} }
Plot cloned = null; Plot cloned = null;
try { try {
cloned = (Plot)newPlot.clone(); if(newPlot != null) {
cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In BubbleChart"); FineLoggerFactory.getLogger().error("Error In BubbleChart");
} }

8
designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java

@ -37,8 +37,8 @@ public class ColumnIndependentVanChartInterface extends AbstractMultiCategoryVan
return VanChartColumnPlotPane.TITLE; return VanChartColumnPlotPane.TITLE;
} }
@Override // @Override
public ChartDataPane getChartDataPane(AttributeChangeListener listener) { // public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new MultiCategoryChartDataPane(listener); // return new MultiCategoryChartDataPane(listener);
} // }
} }

5
designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotPane.java

@ -66,10 +66,11 @@ public class VanChartColumnPlotPane extends AbstractVanChartTypePane {
newPlot = (VanChartColumnPlot)columnChart[i].getPlot(); newPlot = (VanChartColumnPlot)columnChart[i].getPlot();
} }
} }
Plot cloned = null; Plot cloned = null;
try { try {
cloned = (Plot)newPlot.clone(); if(newPlot != null) {
cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart"); FineLoggerFactory.getLogger().error("Error In ColumnChart");
} }

2
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java

@ -261,7 +261,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
} }
Plot cloned = null; Plot cloned = null;
try { try {
if(newPlot != null) {
cloned = (Plot) newPlot.clone(); cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ScatterChart"); FineLoggerFactory.getLogger().error("Error In ScatterChart");
} }

3
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java

@ -92,9 +92,10 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> {
pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
buttonPane.add(pane); buttonPane.add(pane);
} }
if(pane != null) {
pane.add(indexList_Y.get(i)); pane.add(indexList_Y.get(i));
} }
}
if(popupMenu != null){ if(popupMenu != null){
popupMenu.setVisible(false); popupMenu.setVisible(false);

8
designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java

@ -26,10 +26,10 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan
return "com/fr/design/images/form/toolbar/multiPie.png"; return "com/fr/design/images/form/toolbar/multiPie.png";
} }
@Override // @Override
public ChartDataPane getChartDataPane(AttributeChangeListener listener) { // public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new MultiPieChartDataPane(listener); // return new MultiPieChartDataPane(listener);
} // }
public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot){ public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot){
return new VanChartMultiPieSeriesPane(parent, plot); return new VanChartMultiPieSeriesPane(parent, plot);

6
designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java

@ -11,7 +11,6 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort;
import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.other.VanChartOtherPane;
@ -81,4 +80,9 @@ public class StructureIndependentVanChartInterface extends AbstractIndependentVa
public ConditionAttributesPane getPlotConditionPane(Plot plot) { public ConditionAttributesPane getPlotConditionPane(Plot plot) {
return new VanChartStructureConditionPane(plot); return new VanChartStructureConditionPane(plot);
} }
/* @Override
public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new StructureChartDataPane(listener);
}*/
} }

8
designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java

@ -91,8 +91,8 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa
return VanChartWordCloudTypePane.TITLE; return VanChartWordCloudTypePane.TITLE;
} }
@Override // @Override
public ChartDataPane getChartDataPane(AttributeChangeListener listener) { // public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new WordCloudChartDataPane(listener); // return new WordCloudChartDataPane(listener);
} // }
} }

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

@ -148,6 +148,9 @@ public class FormCreatorDropTarget extends DropTarget {
// 取消前一个焦点容器的提示渲染器 // 取消前一个焦点容器的提示渲染器
designer.setPainter(null); designer.setPainter(null);
} }
if (container == null) {
throw new IllegalArgumentException("container can not be null!");
}
//获取painter的时候要考虑布局之间嵌套的问题 //获取painter的时候要考虑布局之间嵌套的问题
XLayoutContainer xLayoutContainer = container.getTopLayout(); XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.getParent() != null if (xLayoutContainer != null && xLayoutContainer.getParent() != null
@ -215,7 +218,8 @@ public class FormCreatorDropTarget extends DropTarget {
* *
* @param dtde 事件 * @param dtde 事件
*/ */
public void dragEnter(DropTargetDragEvent dtde) { @Override
public synchronized void dragEnter(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
this.entering(loc.x, loc.y); this.entering(loc.x, loc.y);
} }
@ -225,7 +229,8 @@ public class FormCreatorDropTarget extends DropTarget {
* *
* @param dtde 事件 * @param dtde 事件
*/ */
public void dragOver(DropTargetDragEvent dtde) { @Override
public synchronized void dragOver(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
hovering(loc.x, loc.y); hovering(loc.x, loc.y);
} }
@ -235,7 +240,8 @@ public class FormCreatorDropTarget extends DropTarget {
* *
* @param dtde 事件 * @param dtde 事件
*/ */
public void dropActionChanged(DropTargetDragEvent dtde) { @Override
public synchronized void dropActionChanged(DropTargetDragEvent dtde) {
} }
/** /**
@ -243,7 +249,8 @@ public class FormCreatorDropTarget extends DropTarget {
* *
* @param dte 事件 * @param dte 事件
*/ */
public void dragExit(DropTargetEvent dte) { @Override
public synchronized void dragExit(DropTargetEvent dte) {
this.exiting(); this.exiting();
} }
@ -252,7 +259,8 @@ public class FormCreatorDropTarget extends DropTarget {
* *
* @param dtde 事件 * @param dtde 事件
*/ */
public void drop(DropTargetDropEvent dtde) { @Override
public synchronized void drop(DropTargetDropEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
this.adding(loc.x, loc.y); this.adding(loc.x, loc.y);
//针对在表单中拖入一个控件直接ctrl+s无反应 //针对在表单中拖入一个控件直接ctrl+s无反应

1
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1368,6 +1368,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
Thread.sleep(1500); Thread.sleep(1500);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage(), e); FRLogger.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
pane.setLayout(new BorderLayout()); pane.setLayout(new BorderLayout());

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

@ -20,7 +20,7 @@ public class FormToolBar {
} }
public void setButtonlist(List<FormToolBarButton> buttonlist) { public void setButtonlist(List<FormToolBarButton> buttonlist) {
if (buttonlist == null || buttonlist.size() < 0) { if (buttonlist == null) {
this.buttonlist = new ArrayList<FormToolBarButton>(); this.buttonlist = new ArrayList<FormToolBarButton>();
} else { } else {
this.buttonlist = buttonlist; this.buttonlist = buttonlist;

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

@ -118,7 +118,7 @@ public class FormToolBarPane extends BasicBeanPane<ToolBar> {
} }
private void setToolBar(List<FormToolBarButton> list) { private void setToolBar(List<FormToolBarButton> list) {
if (list == null || list.size() < 0) { if (list == null) {
return; return;
} }
this.removeAll(); this.removeAll();

1
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -765,6 +765,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
Thread.sleep(1500); Thread.sleep(1500);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
JPanel pane = new JPanel(); JPanel pane = new JPanel();
pane.setLayout(new BorderLayout()); pane.setLayout(new BorderLayout());

4
designer-form/src/main/java/com/fr/design/mainframe/widget/UITreeComboBox.java

@ -192,7 +192,11 @@ public class UITreeComboBox extends UIComboBox {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o != null) {
return o.getClass() == this.getClass(); return o.getClass() == this.getClass();
} else {
return false;
}
} }
} }

6
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java

@ -160,7 +160,7 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane {
boolean allowFullScreen = chartEditor.getMobileAttr().isAllowFullScreen(); boolean allowFullScreen = chartEditor.getMobileAttr().isAllowFullScreen();
this.allowFullCheckBox.setSelected(allowFullScreen); this.allowFullCheckBox.setSelected(allowFullScreen);
boolean isFunctionalWhenUnactivated = chartEditor.getMobileAttr().isFunctionalWhenUnactivated(); boolean isFunctionalWhenUnactivated = chartEditor.getMobileAttr().isFunctionalWhenUnactivated();
this.functionalWhenUnactivatedCheckBox.setSelected(isFunctionalWhenUnactivated); this.functionalWhenUnactivatedCheckBox.setSelected(!isFunctionalWhenUnactivated);
this.bindListeners2Widgets(); this.bindListeners2Widgets();
this.addAttributeChangeListener(changeListener); this.addAttributeChangeListener(changeListener);
@ -195,10 +195,10 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane {
mobileAttr.setZoomInAttr(ChartMobileFitAttrState.PROPORTION); mobileAttr.setZoomInAttr(ChartMobileFitAttrState.PROPORTION);
mobileAttr.setZoomOutAttr((ChartMobileFitAttrState) ((Item) zoomOutComboBox.getSelectedItem()).getValue()); mobileAttr.setZoomOutAttr((ChartMobileFitAttrState) ((Item) zoomOutComboBox.getSelectedItem()).getValue());
mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected()); mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected());
mobileAttr.setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); mobileAttr.setFunctionalWhenUnactivated(!functionalWhenUnactivatedCheckBox.isSelected());
}else { }else {
mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected()); mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected());
mobileAttr.setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); mobileAttr.setFunctionalWhenUnactivated(!functionalWhenUnactivatedCheckBox.isSelected());
} }
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来
} }

4
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java

@ -143,7 +143,7 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane {
this.maxHeightSpinner.setVisible(elementCaseEditor.isHeightRestrict()); this.maxHeightSpinner.setVisible(elementCaseEditor.isHeightRestrict());
this.maxHeightSpinner.setValue(elementCaseEditor.getHeightPercent()); this.maxHeightSpinner.setValue(elementCaseEditor.getHeightPercent());
this.allowFullCheckBox.setSelected(elementCaseEditor.isAllowFullScreen()); this.allowFullCheckBox.setSelected(elementCaseEditor.isAllowFullScreen());
this.functionalWhenUnactivatedCheckBox.setSelected(elementCaseEditor.isFunctionalWhenUnactivated()); this.functionalWhenUnactivatedCheckBox.setSelected(!elementCaseEditor.isFunctionalWhenUnactivated());
} }
@Override @Override
@ -170,7 +170,7 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane {
((ElementCaseEditor) xCreator.toData()).setAllowFullScreen(allowFullCheckBox.isSelected()); ((ElementCaseEditor) xCreator.toData()).setAllowFullScreen(allowFullCheckBox.isSelected());
break; break;
case "functionalWhenUnactivatedCheckBox": case "functionalWhenUnactivatedCheckBox":
((ElementCaseEditor) xCreator.toData()).setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); ((ElementCaseEditor) xCreator.toData()).setFunctionalWhenUnactivated(!functionalWhenUnactivatedCheckBox.isSelected());
} }
} }

Loading…
Cancel
Save