Browse Source

CHART-9435 仪表盘字符大小自动处理

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
625dcd8f58
  1. 3
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java
  2. 3
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java
  3. 64
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java
  4. 86
      designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java
  5. 56
      designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java
  6. 34
      designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java
  7. 5
      designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java

3
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java

@ -32,9 +32,10 @@ public class ChartTextAttrNoColorPane extends ChartTextAttrPane{
}
protected void initComponents() {
initFontSizes();
fontColor = new UIColorButton();
fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
fontSizeComboBox = new UIComboBox(Font_Sizes);
fontSizeComboBox = new UIComboBox(getFontSizes());
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));

3
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java

@ -31,9 +31,10 @@ public class ChartTextAttrNoFontSizePane extends ChartTextAttrPane {
}
protected void initComponents() {
initFontSizes();
fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
fontColor = new UIColorButton();
fontSizeComboBox = new UIComboBox(Font_Sizes);
fontSizeComboBox = new UIComboBox(getFontSizes());
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));

64
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui.style;
import com.fr.base.BaseUtils;
import com.fr.base.Utils;
import com.fr.chart.base.TextAttr;
import com.fr.design.i18n.Toolkit;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.UIObserverListener;
@ -12,6 +13,7 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
@ -27,23 +29,49 @@ public class ChartTextAttrPane extends BasicPane {
private static final long serialVersionUID = 6731679928019436869L;
private static final int FONT_START = 6;
private static final int FONT_END = 72;
private static final String auto = Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
private static final int autoSizeInt = 0;
private String[] fontSizes;
private boolean isFontSizeAuto;
protected UIComboBox fontNameComboBox;
protected UIComboBox fontSizeComboBox;
protected UIToggleButton bold;
protected UIToggleButton italic;
protected UIColorButton fontColor;
public static Integer[] Font_Sizes = new Integer[FONT_END-FONT_START+1];
static{
for(int i = FONT_START; i <= FONT_END; i++){
Font_Sizes [i - FONT_START] = new Integer(i);
}
}
public ChartTextAttrPane() {
this.isFontSizeAuto = false;
initComponents();
}
/**
* 标题
public ChartTextAttrPane(boolean isFontSizeAuto) {
this.isFontSizeAuto = isFontSizeAuto;
initComponents();
}
public String[] getFontSizes() {
return fontSizes;
}
protected void initFontSizes() {
if (isFontSizeAuto) {
fontSizes = new String[FONT_END - FONT_START + 2];
fontSizes[0] = auto;
for (int i = 1; i < fontSizes.length; i++) {
fontSizes[i] = Utils.objectToString(i + FONT_START);
}
} else {
fontSizes = new String[FONT_END - FONT_START + 1];
for (int i = 0; i < fontSizes.length; i++) {
fontSizes[i] = Utils.objectToString(i + FONT_START);
}
}
}
/* 标题
* @return 标题
*/
public String title4PopupWindow() {
@ -85,7 +113,11 @@ public class ChartTextAttrPane extends BasicPane {
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
if (fontSizeComboBox != null) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
if (frFont.getSize() == autoSizeInt) {
fontSizeComboBox.setSelectedItem(auto);
} else {
fontSizeComboBox.setSelectedItem(frFont.getSize() + "");
}
}
if (fontColor != null) {
fontColor.setColor(frFont.getForeground());
@ -108,10 +140,12 @@ public class ChartTextAttrPane extends BasicPane {
/**
* 更新字
*
* @return 更新字
*/
public FRFont updateFRFont() {
int style = Font.PLAIN;
float size;
if (bold.isSelected() && !italic.isSelected()) {
style = Font.BOLD;
} else if (!bold.isSelected() && italic.isSelected()) {
@ -119,8 +153,13 @@ public class ChartTextAttrPane extends BasicPane {
} else if (bold.isSelected() && italic.isSelected()) {
style = 3;
}
return FRFont.getInstance(Utils.objectToString(fontNameComboBox.getSelectedItem()), style,
Float.valueOf(Utils.objectToString(fontSizeComboBox.getSelectedItem())), fontColor.getColor());
if (ComparatorUtils.equals(fontSizeComboBox.getSelectedItem(), auto)) {
size = Float.parseFloat(Utils.objectToString(autoSizeInt));
} else {
size = Float.parseFloat(Utils.objectToString(fontSizeComboBox.getSelectedItem()));
}
return FRFont.getInstance(Utils.objectToString(fontNameComboBox.getSelectedItem()), style, size, fontColor.getColor());
}
public void setEnabled(boolean enabled) {
@ -132,8 +171,9 @@ public class ChartTextAttrPane extends BasicPane {
}
protected void initComponents() {
initFontSizes();
fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
fontSizeComboBox = new UIComboBox(Font_Sizes);
fontSizeComboBox = new UIComboBox(fontSizes);
fontColor = new UIColorButton();
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));

86
designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java

@ -1,9 +1,7 @@
package com.fr.van.chart.designer.style.label;
import com.fr.chart.chartattr.Plot;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.label.LabelContentPaneWithCate;
@ -11,14 +9,12 @@ import com.fr.van.chart.designer.component.label.LabelContentPaneWithPercent;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.Component;
/**
* 仪表盘的分类多指针时或者百分比标签
*/
public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabelDetailPane {
//todo 重新整理这个面板
private static final long serialVersionUID = 5176535960949074945L;
@ -27,15 +23,20 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe
}
protected double[] getLabelPaneRowSize(Plot plot, double p) {
return hasLabelPosition(plot) ? new double[]{p,p,p} : new double[]{p,p};
if (hasLabelAlign(plot)) {
return new double[]{p, p, p, p};
}
if (hasLabelPosition(plot)) {
return new double[]{p, p, p};
}
return new double[]{p, p};
}
protected void initToolTipContentPane(Plot plot) {
initGaugeStyle(plot);
switch (gaugeStyle){
switch (getGaugeStyle()) {
case POINTER:
dataLabelContentPane = new LabelContentPaneWithCate(parent, VanChartGaugeCateOrPercentLabelDetailPane.this);
break;
case POINTER_SEMI:
dataLabelContentPane = new LabelContentPaneWithCate(parent, VanChartGaugeCateOrPercentLabelDetailPane.this);
break;
@ -45,13 +46,13 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe
}
}
protected boolean getFontSizeAuto() {
return ComparatorUtils.equals(getGaugeStyle(), GaugeStyle.RING) || ComparatorUtils.equals(getGaugeStyle(), GaugeStyle.SLOT);
}
protected boolean hasLabelPosition(Plot plot) {
initGaugeStyle(plot);
switch (gaugeStyle){
switch (getGaugeStyle()) {
case RING:
return false;
case SLOT:
return false;
default:
@ -60,67 +61,10 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe
}
protected double[] getLabelStyleRowSize(double p) {
switch (gaugeStyle){
case RING:
return new double[]{p, p};
case SLOT:
return new double[] {p, p};
default:
return new double[] {p};
}
}
protected JPanel createTableLayoutPaneWithTitle(String title, Component component) {
return TableLayout4VanChartHelper.createTableLayoutPaneWithSmallTitle(title, component);
}
protected Component[][] getLabelStyleComponents(Plot plot) {
initGaugeStyle(plot);
if (gaugeStyle == GaugeStyle.RING || gaugeStyle == GaugeStyle.SLOT) {
UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT);
return new Component[][]{
new Component[]{text,style},
new Component[]{textFontPane,null},
};
} else {
return new Component[][]{
new Component[]{textFontPane, null},
};
}
}
protected ChartTextAttrPane initTextFontPane () {
//todo 需要再整理下
if (gaugeStyle == GaugeStyle.RING || gaugeStyle == GaugeStyle.SLOT){
return new ChartTextAttrPane(){
protected double[] getRowSize () {
double p = TableLayout.PREFERRED;
return new double[]{p, p};
}
protected Component[][] getComponents(JPanel buttonPane) {
return new Component[][]{
new Component[]{null, fontNameComboBox},
new Component[]{null, buttonPane}
};
}
};
} else {
return new ChartTextAttrPane(){
protected double[] getRowSize () {
double p = TableLayout.PREFERRED;
return new double[]{p, p};
}
protected Component[][] getComponents(JPanel buttonPane) {
UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT);
return new Component[][]{
new Component[]{text, fontNameComboBox},
new Component[]{null, buttonPane}
};
}
};
}
}
}

56
designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java

@ -21,25 +21,33 @@ import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* Created by mengao on 2017/8/13.
*/
public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane {
protected GaugeStyle gaugeStyle;
protected UIButtonGroup<Integer> align;
private GaugeStyle gaugeStyle;
private UIButtonGroup<Integer> align;
private JPanel alignPane;
protected Integer[] oldAlignValues;
private Integer[] oldAlignValues;
public VanChartGaugeLabelDetailPane(Plot plot, VanChartStylePane parent) {
super(plot, parent);
}
protected void initGaugeStyle(Plot plot) {
if (gaugeStyle == null) {
gaugeStyle = ((VanChartGaugePlot) plot).getGaugeStyle();
protected void initLabelDetailPane(Plot plot) {
setGaugeStyle(((VanChartGaugePlot) plot).getGaugeStyle());
super.initLabelDetailPane(plot);
}
public GaugeStyle getGaugeStyle() {
return gaugeStyle;
}
public void setGaugeStyle(GaugeStyle gaugeStyle) {
this.gaugeStyle = gaugeStyle;
}
protected JPanel createLabelStylePane(double[] row, double[] col, Plot plot) {
@ -52,8 +60,26 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane {
return TableLayoutHelper.createTableLayoutPane(getLabelStyleComponents(plot), row, col);
}
protected boolean getFontSizeAuto() {
return false;
}
protected ChartTextAttrPane initTextFontPane() {
return new ChartTextAttrPane();
return new ChartTextAttrPane(getFontSizeAuto()) {
protected double[] getRowSize() {
double p = TableLayout.PREFERRED;
return new double[]{p, p};
}
protected Component[][] getComponents(JPanel buttonPane) {
UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT);
return new Component[][]{
new Component[]{text, fontNameComboBox},
new Component[]{null, buttonPane}
};
}
};
}
protected JPanel getLabelPositionPane(Component[][] comps, double[] row, double[] col) {
@ -74,6 +100,7 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane {
new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null},
};
} else {
return super.getLabelPaneComponents(plot, p, columnSize);
}
}
@ -136,6 +163,12 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane {
return new TwoTuple<>(names, values);
}
protected Component[][] getLabelStyleComponents(Plot plot) {
return new Component[][]{
new Component[]{textFontPane, null},
};
}
protected void checkPane() {
String verticalTitle = hasLabelAlign(getPlot())
? Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical")
@ -145,13 +178,19 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane {
checkAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal"));
}
private boolean hasLabelAlign(Plot plot) {
protected void checkStyleUse() {
textFontPane.setVisible(true);
textFontPane.setPreferredSize(new Dimension(0, 60));
}
protected boolean hasLabelAlign(Plot plot) {
return ComparatorUtils.equals(gaugeStyle, GaugeStyle.THERMOMETER) && !((VanChartGaugePlot) plot).getGaugeDetailStyle().isHorizontalLayout();
}
public void populate(AttrLabelDetail detail) {
super.populate(detail);
style.setSelectedIndex(1);
if (hasLabelAlign(this.getPlot()) && align != null) {
align.setSelectedItem(detail.getAlign());
}
@ -160,6 +199,7 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane {
public void update(AttrLabelDetail detail) {
super.update(detail);
detail.setCustom(true);
if (align != null && align.getSelectedItem() != null) {
detail.setAlign(align.getSelectedItem());
} else if (align != null) {

34
designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java

@ -1,6 +1,8 @@
package com.fr.van.chart.designer.style.label;
import com.fr.chart.chartattr.Plot;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.label.LabelContentPaneWithCateValue;
import com.fr.van.chart.designer.component.label.LabelContentPaneWithOutCate;
@ -20,11 +22,8 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP
}
protected void initToolTipContentPane(Plot plot) {
initGaugeStyle(plot);
switch (gaugeStyle){
switch (getGaugeStyle()) {
case POINTER:
dataLabelContentPane = new LabelContentPaneWithOutCate(parent, VanChartGaugeValueLabelDetailPane.this);
break;
case POINTER_SEMI:
dataLabelContentPane = new LabelContentPaneWithOutCate(parent, VanChartGaugeValueLabelDetailPane.this);
break;
@ -35,10 +34,8 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP
}
protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) {
initGaugeStyle(plot);
switch (gaugeStyle){
switch (getGaugeStyle()) {
case POINTER:
return getLabelPaneComponentsWithBackground(plot, p, columnSize);
case POINTER_SEMI:
return getLabelPaneComponentsWithBackground(plot, p, columnSize);
default:
@ -55,10 +52,8 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP
}
protected double[] getLabelPaneRowSize(Plot plot, double p) {
initGaugeStyle(plot);
switch (gaugeStyle){
switch (getGaugeStyle()) {
case POINTER:
return new double[]{p,p,p,p,p};
case POINTER_SEMI:
return new double[]{p, p, p, p, p};
default:
@ -66,24 +61,15 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP
}
}
protected boolean hasLabelPosition(Plot plot) {
initGaugeStyle(plot);
switch (gaugeStyle){
case THERMOMETER:
return true;
default:
return false;
protected boolean getFontSizeAuto() {
return !ComparatorUtils.equals(getGaugeStyle(), GaugeStyle.THERMOMETER);
}
protected boolean hasLabelPosition(Plot plot) {
return getGaugeStyle() == GaugeStyle.THERMOMETER;
}
protected JPanel createTableLayoutPaneWithTitle(String title, Component component) {
return TableLayout4VanChartHelper.createTableLayoutPaneWithSmallTitle(title, component);
}
protected Component[][] getLabelStyleComponents(Plot plot) {
return new Component[][]{
new Component[]{textFontPane,null},
};
}
}

5
designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java

@ -59,7 +59,10 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
public VanChartPlotLabelDetailPane(Plot plot, VanChartStylePane parent) {
this.parent = parent;
this.plot = plot;
initLabelDetailPane(plot);
}
protected void initLabelDetailPane (Plot plot) {
this.setLayout(new BorderLayout());
initToolTipContentPane(plot);
JPanel contentPane = createLabelPane(plot);
@ -269,7 +272,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
checkPositionEnabled();
}
private void checkStyleUse() {
protected void checkStyleUse() {
textFontPane.setVisible(style.getSelectedIndex() == 1);
textFontPane.setPreferredSize(style.getSelectedIndex() == 1 ? new Dimension(0, 60) : new Dimension(0, 0));
}

Loading…
Cancel
Save