zheng
5 years ago
4 changed files with 169 additions and 65 deletions
@ -0,0 +1,85 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.base.ScreenResolution; |
||||
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; |
||||
import com.fr.plugin.chart.type.LineType; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import javax.swing.JLabel; |
||||
import javax.swing.JList; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.Font; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
|
||||
/** |
||||
* Created by shine on 2019/08/30. |
||||
*/ |
||||
public class LineTypeComboBox extends UIComboBox { |
||||
|
||||
public LineTypeComboBox(LineType[] lineType) { |
||||
super(lineType); |
||||
|
||||
this.setRenderer(new CellRenderer()); |
||||
} |
||||
|
||||
private class CellRenderer extends UIComboBoxRenderer { |
||||
|
||||
private LineType lineType; |
||||
|
||||
public Component getListCellRendererComponent( |
||||
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
|
||||
JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
this.lineType = (LineType) value; |
||||
comp.setText(null); |
||||
return comp; |
||||
} |
||||
|
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
|
||||
Dimension d = getSize(); |
||||
g2d.setColor(getForeground()); |
||||
|
||||
switch (this.lineType) { |
||||
case NONE: |
||||
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, Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent()); |
||||
break; |
||||
case NORMAL: |
||||
GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2); |
||||
break; |
||||
case DASH: |
||||
GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2, Constants.LINE_DASH); |
||||
break; |
||||
default: |
||||
break; |
||||
|
||||
} |
||||
} |
||||
|
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(60, 16); |
||||
} |
||||
|
||||
public Dimension getMinimumSize() { |
||||
return getPreferredSize(); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
} |
@ -1,30 +1,19 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
|
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* 线-线型 |
||||
* 线型+线宽+空值断开 |
||||
*/ |
||||
public class VanChartLineWidthPane extends VanChartLineTypePane { |
||||
private static final long serialVersionUID = 4537158946119294689L; |
||||
|
||||
protected JPanel createContentPane(double p, double f) { |
||||
double[] row = {p, p, p}; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
double[] col = {f, e}; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null,null}, |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")), nullValueBreak}, |
||||
@Override |
||||
protected Component[][] createContentComponent(Component[] lineTypeComponent, Component[] lineWidthComponent, Component[] lineStyleComponent, Component[] nullValueBreakComponent) { |
||||
return new Component[][]{ |
||||
lineTypeComponent, |
||||
lineWidthComponent, |
||||
nullValueBreakComponent |
||||
}; |
||||
|
||||
return TableLayoutHelper.createTableLayoutPane(components, row, col); |
||||
} |
||||
} |
Loading…
Reference in new issue