|
|
|
@ -3,22 +3,14 @@
|
|
|
|
|
*/ |
|
|
|
|
package com.fr.design.gui.icombobox; |
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
|
import com.fr.base.ScreenResolution; |
|
|
|
|
import com.fr.general.FRFont; |
|
|
|
|
import com.fr.stable.Constants; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.Font; |
|
|
|
|
import java.awt.FontMetrics; |
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.awt.geom.GeneralPath; |
|
|
|
|
import java.awt.geom.Point2D; |
|
|
|
|
import javax.swing.DefaultComboBoxModel; |
|
|
|
|
import javax.swing.JLabel; |
|
|
|
|
import javax.swing.JList; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -59,6 +51,13 @@ public class LineComboBox extends UIComboBox {
|
|
|
|
|
this.setSelectedItem(new Integer(style)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected String toStringFromStyle(int style) { |
|
|
|
|
if (style == Constants.LINE_NONE) { |
|
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* CellRenderer. |
|
|
|
|
*/ |
|
|
|
@ -67,31 +66,27 @@ public class LineComboBox extends UIComboBox {
|
|
|
|
|
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
|
JLabel comp= (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
|
this.style = ((Integer) value).intValue(); |
|
|
|
|
comp.setText(null); |
|
|
|
|
String displayString = toStringFromStyle(style); |
|
|
|
|
if (StringUtils.isNotEmpty(displayString)) { |
|
|
|
|
comp.setText(" " + displayString); |
|
|
|
|
} else { |
|
|
|
|
comp.setText(null); |
|
|
|
|
} |
|
|
|
|
return comp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) { |
|
|
|
|
super.paint(g); |
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
|
|
|
|
|
|
Dimension d = getSize(); |
|
|
|
|
g2d.setColor(getForeground()); |
|
|
|
|
|
|
|
|
|
FRFont font = FRContext.getDefaultValues().getFRFont(); |
|
|
|
|
int resolution = ScreenResolution.getScreenResolution(); |
|
|
|
|
Font rfont = font.applyResolutionNP(resolution); |
|
|
|
|
g2d.setFont(rfont); |
|
|
|
|
FontMetrics fm = GraphHelper.getFontMetrics(rfont); |
|
|
|
|
if (style == Constants.LINE_NONE) { |
|
|
|
|
//draw "none" string
|
|
|
|
|
GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2D + fm.getAscent()); |
|
|
|
|
} else { |
|
|
|
|
if (StringUtils.isEmpty(toStringFromStyle(style))) { |
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
|
|
|
|
|
|
Dimension d = getSize(); |
|
|
|
|
g2d.setColor(getForeground()); |
|
|
|
|
GraphHelper.drawLine(g2d, 4, d.height / 2D, d.width - 8D, d.height / 2D, style); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式.
|
|
|
|
|
drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D)); |
|
|
|
|
|
|
|
|
|
if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式.
|
|
|
|
|
drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|