From ed3540a09a8ee525cdce463941d16a5a721550ca Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Wed, 6 May 2020 16:27:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4instanceof=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/xcombox/MarkerComboBox.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java b/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java index e5154ba5e8..5909437c70 100644 --- a/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java @@ -8,8 +8,8 @@ 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.plugin.chart.glyph.marker.VanChartAutoMarker; +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; @@ -23,6 +23,8 @@ import java.awt.*; * Combobox for selecting marker. */ public class MarkerComboBox extends UIComboBox { + private static final double TEXT_X_COORDINATES = 12d; + /** * Constructor. * @@ -67,21 +69,15 @@ public class MarkerComboBox extends UIComboBox { g2d.setFont(FRContext.getDefaultValues().getFRFont()); if (marker != null) { - boolean isAutoMarker = marker instanceof VanChartAutoMarker; - boolean isNullMarker = marker instanceof NullMarker; + boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); + boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); if (isAutoMarker || isNullMarker) { - 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); String text = isNullMarker ?Toolkit.i18nText("Fine-Design_Report_None") :Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); - GraphHelper.drawString(g2d, text, 12, (d.height - fm.getHeight()) / 2 + fm.getAscent()); + paintTextMarker(g2d, d, text); } else { if (marker.getBackground() == null) { marker.setBackground(ColorBackground.getInstance(Color.black)); @@ -106,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()); + } } } \ No newline at end of file