Browse Source

删除instanceof判断

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
ed3540a09a
  1. 29
      designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java

29
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.ScreenResolution;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.chart.chartglyph.Marker; import com.fr.chart.chartglyph.Marker;
import com.fr.chart.chartglyph.NullMarker; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.glyph.marker.VanChartAutoMarker; import com.fr.plugin.chart.ConfigHelper;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -23,6 +23,8 @@ import java.awt.*;
* Combobox for selecting marker. * Combobox for selecting marker.
*/ */
public class MarkerComboBox extends UIComboBox { public class MarkerComboBox extends UIComboBox {
private static final double TEXT_X_COORDINATES = 12d;
/** /**
* Constructor. * Constructor.
* *
@ -67,21 +69,15 @@ public class MarkerComboBox extends UIComboBox {
g2d.setFont(FRContext.getDefaultValues().getFRFont()); g2d.setFont(FRContext.getDefaultValues().getFRFont());
if (marker != null) { if (marker != null) {
boolean isAutoMarker = marker instanceof VanChartAutoMarker; boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M);
boolean isNullMarker = marker instanceof NullMarker; boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M);
if (isAutoMarker || isNullMarker) { 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 String text = isNullMarker
?Toolkit.i18nText("Fine-Design_Report_None") ?Toolkit.i18nText("Fine-Design_Report_None")
:Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); :Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
GraphHelper.drawString(g2d, text, 12, (d.height - fm.getHeight()) / 2 + fm.getAscent()); paintTextMarker(g2d, d, text);
} else { } else {
if (marker.getBackground() == null) { if (marker.getBackground() == null) {
marker.setBackground(ColorBackground.getInstance(Color.black)); marker.setBackground(ColorBackground.getInstance(Color.black));
@ -106,5 +102,16 @@ public class MarkerComboBox extends UIComboBox {
private Marker marker = null; private Marker marker = null;
private boolean isSelected = false; 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());
}
} }
} }
Loading…
Cancel
Save