Browse Source

Pull request #1639: CHART-13733 折线图标记点新增自动

Merge in DESIGN/design from ~QINGHUI.LIU/design:release/10.0 to release/10.0

* commit 'ed3540a09a8ee525cdce463941d16a5a721550ca':
  删除instanceof判断
  CHART-13733 折线图标记点新增自动
feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
f004a3208e
  1. 35
      designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java
  2. 8
      designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java
  3. 17
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java
  4. 97
      designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java
  5. 19
      designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttCommonMarkerPane.java
  6. 19
      designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java
  7. 13
      designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapScatterMarkerPane.java

35
designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java

@ -8,9 +8,11 @@ import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.base.background.ColorBackground;
import com.fr.chart.chartglyph.Marker;
import com.fr.chart.chartglyph.NullMarker;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.ConfigHelper;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit;
import com.fr.general.FRFont;
@ -21,6 +23,8 @@ import java.awt.*;
* Combobox for selecting marker.
*/
public class MarkerComboBox extends UIComboBox {
private static final double TEXT_X_COORDINATES = 12d;
/**
* Constructor.
*
@ -65,15 +69,15 @@ public class MarkerComboBox extends UIComboBox {
g2d.setFont(FRContext.getDefaultValues().getFRFont());
if (marker != null) {
if (marker instanceof NullMarker) {
g2d.setColor(Color.black);
FRFont font = FRContext.getDefaultValues().getFRFont();
int resolution = ScreenResolution.getScreenResolution();
Font rfont = font.applyResolutionNP(resolution);
g2d.setFont(rfont);
FontMetrics fm = GraphHelper.getFontMetrics(rfont);
GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 12, (d.height - fm.getHeight()) / 2 + fm.getAscent());
boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M);
boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M);
if (isAutoMarker || isNullMarker) {
String text = isNullMarker
?Toolkit.i18nText("Fine-Design_Report_None")
:Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
paintTextMarker(g2d, d, text);
} else {
if (marker.getBackground() == null) {
marker.setBackground(ColorBackground.getInstance(Color.black));
@ -98,5 +102,16 @@ public class MarkerComboBox extends UIComboBox {
private Marker marker = null;
private boolean isSelected = false;
private void paintTextMarker(Graphics2D g2d, Dimension d, String text) {
g2d.setColor(Color.black);
FRFont font = FRContext.getDefaultValues().getFRFont();
int resolution = ScreenResolution.getScreenResolution();
Font rfont = font.applyResolutionNP(resolution);
g2d.setFont(rfont);
FontMetrics fm = GraphHelper.getFontMetrics(rfont);
GraphHelper.drawString(g2d, text, TEXT_X_COORDINATES, (d.height - fm.getHeight()) / 2 + fm.getAscent());
}
}
}

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

@ -2,13 +2,16 @@ package com.fr.van.chart.area;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.van.chart.column.VanChartCustomStackAndAxisConditionPane;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartLineTypePane;
import com.fr.van.chart.designer.component.VanChartLineTypePaneWithoutDashed;
import com.fr.van.chart.designer.component.VanChartMarkerPane;
import com.fr.van.chart.line.VanChartLineSeriesPane;
import javax.swing.JPanel;
@ -55,4 +58,9 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane {
protected VanChartLineTypePane getLineTypePane() {
return new VanChartLineTypePaneWithoutDashed();
}
protected JPanel createMarkerPane() {
markerPane = new VanChartMarkerPane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane);
}
}

17
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java

@ -1,6 +1,7 @@
package com.fr.van.chart.designer.component;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.plugin.chart.base.VanChartAttrMarker;
@ -25,13 +26,13 @@ public class VanChartMarkerPane extends BasicPane {
private CardLayout cardLayout;
private VanChartCommonMarkerPane commonMarkerPane;
private BasicBeanPane imageMarkerPane;
public VanChartMarkerPane() {
this.setLayout(new BorderLayout(0, 4));
String[] array = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rule"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")};
String[] array = new String[]{Toolkit.i18nText("Fine-Design_Chart_Rule"), Toolkit.i18nText("Fine-Design_Chart_Custom")};
commonORCustom = new UIButtonGroup<String>(array, array);
commonORCustom.addChangeListener(new ChangeListener() {
@ -56,8 +57,8 @@ public class VanChartMarkerPane extends BasicPane {
}
}
};
centerPane.add(commonMarkerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rule"));
centerPane.add(imageMarkerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom"));
centerPane.add(commonMarkerPane, Toolkit.i18nText("Fine-Design_Chart_Rule"));
centerPane.add(imageMarkerPane, Toolkit.i18nText("Fine-Design_Chart_Custom"));
layoutComponents();
}
@ -75,8 +76,10 @@ public class VanChartMarkerPane extends BasicPane {
}
protected VanChartCommonMarkerPane createCommonMarkerPane() {
return new VanChartCommonMarkerPane(){
protected double[] getcolumnSize () {
protected double[] getColumnSize() {
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
return new double[] {d, s};
@ -85,7 +88,7 @@ public class VanChartMarkerPane extends BasicPane {
}
protected void layoutComponents() {
this.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Point_Style"), commonORCustom), BorderLayout.NORTH);
this.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Point_Style"), commonORCustom), BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
}
@ -98,7 +101,7 @@ public class VanChartMarkerPane extends BasicPane {
}
protected String title4PopupWindow(){
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Marker");
return Toolkit.i18nText("Fine-Design_Chart_Marker");
}
public void populate(VanChartAttrMarker marker) {

97
designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java

@ -1,6 +1,7 @@
package com.fr.van.chart.designer.component.marker;
import com.fr.chart.chartglyph.Marker;
import com.fr.design.i18n.Toolkit;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
@ -12,17 +13,23 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.background.VanChartMarkerBackgroundPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by Mitisky on 16/5/19.
* 通用标记点,标记点类型/颜色/半径
*/
public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker> {
private MarkerComboBox markerPane;
private MarkerComboBox markerTypeComboBox;
private VanChartMarkerBackgroundPane markerFillColor;
private UISpinner radius;
private JPanel markerTypePane;
private JPanel markerConfigPane;
private static final MarkerType[] NORMAL_TYPES = {
MarkerType.MARKER_NULL,
MarkerType.MARKER_CIRCLE,
@ -46,6 +53,20 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
return normalMarkers;
}
protected static Marker[] getNormalMarkersWithAuto() {
if (normalMarkers == null) {
normalMarkers = new Marker[NORMAL_TYPES.length + 1];
normalMarkers[0] = Marker.createMarker(MarkerType.MARKER_AUTO);
int i = 1;
for (MarkerType markerType : NORMAL_TYPES) {
normalMarkers[i++] = Marker.createMarker(markerType);
}
}
return normalMarkers;
}
//没有无这个选项
private static final MarkerType[] MAP_TYPES = {
MarkerType.MARKER_CIRCLE,
@ -88,13 +109,16 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
return ganttMarkers;
}
public MarkerComboBox getMarkerTypeComboBox() {
return markerTypeComboBox;
}
protected MarkerComboBox getMarkerPane(){
return markerPane;
public UISpinner getRadius() {
return radius;
}
public VanChartCommonMarkerPane() {
markerPane = new MarkerComboBox(getMarkers());
markerTypeComboBox = new MarkerComboBox(getMarkers());
markerFillColor = new VanChartMarkerBackgroundPane(){
protected Component[][] getPaneComponents() {
return new Component[][]{
@ -106,42 +130,55 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
radius = new UISpinner(0, 100, 0.5, 0);
double p = TableLayout.PREFERRED;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
double[] row = {p, p, p};
Component[][] components = getUseComponent();
markerTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(getMarkerTypeComponent(), new double[]{p}, getColumnSize());
markerConfigPane = TableLayout4VanChartHelper.createGapTableLayoutPane(getMarkerConfigComponent(), new double[]{p, p}, getColumnSize());
JPanel jPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, getcolumnSize());
markerTypeComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkMarkType();
}
});
this.add(jPanel);
}
JPanel contentPane = new JPanel(new BorderLayout(0, 6));
protected double[] getcolumnSize () {
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
return new double[] {d, e};
}
contentPane.add(markerTypePane, BorderLayout.CENTER);
contentPane.add(markerConfigPane, BorderLayout.SOUTH);
protected Marker[] getMarkers() {
return getNormalMarkers();
this.add(contentPane);
}
protected Component[][] getUseComponent() {
return new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), markerPane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), markerFillColor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius")), radius},
protected Component[][] getMarkerTypeComponent() {
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), markerTypeComboBox}
};
}
protected Component[][] getUseComponentWithOutFillColor() {
return new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), markerPane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius")), radius},
protected Component[][] getMarkerConfigComponent() {
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), markerFillColor},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Radius")), radius}
};
}
private void checkMarkType() {
if (markerConfigPane != null && markerTypeComboBox != null) {
MarkerType type = MarkerType.parse(markerTypeComboBox.getSelectedMarkder().getMarkerType());
markerConfigPane.setVisible(!(type == MarkerType.MARKER_AUTO || type == MarkerType.MARKER_NULL));
}
}
protected double[] getColumnSize() {
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
return new double[] {d, e};
}
protected Marker[] getMarkers() {
return getNormalMarkers();
}
/**
* title应该是一个属性不只是对话框的标题时用到与其他组件结合时也会用得到
@ -162,9 +199,11 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
marker = new VanChartAttrMarker();
marker.setCommon(true);
}
markerPane.setSelectedMarker(Marker.createMarker(populateMarkType(marker)));
markerTypeComboBox.setSelectedMarker(Marker.createMarker(populateMarkType(marker)));
populateColor(marker);
radius.setValue(marker.getRadius());
checkMarkType();
}
protected void populateColor(VanChartAttrMarker marker) {
@ -188,7 +227,7 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
marker.setCommon(true);
updateColor(marker);
marker.setRadius(radius.getValue());
marker.setMarkerType(MarkerType.parse(markerPane.getSelectedMarkder().getMarkerType()));
marker.setMarkerType(MarkerType.parse(markerTypeComboBox.getSelectedMarkder().getMarkerType()));
}
protected void updateColor(VanChartAttrMarker marker){

19
designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttCommonMarkerPane.java

@ -3,6 +3,7 @@ package com.fr.van.chart.gantt.designer.style.series;
import com.fr.base.background.ColorBackground;
import com.fr.chart.chartglyph.Marker;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent;
import com.fr.plugin.chart.base.VanChartAttrMarker;
import com.fr.plugin.chart.marker.type.MarkerType;
@ -15,6 +16,8 @@ import java.awt.Component;
* Created by hufan on 2017/1/13.
*/
public class VanChartGanttCommonMarkerPane extends VanChartCommonMarkerPane {
private static final int PREFERRED_WIDTH = 100;
private ColorSelectBoxWithOutTransparent colorSelect;
@Override
@ -22,13 +25,17 @@ public class VanChartGanttCommonMarkerPane extends VanChartCommonMarkerPane {
return getGanttMarkers();
}
@Override
protected Component[][] getUseComponent() {
colorSelect = new ColorSelectBoxWithOutTransparent(100);
protected Component[][] getMarkerTypeComponent() {
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Shape")), getMarkerTypeComboBox()},
};
}
protected Component[][] getMarkerConfigComponent() {
colorSelect = new ColorSelectBoxWithOutTransparent(PREFERRED_WIDTH);
return new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Shape")), getMarkerPane()},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), colorSelect}
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), colorSelect}
};
}
@ -52,7 +59,7 @@ public class VanChartGanttCommonMarkerPane extends VanChartCommonMarkerPane {
@Override
public void setDefaultValue() {
getMarkerPane().setSelectedMarker(Marker.createMarker(MarkerType.MARKER_STAR));
getMarkerTypeComboBox().setSelectedMarker(Marker.createMarker(MarkerType.MARKER_STAR));
colorSelect.setSelectObject(new Color(248, 182, 44));
}

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

@ -1,10 +1,15 @@
package com.fr.van.chart.line;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.Marker;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartMarkerPane;
import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
import javax.swing.JPanel;
@ -44,4 +49,18 @@ public class VanChartLineSeriesPane extends VanChartAbstractPlotSeriesPane {
return null;
}
protected JPanel createMarkerPane() {
markerPane = new VanChartMarkerPane() {
protected VanChartCommonMarkerPane createCommonMarkerPane() {
return new VanChartCommonMarkerPane() {
protected Marker[] getMarkers() {
return getNormalMarkersWithAuto();
}
};
}
};
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane);
}
}

13
designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapScatterMarkerPane.java

@ -1,6 +1,8 @@
package com.fr.van.chart.map.designer.style.series;
import com.fr.chart.chartglyph.Marker;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane;
@ -11,9 +13,12 @@ import java.awt.Component;
* 只有标记点类型和半径
*/
public class VanChartMapScatterMarkerPane extends VanChartCommonMarkerPane {
@Override
protected Component[][] getUseComponent() {
return super.getUseComponentWithOutFillColor();
protected Component[][] getMarkerConfigComponent() {
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Radius")), getRadius()}
};
}
@Override
@ -22,7 +27,7 @@ public class VanChartMapScatterMarkerPane extends VanChartCommonMarkerPane {
}
@Override
protected double[] getcolumnSize () {
protected double[] getColumnSize() {
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
return new double[] {d, s};

Loading…
Cancel
Save