Browse Source

CHART-13390 && CHART-13384 布局样式调整

feature/big-screen
白岳 5 years ago
parent
commit
897c9cbd2e
  1. 12
      designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java
  2. 19
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java

12
designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java

@ -177,6 +177,8 @@ public class ColorSchemeComboBox extends UIComboBox {
private static final int MAX_COUNT = 5; private static final int MAX_COUNT = 5;
private static final int BLANK = 1;
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension preferredSize = super.getPreferredSize(); Dimension preferredSize = super.getPreferredSize();
@ -198,7 +200,8 @@ public class ColorSchemeComboBox extends UIComboBox {
comp.setText(BLANK_SPACE + schemeName); comp.setText(BLANK_SPACE + schemeName);
} else { } else {
FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont()); FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont());
double width = (HEIGHT - 2 * Y) * MAX_COUNT; //宽度是5倍的高加上4倍的留白
double width = (HEIGHT - 2 * Y) * MAX_COUNT + BLANK * (MAX_COUNT - 1);
String fill = BLANK_SPACE; String fill = BLANK_SPACE;
//图形和文字之间留的宽度大于3倍的X //图形和文字之间留的宽度大于3倍的X
while (fontMetrics.stringWidth(fill) < width + 3 * X) { while (fontMetrics.stringWidth(fill) < width + 3 * X) {
@ -228,7 +231,7 @@ public class ColorSchemeComboBox extends UIComboBox {
private void drawGradient(Graphics2D g2d, List<Color> colors) { private void drawGradient(Graphics2D g2d, List<Color> colors) {
//上下留4px,宽度等于5倍高 //上下留4px,宽度等于5倍高
double height = HEIGHT - 2 * Y; double height = HEIGHT - 2 * Y;
double width = height * MAX_COUNT; double width = height * MAX_COUNT + BLANK * (MAX_COUNT - 1);
LinearGradientPaint linearGradientPaint = new LinearGradientPaint((float) X, (float) Y, (float) (X + width), (float) Y, new float[]{0f, 1f}, colors.toArray(new Color[colors.size()])); LinearGradientPaint linearGradientPaint = new LinearGradientPaint((float) X, (float) Y, (float) (X + width), (float) Y, new float[]{0f, 1f}, colors.toArray(new Color[colors.size()]));
g2d.setPaint(linearGradientPaint); g2d.setPaint(linearGradientPaint);
Rectangle2D rec = new Rectangle2D.Double(X, Y, width, height); Rectangle2D rec = new Rectangle2D.Double(X, Y, width, height);
@ -238,10 +241,11 @@ public class ColorSchemeComboBox extends UIComboBox {
private void drawCombineColor(Graphics2D g2d, List<Color> colors) { private void drawCombineColor(Graphics2D g2d, List<Color> colors) {
int size = Math.min(colors.size(), MAX_COUNT); int size = Math.min(colors.size(), MAX_COUNT);
double height = HEIGHT - 2 * Y; double height = HEIGHT - 2 * Y;
double width = height * MAX_COUNT / size; //加上1px留白
double width = ((height + BLANK) * MAX_COUNT - size) / size;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
g2d.setPaint(colors.get(i)); g2d.setPaint(colors.get(i));
Rectangle2D rec = new Rectangle2D.Double(X + width * i, Y, width, height); Rectangle2D rec = new Rectangle2D.Double(X + (width + BLANK) * i, Y, width, height);
g2d.fill(rec); g2d.fill(rec);
} }
} }

19
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java

@ -52,7 +52,15 @@ public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
styleSelectBox = new ColorSchemeComboBox(); styleSelectBox = new ColorSchemeComboBox();
customPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); customPane = new JPanel(FRGUIPaneFactory.createBorderLayout()) {
@Override
public Dimension getPreferredSize() {
if (!gradientSelect) {
return colorAdjustPane.getPreferredSize();
}
return colorGradient.getPreferredSize();
}
};
changeColorSetPane = new JPanel(cardLayout = new CardLayout()); changeColorSetPane = new JPanel(cardLayout = new CardLayout());
changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient");
@ -119,18 +127,11 @@ public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> {
} }
protected void initLayout() { protected void initLayout() {
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(getContentPane(), BorderLayout.CENTER); this.add(getContentPane(), BorderLayout.CENTER);
} }
@Override
public Dimension getPreferredSize() {
if (gradientSelect) {
return new Dimension(225, 80);
}
return super.getPreferredSize();
}
protected JPanel getContentPane() { protected JPanel getContentPane() {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;

Loading…
Cancel
Save